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