全量提交: base_device子查询修复+SyncDevices父设备ParentDeviceId=0+KmsAdapter+前端多项修复
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace VolPro.WebApi.Controllers.Warehouse;
|
||||
|
||||
|
||||
+146
-11
@@ -2,16 +2,26 @@
|
||||
*设备管理扩展 — 区域树 + 点位设备列表
|
||||
*所有改动在 Partial 目录,不破坏框架可升级性
|
||||
*/
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using VolPro.Entity.DomainModels;
|
||||
using Warehouse.IServices;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Threading.Tasks;
|
||||
using VolPro.Core.BaseProvider;
|
||||
using VolPro.Core.Configuration;
|
||||
using VolPro.Core.Enums;
|
||||
using VolPro.Core.Extensions;
|
||||
using VolPro.Core.Filters;
|
||||
using VolPro.Core.ManageUser;
|
||||
using VolPro.Entity.DomainModels;
|
||||
using VolPro.Sys.IRepositories;
|
||||
using VolPro.Sys.Repositories;
|
||||
using Warehouse.IRepositories;
|
||||
using Warehouse.IServices;
|
||||
using Warehouse.Repositories;
|
||||
|
||||
namespace Warehouse.Controllers
|
||||
{
|
||||
@@ -20,6 +30,7 @@ namespace Warehouse.Controllers
|
||||
private readonly Ibase_deviceService _service;//访问业务代码
|
||||
private readonly Iwarehouse_regionsService _regionsService;
|
||||
private readonly Iwarehouse_devicepointService _pointService;
|
||||
private readonly Ibase_deviceRepository _repository;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
[ActivatorUtilitiesConstructor]
|
||||
@@ -27,6 +38,7 @@ namespace Warehouse.Controllers
|
||||
Ibase_deviceService service,
|
||||
Iwarehouse_regionsService regionsService,
|
||||
Iwarehouse_devicepointService pointService,
|
||||
Ibase_deviceRepository repository,
|
||||
IHttpContextAccessor httpContextAccessor
|
||||
)
|
||||
: base(service)
|
||||
@@ -34,6 +46,7 @@ namespace Warehouse.Controllers
|
||||
_service = service;
|
||||
_regionsService = regionsService;
|
||||
_pointService = pointService;
|
||||
_repository = repository;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
@@ -113,15 +126,137 @@ namespace Warehouse.Controllers
|
||||
.OrderBy(x => x.DeviceId)
|
||||
.Select(x => new
|
||||
{
|
||||
x.DeviceId, x.DeviceName, x.AdapterCode, x.SourceId,
|
||||
x.DeviceCategory, x.DeviceGroup, x.IsParent,
|
||||
x.ParentDeviceId, x.IsOnline, x.IpAddress, x.Port,
|
||||
x.Location, x.ExtraData, x.LastSyncTime,
|
||||
x.MapModelId, x.MapModelScale, x.MapModelRotation, x.Enable
|
||||
x.DeviceId,
|
||||
x.DeviceName,
|
||||
x.AdapterCode,
|
||||
x.SourceId,
|
||||
x.DeviceCategory,
|
||||
x.DeviceGroup,
|
||||
x.IsParent,
|
||||
x.ParentDeviceId,
|
||||
x.IsOnline,
|
||||
x.IpAddress,
|
||||
x.Port,
|
||||
x.Location,
|
||||
x.ExtraData,
|
||||
x.LastSyncTime,
|
||||
x.MapModelId,
|
||||
x.MapModelScale,
|
||||
x.MapModelRotation,
|
||||
x.Enable
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
return Ok(new { items, total });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// treetable 获取子节点数据(2021.05.02)
|
||||
/// </summary>
|
||||
/// <param name="loadData"></param>
|
||||
/// <returns></returns>
|
||||
[ApiActionPermission(ActionPermissionOptions.Search)]
|
||||
[HttpPost, Route("GetPageData")]
|
||||
public override ActionResult GetPageData([FromBody] PageDataOptions loadData)
|
||||
{
|
||||
return GetTreeTableRootData(loadData).Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// treetable 获取一级(根)节点数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("getTreeTableRootData")]
|
||||
[ApiActionPermission(ActionPermissionOptions.Search)]
|
||||
public async Task<ActionResult> GetTreeTableRootData([FromBody] PageDataOptions options)
|
||||
{
|
||||
//页面加载根节点数据条件x => x.ParentId == 0,自己根据需要设置
|
||||
var dbServiceId = UserContext.CurrentServiceId;
|
||||
var query = _repository.FindAsIQueryable(x => x.ParentDeviceId == 0 || x.DeviceId == 1);
|
||||
|
||||
var queryChild = _repository.FindAsIQueryable(x => true);
|
||||
|
||||
// 先获取总数
|
||||
var total = await query.CountAsync();
|
||||
|
||||
// 按需先排序,再 Skip/Take 分页
|
||||
var rows = await query
|
||||
.OrderBy(x => x.DeviceId)
|
||||
.Skip((options.Page - 1) * options.Rows)
|
||||
.Take(options.Rows)
|
||||
.Select(s => new
|
||||
{
|
||||
s.DeviceId,
|
||||
s.ParentDeviceId,
|
||||
s.DeviceName,
|
||||
s.AdapterCode,
|
||||
s.SourceId,
|
||||
s.DeviceCategory,
|
||||
s.DeviceGroup,
|
||||
s.IsParent,
|
||||
s.IsOnline,
|
||||
s.IpAddress,
|
||||
s.Port,
|
||||
s.Location,
|
||||
s.ExtraData,
|
||||
s.LastSyncTime,
|
||||
s.MapModelId,
|
||||
s.MapModelScale,
|
||||
s.MapModelRotation,
|
||||
s.Enable,
|
||||
s.CreateDate,
|
||||
s.Creator,
|
||||
s.Modifier,
|
||||
s.ModifyDate,
|
||||
hasChildren = SqlSugar.SqlFunc.Subqueryable<base_device>().Where(x => x.ParentDeviceId == s.DeviceId).Any()
|
||||
}).ToListAsync();
|
||||
|
||||
return JsonNormal(new { total, rows });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///treetable 获取子节点数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("getTreeTableChildrenData")]
|
||||
[ApiActionPermission(ActionPermissionOptions.Search)]
|
||||
public async Task<ActionResult> GetTreeTableChildrenData(int deviceId)
|
||||
{
|
||||
//点击节点时,加载子节点数据
|
||||
var basedeviceRepository = base_deviceRepository.Instance.FindAsIQueryable(x => true);
|
||||
var query = basedeviceRepository.Where(x => x.ParentDeviceId == deviceId);
|
||||
//if (AppSetting.UseDynamicShareDB)
|
||||
//{
|
||||
// query = query.Where(x => x.DbServiceId == UserContext.CurrentServiceId);
|
||||
//}
|
||||
var rows = await query
|
||||
.Select(s => new
|
||||
{
|
||||
s.DeviceId,
|
||||
s.ParentDeviceId,
|
||||
s.DeviceName,
|
||||
s.AdapterCode,
|
||||
s.SourceId,
|
||||
s.DeviceCategory,
|
||||
s.DeviceGroup,
|
||||
s.IsParent,
|
||||
s.IsOnline,
|
||||
s.IpAddress,
|
||||
s.Port,
|
||||
s.Location,
|
||||
s.ExtraData,
|
||||
s.LastSyncTime,
|
||||
s.MapModelId,
|
||||
s.MapModelScale,
|
||||
s.MapModelRotation,
|
||||
s.Enable,
|
||||
s.CreateDate,
|
||||
s.Creator,
|
||||
s.Modifier,
|
||||
s.ModifyDate,
|
||||
hasChildren = SqlSugar.SqlFunc.Subqueryable<base_device>().Where(x => x.ParentDeviceId == s.DeviceId).Any()
|
||||
}).ToListAsync();
|
||||
return JsonNormal(new { rows });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user