fix 根据品牌获取设备
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Dlhis.Basic.Device.Dtos;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using Dlhis.Basic.Device.Dtos;
|
||||||
using Dlhis.Basic.Device.Request;
|
using Dlhis.Basic.Device.Request;
|
||||||
using Dlhis.Basic.Device.Services;
|
using Dlhis.Basic.Device.Services;
|
||||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||||
@@ -66,4 +67,15 @@ public class DevicesConnectController : ControllerBase
|
|||||||
{
|
{
|
||||||
return await _deviceConnectService.GetOnlineDeviceUniqueInfoAsync();
|
return await _deviceConnectService.GetOnlineDeviceUniqueInfoAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取品牌设备
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="brand"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("brand-devices")]
|
||||||
|
public async Task<List<DeviceUniqueWithConnectionInfoDto>> GetDeviceUniqueInfoByBrandAsync([Required(ErrorMessage = "请明确设备品牌")] string brand)
|
||||||
|
{
|
||||||
|
return await _deviceConnectService.GetDeviceUniqueInfoByBrandAsync(brand);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -46,4 +46,11 @@ public interface IDeviceConnectService : IScopeDependency
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<DeviceUniqueWithConnectionInfoDto>> GetOnlineDeviceUniqueInfoAsync();
|
Task<List<DeviceUniqueWithConnectionInfoDto>> GetOnlineDeviceUniqueInfoAsync();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据品牌获取设备信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="brand"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<DeviceUniqueWithConnectionInfoDto>> GetDeviceUniqueInfoByBrandAsync(string brand);
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ public class DeviceConnectService : IDeviceConnectService
|
|||||||
{
|
{
|
||||||
return await _dbContext.Queryable<DeviceEntity>()
|
return await _dbContext.Queryable<DeviceEntity>()
|
||||||
.LeftJoin<DeviceRegistryEntity>((d, dr) => d.UniqueNo == dr.DeviceUniqueNo)
|
.LeftJoin<DeviceRegistryEntity>((d, dr) => d.UniqueNo == dr.DeviceUniqueNo)
|
||||||
.Where((d, dr) => d.Enable && SqlFunc.DateAdd(dr.LastHeartbeatTime, SqlFunc.IIF(d.HeartbeatInterval == 0, 30, 30), DateType.Second) > DateTime.Now)
|
.Where((d, dr) => d.Enable && (d.HeartbeatInterval == 0 || SqlFunc.DateAdd(dr.LastHeartbeatTime, d.HeartbeatInterval, DateType.Second) > DateTime.Now))
|
||||||
.Select((d, dr) => new DeviceUniqueWithConnectionInfoDto
|
.Select((d, dr) => new DeviceUniqueWithConnectionInfoDto
|
||||||
{
|
{
|
||||||
DeviceUnique = d.UniqueNo,
|
DeviceUnique = d.UniqueNo,
|
||||||
@@ -123,6 +123,19 @@ public class DeviceConnectService : IDeviceConnectService
|
|||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<DeviceUniqueWithConnectionInfoDto>> GetDeviceUniqueInfoByBrandAsync(string brand)
|
||||||
|
{
|
||||||
|
return await _dbContext.Queryable<DeviceEntity>()
|
||||||
|
.LeftJoin<DeviceTemplateEntity>((d, dt) => d.TemplateCode == dt.Code)
|
||||||
|
.Where((d, dt) => dt.Brand == brand)
|
||||||
|
.Select(d => new DeviceUniqueWithConnectionInfoDto
|
||||||
|
{
|
||||||
|
DeviceUnique = d.UniqueNo,
|
||||||
|
ConnectionInfo = d.ConnectionInfo
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//******************************************************** help methods **********************************************************
|
//******************************************************** help methods **********************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user