From b409f6f37577a04f8297be7293d9ca8563ba1902 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Tue, 16 Dec 2025 11:55:34 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=E7=BD=91=E6=A0=BC?= =?UTF-8?q?=E8=A7=A3=E6=95=A3=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/DeviceUploadLogService.cs | 51 ++++++++++++++----- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs index 936559ec..67c8d774 100644 --- a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs +++ b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs @@ -17,6 +17,7 @@ using Kurisu.AspNetCore.Authentication.Abstractions; using Kurisu.AspNetCore.Cache; using Kurisu.AspNetCore.CustomClass; using Kurisu.AspNetCore.DataAccess.Dto; +using Kurisu.AspNetCore.DataAccess.Entity; using Kurisu.AspNetCore.DataAccess.SqlSugar.Services; using Kurisu.AspNetCore.Utils.Extensions; using SqlSugar; @@ -72,7 +73,12 @@ public class DeviceUploadLogService : IDeviceUploadLogService .Where(x => factories.Contains(x.TenantId)) .Select(x => new { - x.Type, x.Start, x.End, x.Before, x.After, x.TenantId + x.Type, + x.Start, + x.End, + x.Before, + x.After, + x.TenantId }) .ToListAsync(); @@ -83,11 +89,14 @@ public class DeviceUploadLogService : IDeviceUploadLogService .Where(x => x.Date >= min && x.Date <= max && userCodes2.Contains(x.UserCode)) .Select(x => new { - x.UserCode, x.WorkGridCode, x.Date, x.PeriodType + x.UserCode, + x.WorkGridCode, + x.Date, + x.PeriodType }) .ToListAsync(); - var workGrids = await _dbContext.Queryable().ToListAsync(); + var workGrids = await GetAllWorkGridAsync(); var workGridUsers = await _dbContext.Queryable().Where(x => userCodes2.Contains(x.UserCode)).ToListAsync(); var inserts = new List(); @@ -132,13 +141,16 @@ public class DeviceUploadLogService : IDeviceUploadLogService var currentWorkGridTimePeriods = workGridTimePeriods.Where(x => x.TenantId == device.TenantId).ToList(); var currentWorkGridSchedules = workGridSchedules.Where(x => x.UserCode == request.UserUniqueNo).ToList(); var currentWorkGridUser = workGridUsers.FirstOrDefault(x => x.UserCode == request.UserUniqueNo); //可能被删除,但还存在当天的排班 + if (needUpload && currentWorkGridTimePeriods.Any() && (currentWorkGridUser != null || currentWorkGridSchedules.Any())) { workGridInfo.TimeSetting = currentWorkGridTimePeriods.Select(x => new { Type = x.Type.GetDescription(), - x.Before, x.Start, - x.End, x.After, + x.Before, + x.Start, + x.End, + x.After, x.TenantId }).ToList(); @@ -279,6 +291,19 @@ public class DeviceUploadLogService : IDeviceUploadLogService await _dbContext.InsertAsync(inserts); } + private async Task> GetAllWorkGridAsync() + { + _dbContext.Client.QueryFilter.ClearAndBackup(); + try + { + return await _dbContext.Queryable().ToListAsync(); + } + finally + { + _dbContext.Client.QueryFilter.Restore(); + } + + } private async Task> GetDeviceCodeInEFencesAsync(List deviceCodes) { @@ -314,7 +339,7 @@ public class DeviceUploadLogService : IDeviceUploadLogService _logger.LogInformation("MCB未开启, userCode:{userCode} directionType:{directionType}", userCode, directionType); return; } - + var room = await _dbContext.Queryable().Where(x => x.RoomId == roomInfo.RoomId).SingleAsync(); if (room == null) { @@ -334,13 +359,13 @@ public class DeviceUploadLogService : IDeviceUploadLogService await _dbContext.InsertAsync(room); var personEntities = roomInfo.Persons.Select(x => new DormitoryRoomPersonEntity - { - RoomId = roomInfo.RoomId, - UserCode = x.UserCode, - UserName = x.UserName, - In = true, - IsDeleted = false - }) + { + RoomId = roomInfo.RoomId, + UserCode = x.UserCode, + UserName = x.UserName, + In = true, + IsDeleted = false + }) .ToList(); await _dbContext.InsertAsync(personEntities);