fix 设备方向,代码格式化
This commit is contained in:
@@ -56,9 +56,9 @@ public class DeviceSaveRequest : IValidatableObject
|
||||
public string DeployPosition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 部署方向
|
||||
/// 部署方向 DeviceDeployDirectionEnumType
|
||||
/// </summary>
|
||||
public string DeployDirection { get; set; }
|
||||
public DeviceDeployDirectionEnumType? DeployDirection { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 连接信息
|
||||
|
||||
@@ -66,7 +66,7 @@ public class DevicePageResponse
|
||||
/// <summary>
|
||||
/// 部署方向
|
||||
/// </summary>
|
||||
public string DeployDirection { get; set; }
|
||||
public DeviceDeployDirectionEnumType? DeployDirection { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模板code
|
||||
|
||||
@@ -71,7 +71,7 @@ public class DeviceConnectService : IDeviceConnectService
|
||||
if (request.BusinessPlaceCode.HasValue)
|
||||
{
|
||||
var businessPlace = await _dbContext.Queryable<BusinessPlaceEntity>().Where(x => x.Code == request.BusinessPlaceCode).FirstAsync();
|
||||
businessPlace.ThrowIfNull("营业点不存在,无法设置到设备注册信息中");
|
||||
businessPlace.ThrowIfNull("营业点不存在,无法设置到设备注册信息中");
|
||||
}
|
||||
|
||||
//更新营业点信息
|
||||
@@ -98,8 +98,8 @@ public class DeviceConnectService : IDeviceConnectService
|
||||
var ipInfo = request.ConnectionInfo.ToObject<IPPortDto>();
|
||||
|
||||
//超时时间
|
||||
var CancellationTokenSource = new CancellationTokenSource(300);
|
||||
await new TcpClient().ConnectAsync(IPAddress.Parse(ipInfo.IP), ipInfo.Port, CancellationTokenSource.Token);
|
||||
var cancellationTokenSource = new CancellationTokenSource(300);
|
||||
await new TcpClient().ConnectAsync(IPAddress.Parse(ipInfo.IP), ipInfo.Port, cancellationTokenSource.Token);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -123,8 +123,8 @@ public class DeviceConnectService : IDeviceConnectService
|
||||
private async Task<DeviceEntity> GetEnableDeviceAsync(string uniqueNo, bool checkExists = true, string deployPlace = "", string tenantId = "")
|
||||
{
|
||||
var device = await _dbContext.Queryable<DeviceEntity>()
|
||||
.Where(x => x.UniqueNo == uniqueNo)
|
||||
.FirstAsync();
|
||||
.Where(x => x.UniqueNo == uniqueNo)
|
||||
.FirstAsync();
|
||||
|
||||
if (checkExists)
|
||||
{
|
||||
@@ -135,7 +135,7 @@ public class DeviceConnectService : IDeviceConnectService
|
||||
{
|
||||
if (device == null)
|
||||
{
|
||||
device = new DeviceEntity()
|
||||
device = new DeviceEntity
|
||||
{
|
||||
Code = Guid.NewGuid(),
|
||||
ConnectionInfo = string.Empty,
|
||||
@@ -146,7 +146,7 @@ public class DeviceConnectService : IDeviceConnectService
|
||||
Funcs = new List<DeviceFuncEnumType>(),
|
||||
DeployPlace = deployPlace,
|
||||
HeartbeatInterval = 0,
|
||||
DeployDirection = string.Empty,
|
||||
DeployDirection = null,
|
||||
Enable = true,
|
||||
DeployPosition = string.Empty,
|
||||
CreatedBy = 1,
|
||||
@@ -161,4 +161,4 @@ public class DeviceConnectService : IDeviceConnectService
|
||||
|
||||
return device;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
using Dlhis.Basic.Device.Dtos;
|
||||
using Dlhis.Basic.Device.Request;
|
||||
using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Entity.Sys.Entities;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.Core.DataAccess.Entity;
|
||||
using Kurisu.Core.User.Abstractions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
@@ -26,38 +24,36 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
_currentUser = currentUser;
|
||||
}
|
||||
|
||||
public async Task AssignAsync(DevicePermissionSaveReuqest reuqest)
|
||||
public async Task AssignAsync(DevicePermissionSaveReuqest request)
|
||||
{
|
||||
var tenantId = request.AssignType == AssignTypeEnumType.Department ? request.TenantId : _currentUser.GetStringTenantId();
|
||||
|
||||
await GenerateDeviceTasksAsync(async () =>
|
||||
{
|
||||
var tenantId = reuqest.AssignType == AssignTypeEnumType.Department ? reuqest.TenantId : _currentUser.GetStringTenantId();
|
||||
|
||||
//删除当前匹配的基地权限
|
||||
var p = await _dbContext.Queryable<DevicePermissionEntity>()
|
||||
.Where(x => x.AssignType == reuqest.AssignType)
|
||||
.Where(x => x.AssignValue == reuqest.AssignValue)
|
||||
.Where(x => x.UniqueType == reuqest.UniqueType)
|
||||
.Where(x => x.TenantId == tenantId)
|
||||
.ToListAsync();
|
||||
.Where(x => x.AssignType == request.AssignType)
|
||||
.Where(x => x.AssignValue == request.AssignValue)
|
||||
.Where(x => x.UniqueType == request.UniqueType)
|
||||
.Where(x => x.TenantId == tenantId)
|
||||
.ToListAsync();
|
||||
|
||||
await _dbContext.DeleteReallyAsync(p);
|
||||
|
||||
//保存配置的权限
|
||||
if (reuqest.Codes.IsPresent())
|
||||
if (request.Codes.IsPresent())
|
||||
{
|
||||
var devicePermissions = reuqest.Codes.Select(code => new DevicePermissionEntity
|
||||
var devicePermissions = request.Codes.Select(code => new DevicePermissionEntity
|
||||
{
|
||||
AssignType = reuqest.AssignType,
|
||||
AssignValue = reuqest.AssignValue,
|
||||
UniqueType = reuqest.UniqueType,
|
||||
AssignType = request.AssignType,
|
||||
AssignValue = request.AssignValue,
|
||||
UniqueType = request.UniqueType,
|
||||
UniqueValue = code,
|
||||
TenantId = tenantId
|
||||
})
|
||||
.ToList();
|
||||
}).ToList();
|
||||
|
||||
await _dbContext.InsertAsync(devicePermissions);
|
||||
}
|
||||
|
||||
}, null);
|
||||
}
|
||||
|
||||
@@ -277,8 +273,7 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
CancellationId = 0,
|
||||
Version = 0,
|
||||
TenantId = x.TenantId
|
||||
})
|
||||
.ToList();
|
||||
}).ToList();
|
||||
|
||||
await _dbContext.InsertAsync(tasks);
|
||||
}
|
||||
@@ -288,11 +283,11 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
var all = await GetAssignDeviceCodesAsync(userNo);
|
||||
|
||||
return await _dbContext.Queryable<DeviceEntity>()
|
||||
.Where(x => x.Enable)
|
||||
.Where(x => x.Type == DeviceTypeEnumType.Meal)
|
||||
.Where(x => all.Contains(x.Code))
|
||||
.Select(x => x.UniqueNo)
|
||||
.ToListAsync();
|
||||
.Where(x => x.Enable)
|
||||
.Where(x => x.Type == DeviceTypeEnumType.Meal)
|
||||
.Where(x => all.Contains(x.Code))
|
||||
.Select(x => x.UniqueNo)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
@@ -307,7 +302,7 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
var deviceRegistries = await _dbContext.Queryable<DeviceRegistryEntity>().Where(x => !SqlFunc.IsNullOrEmpty(x.BusinessPlaceCode)).ToListAsync();
|
||||
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.No == userNo).SingleAsync()
|
||||
?? await _dbContext.Queryable<GainfoEntity>().AS("GainfoLeave").Where(x => x.No == userNo).SingleAsync();
|
||||
?? await _dbContext.Queryable<GainfoEntity>().AS("GainfoLeave").Where(x => x.No == userNo).SingleAsync();
|
||||
var gainfoGroups = await _dbContext.Queryable<GainfoGroupRelationshipEntity>().ToListAsync();
|
||||
|
||||
var devicePermissions = await _dbContext.Queryable<DevicePermissionEntity>().ToListAsync();
|
||||
@@ -349,8 +344,8 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
}
|
||||
|
||||
private static List<UserTenantDeviceCodeDto> GetAssignCodesInternal(
|
||||
List<DevicePermissionEntity> devicePermissions, List<DeviceGroupEntity> deviceGroups,
|
||||
DeviceAssignmentTypeEnumType uniqueType, AssignTypeEnumType assignType, string assignValue)
|
||||
List<DevicePermissionEntity> devicePermissions, List<DeviceGroupEntity> deviceGroups,
|
||||
DeviceAssignmentTypeEnumType uniqueType, AssignTypeEnumType assignType, string assignValue)
|
||||
{
|
||||
var tenantDevicePermissions = devicePermissions
|
||||
.Where(x => x.UniqueType == uniqueType)
|
||||
@@ -365,10 +360,7 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
{
|
||||
//开始递归处理
|
||||
var tops = deviceGroups.Where(x => !x.PCode.HasValue).ToList();
|
||||
tops.ForEach(x =>
|
||||
{
|
||||
RecursionGetNext(x, deviceGroups, tenantDevicePermissions, tenantDevicePermissions.SelectMany(item => item.Codes).Contains(x.Code));
|
||||
});
|
||||
tops.ForEach(x => { RecursionGetNext(x, deviceGroups, tenantDevicePermissions, tenantDevicePermissions.SelectMany(item => item.Codes).Contains(x.Code)); });
|
||||
}
|
||||
|
||||
return tenantDevicePermissions.GroupBy(x => x.Tenant).Select(x =>
|
||||
@@ -391,6 +383,7 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
{
|
||||
result.Add(new UserTenantDeviceCodeDto { Tenant = item.TenantId, Codes = new List<Guid> { item.Code } });
|
||||
}
|
||||
|
||||
RecursionGetNext(item, deviceGroups, result, result.SelectMany(x => x.Codes).Contains(item.Code));
|
||||
}
|
||||
}
|
||||
@@ -435,7 +428,7 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
List<DeviceGroupRelationshipEntity> deviceGroupRelationships,
|
||||
List<DeviceRegistryEntity> deviceRegistries,
|
||||
List<DeviceEntity> devices
|
||||
)
|
||||
)
|
||||
{
|
||||
var userNo = gainfo.No;
|
||||
var deviceDtos = new List<UserTenantDeviceCodeDto>();
|
||||
@@ -492,18 +485,18 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
Codes = x.Select(item => item.DeviceCode).Distinct().ToList()
|
||||
});
|
||||
|
||||
var placeGroup = deviceRegistries.Where(x => businessPlaceCodes.Contains(x.BusinessPlaceCode!.Value)).GroupBy(x => x.TenantId)
|
||||
.Select(x =>
|
||||
{
|
||||
var currentDeviceUniqueNos = x.Select(item => item.DeviceUniqueNo).ToList();
|
||||
var placeGroup = deviceRegistries.Where(x => businessPlaceCodes.Contains(x.BusinessPlaceCode!.Value))
|
||||
.GroupBy(x => x.TenantId)
|
||||
.Select(x =>
|
||||
{
|
||||
var currentDeviceUniqueNos = x.Select(item => item.DeviceUniqueNo).ToList();
|
||||
|
||||
return new UserTenantDeviceCodeDto
|
||||
{
|
||||
Tenant = x.Key,
|
||||
Codes = devices.Where(d => currentDeviceUniqueNos.Contains(d.UniqueNo)).Select(d => d.Code).Distinct().ToList()
|
||||
};
|
||||
})
|
||||
.ToList();
|
||||
return new UserTenantDeviceCodeDto
|
||||
{
|
||||
Tenant = x.Key,
|
||||
Codes = devices.Where(d => currentDeviceUniqueNos.Contains(d.UniqueNo)).Select(d => d.Code).Distinct().ToList()
|
||||
};
|
||||
}).ToList();
|
||||
|
||||
deviceDtos.AddRange(deviceCodesByGroup);
|
||||
deviceDtos.AddRange(placeGroup);
|
||||
@@ -512,7 +505,6 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
{
|
||||
Tenant = x.Key,
|
||||
Codes = x.SelectMany(item => item.Codes).Distinct().ToList()
|
||||
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,8 +65,8 @@ public class DeviceEntity : SugarBaseEntity, ITenantId
|
||||
/// <summary>
|
||||
/// 部署方向
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "部署方向")]
|
||||
public string DeployDirection { get; set; }
|
||||
[SugarColumn(ColumnDescription = "部署方向", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||
public DeviceDeployDirectionEnumType? DeployDirection { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模板code
|
||||
|
||||
@@ -65,6 +65,12 @@ public class DeviceTaskEntity : SugarBaseEntity, ITenantId, IVersion
|
||||
[SugarColumn(DefaultValue = "0")]
|
||||
public long CancellationId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 任务来源
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||
public DeviceTaskSourceEnumType? Source { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 优先级
|
||||
/// </summary>
|
||||
@@ -73,4 +79,4 @@ public class DeviceTaskEntity : SugarBaseEntity, ITenantId, IVersion
|
||||
|
||||
|
||||
public string TenantId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Dlhis.Entity.Device.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// 设备部署方向
|
||||
/// </summary>
|
||||
[Description("设备部署方向")]
|
||||
public enum DeviceDeployDirectionEnumType
|
||||
{
|
||||
/// <summary>
|
||||
/// 进
|
||||
/// </summary>
|
||||
[Description("进")]
|
||||
Entry = 10,
|
||||
|
||||
/// <summary>
|
||||
/// 出
|
||||
/// </summary>
|
||||
[Description("出")]
|
||||
Exit = 20
|
||||
}
|
||||
16
Src/Dlhis.Entity/Device/Enums/DeviceTaskSourceEnumType.cs
Normal file
16
Src/Dlhis.Entity/Device/Enums/DeviceTaskSourceEnumType.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Dlhis.Entity.Device.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// 设备任务来源
|
||||
/// </summary>
|
||||
[Description("设备任务来源")]
|
||||
public enum DeviceTaskSourceEnumType
|
||||
{
|
||||
/// <summary>
|
||||
/// 预约
|
||||
/// </summary>
|
||||
[Description("预约")]
|
||||
Appointment = 10,
|
||||
}
|
||||
@@ -36,5 +36,5 @@ public enum AssignTypeEnumType
|
||||
/// 租户/基地
|
||||
/// </summary>
|
||||
[Description("租户/基地")]
|
||||
Tenant = 5,
|
||||
}
|
||||
Tenant = 5
|
||||
}
|
||||
Reference in New Issue
Block a user