fix 优化手动获取人员

This commit is contained in:
2024-04-02 13:18:59 +08:00
parent ae8fdf8fdc
commit 96421ed164
32 changed files with 129 additions and 72 deletions

View File

@@ -1,7 +1,8 @@
using Dlhis.ScheduledTask.SyncSapInfo.Dto;
using Dlhis.ScheduledTask.Common;
using Dlhis.ScheduledTask.Common.Dto;
using System.Text;
namespace Dlhis.ScheduledTask.SyncSapInfo.Comparers;
namespace Dlhis.ScheduledTask.Common.Comparers;
/// <summary>
/// 人员信息比较器

View File

@@ -1,6 +1,6 @@
using Newtonsoft.Json;
namespace Dlhis.ScheduledTask.SyncSapInfo.Dto;
namespace Dlhis.ScheduledTask.Common.Dto;
/// <summary>
/// sap机构信息

View File

@@ -1,4 +1,4 @@
namespace Dlhis.ScheduledTask.SyncSapInfo.Dto;
namespace Dlhis.ScheduledTask.Common.Dto;
public class SapOrganizationItem
{

View File

@@ -1,6 +1,6 @@
using Newtonsoft.Json;
namespace Dlhis.ScheduledTask.SyncSapInfo.Dto;
namespace Dlhis.ScheduledTask.Common.Dto;
public class SapPerson<T>
{

View File

@@ -1,4 +1,4 @@
namespace Dlhis.ScheduledTask.SyncSapInfo.Dto
namespace Dlhis.ScheduledTask.Common.Dto
{
public class SapPersonDepartmentStatus
{

View File

@@ -1,4 +1,4 @@
namespace Dlhis.ScheduledTask.SyncSapInfo.Dto;
namespace Dlhis.ScheduledTask.Common.Dto;
public class SapPersonItem
{

View File

@@ -1,4 +1,4 @@
namespace Dlhis.ScheduledTask.SyncSapInfo.Dto
namespace Dlhis.ScheduledTask.Common.Dto
{
public class SapPersonJobStatus
{

View File

@@ -0,0 +1,10 @@
using System.ComponentModel.DataAnnotations;
namespace Dlhis.ScheduledTask.Common.Dto;
public class SapPersonNoRequest
{
[Required]
public string Code { get; set; }
}

View File

@@ -1,6 +1,6 @@
using Newtonsoft.Json;
namespace Dlhis.ScheduledTask.SyncSapInfo.Dto;
namespace Dlhis.ScheduledTask.Common.Dto;
public class SapPosition
{

View File

@@ -1,4 +1,4 @@
namespace Dlhis.ScheduledTask.SyncSapInfo.Dto
namespace Dlhis.ScheduledTask.Common.Dto
{
public class SapPositionItem
{

View File

@@ -1,4 +1,4 @@
namespace Dlhis.ScheduledTask.SyncSapInfo;
namespace Dlhis.ScheduledTask.Common;
internal static class GetHashCodeExtensions
{

View File

@@ -1,4 +1,4 @@
namespace Dlhis.ScheduledTask.SyncSapInfo;
namespace Dlhis.ScheduledTask.Common.Request;
public class SyncMealSupplementRecordRequest
{

View File

@@ -1,6 +1,6 @@
using Newtonsoft.Json;
namespace Dlhis.ScheduledTask.SyncSapInfo
namespace Dlhis.ScheduledTask.Common.Request
{
public class UploadAttendanceRequest
{

View File

@@ -1,7 +1,7 @@
using Dlhis.ScheduledTask.SyncSapInfo.Dto;
using Dlhis.ScheduledTask.Common.Dto;
using Newtonsoft.Json;
namespace Dlhis.ScheduledTask.SyncSapInfo.Response;
namespace Dlhis.ScheduledTask.Common.Response;
public class SapOrganizationResponse
{

View File

@@ -1,7 +1,7 @@
using Dlhis.ScheduledTask.SyncSapInfo.Dto;
using Dlhis.ScheduledTask.Common.Dto;
using Newtonsoft.Json;
namespace Dlhis.ScheduledTask.SyncSapInfo.Response;
namespace Dlhis.ScheduledTask.Common.Response;
public class SapPersonResponse
{

View File

@@ -1,7 +1,7 @@
using Dlhis.ScheduledTask.SyncSapInfo.Dto;
using Dlhis.ScheduledTask.Common.Dto;
using Newtonsoft.Json;
namespace Dlhis.ScheduledTask.SyncSapInfo.Response;
namespace Dlhis.ScheduledTask.Common.Response;
public class SapPositionResponse
{

View File

@@ -1,4 +1,4 @@
namespace Dlhis.ScheduledTask.SyncSapInfo.Response
namespace Dlhis.ScheduledTask.Common.Response
{
public class UploadAttendanceResponse
{

View File

@@ -1,4 +1,4 @@
namespace Dlhis.ScheduledTask.SyncSapInfo.Services;
namespace Dlhis.ScheduledTask.Common.Services;
public interface IGainfoUpdateService : IScopeDependency
{

View File

@@ -0,0 +1,16 @@
using Dlhis.ScheduledTask.Common.Dto;
namespace Dlhis.ScheduledTask.Common.Services;
/// <summary>
/// hangfire调度服务
/// </summary>
public interface IHangfireService : ISingletonDependency
{
/// <summary>
/// 创建sap人员同步后台任务
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Task CreateSapPersonSyncBackgroundJobAsync(SapPersonNoRequest request);
}

View File

@@ -1,6 +1,7 @@
using Dlhis.ScheduledTask.SyncSapInfo.Response;
using Dlhis.ScheduledTask.Common.Request;
using Dlhis.ScheduledTask.Common.Response;
namespace Dlhis.ScheduledTask.SyncSapInfo.Services;
namespace Dlhis.ScheduledTask.Common.Services;
public interface IJinkoJIPService : ISingletonDependency
{

View File

@@ -1,6 +1,6 @@
using Dlhis.ScheduledTask.SyncSapInfo.Response;
using Dlhis.ScheduledTask.Common.Response;
namespace Dlhis.ScheduledTask.SyncSapInfo.Services;
namespace Dlhis.ScheduledTask.Common.Services;
public interface IJinkoSapService : IScopeDependency
{

View File

@@ -2,15 +2,15 @@
using Dlhis.Basic.Api;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Basic.Enums;
using Dlhis.ScheduledTask.SyncSapInfo.Comparers;
using Dlhis.ScheduledTask.SyncSapInfo.Dto;
using System.Text;
using Dlhis.Sys.Api;
using Kurisu.SqlSugar.Services;
using SqlSugar;
using Dlhis.Sys.Api.Response;
using Dlhis.ScheduledTask.Common.Dto;
using Dlhis.ScheduledTask.Common.Comparers;
namespace Dlhis.ScheduledTask.SyncSapInfo.Services.Implements;
namespace Dlhis.ScheduledTask.Common.Services.Implements;
public class GainfoUpdateService : IGainfoUpdateService
{
@@ -368,7 +368,7 @@ public class GainfoUpdateService : IGainfoUpdateService
remark = rmk,
native = native,
sex = sex,
//web = SubString(position?.Name ?? "", 30),
web = person.PLANS,
logdate = DateTime.Now,
isowner = int.Parse(person.ZSTATUS) < 5 ? "T" : "F",
@class = "C",

View File

@@ -0,0 +1,26 @@
using Dlhis.ScheduledTask.Common.Dto;
using Hangfire;
using Kurisu.AspNetCore.Utils;
namespace Dlhis.ScheduledTask.Common.Services.Implements;
public class HangfireService : IHangfireService
{
private readonly RedisCache _redisCache;
public HangfireService(RedisCache redisCache)
{
_redisCache = redisCache;
}
public async Task CreateSapPersonSyncBackgroundJobAsync(SapPersonNoRequest request)
{
var jobKey = $"hangfire:background:{request.Code}";
using var handler = await _redisCache.LockAsync(jobKey);
if (handler.Acquired)
{
BackgroundJob.Enqueue<IGainfoUpdateService>(x => x.TodoAsync(request.Code));
}
}
}

View File

@@ -2,12 +2,14 @@
using System.Net.Http.Headers;
using System.Security.Claims;
using System.Text;
using Dlhis.ScheduledTask.SyncSapInfo.Response;
using Dlhis.ScheduledTask.Common.Request;
using Dlhis.ScheduledTask.Common.Response;
using Dlhis.ScheduledTask.Common.Services;
using Kurisu.AspNetCore.Utils.Extensions;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json.Linq;
namespace Dlhis.ScheduledTask.SyncSapInfo.Services.Implements;
namespace Dlhis.ScheduledTask.Common.Services.Implements;
public class JinkoJIPService : IJinkoJIPService
{

View File

@@ -1,13 +1,13 @@
using System.Net.Http.Headers;
using System.Text;
using Dlhis.Entity.Basic.Entity;
using Dlhis.ScheduledTask.SyncSapInfo.Dto;
using Dlhis.ScheduledTask.SyncSapInfo.Response;
using Dlhis.ScheduledTask.Common.Dto;
using Dlhis.ScheduledTask.Common.Response;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.SqlSugar.Services;
using Newtonsoft.Json;
namespace Dlhis.ScheduledTask.SyncSapInfo.Services.Implements;
namespace Dlhis.ScheduledTask.Common.Services.Implements;
public class JinkoSapService : IJinkoSapService
{

View File

@@ -4,8 +4,8 @@ using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Basic.Enums;
using Dlhis.Entity.Canteen.Entities;
using Dlhis.Entity.Canteen.Enums;
using Dlhis.ScheduledTask.SyncSapInfo;
using Dlhis.ScheduledTask.SyncSapInfo.Services;
using Dlhis.ScheduledTask.Common.Request;
using Dlhis.ScheduledTask.Common.Services;
using Kurisu.AspNetCore.Utils;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.Scheduled;

View File

@@ -1,6 +1,6 @@
using Dlhis.Entity.Basic.Entity;
using Dlhis.ScheduledTask.SyncSapInfo.Dto;
using Dlhis.ScheduledTask.SyncSapInfo.Services;
using Dlhis.ScheduledTask.Common.Dto;
using Dlhis.ScheduledTask.Common.Services;
using Hangfire;
using Kurisu.Scheduled;
using Kurisu.Scheduled.Attributes;

View File

@@ -1,8 +1,8 @@
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Device.Entities;
using Dlhis.Entity.Device.Enums;
using Dlhis.ScheduledTask.SyncSapInfo;
using Dlhis.ScheduledTask.SyncSapInfo.Services;
using Dlhis.ScheduledTask.Common.Request;
using Dlhis.ScheduledTask.Common.Services;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.Scheduled;
using Kurisu.Scheduled.Attributes;

View File

@@ -1,4 +1,4 @@
using Dlhis.ScheduledTask.SyncSapInfo.Services;
using Dlhis.ScheduledTask.Common.Services;
using Kurisu.Scheduled;
using Kurisu.Scheduled.Attributes;

View File

@@ -1,6 +1,6 @@
using Dlhis.Entity.Basic.Entity;
using Dlhis.ScheduledTask.SyncSapInfo.Dto;
using Dlhis.ScheduledTask.SyncSapInfo.Services;
using Dlhis.ScheduledTask.Common.Dto;
using Dlhis.ScheduledTask.Common.Services;
using Kurisu.Scheduled;
using Kurisu.Scheduled.Attributes;

View File

@@ -1,29 +0,0 @@
using Dlhis.ScheduledTask.SyncSapInfo.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Dlhis.ScheduledTask.TaskAssignment.Controllers;
[Authorize(Roles = "admin")]
[Route("api/[controller]")]
[ApiController]
public class GainfoTasksController : ControllerBase
{
private readonly IGainfoUpdateService _gainfoUpdateService;
public GainfoTasksController(IGainfoUpdateService gainfoUpdateService)
{
_gainfoUpdateService = gainfoUpdateService;
}
/// <summary>
/// 手动获取人员
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
[HttpGet("ManuallySync")]
public async Task ManuallySync(string code)
{
await _gainfoUpdateService.TodoAsync(code);
}
}

View File

@@ -0,0 +1,30 @@
using Dlhis.ScheduledTask.Common.Dto;
using Dlhis.ScheduledTask.Common.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Dlhis.ScheduledTask.TaskAssignment.Controllers;
[Authorize(Roles = "admin")]
[Route("api/[controller]")]
[ApiController]
public class HangfireController : ControllerBase
{
private readonly IHangfireService _hangfireService;
public HangfireController(IHangfireService hangfireService)
{
_hangfireService = hangfireService;
}
/// <summary>
/// 手动获取人员
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost("sap/person/no")]
public async Task ManuallySync(SapPersonNoRequest request)
{
await _hangfireService.CreateSapPersonSyncBackgroundJobAsync(request);
}
}