From e94d2345664c751785af025097d4cc72939205c1 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Tue, 28 Oct 2025 11:31:16 +0800 Subject: [PATCH] =?UTF-8?q?fix=20idno=E4=B8=BA=E7=A9=BA=E4=BA=BA=E5=91=98?= =?UTF-8?q?=E4=B8=8D=E6=89=A7=E8=A1=8Cinsert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/GainfoUpdateService.cs | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs index 2bd740e8..49897a1a 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs @@ -167,24 +167,32 @@ public class GainfoUpdateService : IGainfoUpdateService private async Task InsertPersonAsync(GainfoSapEntity item) { - await _dbContext.UseTransactionAsync(async () => + var info = GainfoSapToGainfo(item); + //只有身份证号存在才进行新增 + if (info.IdNo.IsPresent()) { - await _dbContext.InsertAsync(item); - var info = GainfoSapToGainfo(item); + await _dbContext.UseTransactionAsync(async () => + { + await _dbContext.InsertAsync(item); - if (item.isowner == "T") - { - await _dbContext.InsertAsync(info); - await _identityUserSyncService.SyncAccountAsync(info.Code, info.Name, info.IdNo, info.Factory); - } - else - { - if (!await _dbContext.Queryable().AnyAsync(x => x.Code == item.ename)) + if (item.isowner == "T") { - await _dbContext.Client.Insertable(info).AS("GainfoLeave").ExecuteCommandAsync(); + await _dbContext.InsertAsync(info); + await _identityUserSyncService.SyncAccountAsync(info.Code, info.Name, info.IdNo, info.Factory); } - } - }); + else + { + if (!await _dbContext.Queryable().AnyAsync(x => x.Code == item.ename)) + { + await _dbContext.Client.Insertable(info).AS("GainfoLeave").ExecuteCommandAsync(); + } + } + }); + } + else + { + _logger.LogWarning("SAP新增人员失败,身份证号不存在:{userCode},{userName}", info.Code, info.Name); + } } private static GainfoEntity GainfoSapToGainfo(GainfoSapEntity item)