This commit is contained in:
2024-03-10 16:19:09 +08:00
parent 72b25c7095
commit c4bb884d48
3 changed files with 10 additions and 3 deletions

View File

@@ -30,6 +30,8 @@ public class SyncOriginCardInfoJob
public async Task RunAsync()
{
_logger.LogInformation("调度任务:{job}.开始执行", nameof(SyncOriginCardInfoJob));
_dbContext.Client.QueryFilter.ClearAndBackup<ITenantId>();
_sqlSugarOptionsService.IgnoreTenant = true;
try
@@ -49,14 +51,14 @@ public class SyncOriginCardInfoJob
//获取人员信息
var userCodes = logs.Select(x => x.UserUniqueNo).ToList();
var gainfos = await _dbContext.Queryable<GainfoEntity>().Where(x => userCodes.Contains(x.Code)).Select(x => new { x.Code, x.CardNo }).ToListAsync();
var gainfoCodes = await _dbContext.Queryable<GainfoEntity>().Where(x => userCodes.Contains(x.Code)).Select(x => x.Code).ToListAsync();
var requests = logs.Select(x => new UploadAttendanceRequest
{
Id = x.Id,
RaiseDateTime = x.RaiseDateTime,
ZNOTE = devices.First(item => item.UniqueNo == x.DeviceUniqueNo).DeployPlace,
ZWORKCODE = gainfos.FirstOrDefault(item => item.Code == x.UserUniqueNo)?.Code?.TrimEnd('\0'),
ZWORKCODE = gainfoCodes.Contains(x.UserUniqueNo) ? x.UserUniqueNo?.TrimEnd('\0') : string.Empty,
}).Where(x => x.ZWORKCODE.IsPresent()).ToList();
@@ -86,6 +88,8 @@ public class SyncOriginCardInfoJob
{
_sqlSugarOptionsService.IgnoreTenant = false;
_dbContext.Client.QueryFilter.Restore();
_logger.LogInformation("调度任务:{job}.结束", nameof(SyncOriginCardInfoJob));
}
}
}

View File

@@ -36,6 +36,7 @@ public class SyncPersonJob
public async Task RunAsync()
{
_logger.LogInformation("开始获取SAP人员");
var personResp = await _jinkoSapService.GetPersonsAsync();
var persons = personResp.Person.Items;
_departmentChanges = personResp.DepartmentInfo.Items;
@@ -56,6 +57,8 @@ public class SyncPersonJob
}
});
}
_logger.LogInformation("同步SAP人员数据结束");
}
private async Task<int> SavePerson(List<SapPersonItem> persons)

View File

@@ -115,7 +115,7 @@ public class JinkoSapService : IJinkoSapService
}
catch (Exception ex)
{
_logger.LogError(ex, "获取人事范围{werk}失败:" + ex.Message, item);
_logger.LogError(ex, "获取人事范围{werk}失败:" + ex.Message, item.Werk);
}
}