fix 电子围栏增加部署方向
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using Dlhis.Entity.Device.Enums;
|
||||||
|
|
||||||
namespace Dlhis.Basic.WorkGrids.Request;
|
namespace Dlhis.Basic.WorkGrids.Request;
|
||||||
|
|
||||||
@@ -10,4 +11,7 @@ public class EFenceSaveRequest
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
[EnumDataType(typeof(DeviceDeployDirectionEnumType))]
|
||||||
|
public DeviceDeployDirectionEnumType DirectionType { get; set; }
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
using Dlhis.Entity.Device.Enums;
|
||||||
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
|
|
||||||
namespace Dlhis.Basic.WorkGrids.Response;
|
namespace Dlhis.Basic.WorkGrids.Response;
|
||||||
|
|
||||||
public class EFencePageResponse
|
public class EFencePageResponse
|
||||||
@@ -20,4 +23,8 @@ public class EFencePageResponse
|
|||||||
/// 设备数量
|
/// 设备数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int DeviceCount { get; set; }
|
public int DeviceCount { get; set; }
|
||||||
|
|
||||||
|
public DeviceDeployDirectionEnumType DirectionType { get; set; }
|
||||||
|
|
||||||
|
public string DirectionTypeDesc => DirectionType.GetDescription();
|
||||||
}
|
}
|
||||||
@@ -49,6 +49,7 @@ public class EFenceService : IEFenceService
|
|||||||
Code = x.Code,
|
Code = x.Code,
|
||||||
Name = x.Name,
|
Name = x.Name,
|
||||||
Description = x.Description,
|
Description = x.Description,
|
||||||
|
DirectionType = x.DirectionType,
|
||||||
DeviceCount = SqlFunc.Subqueryable<EFenceDeviceRelationEntity>().Where(p => p.EFenceCode == x.Code).Count(),
|
DeviceCount = SqlFunc.Subqueryable<EFenceDeviceRelationEntity>().Where(p => p.EFenceCode == x.Code).Count(),
|
||||||
})
|
})
|
||||||
.ToPageListAsync(request);
|
.ToPageListAsync(request);
|
||||||
@@ -81,9 +82,8 @@ public class EFenceService : IEFenceService
|
|||||||
//查询设备
|
//查询设备
|
||||||
var devices = await _dbContext.Queryable<DeviceEntity>()
|
var devices = await _dbContext.Queryable<DeviceEntity>()
|
||||||
.Where(d => deviceCodes.Contains(d.Code))
|
.Where(d => deviceCodes.Contains(d.Code))
|
||||||
.Where(d => d.DeployDirection.HasValue)
|
|
||||||
.Where(d => SqlFunc.Subqueryable<EFenceDeviceRelationEntity>()
|
.Where(d => SqlFunc.Subqueryable<EFenceDeviceRelationEntity>()
|
||||||
.Where(p => p.EFenceCode == fence.Code && p.DeviceCode == d.Code)
|
.Where(p => p.DeviceCode == d.Code)
|
||||||
.NotAny() //不可重复分配
|
.NotAny() //不可重复分配
|
||||||
)
|
)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
using Dlhis.Entity.Device.Enums;
|
||||||
using Kurisu.AspNetCore.DataAccess.SqlSugar;
|
using Kurisu.AspNetCore.DataAccess.SqlSugar;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
using SqlSugar.DbConvert;
|
||||||
|
|
||||||
namespace Dlhis.Entity.Device.Entities;
|
namespace Dlhis.Entity.Device.Entities;
|
||||||
|
|
||||||
@@ -25,4 +27,10 @@ public class EFenceEntity : SugarBaseEntity
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(IsNullable = true, Length = 1000)]
|
[SugarColumn(IsNullable = true, Length = 1000)]
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 部署方向
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = false, ColumnDataType = "varchar(20)", SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||||
|
public DeviceDeployDirectionEnumType DirectionType { get; set; }
|
||||||
}
|
}
|
||||||
@@ -50,11 +50,9 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
|||||||
{
|
{
|
||||||
var deviceUniqueNos = requests.Select(x => x.DeviceUniqueNo).Distinct().ToList();
|
var deviceUniqueNos = requests.Select(x => x.DeviceUniqueNo).Distinct().ToList();
|
||||||
var devices = await _dbContext.Queryable<DeviceEntity>().Where(x => deviceUniqueNos.Contains(x.UniqueNo)).ToListAsync();
|
var devices = await _dbContext.Queryable<DeviceEntity>().Where(x => deviceUniqueNos.Contains(x.UniqueNo)).ToListAsync();
|
||||||
var existsDeviceUniqueNos = devices.Select(x => x.UniqueNo).ToList();
|
var existsDeviceUniqueNos = devices.Select(x => x.UniqueNo).ToList();
|
||||||
|
|
||||||
var deviceCodes = devices.Where(x => x.DeployDirection.HasValue).Select(x => x.Code).Distinct().ToList();
|
var deviceCodeInEFenceMap = await GetDeviceCodeInEFencesAsync(devices.Select(x => x.Code).ToList());
|
||||||
var eFenceDeviceRelations = await _dbContext.Queryable<EFenceDeviceRelationEntity>().Where(x => deviceCodes.Contains(x.DeviceCode)).ToListAsync();
|
|
||||||
var eFenceDeviceMap = eFenceDeviceRelations.ToDictionary(x => x.DeviceCode, x => x.EFenceCode);
|
|
||||||
|
|
||||||
var userCodes = requests.Where(x => x.UserUniqueNo.IsPresent()).Select(x => x.UserUniqueNo).Distinct().ToList();
|
var userCodes = requests.Where(x => x.UserUniqueNo.IsPresent()).Select(x => x.UserUniqueNo).Distinct().ToList();
|
||||||
var gainfo1 = await _dbContext.Queryable<GainfoEntity>().Where(x => userCodes.Contains(x.Code)).Select(x => new { x.Code, x.Name, x.Type }).ToListAsync();
|
var gainfo1 = await _dbContext.Queryable<GainfoEntity>().Where(x => userCodes.Contains(x.Code)).Select(x => new { x.Code, x.Name, x.Type }).ToListAsync();
|
||||||
@@ -121,9 +119,9 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
|||||||
? DeviceUploadLogTypeEnumType.Attendance
|
? DeviceUploadLogTypeEnumType.Attendance
|
||||||
: DeviceUploadLogTypeEnumType.Door;
|
: DeviceUploadLogTypeEnumType.Door;
|
||||||
|
|
||||||
if (eFenceDeviceMap.TryGetValue(device.Code, out var eFenceCore))
|
if (deviceCodeInEFenceMap.TryGetValue(device.Code, out var fence))
|
||||||
{
|
{
|
||||||
await HandlerPowerSwitchAsync(eFenceCore, request.UserUniqueNo, device.DeployDirection.Value);
|
await HandlerPowerSwitchAsync(fence.Code, request.UserUniqueNo, fence.DirectionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
var workGridInfo = new WorkGridInfo();
|
var workGridInfo = new WorkGridInfo();
|
||||||
@@ -278,6 +276,23 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task<Dictionary<Guid, EFenceEntity>> GetDeviceCodeInEFencesAsync(List<Guid> deviceCodes)
|
||||||
|
{
|
||||||
|
var eFenceDeviceRelations = await _dbContext.Queryable<EFenceDeviceRelationEntity>()
|
||||||
|
.Where(x => deviceCodes.Contains(x.DeviceCode))
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
var eFenceCodes = eFenceDeviceRelations.Select(x => x.DeviceCode).Distinct().ToList();
|
||||||
|
var eFences = await _dbContext.Queryable<EFenceEntity>().Where(x => eFenceCodes.Contains(x.Code)).ToListAsync();
|
||||||
|
|
||||||
|
//二次过滤
|
||||||
|
var eFenceCodesNew = eFences.Select(x => x.Code).Distinct().ToList();
|
||||||
|
eFenceDeviceRelations = eFenceDeviceRelations.Where(x => eFenceCodesNew.Contains(x.EFenceCode)).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
return eFenceDeviceRelations.ToDictionary(x => x.DeviceCode, x => eFences.First(y => y.Code == x.EFenceCode));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 宿舍只能空开触发
|
/// 宿舍只能空开触发
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user