fix 功能调整
This commit is contained in:
@@ -2,12 +2,11 @@
|
||||
using Dlhis.Basic.BusinessShift.Request;
|
||||
using Dlhis.Basic.BusinessShift.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.User.Api;
|
||||
using Dlhis.Sys.Api;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.CustomClass;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.Core.Result;
|
||||
using Kurisu.Core.User.Abstractions;
|
||||
using Kurisu.SqlSugar.Attributes;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
@@ -30,8 +29,8 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
|
||||
{
|
||||
var page = await _dbContext.Queryable<CanteenBusinessShiftEntity>()
|
||||
.LeftJoin<CanteenBusinessPlaceEntity>((shift, place) => shift.BusinessPlaceCode == place.Code)
|
||||
.LeftJoin<BasicTypeEntity>((shift, place,type)=>shift.Code.ToString() == type.Code)
|
||||
.WhereIF(request.Search.IsPresent(), (shift, place) => shift.CustomCode.Contains(request.Search) )
|
||||
.LeftJoin<BasicTypeEntity>((shift, place, type) => shift.Code.ToString() == type.Code)
|
||||
.WhereIF(request.Search.IsPresent(), (shift, place) => shift.CustomCode.Contains(request.Search))
|
||||
.WhereIF(request.BusinessPlaceCode.HasValue, (shift, place) => shift.BusinessPlaceCode == request.BusinessPlaceCode)
|
||||
.Select((shift, place, type) => new BusinessPlaceShiftResponse
|
||||
{
|
||||
|
||||
@@ -20,9 +20,9 @@ public class DevicesController : ControllerBase
|
||||
private readonly IDeviceConnectService _deviceConnectService;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public DevicesController(IDeviceService deviceService,
|
||||
IDeviceTemplateService deviceTemplateService,
|
||||
IDeviceConnectService deviceConnectService,
|
||||
public DevicesController(IDeviceService deviceService,
|
||||
IDeviceTemplateService deviceTemplateService,
|
||||
IDeviceConnectService deviceConnectService,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
_deviceService = deviceService;
|
||||
|
||||
@@ -19,9 +19,9 @@ public class DeviceGroupSaveRequest
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备组功能类型
|
||||
/// 分类类型 DeviceTypeEnumType
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "设备组功能类型不能为空")]
|
||||
[EnumDataType(typeof(DeviceGroupFunctionEnumType))]
|
||||
public DeviceGroupFunctionEnumType Type { get; set; }
|
||||
[Required(ErrorMessage = "分类不能为空")]
|
||||
[EnumDataType(typeof(DeviceTypeEnumType))]
|
||||
public DeviceTypeEnumType Type { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Basic.Device.Request;
|
||||
|
||||
public class DevicePageRequest : PageDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 平台
|
||||
/// 品牌
|
||||
/// </summary>
|
||||
public string Brand { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备唯一号
|
||||
/// </summary>
|
||||
public string UniqueNo { get; set; }
|
||||
/// <summary>
|
||||
/// 设备分类 DeviceTypeEnumType
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(DeviceTypeEnumType))]
|
||||
public DeviceTypeEnumType? Type { get; set; }
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ public class DeviceSaveRequest
|
||||
public List<DeviceFuncEnumType> Funcs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备机功能类型
|
||||
/// 设备类型 DeviceTypeEnumType
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "设备机功能类型不能为空")]
|
||||
[EnumDataType(typeof(DeviceGroupFunctionEnumType))]
|
||||
public DeviceGroupFunctionEnumType Type { get; set; }
|
||||
[Required(ErrorMessage = "设备类型不能为空")]
|
||||
[EnumDataType(typeof(DeviceTypeEnumType))]
|
||||
public DeviceTypeEnumType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 心跳间隔
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Basic.Device.Response;
|
||||
|
||||
@@ -52,7 +50,7 @@ public class DevicePageResponse
|
||||
/// <summary>
|
||||
/// 设备机功能类型
|
||||
/// </summary>
|
||||
public DeviceGroupFunctionEnumType Type { get; set; }
|
||||
public DeviceTypeEnumType Type { get; set; }
|
||||
|
||||
public string TypeDescription => Type.GetDescription();
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
group.ThrowIfNull("设备组不存在");
|
||||
|
||||
await CheckNoNextGroupAsync(group.Code);
|
||||
await CheckGroupTypeMatchAsync(request, group);
|
||||
|
||||
//下发任务
|
||||
await _devicePermissionService.GenerateDeviceTasksAsync(async () =>
|
||||
@@ -87,7 +88,7 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
var relationships = await _dbContext.Queryable<DeviceGroupRelationshipEntity>().Where(x => x.GroupCode == request.GroupCode).ToListAsync();
|
||||
await _dbContext.DeleteAsync(relationships);
|
||||
|
||||
request.DeviceCodes = await _dbContext.Queryable<DeviceEntity>().Where(x => request.DeviceCodes.Contains(x.Code)).Select(x => x.Code).ToListAsync();
|
||||
|
||||
var entities = request.DeviceCodes.Select(x => new DeviceGroupRelationshipEntity
|
||||
{
|
||||
GroupCode = request.GroupCode,
|
||||
@@ -115,7 +116,7 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
/****************************************************** help methods *********************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// 检查
|
||||
/// 检查父级分组存在设备
|
||||
/// </summary>
|
||||
/// <param name="pCode"></param>
|
||||
/// <returns></returns>
|
||||
@@ -139,6 +140,25 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
exists.ThrowIfTrue("存在下级设备分组");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查分组分类匹配
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="group"></param>
|
||||
/// <returns></returns>
|
||||
private async Task CheckGroupTypeMatchAsync(DeviceAssignRequest request, DeviceGroupEntity group)
|
||||
{
|
||||
var devices = await _dbContext.Queryable<DeviceEntity>().Where(x => request.DeviceCodes.Contains(x.Code)).ToListAsync();
|
||||
//检查分组的分类控制
|
||||
if (group.Type.HasValue)
|
||||
{
|
||||
devices.Any(x => x.Type != group.Type).ThrowIfTrue("存在设备类型有误,无法分配到当前分组");
|
||||
}
|
||||
|
||||
//重新赋值到请求参数中
|
||||
request.DeviceCodes = devices.Select(x => x.Code).ToList();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 递归获取树
|
||||
|
||||
@@ -28,11 +28,13 @@ public class DeviceService : IDeviceService
|
||||
{
|
||||
var page = await _dbContext.Queryable<DeviceEntity>()
|
||||
.LeftJoin<DeviceTemplateEntity>((d, dt) => d.TemplateCode == dt.Code)
|
||||
.WhereIF(request.Type.HasValue, (d, dt) => d.Type == request.Type)
|
||||
.Select((d, dt) => new DevicePageResponse
|
||||
{
|
||||
FuncsStr = d.Funcs.ToString(),
|
||||
Brand = dt.Brand,
|
||||
Type = d.Type,
|
||||
|
||||
}, true)
|
||||
.ToPageListAsync(request);
|
||||
|
||||
@@ -72,6 +74,18 @@ public class DeviceService : IDeviceService
|
||||
var entity = await _dbContext.Queryable<DeviceEntity>().Where(x => x.Id == request.Id).FirstAsync();
|
||||
entity.ThrowIfNull("设备不存在,无法更新");
|
||||
|
||||
//分类发生变化,检查是否存在分组
|
||||
if (request.Type != entity.Type)
|
||||
{
|
||||
var existsG = await _dbContext.Queryable<DeviceGroupRelationshipEntity>()
|
||||
.LeftJoin<DeviceGroupEntity>((dgr, dg) => dgr.GroupCode == dg.Code)
|
||||
.Where((dgr, dg) => dgr.DeviceCode == entity.Code)
|
||||
.Where((dgr, dg) => dg.Type != null)
|
||||
.AnyAsync();
|
||||
|
||||
existsG.ThrowIfTrue("存在设备分组,不可修改设备分类");
|
||||
}
|
||||
|
||||
var uniqueNo = entity.UniqueNo;
|
||||
request.Adapt(entity).UniqueNo = uniqueNo;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Dlhis.User.Api;
|
||||
using Dlhis.Sys.Api;
|
||||
using Dlhis.User.Api.Response;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.Result;
|
||||
|
||||
@@ -7,15 +7,7 @@
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://*:5002"
|
||||
},
|
||||
"Docker": {
|
||||
"commandName": "Docker",
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger/index.html",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_URLS": "http://+:80"
|
||||
},
|
||||
"publishAllPorts": true
|
||||
"applicationUrl": "http://localhost:5002"
|
||||
}
|
||||
},
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json"
|
||||
|
||||
Reference in New Issue
Block a user