fix 优化人脸同步sap

This commit is contained in:
2024-10-21 16:14:43 +08:00
parent a8e7b799e1
commit 8f928b8196
4 changed files with 19 additions and 31 deletions

View File

@@ -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; }
}
}

View File

@@ -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; }
}

View File

@@ -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();
}
}
}

View File

@@ -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)