67 lines
2.1 KiB
C#
67 lines
2.1 KiB
C#
using Dlhis.Entity.Basic.Entity;
|
|
using Dlhis.Entity.Basic.Enums;
|
|
using Dlhis.ScheduledTask.Common.Dto;
|
|
using Kurisu.AspNetCore.Utils;
|
|
using Kurisu.Scheduled;
|
|
using Kurisu.Scheduled.Attributes;
|
|
|
|
namespace Dlhis.ScheduledTask.Jobs;
|
|
|
|
/// <summary>
|
|
/// 缓存山西档案数据
|
|
/// </summary>
|
|
[RecurringJob(nameof(SyncShanxiGainfoJob), "0 0 3 * * ?", Name = "缓存山西档案数据")]
|
|
public class SyncShanxiGainfoJob : BaseJob
|
|
{
|
|
private readonly RedisCache _redisCache;
|
|
|
|
public SyncShanxiGainfoJob(IServiceProvider serviceProvider, RedisCache redisCache) : base(serviceProvider)
|
|
{
|
|
_redisCache = redisCache;
|
|
}
|
|
|
|
public override async Task RunAsync(IServiceProvider serviceProvider)
|
|
{
|
|
var key = "gainfo:shanxi";
|
|
await _redisCache.KeyDeleteAsync(key);
|
|
|
|
var gainfos = await DbContext.Queryable<GainfoEntity>()
|
|
.LeftJoin<DepartmentEntity>((x, d) => x.DepartmentNo == d.No)
|
|
.Where(x => x.Factory == "2401")
|
|
.Select((x, d) => new GainfoOpenResponse
|
|
{
|
|
Code = x.Code,
|
|
DepartmentNo = x.DepartmentNo,
|
|
DepartmentName = d.Name,
|
|
Name = x.Name,
|
|
Gender = x.Gender,
|
|
Status = GainfoStatusEnumType.Working,
|
|
})
|
|
.ToListAsync();
|
|
|
|
foreach (var item in gainfos)
|
|
{
|
|
await _redisCache.ListLeftPushAsync(key, item);
|
|
}
|
|
|
|
var gainfoLeaves = await DbContext.Queryable<GainfoEntity>().AS("GainfoLeave")
|
|
.LeftJoin<DepartmentEntity>((x, d) => x.DepartmentNo == d.No)
|
|
.Where(x => x.Factory == "2401")
|
|
.Select((x, d) => new GainfoOpenResponse
|
|
{
|
|
Code = x.Code,
|
|
DepartmentNo = x.DepartmentNo,
|
|
DepartmentName = d.Name,
|
|
Name = x.Name,
|
|
Gender = x.Gender,
|
|
Status = GainfoStatusEnumType.Leave,
|
|
})
|
|
.ToListAsync();
|
|
|
|
foreach (var item in gainfoLeaves)
|
|
{
|
|
await _redisCache.ListLeftPushAsync(key, item);
|
|
}
|
|
}
|
|
}
|