From 05f0dfb312c072937581601d1cef51739d933a24 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Fri, 22 May 2026 11:53:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=94=A8=E6=88=B7=E5=8D=A1=E5=8F=B7?= =?UTF-8?q?=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/GainfoCardsController.cs | 13 +++++++++++ .../Request/GainfoImportCardRequest.cs | 23 +++++++++++++++++++ .../Services/IGainfoCardService.cs | 7 ++++++ .../Services/Implements/GainfoCardService.cs | 23 +++++++++++++++++-- 4 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 Src/Dlhis.Basic/Organization/Request/GainfoImportCardRequest.cs diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfoCardsController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfoCardsController.cs index bc412643..c2e20fea 100644 --- a/Src/Dlhis.Basic/Organization/Controllers/GainfoCardsController.cs +++ b/Src/Dlhis.Basic/Organization/Controllers/GainfoCardsController.cs @@ -36,6 +36,19 @@ public class GainfoCardsController : ControllerBase await _gainfoCardService.ChangeCardAsync(request); } + /// + /// 导入卡 + /// + /// + /// + [HttpPost("import")] + [IgnoreTenant] + [Transactional] + public async Task ImportCardsAsync(GainfoImportCardRequest request) + { + await _gainfoCardService.ImportCardsAsync(request); + } + /// /// 换卡记录 /// diff --git a/Src/Dlhis.Basic/Organization/Request/GainfoImportCardRequest.cs b/Src/Dlhis.Basic/Organization/Request/GainfoImportCardRequest.cs new file mode 100644 index 00000000..70a292f2 --- /dev/null +++ b/Src/Dlhis.Basic/Organization/Request/GainfoImportCardRequest.cs @@ -0,0 +1,23 @@ +using System.ComponentModel.DataAnnotations; + +namespace Dlhis.Basic.Organization.Request; + +public class GainfoImportCardRequest +{ + public List UserCards { get; set; } = new List(); +} + +public class GainfoImportCardItemRequest +{ + /// + /// 档案号 + /// + [Required(ErrorMessage = "工号不能为空")] + public string UserCode { get; set; } + + /// + /// 卡号 + /// + [Required(ErrorMessage = "卡号不能为空")] + public string CardNo { get; set; } +} diff --git a/Src/Dlhis.Basic/Organization/Services/IGainfoCardService.cs b/Src/Dlhis.Basic/Organization/Services/IGainfoCardService.cs index e1c285ff..18299d80 100644 --- a/Src/Dlhis.Basic/Organization/Services/IGainfoCardService.cs +++ b/Src/Dlhis.Basic/Organization/Services/IGainfoCardService.cs @@ -26,4 +26,11 @@ public interface IGainfoCardService : IScopeDependency /// /// Task EditCardTypeAsync(List userCodes, int typeId); + + /// + /// 导入卡信息 + /// + /// + /// + Task ImportCardsAsync(GainfoImportCardRequest request); } \ No newline at end of file diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoCardService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoCardService.cs index fe50aada..483dcfec 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoCardService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoCardService.cs @@ -48,9 +48,9 @@ public class GainfoCardService : IGainfoCardService UserNo = gainfo.No, CardNo = gainfo.CardNo, Reason = "换卡", - Remark = $"换卡前卡号:{gainfo.CardNo}" + Remark = $"换卡前卡号:{gainfo.CardNo}", + TenantId = gainfo.Factory }; - oldCardRecord.TenantId = gainfo.Factory; await _dbContext.InsertAsync(oldCardRecord); } @@ -60,6 +60,25 @@ public class GainfoCardService : IGainfoCardService await _gainfoPermissionService.ResetPermissionsAsync(gainfo.No, DeviceTaskEnumType.Update, null, null, "更新卡号下发"); } + public async Task ImportCardsAsync(GainfoImportCardRequest request) + { + var userCodes = request.UserCards.Select(x => x.UserCode).Distinct().ToList(); + var gainfos = await _dbContext.Queryable().Where(x => userCodes.Contains(x.Code)).ToListAsync(); + + (gainfos.Count != userCodes.Count).ThrowIfTrue("存在档案号不存在,检查"); + + foreach (var gainfo in gainfos) + { + await ChangeCardAsync(new GainfoChangeCardRequest + { + UserNo = gainfo.No, + CardNo = request.UserCards.First(x => x.UserCode == gainfo.Code).CardNo, + Remark = "导入", + Reason = "卡号初始化导入" + }); + } + } + public async Task> GetChangeRecordsAsync(string userNo) { return await _dbContext.Queryable()