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()