using System; using System.Collections.Generic; using System.Linq; 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.Text; using QMAPP.FJC.Entity.Andon; using QMAPP.FJC.Web.Models.Andon; namespace QMAPP.FJC.Web.Controllers { /// /// 作 用:大屏幕显示 /// 作 者:周晓东 /// 编写日期:2018年01月29日 /// public class AndonDisplayController : QController { #region 获取列表 /// /// 加载列表 /// /// 结果 [HandleException] public ActionResult List(bool? callBack) { MainOperationReviewModel seachModel = new MainOperationReviewModel(); if (callBack == true) TryGetSelectBuffer(out seachModel); seachModel.rownumbers = true; seachModel.url = "/AndonDisplay/GetList"; return View("List", 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 = "/AndonDisplay/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 GetTempData() { 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 Json(nli); } /// /// 生产完成率分析 /// /// 处理结果 [HandleException] public ActionResult GetEchartDataGroup1(string name) { QTYCompletionRateVModel seachModel; DataPage page = null; ServiceAgent wcfAgent = GetServiceAgent(); QTYCompletionRateDModel condition; 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; DataPage page = null; ServiceAgent wcfAgent = GetServiceAgent(); QTYCompletionRateDModel condition; 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,string name1) { #region 源数据定义 var maxWCL = -1D; string jihua = "", wancheng = "", wclv = "", riqi = "", dou = ""; if (nli == null || nli.Count == 0) { jihua += "''"; wancheng += "''"; wclv += "''"; riqi += "''"; } else { bool first = true; foreach (QTYCompletionRateDModel item in nli) { jihua += dou + "'" + item.QTY + "'"; wancheng += dou + "'" + item.COMPLETE_QTY + "'"; double fenzi = 0; if (!string.IsNullOrEmpty(item.COMPLETE_QTY) && item.COMPLETE_QTY != "0") { fenzi = Convert.ToDouble(item.COMPLETE_QTY); } double fenmu = 0; if (!string.IsNullOrEmpty(item.QTY)) { fenmu = Convert.ToDouble(item.QTY); } string WCL=""; if(fenmu>0) { WCL=(fenzi/fenmu*100).ToString("0"); if (fenzi / fenmu * 100 > maxWCL) { maxWCL = fenzi / fenmu * 100; } } wclv += dou + "'" + WCL + "'"; riqi += dou + "'" + item.MATERIAL_SHORT + "'"; if (first) { first = false; dou = ","; } } } if(maxWCL<0) { maxWCL=100; } 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: ['" + name1 + @"计划数量', '" + name1 + @"完成数量','完成率'] }, xAxis: [ { type: 'category', axisLabel : { //坐标轴刻度标签的相关设置。 interval:0, rotate:0 }, data: [" + riqi + @"] } ], yAxis: [ { type: 'value', name: '件', axisLabel: { formatter: '{value}' } }, { type: 'value', // name: '百分比', // axisLabel: { // formatter: '{value} %' // } splitLine:{ show:false }, scale: true, name: '百分比', max: "+(Math.Round(maxWCL/10)*10).ToString("0") +@", min: 0 //boundaryGap: [" + wclv + @"] } ], series: [ { name: '" + name1 + @"计划数量', type: 'bar', barMaxWidth: '100', itemStyle: { normal: { label: { show: true, } } }, data: [" + jihua + @"] }, { name: '" + name1 + @"完成数量', type: 'bar', barMaxWidth: '100', itemStyle: { normal: { label: { show: true, } } }, data: [" + wancheng + @"] }, { name: '完成率', type: 'line', yAxisIndex: 1, data: [" + wclv + @"], itemStyle: { normal: { color:'#cc0033', lineStyle:{ width:3, color:'#ff9933' }, label: { show: true, //formatter:function(value){if(value!=''){return value+'%'}else{return ''}}, textStyle:{ color:'#000000', fontSize: 12, fontWeight: '100' } } } } } ] }"; #endregion return strOption; } //返修率 [HandleException] public ActionResult GetEchartRepair1(string name) { QTYCompletionRateVModel seachModel; DataPage page = null; ServiceAgent wcfAgent = GetServiceAgent(); QTYCompletionRateDModel condition; List nli = new List(); try { //获取查询对象 seachModel = GetModel(); //获取前台分页设置信息 page = this.GetDataPage(seachModel); condition = CopyToModel(seachModel); #region wcf服务统一接口 var dataResult = wcfAgent.InvokeServiceFunction>>("RepairRateCountBLL_GetInjectReworkRate"); nli = dataResult.Result; #endregion } catch (Exception ex) { throw ex; } return Content(setOptionRepair(nli, "注塑")); } [HandleException] public ActionResult GetEchartRepair2(string name) { QTYCompletionRateVModel seachModel; DataPage page = null; ServiceAgent wcfAgent = GetServiceAgent(); QTYCompletionRateDModel condition; List nli = new List(); try { //获取查询对象 seachModel = GetModel(); //获取前台分页设置信息 page = this.GetDataPage(seachModel); condition = CopyToModel(seachModel); #region wcf服务统一接口 var dataResult = wcfAgent.InvokeServiceFunction>>("RepairRateCountBLL_GetReworkRate", "VW331 DP"); nli = dataResult.Result; #endregion } catch (Exception ex) { throw ex; } return Content(setOptionRepair(nli, "门板")); } [HandleException] public ActionResult GetEchartRepair3(string name) { QTYCompletionRateVModel seachModel; DataPage page = null; ServiceAgent wcfAgent = GetServiceAgent(); QTYCompletionRateDModel condition; List nli = new List(); try { //获取查询对象 seachModel = GetModel(); //获取前台分页设置信息 page = this.GetDataPage(seachModel); condition = CopyToModel(seachModel); #region wcf服务统一接口 var dataResult = wcfAgent.InvokeServiceFunction>>("RepairRateCountBLL_GetReworkRate", "VW331/5CN IP"); nli = dataResult.Result; #endregion } catch (Exception ex) { throw ex; } return Content(setOptionRepair(nli, "仪表板")); } public string setOptionRepair(List nli, string name1) { #region 源数据定义 string jihua = "", wancheng = "", wclv = "", riqi = "", dou = ""; bool first = true; if (nli==null || nli.Count == 0) { jihua += "''"; wancheng += "''"; wclv += "''"; riqi += "''"; } else { //jihua += ""; //wancheng += ""; //wclv += "'',"; //riqi += "'',"; foreach (QTYCompletionRateDModel item in nli) { //jihua=生成数量QTY,wancheng=返修数量COMPLETE_QTY。 借用 jihua += dou + "'" + item.REWORK_QTY + "'"; wancheng += dou + "'" + item.COMPLETE_QTY + "'"; double fenmu = 1; if (!string.IsNullOrEmpty(item.COMPLETE_QTY) && item.COMPLETE_QTY != "0") { fenmu = Convert.ToDouble(item.COMPLETE_QTY); } double fenzi = 0; if (!string.IsNullOrEmpty(item.REWORK_QTY)) { fenzi = Convert.ToDouble(item.REWORK_QTY); } wclv += dou + "'" + (fenzi/fenmu*100).ToString("0") + "'"; riqi += dou + "'" + item.MATERIAL_SHORT + "'"; if (first) { first = false; dou = ","; } } //jihua += ",''"; //wancheng += ",''"; //wclv += ",''"; //riqi += ",''"; } 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: ['" + name1 + @"返修数量', '" + name1 + @"生产数量','返修率'] }, xAxis: [ { type: 'category', axisLabel : { //坐标轴刻度标签的相关设置。 interval:0, rotate:0 }, data: [" + riqi + @"] } ], yAxis: [ { type: 'value', name: '件', axisLabel: { formatter: '{value}' } }, { type: 'value', scale: true, name: '百分比', max: 100, min: 0, boundaryGap: [" + wclv + @"] } ], series: [ { name: '" + name1 + @"返修数量', type: 'bar', barMaxWidth: '100', itemStyle: { normal: { label: { show: true, } } }, data: [" + jihua + @"] }, { name: '" + name1 + @"生产数量', type: 'bar', barMaxWidth: '100', itemStyle: { normal: { label: { show: true, } } }, data: [" + wancheng + @"] }, { name: '返修率', type: 'line', yAxisIndex: 1, data: [" + wclv + @"], itemStyle: { normal: { color:'#cc0033', lineStyle:{ width:3, color:'#ff9933' }, label: { show: true, //formatter:'{c}%', textStyle:{ color:'#000000', fontSize: 12, fontWeight: '100' } } } } } ] }"; #endregion return strOption; } /// /// 统计图页面配置 /// /// public static string QMEChartPageConfig() { StringBuilder configBuilder = new StringBuilder(); configBuilder.AppendLine(""); configBuilder.AppendLine(""); configBuilder.AppendLine(""); configBuilder.AppendLine(""); return configBuilder.ToString(); } /// /// 堆积柱状图 /// /// 处理结果 [HandleException] public ActionResult GetEchartDataBar2() { RepairRateCountVModel seachModel; DataPage page = null; ServiceAgent wcfAgent = GetServiceAgent(); RepairRateCountDModel condition; List nli = new List(); try { //获取查询对象 seachModel = GetModel(); //获取前台分页设置信息 page = this.GetDataPage(seachModel); condition = CopyToModel(seachModel); #region wcf服务统一接口 var dataResult = wcfAgent.InvokeServiceFunction>>("RepairRateCountBLL_GetAllListNew", condition); nli = dataResult.Result; #endregion } catch (Exception ex) { throw ex; } string mubiao = "", fxlv = "", riqi = "", dou = ""; bool first = true; foreach (RepairRateCountDModel item in nli) { mubiao += dou + "'" + item.MFlV + "'"; fxlv += dou + "'" + (Convert.ToDouble(item.REWORK_QTY) / Convert.ToDouble(item.QTY) * 100).ToString("0") + "'"; riqi += dou + "'" + item.TDAY + "'"; if (first) { first = false; dou = ","; } } #region 源数据定义 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', data: [" + riqi + @"] } ], yAxis: [ { type: 'value', scale: true, name: '百分比', max: 100, min: 0, boundaryGap: [" + fxlv + @"] } } ], series: [ { name: '返修率', type: 'line', data: [" + fxlv + @"] }, { name: '目标值', type: 'line', data: [" + mubiao + @"] } ] }"; #endregion return Content(strOption); } } }