fix 优化人脸同步sap
This commit is contained in:
@@ -23,5 +23,12 @@ namespace Dlhis.Entity.Basic.Entity
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "longtext", IsNullable = false)]
|
||||
public string Face { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否同步
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false, ColumnDataType = "bit")]
|
||||
public bool IsSync { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Entity.Sap;
|
||||
|
||||
[SugarTable(TableName = "SapDataSync")]
|
||||
public class SapDataSyncEntity : SugarBaseEntity
|
||||
{
|
||||
[SugarColumn(UniqueGroupNameList = new[] { "unique_SapDataSync_key-type" })]
|
||||
public string Key { get; set; }
|
||||
|
||||
[SugarColumn(UniqueGroupNameList = new[] { "unique_SapDataSync_key-type" })]
|
||||
public string Type { get; set; }
|
||||
|
||||
[SugarColumn(ColumnDataType = "bit")]
|
||||
public bool IsSync { get; set; }
|
||||
}
|
||||
@@ -50,6 +50,14 @@ public class HangfireService : IHangfireService
|
||||
|
||||
public async Task FaceUploadToSapAsync(FaceUploadToSapRequest request)
|
||||
{
|
||||
await _jinkoJipService.SyncFaceToSapAsync(request.UserCode, request.Base64);
|
||||
var response = await _jinkoJipService.SyncFaceToSapAsync(request.UserCode, request.Base64);
|
||||
if (response.OLX == "S")
|
||||
{
|
||||
var faceDbContext = _dbContext.ChangeDb("face");
|
||||
await faceDbContext.Updateable<GainfoFaceEntity>()
|
||||
.SetColumns(x => x.IsSync == true)
|
||||
.Where(x => x.UserCode == request.UserCode)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Sap;
|
||||
using Dlhis.ScheduledTask.Attributes;
|
||||
using Dlhis.ScheduledTask.Common.Services;
|
||||
|
||||
@@ -21,12 +20,7 @@ public class SyncFaceJob : BaseJob
|
||||
{
|
||||
var faceDbContext = DbContext.ChangeDb("face");
|
||||
|
||||
var existsData = await DbContext.Queryable<SapDataSyncEntity>().Where(x => x.IsSync).Select(x => x.Key).ToListAsync();
|
||||
|
||||
var userFaces = await faceDbContext.Queryable<GainfoFaceEntity>()
|
||||
.Where(x => !existsData.Contains(x.UserCode))
|
||||
.ToPageListAsync(1, 5000);
|
||||
|
||||
var userFaces = await faceDbContext.Queryable<GainfoFaceEntity>().Where(x => x.IsSync == false).ToPageListAsync(1, 1000);
|
||||
foreach (var data in userFaces)
|
||||
{
|
||||
try
|
||||
@@ -34,12 +28,8 @@ public class SyncFaceJob : BaseJob
|
||||
var response = await _jinkoJipService.SyncFaceToSapAsync(data.UserCode, data.Face);
|
||||
if (response.OLX == "S")
|
||||
{
|
||||
await DbContext.InsertAsync(new SapDataSyncEntity
|
||||
{
|
||||
Key = data.UserCode,
|
||||
Type = "Face",
|
||||
IsSync = true
|
||||
});
|
||||
data.IsSync = true;
|
||||
await faceDbContext.UpdateAsync(data);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
Reference in New Issue
Block a user