|
|
|
@ -6,6 +6,7 @@ using Microsoft.Data.SqlClient;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using NewLife.Reflection;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
@ -13,7 +14,9 @@ using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using ZhongLianModel;
|
|
|
|
|
|
|
|
|
|
namespace LanShengService
|
|
|
|
|
{
|
|
|
|
@ -906,124 +909,124 @@ namespace LanShengService
|
|
|
|
|
switch (deviceData.Data17)
|
|
|
|
|
{
|
|
|
|
|
case 2:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "加速过电流";
|
|
|
|
|
deviceData.ErrCode = "MJ0002";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-加速过电流";
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "减速过电流";
|
|
|
|
|
deviceData.ErrCode = "MJ0003";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-减速过电流";
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "恒速过电流";
|
|
|
|
|
deviceData.ErrCode = "MJ0004";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-恒速过电流";
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "加速过电压";
|
|
|
|
|
deviceData.ErrCode = "MJ0005";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-加速过电压";
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "减速过电压";
|
|
|
|
|
deviceData.ErrCode = "MJ0006";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-减速过电压";
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "恒速过电压";
|
|
|
|
|
deviceData.ErrCode = "MJ0007";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-恒速过电压";
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "控制电源异常";
|
|
|
|
|
deviceData.ErrCode = "MJ0008";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-控制电源异常";
|
|
|
|
|
break;
|
|
|
|
|
case 9:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "欠电压";
|
|
|
|
|
deviceData.ErrCode = "MJ0009";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-欠电压";
|
|
|
|
|
break;
|
|
|
|
|
case 10:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "变频器过载";
|
|
|
|
|
deviceData.ErrCode = "MJ0010";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-变频器过载";
|
|
|
|
|
break;
|
|
|
|
|
case 11:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "电机过载";
|
|
|
|
|
deviceData.ErrCode = "MJ0011";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-电机过载";
|
|
|
|
|
break;
|
|
|
|
|
case 12:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "输入缺相";
|
|
|
|
|
deviceData.ErrCode = "MJ0012";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-输入缺相";
|
|
|
|
|
break;
|
|
|
|
|
case 13:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "输出缺相";
|
|
|
|
|
deviceData.ErrCode = "MJ0013";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-输出缺相";
|
|
|
|
|
break;
|
|
|
|
|
case 14:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "模块过热";
|
|
|
|
|
deviceData.ErrCode = "MJ0014";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-模块过热";
|
|
|
|
|
break;
|
|
|
|
|
case 15:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "外部故障";
|
|
|
|
|
deviceData.ErrCode = "MJ0015";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-外部故障";
|
|
|
|
|
break;
|
|
|
|
|
case 16:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "通讯异常";
|
|
|
|
|
deviceData.ErrCode = "MJ0016";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-通讯异常";
|
|
|
|
|
break;
|
|
|
|
|
case 17:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "接触器异常";
|
|
|
|
|
deviceData.ErrCode = "MJ0017";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-接触器异常";
|
|
|
|
|
break;
|
|
|
|
|
case 18:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "电流检测异常";
|
|
|
|
|
deviceData.ErrCode = "MJ0018";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-电流检测异常";
|
|
|
|
|
break;
|
|
|
|
|
case 19:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "电机调谐异常";
|
|
|
|
|
deviceData.ErrCode = "MJ0019";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-电机调谐异常";
|
|
|
|
|
break;
|
|
|
|
|
case 20:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "编码器/PG卡异常";
|
|
|
|
|
deviceData.ErrCode = "MJ0020";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-编码器/PG卡异常";
|
|
|
|
|
break;
|
|
|
|
|
case 21:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "EPPROM读写异常";
|
|
|
|
|
deviceData.ErrCode = "MJ0021";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-EPPROM读写异常";
|
|
|
|
|
break;
|
|
|
|
|
case 22:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "变频器硬件故障";
|
|
|
|
|
deviceData.ErrCode = "MJ0022";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-变频器硬件故障";
|
|
|
|
|
break;
|
|
|
|
|
case 23:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "电机对地短路";
|
|
|
|
|
deviceData.ErrCode = "MJ0023";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-电机对地短路";
|
|
|
|
|
break;
|
|
|
|
|
case 26:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "累计运行时间到达";
|
|
|
|
|
deviceData.ErrCode = "MJ0026";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-累计运行时间到达";
|
|
|
|
|
break;
|
|
|
|
|
case 29:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "累计上电时间到达";
|
|
|
|
|
deviceData.ErrCode = "MJ0029";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-累计上电时间到达";
|
|
|
|
|
break;
|
|
|
|
|
case 30:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "掉载";
|
|
|
|
|
deviceData.ErrCode = "MJ0030";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-掉载";
|
|
|
|
|
break;
|
|
|
|
|
case 31:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "运行时PID反馈丢失";
|
|
|
|
|
deviceData.ErrCode = "MJ0031";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-运行时PID反馈丢失";
|
|
|
|
|
break;
|
|
|
|
|
case 40:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "CBC限流保护";
|
|
|
|
|
deviceData.ErrCode = "MJ0040";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-CBC限流保护";
|
|
|
|
|
break;
|
|
|
|
|
case 42:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "速度偏差过大";
|
|
|
|
|
deviceData.ErrCode = "MJ0040";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-速度偏差过大";
|
|
|
|
|
break;
|
|
|
|
|
case 43:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "过速度";
|
|
|
|
|
deviceData.ErrCode = "MJ0043";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-过速度";
|
|
|
|
|
break;
|
|
|
|
|
case 45:
|
|
|
|
|
deviceData.ErrCode = "门机故障";
|
|
|
|
|
deviceData.ErrMsg = "电机过热";
|
|
|
|
|
deviceData.ErrCode = "MJ0045";
|
|
|
|
|
deviceData.ErrMsg = "门机故障-电机过热";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
@ -1283,80 +1286,152 @@ namespace LanShengService
|
|
|
|
|
throw new BadRequestException("单元无效");
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
var TempQuery = Db.Queryable<DeviceError>()
|
|
|
|
|
.WhereIF(report.ErrCodes != null, x => report.ErrCodes!.Any(q => q == x.ErrCode))
|
|
|
|
|
.WhereIF(report.DeviceIds != null, x => report.DeviceIds!.Any(q => q == x.DeviceId))
|
|
|
|
|
.Where(x => x.CreateDate >= report.StartDate && x.CreateDate <= report.EndDate);
|
|
|
|
|
DateTime TempStart = (DateTime)report.StartDate!;
|
|
|
|
|
DateTime TempEnd = (DateTime)report.EndDate!;
|
|
|
|
|
if ((report.CompanyIds != null && report.CompanyIds.Count() > 0) || (report.ProjectIds != null && report.ProjectIds.Count() > 0) || (report.DeviceIds != null && report.DeviceIds.Count() > 0)) {
|
|
|
|
|
var TempCompanyIds = report.CompanyIds;
|
|
|
|
|
var TempProjectIds = report.ProjectIds;
|
|
|
|
|
var TempDeviceIds = report.DeviceIds;
|
|
|
|
|
var TempGpss = Db.Queryable<DeviceDO>()
|
|
|
|
|
.LeftJoin<ProjectDO>((x, y) => x.ProjectId == y.Id)
|
|
|
|
|
.WhereIF(TempCompanyIds != null, (x, y) => TempCompanyIds!.Contains(y.CompanyId))
|
|
|
|
|
.WhereIF(TempProjectIds != null, (x, y) => TempProjectIds!.Contains(x.ProjectId))
|
|
|
|
|
.WhereIF(TempDeviceIds != null, (x, y) => TempDeviceIds!.Contains(x.Id))
|
|
|
|
|
.Where((x, y) => x.Deleted == 0)
|
|
|
|
|
.Select((x,y)=> x.Gps!.ToString())
|
|
|
|
|
.ToList();
|
|
|
|
|
var TempGpsIds = new List<string>();
|
|
|
|
|
TempGpss.ForEach(v => {
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var tempGps = JsonSerializer.Deserialize<IEnumerable<DeviceGpsDO>>(v!);
|
|
|
|
|
TempGpsIds.AddRange(tempGps!.Select(x => x.Id!));
|
|
|
|
|
}
|
|
|
|
|
catch {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
report.GpsIds = TempGpsIds!;
|
|
|
|
|
}
|
|
|
|
|
var TempErrors = await GetDayError(report);
|
|
|
|
|
var TempErrorGroup = TempErrors.Select(x => x.ErrCode).Distinct();
|
|
|
|
|
var TempItems = new List<DeviceErrorReportItem>();
|
|
|
|
|
if (string.IsNullOrEmpty(report.Unit))
|
|
|
|
|
{
|
|
|
|
|
report.Items = await TempQuery
|
|
|
|
|
.GroupBy(x => new { x.ErrCode, x.ErrMsg })
|
|
|
|
|
foreach (var group in TempErrorGroup)
|
|
|
|
|
{
|
|
|
|
|
TempItems.Add(new DeviceErrorReportItem
|
|
|
|
|
{
|
|
|
|
|
Code = group!,
|
|
|
|
|
Msg = TempErrors.First(x => x.ErrCode == group).ErrMsg!,
|
|
|
|
|
Count = TempErrors.Where(x => x.ErrCode == group).Select(x => x.Count).Sum().ToInt()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (report.Unit.ToLower() == "year")
|
|
|
|
|
{
|
|
|
|
|
var TempErrorDate = TempErrors.Select(x => x.Id!.Substring(0, 4)).Distinct();
|
|
|
|
|
foreach (var group in TempErrorGroup)
|
|
|
|
|
{
|
|
|
|
|
var item = new DeviceErrorReportItem
|
|
|
|
|
{
|
|
|
|
|
Code = group!,
|
|
|
|
|
Msg = TempErrors.First(x => x.ErrCode == group).ErrMsg!,
|
|
|
|
|
Count = TempErrors.Where(x => x.ErrCode == group).Select(x => x.Count).Sum().ToInt()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
foreach (var date in TempErrorDate)
|
|
|
|
|
{
|
|
|
|
|
item.Counts.Add(date, TempErrors.Where(x => x.ErrCode == group && x.Id!.IndexOf(date) == 0).Select(x => x.Count).Sum().ToInt());
|
|
|
|
|
}
|
|
|
|
|
TempItems.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (report.Unit.ToLower() == "month") {
|
|
|
|
|
var TempErrorDate = TempErrors.Select(x => x.Id!.Substring(0, 7)).Distinct();
|
|
|
|
|
foreach (var group in TempErrorGroup)
|
|
|
|
|
{
|
|
|
|
|
var item = new DeviceErrorReportItem
|
|
|
|
|
{
|
|
|
|
|
Code = group!,
|
|
|
|
|
Msg = TempErrors.First(x => x.ErrCode == group).ErrMsg!,
|
|
|
|
|
Count = TempErrors.Where(x => x.ErrCode == group).Select(x => x.Count).Sum().ToInt()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
foreach (var date in TempErrorDate)
|
|
|
|
|
{
|
|
|
|
|
item.Counts.Add(date, TempErrors.Where(x => x.ErrCode == group && x.Id!.IndexOf(date) == 0).Select(x => x.Count).Sum().ToInt());
|
|
|
|
|
}
|
|
|
|
|
TempItems.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (report.Unit.ToLower() == "day")
|
|
|
|
|
{
|
|
|
|
|
var TempErrorDate = TempErrors.Select(x => x.Id).Distinct();
|
|
|
|
|
foreach (var group in TempErrorGroup)
|
|
|
|
|
{
|
|
|
|
|
var item = new DeviceErrorReportItem
|
|
|
|
|
{
|
|
|
|
|
Code = group!,
|
|
|
|
|
Msg = TempErrors.First(x => x.ErrCode == group).ErrMsg!,
|
|
|
|
|
Count = TempErrors.Where(x => x.ErrCode == group).Select(x => x.Count).Sum().ToInt()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
foreach (var date in TempErrorDate)
|
|
|
|
|
{
|
|
|
|
|
item.Counts.Add(date, TempErrors.Where(x => x.ErrCode == group && x.Id!.IndexOf(date) == 0).Select(x => x.Count).Sum().ToInt());
|
|
|
|
|
}
|
|
|
|
|
TempItems.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
report.Items = TempItems;
|
|
|
|
|
report.GpsIds = null;
|
|
|
|
|
return report;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Task<List<DeviceError>> GetDayError(DeviceErrorReport report)
|
|
|
|
|
{
|
|
|
|
|
var TempStart = (DateTime)report.StartDate!;
|
|
|
|
|
var TempEnd = (DateTime)report.EndDate!;
|
|
|
|
|
var TempSpan = TempEnd - TempStart;
|
|
|
|
|
var TempDayCount = (int)TempSpan.TotalDays;
|
|
|
|
|
var TempDaySpan = 5;
|
|
|
|
|
|
|
|
|
|
var TempTasks = new Task<List<DeviceError>>[TempDayCount % TempDaySpan > 0 ? TempDayCount / TempDaySpan + 1 : TempDayCount / TempDaySpan];
|
|
|
|
|
for (var i = 0; i < TempTasks.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
SqlSugarClient client = new SqlSugarClient(Db.CurrentConnectionConfig);
|
|
|
|
|
TempTasks[i] = client.Queryable<DeviceError>()
|
|
|
|
|
.WhereIF(report.ErrCodes != null && report.ErrCodes.Count() > 0, x => report.ErrCodes!.Contains(x.ErrCode))
|
|
|
|
|
.WhereIF(report.GpsIds != null && report.GpsIds.Count() > 0, x => report.GpsIds!.Contains(x.DeviceId!))
|
|
|
|
|
.Select(x => new DeviceError
|
|
|
|
|
{
|
|
|
|
|
ErrCode = x.ErrCode,
|
|
|
|
|
ErrMsg = x.ErrMsg,
|
|
|
|
|
Id = ((DateTime)x.CreateDate!).ToString("yyyy-MM-dd"),
|
|
|
|
|
Count = SqlFunc.AggregateCount(x.ErrCode)
|
|
|
|
|
})
|
|
|
|
|
.SplitTable(TempStart, TempEnd)
|
|
|
|
|
.GroupBy(x => new { x.ErrCode, x.ErrMsg, Date = ((DateTime)x.CreateDate!).ToString("yyyy-MM-dd") })
|
|
|
|
|
.SplitTable(TempStart.AddDays(i * TempDaySpan), TempStart.AddDays((i + 1) * TempDaySpan))
|
|
|
|
|
.OrderBy(x => x.Id)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
else if (report.Unit.ToLower() == "year")
|
|
|
|
|
Task.WaitAll(TempTasks);
|
|
|
|
|
List<DeviceError> result = new List<DeviceError>();
|
|
|
|
|
foreach (var task in TempTasks)
|
|
|
|
|
{
|
|
|
|
|
var TempYears = TempEnd.Year - TempStart.Year + 1;
|
|
|
|
|
var TempYearArray = Enumerable.Range(0, TempYears).Select(x => Convert.ToDateTime(TempStart.AddYears(x).ToString("yyyy-MM-dd"))).ToList();
|
|
|
|
|
var TempQueryYear = Db.Reportable(TempYearArray).ToQueryable<DateTime>();
|
|
|
|
|
report.Items = TempQueryYear
|
|
|
|
|
.LeftJoin(TempQuery.SplitTable(TempStart, TempEnd), (x, y) => x.ColumnName.ToString("yyyy") == ((DateTime)y.CreateDate!).ToString("yyyy"))
|
|
|
|
|
.GroupBy((x, y) => new { x.ColumnName, y.ErrCode, y.ErrMsg })
|
|
|
|
|
.Select((x, y) => new DeviceError
|
|
|
|
|
{
|
|
|
|
|
ErrCode = y.ErrCode,
|
|
|
|
|
ErrMsg = y.ErrMsg,
|
|
|
|
|
Count = SqlFunc.AggregateCount(y.ErrCode),
|
|
|
|
|
Id = x.ColumnName.ToString("yyyy"),
|
|
|
|
|
CreateDate = x.ColumnName
|
|
|
|
|
})
|
|
|
|
|
.ToList().OrderBy(x => x.Id);
|
|
|
|
|
}
|
|
|
|
|
else if (report.Unit.ToLower() == "month")
|
|
|
|
|
{
|
|
|
|
|
var TempMonths = (TempEnd.Year - TempStart.Year) * 12 + (TempEnd.Month - TempStart.Month + 1);
|
|
|
|
|
var TempMonthArray = Enumerable.Range(0, TempMonths).Select(x => Convert.ToDateTime(TempStart.AddMonths(x).ToString("yyyy-MM-dd"))).ToList();
|
|
|
|
|
var TempQueryMonth = Db.Reportable(TempMonthArray).ToQueryable<DateTime>();
|
|
|
|
|
report.Items = TempQueryMonth
|
|
|
|
|
.LeftJoin(TempQuery.SplitTable(TempStart, TempEnd), (x, y) => x.ColumnName.ToString("yyyy-MM") == ((DateTime)y.CreateDate!).ToString("yyyy-MM"))
|
|
|
|
|
.GroupBy((x, y) => new { x.ColumnName, y.ErrCode, y.ErrMsg })
|
|
|
|
|
.Select((x, y) => new DeviceError
|
|
|
|
|
{
|
|
|
|
|
ErrCode = y.ErrCode,
|
|
|
|
|
ErrMsg = y.ErrMsg,
|
|
|
|
|
Count = SqlFunc.AggregateCount(y.ErrCode),
|
|
|
|
|
Id = x.ColumnName.ToString("yyyy-MM"),
|
|
|
|
|
CreateDate = x.ColumnName
|
|
|
|
|
})
|
|
|
|
|
.ToList().OrderBy(x => x.Id);
|
|
|
|
|
result.AddRange(task.Result);
|
|
|
|
|
}
|
|
|
|
|
else if (report.Unit.ToLower() == "day")
|
|
|
|
|
{
|
|
|
|
|
var TempDays = (TempEnd - TempStart).TotalDays.ToInt();
|
|
|
|
|
var TempDayArray = Enumerable.Range(0, TempDays).Select(x => Convert.ToDateTime(TempStart.AddDays(x).ToString("yyyy-MM-dd"))).ToList();
|
|
|
|
|
var TempQueryDay = Db.Reportable(TempDayArray).ToQueryable<DateTime>();
|
|
|
|
|
report.Items = TempQueryDay
|
|
|
|
|
.LeftJoin(TempQuery.SplitTable(TempStart, TempEnd), (x, y) => x.ColumnName.ToString("yyyy-MM-dd") == ((DateTime)y.CreateDate!).ToString("yyyy-MM-dd"))
|
|
|
|
|
.GroupBy((x, y) => new { x.ColumnName, y.ErrCode, y.ErrMsg })
|
|
|
|
|
.Select((x, y) => new DeviceError
|
|
|
|
|
{
|
|
|
|
|
ErrCode = y.ErrCode,
|
|
|
|
|
ErrMsg = y.ErrMsg,
|
|
|
|
|
Count = SqlFunc.AggregateCount(y.ErrCode),
|
|
|
|
|
Id = x.ColumnName.ToString("yyyy-MM-dd"),
|
|
|
|
|
CreateDate = x.ColumnName
|
|
|
|
|
})
|
|
|
|
|
.ToList().OrderBy(x => x.Id);
|
|
|
|
|
return Task.FromResult(result);
|
|
|
|
|
}
|
|
|
|
|
return report;
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<DeviceError>> GetErrorList() {
|
|
|
|
|
return await Db.Queryable<DeviceError>()
|
|
|
|
|
.Select(x => new DeviceError
|
|
|
|
|
{
|
|
|
|
|
ErrCode = x.ErrCode,
|
|
|
|
|
ErrMsg = x.ErrMsg
|
|
|
|
|
}).Distinct()
|
|
|
|
|
.SplitTable(DateTime.Now.AddYears(-1), DateTime.Now)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|