diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs index 863c3039..cdb83f0b 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs @@ -100,7 +100,7 @@ public class DevicePermissionService : IDevicePermissionService if (request.Values.IsPresent()) { var gainfoNos = await _dbContext.Queryable() - .Where(x => request.Values.Contains(x.Code) || request.Values.Contains(x.No)) + .Where(x => request.Values.Contains(x.Code) || request.Values.Contains(x.No) || request.Values.Contains(x.IdNo)) .Select(x => x.No) .ToListAsync(); diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs index a892529f..e8747086 100644 --- a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs +++ b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs @@ -36,7 +36,7 @@ public class GainfosController : ControllerBase { return await _gainfoService.GetPageAsync(request); } - + /// /// 档案详情 /// @@ -199,4 +199,16 @@ public class GainfosController : ControllerBase { await _gainfoService.ResignAsync(request); } + + /// + /// 设置安检白名单 + /// + /// + [HttpPost("setSecurityWhite")] + [Transactional] + [CrossTenant] + public async Task SetSecurityWhiteAsync(GainfoSetSecurityWhiteRequest request) + { + await _gainfoService.SetSecurityWhiteAsync(request.UserCode); + } } \ No newline at end of file diff --git a/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs b/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs index 54386fd3..82233c5c 100644 --- a/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs +++ b/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs @@ -19,7 +19,7 @@ public class GainfoPageResponse /// /// 人员类型 /// - public string Type { get; set; } + public GainfoUserTypeEnumType? Type { get; set; } /// /// 姓名 @@ -120,8 +120,8 @@ public class GainfoPageResponse /// 人事范围 /// public string Werks { get; set; } - - + + /// /// 卡类型 /// diff --git a/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs b/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs index a74430e3..358be7fb 100644 --- a/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs +++ b/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs @@ -19,6 +19,8 @@ public interface IGainfoService : IScopeDependency Task MigrationAsync(MigrationRequest request); Task CheckIdNoAndNameMatchAsync(GainfoCheckIdNoAndNameRequest request); - + Task ResignAsync(GainfoResignRequest request); -} + + Task SetSecurityWhiteAsync(string userCode); +} \ No newline at end of file diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs index 603ba74c..e24350ad 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs @@ -3,6 +3,7 @@ using Dlhis.Basic.Organization.Request; using Dlhis.Basic.Organization.Response; using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Basic.Enums; +using Dlhis.Entity.Device.Entities; using Dlhis.Entity.Device.Enums; using Dlhis.Entity.Visitor.Entity; using Dlhis.Scheduled.Api; @@ -236,6 +237,37 @@ public class GainfoService : IGainfoService await _dbContext.DeleteReallyAsync(gainfo); } + public async Task SetSecurityWhiteAsync(string userCode) + { + var gainfo = await _gainfoStore.Queryable().Where(x => x.Code == userCode).SingleAsync(); + gainfo.ThrowIfNull("档案信息不存在"); + gainfo.Type = GainfoUserTypeEnumType.SecurityWhite; + await _dbContext.UpdateAsync(gainfo); + + var deviceCodes = await _devicePermissionService.GetAssignDeviceCodesAsync(gainfo.No); + + var dhDevices = await _dbContext.Queryable().LeftJoin((x, xt) => x.TemplateCode == xt.Code) + .Where((x, xt) => xt.Brand == "大华") + .Where(x => deviceCodes.Contains(x.Code)) + .ToListAsync(); + + await _dbContext.InsertAsync(dhDevices.Select(x => new DeviceTaskEntity + { + Type = DeviceTaskEnumType.Update, + DeviceType = x.Type, + UserId = gainfo.Id, + UserNo = gainfo.No, + DeviceUniqueNo = x.UniqueNo, + Status = DeviceTaskStatusEnumType.Wait, + Version = 0, + ResultMessage = null, + CancellationId = 0, + Source = null, + Priority = 60, + TenantId = x.TenantId + }).ToList()); + } + /// /// 档案列表 /// diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoStore.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoStore.cs index 4f260124..0e4b4451 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoStore.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoStore.cs @@ -25,13 +25,13 @@ public class GainfoStore : IGainfoStore /// public ISugarQueryable Queryable(GainfoStatusEnumType? gainfoStatus) { - if (gainfoStatus.HasValue && gainfoStatus != GainfoStatusEnumType.Working) + if (gainfoStatus is null or GainfoStatusEnumType.Working) { - var tableName = typeof(GainfoEntity).GetCustomAttribute().TableName; - return _dbContext.Queryable().AS(tableName + gainfoStatus); + return _dbContext.Queryable(); } - return _dbContext.Queryable(); + var tableName = typeof(GainfoEntity).GetCustomAttribute()!.TableName; + return _dbContext.Queryable().AS(tableName + gainfoStatus); } diff --git a/Src/Dlhis.Entity/Basic/Entity/GainfoEntity.cs b/Src/Dlhis.Entity/Basic/Entity/GainfoEntity.cs index d57329c8..22edbd5d 100644 --- a/Src/Dlhis.Entity/Basic/Entity/GainfoEntity.cs +++ b/Src/Dlhis.Entity/Basic/Entity/GainfoEntity.cs @@ -25,13 +25,13 @@ public class GainfoEntity : SugarBaseEntity public string SapNo { get; set; } /// - /// 人员类型 + /// 员类型 /// - [SugarColumn(ColumnDescription = "人员类型")] - public string Type { get; set; } + [SugarColumn(ColumnDescription = "人员类型", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))] + public GainfoUserTypeEnumType? Type { get; set; } /// - /// 姓名 + /// 姓名 /// [SugarColumn(ColumnDescription = "姓名")] public string Name { get; set; } diff --git a/Src/Dlhis.Entity/Basic/Enums/GainfoUserTypeEnumType.cs b/Src/Dlhis.Entity/Basic/Enums/GainfoUserTypeEnumType.cs new file mode 100644 index 00000000..c9bb65d5 --- /dev/null +++ b/Src/Dlhis.Entity/Basic/Enums/GainfoUserTypeEnumType.cs @@ -0,0 +1,22 @@ +using System.ComponentModel; + +namespace Dlhis.Entity.Basic.Enums; + +/// +/// 档案人员类型 +/// +[Description("档案人员类型")] +public enum GainfoUserTypeEnumType +{ + /// + /// 普通人员 + /// + [Description("普通人员")] + Normal = 1, + + /// + /// 安检白名单 + /// + [Description("安检白名单")] + SecurityWhite = 99 +} \ No newline at end of file diff --git a/Src/Dlhis.ScheduledTask/Common/Services/Implements/GainfoUpdateService.cs b/Src/Dlhis.ScheduledTask/Common/Services/Implements/GainfoUpdateService.cs index 0aa4207e..4ec397a4 100644 --- a/Src/Dlhis.ScheduledTask/Common/Services/Implements/GainfoUpdateService.cs +++ b/Src/Dlhis.ScheduledTask/Common/Services/Implements/GainfoUpdateService.cs @@ -155,7 +155,7 @@ public class GainfoUpdateService : IGainfoUpdateService var originInserts = persons.Where(x => searchCodes.Contains(x.ZWORKCODE)).Where(x => !existsUpdateWorkCodes.Contains(x.ZWORKCODE)).ToList(); var updates = ToGainfoSap(originUpdates); - // _logger.LogWarning("SAP分批更新数:{count}", updates.Count); + // _logger.LogWarning("SAP分批更新数:{count}", updates.Count); var inserts = ToGainfoSap(originInserts); //_logger.LogWarning("SAP分批新增数:{count}", inserts.Count); @@ -244,7 +244,7 @@ public class GainfoUpdateService : IGainfoUpdateService { No = Guid.NewGuid().ToString(), SapNo = item.PERNR, - Type = item.@class, + Type = GainfoUserTypeEnumType.Normal, Name = item.gname, Code = item.ename, CountryNo = item.country, diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs index 6e5f68bf..21d638a7 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs @@ -389,7 +389,7 @@ public class AssignmentService : IAssignmentService .LeftJoin((x, type) => x.CardType.ToString() == type.Code && type.Type == "timeperiod") .Where(x => (x.AssignType == DeviceTimePeriodAssignEnumType.Template && templateCodes.Contains(x.Value)) || (x.AssignType == DeviceTimePeriodAssignEnumType.Device && deviceCodes.Contains(x.Value))) - .Select((x, type) => new DeviceTimePeriodDto() + .Select((x, type) => new DeviceTimePeriodDto { CardName = type.Display }, true) diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs index c5674450..cf27a6c8 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs @@ -82,6 +82,7 @@ public class DeviceTaskAssignmentService : IDeviceTaskAssignmentService } catch (Exception) { + //ignore } return page; @@ -100,11 +101,9 @@ public class DeviceTaskAssignmentService : IDeviceTaskAssignmentService tasks.Any(x => x.ModifiedTime.AddMinutes(10) < now && x.Status == DeviceTaskStatusEnumType.Process).ThrowIfTrue("请等待任务处理完成"); } + tasks.ForEach(x => x.Status = DeviceTaskStatusEnumType.Wait); + //更新任务状态 - await _dbContext.Updateable() - .SetColumns(x => x.Status == DeviceTaskStatusEnumType.Wait) - .SetColumns(x => x.ModifiedTime == DateTime.Now) - .Where(x => request.Ids.Contains(x.Id)) - .ExecuteCommandAsync(); + await _dbContext.UpdateAsync(tasks); } } \ No newline at end of file