fix 调整时段码结构
This commit is contained in:
@@ -19,17 +19,14 @@ public class DevicesController : ControllerBase
|
||||
private readonly IDeviceService _deviceService;
|
||||
private readonly IDeviceTemplateService _deviceTemplateService;
|
||||
private readonly IDeviceConnectService _deviceConnectService;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public DevicesController(IDeviceService deviceService,
|
||||
IDeviceTemplateService deviceTemplateService,
|
||||
IDeviceConnectService deviceConnectService,
|
||||
IConfiguration configuration)
|
||||
IDeviceConnectService deviceConnectService)
|
||||
{
|
||||
_deviceService = deviceService;
|
||||
_deviceTemplateService = deviceTemplateService;
|
||||
_deviceConnectService = deviceConnectService;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -106,20 +103,6 @@ public class DevicesController : ControllerBase
|
||||
await _deviceService.SaveAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取激活码
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("resigter-code")]
|
||||
public object GetRegisterCode()
|
||||
{
|
||||
return new
|
||||
{
|
||||
AppId = _configuration.GetSection("RegisterAppId").Value,
|
||||
Key = _configuration.GetSection("RegisterCode").Value
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取尚未设置营业点的设备
|
||||
/// </summary>
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace Dlhis.Basic.Device.Dtos;
|
||||
|
||||
public class DeviceTimePeriodDto
|
||||
{
|
||||
public int CardType { get; set; }
|
||||
public TimeOnly OnStart { get; set; }
|
||||
public TimeOnly OnEnd { get; set; }
|
||||
|
||||
public TimeOnly OffStart { get; set; }
|
||||
public TimeOnly OffEnd { get; set; }
|
||||
}
|
||||
@@ -1,22 +1,23 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Entity.Device.Models;
|
||||
|
||||
namespace Dlhis.Basic.Device.Request;
|
||||
|
||||
public class DeviceTimePeriodSaveRequest : IValidatableObject
|
||||
public class DeviceTimePeriodSaveRequest
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 卡类型 timeperiod
|
||||
/// </summary>
|
||||
[Range(2, 3)]
|
||||
[Range(2, 3, ErrorMessage = "卡类型有误")]
|
||||
public int CardType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分配类型 DeviceTimePeriodAssignEnumType
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(DeviceTimePeriodAssignEnumType))]
|
||||
[EnumDataType(typeof(DeviceTimePeriodAssignEnumType), ErrorMessage = "时段分配类型有误")]
|
||||
public DeviceTimePeriodAssignEnumType AssignType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -26,46 +27,9 @@ public class DeviceTimePeriodSaveRequest : IValidatableObject
|
||||
public Guid Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上班开始
|
||||
/// 星期配置
|
||||
/// </summary>
|
||||
[Required]
|
||||
public TimeOnly OnStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上班结束
|
||||
/// </summary>
|
||||
[Required]
|
||||
public TimeOnly OnEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 下班开始
|
||||
/// </summary>
|
||||
[Required]
|
||||
public TimeOnly OffStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 下班结束
|
||||
/// </summary>
|
||||
[Required]
|
||||
public TimeOnly OffEnd { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (OnStart >= OnEnd)
|
||||
{
|
||||
yield return new ValidationResult("上班时段范围有误", new[] { nameof(OnStart) });
|
||||
}
|
||||
|
||||
if (OffStart >= OffEnd)
|
||||
{
|
||||
yield return new ValidationResult("下班时段范围有误", new[] { nameof(OffStart) });
|
||||
}
|
||||
|
||||
|
||||
if (OnEnd >= OffStart)
|
||||
{
|
||||
yield return new ValidationResult("上下班时段范围有误", new[] { nameof(OnEnd) });
|
||||
}
|
||||
}
|
||||
[MinLength(7, ErrorMessage = "配置有误")]
|
||||
[MaxLength(7, ErrorMessage = "配置有误")]
|
||||
public List<DeviceWeekDayTimePeriod> Sections { get; set; }
|
||||
}
|
||||
@@ -1,16 +1,25 @@
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Entity.Device.Models;
|
||||
|
||||
namespace Dlhis.Basic.Device.Response;
|
||||
|
||||
public class DeviceTimePeriodResponse
|
||||
public class DeviceTimePeriodResponse
|
||||
{
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 卡类型
|
||||
/// </summary>
|
||||
public int CardType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 卡类型描述
|
||||
/// </summary>
|
||||
public string CardTypeDesc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分配类型
|
||||
/// </summary>
|
||||
@@ -22,27 +31,7 @@ public class DeviceTimePeriodResponse
|
||||
public Guid Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// 时段信息
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上班开始
|
||||
/// </summary>
|
||||
public TimeOnly OnStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上班结束
|
||||
/// </summary>
|
||||
public TimeOnly OnEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 下班开始
|
||||
/// </summary>
|
||||
public TimeOnly OffStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 下班结束
|
||||
/// </summary>
|
||||
public TimeOnly OffEnd { get; set; }
|
||||
public List<DeviceWeekDayTimePeriod> Sections { get; set; }
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
using Dlhis.Basic.Device.Dtos;
|
||||
using Dlhis.Basic.Device.Request;
|
||||
using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
@@ -25,17 +24,24 @@ public class DeviceTimePeriodService : IDeviceTimePeriodService
|
||||
/// <inheritdoc />
|
||||
public async Task<Pagination<DeviceTimePeriodResponse>> GetPageAsync(DeviceTimePeriodPageRequest request)
|
||||
{
|
||||
var page = await _dbContext.Queryable<DeviceTimePeriodEntity>()
|
||||
var pageOri = await _dbContext.Queryable<DeviceTimePeriodEntity>()
|
||||
.Where(x => x.AssignType == request.AssignType)
|
||||
.Select<DeviceTimePeriodResponse>()
|
||||
.ToPageListAsync(request);
|
||||
|
||||
var page = pageOri.Adapt<Pagination<DeviceTimePeriodResponse>>();
|
||||
|
||||
var values = page.Data.Select(x => x.Value);
|
||||
var data = request.AssignType == DeviceTimePeriodAssignEnumType.Device
|
||||
? await _dbContext.Queryable<DeviceEntity>().Where(x => values.Contains(x.Code)).Select(x => new { x.Code, Name = x.DeployPlace }).ToListAsync()
|
||||
: await _dbContext.Queryable<DeviceTemplateEntity>().Where(x => values.Contains(x.Code)).Select(x => new { x.Code, x.Name }).ToListAsync();
|
||||
|
||||
page.Data.ForEach(item => { item.Name = data.FirstOrDefault(x => x.Code == item.Value)?.Name; });
|
||||
var basicTypes = await _dbContext.Queryable<BasicTypeEntity>().Where(x => x.Type == "timeperiod").ToListAsync();
|
||||
|
||||
page.Data.ForEach(item =>
|
||||
{
|
||||
item.Name = data.FirstOrDefault(x => x.Code == item.Value)?.Name;
|
||||
item.CardTypeDesc = basicTypes.FirstOrDefault(x => x.Code == item.CardType.ToString())?.Display;
|
||||
});
|
||||
|
||||
return page;
|
||||
}
|
||||
@@ -49,8 +55,7 @@ public class DeviceTimePeriodService : IDeviceTimePeriodService
|
||||
var existsData = request.AssignType == DeviceTimePeriodAssignEnumType.Device
|
||||
? await _dbContext.Queryable<DeviceEntity>().Where(x => x.Code == request.Value).AnyAsync()
|
||||
: await _dbContext.Queryable<DeviceTemplateEntity>().Where(x => x.Code == request.Value).AnyAsync();
|
||||
existsData.ThrowIfFalse("数据不匹配");
|
||||
|
||||
existsData.ThrowIfFalse("数据不匹配分配类型");
|
||||
|
||||
(await _dbContext.Queryable<DeviceTimePeriodEntity>()
|
||||
.Where(x => x.CardType == request.CardType)
|
||||
@@ -103,10 +108,10 @@ public class DeviceTimePeriodService : IDeviceTimePeriodService
|
||||
var deviceUniqueNo = device.UniqueNo;
|
||||
|
||||
before.TryGetValue(deviceUniqueNo, out var beforeDtos);
|
||||
beforeDtos ??= new List<DeviceTimePeriodDto>(0);
|
||||
beforeDtos ??= new List<DeviceTimePeriodEntity>(0);
|
||||
|
||||
current.TryGetValue(deviceUniqueNo, out var currentDtos);
|
||||
currentDtos ??= new List<DeviceTimePeriodDto>(0);
|
||||
currentDtos ??= new List<DeviceTimePeriodEntity>(0);
|
||||
|
||||
if (beforeDtos.Count != currentDtos.Count)
|
||||
{
|
||||
@@ -138,7 +143,7 @@ public class DeviceTimePeriodService : IDeviceTimePeriodService
|
||||
|
||||
var c = currentDtos.First(x => x.CardType == cardType);
|
||||
|
||||
if (b.OnStart != c.OnStart || b.OnEnd != c.OnEnd || b.OffStart != c.OffStart || b.OffEnd != c.OffEnd)
|
||||
if (b.ToJson() != c.ToJson())
|
||||
{
|
||||
tasks.Add(new DeviceTaskEntity
|
||||
{
|
||||
@@ -161,7 +166,7 @@ public class DeviceTimePeriodService : IDeviceTimePeriodService
|
||||
await _dbContext.InsertAsync(tasks);
|
||||
}
|
||||
|
||||
private async Task<Dictionary<string, List<DeviceTimePeriodDto>>> GetSettingsAsync()
|
||||
private async Task<Dictionary<string, List<DeviceTimePeriodEntity>>> GetSettingsAsync()
|
||||
{
|
||||
var timePeriods = await _dbContext.Queryable<DeviceTimePeriodEntity>().ToListAsync();
|
||||
|
||||
@@ -178,11 +183,11 @@ public class DeviceTimePeriodService : IDeviceTimePeriodService
|
||||
{
|
||||
var tSettings = timePeriods
|
||||
.Where(item => item.AssignType == DeviceTimePeriodAssignEnumType.Template && item.Value == x.TemplateCode)
|
||||
.Adapt<List<DeviceTimePeriodDto>>();
|
||||
.ToList();
|
||||
|
||||
var dSettings = timePeriods
|
||||
.Where(item => item.AssignType == DeviceTimePeriodAssignEnumType.Device && item.Value == x.Code)
|
||||
.Adapt<List<DeviceTimePeriodDto>>();
|
||||
.ToList();
|
||||
|
||||
foreach (var setting in dSettings)
|
||||
{
|
||||
|
||||
@@ -262,6 +262,10 @@ public class GainfoFaceService : IGainfoFaceService
|
||||
Face = request.Face
|
||||
};
|
||||
|
||||
face.CreatedBy = _currentUser.GetIntSubjectId();
|
||||
face.CreateTime = DateTime.Now;
|
||||
face.ModifiedBy = _currentUser.GetIntSubjectId();
|
||||
face.ModifiedTime = DateTime.Now;
|
||||
await _faceDbContext.InsertAsync(face);
|
||||
}
|
||||
else
|
||||
@@ -271,7 +275,9 @@ public class GainfoFaceService : IGainfoFaceService
|
||||
_logger.LogWarning("相同的人脸照片更新忽略");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
face.ModifiedBy = _currentUser.GetIntSubjectId();
|
||||
face.ModifiedTime = DateTime.Now;
|
||||
face.Face = request.Face;
|
||||
await _faceDbContext.UpdateAsync(face);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5002"
|
||||
"applicationUrl": "http://*:5002"
|
||||
},
|
||||
"Docker": {
|
||||
"commandName": "Docker",
|
||||
|
||||
Reference in New Issue
Block a user