diff --git a/Src/Dlhis.Basic/Device/Response/DeviceGroupPageResponse.cs b/Src/Dlhis.Basic/Device/Response/DeviceGroupPageResponse.cs index 8d81e4a4..941a4487 100644 --- a/Src/Dlhis.Basic/Device/Response/DeviceGroupPageResponse.cs +++ b/Src/Dlhis.Basic/Device/Response/DeviceGroupPageResponse.cs @@ -20,6 +20,11 @@ public class DeviceGroupPageResponse /// public DeviceTypeEnumType? Type { get; set; } + /// + /// 是否可编辑 + /// + public bool Editable { get; set; } + /// /// 分组类型描述 /// diff --git a/Src/Dlhis.Basic/Device/Response/DeviceGroupTreeResponse.cs b/Src/Dlhis.Basic/Device/Response/DeviceGroupTreeResponse.cs index 6e9588ea..54d2c7fc 100644 --- a/Src/Dlhis.Basic/Device/Response/DeviceGroupTreeResponse.cs +++ b/Src/Dlhis.Basic/Device/Response/DeviceGroupTreeResponse.cs @@ -1,4 +1,7 @@ -namespace Dlhis.Basic.Device.Response; +using Dlhis.Entity.Device.Enums; +using Kurisu.AspNetCore.Utils.Extensions; + +namespace Dlhis.Basic.Device.Response; public class DeviceGroupTreeResponse { @@ -17,6 +20,27 @@ public class DeviceGroupTreeResponse /// public string Name { get; set; } + /// + /// 设备组类型 + /// + public DeviceTypeEnumType? Type { get; set; } + + /// + /// 分组类型描述 + /// + public string TypeDesc + { + get + { + if (!Type.HasValue) + { + return string.Empty; + } + + return Type.Value.GetDescription(); + } + } + /// /// 下级 /// diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs index 04722357..3047a115 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs @@ -56,8 +56,9 @@ public class DeviceGroupService : IDeviceGroupService if (!request.Id.HasValue) { var entity = request.Adapt(); - + entity.Editable = true; entity.Code = Guid.NewGuid(); + await _dbContext.InsertAsync(entity); } else @@ -65,6 +66,8 @@ public class DeviceGroupService : IDeviceGroupService var entity = await _dbContext.Queryable().Where(x => x.Id == request.Id).FirstAsync(); entity.ThrowIfNull("设备组不存在,无法更新"); + entity.Editable.ThrowIfFalse("不可编辑当前组"); + var nextDevices = await GetDevicesAsync(entity.Code); if (!entity.Type.HasValue) { @@ -75,7 +78,6 @@ public class DeviceGroupService : IDeviceGroupService (request.Type.HasValue && request.Type != entity.Type && nextDevices.Any()).ThrowIfTrue("分组设备类型不匹配,无法修改类型"); } - await _dbContext.UpdateAsync(entity); } } diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs index 39d3405f..e577baaa 100644 --- a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs +++ b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs @@ -100,6 +100,17 @@ public class GainfosController : ControllerBase await _gainfoService.UploadFaceAsync(request); } + /// + /// 批量上传人脸照片 + /// + /// + /// + [HttpPost("faces")] + public async Task UploadFaceAsync(List request) + { + await _gainfoService.UploadFacesAsync(request); + } + /// /// 通过token获取人脸照片,失效或者找不到返回HttpStatus404状态码 /// diff --git a/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs b/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs index 7372f48d..768aa36b 100644 --- a/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs +++ b/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs @@ -1,6 +1,5 @@ using Dlhis.Basic.Organization.Request; using Dlhis.Basic.Organization.Response; -using Dlhis.Entity.Basic.Entity; using Kurisu.Core.DataAccess.Dto; using Microsoft.AspNetCore.Mvc; @@ -22,6 +21,8 @@ public interface IGainfoService : IScopeDependency Task UploadFaceAsync(GainfoUploadFaceRequest request); + Task UploadFacesAsync(List request); + Task GetFaceAsync(string token); Task GetFaceByUserCodeAsync(string userCode); diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs index f21150bd..bfc6e493 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs @@ -255,6 +255,54 @@ public class GainfoService : IGainfoService }); } + public async Task UploadFacesAsync(List requests) + { + foreach (var request in requests) + { + var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).Where(x => x.No == request.UserNo).FirstAsync(); + gainfo ??= await _gainfoStore.Queryable(GainfoStatusEnumType.External).Where(x => x.No == request.UserNo).FirstAsync(); + + gainfo.ThrowIfNull("人员档案信息不存在"); + + await Scoped.Request.Value.CreateAsync(async (sp) => + { + var configuration = sp.GetService(); + var faceConnectionString = configuration.GetSection("SqlSugarOptions:FaceConnectionString").Value; + + var dbContext = sp.GetService(); + //todo 切换连接字符串 + dbContext.Client.CurrentConnectionConfig.ConnectionString = faceConnectionString; + var face = await dbContext.Queryable().Where(x => x.UserCode == gainfo.Code).SingleAsync(); + + var taskType = face == null ? DeviceTaskEnumType.Add : DeviceTaskEnumType.Update; + if (face == null) + { + face = new GainfoFaceEntity + { + UserCode = gainfo.Code, + Face = request.Face + }; + + await dbContext.InsertAsync(face); + } + else + { + if (face.Face == request.Face) + { + _logger.LogWarning("相同的人脸照片更新忽略"); + return; + } + + face.Face = request.Face; + await dbContext.UpdateAsync(face); + } + + //生成任务 + await _devicePermissionService.GenerateDeviceTasksAsync(gainfo.No, taskType); + }); + } + } + public async Task GetFaceByUserCodeAsync(string userCode) diff --git a/Src/Dlhis.Basic/Program.cs b/Src/Dlhis.Basic/Program.cs index 48192332..966be9f0 100644 --- a/Src/Dlhis.Basic/Program.cs +++ b/Src/Dlhis.Basic/Program.cs @@ -24,7 +24,7 @@ public class Startup : DefaultStartup base.ConfigureServices(services); //todo - var redis = ConnectionMultiplexer.Connect($"10.27.21.15:30050,defaultDatabase:1,password=dlhis123"); + var redis = ConnectionMultiplexer.Connect($"192.168.199.30:30115,defaultDatabase:1,password=dlhis123"); services.AddDataProtection() .SetApplicationName("basic") .PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys"); diff --git a/Src/Dlhis.Basic/Summary/Response/AttendanceDetailSummary.cs b/Src/Dlhis.Basic/Summary/Response/AttendanceDetailSummary.cs index f4f9c24a..a013bb6a 100644 --- a/Src/Dlhis.Basic/Summary/Response/AttendanceDetailSummary.cs +++ b/Src/Dlhis.Basic/Summary/Response/AttendanceDetailSummary.cs @@ -1,9 +1,12 @@ -using Dlhis.Basic.Summary.Dto; - -namespace Dlhis.Basic.Summary.Response; +namespace Dlhis.Basic.Summary.Response; public class AttendanceDetailSummary { + /// + /// 考勤总人数 + /// + public int Total => Employed + Unemployed; + /// /// 在职人数 /// diff --git a/Src/Dlhis.Entity/Device/Entities/DeviceGroupEntity.cs b/Src/Dlhis.Entity/Device/Entities/DeviceGroupEntity.cs index 6d037b6a..b3f44bb9 100644 --- a/Src/Dlhis.Entity/Device/Entities/DeviceGroupEntity.cs +++ b/Src/Dlhis.Entity/Device/Entities/DeviceGroupEntity.cs @@ -37,6 +37,13 @@ public class DeviceGroupEntity : SugarBaseEntity, ITenantId, ISoftDeleted public string Name { get; set; } + /// + /// 是否可编辑 + /// + [SugarColumn(ColumnDescription = "是否可编辑")] + public bool Editable { get; set; } + + public string TenantId { get; set; } diff --git a/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs b/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs index 9390c884..0bdda3ff 100644 --- a/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs +++ b/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs @@ -4,6 +4,7 @@ using Dlhis.Entity.Device.Enums; using Dlhis.Sys.Api; using Kurisu.Core.DataAccess.Entity; using Kurisu.SqlSugar.Services; +using Newtonsoft.Json; namespace Dlhis.ScheduledTask.CommonJobs; @@ -13,11 +14,13 @@ public class CreateDefinitelyGroupJob private readonly ITenantApi _tenantApi; private readonly IDbContext _dbContext; - public CreateDefinitelyGroupJob(ILogger logger, ITenantApi tenantApi, IDbContext dbContext) + public CreateDefinitelyGroupJob(ILogger logger, ITenantApi tenantApi, IDbContext dbContext, ISqlSugarOptionsService sqlSugarOptionsService) { _logger = logger; _tenantApi = tenantApi; _dbContext = dbContext; + + sqlSugarOptionsService.IgnoreTenant = true; } public async Task RunAsync() @@ -28,11 +31,12 @@ public class CreateDefinitelyGroupJob var tenantResult = await _tenantApi.GetTenantsInternalAsync(); var tenants = tenantResult.Data; + _logger.LogInformation("获取基地信息:{json}", JsonConvert.SerializeObject(tenants)); + foreach (var tenant in tenants) { if (!await _dbContext.Queryable().Where(x => x.TenantId == tenant.Code).AnyAsync(x => x.IsDefault)) { - var customGroup = new GainfoGroupEntity { PCode = null, @@ -82,6 +86,7 @@ public class CreateDefinitelyGroupJob Code = Guid.NewGuid(), Type = DeviceTypeEnumType.Attendance, Name = "*通用考勤设备组", + Editable = false, CreatedBy = 1, CreateTime = DateTime.Now, @@ -99,6 +104,7 @@ public class CreateDefinitelyGroupJob Code = Guid.NewGuid(), Type = DeviceTypeEnumType.Attendance, Name = "*专用考勤设备组", + Editable = false, CreatedBy = 1, CreateTime = DateTime.Now, @@ -121,6 +127,7 @@ public class CreateDefinitelyGroupJob Code = Guid.NewGuid(), Type = DeviceTypeEnumType.Door, Name = "*非公共区域", + Editable = false, CreatedBy = 1, CreateTime = DateTime.Now, @@ -141,6 +148,7 @@ public class CreateDefinitelyGroupJob Code = Guid.NewGuid(), Type = DeviceTypeEnumType.Door, Name = "*公共区域", + Editable = false, CreatedBy = 1, CreateTime = DateTime.Now, diff --git a/Src/Dlhis.ScheduledTask/Program.cs b/Src/Dlhis.ScheduledTask/Program.cs index 1060cca9..aad2b382 100644 --- a/Src/Dlhis.ScheduledTask/Program.cs +++ b/Src/Dlhis.ScheduledTask/Program.cs @@ -26,11 +26,11 @@ public class Startup : DefaultStartup services.AddSingleton(sp => { - return ConnectionMultiplexer.Connect("10.27.21.15:30050,defaultDatabase:1,password=dlhis123"); + return ConnectionMultiplexer.Connect("192.168.199.30:30115,defaultDatabase:1,password=dlhis123"); }); //todo - var redis = ConnectionMultiplexer.Connect($"10.27.21.15:30050,defaultDatabase:1,password=dlhis123"); + var redis = ConnectionMultiplexer.Connect($"192.168.199.30:30115,defaultDatabase:1,password=dlhis123"); services.AddDataProtection() .SetApplicationName("basic") .PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys"); diff --git a/Src/Dlhis.ScheduledTask/SyncSapInfo/Job/SyncPersonJob.cs b/Src/Dlhis.ScheduledTask/SyncSapInfo/Job/SyncPersonJob.cs index 4bf792b5..9cdb0089 100644 --- a/Src/Dlhis.ScheduledTask/SyncSapInfo/Job/SyncPersonJob.cs +++ b/Src/Dlhis.ScheduledTask/SyncSapInfo/Job/SyncPersonJob.cs @@ -123,10 +123,10 @@ public class SyncPersonJob //CarNo Remark = item.remark, Werks = item.WERKS, - Employed = item.isowner, }; await _dbContext.InsertAsync(info); } + private async Task UpdatePerson(GainfoSapEntity item) { var gainfo = await _dbContext.Queryable().Where(x => x.IdNo == item.idno).FirstAsync(); @@ -138,7 +138,6 @@ public class SyncPersonJob Position = item.web, Phone = item.phone, DepartmentNo = item.appellation, - Employed = item.isowner, Remark = item.remark, Degree = item.email, Werks = item.WERKS diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetAttendanceJob.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetAttendanceJob.cs index 2e57474d..34c614ae 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetAttendanceJob.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetAttendanceJob.cs @@ -33,7 +33,7 @@ public class CreateGetAttendanceJob var b = await _dbContext.Queryable() .Where(x => ds.Contains(x.DeviceUniqueNo)) .Where(x => x.Type == DeviceTaskEnumType.UploadRecord) - .Where(x => x.Status == DeviceTaskStatusEnumType.Process) + .Where(x => x.Status == DeviceTaskStatusEnumType.Process || x.Status == DeviceTaskStatusEnumType.Wait) .AnyAsync(); if (b) diff --git a/Src/Dlhis.ScheduledTask/appsettings.json b/Src/Dlhis.ScheduledTask/appsettings.json index 3ba4c3a5..28bddadf 100644 --- a/Src/Dlhis.ScheduledTask/appsettings.json +++ b/Src/Dlhis.ScheduledTask/appsettings.json @@ -5,6 +5,9 @@ "Microsoft.AspNetCore": "Warning" } }, + "InternalRequest": { + "SysRequestUrl": "http://sys" + }, "SqlSugarOptions": { "DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;", "SlaveConnectionString": [],