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

581 lines
22 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.FJC.Web.Models.TianJin;
using QMFrameWork.Data;
using QMAPP.ServicesAgent;
using QMAPP.FJC.Entity.TianJin;
using QMAPP.Entity;
using QMFrameWork.WebUI.DataSource;
using QMFrameWork.Common.Serialization;
using System.Data;
using QMAPP.Common.Web.Models;
using QMAPP.FJC.Entity.Basic;
using QMAPP.MD.Entity;
using QMAPP.FJC.BLL.TianJin;
namespace QMAPP.FJC.Web.Controllers
{
/// <summary>
/// 天津门板发运计划
/// 作 者:张松男
/// 时 间:2021年12月28日
/// </summary>
public class TJDoorPlankPlanController : QController
{
#region 获取信息
/// <summary>
/// 加载列表
/// </summary>
/// <returns>结果</returns>
[HandleException]
public ActionResult List(bool? callback)
{
TJDoorPlankPlanModel seachModel = new TJDoorPlankPlanModel();
seachModel.PLANTIMESTART = DateTime.Now.Date.AddDays(-10).ToString("yyyy-MM-dd HH:mm:ss");
seachModel.PLANTIMEEND = DateTime.Now.Date.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss");
seachModel.PLAN_STATE = "0";
seachModel.ImmediateSearch = false;
if (callback == true)
TryGetSelectBuffer<TJDoorPlankPlanModel>(out seachModel);
seachModel.rownumbers = false;
seachModel.url = "/TJDoorPlankPlan/GetList";
return View("DoorPlankPlanList", seachModel);
}
#endregion
#region 获取列表
/// <summary>
/// 获取列表
/// </summary>
/// <param name="callBack">是否回调</param>
/// <returns>列表</returns>
[HandleException]
public ActionResult GetList(bool? callBack)
{
TJDoorPlankPlanModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
TJOrderPlan condition = null;
DataResult<DataPage> pageResult = new DataResult<DataPage>();
try
{
//获取查询对象
seachModel = GetModel<TJDoorPlankPlanModel>();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer<TJDoorPlankPlanModel>(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer<TJDoorPlankPlanModel>(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
condition = CopyToModel<TJOrderPlan, TJDoorPlankPlanModel>(seachModel);
#region wcf服务统一接口
pageResult = wcfAgent.InvokeServiceFunction<DataResult<DataPage>>("TJDoorPlankPlanBLL_GetList", condition, page);
if (pageResult.IsSuccess == false)
{
SetMessage(pageResult.Msg);
return List(true);
}
DateGridResult<TJOrderPlan> result = new DateGridResult<TJOrderPlan>();
result.Total = pageResult.Result.RecordCount;
result.Rows = JsonConvertHelper.GetDeserialize<List<TJOrderPlan>>(pageResult.Result.Result.ToString());
#endregion
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 编辑
/// <summary>
/// 编辑载入
/// </summary>
/// <returns>处理结果</returns>
[HandleException]
public ActionResult Edit()
{
TJDoorPlankPlanModel model = new TJDoorPlankPlanModel();
string ID = Request.Params["PID"];
TJOrderPlan Entity = new TJOrderPlan();
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult<TJOrderPlan> result = new DataResult<TJOrderPlan>();
try
{
if (string.IsNullOrEmpty(ID) == false)
{
//修改获取原数据
Entity.PID = ID;
result = wcfAgent.InvokeServiceFunction<DataResult<TJOrderPlan>>("TJDoorPlankPlanBLL_Get", Entity);
if (result.IsSuccess == false)
{
SetMessage(result.Msg);
return View("DoorPlankPlanEdit", model);
}
model = CopyToModel<TJDoorPlankPlanModel, TJOrderPlan>(result.Result);
}
return View("DoorPlankPlanEdit", model);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 保存
/// </summary>
/// <param name="model"></param>
/// <returns>处理结果</returns>
[HttpPost]
[HandleException]
[ValidateInput(false)]
public ActionResult Save(TJDoorPlankPlanModel saveModel)
{
TJOrderPlan Entity = null;
string TYPE = Request.Form["ORDER_TYPE"];
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult<int> result = new DataResult<int>();
try
{
Entity = CopyToModel<TJOrderPlan, TJDoorPlankPlanModel>(saveModel);
if (string.IsNullOrEmpty(Entity.PID) == true)
{
//新增
//Entity.ORDER_TYPE = TYPE;
result = wcfAgent.InvokeServiceFunction<DataResult<int>>("TJDoorPlankPlanBLL_Insert", Entity);
if (result.IsSuccess == false)
{
SetMessage("计划单号已存在!");
return View("DoorPlankPlanEdit", saveModel);
}
}
else
{
//修改
result = wcfAgent.InvokeServiceFunction<DataResult<int>>("TJDoorPlankPlanBLL_Update", Entity);
if (result.IsSuccess == false)
{
SetMessage(result.Msg);
return View("DoorPlankPlanEdit", 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(TJOrderPlan model)
{
string selectKey = Request.Form["selectKey"];
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult<int> result = new DataResult<int>();
try
{
result = wcfAgent.InvokeServiceFunction<DataResult<int>>("TJDoorPlankPlanBLL_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>
/// <returns></returns>
[HttpPost]
[HandleException]
public ActionResult PutOut(TJOrderPlan model)
{
string selectKey = Request.Form["selectKey"];
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult<int> result = new DataResult<int>();
result = wcfAgent.InvokeServiceFunction<DataResult<int>>("TJDoorPlankPlanBLL_PutOut", selectKey);
if (result.IsSuccess == false)
{
SetMessage(result.Msg);
return List(true);
}
SetMessage(AppResource.PutOutMessage);
return List(true);
}
#endregion
#region 导出excel
/// <summary>
/// 导出excel
/// </summary>
/// <returns>结果</returns>
[HttpPost]
public ActionResult ExportExcel()
{
TJDoorPlankPlanModel seachModel = null;
TJOrderPlan condition = null;
DataTable exportDt = new DataTable();
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
//获取查询对象
seachModel = GetModel<TJDoorPlankPlanModel>();
condition = CopyToModel<TJOrderPlan, TJDoorPlankPlanModel>(seachModel);
//获取数据
TJDoorPlankPlanBLL dp = new TJDoorPlankPlanBLL();
exportDt = dp.GetExportData(condition);
//exportDt = wcfAgent.InvokeServiceFunction<DataTable>("DoorPlankPlanBLL_GetExportData", condition);
//导出
QMFrameWork.WebUI.Util.IEFileTool efTool = new QMFrameWork.WebUI.Util.IEFileTool();
return efTool.GetExcelFileResult("DoorPlankPlanExp", "门板计划信息.xlsx", exportDt);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 导入excel
/// <summary>
/// 导入excel
/// </summary>
/// <returns>结果</returns>
[HttpPost]
public ActionResult ImportExcel()
{
DataTable dt = null;
List<TJOrderPlan> list = new List<TJOrderPlan>();
DataResult<ImportMessage> serviceResult = null;
string fileName = Request.Form["fileName"];
string orderby = Request.Form["ORDER_TYPE"];
ServiceAgent wcfAgent = this.GetServiceAgent();
Materiel materialmodel = new Materiel();
ProduceShift produceshiftmodel = new ProduceShift();
MachineInfo machine = new MachineInfo();
//初始工作中心编号条件
QMAPP.MD.Entity.WorkCell workcell = new QMAPP.MD.Entity.WorkCell();
workcell.WORKCELL_CODE = orderby;
try
{
dt = this.GetTableByExcel("TJDoorPlankPlanImp", fileName, dt);
//格式转换
list = QMFrameWork.Common.Util.BindHelper.ConvertToList<TJOrderPlan>(dt).ToList();
serviceResult = wcfAgent.InvokeServiceFunction<DataResult<ImportMessage>>("TJDoorPlankPlanBLL_GetImportData", list, materialmodel,machine, produceshiftmodel, workcell);
if (serviceResult.Ex != null)
{
throw serviceResult.Ex;
}
if (serviceResult.Result.failureNum != 0)
{
foreach (RowError error in serviceResult.Result.Errors)
{
dt.Rows[error.Key - 1]["InfoError"] = error.Value;
}
ImportMessageModel model = new ImportMessageModel();
model.InfoName = "TJDoorPlankPlanImp";
model.ReturnUrl = "/TJDoorPlankPlan/List?callBack=true";
model.Message = serviceResult.Result;
model.ErrorDt = dt;
return new MessageOutputController().OutputImportMessage(model);
}
else
{
SetMessage(serviceResult.Msg + ",如下:<br/>"
+ "插入" + serviceResult.Result.insertNum + "条,"
+ "更新" + serviceResult.Result.updateNum + "条"
);
return List(true);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
System.IO.File.Delete(MvcApplication.TempPath + fileName);
}
}
#endregion
#region 下载模板
/// <summary>
/// 下载导入模板
/// </summary>
/// <returns>结果</returns>
[HttpPost]
public ActionResult GetTemplate()
{
try
{
string path = AppDomain.CurrentDomain.BaseDirectory + "App_Data/Excel/";
string fileName = "TJDoorPlankPlanImp.xlsx";
return File(path + fileName, "application/vnd.ms-excel", Url.Encode("门板发运导入模板.xlsx"));
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
//#region 整车添加物料信息
///// <summary>
///// 编辑载入
///// </summary>
///// <returns>处理结果</returns>
//[HandleException]
//public ActionResult AddMaterial()
//{
// TJDoorPlankPlanModel model = new TJDoorPlankPlanModel();
// string ID = Request.Params["PID"];
// string TYPE = Request.Params["ORDER_TYPE"];
// TJOrderPlan Entity = new TJOrderPlan();
// ServiceAgent wcfAgent = this.GetServiceAgent();
// DataResult<TJOrderPlan> result = new DataResult<TJOrderPlan>();
// try
// {
// model.ORDER_TYPE = TYPE;
// return View("AddMaterialEdit", model);
// }
// catch (Exception ex)
// {
// throw ex;
// }
//}
///// <summary>
///// 保存
///// </summary>
///// <param name="model"></param>
///// <returns>处理结果</returns>
//[HttpPost]
//[HandleException]
//[ValidateInput(false)]
//public ActionResult SaveMaterial(TJDoorPlankPlanModel saveModel)
//{
// Material condition = new Material();
// ServiceAgent wcfAgent = this.GetServiceAgent();
// condition.MATERIAL_CODE = saveModel.MATERIAL_CODE;
// Material material = wcfAgent.InvokeServiceFunction<Material>("MaterialBLL_GetMaterialInfo", condition);
// if (!string.IsNullOrEmpty(material.PID))
// {
// saveModel.MATERIAL_NAME = material.MATERIAL_NAME;
// saveModel.COLOR = material.COLOR;
// saveModel.HBTYPE = material.HBTYPE;
// return View("AddWholeDoorEdit", saveModel);
// }
// return this.GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();", AppResource.SaveMessge));
//}
//#endregion
#region 整车添加物料信息
//[HandleException]
//public ActionResult AddSendDetail(bool? callBack)
//{
// //实例化服务
// ServiceAgent wcfAgent = this.GetServiceAgent();
// QMAPP.MD.Web.Models.MaterialModel seachModel = null;
// DataResult<DataPage> pageResult = new DataResult<DataPage>();
// DataPage page = new DataPage();
// string Fisid = Request["MATERIAL_CODE"].ToString();
// FISAssembly MaterialAssInfo = wcfAgent.InvokeServiceFunction<FISAssembly>("DoorPlankPlanBLL_GetFISMaterialInfoCD", Fisid);
// string materials = "('" + MaterialAssInfo.MESModulFL + "','" + MaterialAssInfo.MESModulFR + "','" + MaterialAssInfo.MESModulRL + "','" + MaterialAssInfo.MESModulRR + "')";
// //物料发货明细实体
// Material detail = new Material()
// {
// MaterialCodes = materials,
// };
// try
// {
// //获取查询对象
// seachModel = GetModel<QMAPP.MD.Web.Models.MaterialModel>();
// #region 获取缓存值
// if (callBack != null)
// {
// TryGetSelectBuffer<QMAPP.MD.Web.Models.MaterialModel>(out seachModel);
// }
// else
// {
// //保存搜索条件
// SetSelectBuffer<QMAPP.MD.Web.Models.MaterialModel>(seachModel);
// }
// #endregion
// //获取前台分页设置信息
// page = this.GetDataPage(seachModel);
// pageResult = wcfAgent.InvokeServiceFunction<DataResult<DataPage>>("MaterialBLL_GetList", detail, page);
// if (pageResult.IsSuccess == false)
// {
// SetMessage(pageResult.Msg);
// return List(true);
// }
// DateGridResult<Material> result = new DateGridResult<Material>();
// result.Total = pageResult.Result.RecordCount;
// result.Rows = JsonConvertHelper.GetDeserialize<List<Material>>(pageResult.Result.Result.ToString());
// for (var i = 0; i < result.Total; i++)
// {
// result.Rows[i].AsmSetCode = MaterialAssInfo.AsmSetCode;
// }
// return Content(result.GetJsonSource());
// }
// catch (Exception ex)
// {
// throw ex;
// }
//}
#endregion
#region 门板顺序号编辑
/// <summary>
/// 门板顺序号编辑
/// </summary>
/// <returns></returns>
public ActionResult DoorPlankEditSeq()
{
TJDoorPlankPlanModel model = new TJDoorPlankPlanModel();
TJOrderPlan Entity = new TJOrderPlan();
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult<TJOrderPlan> result = new DataResult<TJOrderPlan>();
try
{
model = GetModel<TJDoorPlankPlanModel>();
return View("DoorPlankEditSeq", model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取编辑系列号列表
/// <summary>
/// 获取编辑系列号列表
/// </summary>
/// <param name="callBack"></param>
/// <returns></returns>
[HandleException]
public ActionResult GetDoorPlankPlanList(bool? callBack)
{
TJDoorPlankPlanModel seachModel = null;
DataResult<DataPage> pageResult = new DataResult<DataPage>();
DataPage page = new DataPage();
ServiceAgent wcfAgent = this.GetServiceAgent();
TJOrderPlan condition = new TJOrderPlan();
try
{
//获取查询对象
seachModel = GetModel<TJDoorPlankPlanModel>();
//condition.PIDList =seachModel.PIDList;
//condition.ORDER_TYPE = seachModel.ORDER_TYPE;
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer<TJDoorPlankPlanModel>(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer<TJDoorPlankPlanModel>(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
condition = CopyToModel<TJOrderPlan, TJDoorPlankPlanModel>(seachModel);
#region wcf服务统一接口
pageResult = wcfAgent.InvokeServiceFunction<DataResult<DataPage>>("DoorPlankPlanBLL_GetDoorPlankPlanList", condition, page);
if (pageResult.IsSuccess == false)
{
SetMessage(pageResult.Msg);
return List(true);
}
DateGridResult<TJOrderPlan> result = new DateGridResult<TJOrderPlan>();
result.Total = pageResult.Result.RecordCount;
result.Rows = JsonConvertHelper.GetDeserialize<List<TJOrderPlan>>(pageResult.Result.Result.ToString());
#endregion
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 保存顺序号修改
/// <summary>
///
/// </summary>
/// <param name="model"></param>
/// <returns>处理结果</returns>
[HttpPost]
[HandleException]
[ValidateInput(false)]
public ActionResult DoorPlankPlanSeqSave(TJDoorPlankPlanModel saveModel)
{
TJOrderPlan entity = new TJOrderPlan();
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult<int> result = new DataResult<int>();
entity.PLAN_SEQ = saveModel.PLAN_SEQ;
//entity.PIDList = saveModel.PIDList;
entity = CopyToModel<TJOrderPlan, TJDoorPlankPlanModel>(saveModel);
//修改
result = wcfAgent.InvokeServiceFunction<DataResult<int>>("DoorPlankPlanBLL_UpdateDoorPlankPlanSeq", entity);
return this.GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();", AppResource.SaveMessge));
}
#endregion
}
}