fix 外部接口调用封装处理
This commit is contained in:
@@ -103,6 +103,9 @@ public class AppointmentService : IAppointmentService
|
||||
var detail = await _dbContext.Queryable<VisitorAppointmentDetailEntity>().Where(x => x.Id == request.Id).SingleAsync();
|
||||
detail.ThrowIfNull("预约信息不存在");
|
||||
|
||||
//提前传
|
||||
await UploadFaceToDhAsync(detail.IdNo, request.Base64Image);
|
||||
|
||||
if (detail.DoorStatus == VisitorAppointmentDetailStatusEnumType.Wait)
|
||||
{
|
||||
detail.DoorStatus = VisitorAppointmentDetailStatusEnumType.Arrived;
|
||||
@@ -122,16 +125,19 @@ public class AppointmentService : IAppointmentService
|
||||
});
|
||||
|
||||
await GenerateDeviceTasksAsync(detail, false, DeviceTaskEnumType.Add, "访客门岗认证生成");
|
||||
}
|
||||
|
||||
private async Task UploadFaceToDhAsync(string idNo, string base64Image)
|
||||
{
|
||||
try
|
||||
{
|
||||
var r = await _dhApi.SendFaceAsync(new FaceRequest
|
||||
{
|
||||
IdNo = detail.IdNo,
|
||||
Face = request.Base64Image
|
||||
IdNo = idNo,
|
||||
Face = base64Image
|
||||
});
|
||||
|
||||
_logger.LogInformation("上传face数据到大华成功: {idNo} . {json}", detail.IdNo, r.ToJson());
|
||||
_logger.LogInformation("上传face数据到大华成功: {idNo} . {json}", idNo, r.ToJson());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -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