fix 优化代码
This commit is contained in:
@@ -6,6 +6,7 @@ using Dlhis.ScheduledTask.Common.Services;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Scheduled;
|
||||
using Kurisu.Scheduled.Attributes;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Jobs;
|
||||
@@ -13,7 +14,7 @@ namespace Dlhis.ScheduledTask.Jobs;
|
||||
/// <summary>
|
||||
/// 上传考勤记录
|
||||
/// </summary>
|
||||
[RecurringJob(nameof(SyncOriginCardInfoJob), "0/20 * * * * ?", Name = "上传考勤记录")]
|
||||
[RecurringJob(nameof(SyncOriginCardInfoJob), "0 0/15 * * * ?", Name = "上传考勤记录")]
|
||||
public class SyncOriginCardInfoJob : BaseJob
|
||||
{
|
||||
private readonly IJinkoJIPService _jinkoJIPService;
|
||||
@@ -51,21 +52,31 @@ public class SyncOriginCardInfoJob : BaseJob
|
||||
|
||||
}).Where(x => x.ZWORKCODE.IsPresent()).ToList();
|
||||
|
||||
var ids = requests.Select(x => x.Id).ToList();
|
||||
if (ids.Any())
|
||||
if (requests.Any())
|
||||
{
|
||||
var r = await _jinkoJIPService.UploadAttendancesAsync(requests);
|
||||
if (r.OLX == "0")
|
||||
foreach (var items in requests.Chunk(500))
|
||||
{
|
||||
await DbContext.Updateable<DeviceUploadLogEntity>()
|
||||
.SetColumns(x => x.Sync == true)
|
||||
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||
.Where(x => ids.Contains(x.Id))
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogError(r.OMS);
|
||||
try
|
||||
{
|
||||
var ids = items.Select(x => x.Id).ToList();
|
||||
var r = await _jinkoJIPService.UploadAttendancesAsync(items.ToList());
|
||||
if (r.OLX == "0")
|
||||
{
|
||||
await DbContext.Updateable<DeviceUploadLogEntity>()
|
||||
.SetColumns(x => x.Sync == true)
|
||||
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||
.Where(x => ids.Contains(x.Id))
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogError(r.OMS);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "考勤分配上传异常:{message}", ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user