This commit is contained in:
2025-10-30 12:02:12 +08:00
parent 32f68c544e
commit e460ff6c04
5 changed files with 127 additions and 91 deletions

View File

@@ -48,8 +48,7 @@ namespace MoviconWebApi.API.DeviceStateApi
a.StandbyTime,
a.FaultTime,
a.ShutdownTime,
a.FaultNum,
a.JobNum
a.FaultNum
});
long totalPowerOn = lightList.Sum(x => (long)(x.PowerOnTime ?? 0));
@@ -58,7 +57,11 @@ namespace MoviconWebApi.API.DeviceStateApi
long totalFault = lightList.Sum(x => (long)(x.FaultTime ?? 0));
long totalShutdown = lightList.Sum(x => (long)(x.ShutdownTime ?? 0));
long totalFaultCount = lightList.Sum(x => (long)(x.FaultNum ?? 0));
long totalJobCount = lightList.Sum(x => (long)(x.JobNum ?? 0));
// 作业次数:来自当前搜索时间内 ClearData 的记录数
long totalJobCount = await db.Select<ClearData>()
.WhereIf(!string.IsNullOrWhiteSpace(request.DeviceCode), x => x.DeviceCode == request.DeviceCode)
.Where(x => x.CreateTime >= startTime && x.CreateTime <= endTime)
.CountAsync();
// 若该时间段内没有任何记录,返回空集合
var hasAnyData = (totalPowerOn + totalRun + totalStandby + totalFault + totalShutdown + totalFaultCount + totalJobCount) > 0;
@@ -99,7 +102,7 @@ namespace MoviconWebApi.API.DeviceStateApi
ShutdownTime = (int)totalShutdown,
UseRatio = useRatioText,
FaultNum = (int)totalFaultCount,
JobNum = (int)totalJobCount,
JobNum = totalJobCount > int.MaxValue ? int.MaxValue : (int)totalJobCount,
CreateTime = endTime.ToString("yyyy-MM-dd HH:mm:ss")
};