fix 处理已知问题
This commit is contained in:
@@ -140,4 +140,16 @@ public class AppointmentsController : ControllerBase
|
||||
end = start.Date.AddDays(1).AddMilliseconds(-1);
|
||||
return await _appointmentService.GetSummaryAsync(factory, start, end);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 自动离职处理
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
[HttpPost("autoResign")]
|
||||
[IgnoreTenant]
|
||||
public async Task AutoResignAsync()
|
||||
{
|
||||
await _appointmentService.AutoResignAsync();
|
||||
}
|
||||
}
|
||||
@@ -66,4 +66,10 @@ public interface IAppointmentService : IScopeDependency
|
||||
/// <param name="base64"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateFaceAsync(long detailId, string base64);
|
||||
|
||||
/// <summary>
|
||||
/// 自动离职
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task AutoResignAsync();
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using Dlhis.Basic.Organization.Services;
|
||||
using Dlhis.Dh.Api;
|
||||
using Dlhis.Dh.Api.Requests;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Entity.Visitor.Entity;
|
||||
@@ -26,6 +27,8 @@ public class AppointmentService : IAppointmentService
|
||||
private readonly IDataProtectionProvider _dataProtectionProvider;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
private readonly IDhApi _dhApi;
|
||||
private readonly IGainfoService _gainfoService;
|
||||
private readonly IFactorySettingService _factorySettingService;
|
||||
private readonly ILogger<AppointmentService> _logger;
|
||||
private readonly IGainfoFaceService _gainfoFaceService;
|
||||
|
||||
@@ -33,6 +36,8 @@ public class AppointmentService : IAppointmentService
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
ICurrentUser currentUser,
|
||||
IDhApi dhApi,
|
||||
IGainfoService gainfoService,
|
||||
IFactorySettingService factorySettingService,
|
||||
IGainfoFaceService gainfoFaceService,
|
||||
ILogger<AppointmentService> logger)
|
||||
{
|
||||
@@ -40,6 +45,8 @@ public class AppointmentService : IAppointmentService
|
||||
_dataProtectionProvider = dataProtectionProvider;
|
||||
_currentUser = currentUser;
|
||||
_dhApi = dhApi;
|
||||
_gainfoService = gainfoService;
|
||||
_factorySettingService = factorySettingService;
|
||||
_logger = logger;
|
||||
_gainfoFaceService = gainfoFaceService;
|
||||
}
|
||||
@@ -311,6 +318,57 @@ public class AppointmentService : IAppointmentService
|
||||
await GenerateDeviceTasksAsync(detail, true, DeviceTaskEnumType.Update, "访客手动上传照片");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task AutoResignAsync()
|
||||
{
|
||||
var outsources = await _dbContext.Queryable<GainfoEntity>()
|
||||
.Where(x => x.Type == GainfoUserTypeEnumType.External)
|
||||
.Select(x => new { x.Id, x.Code, x.Factory, x.CreateTime })
|
||||
.ToListAsync();
|
||||
|
||||
var settings = await _factorySettingService.GetListAsync(false);
|
||||
//0001/1/1 0:00:00
|
||||
var nullDateTime = new DateTime(1, 1, 1);
|
||||
|
||||
foreach (var grp in outsources.GroupBy(x => x.Factory))
|
||||
{
|
||||
var setting = settings.First(x => x.Factory == grp.Key);
|
||||
if (setting.NoRecordAutoResignExternalDays == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var outsource in grp)
|
||||
{
|
||||
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.NoRecordAutoResignExternalDays) < DateTime.Now)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _gainfoService.ResignAsync(new GainfoResignRequest
|
||||
{
|
||||
Id = outsource.Id,
|
||||
Reason = $"{setting.NoRecordAutoResignExternalDays}天无通行记录",
|
||||
Date = DateTime.Now,
|
||||
IsOutsource = true
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "自动归档外部人员异常:{msg}", e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*********************************************************************************************************************
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user