fix 获取品牌设备增加factory字段

This commit is contained in:
2024-06-13 14:49:41 +08:00
parent 15c67a4f78
commit bd91787e92
4 changed files with 26 additions and 20 deletions

View File

@@ -72,10 +72,13 @@ public class DevicesConnectController : ControllerBase
/// 获取品牌设备
/// </summary>
/// <param name="brand"></param>
/// <param name="factory"></param>
/// <returns></returns>
[HttpGet("brand-devices")]
public async Task<List<DeviceUniqueWithConnectionInfoDto>> GetDeviceUniqueInfoByBrandAsync([Required(ErrorMessage = "请明确设备品牌")] string brand)
public async Task<List<DeviceUniqueWithConnectionInfoDto>> GetDeviceUniqueInfoByBrandAsync(
[Required(ErrorMessage = "请明确设备品牌")] string brand,
[Required(ErrorMessage = "请明确厂区")] string factory)
{
return await _deviceConnectService.GetDeviceUniqueInfoByBrandAsync(brand);
return await _deviceConnectService.GetDeviceUniqueInfoByBrandAsync(brand, factory);
}
}

View File

@@ -37,11 +37,24 @@ public class DevicesController : ControllerBase
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Authorize(Roles = "admin")]
[HttpGet("template/page")]
public async Task<Pagination<DeviceTemplateResponse>> GetTemplatePageAsync([FromQuery] DeviceTemplatePageRequest request)
{
return await _deviceTemplateService.GetPageAsync(request);
}
/// <summary>
/// 设备模板保存
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Authorize(Roles = "admin")]
[HttpPost("template")]
public async Task SaveTemplateAsync(DeviceTemplateSaveRequest request)
{
await _deviceTemplateService.SaveTemplateAsync(request);
}
/// <summary>
@@ -70,17 +83,6 @@ public class DevicesController : ControllerBase
return await _deviceConnectService.RegisterAsync(request);
}
/// <summary>
/// 设备模板保存
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Authorize(Roles = "admin")]
[HttpPost("template")]
public async Task SaveTemplateAsync(DeviceTemplateSaveRequest request)
{
await _deviceTemplateService.SaveTemplateAsync(request);
}
/// <summary>
/// 设备分页
@@ -219,6 +221,6 @@ public class DevicesController : ControllerBase
[HttpPost("import")]
public async Task Import(List<DeviceImportRequest> request)
{
await _deviceService.ImportAsync(request);
await _deviceService.ImportAsync(request);
}
}
}

View File

@@ -51,6 +51,7 @@ public interface IDeviceConnectService : IScopeDependency
/// 根据品牌获取设备信息
/// </summary>
/// <param name="brand"></param>
/// <param name="factory"></param>
/// <returns></returns>
Task<List<DeviceUniqueWithConnectionInfoDto>> GetDeviceUniqueInfoByBrandAsync(string brand);
Task<List<DeviceUniqueWithConnectionInfoDto>> GetDeviceUniqueInfoByBrandAsync(string brand, string factory);
}

View File

@@ -123,12 +123,12 @@ public class DeviceConnectService : IDeviceConnectService
})
.ToListAsync();
}
public async Task<List<DeviceUniqueWithConnectionInfoDto>> GetDeviceUniqueInfoByBrandAsync(string brand)
public async Task<List<DeviceUniqueWithConnectionInfoDto>> GetDeviceUniqueInfoByBrandAsync(string brand, string factory)
{
return await _dbContext.Queryable<DeviceEntity>()
.LeftJoin<DeviceTemplateEntity>((d, dt) => d.TemplateCode == dt.Code)
.Where((d, dt) => dt.Brand == brand)
.Where((d, dt) => dt.Brand == brand && d.TenantId == factory)
.Select(d => new DeviceUniqueWithConnectionInfoDto
{
DeviceUnique = d.UniqueNo,
@@ -176,7 +176,7 @@ public class DeviceConnectService : IDeviceConnectService
Funcs = new List<DeviceFuncEnumType>(),
Type = DeviceTypeEnumType.Meal,
DeployPlace = deployPlace,
HeartbeatInterval = 30,
HeartbeatInterval = 0,
DeployDirection = null,
Enable = true,
AsAttendance = false,