天津投入产出系统后端
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.
 
 
 
 
 
 

276 lines
7.7 KiB

using System;
using System.Collections.Generic;
using System.Web.Mvc;
using QMAPP.MESReport.Web.Models.LineQTY;
using QMAPP.Common.Web.Controllers;
using QMFrameWork.WebUI.Attribute;
using QMFrameWork.Data;
using QMAPP.Entity;
using QMAPP.ServicesAgent;
using QMAPP.MESReport.Entity.LineQTY;
namespace QMAPP.MESReport.Web.Controllers
{
/// <summary>
/// 不合格率分析
/// 周晓东
/// 2017-10-13
/// </summary>
public class StandardNotRateCountController : QController
{
/// <summary>
/// 主界面
/// </summary>
/// <returns></returns>
public ActionResult QTYStandardNotRate()
{
StandardRateVModel seachModel = new StandardRateVModel();
seachModel.START_DATE = DateTime.Now.Date.AddDays(-30).ToString("yyyy-MM-dd HH:mm:ss");
seachModel.END_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
return View(seachModel);
}
/// <summary>
/// 堆积柱状图
/// </summary>
/// <returns>处理结果</returns>
[HandleException]
public ActionResult GetEchartDataBar2()
{
StandardRateVModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
StandardRateDModel condition = null;
List<StandardRateDModel> nli = new List<StandardRateDModel>();
try
{
//获取查询对象
seachModel = GetModel<StandardRateVModel>();
if (string.IsNullOrEmpty(seachModel.START_DATE) || string.IsNullOrEmpty(seachModel.END_DATE))
{
//return Content(null);
}
else
{
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
condition = CopyToModel<StandardRateDModel, StandardRateVModel>(seachModel);
#region wcf服务统一接口
var dataResult =
wcfAgent.InvokeServiceFunction<DataResult<List<StandardRateDModel>>>(
"StandardRateCountBLL_GetMainListNot", condition);
nli = dataResult.Result;
#endregion
}
}
catch (Exception ex)
{
throw ex;
}
#region 源数据定义
string fenmu = "",
fenzi = "",
bfb = "",
xLabe = "",
dou = "",
ok_Count = "",
ok_rate = "";
bool first = true;
foreach (StandardRateDModel item in nli)
{
fenmu += dou + "'" + item.QTY + "'";
fenzi += dou + "'" + item.NOK_QTY + "'";
ok_Count += dou + "'" + item.OK_QTY + "'";
#region 报废率
if (item.QTY == "0")
{
bfb += dou + "0";
}
else
{
bfb += dou + "'" + (Math.Round(Convert.ToDouble(item.NOK_QTY) / Convert.ToDouble(item.QTY),4) * 100).ToString() + "'";
}
#endregion
#region 合格率
if (item.QTY == "0")
{
bfb += dou + "0";
}
else
{
ok_rate += dou + "'" + (Math.Round(Convert.ToDouble(item.OK_QTY) / Convert.ToDouble(item.QTY), 4) * 100).ToString() + "'";
}
#endregion
xLabe += dou + "'" + item.WORKCELL_NAME + "'";
if (first)
{
first = false;
dou = ",";
}
}
string strOption = @"{
noDataLoadingOption: {
text: '无数据',
effect: 'bubble',
effectOption: {
effect: {
n: 0
}
}
},
tooltip: {
trigger: 'axis'
},
toolbox: {
show: false,
feature: {
mark: { show: true },
dataView: { show: true, readOnly: true },
magicType: { show: true, type: ['line', 'bar'] },
restore: { show: true },
saveAsImage: { show: true }
}
},
legend: {
data: ['不合格数', '合格数','生产数量']
},
dataZoom : {
show : true,
realtime : true,
start : 0,
end : 100
},
grid: {
y2: 90
},
xAxis: [
{
type: 'category',
axisLine: {onZero: false},
axisLabel : {
interval:0,
rotate:10
},
data: [" + xLabe + @"]
}
],
yAxis: [
{
type: 'value',
name: '数量',
axisLabel: {
formatter: '{value}'
}
},
{
type: 'value',
name: '百分比',
axisLabel: {
formatter: '{value}'
}
}
],
series: [
{
name: '不合格数',
type: 'bar',
barMaxWidth: '100',
itemStyle: {
normal: {
label: {
show: true,
}
}
},
data: [" + fenzi + @"]
},
{
name: '合格数',
type: 'bar',
barMaxWidth: '100',
itemStyle: {
normal: {
label: {
show: true,
}
}
},
data: [" + ok_Count + @"]
},
{
name: '生产数量',
type: 'bar',
barMaxWidth: '100',
itemStyle: {
normal: {
label: {
show: true,
}
}
},
data: [" + fenmu + @"]
},
{
name: '不合格率%',
type: 'line',
yAxisIndex: 1,
data: [" + bfb + @"],
itemStyle: { normal: { label: { show: true}} }
}
,
{
name: '合格率%',
type: 'line',
yAxisIndex: 1,
data: [" + ok_rate + @"],
itemStyle: { normal: { label: { show: true}} }
}
]
}";
#endregion
return Content(strOption);
}
#region 导出图片
[HttpPost]
[HandleException]
public ActionResult ExportBanCi()
{
string imgSend = Request.Form["hiChartImg"];
imgSend = imgSend.Replace(" ", "+");
string[] contents = imgSend.Split(',');
imgSend = contents[1];
byte[] content = Convert.FromBase64String(imgSend);
System.Web.Mvc.FileContentResult result = null;
result = new System.Web.Mvc.FileContentResult(content, "application/png");
result.FileDownloadName = System.Web.HttpUtility.UrlEncode("不合格率分析.png", System.Text.Encoding.UTF8);
return result;
}
#endregion
}
}