fix: 单工号同步前清理 SAP 历史
This commit is contained in:
@@ -5,4 +5,6 @@ namespace Dlhis.Basic.Organization.Repositories;
|
|||||||
public interface IGainfoSapRepository : IScopeDependency
|
public interface IGainfoSapRepository : IScopeDependency
|
||||||
{
|
{
|
||||||
Task<List<SapPersonItem>> GetLatestPersonsAsync(List<string> workCodes);
|
Task<List<SapPersonItem>> GetLatestPersonsAsync(List<string> workCodes);
|
||||||
|
|
||||||
|
Task<int> DeleteByWorkCodeAsync(string workCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ public class GainfoSapRepository : IGainfoSapRepository
|
|||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<int> DeleteByWorkCodeAsync(string workCode)
|
||||||
|
{
|
||||||
|
return await _dbContext.Deleteable<GainfoSapEntity>()
|
||||||
|
.Where(x => x.ename == workCode)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<List<SapPersonItem>> GetLatestPersonsAsync(List<string> workCodes)
|
public async Task<List<SapPersonItem>> GetLatestPersonsAsync(List<string> workCodes)
|
||||||
{
|
{
|
||||||
var persons = new List<SapPersonItem>();
|
var persons = new List<SapPersonItem>();
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ public class GainfoUpdateService : IGainfoUpdateService
|
|||||||
_logger.LogInformation("获取SAP人员数量为:{count}", persons.Count);
|
_logger.LogInformation("获取SAP人员数量为:{count}", persons.Count);
|
||||||
if (persons.Count > 0)
|
if (persons.Count > 0)
|
||||||
{
|
{
|
||||||
|
var deleteCount = await _gainfoSapRepository.DeleteByWorkCodeAsync(code);
|
||||||
|
_logger.LogInformation("删除工号:{code}的GainfoSap历史数量:{count}", code, deleteCount);
|
||||||
|
|
||||||
var modifiedPersons = await GetModifiedPersonAsync(persons.OrderByDescending(x => x.ZSTATUS).ThenBy(x => x.ZRZRQ).ToList());
|
var modifiedPersons = await GetModifiedPersonAsync(persons.OrderByDescending(x => x.ZSTATUS).ThenBy(x => x.ZRZRQ).ToList());
|
||||||
_logger.LogInformation("SAP人员差异数量为:{count}", modifiedPersons.Count);
|
_logger.LogInformation("SAP人员差异数量为:{count}", modifiedPersons.Count);
|
||||||
if (modifiedPersons.Count > 0)
|
if (modifiedPersons.Count > 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user