From a460bce6bc8c95800c827de7fcc818f5d6a2e51e Mon Sep 17 00:00:00 2001 From: liguoyang Date: Mon, 12 May 2025 14:00:27 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E8=80=83=E5=8B=A4=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/DeviceUploadLogService.cs | 69 +++++++++---------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs index a86894bd..d32d3b4e 100644 --- a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs +++ b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs @@ -152,15 +152,14 @@ public class DeviceUploadLogService : IDeviceUploadLogService if (request.RaiseDateTime >= start && request.RaiseDateTime <= end) { workGridInfo.PeriodType = WorkGridTimePeriodEnumType.Day; + var currentWorkGrid = workGrids.First(x => x.Code == currentDayWorkGridSchedule.WorkGridCode); + workGridInfo.WorkGrid = new WorkGridInfoDetail + { + WorkGridCode = currentWorkGrid.Code, + WorkGridName = currentWorkGrid.Name, + LeaderUserCode = currentWorkGrid.LeaderUserCode + }; } - - var currentWorkGrid = workGrids.First(x => x.Code == currentDayWorkGridSchedule.WorkGridCode); - workGridInfo.WorkGrid = new WorkGridInfoDetail - { - WorkGridCode = currentWorkGrid.Code, - WorkGridName = currentWorkGrid.Name, - LeaderUserCode = currentWorkGrid.LeaderUserCode - }; } } @@ -180,47 +179,44 @@ public class DeviceUploadLogService : IDeviceUploadLogService if (currentNightWorkGridSchedules.Any(x => x.Date == currentDateOnly)) { - var currentWorkGrid = workGrids.First(x => x.Code == currentNightWorkGridSchedules.First(p => p.Date == currentDateOnly).WorkGridCode); - workGridInfo.WorkGrid = new WorkGridInfoDetail - { - WorkGridCode = currentWorkGrid.Code, - WorkGridName = currentWorkGrid.Name, - LeaderUserCode = currentWorkGrid.LeaderUserCode - }; - var start = currentDateOnly.ToDateTime(startTime); var end = currentDateOnly.ToDateTime(new TimeOnly(23, 59, 59, 999)); if (request.RaiseDateTime >= start && request.RaiseDateTime <= end) { workGridInfo.PeriodType = WorkGridTimePeriodEnumType.Night; + var currentWorkGrid = workGrids.First(x => x.Code == currentNightWorkGridSchedules.First(p => p.Date == currentDateOnly).WorkGridCode); + workGridInfo.WorkGrid = new WorkGridInfoDetail + { + WorkGridCode = currentWorkGrid.Code, + WorkGridName = currentWorkGrid.Name, + LeaderUserCode = currentWorkGrid.LeaderUserCode + }; } } if (currentNightWorkGridSchedules.Any(x => x.Date == currentDateOnly.AddDays(-1))) { - var currentWorkGrid = workGrids.First(x => x.Code == currentNightWorkGridSchedules.First(p => p.Date == currentDateOnly.AddDays(-1)).WorkGridCode); - workGridInfo.WorkGrid = new WorkGridInfoDetail - { - WorkGridCode = currentWorkGrid.Code, - WorkGridName = currentWorkGrid.Name, - LeaderUserCode = currentWorkGrid.LeaderUserCode - }; - var start = currentDateOnly.AddDays(-1).ToDateTime(startTime); var end = currentDateOnly.ToDateTime(endTime); if (request.RaiseDateTime >= start && request.RaiseDateTime <= end) { workGridInfo.PeriodType = WorkGridTimePeriodEnumType.Night; + var currentWorkGrid = workGrids.First(x => x.Code == currentNightWorkGridSchedules.First(p => p.Date == currentDateOnly.AddDays(-1)).WorkGridCode); + workGridInfo.WorkGrid = new WorkGridInfoDetail + { + WorkGridCode = currentWorkGrid.Code, + WorkGridName = currentWorkGrid.Name, + LeaderUserCode = currentWorkGrid.LeaderUserCode + }; } } } } - - - needUpload = workGridInfo.PeriodType.HasValue; - workGridInfo.IsError = workGridInfo.TimeSetting != null && workGridInfo.PeriodType.HasValue == false; + + needUpload = workGridInfo.WorkGrid == null || workGridInfo.PeriodType.HasValue; + workGridInfo.IsError = !needUpload; if (!needUpload) { try @@ -375,15 +371,18 @@ public class DeviceUploadLogService : IDeviceUploadLogService { var before60Days = DateTime.Today.AddDays(-60).AddSeconds(1); var data = await _dbContext.Queryable().Where(x => x.RaiseDateTime < before60Days).OrderBy(x => x.Id).ToPageListAsync(1, 500); - await _dbContext.DeleteReallyAsync(data); - - const string tableName = "deviceuploadlog_20250107"; - foreach (var item in data) + if (data.Any()) { - item.Id = 0; - } + await _dbContext.DeleteReallyAsync(data); - await _dbContext.Client.Insertable(data).AS(tableName).ExecuteCommandAsync(); + const string tableName = "deviceuploadlog_20250107"; + foreach (var item in data) + { + item.Id = 0; + } + + await _dbContext.Client.Insertable(data).AS(tableName).ExecuteCommandAsync(); + } } public async Task GetDeviceUploadRecordSettingAsync(string deviceNo)