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>
|
/// MonitorRealRecord
|
/// </summary>
|
[Route("Run/MonitorRealRecord/Mgr")]
|
[ApiDescriptionSettings("Run", Name = "监测实时记录(管理)", Order = 990)]
|
public class MonitorRealRecord_MgrController : IDynamicApiController
|
{
|
//服务
|
private readonly Service.MonitorRealRecord _service = new Service.MonitorRealRecord();
|
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取某天的数据(未进行单位转换,采用系统默认单位)
|
/// </summary>
|
[Route("GetByMonitorPointIDOfDay@V1.0")]
|
[HttpGet]
|
public List<MonitorRealRecordMgrDto> GetByMonitorPointIDOfDay
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
DateTime Day
|
)
|
{
|
var list = _service.GetByMonitorPointIDOfDay(CorpID, MonitorPointID, Day);
|
var vmList = list?.Select(x => new MonitorRealRecordMgrDto(x)).ToList();
|
return vmList;
|
}
|
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取日期区间内的数据(未进行单位转换,采用系统默认单位)
|
/// </summary>
|
[Route("GetByMonitorPointIDOfDayRange@V1.0")]
|
[HttpGet]
|
public List<MonitorRealRecordMgrDto> GetByMonitorPointIDOfDayRange
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
DateTime StartDay,
|
[Required]
|
DateTime EndDay
|
)
|
{
|
if (StartDay.Date > EndDay.Date)
|
{
|
return default;
|
}
|
var list = _service.GetByMonitorPointIDOfDayRange(CorpID, MonitorPointID, StartDay, EndDay);
|
var vmList = list?.Select(x => new MonitorRealRecordMgrDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取时间区间内的数据(未进行单位转换,采用系统默认单位)
|
/// </summary>
|
[Route("GetByMonitorPointIDOfTimeRange@V1.0")]
|
[HttpGet]
|
public List<MonitorRealRecordMgrDto> GetByMonitorPointIDOfTimeRange
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required]
|
DateTime StartTime,
|
[Required]
|
DateTime EndTime
|
)
|
{
|
if (StartTime > EndTime)
|
{
|
return default;
|
}
|
var list = _service.GetByMonitorPointIDOfTimeRange(CorpID, MonitorPointID, StartTime, EndTime);
|
var vmList = list?.Select(x => new MonitorRealRecordMgrDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 批量更新
|
/// </summary>
|
[Route("Updates@V1.0")]
|
[HttpPut]
|
public bool Updates([Required] List<UpdateMonitorRealRecordInput> list)
|
{
|
if (list == null || list.Count < 1)
|
return default;
|
var modelList = list.Select(x => new Model.MonitorRealRecord()
|
{
|
ID = x.ID,
|
CorpID = x.CorpID,
|
MonitorPointID = x.MonitorPointID,
|
SignalID = x.SignalID,
|
RecordType = x.RecordType,
|
SrcTime = x.SrcTime,
|
SrcValue = x.SrcValue,
|
DataTime = x.DataTime,
|
DataValue = x.DataValue,
|
DataStatus = x.DataStatus
|
}).ToList();
|
var bol = _service.Updates(modelList);
|
return bol;
|
}
|
|
|
|
|
|
}
|
}
|