using Microsoft.AspNetCore.Mvc;
using System.Net;
using System.Net.Http.Headers;
using Microsoft.Extensions.Hosting.Internal;
using Microsoft.AspNetCore.Http.Extensions;
using IStation.Untity;
using Furion.DynamicApiController;
using System.ComponentModel.DataAnnotations;
using Mapster;
using Microsoft.AspNetCore.Authorization;
namespace IStation.Application
{
///
/// MonitorPoint
///
[Route("Monitor/MonitorPoint/Logic")]
[ApiDescriptionSettings("Monitor", Name = "监测点(业务)", Order = 789)]
public class MonitorPoint_LogicController : IDynamicApiController
{
#region 逻辑树
#region 通过 BelongType 和 BelongID 获取逻辑树
///
/// 通过 BelongType 和 BelongID 获取逻辑树
///
[Route("GetLogicalTreeByBelongTypeAndBelongID@V1.0")]
[HttpGet]
public List GetLogicalTreeByBelongTypeAndBelongID_V1_0([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetLogicalTreeByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
#region 监测点组
var group_list = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_group_list = group_list?.Select(x => new MonitorPointGroupLogicDto(x)).ToList();
var vm_cache_group_list = vm_group_list?.Select(x =>
{
var vm_cache_group = new LogicalTreeItemDto();
vm_cache_group.ID = $"{ObjectType.MonitorPointGroup}_{x.ID}";
vm_cache_group.ParentID = $"{ObjectType.MonitorPointGroup}_{x.ParentID}";
vm_cache_group.LogicalName = x.Name;
vm_cache_group.LogicalType = ObjectType.MonitorPointGroup;
vm_cache_group.LogicalID = x.ID;
vm_cache_group.LogicalModel = x;
vm_cache_group.Children = new List();
return vm_cache_group;
}).ToList();
#endregion
#region 监测点
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_monitor_list = monitor_list?.Where(x=>x.UseStatus== Model.eUseStatus.Enable)?.Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
var vm_cache_monitor_list = vm_monitor_list?.Select(x =>
{
var vm_cache_monitor = new LogicalTreeItemDto();
vm_cache_monitor.ID = $"{ObjectType.MonitorPoint}_{x.ID}";
vm_cache_monitor.ParentID = $"{ObjectType.MonitorPointGroup}_{x.GroupID}";
vm_cache_monitor.LogicalName = x.Name;
vm_cache_monitor.LogicalType = ObjectType.MonitorPoint;
vm_cache_monitor.LogicalID = x.ID;
vm_cache_monitor.LogicalModel = x;
vm_cache_monitor.Children = null;
return vm_cache_monitor;
}).ToList();
#endregion
#region 生成树
var vm_cache_list = new List();
//遍历测点
if (vm_cache_monitor_list != null && vm_cache_monitor_list.Count > 0)
{
foreach (var vm_cache_monitor in vm_cache_monitor_list)
{
var vm_cache_monitor_parent = vm_cache_group_list?.Find(t => t.ID == vm_cache_monitor.ParentID);
if (vm_cache_monitor_parent == null)
{
vm_cache_list.Add(vm_cache_monitor);
}
else
{
vm_cache_monitor_parent.Children.Add(vm_cache_monitor);
}
}
}
//遍历测点组
if (vm_cache_group_list != null && vm_cache_group_list.Count > 0)
{
foreach (var vm_cache_group in vm_cache_group_list)
{
var vm_cahce_group_parent = vm_cache_group_list.Find(t => t.ID == vm_cache_group.ParentID);
if (vm_cahce_group_parent == null)
{
vm_cache_list.Add(vm_cache_group);
}
else
{
vm_cahce_group_parent.Children.Add(vm_cache_group);
}
}
}
return vm_cache_list;
#endregion
}, CacheHelper.CacheLevel2);
return vm_list;
}
///
/// 通过 BelongType 和 BelongID 获取逻辑树(不需要验证Token)
///
[AllowAnonymous]
[Route("GetLogicalTreeByBelongTypeAndBelongID@V1.1")]
[HttpGet]
public List GetLogicalTreeByBelongTypeAndBelongID_V1_1([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetLogicalTreeByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
#region 监测点组
var group_list = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_group_list = group_list?.Select(x => new MonitorPointGroupLogicDto(x)).ToList();
var vm_cache_group_list = vm_group_list?.Select(x =>
{
var vm_cache_group = new LogicalTreeItemDto();
vm_cache_group.ID = $"{ObjectType.MonitorPointGroup}_{x.ID}";
vm_cache_group.ParentID = $"{ObjectType.MonitorPointGroup}_{x.ParentID}";
vm_cache_group.LogicalName = x.Name;
vm_cache_group.LogicalType = ObjectType.MonitorPointGroup;
vm_cache_group.LogicalID = x.ID;
vm_cache_group.LogicalModel = x;
vm_cache_group.Children = new List();
return vm_cache_group;
}).ToList();
#endregion
#region 监测点
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_monitor_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable)?.Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
var vm_cache_monitor_list = vm_monitor_list?.Select(x =>
{
var vm_cache_monitor = new LogicalTreeItemDto();
vm_cache_monitor.ID = $"{ObjectType.MonitorPoint}_{x.ID}";
vm_cache_monitor.ParentID = $"{ObjectType.MonitorPointGroup}_{x.GroupID}";
vm_cache_monitor.LogicalName = x.Name;
vm_cache_monitor.LogicalType = ObjectType.MonitorPoint;
vm_cache_monitor.LogicalID = x.ID;
vm_cache_monitor.LogicalModel = x;
vm_cache_monitor.Children = null;
return vm_cache_monitor;
}).ToList();
#endregion
#region 生成树
var vm_cache_list = new List();
//遍历测点
if (vm_cache_monitor_list != null && vm_cache_monitor_list.Count > 0)
{
foreach (var vm_cache_monitor in vm_cache_monitor_list)
{
var vm_cache_monitor_parent = vm_cache_group_list?.Find(t => t.ID == vm_cache_monitor.ParentID);
if (vm_cache_monitor_parent == null)
{
vm_cache_list.Add(vm_cache_monitor);
}
else
{
vm_cache_monitor_parent.Children.Add(vm_cache_monitor);
}
}
}
//遍历测点组
if (vm_cache_group_list != null && vm_cache_group_list.Count > 0)
{
foreach (var vm_cache_group in vm_cache_group_list)
{
var vm_cahce_group_parent = vm_cache_group_list.Find(t => t.ID == vm_cache_group.ParentID);
if (vm_cahce_group_parent == null)
{
vm_cache_list.Add(vm_cache_group);
}
else
{
vm_cahce_group_parent.Children.Add(vm_cache_group);
}
}
}
return vm_cache_list;
#endregion
}, CacheHelper.CacheLevel2);
return vm_list;
}
#endregion
#region 通过 BelongType 和 BelongID 获取常规逻辑树
///
/// 通过 BelongType 和 BelongID 获取常规逻辑树
///
[Route("GetGeneralLogicalTreeByBelongTypeAndBelongID@V1.0")]
[HttpGet]
public List GetGeneralLogicalTreeByBelongTypeAndBelongID_V1_0([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetGeneralLogicalTreeByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
#region 监测点组
var group_list = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_group_list = group_list?.Select(x => new MonitorPointGroupLogicDto(x)).ToList();
var vm_cache_group_list = vm_group_list?.Select(x =>
{
var vm_cache_group = new LogicalTreeItemDto();
vm_cache_group.ID = $"{ObjectType.MonitorPointGroup}_{x.ID}";
vm_cache_group.ParentID = $"{ObjectType.MonitorPointGroup}_{x.ParentID}";
vm_cache_group.LogicalName = x.Name;
vm_cache_group.LogicalType = ObjectType.MonitorPointGroup;
vm_cache_group.LogicalID = x.ID;
vm_cache_group.LogicalModel = x;
vm_cache_group.Children = new List();
return vm_cache_group;
}).ToList();
#endregion
#region 监测点
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId, Model.eMonitorType.General);
var vm_monitor_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable)?.Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
var vm_cache_monitor_list = vm_monitor_list?.Select(x =>
{
var vm_cache_monitor = new LogicalTreeItemDto();
vm_cache_monitor.ID = $"{ObjectType.MonitorPoint}_{x.ID}";
vm_cache_monitor.ParentID = $"{ObjectType.MonitorPointGroup}_{x.GroupID}";
vm_cache_monitor.LogicalName = x.Name;
vm_cache_monitor.LogicalType = ObjectType.MonitorPoint;
vm_cache_monitor.LogicalID = x.ID;
vm_cache_monitor.LogicalModel = x;
vm_cache_monitor.Children = null;
return vm_cache_monitor;
}).ToList();
#endregion
#region 生成树
var vm_cache_list = new List();
//遍历测点
if (vm_cache_monitor_list != null && vm_cache_monitor_list.Count > 0)
{
foreach (var vm_cache_monitor in vm_cache_monitor_list)
{
var vm_cache_monitor_parent = vm_cache_group_list?.Find(t => t.ID == vm_cache_monitor.ParentID);
if (vm_cache_monitor_parent == null)
{
vm_cache_list.Add(vm_cache_monitor);
}
else
{
vm_cache_monitor_parent.Children.Add(vm_cache_monitor);
}
}
}
//遍历测点组
if (vm_cache_group_list != null && vm_cache_group_list.Count > 0)
{
foreach (var vm_cache_group in vm_cache_group_list)
{
var vm_cahce_group_parent = vm_cache_group_list.Find(t => t.ID == vm_cache_group.ParentID);
if (vm_cahce_group_parent == null)
{
vm_cache_list.Add(vm_cache_group);
}
else
{
vm_cahce_group_parent.Children.Add(vm_cache_group);
}
}
}
return vm_cache_list;
#endregion
}, CacheHelper.CacheLevel2);
return vm_list;
}
///
/// 通过 BelongType 和 BelongID 获取常规逻辑树(不需要验证Token)
///
[AllowAnonymous]
[Route("GetGeneralLogicalTreeByBelongTypeAndBelongID@V1.1")]
[HttpGet]
public List GetGeneralLogicalTreeByBelongTypeAndBelongID_V1_1([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetGeneralLogicalTreeByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
#region 监测点组
var group_list = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_group_list = group_list?.Select(x => new MonitorPointGroupLogicDto(x)).ToList();
var vm_cache_group_list = vm_group_list?.Select(x =>
{
var vm_cache_group = new LogicalTreeItemDto();
vm_cache_group.ID = $"{ObjectType.MonitorPointGroup}_{x.ID}";
vm_cache_group.ParentID = $"{ObjectType.MonitorPointGroup}_{x.ParentID}";
vm_cache_group.LogicalName = x.Name;
vm_cache_group.LogicalType = ObjectType.MonitorPointGroup;
vm_cache_group.LogicalID = x.ID;
vm_cache_group.LogicalModel = x;
vm_cache_group.Children = new List();
return vm_cache_group;
}).ToList();
#endregion
#region 监测点
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId, Model.eMonitorType.General);
var vm_monitor_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable)?.Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
var vm_cache_monitor_list = vm_monitor_list?.Select(x =>
{
var vm_cache_monitor = new LogicalTreeItemDto();
vm_cache_monitor.ID = $"{ObjectType.MonitorPoint}_{x.ID}";
vm_cache_monitor.ParentID = $"{ObjectType.MonitorPointGroup}_{x.GroupID}";
vm_cache_monitor.LogicalName = x.Name;
vm_cache_monitor.LogicalType = ObjectType.MonitorPoint;
vm_cache_monitor.LogicalID = x.ID;
vm_cache_monitor.LogicalModel = x;
vm_cache_monitor.Children = null;
return vm_cache_monitor;
}).ToList();
#endregion
#region 生成树
var vm_cache_list = new List();
//遍历测点
if (vm_cache_monitor_list != null && vm_cache_monitor_list.Count > 0)
{
foreach (var vm_cache_monitor in vm_cache_monitor_list)
{
var vm_cache_monitor_parent = vm_cache_group_list?.Find(t => t.ID == vm_cache_monitor.ParentID);
if (vm_cache_monitor_parent == null)
{
vm_cache_list.Add(vm_cache_monitor);
}
else
{
vm_cache_monitor_parent.Children.Add(vm_cache_monitor);
}
}
}
//遍历测点组
if (vm_cache_group_list != null && vm_cache_group_list.Count > 0)
{
foreach (var vm_cache_group in vm_cache_group_list)
{
var vm_cahce_group_parent = vm_cache_group_list.Find(t => t.ID == vm_cache_group.ParentID);
if (vm_cahce_group_parent == null)
{
vm_cache_list.Add(vm_cache_group);
}
else
{
vm_cahce_group_parent.Children.Add(vm_cache_group);
}
}
}
return vm_cache_list;
#endregion
}, CacheHelper.CacheLevel2);
return vm_list;
}
#endregion
#region 通过 BelongType 和 BelongID 获取振动逻辑树
///
/// 通过 BelongType 和 BelongID 获取振动逻辑树
///
[Route("GetVibrationLogicalTreeByBelongTypeAndBelongID@V1.0")]
[HttpGet]
public List GetVibrationLogicalTreeByBelongTypeAndBelongID_V1_0([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetVibrationLogicalTreeByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
#region 监测点组
var group_list = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_group_list = group_list?.Select(x => new MonitorPointGroupLogicDto(x)).ToList();
var vm_cache_group_list = vm_group_list?.Select(x =>
{
var vm_cache_group = new LogicalTreeItemDto();
vm_cache_group.ID = $"{ObjectType.MonitorPointGroup}_{x.ID}";
vm_cache_group.ParentID = $"{ObjectType.MonitorPointGroup}_{x.ParentID}";
vm_cache_group.LogicalName = x.Name;
vm_cache_group.LogicalType = ObjectType.MonitorPointGroup;
vm_cache_group.LogicalID = x.ID;
vm_cache_group.LogicalModel = x;
vm_cache_group.Children = new List();
return vm_cache_group;
}).ToList();
#endregion
#region 监测点
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId, Model.eMonitorType.Vibration);
var vm_monitor_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable)?.Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
var vm_cache_monitor_list = vm_monitor_list?.Select(x =>
{
var vm_cache_monitor = new LogicalTreeItemDto();
vm_cache_monitor.ID = $"{ObjectType.MonitorPoint}_{x.ID}";
vm_cache_monitor.ParentID = $"{ObjectType.MonitorPointGroup}_{x.GroupID}";
vm_cache_monitor.LogicalName = x.Name;
vm_cache_monitor.LogicalType = ObjectType.MonitorPoint;
vm_cache_monitor.LogicalID = x.ID;
vm_cache_monitor.LogicalModel = x;
vm_cache_monitor.Children = null;
return vm_cache_monitor;
}).ToList();
#endregion
#region 生成树
var vm_cache_list = new List();
//遍历测点
if (vm_cache_monitor_list != null && vm_cache_monitor_list.Count > 0)
{
foreach (var vm_cache_monitor in vm_cache_monitor_list)
{
var vm_cache_monitor_parent = vm_cache_group_list?.Find(t => t.ID == vm_cache_monitor.ParentID);
if (vm_cache_monitor_parent == null)
{
vm_cache_list.Add(vm_cache_monitor);
}
else
{
vm_cache_monitor_parent.Children.Add(vm_cache_monitor);
}
}
}
//遍历测点组
if (vm_cache_group_list != null && vm_cache_group_list.Count > 0)
{
foreach (var vm_cache_group in vm_cache_group_list)
{
var vm_cahce_group_parent = vm_cache_group_list.Find(t => t.ID == vm_cache_group.ParentID);
if (vm_cahce_group_parent == null)
{
vm_cache_list.Add(vm_cache_group);
}
else
{
vm_cahce_group_parent.Children.Add(vm_cache_group);
}
}
}
return vm_cache_list;
#endregion
}, CacheHelper.CacheLevel2);
return vm_list;
}
///
/// 通过 BelongType 和 BelongID 获取振动逻辑树(不需要验证Token)
///
[AllowAnonymous]
[Route("GetVibrationLogicalTreeByBelongTypeAndBelongID@V1.1")]
[HttpGet]
public List GetVibrationLogicalTreeByBelongTypeAndBelongID_V1_1([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetVibrationLogicalTreeByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
#region 监测点组
var group_list = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_group_list = group_list?.Select(x => new MonitorPointGroupLogicDto(x)).ToList();
var vm_cache_group_list = vm_group_list?.Select(x =>
{
var vm_cache_group = new LogicalTreeItemDto();
vm_cache_group.ID = $"{ObjectType.MonitorPointGroup}_{x.ID}";
vm_cache_group.ParentID = $"{ObjectType.MonitorPointGroup}_{x.ParentID}";
vm_cache_group.LogicalName = x.Name;
vm_cache_group.LogicalType = ObjectType.MonitorPointGroup;
vm_cache_group.LogicalID = x.ID;
vm_cache_group.LogicalModel = x;
vm_cache_group.Children = new List();
return vm_cache_group;
}).ToList();
#endregion
#region 监测点
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId, Model.eMonitorType.Vibration);
var vm_monitor_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable)?.Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
var vm_cache_monitor_list = vm_monitor_list?.Select(x =>
{
var vm_cache_monitor = new LogicalTreeItemDto();
vm_cache_monitor.ID = $"{ObjectType.MonitorPoint}_{x.ID}";
vm_cache_monitor.ParentID = $"{ObjectType.MonitorPointGroup}_{x.GroupID}";
vm_cache_monitor.LogicalName = x.Name;
vm_cache_monitor.LogicalType = ObjectType.MonitorPoint;
vm_cache_monitor.LogicalID = x.ID;
vm_cache_monitor.LogicalModel = x;
vm_cache_monitor.Children = null;
return vm_cache_monitor;
}).ToList();
#endregion
#region 生成树
var vm_cache_list = new List();
//遍历测点
if (vm_cache_monitor_list != null && vm_cache_monitor_list.Count > 0)
{
foreach (var vm_cache_monitor in vm_cache_monitor_list)
{
var vm_cache_monitor_parent = vm_cache_group_list?.Find(t => t.ID == vm_cache_monitor.ParentID);
if (vm_cache_monitor_parent == null)
{
vm_cache_list.Add(vm_cache_monitor);
}
else
{
vm_cache_monitor_parent.Children.Add(vm_cache_monitor);
}
}
}
//遍历测点组
if (vm_cache_group_list != null && vm_cache_group_list.Count > 0)
{
foreach (var vm_cache_group in vm_cache_group_list)
{
var vm_cahce_group_parent = vm_cache_group_list.Find(t => t.ID == vm_cache_group.ParentID);
if (vm_cahce_group_parent == null)
{
vm_cache_list.Add(vm_cache_group);
}
else
{
vm_cahce_group_parent.Children.Add(vm_cache_group);
}
}
}
return vm_cache_list;
#endregion
}, CacheHelper.CacheLevel2);
return vm_list;
}
#endregion
#region 通过 BelongType 和 BelongID 获取实时测点逻辑树
///
/// 通过 BelongType 和 BelongID 获取实时测点逻辑树
///
[Route("GetRealLogicalTreeByBelongTypeAndBelongID@V1.0")]
[HttpGet]
public List GetRealLogicalTreeByBelongTypeAndBelongID_V1_0([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetRealLogicalTreeByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
#region 监测点组
var group_list = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_group_list = group_list?.Select(x => new MonitorPointGroupLogicDto(x)).ToList();
var vm_cache_group_list = vm_group_list?.Select(x =>
{
var vm_cache_group = new LogicalTreeItemDto();
vm_cache_group.ID = $"{ObjectType.MonitorPointGroup}_{x.ID}";
vm_cache_group.ParentID = $"{ObjectType.MonitorPointGroup}_{x.ParentID}";
vm_cache_group.LogicalName = x.Name;
vm_cache_group.LogicalType = ObjectType.MonitorPointGroup;
vm_cache_group.LogicalID = x.ID;
vm_cache_group.LogicalModel = x;
vm_cache_group.Children = new List();
return vm_cache_group;
}).ToList();
#endregion
#region 监测点
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId, Model.Monitor.eCronType.Real);
var vm_monitor_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable)?.Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
var vm_cache_monitor_list = vm_monitor_list?.Select(x =>
{
var vm_cache_monitor = new LogicalTreeItemDto();
vm_cache_monitor.ID = $"{ObjectType.MonitorPoint}_{x.ID}";
vm_cache_monitor.ParentID = $"{ObjectType.MonitorPointGroup}_{x.GroupID}";
vm_cache_monitor.LogicalName = x.Name;
vm_cache_monitor.LogicalType = ObjectType.MonitorPoint;
vm_cache_monitor.LogicalID = x.ID;
vm_cache_monitor.LogicalModel = x;
vm_cache_monitor.Children = null;
return vm_cache_monitor;
}).ToList();
#endregion
#region 生成树
var vm_cache_list = new List();
//遍历测点
if (vm_cache_monitor_list != null && vm_cache_monitor_list.Count > 0)
{
foreach (var vm_cache_monitor in vm_cache_monitor_list)
{
var vm_cache_monitor_parent = vm_cache_group_list?.Find(t => t.ID == vm_cache_monitor.ParentID);
if (vm_cache_monitor_parent == null)
{
vm_cache_list.Add(vm_cache_monitor);
}
else
{
vm_cache_monitor_parent.Children.Add(vm_cache_monitor);
}
}
}
//遍历测点组
if (vm_cache_group_list != null && vm_cache_group_list.Count > 0)
{
foreach (var vm_cache_group in vm_cache_group_list)
{
var vm_cahce_group_parent = vm_cache_group_list.Find(t => t.ID == vm_cache_group.ParentID);
if (vm_cahce_group_parent == null)
{
vm_cache_list.Add(vm_cache_group);
}
else
{
vm_cahce_group_parent.Children.Add(vm_cache_group);
}
}
}
return vm_cache_list;
#endregion
}, CacheHelper.CacheLevel2);
return vm_list;
}
///
/// 通过 BelongType 和 BelongID 获取实时测点逻辑树(不需要验证Token)
///
[AllowAnonymous]
[Route("GetRealLogicalTreeByBelongTypeAndBelongID@V1.1")]
[HttpGet]
public List GetRealLogicalTreeByBelongTypeAndBelongID_V1_1([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetRealLogicalTreeByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
#region 监测点组
var group_list = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_group_list = group_list?.Select(x => new MonitorPointGroupLogicDto(x)).ToList();
var vm_cache_group_list = vm_group_list?.Select(x =>
{
var vm_cache_group = new LogicalTreeItemDto();
vm_cache_group.ID = $"{ObjectType.MonitorPointGroup}_{x.ID}";
vm_cache_group.ParentID = $"{ObjectType.MonitorPointGroup}_{x.ParentID}";
vm_cache_group.LogicalName = x.Name;
vm_cache_group.LogicalType = ObjectType.MonitorPointGroup;
vm_cache_group.LogicalID = x.ID;
vm_cache_group.LogicalModel = x;
vm_cache_group.Children = new List();
return vm_cache_group;
}).ToList();
#endregion
#region 监测点
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId, Model.Monitor.eCronType.Real);
var vm_monitor_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable)?.Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
var vm_cache_monitor_list = vm_monitor_list?.Select(x =>
{
var vm_cache_monitor = new LogicalTreeItemDto();
vm_cache_monitor.ID = $"{ObjectType.MonitorPoint}_{x.ID}";
vm_cache_monitor.ParentID = $"{ObjectType.MonitorPointGroup}_{x.GroupID}";
vm_cache_monitor.LogicalName = x.Name;
vm_cache_monitor.LogicalType = ObjectType.MonitorPoint;
vm_cache_monitor.LogicalID = x.ID;
vm_cache_monitor.LogicalModel = x;
vm_cache_monitor.Children = null;
return vm_cache_monitor;
}).ToList();
#endregion
#region 生成树
var vm_cache_list = new List();
//遍历测点
if (vm_cache_monitor_list != null && vm_cache_monitor_list.Count > 0)
{
foreach (var vm_cache_monitor in vm_cache_monitor_list)
{
var vm_cache_monitor_parent = vm_cache_group_list?.Find(t => t.ID == vm_cache_monitor.ParentID);
if (vm_cache_monitor_parent == null)
{
vm_cache_list.Add(vm_cache_monitor);
}
else
{
vm_cache_monitor_parent.Children.Add(vm_cache_monitor);
}
}
}
//遍历测点组
if (vm_cache_group_list != null && vm_cache_group_list.Count > 0)
{
foreach (var vm_cache_group in vm_cache_group_list)
{
var vm_cahce_group_parent = vm_cache_group_list.Find(t => t.ID == vm_cache_group.ParentID);
if (vm_cahce_group_parent == null)
{
vm_cache_list.Add(vm_cache_group);
}
else
{
vm_cahce_group_parent.Children.Add(vm_cache_group);
}
}
}
return vm_cache_list;
#endregion
}, CacheHelper.CacheLevel2);
return vm_list;
}
#endregion
#region BelongType 和 BelongID 获取常规实时测点逻辑树
///
/// 通过 BelongType 和 BelongID 获取常规实时测点逻辑树
///
[Route("GetGeneralRealLogicalTreeByBelongTypeAndBelongID@V1.0")]
[HttpGet]
public List GetGeneralRealLogicalTreeByBelongTypeAndBelongID_V1_0([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetGeneralRealLogicalTreeByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
#region 监测点组
var group_list = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_group_list = group_list?.Select(x => new MonitorPointGroupLogicDto(x)).ToList();
var vm_cache_group_list = vm_group_list?.Select(x =>
{
var vm_cache_group = new LogicalTreeItemDto();
vm_cache_group.ID = $"{ObjectType.MonitorPointGroup}_{x.ID}";
vm_cache_group.ParentID = $"{ObjectType.MonitorPointGroup}_{x.ParentID}";
vm_cache_group.LogicalName = x.Name;
vm_cache_group.LogicalType = ObjectType.MonitorPointGroup;
vm_cache_group.LogicalID = x.ID;
vm_cache_group.LogicalModel = x;
vm_cache_group.Children = new List();
return vm_cache_group;
}).ToList();
#endregion
#region 监测点
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID
(corpId, belongType, belongId, Model.eMonitorType.General, Model.Monitor.eCronType.Real);
var vm_monitor_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable)?.Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
var vm_cache_monitor_list = vm_monitor_list?.Select(x =>
{
var vm_cache_monitor = new LogicalTreeItemDto();
vm_cache_monitor.ID = $"{ObjectType.MonitorPoint}_{x.ID}";
vm_cache_monitor.ParentID = $"{ObjectType.MonitorPointGroup}_{x.GroupID}";
vm_cache_monitor.LogicalName = x.Name;
vm_cache_monitor.LogicalType = ObjectType.MonitorPoint;
vm_cache_monitor.LogicalID = x.ID;
vm_cache_monitor.LogicalModel = x;
vm_cache_monitor.Children = null;
return vm_cache_monitor;
}).ToList();
#endregion
#region 生成树
var vm_cache_list = new List();
//遍历测点
if (vm_cache_monitor_list != null && vm_cache_monitor_list.Count > 0)
{
foreach (var vm_cache_monitor in vm_cache_monitor_list)
{
var vm_cache_monitor_parent = vm_cache_group_list?.Find(t => t.ID == vm_cache_monitor.ParentID);
if (vm_cache_monitor_parent == null)
{
vm_cache_list.Add(vm_cache_monitor);
}
else
{
vm_cache_monitor_parent.Children.Add(vm_cache_monitor);
}
}
}
//遍历测点组
if (vm_cache_group_list != null && vm_cache_group_list.Count > 0)
{
foreach (var vm_cache_group in vm_cache_group_list)
{
var vm_cahce_group_parent = vm_cache_group_list.Find(t => t.ID == vm_cache_group.ParentID);
if (vm_cahce_group_parent == null)
{
vm_cache_list.Add(vm_cache_group);
}
else
{
vm_cahce_group_parent.Children.Add(vm_cache_group);
}
}
}
return vm_cache_list;
#endregion
}, CacheHelper.CacheLevel2);
return vm_list;
}
///
/// 通过 BelongType 和 BelongID 获取常规实时测点逻辑树(不需要验证Token)
///
[AllowAnonymous]
[Route("GetGeneralRealLogicalTreeByBelongTypeAndBelongID@V1.1")]
[HttpGet]
public List GetGeneralRealLogicalTreeByBelongTypeAndBelongID_V1_1([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetGeneralRealLogicalTreeByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
#region 监测点组
var group_list = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_group_list = group_list?.Select(x => new MonitorPointGroupLogicDto(x)).ToList();
var vm_cache_group_list = vm_group_list?.Select(x =>
{
var vm_cache_group = new LogicalTreeItemDto();
vm_cache_group.ID = $"{ObjectType.MonitorPointGroup}_{x.ID}";
vm_cache_group.ParentID = $"{ObjectType.MonitorPointGroup}_{x.ParentID}";
vm_cache_group.LogicalName = x.Name;
vm_cache_group.LogicalType = ObjectType.MonitorPointGroup;
vm_cache_group.LogicalID = x.ID;
vm_cache_group.LogicalModel = x;
vm_cache_group.Children = new List();
return vm_cache_group;
}).ToList();
#endregion
#region 监测点
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID
(corpId, belongType, belongId, Model.eMonitorType.General, Model.Monitor.eCronType.Real);
var vm_monitor_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable)?.Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
var vm_cache_monitor_list = vm_monitor_list?.Select(x =>
{
var vm_cache_monitor = new LogicalTreeItemDto();
vm_cache_monitor.ID = $"{ObjectType.MonitorPoint}_{x.ID}";
vm_cache_monitor.ParentID = $"{ObjectType.MonitorPointGroup}_{x.GroupID}";
vm_cache_monitor.LogicalName = x.Name;
vm_cache_monitor.LogicalType = ObjectType.MonitorPoint;
vm_cache_monitor.LogicalID = x.ID;
vm_cache_monitor.LogicalModel = x;
vm_cache_monitor.Children = null;
return vm_cache_monitor;
}).ToList();
#endregion
#region 生成树
var vm_cache_list = new List();
//遍历测点
if (vm_cache_monitor_list != null && vm_cache_monitor_list.Count > 0)
{
foreach (var vm_cache_monitor in vm_cache_monitor_list)
{
var vm_cache_monitor_parent = vm_cache_group_list?.Find(t => t.ID == vm_cache_monitor.ParentID);
if (vm_cache_monitor_parent == null)
{
vm_cache_list.Add(vm_cache_monitor);
}
else
{
vm_cache_monitor_parent.Children.Add(vm_cache_monitor);
}
}
}
//遍历测点组
if (vm_cache_group_list != null && vm_cache_group_list.Count > 0)
{
foreach (var vm_cache_group in vm_cache_group_list)
{
var vm_cahce_group_parent = vm_cache_group_list.Find(t => t.ID == vm_cache_group.ParentID);
if (vm_cahce_group_parent == null)
{
vm_cache_list.Add(vm_cache_group);
}
else
{
vm_cahce_group_parent.Children.Add(vm_cache_group);
}
}
}
return vm_cache_list;
#endregion
}, CacheHelper.CacheLevel2);
return vm_list;
}
#endregion
#region 通过 BelongType 和 BelongID 获取振动实时测点逻辑树
///
/// 通过 BelongType 和 BelongID 获取振动实时测点逻辑树
///
[Route("GetVibrationRealLogicalTreeByBelongTypeAndBelongID@V1.0")]
[HttpGet]
public List GetVibrationRealLogicalTreeByBelongTypeAndBelongID_V1_0([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetVibrationRealLogicalTreeByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
#region 监测点组
var group_list = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_group_list = group_list?.Select(x => new MonitorPointGroupLogicDto(x)).ToList();
var vm_cache_group_list = vm_group_list?.Select(x =>
{
var vm_cache_group = new LogicalTreeItemDto();
vm_cache_group.ID = $"{ObjectType.MonitorPointGroup}_{x.ID}";
vm_cache_group.ParentID = $"{ObjectType.MonitorPointGroup}_{x.ParentID}";
vm_cache_group.LogicalName = x.Name;
vm_cache_group.LogicalType = ObjectType.MonitorPointGroup;
vm_cache_group.LogicalID = x.ID;
vm_cache_group.LogicalModel = x;
vm_cache_group.Children = new List();
return vm_cache_group;
}).ToList();
#endregion
#region 监测点
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID
(corpId, belongType, belongId, Model.eMonitorType.Vibration, Model.Monitor.eCronType.Real);
var vm_monitor_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable)?.Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
var vm_cache_monitor_list = vm_monitor_list?.Select(x =>
{
var vm_cache_monitor = new LogicalTreeItemDto();
vm_cache_monitor.ID = $"{ObjectType.MonitorPoint}_{x.ID}";
vm_cache_monitor.ParentID = $"{ObjectType.MonitorPointGroup}_{x.GroupID}";
vm_cache_monitor.LogicalName = x.Name;
vm_cache_monitor.LogicalType = ObjectType.MonitorPoint;
vm_cache_monitor.LogicalID = x.ID;
vm_cache_monitor.LogicalModel = x;
vm_cache_monitor.Children = null;
return vm_cache_monitor;
}).ToList();
#endregion
#region 生成树
var vm_cache_list = new List();
//遍历测点
if (vm_cache_monitor_list != null && vm_cache_monitor_list.Count > 0)
{
foreach (var vm_cache_monitor in vm_cache_monitor_list)
{
var vm_cache_monitor_parent = vm_cache_group_list?.Find(t => t.ID == vm_cache_monitor.ParentID);
if (vm_cache_monitor_parent == null)
{
vm_cache_list.Add(vm_cache_monitor);
}
else
{
vm_cache_monitor_parent.Children.Add(vm_cache_monitor);
}
}
}
//遍历测点组
if (vm_cache_group_list != null && vm_cache_group_list.Count > 0)
{
foreach (var vm_cache_group in vm_cache_group_list)
{
var vm_cahce_group_parent = vm_cache_group_list.Find(t => t.ID == vm_cache_group.ParentID);
if (vm_cahce_group_parent == null)
{
vm_cache_list.Add(vm_cache_group);
}
else
{
vm_cahce_group_parent.Children.Add(vm_cache_group);
}
}
}
return vm_cache_list;
#endregion
}, CacheHelper.CacheLevel2);
return vm_list;
}
///
/// 通过 BelongType 和 BelongID 获取振动实时测点逻辑树(不需要验证Token)
///
[AllowAnonymous]
[Route("GetVibrationRealLogicalTreeByBelongTypeAndBelongID@V1.1")]
[HttpGet]
public List GetVibrationRealLogicalTreeByBelongTypeAndBelongID_V1_1([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetVibrationRealLogicalTreeByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
#region 监测点组
var group_list = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_group_list = group_list?.Select(x => new MonitorPointGroupLogicDto(x)).ToList();
var vm_cache_group_list = vm_group_list?.Select(x =>
{
var vm_cache_group = new LogicalTreeItemDto();
vm_cache_group.ID = $"{ObjectType.MonitorPointGroup}_{x.ID}";
vm_cache_group.ParentID = $"{ObjectType.MonitorPointGroup}_{x.ParentID}";
vm_cache_group.LogicalName = x.Name;
vm_cache_group.LogicalType = ObjectType.MonitorPointGroup;
vm_cache_group.LogicalID = x.ID;
vm_cache_group.LogicalModel = x;
vm_cache_group.Children = new List();
return vm_cache_group;
}).ToList();
#endregion
#region 监测点
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID
(corpId, belongType, belongId, Model.eMonitorType.Vibration, Model.Monitor.eCronType.Real);
var vm_monitor_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable)?.Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
var vm_cache_monitor_list = vm_monitor_list?.Select(x =>
{
var vm_cache_monitor = new LogicalTreeItemDto();
vm_cache_monitor.ID = $"{ObjectType.MonitorPoint}_{x.ID}";
vm_cache_monitor.ParentID = $"{ObjectType.MonitorPointGroup}_{x.GroupID}";
vm_cache_monitor.LogicalName = x.Name;
vm_cache_monitor.LogicalType = ObjectType.MonitorPoint;
vm_cache_monitor.LogicalID = x.ID;
vm_cache_monitor.LogicalModel = x;
vm_cache_monitor.Children = null;
return vm_cache_monitor;
}).ToList();
#endregion
#region 生成树
var vm_cache_list = new List();
//遍历测点
if (vm_cache_monitor_list != null && vm_cache_monitor_list.Count > 0)
{
foreach (var vm_cache_monitor in vm_cache_monitor_list)
{
var vm_cache_monitor_parent = vm_cache_group_list?.Find(t => t.ID == vm_cache_monitor.ParentID);
if (vm_cache_monitor_parent == null)
{
vm_cache_list.Add(vm_cache_monitor);
}
else
{
vm_cache_monitor_parent.Children.Add(vm_cache_monitor);
}
}
}
//遍历测点组
if (vm_cache_group_list != null && vm_cache_group_list.Count > 0)
{
foreach (var vm_cache_group in vm_cache_group_list)
{
var vm_cahce_group_parent = vm_cache_group_list.Find(t => t.ID == vm_cache_group.ParentID);
if (vm_cahce_group_parent == null)
{
vm_cache_list.Add(vm_cache_group);
}
else
{
vm_cahce_group_parent.Children.Add(vm_cache_group);
}
}
}
return vm_cache_list;
#endregion
}, CacheHelper.CacheLevel2);
return vm_list;
}
#endregion
#region 通过 BelongType 和 BelongID 获取录入测点逻辑树
///
/// 通过 BelongType 和 BelongID 获取录入测点逻辑树
///
[Route("GetInputLogicalTreeByBelongTypeAndBelongID@V1.0")]
[HttpGet]
public List GetInputLogicalTreeByBelongTypeAndBelongID_V1_0([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetInputLogicalTreeByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
#region 监测点组
var group_list = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_group_list = group_list?.Select(x => new MonitorPointGroupLogicDto(x)).ToList();
var vm_cache_group_list = vm_group_list?.Select(x =>
{
var vm_cache_group = new LogicalTreeItemDto();
vm_cache_group.ID = $"{ObjectType.MonitorPointGroup}_{x.ID}";
vm_cache_group.ParentID = $"{ObjectType.MonitorPointGroup}_{x.ParentID}";
vm_cache_group.LogicalName = x.Name;
vm_cache_group.LogicalType = ObjectType.MonitorPointGroup;
vm_cache_group.LogicalID = x.ID;
vm_cache_group.LogicalModel = x;
vm_cache_group.Children = new List();
return vm_cache_group;
}).ToList();
#endregion
#region 监测点
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId);
monitor_list = monitor_list?.Where(x => x.SourceType == Model.Monitor.eSourceType.Input).ToList();
var vm_monitor_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable)?.Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
var vm_cache_monitor_list = vm_monitor_list?.Select(x =>
{
var vm_cache_monitor = new LogicalTreeItemDto();
vm_cache_monitor.ID = $"{ObjectType.MonitorPoint}_{x.ID}";
vm_cache_monitor.ParentID = $"{ObjectType.MonitorPointGroup}_{x.GroupID}";
vm_cache_monitor.LogicalName = x.Name;
vm_cache_monitor.LogicalType = ObjectType.MonitorPoint;
vm_cache_monitor.LogicalID = x.ID;
vm_cache_monitor.LogicalModel = x;
vm_cache_monitor.Children = null;
return vm_cache_monitor;
}).ToList();
#endregion
#region 生成树
var vm_cache_list = new List();
//遍历测点
if (vm_cache_monitor_list != null && vm_cache_monitor_list.Count > 0)
{
foreach (var vm_cache_monitor in vm_cache_monitor_list)
{
var vm_cache_monitor_parent = vm_cache_group_list?.Find(t => t.ID == vm_cache_monitor.ParentID);
if (vm_cache_monitor_parent == null)
{
vm_cache_list.Add(vm_cache_monitor);
}
else
{
vm_cache_monitor_parent.Children.Add(vm_cache_monitor);
}
}
}
//遍历测点组
if (vm_cache_group_list != null && vm_cache_group_list.Count > 0)
{
foreach (var vm_cache_group in vm_cache_group_list)
{
var vm_cahce_group_parent = vm_cache_group_list.Find(t => t.ID == vm_cache_group.ParentID);
if (vm_cahce_group_parent == null)
{
vm_cache_list.Add(vm_cache_group);
}
else
{
vm_cahce_group_parent.Children.Add(vm_cache_group);
}
}
}
return vm_cache_list;
#endregion
}, CacheHelper.CacheLevel2);
return vm_list;
}
///
/// 通过 BelongType 和 BelongID 获取录入测点逻辑树(不需要验证Token)
///
[AllowAnonymous]
[Route("GetInputLogicalTreeByBelongTypeAndBelongID@V1.1")]
[HttpGet]
public List GetInputLogicalTreeByBelongTypeAndBelongID_V1_1([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetInputLogicalTreeByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
#region 监测点组
var group_list = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_group_list = group_list?.Select(x => new MonitorPointGroupLogicDto(x)).ToList();
var vm_cache_group_list = vm_group_list?.Select(x =>
{
var vm_cache_group = new LogicalTreeItemDto();
vm_cache_group.ID = $"{ObjectType.MonitorPointGroup}_{x.ID}";
vm_cache_group.ParentID = $"{ObjectType.MonitorPointGroup}_{x.ParentID}";
vm_cache_group.LogicalName = x.Name;
vm_cache_group.LogicalType = ObjectType.MonitorPointGroup;
vm_cache_group.LogicalID = x.ID;
vm_cache_group.LogicalModel = x;
vm_cache_group.Children = new List();
return vm_cache_group;
}).ToList();
#endregion
#region 监测点
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId);
monitor_list = monitor_list?.Where(x => x.SourceType == Model.Monitor.eSourceType.Input).ToList();
var vm_monitor_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable)?.Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
var vm_cache_monitor_list = vm_monitor_list?.Select(x =>
{
var vm_cache_monitor = new LogicalTreeItemDto();
vm_cache_monitor.ID = $"{ObjectType.MonitorPoint}_{x.ID}";
vm_cache_monitor.ParentID = $"{ObjectType.MonitorPointGroup}_{x.GroupID}";
vm_cache_monitor.LogicalName = x.Name;
vm_cache_monitor.LogicalType = ObjectType.MonitorPoint;
vm_cache_monitor.LogicalID = x.ID;
vm_cache_monitor.LogicalModel = x;
vm_cache_monitor.Children = null;
return vm_cache_monitor;
}).ToList();
#endregion
#region 生成树
var vm_cache_list = new List();
//遍历测点
if (vm_cache_monitor_list != null && vm_cache_monitor_list.Count > 0)
{
foreach (var vm_cache_monitor in vm_cache_monitor_list)
{
var vm_cache_monitor_parent = vm_cache_group_list?.Find(t => t.ID == vm_cache_monitor.ParentID);
if (vm_cache_monitor_parent == null)
{
vm_cache_list.Add(vm_cache_monitor);
}
else
{
vm_cache_monitor_parent.Children.Add(vm_cache_monitor);
}
}
}
//遍历测点组
if (vm_cache_group_list != null && vm_cache_group_list.Count > 0)
{
foreach (var vm_cache_group in vm_cache_group_list)
{
var vm_cahce_group_parent = vm_cache_group_list.Find(t => t.ID == vm_cache_group.ParentID);
if (vm_cahce_group_parent == null)
{
vm_cache_list.Add(vm_cache_group);
}
else
{
vm_cahce_group_parent.Children.Add(vm_cache_group);
}
}
}
return vm_cache_list;
#endregion
}, CacheHelper.CacheLevel2);
return vm_list;
}
#endregion
#region 通过 BelongType 和 BelongID 获取常规录入测点逻辑树
///
/// 通过 BelongType 和 BelongID 获取常规录入测点逻辑树
///
[Route("GetGeneralInputLogicalTreeByBelongTypeAndBelongID@V1.0")]
[HttpGet]
public List GetGeneralInputLogicalTreeByBelongTypeAndBelongID_V1_0([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetGeneralInputLogicalTreeByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
#region 监测点组
var group_list = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_group_list = group_list?.Select(x => new MonitorPointGroupLogicDto(x)).ToList();
var vm_cache_group_list = vm_group_list?.Select(x =>
{
var vm_cache_group = new LogicalTreeItemDto();
vm_cache_group.ID = $"{ObjectType.MonitorPointGroup}_{x.ID}";
vm_cache_group.ParentID = $"{ObjectType.MonitorPointGroup}_{x.ParentID}";
vm_cache_group.LogicalName = x.Name;
vm_cache_group.LogicalType = ObjectType.MonitorPointGroup;
vm_cache_group.LogicalID = x.ID;
vm_cache_group.LogicalModel = x;
vm_cache_group.Children = new List();
return vm_cache_group;
}).ToList();
#endregion
#region 监测点
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId);
monitor_list = monitor_list?.Where(x => x.MonitorType == Model.eMonitorType.General && x.SourceType == Model.Monitor.eSourceType.Input).ToList();
var vm_monitor_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable)?.Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
var vm_cache_monitor_list = vm_monitor_list?.Select(x =>
{
var vm_cache_monitor = new LogicalTreeItemDto();
vm_cache_monitor.ID = $"{ObjectType.MonitorPoint}_{x.ID}";
vm_cache_monitor.ParentID = $"{ObjectType.MonitorPointGroup}_{x.GroupID}";
vm_cache_monitor.LogicalName = x.Name;
vm_cache_monitor.LogicalType = ObjectType.MonitorPoint;
vm_cache_monitor.LogicalID = x.ID;
vm_cache_monitor.LogicalModel = x;
vm_cache_monitor.Children = null;
return vm_cache_monitor;
}).ToList();
#endregion
#region 生成树
var vm_cache_list = new List();
//遍历测点
if (vm_cache_monitor_list != null && vm_cache_monitor_list.Count > 0)
{
foreach (var vm_cache_monitor in vm_cache_monitor_list)
{
var vm_cache_monitor_parent = vm_cache_group_list?.Find(t => t.ID == vm_cache_monitor.ParentID);
if (vm_cache_monitor_parent == null)
{
vm_cache_list.Add(vm_cache_monitor);
}
else
{
vm_cache_monitor_parent.Children.Add(vm_cache_monitor);
}
}
}
//遍历测点组
if (vm_cache_group_list != null && vm_cache_group_list.Count > 0)
{
foreach (var vm_cache_group in vm_cache_group_list)
{
var vm_cahce_group_parent = vm_cache_group_list.Find(t => t.ID == vm_cache_group.ParentID);
if (vm_cahce_group_parent == null)
{
vm_cache_list.Add(vm_cache_group);
}
else
{
vm_cahce_group_parent.Children.Add(vm_cache_group);
}
}
}
return vm_cache_list;
#endregion
}, CacheHelper.CacheLevel2);
return vm_list;
}
///
/// 通过 BelongType 和 BelongID 获取常规录入测点逻辑树(不需要验证Token)
///
[AllowAnonymous]
[Route("GetGeneralInputLogicalTreeByBelongTypeAndBelongID@V1.1")]
[HttpGet]
public List GetGeneralInputLogicalTreeByBelongTypeAndBelongID_V1_1([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetGeneralInputLogicalTreeByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
#region 监测点组
var group_list = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
var vm_group_list = group_list?.Select(x => new MonitorPointGroupLogicDto(x)).ToList();
var vm_cache_group_list = vm_group_list?.Select(x =>
{
var vm_cache_group = new LogicalTreeItemDto();
vm_cache_group.ID = $"{ObjectType.MonitorPointGroup}_{x.ID}";
vm_cache_group.ParentID = $"{ObjectType.MonitorPointGroup}_{x.ParentID}";
vm_cache_group.LogicalName = x.Name;
vm_cache_group.LogicalType = ObjectType.MonitorPointGroup;
vm_cache_group.LogicalID = x.ID;
vm_cache_group.LogicalModel = x;
vm_cache_group.Children = new List();
return vm_cache_group;
}).ToList();
#endregion
#region 监测点
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId);
monitor_list = monitor_list?.Where(x => x.MonitorType == Model.eMonitorType.General && x.SourceType == Model.Monitor.eSourceType.Input).ToList();
var vm_monitor_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable)?.Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
var vm_cache_monitor_list = vm_monitor_list?.Select(x =>
{
var vm_cache_monitor = new LogicalTreeItemDto();
vm_cache_monitor.ID = $"{ObjectType.MonitorPoint}_{x.ID}";
vm_cache_monitor.ParentID = $"{ObjectType.MonitorPointGroup}_{x.GroupID}";
vm_cache_monitor.LogicalName = x.Name;
vm_cache_monitor.LogicalType = ObjectType.MonitorPoint;
vm_cache_monitor.LogicalID = x.ID;
vm_cache_monitor.LogicalModel = x;
vm_cache_monitor.Children = null;
return vm_cache_monitor;
}).ToList();
#endregion
#region 生成树
var vm_cache_list = new List();
//遍历测点
if (vm_cache_monitor_list != null && vm_cache_monitor_list.Count > 0)
{
foreach (var vm_cache_monitor in vm_cache_monitor_list)
{
var vm_cache_monitor_parent = vm_cache_group_list?.Find(t => t.ID == vm_cache_monitor.ParentID);
if (vm_cache_monitor_parent == null)
{
vm_cache_list.Add(vm_cache_monitor);
}
else
{
vm_cache_monitor_parent.Children.Add(vm_cache_monitor);
}
}
}
//遍历测点组
if (vm_cache_group_list != null && vm_cache_group_list.Count > 0)
{
foreach (var vm_cache_group in vm_cache_group_list)
{
var vm_cahce_group_parent = vm_cache_group_list.Find(t => t.ID == vm_cache_group.ParentID);
if (vm_cahce_group_parent == null)
{
vm_cache_list.Add(vm_cache_group);
}
else
{
vm_cahce_group_parent.Children.Add(vm_cache_group);
}
}
}
return vm_cache_list;
#endregion
}, CacheHelper.CacheLevel2);
return vm_list;
}
#endregion
#endregion
#region Kpi
#region 通过 StationID 获取KPI
///
/// 通过 StationID 获取KPI
///
/// 客户标识
/// 泵站标识
/// KPI数量
[Route("GetKpiByStationID@V1.0")]
[HttpGet]
public List GetKpiByStationID_V1_0
(
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
long CorpID,
[Required, Range(1, long.MaxValue, ErrorMessage = "StationID 必须大于0")]
long StationID,
int Count = 2
)
{
var cacheKey = $"Monitor_MonitorPoint_Logic_GetKpiByStationID_{CorpID}_{StationID}_{Count}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
//最后kpi记录列表
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID
(CorpID, ObjectType.Station, StationID, Model.eMonitorType.General, Model.Monitor.eCronType.Real);
var monitor_kpi_list = monitor_list?.Where(x =>x.UseStatus== Model.eUseStatus.Enable&& x.Flags != null && x.Flags.Contains(LogicFlags.KPI))
.OrderBy(x => x.ImportanceIndex == null ? int.MaxValue : x.ImportanceIndex.Value).ToList();
var vmCacheList = new List();
if (monitor_kpi_list != null)
{
var take_count = monitor_kpi_list.Count > Count ? Count : monitor_kpi_list.Count;
monitor_kpi_list = monitor_kpi_list.Take(take_count).ToList();
foreach (var monitor_kpi in monitor_kpi_list)
{
var vm = new MonitorPointExSignalListLogicDto(monitor_kpi);
vmCacheList.Add(vm);
}
}
return vmCacheList;
}, CacheHelper.CacheLevel4);
return vm_list;
}
///
/// 通过 StationID 获取KPI(不需要验证Token)
///
/// 客户标识
/// 泵站标识
/// KPI数量
[AllowAnonymous]
[Route("GetKpiByStationID@V1.1")]
[HttpGet]
public List GetKpiByStationID_V1_1
(
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
long CorpID,
[Required, Range(1, long.MaxValue, ErrorMessage = "StationID 必须大于0")]
long StationID,
int Count = 2
)
{
var cacheKey = $"Monitor_MonitorPoint_Logic_GetKpiByStationID_{CorpID}_{StationID}_{Count}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
//最后kpi记录列表
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID
(CorpID, ObjectType.Station, StationID, Model.eMonitorType.General, Model.Monitor.eCronType.Real);
var monitor_kpi_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable && x.Flags != null && x.Flags.Contains(LogicFlags.KPI))
.OrderBy(x => x.ImportanceIndex == null ? int.MaxValue : x.ImportanceIndex.Value).ToList();
var vmCacheList = new List();
if (monitor_kpi_list != null)
{
var take_count = monitor_kpi_list.Count > Count ? Count : monitor_kpi_list.Count;
monitor_kpi_list = monitor_kpi_list.Take(take_count).ToList();
foreach (var monitor_kpi in monitor_kpi_list)
{
var vm = new MonitorPointExSignalListLogicDto(monitor_kpi);
vmCacheList.Add(vm);
}
}
return vmCacheList;
}, CacheHelper.CacheLevel4);
return vm_list;
}
#endregion
#region 通过 StationIds 获取KPI
///
/// 通过 StationIds 获取KPI
///
/// 客户标识
/// 泵站标识 , 分隔
/// KPI数量
[Route("GetKpiByStationIds@V1.0")]
[HttpGet]
public List GetKpiByStationIds_V1_0
(
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
long CorpID,
[Required, DataValidation(AllowEmptyStrings =false)]
string StationIds,
int Count = 2
)
{
var stationIds = LongListHelper.ToList(StationIds);
if (stationIds == null || stationIds.Count < 1)
{
throw new Exception("StationIds 参数错误");
}
var cacheKey = $"Monitor_MonitorPoint_Logic_GetKpiByStationID_{CorpID}_{StationIds}_{Count}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
var vmCacheList = new List();
foreach (var stationId in stationIds)
{
//最后kpi记录列表
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID
(CorpID, ObjectType.Station, stationId, Model.eMonitorType.General, Model.Monitor.eCronType.Real);
var monitor_kpi_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable && x.Flags != null && x.Flags.Contains(LogicFlags.KPI))
.OrderBy(x => x.ImportanceIndex == null ? int.MaxValue : x.ImportanceIndex.Value).ToList();
if (monitor_kpi_list != null)
{
var take_count = monitor_kpi_list.Count > Count ? Count : monitor_kpi_list.Count;
monitor_kpi_list = monitor_kpi_list.Take(take_count).ToList();
foreach (var monitor_kpi in monitor_kpi_list)
{
var vm = new MonitorPointExSignalListLogicDto(monitor_kpi);
vmCacheList.Add(vm);
}
}
}
return vmCacheList;
}, CacheHelper.CacheLevel3);
return vm_list;
}
///
/// 通过 StationIds 获取KPI(不需要验证Token)
///
/// 客户标识
/// 泵站标识 , 分隔
/// KPI数量
[AllowAnonymous]
[Route("GetKpiByStationIds@V1.1")]
[HttpGet]
public List GetKpiByStationIds_V1_1
(
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
long CorpID,
[Required, DataValidation(AllowEmptyStrings =false)]
string StationIds,
int Count = 2
)
{
var stationIds = LongListHelper.ToList(StationIds);
if (stationIds == null || stationIds.Count < 1)
{
throw new Exception("StationIds 参数错误");
}
var cacheKey = $"Monitor_MonitorPoint_Logic_GetKpiByStationID_{CorpID}_{StationIds}_{Count}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
var vmCacheList = new List();
foreach (var stationId in stationIds)
{
//最后kpi记录列表
var monitor_list = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID
(CorpID, ObjectType.Station, stationId, Model.eMonitorType.General, Model.Monitor.eCronType.Real);
var monitor_kpi_list = monitor_list?.Where(x => x.UseStatus == Model.eUseStatus.Enable && x.Flags != null && x.Flags.Contains(LogicFlags.KPI))
.OrderBy(x => x.ImportanceIndex == null ? int.MaxValue : x.ImportanceIndex.Value).ToList();
if (monitor_kpi_list != null)
{
var take_count = monitor_kpi_list.Count > Count ? Count : monitor_kpi_list.Count;
monitor_kpi_list = monitor_kpi_list.Take(take_count).ToList();
foreach (var monitor_kpi in monitor_kpi_list)
{
var vm = new MonitorPointExSignalListLogicDto(monitor_kpi);
vmCacheList.Add(vm);
}
}
}
return vmCacheList;
}, CacheHelper.CacheLevel3);
return vm_list;
}
#endregion
#endregion
#region 列表
#region 通过 BelongType 和 BelongID 获取列表
///
/// 通过 BelongType 和 BelongID 获取列表
///
[Route("GetListByBelongTypeAndBelongID@V1.0")]
[HttpGet]
public List GetListByBelongTypeAndBelongID_V1_0([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetListByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId);
var vmCacheList = monitorList?.Where(x=>x.UseStatus== Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}, CacheHelper.CacheLevel3);
return vm_list;
}
///
/// 通过 BelongType 和 BelongID 获取列表(不需要验证Token)
///
[AllowAnonymous]
[Route("GetListByBelongTypeAndBelongID@V1.1")]
[HttpGet]
public List GetListByBelongTypeAndBelongID_V1_1([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetListByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId);
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}, CacheHelper.CacheLevel3);
return vm_list;
}
#endregion
#region 通过 BelongType 和 BelongID 获取常规实时列表
///
/// 通过 BelongType 和 BelongID 获取常规实时列表
///
[Route("GetGeneralRealListByBelongTypeAndBelongID@V1.0")]
[HttpGet]
public List GetGeneralRealListByBelongTypeAndBelongID_V1_0([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetGeneralRealListByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID
(corpId, belongType, belongId, Model.eMonitorType.General, Model.Monitor.eCronType.Real);
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}, CacheHelper.CacheLevel3);
return vm_list;
}
///
/// 通过 BelongType 和 BelongID 获取常规实时列表(不需要验证Token)
///
[AllowAnonymous]
[Route("GetGeneralRealListByBelongTypeAndBelongID@V1.1")]
[HttpGet]
public List GetGeneralRealListByBelongTypeAndBelongID_V1_1([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetGeneralRealListByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID
(corpId, belongType, belongId, Model.eMonitorType.General, Model.Monitor.eCronType.Real);
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}, CacheHelper.CacheLevel3);
return vm_list;
}
#endregion
#region 通过 BelongType 和 BelongID 获取Master(总站)列表
///
/// 通过 BelongType 和 BelongID 获取Master(总站)列表
///
[Route("GetMasterListByBelongTypeAndBelongID@V1.0")]
[HttpGet]
public List GetMasterListByBelongTypeAndBelongID_V1_0([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetMasterListByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
var allGroupList = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
if (allGroupList == null || allGroupList.Count < 1)
{
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId);
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}
else
{
var groupList = allGroupList.Where(x => x.Flags != null && x.Flags.Contains(LogicFlags.总站)).ToList();
if (groupList == null || groupList.Count < 1)
{
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId);
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}
else
{
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByGroupIds(corpId, groupList.Select(x => x.ID));
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}
}
}, CacheHelper.CacheLevel3);
return vm_list;
}
///
/// 通过 BelongType 和 BelongID 获取Master(总站)列表(不需要验证Token)
///
[AllowAnonymous]
[Route("GetMasterListByBelongTypeAndBelongID@V1.1")]
[HttpGet]
public List GetMasterListByBelongTypeAndBelongID_V1_1([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetMasterListByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
var allGroupList = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
if (allGroupList == null || allGroupList.Count < 1)
{
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId);
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}
else
{
var groupList = allGroupList.Where(x => x.Flags != null && x.Flags.Contains(LogicFlags.总站)).ToList();
if (groupList == null || groupList.Count < 1)
{
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId);
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}
else
{
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByGroupIds(corpId, groupList.Select(x => x.ID));
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}
}
}, CacheHelper.CacheLevel3);
return vm_list;
}
#endregion
#region 通过 BelongType 和 BelongID 获取Master(总站)常规实时列表
///
/// 通过 BelongType 和 BelongID 获取Master(总站)常规实时列表
///
[Route("GetMasterGeneralRealListByBelongTypeAndBelongID@V1.0")]
[HttpGet]
public List GetMasterGeneralRealListByBelongTypeAndBelongID_V1_0([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetMasterGeneralRealListByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
var allGroupList = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
if (allGroupList == null || allGroupList.Count < 1)
{
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId);
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}
else
{
var groupList = allGroupList.Where(x => x.Flags != null && x.Flags.Contains(LogicFlags.总站)).ToList();
if (groupList == null || groupList.Count < 1)
{
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId);
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}
else
{
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByGroupIds(corpId, groupList.Select(x => x.ID), Model.eMonitorType.General, Model.Monitor.eCronType.Real);
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}
}
}, CacheHelper.CacheLevel3);
return vm_list;
}
///
/// 通过 BelongType 和 BelongID 获取Master(总站)常规实时列表(不需要验证Token)
///
[AllowAnonymous]
[Route("GetMasterGeneralRealListByBelongTypeAndBelongID@V1.1")]
[HttpGet]
public List GetMasterGeneralRealListByBelongTypeAndBelongID_V1_1([FromQuery][Required] BelongUnderCorpInput input)
{
var corpId = input.CorpID;
var belongType = input.BelongType;
var belongId = input.BelongID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetMasterGeneralRealListByBelongTypeAndBelongID_{corpId}_{belongType}_{belongId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
var allGroupList = new Service.MonitorPointGroup().GetByBelongTypeAndBelongID(corpId, belongType, belongId);
if (allGroupList == null || allGroupList.Count < 1)
{
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId);
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}
else
{
var groupList = allGroupList.Where(x => x.Flags != null && x.Flags.Contains(LogicFlags.总站)).ToList();
if (groupList == null || groupList.Count < 1)
{
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, belongType, belongId);
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}
else
{
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByGroupIds(corpId, groupList.Select(x => x.ID), Model.eMonitorType.General, Model.Monitor.eCronType.Real);
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}
}
}, CacheHelper.CacheLevel3);
return vm_list;
}
#endregion
#endregion
#region 通过设备获取列表
#region 通过 ProductID 获取列表
///
/// 通过 ProductID 获取列表
///
[Route("GetListByProductID@V1.0")]
[HttpGet]
public List GetListByProductID_V1_0([FromQuery][Required] ProductIDUnderCorpInput input)
{
var corpId = input.CorpID;
var productId = input.ProductID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetListByProductID_{corpId}_{productId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
var monitorMappingList = new Service.MonitorPointMapping().GetByObjectTypeAndObjectID(corpId, ObjectType.Product, productId);
if (monitorMappingList == null || monitorMappingList.Count < 1)
return default;
var monitorIds = monitorMappingList.Select(x => x.MonitorPointID).Distinct().ToList();
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByIds(corpId, monitorIds);
var vmCacheList = monitorList?.Where(x=>x.UseStatus== Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}, CacheHelper.CacheLevel3);
return vm_list;
}
///
/// 通过 ProductID 获取列表(不需要验证Token)
///
[AllowAnonymous]
[Route("GetListByProductID@V1.1")]
[HttpGet]
public List GetListByProductID_V1_1([FromQuery][Required] ProductIDUnderCorpInput input)
{
var corpId = input.CorpID;
var productId = input.ProductID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetListByProductID_{corpId}_{productId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
var monitorMappingList = new Service.MonitorPointMapping().GetByObjectTypeAndObjectID(corpId, ObjectType.Product, productId);
if (monitorMappingList == null || monitorMappingList.Count < 1)
return default;
var monitorIds = monitorMappingList.Select(x => x.MonitorPointID).Distinct().ToList();
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByIds(corpId, monitorIds);
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}, CacheHelper.CacheLevel3);
return vm_list;
}
#endregion
#region 通过 ProductID 获取常规实时列表
///
/// 通过 ProductID 获取常规实时列表
///
[Route("GetGeneralRealListByProductID@V1.0")]
[HttpGet]
public List GetGeneralRealListByProductID_V1_0([FromQuery][Required] ProductIDUnderCorpInput input)
{
var corpId = input.CorpID;
var productId = input.ProductID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetGeneralRealListByProductID_{corpId}_{productId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
var monitorMappingList = new Service.MonitorPointMapping().GetByObjectTypeAndObjectID(corpId, ObjectType.Product, productId);
if (monitorMappingList == null || monitorMappingList.Count < 1)
return default;
var monitorIds = monitorMappingList.Select(x => x.MonitorPointID).Distinct().ToList();
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByIds(corpId, monitorIds, Model.eMonitorType.General, Model.Monitor.eCronType.Real);
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}, CacheHelper.CacheLevel3);
return vm_list;
}
///
/// 通过 ProductID 获取常规实时列表(不需要验证Token)
///
[AllowAnonymous]
[Route("GetGeneralRealListByProductID@V1.1")]
[HttpGet]
public List GetGeneralRealListByProductID_V1_1([FromQuery][Required] ProductIDUnderCorpInput input)
{
var corpId = input.CorpID;
var productId = input.ProductID;
var cacheKey = $"Monitor_MonitorPoint_Logic_GetGeneralRealListByProductID_{corpId}_{productId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
var monitorMappingList = new Service.MonitorPointMapping().GetByObjectTypeAndObjectID(corpId, ObjectType.Product, productId);
if (monitorMappingList == null || monitorMappingList.Count < 1)
return default;
var monitorIds = monitorMappingList.Select(x => x.MonitorPointID).Distinct().ToList();
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByIds(corpId, monitorIds, Model.eMonitorType.General, Model.Monitor.eCronType.Real);
var vmCacheList = monitorList?.Where(x => x.UseStatus == Model.eUseStatus.Enable).Select(x => new MonitorPointExSignalListLogicDto(x)).ToList();
return vmCacheList;
}, CacheHelper.CacheLevel3);
return vm_list;
}
#endregion
#endregion
}
}