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)