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
{
///
/// 发运大屏监控
/// 作 者:李炳海
/// 编写日期:2017年09月27日
///
public class ShipmentMonitorController : Controller
{
///
/// 初始化
///
///
public ActionResult MonitorDisplay()
{
ShipmentMonitorModel model = new ShipmentMonitorModel();
model = this.GetFisDatas(model, 0);
model = this.GetOnTheWayDatas(model, 0);
return View("MonitorDisplayView",model);
}
#region 获取待发运FIS数据
///
/// 获取待发运FIS数据
///
///
public ActionResult ShowFisDatas(int pageIndex)
{
try
{
ShipmentMonitorModel model=new ShipmentMonitorModel();
model = this.GetFisDatas(model, pageIndex);
return Json(model);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 获取待发运FIS数据
///
///
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("ShipmentMonitorBLL_GetShipmentFisList", page);
List list = JsonConvertHelper.GetDeserialize>(page.Result.ToString());
int count = list.Count;
for (int i = count; i < 15; i++)
{
list.Add(new ShipmentFisData { VWSEQ = " ", DisplayColor = "GREEN", CARTYPE = " ", PRODNO = " ", R100_ASSY_DESC = " ", ONLINEDATE = " " });
}
//设置返回结果
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 list)
{
StringBuilder htmlBuilder = new StringBuilder();
htmlBuilder.Append("");
htmlBuilder.Append("");
htmlBuilder.Append("顺序号 | ");
htmlBuilder.Append("车型 | ");
htmlBuilder.Append("零件号 | ");
htmlBuilder.Append("总成描述 | ");
htmlBuilder.Append("上线时间 | ");
htmlBuilder.Append("
");
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("");
htmlBuilder.AppendFormat("{1} | ",colorClass,item.VWSEQ);
htmlBuilder.AppendFormat("{1} | ", colorClass, item.CARTYPE);
htmlBuilder.AppendFormat("{1} | ", colorClass, item.PRODNO);
htmlBuilder.AppendFormat("{1} | ", colorClass, item.R100_ASSY_DESC);
htmlBuilder.AppendFormat("{1} | ", colorClass, item.ONLINEDATE);
htmlBuilder.Append("
");
}
htmlBuilder.Append("
");
return htmlBuilder.ToString();
}
#endregion
///
/// 获取预计在途数据
///
///
public ActionResult ShowOnTheWayDatas(int pageIndex)
{
try
{
ShipmentMonitorModel model = new ShipmentMonitorModel();
model = this.GetOnTheWayDatas(model, pageIndex);
return Json(model);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 获取预计在途数据
///
///
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("ShipmentMonitorBLL_GetOnTheWayQTYList", page);
List list = JsonConvertHelper.GetDeserialize>(page.Result.ToString());
int count = list.Count;
for (int i = count; i < 8; i++)
{
list.Add(new OnTheWayQTYData { PRODNO = " ", R100_ASSY_DESC = " ", QTY = " " });
}
//设置返回结果
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 list)
{
StringBuilder htmlBuilder = new StringBuilder();
htmlBuilder.Append("");
htmlBuilder.Append("");
htmlBuilder.Append("零件号 | ");
htmlBuilder.Append("总成描述 | ");
htmlBuilder.Append("数量 | ");
htmlBuilder.Append("
");
foreach (OnTheWayQTYData item in list)
{
htmlBuilder.Append("");
htmlBuilder.AppendFormat("{0} | ", item.PRODNO);
htmlBuilder.AppendFormat("{0} | ", item.R100_ASSY_DESC);
htmlBuilder.AppendFormat("{0} | ", item.QTY);
htmlBuilder.Append("
");
}
htmlBuilder.Append("
");
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
}
}