diff --git a/Src/Dlhis.Basic/Device/Request/DeviceSaveRequest.cs b/Src/Dlhis.Basic/Device/Request/DeviceSaveRequest.cs index bf96e51e..b1b9cade 100644 --- a/Src/Dlhis.Basic/Device/Request/DeviceSaveRequest.cs +++ b/Src/Dlhis.Basic/Device/Request/DeviceSaveRequest.cs @@ -32,6 +32,12 @@ public class DeviceSaveRequest [Required(ErrorMessage = "设备功能不能为空")] public List Funcs { get; set; } + /// + /// 心跳间隔 + /// + [Range(0, int.MaxValue)] + public int HeartbeatInterval { get; set; } + /// /// 部署点 /// diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs index 9403f1a2..c8255235 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs @@ -27,9 +27,11 @@ public class DeviceService : IDeviceService public async Task> GetPageAsync(DevicePageRequest request) { var page = await _dbContext.Queryable() - .Select(device => new DevicePageResponse + .LeftJoin((d, dt) => d.TemplateCode == dt.Code) + .Select((d, dt) => new DevicePageResponse { - FuncsStr = device.Funcs.ToString() + FuncsStr = d.Funcs.ToString(), + Brand = dt.Brand, }, true) .ToPageListAsync(request); @@ -70,7 +72,8 @@ public class DeviceService : IDeviceService var entity = await _dbContext.Queryable().Where(x => x.Id == request.Id).FirstAsync(); entity.ThrowIfNull("设备不存在,无法更新"); - request.Adapt(entity); + var uniqueNo = entity.UniqueNo; + request.Adapt(entity).UniqueNo = uniqueNo; await _dbContext.UpdateAsync(entity); } diff --git a/Src/Dlhis.Basic/MealUser/Services/Implements/MealUserService.cs b/Src/Dlhis.Basic/MealUser/Services/Implements/MealUserService.cs index b8d29f41..0469fe53 100644 --- a/Src/Dlhis.Basic/MealUser/Services/Implements/MealUserService.cs +++ b/Src/Dlhis.Basic/MealUser/Services/Implements/MealUserService.cs @@ -24,7 +24,16 @@ public class MealUserService : IMealUserService public async Task> GetPageAsync(MealUserPageRequest request) { var page = await _dbContext.Queryable() - .Select() + .LeftJoin((x, ga) => x.UserNo == ga.No) + .Select((x, ga) => new MealUserResponse + { + Balance = x.Balance, + BalanceOfRecharge = x.BalanceOfRecharge, + BalanceOfSubsidies = x.BalanceOfSubsidies, + UserCode = ga.Code, + UserNo = ga.No, + UserType = x.UserType + }) .ToPageListAsync(request); return page; @@ -33,7 +42,7 @@ public class MealUserService : IMealUserService public async Task AddAsync(MealUserAddRequest request) { //todo 获取档案信息 - + var gainfoEntity = await _gainfoStore.Queryable(GainfoStatusEnumType.Working) .Where(x => x.No.ToString() == request.UserNo) .FirstAsync(); diff --git a/Src/Dlhis.Canteen/Setting/Controllers/SettingController.cs b/Src/Dlhis.Canteen/Setting/Controllers/SettingController.cs index a7daf5b8..1bb4bd93 100644 --- a/Src/Dlhis.Canteen/Setting/Controllers/SettingController.cs +++ b/Src/Dlhis.Canteen/Setting/Controllers/SettingController.cs @@ -50,7 +50,7 @@ public class SettingController : ControllerBase /// /// /// - [HttpPut("enable")] + [HttpPost("enable")] public async Task SetEnableAsync(CanteenSettingSetEnableRequest request) { await _settingService.SetEnableAsync(request); diff --git a/Src/Dlhis.Canteen/Setting/Request/CanteenSettingSaveRequest.cs b/Src/Dlhis.Canteen/Setting/Request/CanteenSettingSaveRequest.cs index ef7c480a..1d8fa4da 100644 --- a/Src/Dlhis.Canteen/Setting/Request/CanteenSettingSaveRequest.cs +++ b/Src/Dlhis.Canteen/Setting/Request/CanteenSettingSaveRequest.cs @@ -1,38 +1,48 @@ -using System.ComponentModel.DataAnnotations; +using System; +using System.ComponentModel.DataAnnotations; using Dlhis.Entity.Canteen.Enums; +using Kurisu.AspNetCore.Utils.Extensions; +using Org.BouncyCastle.Asn1.X509.SigI; namespace Dlhis.Canteen.Setting.Request; -public class CanteenSettingSaveRequest +public class CanteenSettingSaveRequest : IValidatableObject { public long? Id { get; set; } /// - /// 配置生效范围 + /// 配置生效范围类型 CanteenSettingUnqiueEnumType /// [EnumDataType(typeof(CanteenSettingUnqiueEnumType))] public CanteenSettingUnqiueEnumType UniqueType { get; set; } /// - /// 唯一值 eg:UniqueType = 1时,传入非空字符串 + /// 配置生效范围 /// - [Required(ErrorMessage = "值不能为空")] public string UniqueValue { get; set; } /// - /// 自定义分类分类 + /// 自定义分类 /// [Required(ErrorMessage = "分类不能为空")] public string Catalog { get; set; } /// - /// 参数 CanteenSettingItemEnumType + /// 就餐配置 CanteenSettingItemEnumType /// [EnumDataType(typeof(CanteenSettingItemEnumType))] public CanteenSettingItemEnumType Item { get; set; } /// - /// 值 + /// 参数值 /// public string Value { get; set; } + + public IEnumerable Validate(ValidationContext validationContext) + { + if (UniqueType != CanteenSettingUnqiueEnumType.Tenant && UniqueValue.IsEmpty()) + { + yield return new ValidationResult($"配置{UniqueType.GetDescription()}值不能为空", new string[] { nameof(UniqueValue) }); + } + } } diff --git a/Src/Dlhis.Canteen/Setting/Response/CanteenSettingResponse.cs b/Src/Dlhis.Canteen/Setting/Response/CanteenSettingResponse.cs index b168d062..8050101b 100644 --- a/Src/Dlhis.Canteen/Setting/Response/CanteenSettingResponse.cs +++ b/Src/Dlhis.Canteen/Setting/Response/CanteenSettingResponse.cs @@ -5,6 +5,9 @@ namespace Dlhis.Canteen.Setting.Response; public class CanteenSettingResponse { + + public long Id { get; set; } + public CanteenSettingUnqiueEnumType UniqueType { get; set; } public string UniqueTypeDesc => UniqueType.GetDescription(); diff --git a/Src/Dlhis.Canteen/Setting/Services/Implements/CanteenSettingService.cs b/Src/Dlhis.Canteen/Setting/Services/Implements/CanteenSettingService.cs index 0d13d529..4f6a4446 100644 --- a/Src/Dlhis.Canteen/Setting/Services/Implements/CanteenSettingService.cs +++ b/Src/Dlhis.Canteen/Setting/Services/Implements/CanteenSettingService.cs @@ -33,12 +33,12 @@ public class CanteenSettingService : ICanteenSettingService .LeftJoin((setting, user) => setting.UniqueValue == user.UserNo) .WhereIF(request.UniqueType.HasValue, setting => setting.UniqueType == request.UniqueType) .WhereIF(request.Item.HasValue, setting => setting.Item == request.Item) - .WhereIF(request.Search.IsPresent(), setting => setting.UniqueValue.Contains(request.Search)) + .WhereIF(request.Search.IsPresent(), setting => setting.Catalog.Contains(request.Search)) .Select((setting, user) => new CanteenSettingResponse { + Id = setting.Id, UniqueType = setting.UniqueType, UniqueValue = setting.UniqueValue, - //UniqueValueDesc = user.UserName, Catalog = setting.Catalog, Enable = setting.Enable, Item = setting.Item, @@ -90,7 +90,7 @@ public class CanteenSettingService : ICanteenSettingService //bool CanteenSettingItemEnumType.AllowSendAtMeal => IsValidFormat(value, request.Item), - CanteenSettingItemEnumType.AllowRepeatInOneShift => IsValidFormat(value,request.Item), + CanteenSettingItemEnumType.AllowRepeatInOneShift => IsValidFormat(value, request.Item), CanteenSettingItemEnumType.AllowCrossTenant => IsValidFormat(value, request.Item), _ => throw new NotImplementedException(), }; @@ -177,15 +177,15 @@ public class CanteenSettingService : ICanteenSettingService { return false; } - } - if(type == CanteenSettingItemEnumType.BusinessSwitchTime) + } + if (type == CanteenSettingItemEnumType.BusinessSwitchTime) { var timeOnly = value.Adapt(); return timeOnly.Minute == 0 && timeOnly.Second == 0; } //mapster - value.Adapt(); - + value.Adapt(); + } catch (Exception) { @@ -194,5 +194,5 @@ public class CanteenSettingService : ICanteenSettingService return true; } - + } diff --git a/Src/Dlhis.Entity/Basic/Entity/GainfoEntity.cs b/Src/Dlhis.Entity/Basic/Entity/GainfoEntity.cs index 788d3080..1ddbe206 100644 --- a/Src/Dlhis.Entity/Basic/Entity/GainfoEntity.cs +++ b/Src/Dlhis.Entity/Basic/Entity/GainfoEntity.cs @@ -42,9 +42,9 @@ public class GainfoEntity : SugarBaseEntity public string NameEn { get; set; } /// - /// 工号 + /// 学工号 /// - [SugarColumn(ColumnDescription = "工号")] + [SugarColumn(ColumnDescription = "学工号")] public string Code { get; set; } /// diff --git a/Src/Dlhis.Entity/Canteen/Enums/CanteenSettingItemEnumType.cs b/Src/Dlhis.Entity/Canteen/Enums/CanteenSettingItemEnumType.cs index d24dc5bd..1b01b10f 100644 --- a/Src/Dlhis.Entity/Canteen/Enums/CanteenSettingItemEnumType.cs +++ b/Src/Dlhis.Entity/Canteen/Enums/CanteenSettingItemEnumType.cs @@ -8,28 +8,20 @@ namespace Dlhis.Entity.Canteen.Enums; [Description("就餐配置项")] public enum CanteenSettingItemEnumType { - //# BusinessSwitchTime varchar(255) not null comment '营业点切换时间 HH:00:00', - //# DayCostMax decimal(16, 2) not null comment '每日允许消费最高金额(存在普通模式)', - //# DayMarketCostMax decimal(16, 2) not null comment '每日超市允许消费最高金额', - //# AllowSendAtMeal bit not null comment '允许就餐下发', - //# DayEVoucherUseCountMax int not null comment '电子券每天使用最多次数', - //# Subsidies decimal(16, 2) not null comment '补贴', - //# AllowRepeatInOneShift bit not null comment '允许一餐次多次消费', - //# OnceCostMax decimal(16, 2) not null comment '一次最高消费金额', - //# AllowCrossTenant bit not null comment '允许跨基地消费', - //# InitBalance decimal(16, 2) not null comment '初始金额', - /// /// 营业点切换时间 /// [Description("营业点切换时间(HH:00:00)")] - BusinessSwitchTime = 1, + BusinessSwitchTime = 100, + + + //----------------------------------------------------------------[200,300)-------------------------------------------------------------------------------------- /// /// 每日允许消费最高金额 /// [Description("每日允许消费最高金额(decimal)")] - DayCostMax, + DayCostMax = 200, /// /// 每日超市允许消费最高金额 @@ -37,17 +29,18 @@ public enum CanteenSettingItemEnumType [Description("每日超市允许消费最高金额(decimal)")] DayMarketCostMax, - /// - /// 允许就餐下发 - /// - [Description("允许就餐下发(0/1)")] - AllowSendAtMeal, /// - /// 电子券每天使用最多次数 + /// 一次最高消费金额 /// - [Description("电子券每天使用最多次数(int)")] - DayEVoucherUseCountMax, + [Description("一次最高消费金额(decimal)")] + OnceCostMax, + + /// + /// 初始金额 + /// + [Description("初始金额(decimal)")] + InitBalance, /// /// 补贴 @@ -55,28 +48,35 @@ public enum CanteenSettingItemEnumType [Description("补贴(decimal)")] Subsidies, + + //--------------------------------------------------------------------[300,400)---------------------------------------------------------------------------------- + + /// + /// 允许就餐下发 + /// + [Description("允许就餐下发(0/1)")] + AllowSendAtMeal = 300, + + /// /// 允许一餐次多次消费 /// [Description("允许一餐次多次消费(0/1)")] AllowRepeatInOneShift, - /// - /// 一次最高消费金额 - /// - [Description("一次最高消费金额(decimal)")] - OnceCostMax, - - /// /// 允许跨基地消费 /// [Description("允许跨基地消费(0/1)")] AllowCrossTenant, + + //--------------------------------------------------------------------[400,500)---------------------------------------------------------------------------------- + /// - /// 初始金额 + /// 电子券每天使用最多次数 /// - [Description("初始金额(decimal)")] - InitBalance, + [Description("电子券每天使用最多次数(int)")] + DayEVoucherUseCountMax = 400, + } diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetAttendanceJob.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetAttendanceJob.cs index de9b16e5..9a0f8d8b 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetAttendanceJob.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetAttendanceJob.cs @@ -2,57 +2,57 @@ using Dlhis.Entity.Device.Entities; using Dlhis.Entity.Device.Enums; using Kurisu.AspNetCore.Utils.Extensions; +using Kurisu.Core.DataAccess.Entity; using Kurisu.SqlSugar.Services; -namespace Dlhis.ScheduledTask.TaskAssignment.Job +namespace Dlhis.ScheduledTask.TaskAssignment.Job; + +public class CreateGetAttendanceJob { - public class CreateGetAttendanceJob + private readonly IDbContext _dbContext; + private readonly ILogger _logger; + + public CreateGetAttendanceJob(IDbContext dbContext, ILogger logger) { - private readonly IDbContext _dbContext; - private readonly ILogger _logger; + _logger = logger; + _dbContext = dbContext; + } - public CreateGetAttendanceJob(IDbContext dbContext, ILogger logger) + public async Task RunAsync() + { + _dbContext.Client.QueryFilter.ClearAndBackup(); + try { - _logger = logger; - _dbContext = dbContext; + var devices = await _dbContext.Queryable().Where(x => x.Enable).ToListAsync(); + devices = devices.Where(x => x.Funcs.Contains(DeviceFuncEnumType.Attendance)).ToList(); + + var tasks = devices.Select(x => new DeviceTaskEntity + { + DeviceUniqueNo = x.UniqueNo, + Status = DeviceTaskStatusEnumType.Wait, + + TenantId = x.TenantId, + Version = 0, + UserNo = string.Empty, + UserCode = string.Empty, + Type = DeviceTaskEnumType.UploadRecord, + + CreatedBy = 1, + CreateTime = DateTime.Now, + ModifiedBy = 1, + ModifiedTime = DateTime.Now, + + }).ToList(); + + await _dbContext.InsertAsync(tasks); } - - public async Task RunAsync() + catch (Exception ex) { - _dbContext.Client.QueryFilter.ClearAndBackup(); - try - { - var devices = await _dbContext.Queryable().Where(x => x.Enable).ToListAsync(); - devices = devices.Where(x => x.Funcs.Contains(DeviceFuncEnumType.Attendance)).ToList(); - - var tasks = devices.Select(x => new DeviceTaskEntity - { - DeviceUniqueNo = x.UniqueNo, - Status = DeviceTaskStatusEnumType.Wait, - - TenantId = x.TenantId, - Version = 0, - UserNo = string.Empty, - UserCode = string.Empty, - Type = DeviceTaskEnumType.UploadRecord, - - CreatedBy = 1, - CreateTime = DateTime.Now, - ModifiedBy = 1, - ModifiedTime = DateTime.Now, - - }).ToList(); - - await _dbContext.InsertAsync(tasks); - } - catch (Exception ex) - { - _logger.LogError(ex, $"生成{DeviceTaskEnumType.UploadRecord.GetDescription()}任务失败:" + ex.Message); - } - finally - { - _dbContext.Client.QueryFilter.Restore(); - } + _logger.LogError(ex, "生成{type}任务失败:{message}", DeviceTaskEnumType.UploadRecord.GetDescription(), ex.Message); + } + finally + { + _dbContext.Client.QueryFilter.Restore(); } } }