fix 外部接口调用封装处理
This commit is contained in:
@@ -342,39 +342,8 @@ public class GainfoFaceService : IGainfoFaceService
|
||||
await _faceDbContext.UpdateAsync(face);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var r = await _jinkoJipApi.SyncFaceToSapAsync(new SyncFaceRequest
|
||||
{
|
||||
UserCode = face.UserCode,
|
||||
Base64 = face.Face
|
||||
});
|
||||
|
||||
if (r.OLX == "S")
|
||||
{
|
||||
await _faceDbContext.Updateable<GainfoFaceEntity>()
|
||||
.SetColumns(x => x.IsSync == true)
|
||||
.Where(x => x.UserCode == face.UserCode)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "上传face数据到sap失败:{message}", e.Message);
|
||||
}
|
||||
|
||||
// try
|
||||
// {
|
||||
// await _hainingApi.UploadAsync(new HainingApiUploadRequest()
|
||||
// {
|
||||
// Code = gainfo.Code,
|
||||
// Base64 = request.Face
|
||||
// });
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// _logger.LogError(e, "上传face数据到老系统失败:{message}", e.Message);
|
||||
// }
|
||||
await FaceUploadToSapSafelyAsync(face.UserCode, face.Face);
|
||||
//await FaceUploadToOldSystemSafelyAsync(face.UserCode, face.Face);
|
||||
|
||||
//生成任务
|
||||
await _devicePermissionService.GenerateDeviceTasksAsync(gainfo.No, taskType, "照片上传生成");
|
||||
@@ -386,7 +355,7 @@ public class GainfoFaceService : IGainfoFaceService
|
||||
{
|
||||
foreach (var request in requests)
|
||||
{
|
||||
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).Where(x => x.Code == request.UserNo).FirstAsync();
|
||||
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).Where(x => x.Code == request.UserNo).SingleAsync();
|
||||
gainfo.ThrowIfNull("人员档案信息不存在");
|
||||
|
||||
var face = await _faceDbContext.Queryable<GainfoFaceEntity>().Where(x => x.UserCode == gainfo.Code).SingleAsync();
|
||||
@@ -425,8 +394,7 @@ public class GainfoFaceService : IGainfoFaceService
|
||||
await _devicePermissionService.GenerateDeviceTasksAsync(gainfo.No, taskType, "照片上传生成");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<string> GetFaceByUserCodeAsync(string userCode)
|
||||
{
|
||||
var face = await _faceDbContext.Queryable<GainfoFaceEntity>()
|
||||
@@ -525,4 +493,54 @@ public class GainfoFaceService : IGainfoFaceService
|
||||
r.IsPresent().ThrowIfTrue($"{r.Join("\r\n")}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上传到sap
|
||||
/// </summary>
|
||||
/// <param name="userCode"></param>
|
||||
/// <param name="faceBase64"></param>
|
||||
private async Task FaceUploadToSapSafelyAsync(string userCode, string faceBase64)
|
||||
{
|
||||
try
|
||||
{
|
||||
var r = await _jinkoJipApi.SyncFaceToSapAsync(new SyncFaceRequest
|
||||
{
|
||||
UserCode = userCode,
|
||||
Base64 = faceBase64
|
||||
});
|
||||
|
||||
if (r.OLX == "S")
|
||||
{
|
||||
await _faceDbContext.Updateable<GainfoFaceEntity>()
|
||||
.SetColumns(x => x.IsSync == true)
|
||||
.Where(x => x.UserCode == userCode)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "上传face数据到sap失败:{message}", e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上传到老系统(兼容)
|
||||
/// </summary>
|
||||
/// <param name="userCode"></param>
|
||||
/// <param name="faceBase64"></param>
|
||||
private async Task FaceUploadToOldSystemSafelyAsync(string userCode, string faceBase64)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _hainingApi.UploadAsync(new HainingApiUploadRequest()
|
||||
{
|
||||
Code = userCode,
|
||||
Base64 = faceBase64
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "上传face数据到老系统失败:{message}", e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user