From 71e3e4fd0be83572e3dd46290a97edc30095b108 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Wed, 24 Dec 2025 10:18:06 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=81=A2=E5=A4=8D=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/GainfoOutsourceController.cs | 8 +++++ .../Services/IGainfoOutsourceService.cs | 2 ++ .../Implements/GainfoOutsourceService.cs | 30 ++++++++++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfoOutsourceController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfoOutsourceController.cs index 4cd78b4d..a11bd211 100644 --- a/Src/Dlhis.Basic/Organization/Controllers/GainfoOutsourceController.cs +++ b/Src/Dlhis.Basic/Organization/Controllers/GainfoOutsourceController.cs @@ -89,6 +89,14 @@ public class GainfoOutsourceController : ControllerBase await _gainfoOutSourceService.AutoResignAsync(); } + [AllowAnonymous] + [HttpPost("recover")] + [IgnoreTenant] + public async Task RecoverAsync() + { + await _gainfoOutSourceService.RecoverAsync(); + } + /// /// 获取外包白名单分页数据 /// diff --git a/Src/Dlhis.Basic/Organization/Services/IGainfoOutsourceService.cs b/Src/Dlhis.Basic/Organization/Services/IGainfoOutsourceService.cs index 6aaed7a3..a4783362 100644 --- a/Src/Dlhis.Basic/Organization/Services/IGainfoOutsourceService.cs +++ b/Src/Dlhis.Basic/Organization/Services/IGainfoOutsourceService.cs @@ -24,4 +24,6 @@ public interface IGainfoOutsourceService : IScopeDependency /// /// Task AutoResignAsync(); + + Task RecoverAsync(); } \ No newline at end of file diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs index d5c35bf8..20303644 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs @@ -4,7 +4,6 @@ using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Basic.Enums; using Dlhis.Entity.Device.Entities; using Kurisu.AspNetCore.Cache; -using Kurisu.AspNetCore.CustomClass; using Kurisu.AspNetCore.DataAccess.SqlSugar.Services; using Kurisu.AspNetCore.Utils.Extensions; using Mapster; @@ -211,6 +210,35 @@ public class GainfoOutsourceService : IGainfoOutsourceService } } + + public async Task RecoverAsync() + { + var gainfoLeaves = await _dbContext.Queryable() + .Where(x => x.Type == GainfoUserTypeEnumType.Outsource) + .Where(x => x.Remark == "1000天无通行记录") + .Where(x => SqlFunc.Subqueryable().Where(p => p.No == x.No || p.IdNo == x.IdNo).NotAny()) + .ToListAsync(); + + foreach (var gainfoLeave in gainfoLeaves) + { + await _dbContext.Client.Ado.BeginTranAsync(); + try + { + var gainfo = gainfoLeave.Adapt(); + gainfo.Id = gainfo.IdentityUserId; + await _dbContext.InsertAsync(gainfo); + await _dbContext.DeleteReallyAsync(gainfoLeave); + + await _dbContext.Client.Ado.CommitTranAsync(); + } + catch (Exception ex) + { + _logger.LogError(ex, "恢复外包人员失败:{userNo}", gainfoLeave.No); + await _dbContext.Client.Ado.RollbackTranAsync(); + } + } + } + public List GetDaysUntilToday(DateTime begin) { var start = DateOnly.FromDateTime(begin.Date);