From 2a21e6bd5b42268f841c685c1c1e65ba91ff4628 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 22 Feb 2024 16:36:43 +0800 Subject: [PATCH 1/7] =?UTF-8?q?fix=20=E4=BC=98=E5=8C=96=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Dlhis.ScheduledTask/SyncSapInfo/Job/SyncPersonJob.cs | 3 +-- .../TaskAssignment/Job/CreateGetAttendanceJob.cs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) 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) From 77d3207bb48d3c2ed9b6c823d2d2b8378283dcf8 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 22 Feb 2024 16:37:35 +0800 Subject: [PATCH 2/7] =?UTF-8?q?fix=20=E8=8E=B7=E5=8F=96=E8=80=83=E5=8B=A4?= =?UTF-8?q?=E4=BA=BA=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Summary/Response/AttendanceDetailSummary.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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; + /// /// 在职人数 /// From e3710ad0a5ed73d97b2869e683f41353d714a175 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 22 Feb 2024 16:37:52 +0800 Subject: [PATCH 3/7] =?UTF-8?q?feat=20=E6=89=B9=E9=87=8F=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E4=BA=BA=E8=84=B8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/GainfosController.cs | 11 +++++ .../Organization/Services/IGainfoService.cs | 3 +- .../Services/Implements/GainfoService.cs | 48 +++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) 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) From 0296f670e9bc15c526ce5c2c6b62a39534c1afd6 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 22 Feb 2024 16:46:07 +0800 Subject: [PATCH 4/7] =?UTF-8?q?fix=20=E6=81=A2=E5=A4=8Dredis=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Dlhis.Basic/Program.cs | 4 ++-- Src/Dlhis.ScheduledTask/Program.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Src/Dlhis.Basic/Program.cs b/Src/Dlhis.Basic/Program.cs index 0ebc0761..966be9f0 100644 --- a/Src/Dlhis.Basic/Program.cs +++ b/Src/Dlhis.Basic/Program.cs @@ -24,9 +24,9 @@ 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");*/ + .PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys"); } } \ No newline at end of file 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"); From 78b92ab2231b26cc7f8c50f7f95f65c638f98c82 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 22 Feb 2024 17:10:09 +0800 Subject: [PATCH 5/7] =?UTF-8?q?fix=20=E9=85=8D=E7=BD=AEtenant=20api=20?= =?UTF-8?q?=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Dlhis.ScheduledTask/appsettings.json | 3 +++ 1 file changed, 3 insertions(+) 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": [], From 4bd0c2403d78d3b5ba44d99b9683c5ca4b91079e Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 22 Feb 2024 17:43:33 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix=20=E8=AE=BE=E5=A4=87=E7=BB=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=B1=95=E7=A4=BA,=E4=BF=9D=E5=AD=98=E6=8E=A7?= =?UTF-8?q?=E5=88=B6editable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Response/DeviceGroupTreeResponse.cs | 26 ++++++++++++++++++- .../Services/Implements/DeviceGroupService.cs | 6 +++-- .../Device/Entities/DeviceGroupEntity.cs | 7 +++++ .../CommonJobs/CreateDefinitelyGroupJob.cs | 8 +++++- 4 files changed, 43 insertions(+), 4 deletions(-) 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.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..7b8549a8 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; @@ -28,11 +29,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 +84,7 @@ public class CreateDefinitelyGroupJob Code = Guid.NewGuid(), Type = DeviceTypeEnumType.Attendance, Name = "*通用考勤设备组", + Editable = false, CreatedBy = 1, CreateTime = DateTime.Now, @@ -99,6 +102,7 @@ public class CreateDefinitelyGroupJob Code = Guid.NewGuid(), Type = DeviceTypeEnumType.Attendance, Name = "*专用考勤设备组", + Editable = false, CreatedBy = 1, CreateTime = DateTime.Now, @@ -121,6 +125,7 @@ public class CreateDefinitelyGroupJob Code = Guid.NewGuid(), Type = DeviceTypeEnumType.Door, Name = "*非公共区域", + Editable = false, CreatedBy = 1, CreateTime = DateTime.Now, @@ -141,6 +146,7 @@ public class CreateDefinitelyGroupJob Code = Guid.NewGuid(), Type = DeviceTypeEnumType.Door, Name = "*公共区域", + Editable = false, CreatedBy = 1, CreateTime = DateTime.Now, From 0143b2aba1e8d6aa787f8643757fa5b5d91465c3 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 22 Feb 2024 17:53:06 +0800 Subject: [PATCH 7/7] =?UTF-8?q?fix=20=E4=BC=98=E5=8C=96=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Dlhis.Basic/Device/Response/DeviceGroupPageResponse.cs | 5 +++++ .../CommonJobs/CreateDefinitelyGroupJob.cs | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) 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.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs b/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs index 7b8549a8..0bdda3ff 100644 --- a/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs +++ b/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs @@ -14,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()