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.
255 lines
10 KiB
255 lines
10 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using QMAPP.Common.Web.Controllers;
|
|
using QMAPP.Entity;
|
|
using QMAPP.FJC.Entity.Andon;
|
|
using QMAPP.FJC.Entity.Basic;
|
|
using QMAPP.FJC.Web.Models.Andon;
|
|
using QMAPP.FJC.Web.Models.Basic;
|
|
using QMAPP.MD.Entity;
|
|
using QMAPP.ServicesAgent;
|
|
using QMFrameWork.Common.Serialization;
|
|
using QMFrameWork.Data;
|
|
using QMFrameWork.WebUI.Attribute;
|
|
using QMFrameWork.WebUI.DataSource;
|
|
using ProcessInfo = QMAPP.FJC.Entity.Basic.ProcessInfo;
|
|
|
|
namespace QMAPP.FJC.Web.Controllers
|
|
{
|
|
public class AndonCallReasonController : QController
|
|
{
|
|
#region 获取列表
|
|
/// <summary>
|
|
/// 加载列表
|
|
/// </summary>
|
|
/// <returns>结果</returns>
|
|
[HandleException]
|
|
public ActionResult List(bool? callBack)
|
|
{
|
|
CallReasonModel seachModel = new CallReasonModel();
|
|
if (callBack == true)
|
|
TryGetSelectBuffer<CallReasonModel>(out seachModel);
|
|
seachModel.rownumbers = false;
|
|
seachModel.url = "/AndonCallReason/GetList";
|
|
return View("CallReasonList", seachModel);
|
|
}
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <param name="callBack">是否回调</param>
|
|
/// <returns>列表</returns>
|
|
[HandleException]
|
|
public ActionResult GetList(bool? callBack)
|
|
{
|
|
CallReasonModel seachModel = null;
|
|
DataResult<DataPage> pageResult = new DataResult<DataPage>();
|
|
DataPage page = new DataPage();
|
|
ServiceAgent wcfAgent = this.GetServiceAgent();
|
|
CallReasonEntity condition = null;
|
|
try
|
|
{
|
|
//获取查询对象
|
|
seachModel = GetModel<CallReasonModel>();
|
|
#region 获取缓存值
|
|
if (callBack != null)
|
|
{
|
|
TryGetSelectBuffer<CallReasonModel>(out seachModel);
|
|
}
|
|
else
|
|
{
|
|
//保存搜索条件
|
|
SetSelectBuffer<CallReasonModel>(seachModel);
|
|
}
|
|
#endregion
|
|
//获取前台分页设置信息
|
|
page = this.GetDataPage(seachModel);
|
|
condition = CopyToModel<CallReasonEntity, CallReasonModel>(seachModel);
|
|
#region wcf服务统一接口
|
|
pageResult = wcfAgent.InvokeServiceFunction<DataResult<DataPage>>("AndonCallBLL_GetList", condition, page);
|
|
if (pageResult.IsSuccess == false)
|
|
{
|
|
SetMessage(pageResult.Msg);
|
|
return List(true);
|
|
}
|
|
DateGridResult<CallReasonEntity> result = new DateGridResult<CallReasonEntity>();
|
|
result.Total = pageResult.Result.RecordCount;
|
|
result.Rows = JsonConvertHelper.GetDeserialize<List<CallReasonEntity>>(pageResult.Result.Result.ToString());
|
|
#endregion
|
|
return Content(result.GetJsonSource());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 编辑
|
|
/// <summary>
|
|
/// 编辑载入
|
|
/// </summary>
|
|
/// <returns>处理结果</returns>
|
|
[HandleException]
|
|
public ActionResult Edit()
|
|
{
|
|
CallReasonModel model = new CallReasonModel();
|
|
string ID = Request.Params["PID"];
|
|
string callType = Request.Params["callType"];
|
|
model.CALL_TYPE = callType;
|
|
CallReasonEntity Entity = new CallReasonEntity();
|
|
ServiceAgent wcfAgent = this.GetServiceAgent();
|
|
DataResult<CallReasonEntity> result = new DataResult<CallReasonEntity>();
|
|
try
|
|
{
|
|
if (string.IsNullOrEmpty(ID) == false)
|
|
{
|
|
//修改获取原数据
|
|
Entity.PID = ID;
|
|
result = wcfAgent.InvokeServiceFunction<DataResult<CallReasonEntity>>("AndonCallBLL_Get", Entity);
|
|
if (result.IsSuccess == false)
|
|
{
|
|
SetMessage(result.Msg);
|
|
return View("CallReasonEdit", model);
|
|
}
|
|
model = CopyToModel<CallReasonModel, CallReasonEntity>(result.Result);
|
|
////根据工位信息获得工序信息
|
|
//string kind = model.CALL_TYPE;
|
|
//var WORKCELL_CODE = "";
|
|
//ServiceAgent wcfAgent1 = this.GetServiceAgent();
|
|
//if (string.IsNullOrEmpty(kind) == false)
|
|
//{
|
|
// var dataResult = wcfAgent1.InvokeServiceFunction<List<WorkLoc>>
|
|
// ("WorkLocBLL_GetWorkCellFromWorkLocList", new WorkLoc(), kind);
|
|
// foreach (WorkLoc item in dataResult)
|
|
// {
|
|
// WORKCELL_CODE = item.WORKCELL_CODE;
|
|
// }
|
|
//}
|
|
//model.CALL_TYPE = WORKCELL_CODE;
|
|
|
|
}
|
|
return View("CallReasonEdit", model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns>处理结果</returns>
|
|
[HttpPost]
|
|
[HandleException]
|
|
[ValidateInput(false)]
|
|
public ActionResult Save(CallReasonModel saveModel)
|
|
{
|
|
CallReasonEntity Entity = null;
|
|
ServiceAgent _agent = this.GetServiceAgent();
|
|
DataResult<int> result = new DataResult<int>();
|
|
try
|
|
{
|
|
Entity = CopyToModel<CallReasonEntity, CallReasonModel>(saveModel);
|
|
if (string.IsNullOrEmpty(Entity.PID) == true)
|
|
{
|
|
//新增
|
|
|
|
|
|
//根据配置文件获得工位,工序
|
|
string _factoryCode = null;
|
|
string locationfile = System.Configuration.ConfigurationManager.AppSettings["loactionfile"];
|
|
if (System.IO.File.Exists(locationfile))
|
|
{
|
|
string machinecode = System.IO.File.ReadAllText(locationfile);
|
|
if (!string.IsNullOrEmpty(machinecode.Trim()))
|
|
{
|
|
//设置ip
|
|
MachineInfo machoneInofModel = new MachineInfo { MACHINECODDE = machinecode.Trim() };
|
|
var list = _agent.InvokeServiceFunction<List<MachineInfo>>(B9BasicService.MachineInfoBLL_GetAllList.ToString(), machoneInofModel);
|
|
if (list.Count > 0)
|
|
{
|
|
var _worklocCode = list[0].WORKLOC_CODE;
|
|
var _workcellCode = list[0].WORKCELL_CODE;
|
|
//根据工序获得工作中心
|
|
WorkCell workCellModel = new WorkCell { WORKCELL_CODE = _workcellCode };
|
|
var resultWorkCell = _agent.InvokeServiceFunction<DataResult<WorkCell>>("WorkCellBLL_Get", workCellModel);
|
|
if (resultWorkCell != null)
|
|
{
|
|
var _workcenterCode = resultWorkCell.Result.WORKCENTER_CODE;
|
|
//根据工作中心获得工厂编码
|
|
var workCenterModel = new MD.Entity.WorkCenter { WORKCENTER_CODE = _workcenterCode };
|
|
var resultWorkCenter = _agent.InvokeServiceFunction<DataResult<MD.Entity.WorkCenter>>("WorkCenterBLL_Get", workCenterModel);
|
|
if (resultWorkCenter != null)
|
|
{
|
|
_factoryCode = resultWorkCenter.Result.FACTORY_CODE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Entity.FACTORY_CODE = _factoryCode;
|
|
|
|
result = _agent.InvokeServiceFunction<DataResult<int>>("AndonCallBLL_InsertCallReason", Entity);
|
|
}
|
|
else
|
|
{
|
|
//修改
|
|
result = _agent.InvokeServiceFunction<DataResult<int>>("AndonCallBLL_UpdateCallReason", Entity);
|
|
|
|
//result = wcfAgent.InvokeServiceFunction<DataResult<int>>(QMAPP.ServicesAgent.B9BasicService.CallReasonBLL_Update.ToString(), Entity);
|
|
}
|
|
if (result.IsSuccess == false)
|
|
{
|
|
SetMessage(result.Msg);
|
|
return View("CallReasonEdit", 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(CallReasonModel saveMode)
|
|
{
|
|
string selectKey = Request.Form["selectKey"];
|
|
ServiceAgent wcfAgent = this.GetServiceAgent();
|
|
DataResult<int> result = new DataResult<int>();
|
|
try
|
|
{
|
|
result = wcfAgent.InvokeServiceFunction<DataResult<int>>("AndonCallBLL_DeleteCallReason", selectKey);
|
|
if (result.IsSuccess == false)
|
|
{
|
|
SetMessage(result.Msg);
|
|
return List(true);
|
|
}
|
|
SetMessage(AppResource.DeleteMessage);
|
|
return List(true);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|