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 IStation.Calculation;
|
using IStation.Model;
|
|
namespace IStation.Application
|
{
|
/// <summary>
|
/// MonitorRecord
|
/// </summary>
|
[Route("Run/MonitorRecord/Mobile")]
|
[ApiDescriptionSettings("Run", Name = "监测记录(手机)", Order = 999)]
|
public class MonitorRecord_MobileController : IDynamicApiController
|
{
|
/// <summary>
|
/// 通过 MonitorPointID 获取最近一条数据 (已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[Route("GetLastRecordByMonitorPointID@V1.0")]
|
[HttpGet]
|
public List<MonitorBasicRecordSignalContentMobileDto> GetLastRecordByMonitorPointID([FromQuery][Required] MonitorPointIDUnderCorpInput input)
|
{
|
var corpId = input.CorpID;
|
var monitorPointId = input.MonitorPointID;
|
var list = new Service.MonitorRecord().GetLastRecord(corpId, monitorPointId);
|
if (list == null || list.Count < 1)
|
return default;
|
var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(corpId, monitorPointId);
|
var vm_list = list.Select(x => {
|
var signal = monitor.SignalList.Find(t => t.ID == x.SignalID);
|
var vm = new MonitorBasicRecordSignalContentMobileDto(x, signal);
|
return vm;
|
}).ToList();
|
|
return vm_list;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointIds 获取最近一条数据 (已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[Route("GetLastRecordByMonitorPointIds@V1.0")]
|
[HttpGet]
|
public List<MonitorBasicRecordMobileDto> GetLastRecordByMonitorPointIds([FromQuery][Required] MonitorPointIdsUnderCorpInput input)
|
{
|
var corpId = input.CorpID;
|
var monitorPointIds = LongListHelper.ToList(input.MonitorPointIds);
|
var list = new Service.MonitorRecord().GetLastRecord(corpId, monitorPointIds);
|
if (list == null || list.Count < 1)
|
return default;
|
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByIds(corpId, monitorPointIds);
|
var vm_list = list.Select(x => {
|
var monitor = monitorList.Find(t => t.ID == x.MonitorPointID);
|
var signal = monitor.SignalList.Find(t => t.ID == x.SignalID);
|
var vm = new MonitorBasicRecordMobileDto(x, signal);
|
return vm;
|
}).ToList();
|
|
return vm_list;
|
}
|
|
/// <summary>
|
/// 通过 StationID 获取最近一条数据 (已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[Route("GetLastRecordByStationID@V1.0")]
|
[HttpGet]
|
public List<MonitorBasicRecordMobileDto> GetLastRecordByStationID([FromQuery][Required] StationIDUnderCorpInput input)
|
{
|
var corpId = input.CorpID;
|
var stationId = input.StationID;
|
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, ObjectType.Station, stationId);
|
if (monitorList == null || monitorList.Count < 1)
|
return default;
|
var monitorPointIds = monitorList.Select(x => x.ID).Distinct().ToList();
|
var list = new Service.MonitorRecord().GetLastRecord(corpId, monitorPointIds);
|
if (list == null || list.Count < 1)
|
return default;
|
var vm_list = list.Select(x => {
|
var monitor = monitorList.Find(t => t.ID == x.MonitorPointID);
|
var signal = monitor.SignalList.Find(t => t.ID == x.SignalID);
|
var vm = new MonitorBasicRecordMobileDto(x, signal);
|
return vm;
|
}).ToList();
|
|
return vm_list;
|
}
|
|
/// <summary>
|
/// 通过 StationID 获取最近一条数据 (已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[Route("GetGeneralLastRecordByStationID@V1.0")]
|
[HttpGet]
|
public List<MonitorBasicRecordMobileDto> GetGeneralLastRecordByStationID([FromQuery][Required] StationIDUnderCorpInput input)
|
{
|
var corpId = input.CorpID;
|
var stationId = input.StationID;
|
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(corpId, ObjectType.Station, stationId,eMonitorType.General);
|
if (monitorList == null || monitorList.Count < 1)
|
return default;
|
var monitorPointIds = monitorList.Select(x => x.ID).Distinct().ToList();
|
var list = new Service.MonitorRecord().GetLastRecord(corpId, monitorPointIds);
|
if (list == null || list.Count < 1)
|
return default;
|
var vm_list = list.Select(x => {
|
var monitor = monitorList.Find(t => t.ID == x.MonitorPointID);
|
var signal = monitor.SignalList.Find(t => t.ID == x.SignalID);
|
var vm = new MonitorBasicRecordMobileDto(x, signal);
|
return vm;
|
}).ToList();
|
|
return vm_list;
|
}
|
|
}
|
}
|