This commit is contained in:
2024-12-28 14:41:22 +08:00
parent a47062b3d8
commit e8632b0d49
2 changed files with 17 additions and 16 deletions

View File

@@ -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<GainfoLeaveEntity>().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<GainfoLeaveEntity>().AnyAsync(x => x.Code == item.ename))
{
await _dbContext.Client.Insertable(info).AS("GainfoLeave").ExecuteCommandAsync();
}
}
});
}
private GainfoEntity GainfoSapToGainfo(GainfoSapEntity item)

View File

@@ -23,7 +23,7 @@ public class DhResultHandler : IRemoteCallResultHandler
throw new HttpRequestException(statusCode + " " + (int)statusCode);
}
return responseBody.Adapt<TResult>();
return apiResult.Adapt<TResult>();
}
}