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.
174 lines
6.7 KiB
174 lines
6.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using QMAPP.FJC.Entity.Operation;
|
|
using QMAPP.FJC.Web.Models.StatisticalAnalysis;
|
|
using QMFrameWork.WebUI.Attribute;
|
|
using QMAPP.Common.Web.Controllers;
|
|
using QMAPP.KB.Entity;
|
|
using QMFrameWork.Data;
|
|
using QMAPP.ServicesAgent;
|
|
using QMFrameWork.WebUI.DataSource;
|
|
using QMFrameWork.Common.Serialization;
|
|
using System.Data;
|
|
using QMAPP.FJC.Entity.Basic;
|
|
|
|
|
|
namespace QMAPP.FJC.Web.Controllers
|
|
{
|
|
public class FirstPassYieldController : QController
|
|
{
|
|
/// <summary>
|
|
/// 模块编号:M10-5
|
|
/// 作 用:直通率分析控制层
|
|
/// 作 者:王庆男
|
|
/// 编写日期:2015年07月06日
|
|
///</summary>
|
|
#region 初始化
|
|
/// <summary>
|
|
/// 初始化
|
|
/// </summary>
|
|
/// <returns>结果</returns>
|
|
[HandleException]
|
|
public ActionResult Init()
|
|
{
|
|
FirstPassYieldModel seachModel = new FirstPassYieldModel();
|
|
return View("FirstPassYield", seachModel);
|
|
}
|
|
#endregion
|
|
#region 获取列表
|
|
/// <summary>
|
|
/// 加载列表
|
|
/// </summary>
|
|
/// <returns>结果</returns>
|
|
[HandleException]
|
|
public ActionResult List()
|
|
{
|
|
FirstPassYieldModel seachModel = null;
|
|
DataResult<List<MainOperation>> listResult = new DataResult<List<MainOperation>>();
|
|
DataPage page = new DataPage();
|
|
ServiceAgent wcfAgent = this.GetServiceAgent();
|
|
MainOperation condition = null;
|
|
try
|
|
{
|
|
//获取查询对象
|
|
seachModel = GetModel<FirstPassYieldModel>();
|
|
condition = CopyToModel<MainOperation, FirstPassYieldModel>(seachModel);
|
|
|
|
#region wcf服务统一接口
|
|
listResult = wcfAgent.InvokeServiceFunction<DataResult<List<MainOperation>>>(QMAPP.ServicesAgent.B9BasicService.MainOperationBLL_GetListGroupByStauts.ToString(), condition);
|
|
#endregion
|
|
|
|
if (listResult.IsSuccess == false)
|
|
{
|
|
SetMessage(listResult.Msg);
|
|
return View("FirstPassYield", seachModel);
|
|
}
|
|
double totalRate = 1;
|
|
foreach (MainOperation item in listResult.Result)
|
|
{
|
|
item.RATE = (Convert.ToDouble(item.QUALIFIED) / (Convert.ToDouble(item.QUALIFIED) + Convert.ToDouble(item.REPAIR) + Convert.ToDouble(item.CANCEL)) * 100).ToString("f2");
|
|
totalRate = totalRate * (Convert.ToDouble(item.QUALIFIED) / (Convert.ToDouble(item.QUALIFIED) + Convert.ToDouble(item.REPAIR) + Convert.ToDouble(item.CANCEL)));
|
|
}
|
|
seachModel.results = (totalRate * 100).ToString("f2");
|
|
seachModel.arr = JsonConvertHelper.GetSerializes(listResult.Result);
|
|
if (listResult.Result.Count == 0)
|
|
{
|
|
SetMessage("未查到相关数据!");
|
|
}
|
|
return View("FirstPassYield", seachModel);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 导出excel
|
|
/// <summary>
|
|
/// 导出excel
|
|
/// </summary>
|
|
/// <returns>结果</returns>
|
|
[HttpPost]
|
|
public ActionResult ExportExcel()
|
|
{
|
|
FirstPassYieldModel seachModel = null;
|
|
MainOperation condition = null;
|
|
ServiceAgent wcfAgent = this.GetServiceAgent();
|
|
DataResult<List<MainOperation>> listResult = new DataResult<List<MainOperation>>();
|
|
try
|
|
{
|
|
//获取查询对象
|
|
seachModel = GetModel<FirstPassYieldModel>();
|
|
condition = CopyToModel<MainOperation, FirstPassYieldModel>(seachModel);
|
|
|
|
#region wcf服务统一接口
|
|
listResult = wcfAgent.InvokeServiceFunction<DataResult<List<MainOperation>>>(QMAPP.ServicesAgent.B9BasicService.MainOperationBLL_GetListGroupByStauts.ToString(), condition);
|
|
#endregion
|
|
|
|
double totalRate = 1;
|
|
foreach (MainOperation item in listResult.Result)
|
|
{
|
|
item.RATE = (Convert.ToDouble(item.QUALIFIED) / (Convert.ToDouble(item.QUALIFIED) + Convert.ToDouble(item.REPAIR) + Convert.ToDouble(item.CANCEL)) * 100).ToString("f2");
|
|
totalRate = totalRate * (Convert.ToDouble(item.QUALIFIED) / (Convert.ToDouble(item.QUALIFIED) + Convert.ToDouble(item.REPAIR) + Convert.ToDouble(item.CANCEL)));
|
|
}
|
|
//导出
|
|
QMFrameWork.WebUI.Util.IEFileTool efTool = new QMFrameWork.WebUI.Util.IEFileTool();
|
|
DataTable dt = JsonConvertHelper.GetDeserialize<DataTable>(JsonConvertHelper.GetSerializes(listResult.Result));
|
|
return efTool.GetExcelFileResult("FirstPassYieldExp", "直通率分析.xlsx", dt);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 获取工序类别下拉列表
|
|
/// <summary>
|
|
/// 获取工序类别下拉列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ContentResult GetComboxSource()
|
|
{
|
|
List<ProcessInfo> listProcessInfo = new List<ProcessInfo>();
|
|
ComboboxResult model = new ComboboxResult();
|
|
ServiceAgent wcfAgent = this.GetServiceAgent();
|
|
ProcessSet entity = new ProcessSet();
|
|
DataResult<List<ProcessInfo>> result = new DataResult<List<ProcessInfo>>();
|
|
try
|
|
{
|
|
//获取工序信息
|
|
result = wcfAgent.InvokeServiceFunction<DataResult<List<ProcessInfo>>>(QMAPP.ServicesAgent.B9BasicService.ProcessSetBLL_GetProcessInfoList.ToString(), entity);
|
|
if (result.IsSuccess == false)
|
|
{
|
|
SetMessage(result.Msg);
|
|
return Content(model.ToString());
|
|
}
|
|
foreach (var item in result.Result)
|
|
{
|
|
if (model.Items.Count == 0)
|
|
{
|
|
model.Add(new ComboboxItem { ID = "", Text = "" });
|
|
}
|
|
else
|
|
{
|
|
model.Add(new ComboboxItem { ID = item.PROCESSTYPE, Text = item.PROCESSNAME });
|
|
|
|
}
|
|
}
|
|
return Content(model.ToString());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|