天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

266 lines
9.0 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Text;
using QMFrameWork.Data;
using QMAPP.FJC.Entity.ShipmentMonitor;
using QMFrameWork.WebUI.Attribute;
using QMFrameWork.WebUI.DataSource;
using QMFrameWork.Common.Serialization;
using QMAPP.Common.Web.Models;
using QMAPP.ServicesAgent;
using QMAPP.Common.Web.Controllers;
using QMAPP.FJC.Web.Models.Monitor;
namespace QMAPP.FJC.Web.Controllers
{
/// <summary>
/// 发运大屏监控
/// 作 者:李炳海
/// 编写日期:2017年09月27日
/// </summary>
public class ShipmentMonitorController : Controller
{
/// <summary>
/// 初始化
/// </summary>
/// <returns></returns>
public ActionResult MonitorDisplay()
{
ShipmentMonitorModel model = new ShipmentMonitorModel();
model = this.GetFisDatas(model, 0);
model = this.GetOnTheWayDatas(model, 0);
return View("MonitorDisplayView",model);
}
#region 获取待发运FIS数据
/// <summary>
/// 获取待发运FIS数据
/// </summary>
/// <returns></returns>
public ActionResult ShowFisDatas(int pageIndex)
{
try
{
ShipmentMonitorModel model=new ShipmentMonitorModel();
model = this.GetFisDatas(model, pageIndex);
return Json(model);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 获取待发运FIS数据
/// </summary>
/// <returns></returns>
public ShipmentMonitorModel GetFisDatas(ShipmentMonitorModel model, int pageIndex)
{
try
{
DataPage page = new DataPage();
page.PageIndex = pageIndex + 1;
page.PageSize = 15;
//获取待发运FIS数据
ServiceAgent wcfAgent = this.GetServiceAgent();
page = wcfAgent.InvokeServiceFunction<DataPage>("ShipmentMonitorBLL_GetShipmentFisList", page);
List<ShipmentFisData> list = JsonConvertHelper.GetDeserialize<List<ShipmentFisData>>(page.Result.ToString());
int count = list.Count;
for (int i = count; i < 15; i++)
{
list.Add(new ShipmentFisData { VWSEQ = "&nbsp;", DisplayColor = "GREEN", CARTYPE = "&nbsp;", PRODNO = "&nbsp;", R100_ASSY_DESC = "&nbsp;", ONLINEDATE = "&nbsp;" });
}
//设置返回结果
model.FisDataPageIndex = page.PageIndex;
model.FisDataPageCount = page.PageCount;
model.FisDataPageInfo = page.PageIndex.ToString() + "/" + page.PageCount.ToString();
model.FisDataHtml = this.GetFISTableHtml(list);
return model;
}
catch (Exception ex)
{
throw ex;
}
}
private string GetFISTableHtml(List<ShipmentFisData> list)
{
StringBuilder htmlBuilder = new StringBuilder();
htmlBuilder.Append("<table cellpadding=0 cellspacing=0 id=\"tblQTY\" style=\"width:99%;\">");
htmlBuilder.Append("<tr>");
htmlBuilder.Append("<td class=\"tblFishead_td\">顺序号</td>");
htmlBuilder.Append("<td class=\"tblFishead_td\">车型</td>");
htmlBuilder.Append("<td class=\"tblFishead_td\">零件号</td>");
htmlBuilder.Append("<td class=\"tblFishead_td\">总成描述</td>");
htmlBuilder.Append("<td class=\"tblFishead_td\">上线时间</td>");
htmlBuilder.Append("</tr>");
foreach (ShipmentFisData item in list)
{
string colorClass = "";
switch (item.DisplayColor)
{
case "RED":
colorClass = "tblFisbody_td_red";
break;
case "YELLOW":
colorClass = "tblFisbody_td_yellow";
break;
case "GREEN":
colorClass = "tblFisbody_td_green";
break;
}
htmlBuilder.Append("<tr>");
htmlBuilder.AppendFormat("<td class=\"{0}\">{1}</td>",colorClass,item.VWSEQ);
htmlBuilder.AppendFormat("<td class=\"{0}\">{1}</td>", colorClass, item.CARTYPE);
htmlBuilder.AppendFormat("<td class=\"{0}\">{1}</td>", colorClass, item.PRODNO);
htmlBuilder.AppendFormat("<td class=\"{0}\">{1}</td>", colorClass, item.R100_ASSY_DESC);
htmlBuilder.AppendFormat("<td class=\"{0}\">{1}</td>", colorClass, item.ONLINEDATE);
htmlBuilder.Append("</tr>");
}
htmlBuilder.Append("</table>");
return htmlBuilder.ToString();
}
#endregion
/// <summary>
/// 获取预计在途数据
/// </summary>
/// <returns></returns>
public ActionResult ShowOnTheWayDatas(int pageIndex)
{
try
{
ShipmentMonitorModel model = new ShipmentMonitorModel();
model = this.GetOnTheWayDatas(model, pageIndex);
return Json(model);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 获取预计在途数据
/// </summary>
/// <returns></returns>
public ShipmentMonitorModel GetOnTheWayDatas(ShipmentMonitorModel model,int pageIndex)
{
try
{
DataPage page = new DataPage();
page.PageIndex = pageIndex + 1;
page.PageSize = 8;
//获取待发运FIS数据
ServiceAgent wcfAgent = this.GetServiceAgent();
page = wcfAgent.InvokeServiceFunction<DataPage>("ShipmentMonitorBLL_GetOnTheWayQTYList", page);
List<OnTheWayQTYData> list = JsonConvertHelper.GetDeserialize<List<OnTheWayQTYData>>(page.Result.ToString());
int count = list.Count;
for (int i = count; i < 8; i++)
{
list.Add(new OnTheWayQTYData { PRODNO = "&nbsp;", R100_ASSY_DESC = "&nbsp;", QTY = "&nbsp;" });
}
//设置返回结果
model.OnTheWayDataPageIndex = page.PageIndex;
model.OnTheWayDataPageCount = page.PageCount;
model.OnTheWayDataPageInfo = page.PageIndex.ToString() + "/" + page.PageCount.ToString();
model.OnTheWayDataHtml = this.GetOnTheWayTableHtml(list);
return model;
}
catch (Exception ex)
{
throw ex;
}
}
private string GetOnTheWayTableHtml(List<OnTheWayQTYData> list)
{
StringBuilder htmlBuilder = new StringBuilder();
htmlBuilder.Append("<table cellpadding=0 cellspacing=0 id=\"tblQTY\" style=\"width:99%;\">");
htmlBuilder.Append("<tr>");
htmlBuilder.Append("<td class=\"tblQTYhead_td\">零件号</td>");
htmlBuilder.Append("<td class=\"tblQTYhead_td\">总成描述</td>");
htmlBuilder.Append("<td class=\"tblQTYhead_td\">数量</td>");
htmlBuilder.Append("</tr>");
foreach (OnTheWayQTYData item in list)
{
htmlBuilder.Append("<tr>");
htmlBuilder.AppendFormat("<td class=\"tblQTYhead_td_blue\">{0}</td>", item.PRODNO);
htmlBuilder.AppendFormat("<td class=\"tblQTYhead_td_blue\">{0}</td>", item.R100_ASSY_DESC);
htmlBuilder.AppendFormat("<td class=\"tblQTYhead_td_blue\">{0}</td>", item.QTY);
htmlBuilder.Append("</tr>");
}
htmlBuilder.Append("</table>");
return htmlBuilder.ToString();
}
#region 获取服务代理
public ServicesAgent.ServiceAgent GetServiceAgent()
{
try
{
//创建代理
ServicesAgent.ServiceAgent agent = new ServicesAgent.ServiceAgent();
//设置凭据
agent.ClientCredential = new QMFrameWork.ServiceInterface.CredentialInfo();
QMAPP.Entity.Sys.LoginInfo login = AccountController.GetLoginInfo();
if (login != null)
{
agent.ClientCredential.UserID = login.UserID;
agent.ClientCredential.UserName = login.LoginUserID;
agent.ClientCredential.PassWord = login.PassWord;
}
agent.ClientCredential.CredentialID = System.Web.HttpContext.Current.Session.SessionID;
return agent;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}