diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs index 8a7df2b3..9a46d11a 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs @@ -90,21 +90,28 @@ public class GainfoUpdateService : IGainfoUpdateService { _logger.LogInformation("SAP根据学工号同步开始:{code}", code); - var personResp = await _jinkoSapService.GetPersonsByCodeAsync(code); - var persons = personResp.Person.Items; - - _logger.LogInformation("获取SAP人员数量为:{count}", persons.Count); - if (persons.Count > 0) + try { - var modifiedPersons = await GetModifiedPersonAsync(persons.OrderByDescending(x => x.ZSTATUS).ThenBy(x => x.ZRZRQ).ToList()); - _logger.LogInformation("SAP人员差异数量为:{count}", modifiedPersons.Count); - if (modifiedPersons.Count > 0) - { - await SavePersonAsync(modifiedPersons); - } - } + var personResp = await _jinkoSapService.GetPersonsByCodeAsync(code); + var persons = personResp.Person.Items; - _logger.LogInformation("SAP根据学工号同步结束:{code}", code); + _logger.LogInformation("获取SAP人员数量为:{count}", persons.Count); + if (persons.Count > 0) + { + var modifiedPersons = await GetModifiedPersonAsync(persons.OrderByDescending(x => x.ZSTATUS).ThenBy(x => x.ZRZRQ).ToList()); + _logger.LogInformation("SAP人员差异数量为:{count}", modifiedPersons.Count); + if (modifiedPersons.Count > 0) + { + await SavePersonAsync(modifiedPersons); + } + } + + _logger.LogInformation("SAP根据学工号同步结束:{code}", code); + } + catch (Exception e) + { + _logger.LogError(e, "同步人员异常:{msg}", e.Message); + } } @@ -289,7 +296,7 @@ public class GainfoUpdateService : IGainfoUpdateService try { await _gainfoPermissionService.ResetPermissionsAsync(info.No, DeviceTaskEnumType.Delete, null, "人员离职生成"); - + //先写入离职表 gainfo.IdentityUserId = (int)gainfo.Id; //记录原始id gainfo.Id = 0; @@ -305,7 +312,7 @@ public class GainfoUpdateService : IGainfoUpdateService gainfo.Id = gainfo.IdentityUserId; await _dbContext.DeleteReallyAsync(gainfo); - + await _dbContext.Client.Ado.CommitTranAsync(); } catch (Exception ex)