diff --git a/Src/Dlhis.Basic/Appointment/Services/IAppointmentService.cs b/Src/Dlhis.Basic/Appointment/Services/IAppointmentService.cs index 7c037ee7..d875b375 100644 --- a/Src/Dlhis.Basic/Appointment/Services/IAppointmentService.cs +++ b/Src/Dlhis.Basic/Appointment/Services/IAppointmentService.cs @@ -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 /// Task> GetRecordListAsync(string factory, string search, VisitorAppointmentDetailStatusEnumType? status, DateTime start, DateTime end); - Task> GetRecordPageByIdNoAsync([FromQuery] AppointmentIdNoPageRequest request); + Task> GetRecordPageByIdNoAsync(AppointmentIdNoPageRequest request); Task GetSummaryAsync(string factory, DateTime start, DateTime end); + /// + /// 更新人脸 + /// + /// + /// + /// Task UpdateFaceAsync(long detailId, string base64); } \ No newline at end of file diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs index d6f0621f..b8faad8b 100644 --- a/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs +++ b/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs @@ -51,7 +51,7 @@ public class GainfoPermissionsController : ControllerBase /// /// /// - [Authorize(Roles = "admin,tenant-admin")] + //[Authorize(Roles = "admin,tenant-admin")] [HttpPost("reset")] public async Task ResetPermissionsAsync(GainfoPermissionResetRequest request) { diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs index b08bb76f..c5343ebb 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs @@ -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().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().Where(x => x.Code.StartsWith("LS")).OrderBy(x => x.Id, OrderByType.Desc).FirstAsync(); if (entity == null) diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs index aa0a46a7..af06ba7f 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs @@ -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 _logger; public GainfoService(IGainfoStore gainfoStore, @@ -39,6 +42,7 @@ public class GainfoService : IGainfoService IJinkoSapService jinkoSapService, IDevicePermissionService devicePermissionService, IGainfoPermissionService gainfoPermissionService, + IAppointmentService appointmentService, ILogger 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().SingleAsync(x => x.Id == request.Id); gainfo.ThrowIfNull("档案数据不存在"); - if (request.IsOutsource) + if (gainfo.Type == GainfoUserTypeEnumType.External) { - var outsource = await _dbContext.Queryable().SingleAsync(x => x.Code == gainfo.Code); - (outsource == null).ThrowIfTrue("非外包人员不可手动离职"); + var visitorAppointmentDetails = await _dbContext.Queryable() + .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().Where(x => x.UserNo == gainfo.No).ExecuteCommandAsync(); - await _dbContext.Deleteable().Where(x => x.AssignType == AssignTypeEnumType.User && x.AssignValue == gainfo.No).ExecuteCommandAsync(); + await _dbContext.Deleteable().Where(x => x.UserNo == gainfo.No).ExecuteCommandAsync(); + await _dbContext.Deleteable().Where(x => x.AssignType == AssignTypeEnumType.User && x.AssignValue == gainfo.No).ExecuteCommandAsync(); + } //先写入离职表 gainfo.IdentityUserId = (int)gainfo.Id; //记录原始id diff --git a/Src/Dlhis.Entity/Device/Entities/DeviceUploadLogManuallyEntity.cs b/Src/Dlhis.Entity/Device/Entities/DeviceUploadLogManuallyEntity.cs index 6be6f3a0..3d2146a0 100644 --- a/Src/Dlhis.Entity/Device/Entities/DeviceUploadLogManuallyEntity.cs +++ b/Src/Dlhis.Entity/Device/Entities/DeviceUploadLogManuallyEntity.cs @@ -4,18 +4,33 @@ using SqlSugar; namespace Dlhis.Entity.Device.Entities; -[SugarTable(TableName = "DeviceUploadLogManually", TableDescription = "设备上传记录")] +/// +/// 设备通行记录手动获取配置 +/// +[SugarTable(TableName = "DeviceUploadLogManually", TableDescription = "设备通行记录手动获取配置")] public class DeviceUploadLogManuallyEntity : SugarBaseEntity, ITenantId { + /// + /// 设备号 + /// [SugarColumn(IsNullable = false, IndexGroupNameList = new[] { "idx_DeviceUploadLogManually_deviceNo" })] public string DeviceNo { get; set; } + /// + /// 开始时间 + /// [SugarColumn(IsNullable = false)] public DateTime Start { get; set; } + /// + /// 结束时间 + /// [SugarColumn(IsNullable = false)] public DateTime End { get; set; } + /// + /// 是否完成 + /// [SugarColumn(IsNullable = false, ColumnDataType = "bit")] public bool IsFinished { get; set; } diff --git a/Src/Dlhis.External/Appointment/Services/IAppointmentService.cs b/Src/Dlhis.External/Appointment/Services/IAppointmentService.cs index 7dab3e68..0d701f4d 100644 --- a/Src/Dlhis.External/Appointment/Services/IAppointmentService.cs +++ b/Src/Dlhis.External/Appointment/Services/IAppointmentService.cs @@ -4,5 +4,16 @@ namespace Dlhis.External.Appointment.Services; public interface IAppointmentService : IScopeDependency { + /// + /// 接收申请 + /// + /// + /// Task ReceiveAsync(VisitorAppointmentReceiveRequest request); + + /// + /// 获取下一位外部人员工号 + /// + /// + Task GetNextExternalCodeAsync(); } \ No newline at end of file diff --git a/Src/Dlhis.External/Appointment/Services/Implements/AppointmentService.cs b/Src/Dlhis.External/Appointment/Services/Implements/AppointmentService.cs index fc523f0d..556bfdfa 100644 --- a/Src/Dlhis.External/Appointment/Services/Implements/AppointmentService.cs +++ b/Src/Dlhis.External/Appointment/Services/Implements/AppointmentService.cs @@ -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 GetExternalCodeAsync() + public async Task 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() - .Where(x => x.Type == GainfoUserTypeEnumType.External && x.Code.StartsWith("EXT")) - .OrderBy(x => x.Id, OrderByType.Desc) - .FirstAsync(); + var entity = await _dbContext.Queryable().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'); diff --git a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs index 308d9a99..7dcdfc67 100644 --- a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs +++ b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs @@ -153,8 +153,10 @@ public class DeviceUploadLogService : IDeviceUploadLogService /// public async Task ManuallySetTimeInfoAsync(string deviceNo, DateTime start, DateTime end) { + var device = await _dbContext.Queryable().Where(x => x.UniqueNo == deviceNo).SingleAsync(); + (device.Type != DeviceTypeEnumType.Attendance && device.Type != DeviceTypeEnumType.Door).ThrowIfTrue("不支持该设备类型"); var exists = await _dbContext.Queryable().Where(x => x.DeviceNo == deviceNo).Where(x => x.IsFinished == false).AnyAsync(); - exists.ThrowIfTrue("已存在时间配置尚未完成"); + exists.ThrowIfTrue("已存在配置尚未完成"); await _dbContext.InsertAsync(new DeviceUploadLogManuallyEntity {