V4完成: 预览+云台整合 操作列JSX按钮 全链路调通

This commit is contained in:
2026-05-17 14:22:46 +08:00
parent f118e8b245
commit f9eeeed843
13 changed files with 128 additions and 85 deletions
@@ -17,6 +17,26 @@ namespace Warehouse.Controllers
{
public partial class base_deviceController
{
private readonly Ibase_deviceService _service;//访问业务代码
private readonly Iwarehouse_regionsService _regionsService;
private readonly Iwarehouse_devicepointService _pointService;
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public base_deviceController(
Ibase_deviceService service,
Iwarehouse_regionsService regionsService,
Iwarehouse_devicepointService pointService,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_regionsService = regionsService;
_pointService = pointService;
_httpContextAccessor = httpContextAccessor;
}
/// <summary>
/// 获取区域→点位→设备树。
/// 用于管理端左侧树形控件展示层级结构。
@@ -26,32 +46,27 @@ namespace Warehouse.Controllers
[Route("/api/DeviceManager/GetRegionTree")]
public async Task<IActionResult> GetRegionTree()
{
// 获取区域和点位服务
var regionSvcType = _service.GetType().Assembly.GetType("Warehouse.Services.warehouse_regionsService");
var pointSvcType = _service.GetType().Assembly.GetType("Warehouse.Services.warehouse_devicepointService");
var regionSvc = regionSvcType?.GetProperty("Instance")?.GetValue(null) as IService<warehouse_regions>;
var pointSvc = pointSvcType?.GetProperty("Instance")?.GetValue(null) as IService<warehouse_devicepoint>;
// 查所有区域
var regions = regionSvc != null
? await regionSvc.FindAsIQueryable(x => true).ToListAsync()
: new List<warehouse_regions>();
var regions = await _regionsService.FindAsIQueryable(x => true).ToListAsync();
// 查所有点位
var points = pointSvc != null
? await pointSvc.FindAsIQueryable(x => true).ToListAsync()
: new List<warehouse_devicepoint>();
var points = await _pointService.FindAsIQueryable(x => true).ToListAsync();
// 统计每个点位下的设备数量
//var deviceCounts = new Dictionary<int, int>();
//var allDevices = await _service.FindAsIQueryable(x => true)
// .Where(x => x.PointId != null)
// .GroupBy(x => x.PointId!.Value)
// .Select(g => new { PointId = g.Key, Count = g.Count() })
// .ToListAsync();
var deviceCounts = new Dictionary<int, int>();
var allDevices = await _service.FindAsIQueryable(x => true)
.Where(x => x.PointId != null)
.GroupBy(x => x.PointId!.Value)
.Select(g => new { PointId = g.Key, Count = g.Count() })
var devices = await _service.FindAsIQueryable(x => x.PointId != null)
.Select(x => new { x.PointId })
.ToListAsync();
foreach (var g in allDevices)
deviceCounts[g.PointId] = g.Count;
deviceCounts = devices
.Where(x => x.PointId.HasValue)
.GroupBy(x => x.PointId!.Value)
.ToDictionary(g => g.Key, g => g.Count());
// 构建树形结构
var tree = new List<object>();