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;
|
using Microsoft.AspNetCore.Authorization;
|
|
namespace IStation.Application
|
{
|
/// <summary>
|
/// MonitorMonthRecord
|
/// </summary>
|
[Route("Run/MonitorMonthRecord")]
|
[ApiDescriptionSettings("Run", Name = "监测月记录", Order = 950)]
|
public class MonitorMonthRecord_Controller : IDynamicApiController
|
{
|
//服务
|
private readonly Service.MonitorMonthRecord _service = new Service.MonitorMonthRecord();
|
|
#region 获取最近记录
|
|
#region 通过 MonitorPointID 获取
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取最近一条数据(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[Route("GetLastRecordByMonitorPointID@V1.0")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetLastRecordByMonitorPointID_V1_0([FromQuery][Required] MonitorPointIDUnderCorpInput input)
|
{
|
var list = _service.GetLastRecord(input.CorpID, input.MonitorPointID);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取最近一条数据(不需要验证Token)(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetLastRecordByMonitorPointID@V1.1")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetLastRecordByMonitorPointID_V1_1([FromQuery][Required] MonitorPointIDUnderCorpInput input)
|
{
|
var list = _service.GetLastRecord(input.CorpID, input.MonitorPointID);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取最近一条数据(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[Route("GetLastRecordByMonitorPointID@V2.0")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetLastRecordByMonitorPointID_V2_0([FromQuery][Required] MonitorPointIDUnderCorpInput input)
|
{
|
var list = _service.GetLastRecord(input.CorpID, input.MonitorPointID);
|
if (list == null || list.Count < 1)
|
return default;
|
var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(input.CorpID, input.MonitorPointID);
|
var vmList = list.Select(x => new MonitorMonthRecordDto(x, monitor?.SignalList?.Find(t => t.ID == x.SignalID))).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取最近一条数据(不需要验证Token)(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetLastRecordByMonitorPointID@V2.1")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetLastRecordByMonitorPointID_V2_1([FromQuery][Required] MonitorPointIDUnderCorpInput input)
|
{
|
var list = _service.GetLastRecord(input.CorpID, input.MonitorPointID);
|
if (list == null || list.Count < 1)
|
return default;
|
var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(input.CorpID, input.MonitorPointID);
|
var vmList = list.Select(x => new MonitorMonthRecordDto(x, monitor?.SignalList?.Find(t => t.ID == x.SignalID))).ToList();
|
return vmList;
|
}
|
|
#endregion
|
|
#region 通过 MonitorPointIds 获取最近记录
|
|
/// <summary>
|
/// 通过 MonitorPointIds 获取最近一条数据(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[Route("GetLastRecordByMonitorPointIds@V1.0")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetLastRecordByMonitorPointIds_V1_0([FromQuery][Required] MonitorPointIdsUnderCorpInput input)
|
{
|
var ids = LongListHelper.ToList(input.MonitorPointIds);
|
var list = _service.GetLastRecord(input.CorpID, ids);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointIds 获取最近一条数据(不需要验证Token)(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetLastRecordByMonitorPointIds@V1.1")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetLastRecordByMonitorPointIds_V1_1([FromQuery][Required] MonitorPointIdsUnderCorpInput input)
|
{
|
var ids = LongListHelper.ToList(input.MonitorPointIds);
|
var list = _service.GetLastRecord(input.CorpID, ids);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointIds 获取最近一条数据(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[Route("GetLastRecordByMonitorPointIds@V2.0")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetLastRecordByMonitorPointIds_V2_0([FromQuery][Required] MonitorPointIdsUnderCorpInput input)
|
{
|
var ids = LongListHelper.ToList(input.MonitorPointIds);
|
var list = _service.GetLastRecord(input.CorpID, ids);
|
if (list == null || list.Count < 1)
|
return default;
|
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByIds(input.CorpID, ids);
|
var vmList = 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 MonitorMonthRecordDto(x, signal);
|
return vm;
|
}).ToList();
|
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointIds 获取最近一条数据(不需要验证Token)(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetLastRecordByMonitorPointIds@V2.1")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetLastRecordByMonitorPointIds_V2_1([FromQuery][Required] MonitorPointIdsUnderCorpInput input)
|
{
|
var ids = LongListHelper.ToList(input.MonitorPointIds);
|
var list = _service.GetLastRecord(input.CorpID, ids);
|
if (list == null || list.Count < 1)
|
return default;
|
var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByIds(input.CorpID, ids);
|
var vmList = 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 MonitorMonthRecordDto(x, signal);
|
return vm;
|
}).ToList();
|
|
return vmList;
|
}
|
|
#endregion
|
|
#region 通过 SignalID 获取最近数据
|
|
/// <summary>
|
/// 通过 SignalID 获取最近一条数据(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[Route("GetLastRecordBySignalID@V1.0")]
|
[HttpGet]
|
public MonitorMonthRecordDto GetLastRecordBySignalID_V1_0([FromQuery][Required] SignalIDUnderCorpInput input)
|
{
|
var model = _service.GetLastRecord(input.CorpID, input.MonitorPointID, input.SignalID);
|
if (model == null)
|
return default;
|
var vm = new MonitorMonthRecordDto(model);
|
return vm;
|
}
|
|
/// <summary>
|
/// 通过 SignalID 获取最近一条数据(不需要验证Token)(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetLastRecordBySignalID@V1.1")]
|
[HttpGet]
|
public MonitorMonthRecordDto GetLastRecordBySignalID_V1_1([FromQuery][Required] SignalIDUnderCorpInput input)
|
{
|
var model = _service.GetLastRecord(input.CorpID, input.MonitorPointID, input.SignalID);
|
if (model == null)
|
return default;
|
var vm = new MonitorMonthRecordDto(model);
|
return vm;
|
}
|
|
/// <summary>
|
/// 通过 SignalID 获取最近一条数据(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[Route("GetLastRecordBySignalID@V2.0")]
|
[HttpGet]
|
public MonitorMonthRecordDto GetLastRecordBySignalID_V2_0([FromQuery][Required] SignalIDUnderCorpInput input)
|
{
|
var model = _service.GetLastRecord(input.CorpID, input.MonitorPointID, input.SignalID);
|
if (model == null)
|
return default;
|
var signal = new Service.Signal().GetExSignalTypeByID(input.CorpID, input.SignalID);
|
var vm = new MonitorMonthRecordDto(model, signal);
|
return vm;
|
}
|
|
/// <summary>
|
/// 通过 SignalID 获取最近一条数据(不需要验证Token)(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetLastRecordBySignalID@V2.1")]
|
[HttpGet]
|
public MonitorMonthRecordDto GetLastRecordBySignalID_V2_1([FromQuery][Required] SignalIDUnderCorpInput input)
|
{
|
var model = _service.GetLastRecord(input.CorpID, input.MonitorPointID, input.SignalID);
|
if (model == null)
|
return default;
|
var signal = new Service.Signal().GetExSignalTypeByID(input.CorpID, input.SignalID);
|
var vm = new MonitorMonthRecordDto(model, signal);
|
return vm;
|
}
|
|
#endregion
|
|
#region 通过 SignalIds 获取最近数据
|
|
/// <summary>
|
/// 通过 SignalIds 获取最近一条数据(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[Route("GetLastRecordBySignalIds@V1.0")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetLastRecordBySignalIds_V1_0([FromQuery][Required] SignalIdsUnderCorpInput input)
|
{
|
var ids = LongListHelper.ToList(input.SignalIds);
|
var list = _service.GetLastRecord(input.CorpID, input.MonitorPointID, ids);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 SignalIds 获取最近一条数据(不需要验证Token)(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetLastRecordBySignalIds@V1.1")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetLastRecordBySignalIds_V1_1([FromQuery][Required] SignalIdsUnderCorpInput input)
|
{
|
var ids = LongListHelper.ToList(input.SignalIds);
|
var list = _service.GetLastRecord(input.CorpID, input.MonitorPointID, ids);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 SignalIds 获取最近一条数据(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[Route("GetLastRecordBySignalIds@V2.0")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetLastRecordBySignalIds_V2_0([FromQuery][Required] SignalIdsUnderCorpInput input)
|
{
|
var ids = LongListHelper.ToList(input.SignalIds);
|
var list = _service.GetLastRecord(input.CorpID, input.MonitorPointID, ids);
|
if (list == null || list.Count < 1)
|
return default;
|
var signalList = new Service.Signal().GetExSignalTypeBySignalIds(input.CorpID, ids);
|
var vmList = list.Select(x => new MonitorMonthRecordDto(x, signalList?.Find(t => t.ID == x.SignalID))).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 SignalIds 获取最近一条数据(不需要验证Token)(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetLastRecordBySignalIds@V2.1")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetLastRecordBySignalIds_V2_1([FromQuery][Required] SignalIdsUnderCorpInput input)
|
{
|
var ids = LongListHelper.ToList(input.SignalIds);
|
var list = _service.GetLastRecord(input.CorpID, input.MonitorPointID, ids);
|
if (list == null || list.Count < 1)
|
return default;
|
var signalList = new Service.Signal().GetExSignalTypeBySignalIds(input.CorpID, ids);
|
var vmList = list.Select(x => new MonitorMonthRecordDto(x, signalList?.Find(t => t.ID == x.SignalID))).ToList();
|
return vmList;
|
}
|
|
#endregion
|
|
#endregion
|
|
#region 通过测点标识获取
|
|
#region 获取所有数据
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[Route("GetByMonitorPointID@V1.0")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointID_V1_0([FromQuery][Required] MonitorPointIDUnderCorpInput input)
|
{
|
var list = _service.GetByMonitorPointID(input.CorpID, input.MonitorPointID);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取(不需要验证Token)(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetByMonitorPointID@V1.1")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointID_V1_1([FromQuery][Required] MonitorPointIDUnderCorpInput input)
|
{
|
var list = _service.GetByMonitorPointID(input.CorpID, input.MonitorPointID);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[Route("GetByMonitorPointID@V2.0")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointID_V2_0([FromQuery][Required] MonitorPointIDUnderCorpInput input)
|
{
|
var list = _service.GetByMonitorPointID(input.CorpID, input.MonitorPointID);
|
if (list == null || list.Count < 1)
|
return default;
|
var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(input.CorpID, input.MonitorPointID);
|
var vmList = list.Select(x => new MonitorMonthRecordDto(x, monitor?.SignalList?.Find(t => t.ID == x.SignalID))).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取(不需要验证Token)(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetByMonitorPointID@V2.1")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointID_V2_1([FromQuery][Required] MonitorPointIDUnderCorpInput input)
|
{
|
var list = _service.GetByMonitorPointID(input.CorpID, input.MonitorPointID);
|
if (list == null || list.Count < 1)
|
return default;
|
var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(input.CorpID, input.MonitorPointID);
|
var vmList = list.Select(x => new MonitorMonthRecordDto(x, monitor?.SignalList?.Find(t => t.ID == x.SignalID))).ToList();
|
return vmList;
|
}
|
|
#endregion
|
|
#region 获取某年的数据
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取某年的数据(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[Route("GetByMonitorPointIDOfYear@V1.0")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointIDOfYear_V1_0
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
int Year
|
)
|
{
|
var list = _service.GetByMonitorPointIDOfYear(CorpID, MonitorPointID, Year);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取某年的数据(不需要验证Token)(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetByMonitorPointIDOfYear@V1.1")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointIDOfYear_V1_1
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
int Year
|
)
|
{
|
var list = _service.GetByMonitorPointIDOfYear(CorpID, MonitorPointID, Year);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取某年的数据(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[Route("GetByMonitorPointIDOfYear@V2.0")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointIDOfYear_V2_0
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
int Year
|
)
|
{
|
var list = _service.GetByMonitorPointIDOfYear(CorpID, MonitorPointID, Year);
|
if (list == null || list.Count < 1)
|
return default;
|
var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(CorpID, MonitorPointID);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x, monitor?.SignalList?.Find(t => t.ID == x.SignalID))).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取某年的数据(不需要验证Token)(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetByMonitorPointIDOfYear@V2.1")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointIDOfYear_V2_1
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
int Year
|
)
|
{
|
var list = _service.GetByMonitorPointIDOfYear(CorpID, MonitorPointID, Year);
|
if (list == null || list.Count < 1)
|
return default;
|
var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(CorpID, MonitorPointID);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x, monitor?.SignalList?.Find(t => t.ID == x.SignalID))).ToList();
|
return vmList;
|
}
|
|
#endregion
|
|
#region 获取某月的数据
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取某月的数据(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[Route("GetByMonitorPointIDOfMonth@V1.0")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointIDOfMonth_V1_0
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
int Year,
|
[Required, Range(1, 12, ErrorMessage = "Month 必须介于1-12之间")]
|
int Month
|
)
|
{
|
var list = _service.GetByMonitorPointIDOfMonth(CorpID, MonitorPointID, Year, Month);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取某月的数据(不需要验证Token)(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetByMonitorPointIDOfMonth@V1.1")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointIDOfMonth_V1_1
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
int Year,
|
[Required, Range(1, 12, ErrorMessage = "Month 必须介于1-12之间")]
|
int Month
|
)
|
{
|
var list = _service.GetByMonitorPointIDOfMonth(CorpID, MonitorPointID, Year, Month);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取某月的数据(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[Route("GetByMonitorPointIDOfMonth@V2.0")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointIDOfMonth_V2_0
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
int Year,
|
[Required, Range(1, 12, ErrorMessage = "Month 必须介于1-12之间")]
|
int Month
|
)
|
{
|
var list = _service.GetByMonitorPointIDOfMonth(CorpID, MonitorPointID, Year, Month);
|
if (list == null || list.Count < 1)
|
return default;
|
var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(CorpID, MonitorPointID);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x, monitor?.SignalList?.Find(t => t.ID == x.SignalID))).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取某月的数据(不需要验证Token)(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetByMonitorPointIDOfMonth@V2.1")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointIDOfMonth_V2_1
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
int Year,
|
[Required, Range(1, 12, ErrorMessage = "Month 必须介于1-12之间")]
|
int Month
|
)
|
{
|
var list = _service.GetByMonitorPointIDOfMonth(CorpID, MonitorPointID, Year, Month);
|
if (list == null || list.Count < 1)
|
return default;
|
var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(CorpID, MonitorPointID);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x, monitor?.SignalList?.Find(t => t.ID == x.SignalID))).ToList();
|
return vmList;
|
}
|
|
|
#endregion
|
|
#region 获取年区间内的数据
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取年区间内的数据(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[Route("GetByMonitorPointIDOfYearRange@V1.0")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointIDOfYearRange_V1_0
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
int StartYear,
|
[Required]
|
int EndYear
|
)
|
{
|
|
var list = _service.GetByMonitorPointIDOfYearRange(CorpID, MonitorPointID, StartYear, EndYear);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取年区间内的数据(不需要验证Token)(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetByMonitorPointIDOfYearRange@V1.1")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointIDOfYearRange_V1_1
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
int StartYear,
|
[Required]
|
int EndYear
|
)
|
{
|
|
var list = _service.GetByMonitorPointIDOfYearRange(CorpID, MonitorPointID, StartYear, EndYear);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取年区间内的数据(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[Route("GetByMonitorPointIDOfYearRange@V2.0")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointIDOfYearRange_V2_0
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
int StartYear,
|
[Required]
|
int EndYear
|
)
|
{
|
|
var list = _service.GetByMonitorPointIDOfYearRange(CorpID, MonitorPointID, StartYear, EndYear);
|
if (list == null || list.Count < 1)
|
return default;
|
var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(CorpID, MonitorPointID);
|
var vmList = list.Select(x => new MonitorMonthRecordDto(x, monitor?.SignalList?.Find(t => t.ID == x.SignalID))).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取年区间内的数据(不需要验证Token)(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetByMonitorPointIDOfYearRange@V2.1")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointIDOfYearRange_V2_1
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
int StartYear,
|
[Required]
|
int EndYear
|
)
|
{
|
|
var list = _service.GetByMonitorPointIDOfYearRange(CorpID, MonitorPointID, StartYear, EndYear);
|
if (list == null || list.Count < 1)
|
return default;
|
var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(CorpID, MonitorPointID);
|
var vmList = list.Select(x => new MonitorMonthRecordDto(x, monitor?.SignalList?.Find(t => t.ID == x.SignalID))).ToList();
|
return vmList;
|
}
|
|
#endregion
|
|
#region 获取月区间内的数据
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取月区间内的数据(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[Route("GetByMonitorPointIDOfMonthRange@V1.0")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointIDOfMonthRange_V1_0
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
int StartYear,
|
[Required, Range(1, 12, ErrorMessage = "StartMonth 必须介于1-12之间")]
|
int StartMonth,
|
[Required]
|
int EndYear,
|
[Required, Range(1, 12, ErrorMessage = "EndMonth 必须介于1-12之间")]
|
int EndMonth
|
)
|
{
|
var list = _service.GetByMonitorPointIDOfMonthRange(CorpID, MonitorPointID, StartYear, StartMonth, EndYear, EndMonth);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取月区间内的数据(不需要验证Token)(未进行单位转换,使用的是系统单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetByMonitorPointIDOfMonthRange@V1.1")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointIDOfMonthRange_V1_1
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
int StartYear,
|
[Required, Range(1, 12, ErrorMessage = "StartMonth 必须介于1-12之间")]
|
int StartMonth,
|
[Required]
|
int EndYear,
|
[Required, Range(1, 12, ErrorMessage = "EndMonth 必须介于1-12之间")]
|
int EndMonth
|
)
|
{
|
var list = _service.GetByMonitorPointIDOfMonthRange(CorpID, MonitorPointID, StartYear, StartMonth, EndYear, EndMonth);
|
var vmList = list?.Select(x => new MonitorMonthRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取月区间内的数据(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[Route("GetByMonitorPointIDOfMonthRange@V2.0")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointIDOfMonthRange_V2_0
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
int StartYear,
|
[Required, Range(1, 12, ErrorMessage = "StartMonth 必须介于1-12之间")]
|
int StartMonth,
|
[Required]
|
int EndYear,
|
[Required, Range(1, 12, ErrorMessage = "EndMonth 必须介于1-12之间")]
|
int EndMonth
|
)
|
{
|
var list = _service.GetByMonitorPointIDOfMonthRange(CorpID, MonitorPointID, StartYear, StartMonth, EndYear, EndMonth);
|
if (list == null || list.Count < 1)
|
return default;
|
var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(CorpID, MonitorPointID);
|
var vmList = list.Select(x => new MonitorMonthRecordDto(x, monitor?.SignalList?.Find(t => t.ID == x.SignalID))).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取月区间内的数据(不需要验证Token)(已进行单位转换,使用的是信号显示单位)
|
/// </summary>
|
[AllowAnonymous]
|
[Route("GetByMonitorPointIDOfMonthRange@V2.1")]
|
[HttpGet]
|
public List<MonitorMonthRecordDto> GetByMonitorPointIDOfMonthRange_V2_1
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
int StartYear,
|
[Required, Range(1, 12, ErrorMessage = "StartMonth 必须介于1-12之间")]
|
int StartMonth,
|
[Required]
|
int EndYear,
|
[Required, Range(1, 12, ErrorMessage = "EndMonth 必须介于1-12之间")]
|
int EndMonth
|
)
|
{
|
var list = _service.GetByMonitorPointIDOfMonthRange(CorpID, MonitorPointID, StartYear, StartMonth, EndYear, EndMonth);
|
if (list == null || list.Count < 1)
|
return default;
|
var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(CorpID, MonitorPointID);
|
var vmList = list.Select(x => new MonitorMonthRecordDto(x, monitor?.SignalList?.Find(t => t.ID == x.SignalID))).ToList();
|
return vmList;
|
}
|
|
#endregion
|
|
#endregion
|
|
#region 补录
|
|
/// <summary>
|
/// 补录一条(已弃用,请选用管理下相关接口)
|
/// </summary>
|
[Route("InsertSupplement@V1.0")]
|
[HttpPost]
|
public bool InsertSupplement([Required] SupplementMonitorMonthRecordInput input)
|
{
|
var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(input.CorpID, input.MonitorPointID);
|
if (monitor.CronType != Model.Monitor.eCronType.EachMonth)
|
{
|
return false;
|
}
|
var bol = false;
|
var dataTime = DateTime.Now;
|
switch (monitor.MonitorType)
|
{
|
case Model.eMonitorType.General:
|
{
|
var signal = monitor.SignalList?.FirstOrDefault();
|
if (signal != null)
|
{
|
var data_status = new List<string>();
|
var data_value = MonitorHandleHelper.Handle(monitor, signal, lastRecord: null, input.SrcTime, input.SrcValue, data_status);
|
if (!string.IsNullOrEmpty(data_value))
|
{
|
var record = new Model.MonitorMonthRecordPure();
|
record.CorpID = input.CorpID;
|
record.MonitorPointID = input.MonitorPointID;
|
record.SignalID = signal.ID;
|
record.RecordType = monitor.MonitorType;
|
record.SrcTime = input.SrcTime;
|
record.SrcValue = input.SrcValue;
|
record.DataTime = dataTime;
|
record.DataValue = data_value;
|
record.DataStatus = data_status;
|
record.DataYear = input.DataYear;
|
record.DataMonth = input.DataMonth;
|
bol = _service.InsertSupplement(record);
|
}
|
}
|
}
|
break;
|
case Model.eMonitorType.Vibration:
|
{
|
var sub_record_list = AddMonitorSubRecordInput.ToList(input.SrcValue);
|
if (sub_record_list != null && sub_record_list.Count > 0)
|
{
|
var record_list = new List<Model.MonitorMonthRecordPure>();
|
foreach (var sub_record in sub_record_list)
|
{
|
var signal = monitor.SignalList?.FirstOrDefault(x => x.ID == sub_record.SignalID);
|
if (signal == null)
|
continue;
|
var data_status = new List<string>();
|
var data_value = MonitorHandleHelper.Handle(monitor, signal, lastRecord: null, input.SrcTime, sub_record.SrcValue, data_status);
|
if (string.IsNullOrEmpty(data_value))
|
continue;
|
var record = new Model.MonitorMonthRecordPure();
|
record.CorpID = input.CorpID;
|
record.MonitorPointID = input.MonitorPointID;
|
record.SignalID = signal.ID;
|
record.RecordType = monitor.MonitorType;
|
record.SrcTime = input.SrcTime;
|
record.SrcValue = sub_record.SrcValue;
|
record.DataTime = dataTime;
|
record.DataValue = data_value;
|
record.DataStatus = data_status;
|
record.DataYear = input.DataYear;
|
record.DataMonth = input.DataMonth;
|
record_list.Add(record);
|
}
|
if (record_list.Count > 0)
|
{
|
bol = _service.InsertsSupplement(record_list);
|
}
|
}
|
}
|
break;
|
default: break;
|
}
|
|
return bol;
|
}
|
|
/// <summary>
|
/// 补录多条(已弃用,请选用管理下相关接口)
|
/// </summary>
|
[Route("InsertsSupplement@V1.0")]
|
[HttpPost]
|
public bool InsertsSupplement([Required] List<SupplementMonitorMonthRecordInput> list)
|
{
|
var corpIds = list.Select(x => x.CorpID).Distinct().ToList();
|
if (corpIds.Count > 1)
|
{
|
return false;
|
}
|
|
var dataTime = DateTime.Now;
|
var record_list = new List<Model.MonitorMonthRecordPure>();
|
foreach (var item in list)
|
{
|
var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(item.CorpID, item.MonitorPointID);
|
if (monitor.CronType != Model.Monitor.eCronType.EachMonth)
|
{
|
continue;
|
}
|
switch (monitor.MonitorType)
|
{
|
case Model.eMonitorType.General:
|
{
|
var signal = monitor.SignalList?.FirstOrDefault();
|
if (signal != null)
|
{
|
var data_status = new List<string>();
|
var data_value = MonitorHandleHelper.Handle(monitor, signal, lastRecord: null, item.SrcTime, item.SrcValue, data_status);
|
if (!string.IsNullOrEmpty(data_value))
|
{
|
var record = new Model.MonitorMonthRecordPure();
|
record.CorpID = item.CorpID;
|
record.MonitorPointID = item.MonitorPointID;
|
record.SignalID = signal.ID;
|
record.RecordType = monitor.MonitorType;
|
record.SrcTime = item.SrcTime;
|
record.SrcValue = item.SrcValue;
|
record.DataTime = dataTime;
|
record.DataValue = data_value;
|
record.DataStatus = data_status;
|
record.DataYear = item.DataYear;
|
record.DataMonth = item.DataMonth;
|
record_list.Add(record);
|
}
|
}
|
}
|
break;
|
case Model.eMonitorType.Vibration:
|
{
|
var sub_record_list = AddMonitorSubRecordInput.ToList(item.SrcValue);
|
if (sub_record_list != null && sub_record_list.Count > 0)
|
{
|
foreach (var sub_record in sub_record_list)
|
{
|
var signal = monitor.SignalList?.FirstOrDefault(x => x.ID == sub_record.SignalID);
|
if (signal == null)
|
continue;
|
var data_status = new List<string>();
|
var data_value = MonitorHandleHelper.Handle(monitor, signal, lastRecord: null, item.SrcTime, sub_record.SrcValue, data_status);
|
if (string.IsNullOrEmpty(data_value))
|
continue;
|
var record = new Model.MonitorMonthRecordPure();
|
record.CorpID = item.CorpID;
|
record.MonitorPointID = item.MonitorPointID;
|
record.SignalID = signal.ID;
|
record.RecordType = monitor.MonitorType;
|
record.SrcTime = item.SrcTime;
|
record.SrcValue = sub_record.SrcValue;
|
record.DataTime = dataTime;
|
record.DataValue = data_value;
|
record.DataStatus = data_status;
|
record.DataYear = item.DataYear;
|
record.DataMonth = item.DataMonth;
|
record_list.Add(record);
|
}
|
}
|
}
|
break;
|
default: break;
|
}
|
}
|
|
if (record_list.Count < 1)
|
{
|
return false;
|
}
|
var bol = _service.InsertsSupplement(record_list);
|
return bol;
|
}
|
|
#endregion
|
|
}
|
}
|