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)