cvd 修改

main
xiaoguo 1 year ago
parent 5dcb4f73c9
commit c2387eccf8

@ -146,6 +146,41 @@ namespace PVDEMCS.Devices.Impl
}
});
//设备记录日统计(修复统计,解决出现跨天的数据统计不到的情况)
Task.Run(() =>
{
//凌晨1点运行
var now = DateTime.Now;
var targetTime = new DateTime(now.Year, now.Month, now.Day, 1, 0, 0);
if (targetTime <= now)
{
// 如果目标时间已经过去,则设置到明天
targetTime = targetTime.AddDays(1);
}
while (true)
{
try
{
Thread.Sleep(TimeSpan.FromMilliseconds(targetTime.Subtract(DateTime.Now).TotalMilliseconds));
//这里修复10天前的
for (int i = 10; i > 0; i--)
{
equipmentRecordService.RunEquipmentRecordDayTotal(DateTime.Now.AddDays(-i));
}
$" 设备记录日统计(修复统计) ".WriteInfoLog();
}
catch (Exception ex)
{
ex.WriteErrorLog("设备记录日统计(修复统计)异常");
}
//明天继续
targetTime = targetTime.AddDays(1);
}
});
//设备记录统计
Task.Run(() =>
{

Loading…
Cancel
Save