Merge branch 'development'
This commit is contained in:
@@ -18,11 +18,15 @@ public class JobPack : BaseAppPack
|
||||
TimeZone = TimeZoneInfo.Local
|
||||
});
|
||||
|
||||
RecurringJob.AddOrUpdate<CreateSyncServerDateTimeJob>("SyncServerDateTime", s => s.RunAsync(), "0 0 0/1 * * ?", new RecurringJobOptions
|
||||
RecurringJob.AddOrUpdate<SyncPersonJob>("SyncPerson", s => s.RunAsync(), "0 0 3 * * ?", new RecurringJobOptions
|
||||
{
|
||||
TimeZone = TimeZoneInfo.Local
|
||||
});
|
||||
|
||||
RecurringJob.AddOrUpdate<CreateSyncServerDateTimeJob>("SyncServerDateTime", s => s.RunAsync(), "0 0 0/1 * * ?", new RecurringJobOptions
|
||||
{
|
||||
TimeZone = TimeZoneInfo.Local
|
||||
});
|
||||
|
||||
RecurringJob.AddOrUpdate<CreateGetAttendanceJob>("CreateGetAttendance", s => s.RunAsync(), "0 0/1 * * * ?", new RecurringJobOptions
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.ScheduledTask.SyncSapInfo.Comparers;
|
||||
using Dlhis.ScheduledTask.SyncSapInfo.Dto;
|
||||
using Dlhis.ScheduledTask.SyncSapInfo.Services;
|
||||
using Hangfire;
|
||||
@@ -12,7 +11,6 @@ namespace Dlhis.ScheduledTask.SyncSapInfo.Job;
|
||||
/// </summary>
|
||||
public class SyncOrganizationJob
|
||||
{
|
||||
private List<SapOrganizationItem> lastUpdatedOrgList = new();
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly IJinkoSapService _jinkoSapService;
|
||||
|
||||
@@ -28,23 +26,11 @@ public class SyncOrganizationJob
|
||||
|
||||
if (orgResult.Org != null && orgResult.Org.Items.Count > 0)
|
||||
{
|
||||
//var modifiedOrgList = GetModifiedOrg(orgResult.Org.Items);
|
||||
await SaveOrg(orgResult.Org.Items);
|
||||
}
|
||||
|
||||
var syncPositionJob = BackgroundJob.Enqueue<SyncPositionJob>(job => job.SyncPositionInfo());
|
||||
BackgroundJob.ContinueJobWith<SyncPersonJob>(syncPositionJob, job => job.SyncPersonInfo(), JobContinuationOptions.OnlyOnSucceededState);
|
||||
}
|
||||
|
||||
private List<SapOrganizationItem> GetModifiedOrg(List<SapOrganizationItem> sapList)
|
||||
{
|
||||
if (lastUpdatedOrgList.Count <= 0)
|
||||
{
|
||||
return sapList;
|
||||
}
|
||||
|
||||
var needRemove = sapList.Intersect(lastUpdatedOrgList, new SapOrganizationComparer());
|
||||
return sapList.Except(needRemove, new SapOrganizationComparer()).ToList();
|
||||
BackgroundJob.ContinueJobWith<SyncPersonJob>(syncPositionJob, job => job.RunAsync(), JobContinuationOptions.OnlyOnSucceededState);
|
||||
}
|
||||
|
||||
private async Task SaveOrg(List<SapOrganizationItem> modifiedOrgList)
|
||||
|
||||
@@ -23,7 +23,7 @@ public class SyncPersonJob
|
||||
_jinkoSapService = jinkoSapService;
|
||||
}
|
||||
|
||||
public async Task SyncPersonInfo()
|
||||
public async Task RunAsync()
|
||||
{
|
||||
var personResp = await _jinkoSapService.GetPersonsAsync();
|
||||
var persons = personResp.Person.Items;
|
||||
|
||||
@@ -31,9 +31,6 @@ public class SyncPositionJob
|
||||
|
||||
private async Task SaveOrg(List<SapPositionItem> modifiedPostList)
|
||||
{
|
||||
var addItems = new List<PositionEntity>();
|
||||
var updateItems = new List<PositionEntity>();
|
||||
|
||||
foreach (var item in modifiedPostList)
|
||||
{
|
||||
var position = await _dbContext.Queryable<PositionEntity>().Where(x => x.No == item.ZJOBID).FirstAsync();
|
||||
@@ -47,7 +44,7 @@ public class SyncPositionJob
|
||||
Grade = item.ZZWID
|
||||
};
|
||||
|
||||
addItems.Add(position);
|
||||
await _dbContext.InsertAsync(position);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -55,11 +52,8 @@ public class SyncPositionJob
|
||||
position.DepartmentNo = item.ZDEPID;
|
||||
position.Grade = item.ZZWID;
|
||||
|
||||
updateItems.Add(position);
|
||||
await _dbContext.UpdateAsync(position);
|
||||
}
|
||||
}
|
||||
|
||||
await _dbContext.InsertAsync(addItems);
|
||||
await _dbContext.UpdateAsync(updateItems);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,14 +87,13 @@ public class JinkoSapService : IJinkoSapService
|
||||
T_PERSON = Array.Empty<string>(),
|
||||
T_PNO = Array.Empty<string>(),
|
||||
};
|
||||
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
|
||||
|
||||
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
|
||||
var response = await GetHttpClient().PostAsync(apiUrl, content);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var jsonResponse = await response.Content.ReadAsStringAsync();
|
||||
|
||||
|
||||
var personResp = JsonConvert.DeserializeObject<SapPersonResponse>(jsonResponse);
|
||||
if (personResp?.Person?.Items?.Any() == true)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user