nli, string TYPE_COUNT)
{
StringBuilder html = new StringBuilder();
if (nli == null)
{
return "没有数据";
}
//拼接表头 第一行
html.Append("产品种类 | ");
string timetype = "号";
if (TYPE_COUNT == "WEEK")
{
timetype = "周";
}
else if (TYPE_COUNT == "MONTH")
{
timetype = "月";
}
foreach (EqueUseCountDModel item in nli)
{
if (html.ToString().Contains(item.TDAY + timetype))
{
continue;
}
html.Append("");
if (item.TDAY.Equals("累计"))
{
html.Append(item.TDAY);
}
else
{
html.Append(item.TDAY + timetype);
}
html.Append(" | ");
}
html.Append("
");
//拼接主体数据
html.Append("");
html.Append("开机时间(h)");
html.Append(" | ");
foreach (EqueUseCountDModel item in nli)
{
html.Append("");
html.Append(item.BOOTTIMES);
html.Append(" | ");
}
html.Append("
");
html.Append("");
html.Append("加工时间(h)");
html.Append(" | ");
foreach (EqueUseCountDModel item in nli)
{
html.Append("");
html.Append(item.WORKTIMES);
html.Append(" | ");
}
html.Append("
");
html.Append("");
html.Append("利用率");
html.Append(" | ");
foreach (EqueUseCountDModel item in nli)
{
html.Append("");
html.Append((Convert.ToDouble(item.WORKTIMES) / Convert.ToDouble(item.BOOTTIMES) * 100).ToString("0")+"%");
html.Append(" | ");
}
html.Append("
");
html.Append("");
html.Append("目标值");
html.Append(" | ");
foreach (EqueUseCountDModel item in nli)
{
html.Append("");
html.Append(item.val+"%");
html.Append(" | ");
}
html.Append("
");
return html.ToString();
}
///
/// 堆积柱状图
///
/// 处理结果
[HandleException]
public ActionResult GetEchartDataBar2()
{
EqueUseCountVModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
EqueUseCountDModel condition = null;
List nli = new List();
try
{
//获取查询对象
seachModel = GetModel();
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
condition = CopyToModel(seachModel);
#region wcf服务统一接口
var dataResult = wcfAgent.InvokeServiceFunction>>("EqueUseCountBLL_GetAllList", condition);
nli = dataResult.Result;
#endregion
}
catch (Exception ex)
{
throw ex;
}
string kaiji = "", jiagong = "", wlv = "", mlv = "",dou="",tday="",timetype="号";
bool first = true;
if (condition.TYPE_COUNT=="WEEK")
{
timetype = "周";
}
else if (condition.TYPE_COUNT=="MONTH")
{
timetype = "月";
}
if (nli==null)
{
return Content("没有数据");
}
foreach (EqueUseCountDModel item in nli)
{
kaiji += dou + "'" + item.BOOTTIMES + "'";
jiagong += dou + "'" + item.WORKTIMES + "'";
wlv += dou + "'" + (Convert.ToDouble(item.WORKTIMES) / Convert.ToDouble(item.BOOTTIMES) * 100).ToString("0") + "'";
mlv += dou + "'" + item.val + "'";
tday += dou + "'" + item.TDAY + timetype + "'";
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: [" + tday + @"]
}
],
yAxis: [
{
type: 'value',
name: '小时',
axisLabel: {
formatter: '{value} h'
}
},
{
type: 'value',
name: '百分比',
axisLabel: {
formatter: '{value} %'
}
}
],
series: [
{
name: '开机时间',
type: 'bar',
data: [" + kaiji + @"]
},
{
name: '加工时间',
type: 'bar',
data: [" + jiagong + @"]
},
{
name: '利用率',
type: 'line',
yAxisIndex: 1,
data: [" + wlv + @"]
,itemStyle: { normal: { label: { show: true}} }
},
{
name: '目标值',
type: 'line',
yAxisIndex: 1,
data: [" + mlv + @"]
, 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
}
}