本月各组异常时间统计
This commit is contained in:
parent
f9c7ed5ec6
commit
16c749ffe2
@ -29,7 +29,7 @@ namespace DOAN.Service.MES.BI
|
||||
public List<AndonFaultRecordDto> QueryTodayAndonFaultRecord()
|
||||
{
|
||||
var predicate = Expressionable.Create<AndonFaultRecord>()
|
||||
.And(it=>it.CreatedTime>=DateTime.Now.Date)
|
||||
.And(it => it.CreatedTime >= DateTime.Now.Date)
|
||||
.Or(it => it.Status == 0)
|
||||
;
|
||||
var response = Queryable()
|
||||
@ -131,8 +131,8 @@ namespace DOAN.Service.MES.BI
|
||||
|
||||
EchartsSeries seriesLine = new EchartsSeries();
|
||||
seriesLine.Name = "累计停机时间";
|
||||
seriesLine.Type= "line";
|
||||
List<EchartsSeriesData> seriesLine_data=null;
|
||||
seriesLine.Type = "line";
|
||||
List<EchartsSeriesData> seriesLine_data = null;
|
||||
var result = Context.Queryable<AndonFaultRecord>()
|
||||
.Where(x => x.CreatedTime >= firstDayOfMonth && x.CreatedTime <= lastDayOfMonth)
|
||||
.GroupBy(x => x.CreatedTime.Value.Date) // 按日期分组
|
||||
@ -146,18 +146,18 @@ namespace DOAN.Service.MES.BI
|
||||
var allDaysInMonth = Enumerable.Range(0, (lastDayOfMonth - firstDayOfMonth).Days + 1)
|
||||
.Select(offset => firstDayOfMonth.AddDays(offset).Date)
|
||||
.ToList();
|
||||
seriesLine_data = allDaysInMonth
|
||||
.GroupJoin(result,
|
||||
date => date,
|
||||
summary => summary.Date,
|
||||
(date, summaries) => new EchartsSeriesData
|
||||
{
|
||||
Name = date.ToString("MM-dd"),
|
||||
Value = summaries.FirstOrDefault()?.TotalDuration ?? 0
|
||||
})
|
||||
.OrderBy(x => x.Name)
|
||||
.ToList();
|
||||
seriesLine.Data= seriesLine_data;
|
||||
seriesLine_data = allDaysInMonth
|
||||
.GroupJoin(result,
|
||||
date => date,
|
||||
summary => summary.Date,
|
||||
(date, summaries) => new EchartsSeriesData
|
||||
{
|
||||
Name = date.ToString("MM-dd"),
|
||||
Value = summaries.FirstOrDefault()?.TotalDuration ?? 0
|
||||
})
|
||||
.OrderBy(x => x.Name)
|
||||
.ToList();
|
||||
seriesLine.Data = seriesLine_data;
|
||||
|
||||
echartsOptionsSeries.Add(seriesLine);
|
||||
#endregion
|
||||
@ -165,16 +165,16 @@ namespace DOAN.Service.MES.BI
|
||||
|
||||
|
||||
//获取故障字典
|
||||
List<AndonFaultDict> andonFaults= Context.Queryable<AndonFaultDict>().ToList();
|
||||
foreach(var andonFault in andonFaults)
|
||||
List<AndonFaultDict> andonFaults = Context.Queryable<AndonFaultDict>().ToList();
|
||||
foreach (var andonFault in andonFaults)
|
||||
{
|
||||
EchartsSeries seriesBar = new EchartsSeries();
|
||||
seriesBar.Name = andonFault.Name+"停机时间";
|
||||
seriesBar.Name = andonFault.Name + "停机时间";
|
||||
seriesBar.Type = "bar";
|
||||
List<EchartsSeriesData> seriesLine_data_bar = null;
|
||||
var result01 = Context.Queryable<AndonFaultRecord>()
|
||||
.Where(x => x.CreatedTime >= firstDayOfMonth && x.CreatedTime <= lastDayOfMonth)
|
||||
.Where(x=>x.FaultDict== andonFault.Name)
|
||||
.Where(x => x.FaultDict == andonFault.Name)
|
||||
.GroupBy(x => x.CreatedTime.Value.Date) // 按日期分组
|
||||
.Select(x => new
|
||||
{
|
||||
@ -202,7 +202,7 @@ namespace DOAN.Service.MES.BI
|
||||
}
|
||||
|
||||
#endregion
|
||||
echartsOptions.Series= echartsOptionsSeries;
|
||||
echartsOptions.Series = echartsOptionsSeries;
|
||||
|
||||
return echartsOptions;
|
||||
|
||||
@ -215,18 +215,18 @@ namespace DOAN.Service.MES.BI
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, bool> LineRealTimeStatus()
|
||||
{
|
||||
return Context.Queryable<BaseWorkRoute>()
|
||||
.LeftJoin<AndonFaultRecord>((r,a)=>r.Code==a.LineCode&&a.Status==1)
|
||||
.Select((r, a) => new
|
||||
{
|
||||
Code = r.Code,
|
||||
IsAndonFaultRecordNotNull = SqlFunc.IsNullOrEmpty(a.Id)
|
||||
})
|
||||
.ToList() // 将查询结果转换为列表
|
||||
.ToDictionary(
|
||||
x => x.Code, // 字典的 key 是 r.Code
|
||||
x => x.IsAndonFaultRecordNotNull // 字典的 value 是判断 a 是否为空
|
||||
);
|
||||
return Context.Queryable<BaseWorkRoute>()
|
||||
.LeftJoin<AndonFaultRecord>((r, a) => r.Code == a.LineCode && a.Status == 1)
|
||||
.Select((r, a) => new
|
||||
{
|
||||
Code = r.Code,
|
||||
IsAndonFaultRecordNotNull = SqlFunc.IsNullOrEmpty(a.Id)
|
||||
})
|
||||
.ToList() // 将查询结果转换为列表
|
||||
.ToDictionary(
|
||||
x => x.Code, // 字典的 key 是 r.Code
|
||||
x => x.IsAndonFaultRecordNotNull // 字典的 value 是判断 a 是否为空
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@ -242,7 +242,7 @@ namespace DOAN.Service.MES.BI
|
||||
// X轴
|
||||
EchartsXAxis echartsXAxis = new EchartsXAxis();
|
||||
|
||||
echartsXAxis.Data= Context.Queryable<BaseWorkRoute>().Where(it=>it.Status>0).Select(it=>it.Code).ToList();
|
||||
echartsXAxis.Data = Context.Queryable<BaseWorkRoute>().Where(it => it.Status > 0).Select(it => it.Code).ToList();
|
||||
echartsOptions.XAxis = echartsXAxis;
|
||||
|
||||
|
||||
@ -253,32 +253,25 @@ namespace DOAN.Service.MES.BI
|
||||
|
||||
List<EchartsSeriesData> seriesData = new List<EchartsSeriesData>();
|
||||
|
||||
var subquery= Context.Queryable<AndonFaultRecord>().GroupBy(it => it.LineCode)
|
||||
.Select(it => new
|
||||
{
|
||||
LineCode = it.LineCode,
|
||||
TotalDuration = SqlFunc.AggregateSum(it.Duration)
|
||||
});
|
||||
Context.Queryable<AndonFaultRecord>().GroupBy(it => it.LineCode)
|
||||
|
||||
Context.Queryable<BaseWorkRoute>().LeftJoin(subquery,(r,s)=>r.Code==s.LineCode)
|
||||
.Select((r, s) => new
|
||||
.Select(it => new
|
||||
{
|
||||
Code = r.Code,
|
||||
TotalDuration = SqlFunc.IsNullOrEmpty(s.TotalDuration) ? 0 : s.TotalDuration
|
||||
})
|
||||
.ToList()
|
||||
.ForEach(it =>
|
||||
{
|
||||
seriesData.Add(new EchartsSeriesData
|
||||
{
|
||||
Name = it.Code,
|
||||
Value = it.TotalDuration??0
|
||||
});
|
||||
});
|
||||
LineCode = it.LineCode,
|
||||
TotalDuration = SqlFunc.AggregateSum(it.Duration)
|
||||
}).MergeTable().OrderByDescending(it => it.TotalDuration)
|
||||
.ForEach(it =>
|
||||
{
|
||||
seriesData.Add(new EchartsSeriesData
|
||||
{
|
||||
Name = it.LineCode,
|
||||
Value = it.TotalDuration ?? 0
|
||||
});
|
||||
});
|
||||
|
||||
echartsSeries.Data=seriesData;
|
||||
echartsSeries.Data = seriesData;
|
||||
|
||||
echartsOptions.Series=new List<EchartsSeries> { echartsSeries };
|
||||
echartsOptions.Series = new List<EchartsSeries> { echartsSeries };
|
||||
|
||||
|
||||
return echartsOptions;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user