天津投入产出系统后端
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.
 
 
 
 
 
 

364 lines
13 KiB

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
{
/// <summary>
/// 作 用:线边库存大屏显示
/// 作 者:周晓东
/// 编写日期:20180530
///</summary>
public class PackageDisplayController : QController
{
/// <summary>
/// 初始化
/// </summary>
/// <returns></returns>
[HandleException]
public ActionResult List(bool? callBack)
{
PackageModel model = new PackageModel();
//获取数据
ServiceAgent wcfAgent = this.GetServiceAgent();
//List<Package> list = wcfAgent.InvokeServiceFunction<List<Package>>("PackageBLL_GetList");
//model.MainDataHtml = this.GetMainTableHtml(list);
return View("List", model);
}
#region 获取Main数据
/// <summary>
/// 获取数据-Main
/// </summary>
/// <returns></returns>
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<Entity.Package.PackageSummary> list = wcfAgent.InvokeServiceFunction<List<Entity.Package.PackageSummary>>("PackageBLL_GetList");
//List<Package> list = JsonConvertHelper.GetDeserialize<List<Package>>(page.Result.ToString());
//int count = list.Count;
//for (int i = count; i < 15; i++)
//{
// list.Add(new Package { 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.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<Package> list)
{
StringBuilder htmlBuilder = new StringBuilder();
htmlBuilder.Append("<table cellpadding=0 cellspacing=0 id=\"tbMain\" style=\"width:99%;\">");
htmlBuilder.Append("<tr>");
htmlBuilder.Append("<td style=\"width:10%;\" class=\"tblQTYhead_td\">操作</td>");
htmlBuilder.Append("<td style=\"width:40%;\" class=\"tblQTYhead_td\">物料名称</td>");
htmlBuilder.Append("<td style=\"width:30%;\" class=\"tblQTYhead_td\">物料号</td>");
htmlBuilder.Append("<td class=\"tblQTYhead_td\">剩余数量</td>");
htmlBuilder.Append("</tr>");
foreach (Package item in list)
{
string colorClass = "tblQTYhead_td_blue";
if (item.CAPACITY_USINGCOUNT<item.CAPACITY_SET)
{
colorClass = "tblFisbody_td_red";
}
htmlBuilder.Append("<tr>");
htmlBuilder.AppendFormat("<td class=\"{0}\"><input type=\"button\" value=\"编辑\" onclick=\"clickeMain('{1}')\"></td>", colorClass, item.MATERIAL_CODE);
htmlBuilder.AppendFormat("<td class=\"{0}\">{1}</td>", colorClass, item.MATERIAL_NAME);
htmlBuilder.AppendFormat("<td class=\"{0}\">{1}</td>", colorClass, item.MATERIAL_CODE);
htmlBuilder.AppendFormat("<td class=\"{0}\">{1}</td>", colorClass, item.CAPACITY_USINGCOUNT);
htmlBuilder.Append("</tr>");
}
htmlBuilder.Append("</table>");
return htmlBuilder.ToString();
}
#endregion
#region 获取Child数据
/// <summary>
/// 获取数据-Child
/// </summary>
/// <returns></returns>
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<Package> list = wcfAgent.InvokeServiceFunction<List<Package>>("PackageBLL_GetMaterialCodeList", materialCode);
//List<Package> list = JsonConvertHelper.GetDeserialize<List<Package>>(page.Result.ToString());
//int count = list.Count;
//for (int i = count; i < 15; i++)
//{
// list.Add(new Package { 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.ChildDataHtml = this.GetChildTableHtml(list);
return Json(model);
}
catch (Exception ex)
{
throw ex;
}
}
private string GetChildTableHtml(List<Package> list)
{
StringBuilder htmlBuilder = new StringBuilder();
htmlBuilder.Append("<table cellpadding=0 cellspacing=0 id=\"tbChild\" style=\"width:99%;\">");
htmlBuilder.Append("<tr>");
htmlBuilder.Append("<td style=\"width:10%;\" class=\"tblQTYhead_td\">操作</td>");
htmlBuilder.Append("<td style=\"width:40%;\" class=\"tblQTYhead_td\">箱号</td>");
htmlBuilder.Append("<td style=\"width:30%;\" class=\"tblQTYhead_td\">装箱数量</td>");
htmlBuilder.Append("<td class=\"tblQTYhead_td\">已使用数量</td>");
htmlBuilder.Append("</tr>");
foreach (Package item in list)
{
string colorClass = "tblQTYhead_td_blue";
htmlBuilder.Append("<tr>");
htmlBuilder.AppendFormat("<td class=\"{0}\"><input type=\"button\" value=\"编辑\" onclick=\"clickeEdit('{1}')\"><input type=\"button\" value=\"返回\" onclick=\"clickeReturn()\"></td>", colorClass, item.PID);
htmlBuilder.AppendFormat("<td class=\"{0}\">{1}</td>", colorClass, item.PACKAGECODE);
htmlBuilder.AppendFormat("<td class=\"{0}\">{1}</td>", colorClass, item.CAPACITY);
htmlBuilder.AppendFormat("<td class=\"{0}\">{1}</td>", colorClass, item.USINGCOUNT);
htmlBuilder.Append("</tr>");
}
htmlBuilder.Append("</table>");
return htmlBuilder.ToString();
}
#endregion
#region 编辑
/// <summary>
/// 编辑载入
/// </summary>
/// <returns>处理结果</returns>
[HandleException]
public ActionResult Edit()
{
PackageModel model = new PackageModel();
string ID = Request.Params["PID"];
Package Entity = new Package();
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult<Package> result = new DataResult<Package>();
try
{
if (string.IsNullOrEmpty(ID) == false)
{
//修改获取原数据
Entity.PID = ID;
var pg = wcfAgent.InvokeServiceFunction<Package>("PackageBLL_Get", Entity);
if (pg == null)
{
SetMessage(result.Msg);
return View("Edit", model);
}
model = CopyToModel<PackageModel, Package>(pg);
}
return View("Edit", model);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 保存
/// </summary>
/// <param name="model"></param>
/// <returns>处理结果</returns>
[HttpPost]
[HandleException]
[ValidateInput(false)]
public ActionResult Save(PackageModel saveModel)
{
Package Entity = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult<int> result = new DataResult<int>();
try
{
Entity = CopyToModel<Package, PackageModel>(saveModel);
if (string.IsNullOrEmpty(Entity.PID) == true)
{
}
else
{
//修改
result = wcfAgent.InvokeServiceFunction<DataResult<int>>("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 获取组织结构下拉列表数据源
/// <summary>
/// 因为直接登录,放到DictController不好用。
/// </summary>
/// <returns>数据源</returns>
[HandleException]
public ActionResult GetFixedComboxSource()
{
string kind = Request.Params["kind"];
//单雨春 是否带空项 2014年9月26日
bool isWithEmpty = string.IsNullOrEmpty(Request.Params["WithEmpty"]) ? true : false;
Dictionary<string, string> 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
}
}