diff --git a/Src/Dlhis.Basic/Organization/Controllers/SyncController.cs b/Src/Dlhis.Basic/Organization/Controllers/SyncController.cs index 8ef036d4..942bca38 100644 --- a/Src/Dlhis.Basic/Organization/Controllers/SyncController.cs +++ b/Src/Dlhis.Basic/Organization/Controllers/SyncController.cs @@ -60,8 +60,7 @@ public class SyncController : ControllerBase [IgnoreTenant] public async Task GetBusinessTripsAsync(CodeRequest request) { - await _sapBusinessTripService.HandleDirtyDataAsync(request.Code); - //await _sapBusinessTripService.HandlerBusinessTripsByFactoryAsync(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 b22ed5da..c2d24a10 100644 --- a/Src/Dlhis.Basic/Organization/Services/ISapBusinessTripService.cs +++ b/Src/Dlhis.Basic/Organization/Services/ISapBusinessTripService.cs @@ -3,6 +3,4 @@ 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 aca8bd18..1703effa 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/SapBusinessTripService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/SapBusinessTripService.cs @@ -204,74 +204,4 @@ public class SapBusinessTripService : ISapBusinessTripService .Select(x => x.DeviceCode) .ToListAsync(); } - - 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 - { - var dirtyData = await _dbContext.Queryable() - .Where(x => x.Destination == factory) - .Where(x => !SqlFunc.IsNullOrEmpty(x.Destination)) - .Where(x => x.Status == BusinessTripStatusEnumType.Generated) - .Where(x => x.BeginDate < yesterday) - .Select(x => new - { - num = SqlFunc.RowNumber(SqlFunc.Desc(x.BeginDate), x.Code), - x.Id, x.Code, x.BeginDate - }).MergeTable() - .Where(x => x.num == 1) - .ToListAsync(); - - - foreach (var item in dirtyData) - { - try - { - 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) - .Where(x => x.AssignValue == currentGainfo.No) - .Where(x => x.UniqueType == DeviceAssignmentTypeEnumType.Group) - .Where(x => x.UniqueValue == tripGroup.Code) - .Where(x => x.Type == tripGroup.Type) - .Where(x => x.TenantId == factory) - .ExecuteCommandAsync(); - - await _dbContext.Updateable() - .SetColumns(x => x.Status == BusinessTripStatusEnumType.Deleted) - .Where(x => x.Id == item.Id) - .ExecuteCommandAsync(); - - await _gainfoPermissionService.ResetPermissionsAsync(currentGainfo.No, DeviceTaskEnumType.Delete, deviceCodes, "出差遗留脏数据删除"); - } - catch (Exception e) - { - _logger.LogError(e, "处理出差遗留脏数据删除失败:工号{code}", item.Code); - } - } - } - catch (Exception e) - { - _logger.LogError(e, "处理{factory}遗留出差数据失败:{message}", factory, e.Message); - } - } } \ No newline at end of file