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

304 lines
8.6 KiB

using System;
using System.Collections.Generic;
using System.Linq;
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;
using System.Text;
namespace QMAPP.MESReport.Web.Controllers
{
/// <summary>
/// 班次节拍统计
/// 周晓东
/// 2017-10-30
/// </summary>
public class ProduceCycleTimeShiftController : QController
{
/// <summary>
///
/// </summary>
/// <returns></returns>
public ActionResult Index()
{
ProduceCycleTimeVModel seachModel = new ProduceCycleTimeVModel();
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()
{
ProduceCycleTimeVModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
ProduceCycleTimeDModel condition = null;
List<ProduceCycleTimeDModel> nli = new List<ProduceCycleTimeDModel>();
try
{
//获取查询对象
seachModel = GetModel<ProduceCycleTimeVModel>();
if (string.IsNullOrEmpty(seachModel.START_DATE) || string.IsNullOrEmpty(seachModel.END_DATE))
{
//return Content(null);
}
else
{
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
condition = CopyToModel<ProduceCycleTimeDModel, ProduceCycleTimeVModel>(seachModel);
#region wcf服务统一接口
var dataResult =
wcfAgent.InvokeServiceFunction<DataResult<List<ProduceCycleTimeDModel>>>(
"ProduceCycleTimeBLL_GetAllListShift", condition);
nli = dataResult.Result;
#endregion
}
}
catch (Exception ex)
{
throw ex;
}
#region //源数据定义
// string category = "", val1 = "",dou="";
// bool first = true;
// foreach (ProduceCycleTimeDModel item in nli)
// {
// category += dou + "'" + item.MACHINECODDE + "'";
// val1 += dou + "'" + item.val + "'";
// 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: ['生产节拍(s)']
// },
// xAxis: [
// {
// type: 'category',
// data: ["+category+@"]
// }
// ],
// yAxis: [
// {
// type: 'value',
// name: 's',
// axisLabel: {
// formatter: '{value} s'
// }
// }
// ],
// series: [
//
// {
// name: '生产节拍(s)',
// type: 'bar',
// data: ["+val1+@"]
// }
// ]
// }";
#endregion
#region 源数据定义
string fenmu = "", fenzi = "", bfb = "", xLabe = "", dou = "";
bool first = true;
foreach (ProduceCycleTimeDModel item in nli)
{
fenmu += dou + "'" + item.val + "'";
fenzi += dou + "'" + item.OK_QTY + "'";
bfb += dou + "'" + (Convert.ToDouble(item.OK_QTY) / Convert.ToDouble(item.val)*100).ToString("#0") + "'";
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: false },
magicType: { show: true, type: ['line', 'bar'] },
restore: { show: true },
saveAsImage: { show: true }
}
},
//calculable: true,
legend: {
data: ['合格数', '节拍数']
},
dataZoom : {
show : true,
realtime : true,
start : 0,
end : 100
},
grid: {
y2: 120
},
xAxis: [
{
type: 'category',
axisLine: {onZero: false},
axisLabel : { //坐标轴刻度标签的相关设置。
interval:0,
rotate:20
},
data: [" + xLabe + @"]
}
],
yAxis: [
{
type: 'value',
name: '数量',
axisLabel: {
formatter: '{value}'
}
},
{
type: 'value',
name: '百分比',
axisLabel: {
formatter: '{value}'
}
// scale: true,
// max: 100,
// min: 0,
// boundaryGap: [" + bfb + @"]
}
],
series: [
{
name: '合格数',
type: 'bar',
barMaxWidth: '100',
itemStyle: {
normal: {
label: {
show: true,
//position: 'inside'
}
}
},
data: [" + fenzi + @"]
},
{
name: '节拍数',
type: 'bar',
barMaxWidth: '100',
itemStyle: {
normal: {
label: {
show: true,
//position: 'inside'
}
}
},
data: [" + fenmu + @"]
},
{
name: '节拍率',
type: 'line',
yAxisIndex: 1,
data: [" + bfb + @"]
, itemStyle: {
normal: {
label: {
show: true,
textStyle: {
fontWeight: 'normal', //标题颜色
color: '#CD0000'
}
}
}
}
}
]
}";
#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
}
}