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.
262 lines
10 KiB
262 lines
10 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using QMAPP.FJC.Web.Models.StatisticalAnalysis;
|
|
using QMFrameWork.WebUI.Attribute;
|
|
using QMFrameWork.Common.Serialization;
|
|
using QMAPP.Common.Web.Controllers;
|
|
using QMAPP.Entity;
|
|
using QMAPP.FJC.Entity.Operation;
|
|
using QMFrameWork.Data;
|
|
using QMAPP.ServicesAgent;
|
|
using QMAPP.FJC.Entity.ProduceManage;
|
|
using QMAPP.FJC.Entity;
|
|
using System.Data;
|
|
|
|
namespace QMAPP.FJC.Web.Controllers
|
|
{
|
|
public class MendStatisticsController : QController
|
|
{
|
|
//
|
|
// GET: /MendStatistics/
|
|
|
|
public ActionResult Index()
|
|
{
|
|
MendStatisticsModel seachModel = new MendStatisticsModel();
|
|
return View("Index", seachModel);
|
|
}
|
|
|
|
#region 获取列表
|
|
/// <summary>
|
|
/// 加载列表
|
|
/// </summary>
|
|
/// <returns>结果</returns>
|
|
[HandleException]
|
|
public ActionResult List()
|
|
{
|
|
MendStatisticsModel seachModel = null;
|
|
DataResult<List<MendRecorder>> listResult = new DataResult<List<MendRecorder>>();
|
|
DataPage page = new DataPage();
|
|
ServiceAgent wcfAgent = this.GetServiceAgent();
|
|
MendRecorder condition = null;
|
|
try
|
|
{
|
|
//获取查询对象
|
|
seachModel = GetModel<MendStatisticsModel>();
|
|
condition = CopyToModel<MendRecorder, MendStatisticsModel>(seachModel);
|
|
|
|
#region wcf服务统一接口
|
|
listResult = wcfAgent.InvokeServiceFunction<DataResult<List<MendRecorder>>>(QMAPP.ServicesAgent.B9IPCService.MendRecorderBLL_GetMendRecorderStatistics.ToString(), condition);
|
|
#endregion
|
|
|
|
if (listResult.IsSuccess == false)
|
|
{
|
|
SetMessage(listResult.Msg);
|
|
return View("Index", seachModel);
|
|
}
|
|
|
|
|
|
if (listResult.Result.Count == 0)
|
|
{
|
|
SetMessage("未查到相关数据!");
|
|
}
|
|
|
|
if (seachModel.MENDTYPE == EnumGeter.MENDSTATICTYPE.SCARPRATE.GetHashCode().ToString())
|
|
{
|
|
string arr = "[";
|
|
|
|
foreach (var mr in listResult.Result)
|
|
{
|
|
if (arr.Length > 1)
|
|
{
|
|
arr += ",";
|
|
}
|
|
|
|
arr += "{ \"CODE\":" + "\"" + mr.DEFECTVALUE.Substring(5) + "\"";
|
|
arr += ",\"NAME\":" + "\"" + mr.DEFECTVALUE.Substring(5) + "\"";
|
|
arr += ",\"QUATITY\":" + "\"" + mr.QUATITY + "\"";
|
|
arr += "}";
|
|
}
|
|
|
|
arr += "]";
|
|
|
|
seachModel.arr = arr;
|
|
var machines = new { CODE = "QUATITY", NAME = "" };
|
|
seachModel.results = "[" + JsonConvertHelper.GetSerializes(machines) + "]";
|
|
}
|
|
else if (seachModel.MENDTYPE == EnumGeter.MENDSTATICTYPE.MENDRATE.GetHashCode().ToString())
|
|
{
|
|
string arr = "[";
|
|
|
|
foreach (var mr in listResult.Result)
|
|
{
|
|
|
|
|
|
decimal rate = Math.Round((decimal)mr.COUNTVALUE / (decimal)mr.SUMVALUE, 3);
|
|
if (arr.Length > 1)
|
|
{
|
|
arr += ",";
|
|
}
|
|
|
|
arr += "{ \"CODE\":" + "\"" + mr.DEFECTVALUE.Substring(5) + "\"";
|
|
arr += ",\"NAME\":" + "\"" + mr.DEFECTVALUE.Substring(5) + "\"";
|
|
arr += ",\"QUATITY\":" + "\"" + (rate * 100).ToString() + "\"";
|
|
arr += "}";
|
|
}
|
|
|
|
arr += "]";
|
|
|
|
seachModel.arr = arr;
|
|
var machines = new { CODE = "QUATITY", NAME = "" };
|
|
seachModel.results = "[" + JsonConvertHelper.GetSerializes(machines) + "]";
|
|
}
|
|
else if (seachModel.MENDTYPE == EnumGeter.MENDSTATICTYPE.MENDSUM.GetHashCode().ToString())
|
|
{
|
|
string arr = "[";
|
|
|
|
foreach (var mr in listResult.Result)
|
|
{
|
|
|
|
|
|
if (arr.Length > 1)
|
|
{
|
|
arr += ",";
|
|
}
|
|
|
|
arr += "{ \"CODE\":" + "\"" + mr.DEFECTVALUE.Substring(5) + "\"";
|
|
arr += ",\"NAME\":" + "\"" + mr.DEFECTVALUE.Substring(5) + "\"";
|
|
arr += ",\"QUATITY\":" + "\"" + mr.QUATITY + "\"";
|
|
arr += "}";
|
|
}
|
|
|
|
arr += "]";
|
|
|
|
seachModel.arr = arr;
|
|
var machines = new { CODE = "QUATITY", NAME = "" };
|
|
seachModel.results = "[" + JsonConvertHelper.GetSerializes(machines) + "]";
|
|
}
|
|
else if (seachModel.MENDTYPE == EnumGeter.MENDSTATICTYPE.PRODUCEMENDRATE.GetHashCode().ToString())
|
|
{
|
|
|
|
string arr = "[";
|
|
|
|
foreach (var mr in listResult.Result)
|
|
{
|
|
|
|
|
|
decimal rate = Math.Round((decimal)mr.COUNTVALUE / (decimal)mr.SUMVALUE, 3);
|
|
if (arr.Length > 1)
|
|
{
|
|
arr += ",";
|
|
}
|
|
|
|
arr += "{ \"CODE\":" + "\"" + mr.DEFECTVALUE.Substring(5) + "\"";
|
|
arr += ",\"NAME\":" + "\"" + mr.DEFECTVALUE.Substring(5) + "\"";
|
|
arr += ",\"QUATITY\":" + "\"" + (rate * 100).ToString() + "\"";
|
|
arr += "}";
|
|
}
|
|
|
|
arr += "]";
|
|
|
|
seachModel.arr = arr;
|
|
var machines = new { CODE = "QUATITY", NAME = "" };
|
|
seachModel.results = "[" + JsonConvertHelper.GetSerializes(machines) + "]";
|
|
}
|
|
else
|
|
{
|
|
seachModel.arr = JsonConvertHelper.GetSerializes(listResult.Result);
|
|
}
|
|
|
|
return View("Index", seachModel);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 导出excel
|
|
/// <summary>
|
|
/// 导出excel
|
|
/// </summary>
|
|
/// <returns>结果</returns>
|
|
[HttpPost]
|
|
public ActionResult ExportExcel()
|
|
{
|
|
MendStatisticsModel seachModel = null;
|
|
DataResult<DataTable> listResult = new DataResult<DataTable>();
|
|
DataPage page = new DataPage();
|
|
ServiceAgent wcfAgent = this.GetServiceAgent();
|
|
MendRecorder condition = null;
|
|
try
|
|
{
|
|
//获取查询对象
|
|
seachModel = GetModel<MendStatisticsModel>();
|
|
condition = CopyToModel<MendRecorder, MendStatisticsModel>(seachModel);
|
|
#region wcf服务统一接口
|
|
listResult = wcfAgent.InvokeServiceFunction<DataResult<DataTable>>(QMAPP.ServicesAgent.B9IPCService.MendRecorderBLL_ExportMendRecorderStatistics.ToString(), condition);
|
|
#endregion
|
|
QMFrameWork.WebUI.Util.IEFileTool efTool = new QMFrameWork.WebUI.Util.IEFileTool();
|
|
DataTable dt = JsonConvertHelper.GetDeserialize<DataTable>(JsonConvertHelper.GetSerializes(listResult.Result));
|
|
|
|
if (condition.MENDTYPE == EnumGeter.MENDSTATICTYPE.DEFECTTYPE.GetHashCode().ToString())
|
|
{
|
|
return efTool.GetExcelFileResult("DefectTypeExp", "返修件缺陷类型统计.xlsx", dt);
|
|
}
|
|
else if (condition.MENDTYPE == EnumGeter.MENDSTATICTYPE.DEFECTPOSITION.GetHashCode().ToString())
|
|
{
|
|
return efTool.GetExcelFileResult("DefectPositionExp", "返修件缺陷位置统计.xlsx", dt);
|
|
}
|
|
else if (condition.MENDTYPE == EnumGeter.MENDSTATICTYPE.DEFECTTEAM.GetHashCode().ToString())
|
|
{
|
|
return efTool.GetExcelFileResult("DefectTeamExp", "缺陷班次分布统计.xlsx", dt);
|
|
}
|
|
else if (condition.MENDTYPE == EnumGeter.MENDSTATICTYPE.MENDRATE.GetHashCode().ToString())
|
|
{
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
decimal COUNTVALUE = Convert.ToDecimal(dt.Rows[i]["COUNTVALUE"]);
|
|
decimal SUMVALUE = Convert.ToDecimal(dt.Rows[i]["SUMVALUE"]);
|
|
decimal rate = Math.Round(COUNTVALUE * 100 / SUMVALUE, 1);
|
|
dt.Rows[i]["PERCENTVALUE"] = (rate).ToString() + "%";
|
|
}
|
|
|
|
return efTool.GetExcelFileResult("MendRateExp", "返修率趋势图统计.xlsx", dt);
|
|
|
|
}
|
|
else if (condition.MENDTYPE == EnumGeter.MENDSTATICTYPE.MENDSUM.GetHashCode().ToString())
|
|
{
|
|
return efTool.GetExcelFileResult("MendSumExp", "返修数量趋势图统计.xlsx", dt);
|
|
}
|
|
else if (condition.MENDTYPE == EnumGeter.MENDSTATICTYPE.PRODUCEMENDRATE.GetHashCode().ToString())
|
|
{
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
decimal COUNTVALUE = Convert.ToDecimal(dt.Rows[i]["COUNTVALUE"]);
|
|
decimal SUMVALUE = Convert.ToDecimal(dt.Rows[i]["SUMVALUE"]);
|
|
decimal rate = Math.Round(COUNTVALUE * 100 / SUMVALUE, 1);
|
|
dt.Rows[i]["PERCENTVALUE"] = (rate).ToString() + "%";
|
|
}
|
|
return efTool.GetExcelFileResult("ProduceMendRateExp", "生产返修对比趋势图统计.xlsx", dt);
|
|
}
|
|
else if (condition.MENDTYPE == EnumGeter.MENDSTATICTYPE.SCARPRATE.GetHashCode().ToString())
|
|
{
|
|
return efTool.GetExcelFileResult("ScarpRateExp", "废品趋势图统计.xlsx", dt);
|
|
}
|
|
else
|
|
{
|
|
return efTool.GetExcelFileResult("ScarpDefectExp", "废品缺陷类型统计.xlsx", dt);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|