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

450 lines
17 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QMAPP.Common.Web.Controllers;
using QMFrameWork.WebUI.Attribute;
using QMAPP.MD.Web.Models;
using QMAPP.Entity;
using QMAPP.MD.Entity;
using QMAPP.ServicesAgent;
using QMFrameWork.Data;
using QMFrameWork.WebUI.DataSource;
using QMFrameWork.Common.Serialization;
using QMFrameWork.WebUI.Util;
namespace QMAPP.MD.Web.Controllers
{
/// <summary>
/// 模块名称:工艺路线
/// 作 者:郭兆福
/// 编写日期:2017年05月12日
/// </summary>
public class ProcessRouteController : QController
{
/// <summary>
/// 空数据项显示值
/// </summary>
public string EmptyItemTitle = " ";
#region 获取列表
/// <summary>
/// 加载列表
/// </summary>
/// <returns>结果</returns>
[HandleException]
public ActionResult List(bool? callBack)
{
ProcessRouteModel seachModel = new ProcessRouteModel();
if (callBack == true)
TryGetSelectBuffer<ProcessRouteModel>(out seachModel);
seachModel.rownumbers = false;
seachModel.url = "/ProcessRoute/GetList";
return View("ProcessRouteList", seachModel);
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="callBack">是否回调</param>
/// <returns>列表</returns>
[HandleException]
public ActionResult GetList(bool? callBack)
{
ProcessRouteModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
ProcessRoute condition = null;
DataResult<DataPage> pageResult = new DataResult<DataPage>();
try
{
//获取查询对象
seachModel = GetModel<ProcessRouteModel>();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer<ProcessRouteModel>(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer<ProcessRouteModel>(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
condition = CopyToModel<ProcessRoute, ProcessRouteModel>(seachModel);
#region wcf服务统一接口
pageResult = wcfAgent.InvokeServiceFunction<DataResult<DataPage>>("ProcessRouteBLL_GetList", condition, page);
if (pageResult.IsSuccess == false)
{
SetMessage(pageResult.Msg);
return List(true);
}
DateGridResult<ProcessRoute> result = new DateGridResult<ProcessRoute>();
result.Total = pageResult.Result.RecordCount;
result.Rows = JsonConvertHelper.GetDeserialize<List<ProcessRoute>>(pageResult.Result.Result.ToString());
#endregion
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 编辑
/// <summary>
/// 编辑载入
/// </summary>
/// <returns>处理结果</returns>
[HandleException]
public ActionResult Edit()
{
ProcessRouteModel model = new ProcessRouteModel();
string ID = Request.Params["PID"];
ProcessRoute Entity = new ProcessRoute();
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult<ProcessRoute> result = new DataResult<ProcessRoute>();
try
{
if (string.IsNullOrEmpty(ID) == false)
{
//修改获取原数据
Entity.PID = ID;
result = wcfAgent.InvokeServiceFunction<DataResult<ProcessRoute>>("ProcessRouteBLL_Get", Entity);
if (result.IsSuccess == false)
{
SetMessage(result.Msg);
return View("ProcessRouteEdit", model);
}
model = CopyToModel<ProcessRouteModel, ProcessRoute>(result.Result);
}
return View("ProcessRouteEdit", model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 保存
/// <summary>
/// 保存
/// </summary>
/// <param name="model"></param>
/// <returns>处理结果</returns>
[HttpPost]
[HandleException]
[ValidateInput(false)]
public ActionResult Save(ProcessRouteModel saveModel)
{
ProcessRoute Entity = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult<int> result = new DataResult<int>();
try
{
Entity = CopyToModel<ProcessRoute, ProcessRouteModel>(saveModel);
if (string.IsNullOrEmpty(Entity.PID) == true)
{
//新增
result = wcfAgent.InvokeServiceFunction<DataResult<int>>("ProcessRouteBLL_Insert", Entity);
}
else
{
//修改
result = wcfAgent.InvokeServiceFunction<DataResult<int>>("ProcessRouteBLL_Update", Entity);
}
if (result.IsSuccess == false)
{
SetMessage(result.Msg);
return View("ProcessRouteEdit", saveModel);
}
return this.GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();", AppResource.SaveMessge));
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 删除
/// <summary>
/// 删除
/// </summary>
/// <returns>结果</returns>
[HttpPost]
[HandleException]
public ActionResult Delete(ProcessRouteModel saveMode)
{
string selectKey = Request.Form["selectKey"];
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult<int> result = new DataResult<int>();
try
{
result = wcfAgent.InvokeServiceFunction<DataResult<int>>("ProcessRouteBLL_Delete", selectKey);
if (result.IsSuccess == false)
{
SetMessage(result.Msg);
return List(true);
}
SetMessage(AppResource.DeleteMessage);
return List(true);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 配置工艺路线工序
/// <summary>
/// 加载列表
/// </summary>
/// <param name="callBack"></param>
/// <returns></returns>
public ActionResult ProcessRouteWorkCellList(bool? callBack)
{
ProcessRouteWorkCellModel processRouteModel = new ProcessRouteWorkCellModel();
string routeCode = Request.Params["ROUTE_CODE_PARAM"];
string routeVer = Request.Params["ROUTE_VER_PARAM"];
string factory = Request.Params["FACTORY_CODE"];
if (callBack == true)
TryGetSelectBuffer<ProcessRouteWorkCellModel>(out processRouteModel);
processRouteModel.rownumbers = false;
processRouteModel.url = "/ProcessRoute/GetProcessRouteWorkCellList?ROUTE_CODE_PARAM=" + routeCode + "&ROUTE_VER_PARAM=" + routeVer;
processRouteModel.ROUTE_CODE = routeCode;
processRouteModel.VER_NUM = routeVer;
processRouteModel.FACTORY_CODE = factory;
return View("ProcessRouteWorkCellList", processRouteModel);
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="callBack"></param>
/// <returns></returns>
public ActionResult GetProcessRouteWorkCellList(bool? callBack)
{
string routeCode = Request.Params["ROUTE_CODE_PARAM"];
ProcessRouteWorkCellModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
ProcessRouteWorkCell condition = null;
DataResult<DataPage> pageResult = new DataResult<DataPage>();
try
{
//获取查询对象
seachModel = GetModel<ProcessRouteWorkCellModel>();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer<ProcessRouteWorkCellModel>(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer<ProcessRouteWorkCellModel>(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
if (string.IsNullOrEmpty(seachModel.ROUTE_CODE))
{
seachModel.ROUTE_CODE = routeCode;
}
condition = CopyToModel<ProcessRouteWorkCell, ProcessRouteWorkCellModel>(seachModel);
#region wcf服务统一接口
pageResult = wcfAgent.InvokeServiceFunction<DataResult<DataPage>>
("ProcessRouteBLL_GetProcessRouteWorkCellData", condition, page);
if (pageResult.IsSuccess == false)
{
SetMessage(pageResult.Msg);
return ProcessRouteWorkCellList(true);
}
DateGridResult<ProcessRouteWorkCell> result = new DateGridResult<ProcessRouteWorkCell>();
result.Total = pageResult.Result.RecordCount;
result.Rows = JsonConvertHelper.GetDeserialize<List<ProcessRouteWorkCell>>(pageResult.Result.Result.ToString());
#endregion
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 配置添加页面
/// </summary>
/// <returns></returns>
public ActionResult ProcessRouteWorkCellEdit()
{
ProcessRouteWorkCellModel model = new ProcessRouteWorkCellModel();
model = GetModel<ProcessRouteWorkCellModel>();
model.ROUTE_CODE = Request.Params["ROUTE_CODE_PARAM"];
model.VER_NUM = Request.Params["ROUTE_VER_PARAM"];
try
{
#region 获取前置工序下拉列表
model.workCellSeqModel.Editable = true;
//获取前置工序下拉列表
model.workCellSeqModel.ComboBoxList = new Dictionary<string, Dictionary<string, string>>();
Dictionary<string, string> workCells = this.GetWorkCellComboBoxList(model.ROUTE_CODE);
model.workCellSeqModel.ComboBoxList.Add("PRE_WORKCELL_CODE", workCells);
#endregion
return View("ProcessRouteWorkCellEdit", model);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 获取明细数据
/// </summary>
/// <returns></returns>
[HandleException]
public ActionResult GetDetailList()
{
DataGridResult<ProcessRouteWorkCellSeq> result = new DataGridResult<ProcessRouteWorkCellSeq>();
result.Total = 0;
result.Rows = SessionHelper.GetSession("ProcessRouteWorkCell_Detail") as List<ProcessRouteWorkCellSeq>;
SessionHelper.SessionDispose("ProcessRouteWorkCell_Detail");
if (result.Rows == null)
result.Rows = new List<ProcessRouteWorkCellSeq>();
return Content(result.GetJsonSource());
}
/// <summary>
/// 保存工序配置
/// </summary>
/// <returns></returns>
public ActionResult ProcessRouteWorkCellSave(ProcessRouteWorkCellModel saveModel, ProcessRouteWorkCellSeqModel saveInfo)
{
ProcessRouteWorkCell entity = null;
ProcessRouteWorkCellSeq info = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult<int> result = new DataResult<int>();
try
{
entity = CopyToModel<ProcessRouteWorkCell, ProcessRouteWorkCellModel>(saveModel);
entity.Details = JsonConvertHelper.DeserializeObject<List<ProcessRouteWorkCellSeq>>(saveModel.DetailValue);
//工序顺序信息
info = CopyToModel<ProcessRouteWorkCellSeq, ProcessRouteWorkCellSeqModel>(saveInfo);
if (string.IsNullOrEmpty(entity.PID) == true)
{
//新增
result = wcfAgent.InvokeServiceFunction<DataResult<int>>
("ProcessRouteBLL_ProcessRouteWorkCellSave", entity);
}
if (result.IsSuccess == false)
{
SetMessage(result.Msg);
return View("ProcessRouteWorkCellEdit", saveModel);
}
return this.GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();", AppResource.SaveMessge));
}
catch (Exception)
{
throw;
}
}
/// <summary>
/// 删除
/// </summary>
/// <returns>结果</returns>
[HttpPost]
[HandleException]
public ActionResult ProcessRouteWorkCellDelete(ProcessRouteWorkCellModel saveMode)
{
string selectKey = Request.Form["selectKey"];
string ROUTE_CODE = Request.Form["ROUTE_CODE_PARAM"];
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult<int> result = new DataResult<int>();
try
{
result = wcfAgent.InvokeServiceFunction<DataResult<int>>("ProcessRouteBLL_ProcessRouteWorkCellDelete", selectKey, ROUTE_CODE);
if (result.IsSuccess == false)
{
SetMessage(result.Msg);
return ProcessRouteWorkCellList(true);
}
SetMessage(AppResource.DeleteMessage);
return ProcessRouteWorkCellList(true);
}
catch (Exception ex)
{
throw ex;
}
}
#region 获取当前工艺路线下的工序下拉列表
/// <summary>
/// 获取当前工艺路线下的工序下拉列表
/// </summary>
/// <returns>数据源</returns>
[HandleException]
public ActionResult GetProcessComboxSource()
{
List<ProcessRouteWorkCell> list = new List<ProcessRouteWorkCell>();
ServiceAgent wcfAgent = this.GetServiceAgent();
string routeCode = Request.Params["ROUTE_CODE_PARAM"];
try
{
var dataResult = wcfAgent.InvokeServiceFunction<DataResult<List<ProcessRouteWorkCell>>>
("ProcessRouteBLL_GeProcessRouteWorkCellList", new ProcessRouteWorkCell() { ROUTE_CODE = routeCode });
foreach (ProcessRouteWorkCell item in dataResult.Result)
{
list.Add(item);
}
list.Insert(0, new ProcessRouteWorkCell { WORKCELL_CODE = "", WORKCELL_NAME = " " });
return Content(QMFrameWork.Common.Serialization.JsonConvertHelper.GetSerializes(list));
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#endregion
#region 获取当前工艺路线下的工序下拉列表
/// <summary>
/// 获取工序下拉列表
/// </summary>
/// <param name="routeCode">工艺路线编码</param>
/// <returns></returns>
public Dictionary<string, string> GetWorkCellComboBoxList(string routeCode)
{
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
//获取工序型下拉列表
Dictionary<string, string> listWorkCell = new Dictionary<string, string>();
DataResult<List<ProcessRouteWorkCell>> result = agent.InvokeServiceFunction<DataResult<List<ProcessRouteWorkCell>>>("ProcessRouteBLL_GeProcessRouteWorkCellList", new ProcessRouteWorkCell() { ROUTE_CODE = routeCode });
listWorkCell.Add(this.EmptyItemTitle, this.EmptyItemTitle);
foreach (ProcessRouteWorkCell item in result.Result)
{
listWorkCell.Add(item.WORKCELL_CODE, item.WORKCELL_CODE + "/" + item.WORKCELL_NAME);
}
return listWorkCell;
}
#endregion
}
}