停机原因TOP3
This commit is contained in:
parent
3c0a8e1531
commit
b4da1aed29
@ -134,11 +134,12 @@ namespace DOAN.Admin.WebApi.Controllers
|
||||
|
||||
|
||||
//TODO 停机原因TOP3
|
||||
//public IActionResult actionResult GetDeviceDowntimeRecordReasonTop3()
|
||||
//{
|
||||
// //TODO 停机原因TOP3
|
||||
// return ToResponse(new ApiResult((int)ResultCode.SUCCESS, "停机原因TOP3"));
|
||||
//}
|
||||
public IActionResult GetDeviceDowntimeRecordReasonTop3()
|
||||
{
|
||||
|
||||
EchartsOptions response = _DeviceDowntimeRecordService.GetDeviceDowntimeRecordReasonTop3(10);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -180,5 +180,47 @@ namespace DOAN.Service.MES.dev
|
||||
};
|
||||
return echartsOptions;
|
||||
}
|
||||
|
||||
|
||||
public EchartsOptions GetDeviceDowntimeRecordReasonTop3(int top)
|
||||
{
|
||||
var result= Context.Queryable<DeviceDowntimeRecord>()
|
||||
.Where(x => x.FaultReason != null)
|
||||
.GroupBy(x => x.FaultReason)
|
||||
.Select(x => new
|
||||
{
|
||||
FaultReason = x.FaultReason,
|
||||
TotalDowntime = SqlFunc.AggregateSum(x.ConsumeTime.Value)
|
||||
})
|
||||
.OrderByDescending(x => x.TotalDowntime)
|
||||
.Take(top)
|
||||
.MergeTable()
|
||||
.Select(x => new EchartsSeriesData
|
||||
{
|
||||
Name = x.FaultReason,
|
||||
Value = x.TotalDowntime
|
||||
})
|
||||
.ToList();
|
||||
var echartsOptions = new EchartsOptions
|
||||
{
|
||||
Title = new EchartsTitle("设备停机时间统计", "按月统计停机时间"),
|
||||
YAxis = new EchartsYAxis
|
||||
{
|
||||
Type = "category",
|
||||
Data = result.Select(x => x.Name).ToList(),
|
||||
},
|
||||
|
||||
Series = new List<EchartsSeries>
|
||||
{
|
||||
new EchartsSeries
|
||||
{
|
||||
Name = "停机时间",
|
||||
Type = "bar",
|
||||
Data = result
|
||||
}
|
||||
}
|
||||
};
|
||||
return echartsOptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,5 +24,7 @@ namespace DOAN.Service.MES.dev.IService
|
||||
|
||||
EchartsOptions GetDeviceDowntimeRecordMonthBarChart();
|
||||
|
||||
EchartsOptions GetDeviceDowntimeRecordReasonTop3(int top);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user