From f153d6e3a402dbbb98005d9aa4926f51ceefa1ba Mon Sep 17 00:00:00 2001 From: liguoyang Date: Mon, 17 Nov 2025 10:48:32 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/SyncController.cs | 3 ++- .../Services/ISapBusinessTripService.cs | 2 ++ .../Implements/SapBusinessTripService.cs | 19 ++++++++++++++----- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Src/Dlhis.Basic/Organization/Controllers/SyncController.cs b/Src/Dlhis.Basic/Organization/Controllers/SyncController.cs index 942bca38..8ef036d4 100644 --- a/Src/Dlhis.Basic/Organization/Controllers/SyncController.cs +++ b/Src/Dlhis.Basic/Organization/Controllers/SyncController.cs @@ -60,7 +60,8 @@ public class SyncController : ControllerBase [IgnoreTenant] public async Task GetBusinessTripsAsync(CodeRequest request) { - await _sapBusinessTripService.HandlerBusinessTripsByFactoryAsync(request.Code); + await _sapBusinessTripService.HandleDirtyDataAsync(request.Code); + //await _sapBusinessTripService.HandlerBusinessTripsByFactoryAsync(request.Code); } [HttpGet("/api/sync/test")] diff --git a/Src/Dlhis.Basic/Organization/Services/ISapBusinessTripService.cs b/Src/Dlhis.Basic/Organization/Services/ISapBusinessTripService.cs index c2d24a10..b22ed5da 100644 --- a/Src/Dlhis.Basic/Organization/Services/ISapBusinessTripService.cs +++ b/Src/Dlhis.Basic/Organization/Services/ISapBusinessTripService.cs @@ -3,4 +3,6 @@ namespace Dlhis.Basic.Organization.Services; public interface ISapBusinessTripService : IScopeDependency { Task HandlerBusinessTripsByFactoryAsync(string factory); + + Task HandleDirtyDataAsync(string factory); } \ No newline at end of file diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/SapBusinessTripService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/SapBusinessTripService.cs index 27b4c38e..aca8bd18 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/SapBusinessTripService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/SapBusinessTripService.cs @@ -144,8 +144,6 @@ public class SapBusinessTripService : ISapBusinessTripService _logger.LogError(e, "出差自动下发任务失败:{message}", e.Message); } } - - await HandleDirtyDataAsync(factory, tripGroup, deviceCodes); } } catch (Exception e) @@ -207,8 +205,11 @@ public class SapBusinessTripService : ISapBusinessTripService .ToListAsync(); } - private async Task HandleDirtyDataAsync(string factory, DeviceGroupEntity tripGroup, List deviceCodes) + public async Task HandleDirtyDataAsync(string factory) { + var tripGroup = await GetTripGroupAsync(factory); + var deviceCodes = await GetTripGroupUnderDeviceCodesAsync(tripGroup.Code); + //确保是真实脏数据 var yesterday = DateTime.Now.Date.AddDays(-2); try @@ -231,11 +232,20 @@ public class SapBusinessTripService : ISapBusinessTripService { try { - var currentGainfo = await _dbContext.Queryable() + var currentGainfo = await _dbContext.Queryable() .Where(x => x.Code == item.Code) .Select(x => new { x.No, x.Code }) .SingleAsync(); + if (currentGainfo == null) + { + continue; + // currentGainfo = await _dbContext.Queryable() + // .Where(x => x.Code == item.Code) + // .Select(x => new { x.No, x.Code }) + // .SingleAsync(); + } + await _dbContext.Updateable() .SetColumns(x => x.IsDeleted == true) .Where(x => x.AssignType == AssignTypeEnumType.User) @@ -251,7 +261,6 @@ public class SapBusinessTripService : ISapBusinessTripService .Where(x => x.Id == item.Id) .ExecuteCommandAsync(); - await _gainfoPermissionService.ResetPermissionsAsync(currentGainfo.No, DeviceTaskEnumType.Delete, deviceCodes, "出差遗留脏数据删除"); } catch (Exception e)