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.Http;
|
using Furion.DependencyInjection;
|
using Microsoft.AspNetCore.Authorization;
|
using Furion.DataEncryption;
|
using Furion.FriendlyException;
|
|
namespace IStation.Application
|
{
|
/// <summary>
|
/// 监测
|
/// </summary>
|
[AllowAnonymous]
|
[Route("LargeScreen/Szjt/Monitor")]
|
[ApiDescriptionSettings("LargeScreen", Name = "苏州金庭(监测)", Order = 999)]
|
public class SzjtMonitor_Controller : IDynamicApiController, ITransient
|
{
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
/// <summary>
|
///
|
/// </summary>
|
public SzjtMonitor_Controller(IHttpContextAccessor httpContextAccessor)
|
{
|
_httpContextAccessor = httpContextAccessor;
|
}
|
|
private const long _corpId = 3;
|
|
/// <summary>
|
/// 通过 StationID 获取KPI
|
/// </summary>
|
/// <param name="StationID">泵站标识</param>
|
/// <param name="Count">KPI数量</param>
|
[Route("GetMonitorPointKpiListByStationID")]
|
[HttpGet]
|
public List<SzjtMonitorPointExSignalListDto> GetMonitorPointKpiListByStationID
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "StationID 必须大于0")]
|
long StationID,
|
int Count = 2
|
)
|
{
|
var cacheKey = $"LargeScreen_Szjt_Monitor_GetMonitorPointKpiListByStationID_{_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.Flags != null && x.Flags.Contains(LogicFlags.KPI))
|
.OrderBy(x => x.ImportanceIndex == null ? int.MaxValue : x.ImportanceIndex.Value).ToList();
|
|
var vmCacheList = new List<SzjtMonitorPointExSignalListDto>();
|
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 SzjtMonitorPointExSignalListDto(monitor_kpi);
|
vmCacheList.Add(vm);
|
}
|
}
|
return vmCacheList;
|
}, CacheHelper.CacheLevel4);
|
return vm_list;
|
|
}
|
|
|
/// <summary>
|
/// 通过 ProductID 获取常规实时测点列表
|
/// </summary>
|
[Route("GetGeneralRealMonitorPointListByProductID")]
|
[HttpGet]
|
public List<SzjtMonitorPointExSignalListDto> GetGeneralRealMonitorPointListByProductID([FromQuery][Required] ProductIDInput input)
|
{
|
var productId = input.ProductID;
|
var cacheKey = $"LargeScreen_Szjt_Monitor_GetGeneralRealMonitorPointListByProductID_{_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?.Select(x => new SzjtMonitorPointExSignalListDto(x)).ToList();
|
return vmCacheList;
|
|
}, CacheHelper.CacheLevel3);
|
return vm_list;
|
}
|
|
/// <summary>
|
/// 通过 BelongType 和 BelongID 获取常规实时列表
|
/// </summary>
|
[Route("GetGeneralRealMonitorPointListByBelongTypeAndBelongID")]
|
[HttpGet]
|
public List<SzjtMonitorPointExSignalListDto> GetGeneralRealMonitorPointListByBelongTypeAndBelongID([FromQuery][Required] BelongInput input)
|
{
|
var corpId = _corpId;
|
var belongType = input.BelongType;
|
var belongId = input.BelongID;
|
var cacheKey = $"LargeScreen_Szjt_Monitor_GetGeneralRealMonitorPointListByBelongTypeAndBelongID_{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?.Select(x => new SzjtMonitorPointExSignalListDto(x)).ToList();
|
return vmCacheList;
|
|
}, CacheHelper.CacheLevel3);
|
|
return vm_list;
|
}
|
|
|
|
|
}
|
}
|