feat 处理已知禅道
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
using Dlhis.Basic.Appointment.Request;
|
||||
using Dlhis.Basic.Appointment.Response;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Entity.Visitor.Enums;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Basic.Appointment.Services;
|
||||
|
||||
@@ -57,9 +55,15 @@ public interface IAppointmentService : IScopeDependency
|
||||
/// <returns></returns>
|
||||
Task<List<AppointmentDetailResponse>> GetRecordListAsync(string factory, string search, VisitorAppointmentDetailStatusEnumType? status, DateTime start, DateTime end);
|
||||
|
||||
Task<Pagination<AppointmentDetailResponse>> GetRecordPageByIdNoAsync([FromQuery] AppointmentIdNoPageRequest request);
|
||||
Task<Pagination<AppointmentDetailResponse>> GetRecordPageByIdNoAsync(AppointmentIdNoPageRequest request);
|
||||
|
||||
Task<AppointmentSummaryResponse> GetSummaryAsync(string factory, DateTime start, DateTime end);
|
||||
|
||||
/// <summary>
|
||||
/// 更新人脸
|
||||
/// </summary>
|
||||
/// <param name="detailId"></param>
|
||||
/// <param name="base64"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateFaceAsync(long detailId, string base64);
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class GainfoPermissionsController : ControllerBase
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Authorize(Roles = "admin,tenant-admin")]
|
||||
//[Authorize(Roles = "admin,tenant-admin")]
|
||||
[HttpPost("reset")]
|
||||
public async Task<DevicePermissionAssignResponse> ResetPermissionsAsync(GainfoPermissionResetRequest request)
|
||||
{
|
||||
|
||||
@@ -170,6 +170,27 @@ public class GainfoOutsourceService : IGainfoOutsourceService
|
||||
await using var handler = await _redisCache.LockAsync("gainfo:outsource:code-generate", expiry: TimeSpan.FromSeconds(3), retryInterval: TimeSpan.FromSeconds(1), retryCount: 3);
|
||||
handler.Acquired.ThrowIfFalse("生成虚拟工号失败");
|
||||
|
||||
// var value = await _dbContext.Queryable<BasicTypeEntity>().Where(x => x.Type == "gainfoExternalMaxNum").Select(x => x.Code).SingleAsync();
|
||||
// if (value.IsEmpty())
|
||||
// {
|
||||
// code = 1;
|
||||
// await _dbContext.InsertAsync(new BasicTypeEntity
|
||||
// {
|
||||
// Type = "gainfoExternalMaxNum",
|
||||
// Code = "1",
|
||||
// Display = "外部人员序号",
|
||||
// DisplayEn = "外部人员序号",
|
||||
// Sequence = 1
|
||||
// });
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// code = int.Parse(value) + 1;
|
||||
// }
|
||||
//
|
||||
// return "EXT" + code.ToString().PadLeft(6, '0');
|
||||
|
||||
|
||||
int code;
|
||||
var entity = await _dbContext.Queryable<OutsourceEntity>().Where(x => x.Code.StartsWith("LS")).OrderBy(x => x.Id, OrderByType.Desc).FirstAsync();
|
||||
if (entity == null)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Basic.Device.Services;
|
||||
using Dlhis.Basic.Appointment.Services;
|
||||
using Dlhis.Basic.Device.Services;
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
@@ -8,6 +9,7 @@ using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Entity.Sys.Entities;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
using Dlhis.Entity.Visitor.Entity;
|
||||
using Dlhis.Entity.Visitor.Enums;
|
||||
using Dlhis.Sys.Api;
|
||||
using Kurisu.AspNetCore.Authentication.Abstractions;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
@@ -29,6 +31,7 @@ public class GainfoService : IGainfoService
|
||||
private readonly IJinkoSapService _jinkoSapService;
|
||||
private readonly IDevicePermissionService _devicePermissionService;
|
||||
private readonly IGainfoPermissionService _gainfoPermissionService;
|
||||
private readonly IAppointmentService _appointmentService;
|
||||
private readonly ILogger<GainfoService> _logger;
|
||||
|
||||
public GainfoService(IGainfoStore gainfoStore,
|
||||
@@ -39,6 +42,7 @@ public class GainfoService : IGainfoService
|
||||
IJinkoSapService jinkoSapService,
|
||||
IDevicePermissionService devicePermissionService,
|
||||
IGainfoPermissionService gainfoPermissionService,
|
||||
IAppointmentService appointmentService,
|
||||
ILogger<GainfoService> logger)
|
||||
{
|
||||
_gainfoStore = gainfoStore;
|
||||
@@ -49,6 +53,7 @@ public class GainfoService : IGainfoService
|
||||
_jinkoSapService = jinkoSapService;
|
||||
_devicePermissionService = devicePermissionService;
|
||||
_gainfoPermissionService = gainfoPermissionService;
|
||||
_appointmentService = appointmentService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@@ -248,16 +253,26 @@ public class GainfoService : IGainfoService
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().SingleAsync(x => x.Id == request.Id);
|
||||
gainfo.ThrowIfNull("档案数据不存在");
|
||||
|
||||
if (request.IsOutsource)
|
||||
if (gainfo.Type == GainfoUserTypeEnumType.External)
|
||||
{
|
||||
var outsource = await _dbContext.Queryable<OutsourceEntity>().SingleAsync(x => x.Code == gainfo.Code);
|
||||
(outsource == null).ThrowIfTrue("非外包人员不可手动离职");
|
||||
}
|
||||
var visitorAppointmentDetails = await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
||||
.Where(x => x.UserNo == gainfo.No)
|
||||
.Where(x => x.DoorStatus == VisitorAppointmentDetailStatusEnumType.Wait || x.WorkplaceStatus == VisitorAppointmentDetailStatusEnumType.Wait)
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
foreach (var visitorAppointment in visitorAppointmentDetails)
|
||||
{
|
||||
await _appointmentService.FocusLeaveAsync(visitorAppointment.Id, request.Reason);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await _gainfoPermissionService.ResetPermissionsAsync(gainfo.No, DeviceTaskEnumType.Delete, null, request.Reason);
|
||||
|
||||
await _dbContext.Deleteable<GainfoGroupRelationshipEntity>().Where(x => x.UserNo == gainfo.No).ExecuteCommandAsync();
|
||||
await _dbContext.Deleteable<DevicePermissionEntity>().Where(x => x.AssignType == AssignTypeEnumType.User && x.AssignValue == gainfo.No).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
//先写入离职表
|
||||
gainfo.IdentityUserId = (int)gainfo.Id; //记录原始id
|
||||
|
||||
@@ -4,18 +4,33 @@ using SqlSugar;
|
||||
|
||||
namespace Dlhis.Entity.Device.Entities;
|
||||
|
||||
[SugarTable(TableName = "DeviceUploadLogManually", TableDescription = "设备上传记录")]
|
||||
/// <summary>
|
||||
/// 设备通行记录手动获取配置
|
||||
/// </summary>
|
||||
[SugarTable(TableName = "DeviceUploadLogManually", TableDescription = "设备通行记录手动获取配置")]
|
||||
public class DeviceUploadLogManuallyEntity : SugarBaseEntity, ITenantId
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备号
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false, IndexGroupNameList = new[] { "idx_DeviceUploadLogManually_deviceNo" })]
|
||||
public string DeviceNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 开始时间
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false)]
|
||||
public DateTime Start { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 结束时间
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false)]
|
||||
public DateTime End { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否完成
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false, ColumnDataType = "bit")]
|
||||
public bool IsFinished { get; set; }
|
||||
|
||||
|
||||
@@ -4,5 +4,16 @@ namespace Dlhis.External.Appointment.Services;
|
||||
|
||||
public interface IAppointmentService : IScopeDependency
|
||||
{
|
||||
/// <summary>
|
||||
/// 接收申请
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
Task ReceiveAsync(VisitorAppointmentReceiveRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// 获取下一位外部人员工号
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<string> GetNextExternalCodeAsync();
|
||||
}
|
||||
@@ -7,7 +7,6 @@ using Kurisu.AspNetCore.Cache;
|
||||
using Kurisu.AspNetCore.CustomClass;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.External.Appointment.Services.Implements;
|
||||
|
||||
@@ -70,7 +69,7 @@ public class AppointmentService : IAppointmentService
|
||||
gainfo = new GainfoEntity
|
||||
{
|
||||
No = Guid.NewGuid().ToString(),
|
||||
Code = await GetExternalCodeAsync(),
|
||||
Code = await GetNextExternalCodeAsync(),
|
||||
Gender = GetGender(item.IdNo),
|
||||
Type = GainfoUserTypeEnumType.External,
|
||||
IdNo = item.IdNo,
|
||||
@@ -131,7 +130,7 @@ public class AppointmentService : IAppointmentService
|
||||
}
|
||||
}
|
||||
|
||||
private GenderEnumType GetGender(string idNo)
|
||||
private static GenderEnumType GetGender(string idNo)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -142,31 +141,40 @@ public class AppointmentService : IAppointmentService
|
||||
: GenderEnumType.Male;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
|
||||
return GenderEnumType.Unknown;
|
||||
}
|
||||
|
||||
private async Task<string> GetExternalCodeAsync()
|
||||
public async Task<string> GetNextExternalCodeAsync()
|
||||
{
|
||||
await using var handler = await _redisCache.LockAsync("gainfo:external:code-generate", expiry: TimeSpan.FromSeconds(3), retryInterval: TimeSpan.FromSeconds(1), retryCount: 3);
|
||||
handler.Acquired.ThrowIfFalse("生成虚拟工号失败");
|
||||
|
||||
int code;
|
||||
var entity = await _dbContext.Queryable<GainfoEntity>()
|
||||
.Where(x => x.Type == GainfoUserTypeEnumType.External && x.Code.StartsWith("EXT"))
|
||||
.OrderBy(x => x.Id, OrderByType.Desc)
|
||||
.FirstAsync();
|
||||
|
||||
var entity = await _dbContext.Queryable<BasicTypeEntity>().Where(x => x.Type == "gainfoExternalMaxNum").SingleAsync();
|
||||
if (entity == null)
|
||||
{
|
||||
code = 1;
|
||||
await _dbContext.InsertAsync(new BasicTypeEntity
|
||||
{
|
||||
Type = "gainfoExternalMaxNum",
|
||||
Code = "1",
|
||||
Display = "外部人员序号",
|
||||
DisplayEn = "外部人员序号",
|
||||
Remark = string.Empty,
|
||||
Sequence = 1
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
code = int.Parse(entity.Code.Replace("EXT", "").TrimStart('0')) + 1;
|
||||
code = int.Parse(entity.Code) + 1;
|
||||
entity.Code = code.ToString();
|
||||
await _dbContext.UpdateAsync(entity);
|
||||
}
|
||||
|
||||
return "EXT" + code.ToString().PadLeft(6, '0');
|
||||
|
||||
@@ -153,8 +153,10 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
||||
/// <inheritdoc />
|
||||
public async Task ManuallySetTimeInfoAsync(string deviceNo, DateTime start, DateTime end)
|
||||
{
|
||||
var device = await _dbContext.Queryable<DeviceEntity>().Where(x => x.UniqueNo == deviceNo).SingleAsync();
|
||||
(device.Type != DeviceTypeEnumType.Attendance && device.Type != DeviceTypeEnumType.Door).ThrowIfTrue("不支持该设备类型");
|
||||
var exists = await _dbContext.Queryable<DeviceUploadLogManuallyEntity>().Where(x => x.DeviceNo == deviceNo).Where(x => x.IsFinished == false).AnyAsync();
|
||||
exists.ThrowIfTrue("已存在时间配置尚未完成");
|
||||
exists.ThrowIfTrue("已存在配置尚未完成");
|
||||
|
||||
await _dbContext.InsertAsync(new DeviceUploadLogManuallyEntity
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user