From 37794743fdf6213c760d6d1394ec4679cebac5d8 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Mon, 17 Nov 2025 11:41:45 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=81=A2=E5=A4=8D=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= 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 | 70 ------------------- 3 files changed, 1 insertion(+), 74 deletions(-) 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