diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs index 2eff4f0c..5a3ad9bd 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs @@ -173,24 +173,25 @@ public class GainfoUpdateService : IGainfoUpdateService private async Task InsertPersonAsync(GainfoSapEntity item) { - await _dbContext.InsertAsync(item); - var info = GainfoSapToGainfo(item); + await _dbContext.UseTransactionAsync(async () => + { + await _dbContext.InsertAsync(item); + var info = GainfoSapToGainfo(item); - if (item.isowner == "T") - { - var insertable = _dbContext.Client.Insertable(info); - _logger.LogWarning("sql:{sql}", insertable.ToSqlString()); - await insertable.ExecuteCommandAsync(); - await _identityUserSyncService.SyncAccountAsync(info.Code, info.Name, info.IdNo, info.Factory); - await _gainfoPermissionService.ResetPermissionsAsync(info.No, DeviceTaskEnumType.Add, null, "入职生成"); - } - 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); + await _gainfoPermissionService.ResetPermissionsAsync(info.No, DeviceTaskEnumType.Add, null, "入职生成"); } - } + else + { + if (!await _dbContext.Queryable().AnyAsync(x => x.Code == item.ename)) + { + await _dbContext.Client.Insertable(info).AS("GainfoLeave").ExecuteCommandAsync(); + } + } + }); } private GainfoEntity GainfoSapToGainfo(GainfoSapEntity item) diff --git a/Src/Dlhis.Dh.Api/ResultHandlers/DhResultHandler.cs b/Src/Dlhis.Dh.Api/ResultHandlers/DhResultHandler.cs index 515f127f..e0e9e450 100644 --- a/Src/Dlhis.Dh.Api/ResultHandlers/DhResultHandler.cs +++ b/Src/Dlhis.Dh.Api/ResultHandlers/DhResultHandler.cs @@ -23,7 +23,7 @@ public class DhResultHandler : IRemoteCallResultHandler throw new HttpRequestException(statusCode + " " + (int)statusCode); } - return responseBody.Adapt(); + return apiResult.Adapt(); } }