using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using QMAPP.Common.Web.Controllers; using QMFrameWork.WebUI.Attribute; using QMAPP.FJC.Web.Models.ProductPetrospect; using QMFrameWork.Data; using QMAPP.ServicesAgent; using QMAPP.FJC.Entity.Operation; using QMAPP.Entity; using QMFrameWork.WebUI.DataSource; using QMFrameWork.Common.Serialization; using System.Text; using QMAPP.FJC.Entity.Andon; using QMAPP.FJC.Web.Models.Andon; using QMAPP.FJC.Web.Models.Package; namespace QMAPP.FJC.Web.Controllers { /// /// 作 用:线边库存大屏显示 /// 作 者:周晓东 /// 编写日期:20180530 /// public class PackageDisplayController : QController { /// /// 初始化 /// /// [HandleException] public ActionResult List(bool? callBack) { PackageModel model = new PackageModel(); //获取数据 ServiceAgent wcfAgent = this.GetServiceAgent(); //List list = wcfAgent.InvokeServiceFunction>("PackageBLL_GetList"); //model.MainDataHtml = this.GetMainTableHtml(list); return View("List", model); } #region 获取Main数据 /// /// 获取数据-Main /// /// public ActionResult GetMainDatas() { PackageModel model = new PackageModel(); try { //DataPage page = new DataPage(); //page.PageIndex = pageIndex + 1; //page.PageSize = 15; //获取待发运FIS数据 ServiceAgent wcfAgent = this.GetServiceAgent(); List list = wcfAgent.InvokeServiceFunction>("PackageBLL_GetList"); //List list = JsonConvertHelper.GetDeserialize>(page.Result.ToString()); //int count = list.Count; //for (int i = count; i < 15; i++) //{ // list.Add(new Package { 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.MainDataHtml = this.GetMainTableHtml(list); //return Json(list.GroupBy(p => new { p.WORKCENTER_NAME, p.WORKCELL_NAME, p.WORKCELL_CODE, p.WORKCENTER_CODE }),JsonRequestBehavior.AllowGet); return Json(list, JsonRequestBehavior.AllowGet); } catch (Exception ex) { throw ex; } } private string GetMainTableHtml(List list) { StringBuilder htmlBuilder = new StringBuilder(); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); foreach (Package item in list) { string colorClass = "tblQTYhead_td_blue"; if (item.CAPACITY_USINGCOUNT"); htmlBuilder.AppendFormat("", colorClass, item.MATERIAL_CODE); htmlBuilder.AppendFormat("", colorClass, item.MATERIAL_NAME); htmlBuilder.AppendFormat("", colorClass, item.MATERIAL_CODE); htmlBuilder.AppendFormat("", colorClass, item.CAPACITY_USINGCOUNT); htmlBuilder.Append(""); } htmlBuilder.Append("
操作物料名称物料号剩余数量
{1}{1}{1}
"); return htmlBuilder.ToString(); } #endregion #region 获取Child数据 /// /// 获取数据-Child /// /// public ActionResult GetChildDatas() { PackageModel model = new PackageModel(); try { //DataPage page = new DataPage(); //page.PageIndex = pageIndex + 1; //page.PageSize = 15; string materialCode = Request.Params["materialCode"]; //获取待发运FIS数据 ServiceAgent wcfAgent = this.GetServiceAgent(); List list = wcfAgent.InvokeServiceFunction>("PackageBLL_GetMaterialCodeList", materialCode); //List list = JsonConvertHelper.GetDeserialize>(page.Result.ToString()); //int count = list.Count; //for (int i = count; i < 15; i++) //{ // list.Add(new Package { 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.ChildDataHtml = this.GetChildTableHtml(list); return Json(model); } catch (Exception ex) { throw ex; } } private string GetChildTableHtml(List list) { StringBuilder htmlBuilder = new StringBuilder(); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); foreach (Package item in list) { string colorClass = "tblQTYhead_td_blue"; htmlBuilder.Append(""); htmlBuilder.AppendFormat("", colorClass, item.PID); htmlBuilder.AppendFormat("", colorClass, item.PACKAGECODE); htmlBuilder.AppendFormat("", colorClass, item.CAPACITY); htmlBuilder.AppendFormat("", colorClass, item.USINGCOUNT); htmlBuilder.Append(""); } htmlBuilder.Append("
操作箱号装箱数量已使用数量
{1}{1}{1}
"); return htmlBuilder.ToString(); } #endregion #region 编辑 /// /// 编辑载入 /// /// 处理结果 [HandleException] public ActionResult Edit() { PackageModel model = new PackageModel(); string ID = Request.Params["PID"]; Package Entity = new Package(); ServiceAgent wcfAgent = this.GetServiceAgent(); DataResult result = new DataResult(); try { if (string.IsNullOrEmpty(ID) == false) { //修改获取原数据 Entity.PID = ID; var pg = wcfAgent.InvokeServiceFunction("PackageBLL_Get", Entity); if (pg == null) { SetMessage(result.Msg); return View("Edit", model); } model = CopyToModel(pg); } return View("Edit", model); } catch (Exception ex) { throw ex; } } /// /// 保存 /// /// /// 处理结果 [HttpPost] [HandleException] [ValidateInput(false)] public ActionResult Save(PackageModel saveModel) { Package Entity = null; ServiceAgent wcfAgent = this.GetServiceAgent(); DataResult result = new DataResult(); try { Entity = CopyToModel(saveModel); if (string.IsNullOrEmpty(Entity.PID) == true) { } else { //修改 result = wcfAgent.InvokeServiceFunction>("PackageBLL_Update", Entity); if (result.IsSuccess == false) { SetMessage("修改失败!"); return View("Edit", saveModel); } } return this.GetJsViewResult(string.Format("parent.RefreshChildTable('{0}');parent.showTitle('{1}');parent.closeAppWindow1();", Entity.MATERIAL_CODE, AppResource.SaveMessge)); } catch (Exception ex) { throw ex; } } #endregion #region 获取组织结构下拉列表数据源 /// /// 因为直接登录,放到DictController不好用。 /// /// 数据源 [HandleException] public ActionResult GetFixedComboxSource() { string kind = Request.Params["kind"]; //单雨春 是否带空项 2014年9月26日 bool isWithEmpty = string.IsNullOrEmpty(Request.Params["WithEmpty"]) ? true : false; Dictionary dicts = null; try { ComboboxResult model = new ComboboxResult(); //单雨春 是否带空项 2014年9月26日 if (isWithEmpty) { model.Add(new ComboboxItem { ID = "", Text = " " }); } QMFrameWork.Common.Util.ModelDictionaryHandler.TryGetModelDictionary(kind.ToString(), out dicts); foreach (string key in dicts.Keys) { model.Add(new ComboboxItem { ID = key, Text = dicts[key] }); } return Content(model.ToString()); } catch (Exception ex) { throw ex; } } #endregion #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 } }