feat 处理已知禅道

This commit is contained in:
2025-01-03 17:39:32 +08:00
parent fddf77858e
commit a915492d27
8 changed files with 100 additions and 24 deletions

View File

@@ -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)
{

View File

@@ -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)

View File

@@ -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 _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();
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