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; using QMFrameWork.Log; using System.Data; using QMAPP.FJC.BLL.Andon; namespace QMAPP.FJC.Web.Controllers { public class AndonCallLogController : QController { #region 获取列表 /// /// 加载列表 /// /// 结果 [HandleException] public ActionResult List(bool? callBack) { CallLogModel seachModel = new CallLogModel(); if (callBack == true) TryGetSelectBuffer(out seachModel); seachModel.rownumbers = false; seachModel.url = "/AndonCallLog/GetList"; return View("CallLogList", seachModel); } /// /// 获取列表 /// /// 是否回调 /// 列表 [HandleException] public ActionResult GetList(bool? callBack) { CallLogModel seachModel = null; DataResult pageResult = new DataResult(); DataPage page = new DataPage(); ServiceAgent wcfAgent = this.GetServiceAgent(); CallLogEntity condition = null; try { //获取查询对象 seachModel = GetModel(); #region 获取缓存值 if (callBack != null) { TryGetSelectBuffer(out seachModel); } else { //保存搜索条件 SetSelectBuffer(seachModel); } #endregion //获取前台分页设置信息 page = this.GetDataPage(seachModel); condition = CopyToModel(seachModel); #region wcf服务统一接口 pageResult = wcfAgent.InvokeServiceFunction>("AndonCallBLL_GetCallLogListWeb", condition, page); if (pageResult.IsSuccess == false) { SetMessage(pageResult.Msg); return List(true); } DateGridResult result = new DateGridResult(); result.Total = pageResult.Result.RecordCount; result.Rows = JsonConvertHelper.GetDeserialize>(pageResult.Result.Result.ToString()); #endregion return Content(result.GetJsonSource()); } catch (Exception ex) { throw ex; } } #endregion /* #region 编辑 /// /// 编辑载入 /// /// 处理结果 [HandleException] public ActionResult Edit() { CallLogModel model = new CallLogModel(); string ID = Request.Params["PID"]; string callType = Request.Params["callType"]; model.CALL_TYPE = callType; CallLogEntity Entity = new CallLogEntity(); ServiceAgent wcfAgent = this.GetServiceAgent(); DataResult result = new DataResult(); try { if (string.IsNullOrEmpty(ID) == false) { //修改获取原数据 Entity.PID = ID; result = wcfAgent.InvokeServiceFunction>("AndonCallBLL_Get", Entity); if (result.IsSuccess == false) { SetMessage(result.Msg); return View("CallReasonEdit", model); } model = CopyToModel(result.Result); ////根据工位信息获得工序信息 //string kind = model.CALL_TYPE; //var WORKCELL_CODE = ""; //ServiceAgent wcfAgent1 = this.GetServiceAgent(); //if (string.IsNullOrEmpty(kind) == false) //{ // var dataResult = wcfAgent1.InvokeServiceFunction> // ("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 保存 /// /// 保存 /// /// /// 处理结果 [HttpPost] [HandleException] [ValidateInput(false)] public ActionResult Save(CallLogModel saveModel) { CallLogEntity Entity = null; ServiceAgent _agent = this.GetServiceAgent(); DataResult result = new DataResult(); try { Entity = CopyToModel(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>(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>("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>("WorkCenterBLL_Get", workCenterModel); if (resultWorkCenter != null) { _factoryCode = resultWorkCenter.Result.FACTORY_CODE; } } } } } Entity.FACTORY_CODE = _factoryCode; result = _agent.InvokeServiceFunction>("AndonCallBLL_InsertCallReason", Entity); } else { //修改 result = _agent.InvokeServiceFunction>("AndonCallBLL_UpdateCallReason", Entity); //result = wcfAgent.InvokeServiceFunction>(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 删除 /// /// 删除 /// /// 结果 [HttpPost] [HandleException] public ActionResult Delete(CallLogModel saveMode) { string selectKey = Request.Form["selectKey"]; ServiceAgent wcfAgent = this.GetServiceAgent(); DataResult result = new DataResult(); try { result = wcfAgent.InvokeServiceFunction>("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 */ #region 导出excel /// /// 导出excel /// /// 结果 [HandleException] public ActionResult ExportExcel() { DataTable exportDt = new DataTable(); CallLogModel seachModel = null; CallLogEntity condition = null; try { //获取查询对象 seachModel = GetModel(); condition = CopyToModel(seachModel); condition.TableName = "AndonCallLogExp"; //获取数据 //exportDt = this.GetServiceAgent().InvokeServiceFunction("AndonCallBLL_ExportExcelData", condition); exportDt = new AndonCallBLL().ExportExcelData(condition); //导出 QMFrameWork.WebUI.Util.IEFileTool efTool = new QMFrameWork.WebUI.Util.IEFileTool(); return efTool.GetExcelFileResult("AndonCallLogExp", "安东呼叫.xlsx", exportDt); } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo { ErrorInfo = ex, Info = "导出excel", Tag = "安东呼叫" }); this.SetMessage("导出excel失败"); return this.List(true); } } #endregion } }