update remotecall and feat outsource自动离职
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.RemoteCall" Version="0.4.5" />
|
||||
<PackageReference Include="Kurisu.RemoteCall" Version="0.4.8" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
15
Src/Dlhis.Basic.Api/IGainfoApi.cs
Normal file
15
Src/Dlhis.Basic.Api/IGainfoApi.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Kurisu.RemoteCall.Attributes;
|
||||
|
||||
namespace Dlhis.Basic.Api;
|
||||
|
||||
[RequestResultHandler]
|
||||
[EnableRemoteClient(Name = "basic-service", BaseUrl = "${InternalRequest:BasicRequestUrl}")]
|
||||
public interface IGainfoApi
|
||||
{
|
||||
/// <summary>
|
||||
/// 外包自动离职处理
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Post("/api/gainfoOutsource/autoResign")]
|
||||
Task OutsourceAutoResignAsync();
|
||||
}
|
||||
@@ -72,4 +72,14 @@ public class GainfoOutsourceController : ControllerBase
|
||||
{
|
||||
return await _gainfoOutSourceService.GetExternalInfoAsync(userNo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动离职处理
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
[HttpPost("autoResign")]
|
||||
public async Task AutoResignAsync()
|
||||
{
|
||||
await _gainfoOutSourceService.AutoResignAsync();
|
||||
}
|
||||
}
|
||||
@@ -22,4 +22,9 @@ public class FactorySettingSaveRequest
|
||||
/// 人脸检测配置
|
||||
/// </summary>
|
||||
public FaceImageDetectionDto FaceImageDetection { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 外包自动离职天数(无通行记录)
|
||||
/// </summary>
|
||||
public int NoRecordAutoResignOutsourceDays { get; set; }
|
||||
}
|
||||
@@ -22,4 +22,9 @@ public class FactorySettingResponse
|
||||
/// 人脸检测
|
||||
/// </summary>
|
||||
public FaceImageDetectionDto FaceImageDetection { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 外包自动离职天数(无通行记录)
|
||||
/// </summary>
|
||||
public int NoRecordAutoResignOutsourceDays { get; set; }
|
||||
}
|
||||
@@ -18,4 +18,10 @@ public interface IGainfoOutsourceService : IScopeDependency
|
||||
/// <param name="userNo"></param>
|
||||
/// <returns></returns>
|
||||
Task<GainfoOutSourceExternalInfoResponse> GetExternalInfoAsync(string userNo);
|
||||
|
||||
/// <summary>
|
||||
/// 自动离职处理
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task AutoResignAsync();
|
||||
}
|
||||
@@ -79,10 +79,10 @@ public class FactorySettingService : IFactorySettingService
|
||||
}
|
||||
else
|
||||
{
|
||||
factories = await _tenantApi.GetMyTenantsAsync();
|
||||
factories = await _tenantApi.GetTenantsInternalAsync();
|
||||
}
|
||||
|
||||
var factoryCodes = factories.Select(x => x.Code).ToList();
|
||||
var factoryCodes = factories.Where(x => x.PCode.IsPresent()).Select(x => x.Code).ToList();
|
||||
var settings = await _dbContext.Queryable<FactorySettingEntity>()
|
||||
.Where(x => factoryCodes.Contains(x.TenantId))
|
||||
.ToListAsync();
|
||||
@@ -105,7 +105,8 @@ public class FactorySettingService : IFactorySettingService
|
||||
Type = Enum.Parse<FaceQualityTypeEnumType>(x!.GetValue(null)!.ToString()!),
|
||||
Level = FaceQualityLevelEnumType.Medium
|
||||
}).ToList()
|
||||
}
|
||||
},
|
||||
NoRecordAutoResignOutsourceDays = currentSetting?.NoRecordAutoResignOutsourceDays ?? 30
|
||||
};
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Kurisu.AspNetCore.Utils;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
@@ -14,11 +15,21 @@ public class GainfoOutsourceService : IGainfoOutsourceService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly RedisCache _redisCache;
|
||||
private readonly IGainfoService _gainfoService;
|
||||
private readonly IFactorySettingService _factorySettingService;
|
||||
private readonly ILogger<GainfoOutsourceService> _logger;
|
||||
|
||||
public GainfoOutsourceService(IDbContext dbContext, RedisCache redisCache)
|
||||
public GainfoOutsourceService(IDbContext dbContext,
|
||||
RedisCache redisCache,
|
||||
IGainfoService gainfoService,
|
||||
IFactorySettingService factorySettingService,
|
||||
ILogger<GainfoOutsourceService> logger)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_redisCache = redisCache;
|
||||
_gainfoService = gainfoService;
|
||||
_factorySettingService = factorySettingService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task SaveAsync(GainfoOutsourceRequest request)
|
||||
@@ -101,6 +112,49 @@ public class GainfoOutsourceService : IGainfoOutsourceService
|
||||
}
|
||||
|
||||
|
||||
public async Task AutoResignAsync()
|
||||
{
|
||||
var outsources = await _dbContext.Queryable<GainfoEntity>()
|
||||
.Where(x => x.Type == GainfoUserTypeEnumType.Outsource)
|
||||
.Select(x => new { x.Id, x.Code, x.Factory, x.CreateTime })
|
||||
.ToListAsync();
|
||||
|
||||
var settings = await _factorySettingService.GetListAsync();
|
||||
//0001/1/1 0:00:00
|
||||
var nullDateTime = new DateTime(1, 1, 1);
|
||||
foreach (var outsource in outsources)
|
||||
{
|
||||
var setting = settings.First(x => x.Factory == outsource.Factory);
|
||||
|
||||
var raiseDateTime = await _dbContext.Queryable<DeviceUploadLogEntity>()
|
||||
.Where(x => x.UserUniqueNo == outsource.Code)
|
||||
.GroupBy(x => x.UserUniqueNo)
|
||||
.Select(x => SqlFunc.IsNull(SqlFunc.AggregateMax(x.RaiseDateTime), outsource.CreateTime))
|
||||
.SingleAsync();
|
||||
|
||||
raiseDateTime = raiseDateTime == nullDateTime ? outsource.CreateTime : raiseDateTime;
|
||||
|
||||
if (raiseDateTime.AddDays(setting.NoRecordAutoResignOutsourceDays) < DateTime.Now)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _gainfoService.ResignAsync(new GainfoResignRequest
|
||||
{
|
||||
Id = outsource.Id,
|
||||
Reason = $"{setting.NoRecordAutoResignOutsourceDays}天无打开记录",
|
||||
Date = DateTime.Now,
|
||||
IsOutsource = true
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "自动离职外包异常:{msg}", e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************** help methods ***********************************************************************************
|
||||
|
||||
private async Task<string> GetOutSourceCodeAsync()
|
||||
@@ -128,17 +182,39 @@ public class GainfoOutsourceService : IGainfoOutsourceService
|
||||
/// <param name="request"></param>
|
||||
private async Task CheckDuplicate(GainfoOutsourceRequest request)
|
||||
{
|
||||
var exists = await _dbContext.Queryable<GainfoEntity>()
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>()
|
||||
.WhereIF(request.Id.HasValue, x => x.Id != request.Id)
|
||||
.Where(x => x.IdNo == request.IdNo).AnyAsync();
|
||||
exists.ThrowIfTrue($"证件号{request.IdNo}重复");
|
||||
.Where(x => x.IdNo == request.IdNo).SingleAsync();
|
||||
|
||||
if (gainfo != null)
|
||||
{
|
||||
var msg = string.Empty;
|
||||
var outsource = await _dbContext.Queryable<OutsourceEntity>().Where(x => x.Code == request.Code).SingleAsync();
|
||||
if (outsource != null)
|
||||
{
|
||||
msg = $",对接人工号为{outsource.SapCode}";
|
||||
}
|
||||
|
||||
gainfo.ThrowIfNotNull($"证件号{request.IdNo}重复,厂区为{gainfo.Factory}" + msg);
|
||||
}
|
||||
|
||||
if (request.Code.IsPresent())
|
||||
{
|
||||
exists = await _dbContext.Queryable<GainfoEntity>()
|
||||
gainfo = await _dbContext.Queryable<GainfoEntity>()
|
||||
.WhereIF(request.Id.HasValue, x => x.Id != request.Id)
|
||||
.Where(x => x.Code == request.Code).AnyAsync();
|
||||
exists.ThrowIfTrue($"工号{request.Code}重复");
|
||||
.Where(x => x.Code == request.Code).SingleAsync();
|
||||
|
||||
if (gainfo != null)
|
||||
{
|
||||
var msg = string.Empty;
|
||||
var outsource = await _dbContext.Queryable<OutsourceEntity>().Where(x => x.Code == request.Code).SingleAsync();
|
||||
if (outsource != null)
|
||||
{
|
||||
msg = $",对接人工号为{outsource.SapCode}";
|
||||
}
|
||||
|
||||
gainfo.ThrowIfNotNull($"工号{request.Code}重复,厂区为{gainfo.Factory}" + msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,12 +243,12 @@ public class GainfoService : IGainfoService
|
||||
|
||||
public async Task ResignAsync(GainfoResignRequest request)
|
||||
{
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().FirstAsync(x => x.Id == request.Id);
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().SingleAsync(x => x.Id == request.Id);
|
||||
gainfo.ThrowIfNull("档案数据不存在");
|
||||
|
||||
if (request.IsOutsource)
|
||||
{
|
||||
var outsource = await _dbContext.Queryable<OutsourceEntity>().FirstAsync(x => x.Code == gainfo.Code);
|
||||
var outsource = await _dbContext.Queryable<OutsourceEntity>().SingleAsync(x => x.Code == gainfo.Code);
|
||||
(outsource == null).ThrowIfTrue("非外包人员不可手动离职");
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"SqlSugarOptions": {
|
||||
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;",
|
||||
"SlaveConnectionString": [],
|
||||
"IdentityConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=identity;charset=utf8mb4;",
|
||||
"FaceConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=face;charset=utf8mb4;",
|
||||
"Timeout": 30,
|
||||
"SlowSqlTime": 1,
|
||||
|
||||
@@ -35,5 +35,11 @@ public class FactorySettingEntity : SugarBaseEntity, ITenantId
|
||||
[SugarColumn(ColumnDescription = "人脸检测配置", IsNullable = true, IsJson = true)]
|
||||
public FaceImageDetectionDto FaceImageDetection { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 外包自动离职天数(无通行记录)
|
||||
/// </summary>
|
||||
public int NoRecordAutoResignOutsourceDays { get; set; }
|
||||
|
||||
public string TenantId { get; set; }
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.RemoteCall" Version="0.4.5" />
|
||||
<PackageReference Include="Kurisu.RemoteCall" Version="0.4.8" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.RemoteCall" Version="0.4.6" />
|
||||
<PackageReference Include="Kurisu.RemoteCall" Version="0.4.8" />
|
||||
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.10.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.10.0" />
|
||||
</ItemGroup>
|
||||
|
||||
25
Src/Dlhis.ScheduledTask/Jobs/OutsourceAutoResignJob.cs
Normal file
25
Src/Dlhis.ScheduledTask/Jobs/OutsourceAutoResignJob.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Dlhis.Basic.Api;
|
||||
using Dlhis.ScheduledTask.Attributes;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Jobs;
|
||||
|
||||
/// <summary>
|
||||
/// 自动处理外包离职
|
||||
/// </summary>
|
||||
[RecurringJob(nameof(OutsourceAutoResignJob), "0 0 1 1/1 * ? ", Name = "自动处理外包离职")]
|
||||
public class OutsourceAutoResignJob : BaseJob
|
||||
{
|
||||
private readonly IGainfoApi _gainfoApi;
|
||||
|
||||
/// <inheritdoc />
|
||||
public OutsourceAutoResignJob(IServiceProvider serviceProvider, IGainfoApi gainfoApi) : base(serviceProvider)
|
||||
{
|
||||
_gainfoApi = gainfoApi;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
||||
{
|
||||
await _gainfoApi.OutsourceAutoResignAsync();
|
||||
}
|
||||
}
|
||||
@@ -22,20 +22,4 @@ public class Startup : DefaultStartup
|
||||
base.ConfigureServices(services);
|
||||
services.AddRedis();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
base.Configure(app, env);
|
||||
|
||||
var a = app.ApplicationServices.GetService<IJinkoJipApi>().SyncMealSupplementRecordsAsync(new List<SyncMealSupplementRecordRequest>()
|
||||
{
|
||||
new SyncMealSupplementRecordRequest
|
||||
{
|
||||
UniqueId = null,
|
||||
Status = null,
|
||||
Msg = null
|
||||
}
|
||||
}).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.RemoteCall" Version="0.4.5" />
|
||||
<PackageReference Include="Kurisu.RemoteCall" Version="0.4.8" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user