每月停机时间柱状图
This commit is contained in:
parent
628a3eee67
commit
e547bc89ad
@ -6,6 +6,7 @@ using DOAN.Admin.WebApi.Filters;
|
||||
|
||||
using DOAN.Model.MES.dev;
|
||||
using Infrastructure.Converter;
|
||||
using DOAN.Model.mes.echarts;
|
||||
|
||||
namespace DOAN.Admin.WebApi.Controllers
|
||||
{
|
||||
@ -114,6 +115,32 @@ namespace DOAN.Admin.WebApi.Controllers
|
||||
}
|
||||
|
||||
|
||||
#region 设备停机时间BI
|
||||
|
||||
|
||||
//TODO 每月停机时间柱状图
|
||||
|
||||
/// <summary>
|
||||
/// 每月停机时间柱状图
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IActionResult GetDeviceDowntimeRecordMonthBarChart()
|
||||
{
|
||||
|
||||
EchartsOptions response = _DeviceDowntimeRecordService.GetDeviceDowntimeRecordMonthBarChart();
|
||||
//TODO 每月停机时间柱状图
|
||||
return ToResponse(new ApiResult((int)ResultCode.SUCCESS, "每月停机时间柱状图"));
|
||||
}
|
||||
|
||||
|
||||
//TODO 停机原因TOP3
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DOAN.Model;
|
||||
using DOAN.Model.mes.echarts;
|
||||
using DOAN.Model.MES.dev;
|
||||
using DOAN.Model.MES.dev.Dto;
|
||||
using DOAN.Model.System;
|
||||
@ -126,5 +127,58 @@ namespace DOAN.Service.MES.dev
|
||||
//return response;
|
||||
return Update(model, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public EchartsOptions GetDeviceDowntimeRecordMonthBarChart()
|
||||
{
|
||||
var result = Context.Queryable<DeviceDowntimeRecord>()
|
||||
.Where(x => x.Downdate != null && x.ConsumeTime != null)
|
||||
.GroupBy(x => new
|
||||
{
|
||||
Year = x.Downdate.Value.Year,
|
||||
Month = x.Downdate.Value.Month
|
||||
})
|
||||
.Select(x => new
|
||||
{
|
||||
Year = x.Downdate.Value.Year,
|
||||
Month = x.Downdate.Value.Month,
|
||||
TotalDowntime = SqlFunc.AggregateSum(x.ConsumeTime.Value)
|
||||
})
|
||||
.OrderByDescending(x => x.Year)
|
||||
.OrderByDescending(x => x.Month)
|
||||
.Take(24)
|
||||
.MergeTable()
|
||||
.OrderBy(x => x.Year)
|
||||
.OrderBy(x => x.Month)
|
||||
.Select(x => new EchartsSeriesData
|
||||
{
|
||||
Name = $"{x.Year}-{x.Month.ToString().PadLeft(2, '0')}",
|
||||
Value= x.TotalDowntime
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
||||
var echartsOptions = new EchartsOptions
|
||||
{
|
||||
Title = new EchartsTitle("设备停机时间统计", "按月统计停机时间"),
|
||||
XAxis = new EchartsXAxis
|
||||
{
|
||||
Type = "category",
|
||||
Data = result.Select(x=>x.Name).ToList(),
|
||||
},
|
||||
YAxis = new EchartsYAxis { Type = "value" },
|
||||
Series = new List<EchartsSeries>
|
||||
{
|
||||
new EchartsSeries
|
||||
{
|
||||
Name = "停机时间",
|
||||
Type = "bar",
|
||||
Data = result
|
||||
}
|
||||
}
|
||||
};
|
||||
return echartsOptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ using DOAN.Model.MES.dev;
|
||||
using DOAN.Model.MES.dev.Dto;
|
||||
using System.Collections.Generic;
|
||||
using DOAN.Model;
|
||||
using DOAN.Model.mes.echarts;
|
||||
|
||||
namespace DOAN.Service.MES.dev.IService
|
||||
{
|
||||
@ -21,5 +22,7 @@ namespace DOAN.Service.MES.dev.IService
|
||||
|
||||
int UpdateDeviceDowntimeRecord(DeviceDowntimeRecord parm);
|
||||
|
||||
EchartsOptions GetDeviceDowntimeRecordMonthBarChart();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user