diff --git a/Src/Dlhis.Basic.Api/Dlhis.Basic.Api.csproj b/Src/Dlhis.Basic.Api/Dlhis.Basic.Api.csproj
index 938a97d6..b41f2841 100644
--- a/Src/Dlhis.Basic.Api/Dlhis.Basic.Api.csproj
+++ b/Src/Dlhis.Basic.Api/Dlhis.Basic.Api.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/Src/Dlhis.Basic.Api/IGainfoApi.cs b/Src/Dlhis.Basic.Api/IGainfoApi.cs
new file mode 100644
index 00000000..86b6a3cf
--- /dev/null
+++ b/Src/Dlhis.Basic.Api/IGainfoApi.cs
@@ -0,0 +1,15 @@
+using Kurisu.RemoteCall.Attributes;
+
+namespace Dlhis.Basic.Api;
+
+[RequestResultHandler]
+[EnableRemoteClient(Name = "basic-service", BaseUrl = "${InternalRequest:BasicRequestUrl}")]
+public interface IGainfoApi
+{
+ ///
+ /// 外包自动离职处理
+ ///
+ ///
+ [Post("/api/gainfoOutsource/autoResign")]
+ Task OutsourceAutoResignAsync();
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfoOutsourceController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfoOutsourceController.cs
index d38250f1..b5c45bdf 100644
--- a/Src/Dlhis.Basic/Organization/Controllers/GainfoOutsourceController.cs
+++ b/Src/Dlhis.Basic/Organization/Controllers/GainfoOutsourceController.cs
@@ -72,4 +72,14 @@ public class GainfoOutsourceController : ControllerBase
{
return await _gainfoOutSourceService.GetExternalInfoAsync(userNo);
}
+
+ ///
+ /// 自动离职处理
+ ///
+ [AllowAnonymous]
+ [HttpPost("autoResign")]
+ public async Task AutoResignAsync()
+ {
+ await _gainfoOutSourceService.AutoResignAsync();
+ }
}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Organization/Request/FactorySettingSaveRequest.cs b/Src/Dlhis.Basic/Organization/Request/FactorySettingSaveRequest.cs
index 9756b0b2..5da2c825 100644
--- a/Src/Dlhis.Basic/Organization/Request/FactorySettingSaveRequest.cs
+++ b/Src/Dlhis.Basic/Organization/Request/FactorySettingSaveRequest.cs
@@ -22,4 +22,9 @@ public class FactorySettingSaveRequest
/// 人脸检测配置
///
public FaceImageDetectionDto FaceImageDetection { get; set; }
+
+ ///
+ /// 外包自动离职天数(无通行记录)
+ ///
+ public int NoRecordAutoResignOutsourceDays { get; set; }
}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Organization/Response/FactorySettingResponse.cs b/Src/Dlhis.Basic/Organization/Response/FactorySettingResponse.cs
index 3e6a9661..55b35f80 100644
--- a/Src/Dlhis.Basic/Organization/Response/FactorySettingResponse.cs
+++ b/Src/Dlhis.Basic/Organization/Response/FactorySettingResponse.cs
@@ -22,4 +22,9 @@ public class FactorySettingResponse
/// 人脸检测
///
public FaceImageDetectionDto FaceImageDetection { get; set; }
+
+ ///
+ /// 外包自动离职天数(无通行记录)
+ ///
+ public int NoRecordAutoResignOutsourceDays { get; set; }
}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Organization/Services/IGainfoOutsourceService.cs b/Src/Dlhis.Basic/Organization/Services/IGainfoOutsourceService.cs
index d160e9fc..6aaed7a3 100644
--- a/Src/Dlhis.Basic/Organization/Services/IGainfoOutsourceService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/IGainfoOutsourceService.cs
@@ -18,4 +18,10 @@ public interface IGainfoOutsourceService : IScopeDependency
///
///
Task GetExternalInfoAsync(string userNo);
+
+ ///
+ /// 自动离职处理
+ ///
+ ///
+ Task AutoResignAsync();
}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/FactorySettingService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/FactorySettingService.cs
index 7258b54c..61c132ab 100644
--- a/Src/Dlhis.Basic/Organization/Services/Implements/FactorySettingService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/Implements/FactorySettingService.cs
@@ -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()
.Where(x => factoryCodes.Contains(x.TenantId))
.ToListAsync();
@@ -105,7 +105,8 @@ public class FactorySettingService : IFactorySettingService
Type = Enum.Parse(x!.GetValue(null)!.ToString()!),
Level = FaceQualityLevelEnumType.Medium
}).ToList()
- }
+ },
+ NoRecordAutoResignOutsourceDays = currentSetting?.NoRecordAutoResignOutsourceDays ?? 30
};
}).ToList();
}
diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs
index f48d64df..1beb50be 100644
--- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs
@@ -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 _logger;
- public GainfoOutsourceService(IDbContext dbContext, RedisCache redisCache)
+ public GainfoOutsourceService(IDbContext dbContext,
+ RedisCache redisCache,
+ IGainfoService gainfoService,
+ IFactorySettingService factorySettingService,
+ ILogger 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()
+ .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()
+ .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 GetOutSourceCodeAsync()
@@ -128,17 +182,39 @@ public class GainfoOutsourceService : IGainfoOutsourceService
///
private async Task CheckDuplicate(GainfoOutsourceRequest request)
{
- var exists = await _dbContext.Queryable()
+ var gainfo = await _dbContext.Queryable()
.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().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()
+ gainfo = await _dbContext.Queryable()
.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().Where(x => x.Code == request.Code).SingleAsync();
+ if (outsource != null)
+ {
+ msg = $",对接人工号为{outsource.SapCode}";
+ }
+
+ gainfo.ThrowIfNotNull($"工号{request.Code}重复,厂区为{gainfo.Factory}" + msg);
+ }
}
}
}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
index b4446cf2..2943a9dc 100644
--- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
@@ -243,12 +243,12 @@ public class GainfoService : IGainfoService
public async Task ResignAsync(GainfoResignRequest request)
{
- var gainfo = await _dbContext.Queryable().FirstAsync(x => x.Id == request.Id);
+ var gainfo = await _dbContext.Queryable().SingleAsync(x => x.Id == request.Id);
gainfo.ThrowIfNull("档案数据不存在");
if (request.IsOutsource)
{
- var outsource = await _dbContext.Queryable().FirstAsync(x => x.Code == gainfo.Code);
+ var outsource = await _dbContext.Queryable().SingleAsync(x => x.Code == gainfo.Code);
(outsource == null).ThrowIfTrue("非外包人员不可手动离职");
}
diff --git a/Src/Dlhis.Basic/appsettings.json b/Src/Dlhis.Basic/appsettings.json
index af884ed4..23a2cff2 100644
--- a/Src/Dlhis.Basic/appsettings.json
+++ b/Src/Dlhis.Basic/appsettings.json
@@ -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,
diff --git a/Src/Dlhis.Entity/Sys/Entities/FactorySettingEntity.cs b/Src/Dlhis.Entity/Sys/Entities/FactorySettingEntity.cs
index a3b747ef..89b9f935 100644
--- a/Src/Dlhis.Entity/Sys/Entities/FactorySettingEntity.cs
+++ b/Src/Dlhis.Entity/Sys/Entities/FactorySettingEntity.cs
@@ -34,6 +34,12 @@ public class FactorySettingEntity : SugarBaseEntity, ITenantId
///
[SugarColumn(ColumnDescription = "人脸检测配置", IsNullable = true, IsJson = true)]
public FaceImageDetectionDto FaceImageDetection { get; set; }
+
+
+ ///
+ /// 外包自动离职天数(无通行记录)
+ ///
+ public int NoRecordAutoResignOutsourceDays { get; set; }
public string TenantId { get; set; }
}
\ No newline at end of file
diff --git a/Src/Dlhis.InfoCheck.Api/Dlhis.InfoCheck.Api.csproj b/Src/Dlhis.InfoCheck.Api/Dlhis.InfoCheck.Api.csproj
index 938a97d6..b41f2841 100644
--- a/Src/Dlhis.InfoCheck.Api/Dlhis.InfoCheck.Api.csproj
+++ b/Src/Dlhis.InfoCheck.Api/Dlhis.InfoCheck.Api.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/Src/Dlhis.Jip.Api/Dlhis.Jip.Api.csproj b/Src/Dlhis.Jip.Api/Dlhis.Jip.Api.csproj
index 8964da94..c10fb3f9 100644
--- a/Src/Dlhis.Jip.Api/Dlhis.Jip.Api.csproj
+++ b/Src/Dlhis.Jip.Api/Dlhis.Jip.Api.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/Src/Dlhis.ScheduledTask/Jobs/OutsourceAutoResignJob.cs b/Src/Dlhis.ScheduledTask/Jobs/OutsourceAutoResignJob.cs
new file mode 100644
index 00000000..a0cf2791
--- /dev/null
+++ b/Src/Dlhis.ScheduledTask/Jobs/OutsourceAutoResignJob.cs
@@ -0,0 +1,25 @@
+using Dlhis.Basic.Api;
+using Dlhis.ScheduledTask.Attributes;
+
+namespace Dlhis.ScheduledTask.Jobs;
+
+///
+/// 自动处理外包离职
+///
+[RecurringJob(nameof(OutsourceAutoResignJob), "0 0 1 1/1 * ? ", Name = "自动处理外包离职")]
+public class OutsourceAutoResignJob : BaseJob
+{
+ private readonly IGainfoApi _gainfoApi;
+
+ ///
+ public OutsourceAutoResignJob(IServiceProvider serviceProvider, IGainfoApi gainfoApi) : base(serviceProvider)
+ {
+ _gainfoApi = gainfoApi;
+ }
+
+ ///
+ protected override async Task RunAsync(IServiceProvider serviceProvider)
+ {
+ await _gainfoApi.OutsourceAutoResignAsync();
+ }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.ScheduledTask/Program.cs b/Src/Dlhis.ScheduledTask/Program.cs
index 7f86717a..7c759046 100644
--- a/Src/Dlhis.ScheduledTask/Program.cs
+++ b/Src/Dlhis.ScheduledTask/Program.cs
@@ -22,20 +22,4 @@ public class Startup : DefaultStartup
base.ConfigureServices(services);
services.AddRedis();
}
-
- ///
- public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
- {
- base.Configure(app, env);
-
- var a = app.ApplicationServices.GetService().SyncMealSupplementRecordsAsync(new List()
- {
- new SyncMealSupplementRecordRequest
- {
- UniqueId = null,
- Status = null,
- Msg = null
- }
- }).GetAwaiter().GetResult();
- }
}
\ No newline at end of file
diff --git a/Src/Dlhis.Sys.Api/Dlhis.Sys.Api.csproj b/Src/Dlhis.Sys.Api/Dlhis.Sys.Api.csproj
index 938a97d6..b41f2841 100644
--- a/Src/Dlhis.Sys.Api/Dlhis.Sys.Api.csproj
+++ b/Src/Dlhis.Sys.Api/Dlhis.Sys.Api.csproj
@@ -7,7 +7,7 @@
-
+