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.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.Data; using System.Text; using QMAPP.Entity.Sys; using QMAPP.FJC.Entity.Andon; using QMAPP.FJC.Entity.ProductPetrospect; using QMAPP.FJC.Web.Models.Andon; namespace QMAPP.FJC.Web.Controllers { /// /// 模块编号:M5-3 /// 作 用:产品加工追溯控制层 /// 作 者:王丹丹 /// 编写日期:2015年06月16日 /// public class MainOperationReviewController : QController { #region 获取列表 /// /// 加载列表 /// /// 结果 [HandleException] public ActionResult List(bool? callBack) { MainOperationReviewModel seachModel = new MainOperationReviewModel(); if (callBack == true) TryGetSelectBuffer(out seachModel); seachModel.rownumbers = true; seachModel.url = "/MainOperationReview/GetList"; return View("MainOperationReviewList", seachModel); } /// /// 获取列表 /// /// 是否回调 /// 列表 [HandleException] public ActionResult GetList(bool? callBack) { MainOperationReviewModel seachModel = null; DataPage page = null; ServiceAgent wcfAgent = this.GetServiceAgent(); MainOperation condition = null; DataResult pageResult = new DataResult(); 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>(QMAPP.ServicesAgent.B9BasicService.MainOperationBLL_GetMainOperationReviewList.ToString(), condition, page); 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; } } [HandleException] public ActionResult GetMainOperationReviews(bool? callBack) { ProductArchivesModel seachModel = new ProductArchivesModel(); ServiceAgent wcfAgent = this.GetServiceAgent(); try { //获取查询对象 seachModel = GetModel(); #region 获取缓存值 if (callBack != null) { TryGetSelectBuffer(out seachModel); } else { //保存搜索条件 SetSelectBuffer(seachModel); } #endregion MainOperation condition1 = new MainOperation(); condition1.PRODUCTCODE = seachModel.ERMISCODE; condition1.MAINCODE = seachModel.MAINCODE; //condition = CopyToModel(seachModel); #region wcf服务统一接口 var dlist = wcfAgent.InvokeServiceFunction("MainOperationBLL_GetMainOperations", condition1); #endregion return Content(dlist); } catch (Exception ex) { throw ex; } } #endregion #region 获取列表 /// /// 统计 /// /// 结果 [HandleException] public ActionResult Count(bool? callBack) { CallLogModel seachModel = new CallLogModel(); if (callBack == true) TryGetSelectBuffer(out seachModel); string ids = Request.Params["PID"]; seachModel.rownumbers = false; seachModel.url = "/MainOperationReview/GetCountList?PID=" + ids; return View("CountList", seachModel); } /// /// 获取统计列表 /// /// 是否回调 /// 列表 [HandleException] public ActionResult GetCountList(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); string ids = Request.Params["PID"]; var callType = ids.Substring(0, 1); var mc = ids.Substring(1); condition.CALL_TYPE = callType; condition.MACHINECODDE = mc; #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 /// /// 异步刷新TABLE /// /// /// public ActionResult GetTable(string MATERIAL_CODE, string TYPE_COUNT, string START_DATE, string END_DATE) { ServiceAgent wcfAgent = this.GetServiceAgent(); QTYCompletionRateDModel condition = new QTYCompletionRateDModel(); condition.MATERIAL_CODE = MATERIAL_CODE; condition.TYPE_COUNT = TYPE_COUNT; condition.START_DATE = START_DATE; condition.END_DATE = END_DATE; List nli = new List(); try { #region wcf服务统一接口 var dataResult = wcfAgent.InvokeServiceFunction>>("QTYCompletionRateBLL_GetAllList", condition); nli = dataResult.Result; #endregion } catch (Exception ex) { throw ex; } string sss = GetHTMLStr(nli, TYPE_COUNT); return Json(sss); } /// /// 拼接字符串 /// /// public string GetHTMLStr(List nli, string TYPE_COUNT) { StringBuilder html = new StringBuilder(); if (nli == null || nli.Count == 0) { return "没有数据"; } //测试表头 html.Append("测试"); int i = 0; foreach (QTYCompletionRateDModel item in nli) { if (i == 0 || i % 2 == 0) { html.Append(" "); html.Append("测试" + i); html.Append(""); } ++i; } html.Append(""); //拼接表头 html.Append("产品种类"); string dt = "号"; if (TYPE_COUNT == "MONTH") { dt = "月"; } foreach (QTYCompletionRateDModel item in nli) { html.Append(""); if (item.TDAY.Equals("累计")) { html.Append(item.TDAY); } else { html.Append(item.TDAY + dt); } html.Append(""); } html.Append(""); Dictionary> dls = new Dictionary>(); //对结果集分类 foreach (QTYCompletionRateDModel item in nli) { if (dls.Keys.Contains(item.MATERIAL_NAME + item.MATERIAL_CODE)) { //则添加到KEY下 dls[item.MATERIAL_NAME + item.MATERIAL_CODE].Add(item); continue; } else { //新建key List li = new List(); li.Add(item); dls.Add(item.MATERIAL_NAME + item.MATERIAL_CODE, li); } } //拼接主体数据 foreach (List item in dls.Values) { html.Append(""); html.Append("计划数量"); html.Append(""); foreach (QTYCompletionRateDModel itit in item) { html.Append(""); html.Append(itit.QTY); html.Append(""); } html.Append(""); html.Append(""); html.Append("完成数量"); html.Append(""); foreach (QTYCompletionRateDModel itit in item) { html.Append(""); html.Append(itit.COMPLETE_QTY); html.Append(""); } html.Append(""); } return html.ToString(); } /// /// 多图叠加 /// /// 处理结果 [HandleException] public ActionResult GetEchartDataGroup1(string name) { QTYCompletionRateVModel seachModel = null; DataPage page = null; ServiceAgent wcfAgent = this.GetServiceAgent(); QTYCompletionRateDModel condition = null; List nli = new List(); try { //获取查询对象 seachModel = GetModel(); //获取前台分页设置信息 page = this.GetDataPage(seachModel); condition = CopyToModel(seachModel); #region wcf服务统一接口 var dataResult = wcfAgent.InvokeServiceFunction>>("QTYCompletionRateBLL_GetAllListNew1", condition); nli = dataResult.Result; #endregion } catch (Exception ex) { throw ex; } return Content(setOption(nli)); } [HandleException] public ActionResult GetEchartDataGroup2(string name) { QTYCompletionRateVModel seachModel = null; DataPage page = null; ServiceAgent wcfAgent = this.GetServiceAgent(); QTYCompletionRateDModel condition = null; List nli = new List(); try { //获取查询对象 seachModel = GetModel(); //获取前台分页设置信息 page = this.GetDataPage(seachModel); condition = CopyToModel(seachModel); #region wcf服务统一接口 var dataResult = wcfAgent.InvokeServiceFunction>>("QTYCompletionRateBLL_GetAllListNew2", condition); nli = dataResult.Result; #endregion } catch (Exception ex) { throw ex; } return Content(setOption(nli)); } [HandleException] public ActionResult GetEchartDataGroup3(string name) { QTYCompletionRateVModel seachModel = null; DataPage page = null; ServiceAgent wcfAgent = this.GetServiceAgent(); QTYCompletionRateDModel condition = null; List nli = new List(); try { //获取查询对象 seachModel = GetModel(); //获取前台分页设置信息 page = this.GetDataPage(seachModel); condition = CopyToModel(seachModel); #region wcf服务统一接口 var dataResult = wcfAgent.InvokeServiceFunction>>("QTYCompletionRateBLL_GetAllListNew3", condition); nli = dataResult.Result; #endregion } catch (Exception ex) { throw ex; } return Content(setOption(nli)); } public string setOption(List nli) { #region 源数据定义 string jihua = "", wancheng = "", wclv = "", riqi = "", dou = ""; bool first = true; foreach (QTYCompletionRateDModel item in nli) { jihua += dou + "'" + item.QTY + "'"; wancheng += dou + "'" + item.COMPLETE_QTY + "'"; double fenmu = 1; if (!string.IsNullOrEmpty(item.QTY) && item.QTY != "0") { fenmu = Convert.ToDouble(item.QTY); } double fenzi = 1; if (!string.IsNullOrEmpty(item.COMPLETE_QTY)) { fenmu = Convert.ToDouble(item.COMPLETE_QTY); } wclv += dou + "'" + (fenzi / fenmu * 100).ToString("0") + "'"; riqi += dou + "'" + item.MATERIAL_CODE + "'"; if (first) { first = false; dou = ","; } } string strOption = @"{ tooltip: { trigger: 'axis' }, toolbox: { show: false, feature: { mark: { show: true }, dataView: { show: true, readOnly: false }, magicType: { show: true, type: ['line', 'bar'] }, restore: { show: true }, saveAsImage: { show: true } } }, calculable: true, legend: { data: ['计划数量', '完成数量'] }, xAxis: [ { type: 'category', axisLabel : { //坐标轴刻度标签的相关设置。 interval:'auto', rotate:10, // formatter : function(val){ // var strs = val.split(''); //字符串数组 // var str = '' // for (var i = 0, s; s = strs[i++];) { //遍历字符串数组 // str += s; // if (!(i % 10)) str += '\n'; // } // return str // } }, data: [" + riqi + @"] } ], yAxis: [ { type: 'value', name: '件', axisLabel: { formatter: '{value}' } }, { type: 'value', name: '百分比', axisLabel: { formatter: '{value} %' } } ], series: [ { name: '计划数量', type: 'bar', // label:{ // normal:{ // show:true, //// rotate: 90, //// align: 'left', //// verticalAlign: 'middle', // position: 'top', //// distance: 15, //// formatter: '{c} {name|{a}}', //// fontSize: 16 // }, data: [" + jihua + @"] }, { name: '完成数量', type: 'bar', data: [" + wancheng + @"], // //系列中的数据标注内容 // markPoint: { // data: [ // {type: 'max', name: '最大值'}, // {type: 'min', name: '最小值'} // ] // }, // //系列中的数据标线内容 // markLine: { // data: [ // {type: 'average', name: '平均值'} // ] // } }, { name: '完成率', type: 'line', yAxisIndex: 1, data: [" + wclv + @"] , itemStyle: { normal: { label: { show: true}} } } ] }"; #endregion return strOption; } /// /// 统计图页面配置 /// /// public static string QMEChartPageConfig() { StringBuilder configBuilder = new StringBuilder(); configBuilder.AppendLine(""); configBuilder.AppendLine(""); configBuilder.AppendLine(""); configBuilder.AppendLine(""); return configBuilder.ToString(); } #region 导出excel /// /// 导出excel /// /// 结果 [HttpPost] public ActionResult ExportExcel() { MainOperationReviewModel seachModel = null; MainOperation condition = null; DataTable exportDt = new DataTable(); ServiceAgent wcfAgent = this.GetServiceAgent(); DataResult result = new DataResult(); string selectKey = Request.Form["selectKey"]; try { //获取查询对象 seachModel = GetModel(); condition = CopyToModel(seachModel); //获取数据 result = wcfAgent.InvokeServiceFunction>(QMAPP.ServicesAgent.B9BasicService.MainOperationBLL_GetExportDataForMOR.ToString(), condition); if (result.IsSuccess == false) { SetMessage(result.Msg); return List(true); } //根据所选信息进行导出 if (!String.IsNullOrEmpty(selectKey)) { DataView dv = new DataView(result.Result); string strWhere = ""; string[] list = selectKey.Split(":".ToCharArray()); foreach (string ID in list) { strWhere += " PID='" + ID + "' or"; } if (strWhere != "") { strWhere = strWhere.Remove((strWhere.Length - 2), 2); } dv.RowFilter = strWhere; result.Result = dv.ToTable(); } //导出 QMFrameWork.WebUI.Util.IEFileTool efTool = new QMFrameWork.WebUI.Util.IEFileTool(); return efTool.GetExcelFileResult("MainOperationReviewExp", "MainOperationReviewExp.xlsx", result.Result); } catch (Exception ex) { throw ex; } } [HttpPost] public ActionResult ExportExcelNew() { ProductArchivesModel seachModel = new ProductArchivesModel(); //MainOperationReviewModel seachModel = null; MainOperation condition = null; DataTable exportDt = new DataTable(); ServiceAgent wcfAgent = this.GetServiceAgent(); DataResult result = new DataResult(); string selectKey = Request.Form["selectKey"]; string ermiscode = Request["ermiscode"]; string maincode = Request["maincode"]; try { //获取查询对象 //获取查询对象 seachModel = GetModel(); #region 获取缓存值 //if (callBack != null) //{ // TryGetSelectBuffer(out seachModel); //} //else //{ // //保存搜索条件 // SetSelectBuffer(seachModel); //} #endregion MainOperation condition1 = new MainOperation(); condition1.PRODUCTCODE = ermiscode; condition1.MAINCODE = maincode; //seachModel = GetModel(); //condition = CopyToModel(seachModel); //获取数据 result = wcfAgent.InvokeServiceFunction>("MainOperationBLL_GetExportDataForMORNew", condition1); if (result.IsSuccess == false) { SetMessage(result.Msg); return List(true); } //根据所选信息进行导出 //if (!String.IsNullOrEmpty(selectKey)) //{ // DataView dv = new DataView(result.Result); // string strWhere = ""; // string[] list = selectKey.Split(":".ToCharArray()); // foreach (string ID in list) // { // strWhere += " PID='" + ID + "' or"; // } // if (strWhere != "") // { // strWhere = strWhere.Remove((strWhere.Length - 2), 2); // } // dv.RowFilter = strWhere; // result.Result = dv.ToTable(); //} //导出 QMFrameWork.WebUI.Util.IEFileTool efTool = new QMFrameWork.WebUI.Util.IEFileTool(); return efTool.GetExcelFileResult("MainOperationReviewExp", "MainOperationReviewExp.xlsx", result.Result); } catch (Exception ex) { throw ex; } } #endregion } }