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 { /// /// MonitorMonthRecord /// [Route("Run/MonitorMonthRecord")] [ApiDescriptionSettings("Run", Name = "监测月记录", Order = 950)] public class MonitorMonthRecord_Controller : IDynamicApiController { //服务 private readonly Service.MonitorMonthRecord _service = new Service.MonitorMonthRecord(); #region 获取最近记录 #region 通过 MonitorPointID 获取 /// /// 通过 MonitorPointID 获取最近一条数据(未进行单位转换,使用的是系统单位) /// [Route("GetLastRecordByMonitorPointID@V1.0")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取最近一条数据(不需要验证Token)(未进行单位转换,使用的是系统单位) /// [AllowAnonymous] [Route("GetLastRecordByMonitorPointID@V1.1")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取最近一条数据(已进行单位转换,使用的是信号显示单位) /// [Route("GetLastRecordByMonitorPointID@V2.0")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取最近一条数据(不需要验证Token)(已进行单位转换,使用的是信号显示单位) /// [AllowAnonymous] [Route("GetLastRecordByMonitorPointID@V2.1")] [HttpGet] public List 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 获取最近记录 /// /// 通过 MonitorPointIds 获取最近一条数据(未进行单位转换,使用的是系统单位) /// [Route("GetLastRecordByMonitorPointIds@V1.0")] [HttpGet] public List 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; } /// /// 通过 MonitorPointIds 获取最近一条数据(不需要验证Token)(未进行单位转换,使用的是系统单位) /// [AllowAnonymous] [Route("GetLastRecordByMonitorPointIds@V1.1")] [HttpGet] public List 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; } /// /// 通过 MonitorPointIds 获取最近一条数据(已进行单位转换,使用的是信号显示单位) /// [Route("GetLastRecordByMonitorPointIds@V2.0")] [HttpGet] public List 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; } /// /// 通过 MonitorPointIds 获取最近一条数据(不需要验证Token)(已进行单位转换,使用的是信号显示单位) /// [AllowAnonymous] [Route("GetLastRecordByMonitorPointIds@V2.1")] [HttpGet] public List 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 获取最近数据 /// /// 通过 SignalID 获取最近一条数据(未进行单位转换,使用的是系统单位) /// [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; } /// /// 通过 SignalID 获取最近一条数据(不需要验证Token)(未进行单位转换,使用的是系统单位) /// [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; } /// /// 通过 SignalID 获取最近一条数据(已进行单位转换,使用的是信号显示单位) /// [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; } /// /// 通过 SignalID 获取最近一条数据(不需要验证Token)(已进行单位转换,使用的是信号显示单位) /// [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 获取最近数据 /// /// 通过 SignalIds 获取最近一条数据(未进行单位转换,使用的是系统单位) /// [Route("GetLastRecordBySignalIds@V1.0")] [HttpGet] public List 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; } /// /// 通过 SignalIds 获取最近一条数据(不需要验证Token)(未进行单位转换,使用的是系统单位) /// [AllowAnonymous] [Route("GetLastRecordBySignalIds@V1.1")] [HttpGet] public List 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; } /// /// 通过 SignalIds 获取最近一条数据(已进行单位转换,使用的是信号显示单位) /// [Route("GetLastRecordBySignalIds@V2.0")] [HttpGet] public List 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; } /// /// 通过 SignalIds 获取最近一条数据(不需要验证Token)(已进行单位转换,使用的是信号显示单位) /// [AllowAnonymous] [Route("GetLastRecordBySignalIds@V2.1")] [HttpGet] public List 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 获取所有数据 /// /// 通过 MonitorPointID 获取(未进行单位转换,使用的是系统单位) /// [Route("GetByMonitorPointID@V1.0")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取(不需要验证Token)(未进行单位转换,使用的是系统单位) /// [AllowAnonymous] [Route("GetByMonitorPointID@V1.1")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取(已进行单位转换,使用的是信号显示单位) /// [Route("GetByMonitorPointID@V2.0")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取(不需要验证Token)(已进行单位转换,使用的是信号显示单位) /// [AllowAnonymous] [Route("GetByMonitorPointID@V2.1")] [HttpGet] public List 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 获取某年的数据 /// /// 通过 MonitorPointID 获取某年的数据(未进行单位转换,使用的是系统单位) /// [Route("GetByMonitorPointIDOfYear@V1.0")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取某年的数据(不需要验证Token)(未进行单位转换,使用的是系统单位) /// [AllowAnonymous] [Route("GetByMonitorPointIDOfYear@V1.1")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取某年的数据(已进行单位转换,使用的是信号显示单位) /// [Route("GetByMonitorPointIDOfYear@V2.0")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取某年的数据(不需要验证Token)(已进行单位转换,使用的是信号显示单位) /// [AllowAnonymous] [Route("GetByMonitorPointIDOfYear@V2.1")] [HttpGet] public List 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 获取某月的数据 /// /// 通过 MonitorPointID 获取某月的数据(未进行单位转换,使用的是系统单位) /// [Route("GetByMonitorPointIDOfMonth@V1.0")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取某月的数据(不需要验证Token)(未进行单位转换,使用的是系统单位) /// [AllowAnonymous] [Route("GetByMonitorPointIDOfMonth@V1.1")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取某月的数据(已进行单位转换,使用的是信号显示单位) /// [Route("GetByMonitorPointIDOfMonth@V2.0")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取某月的数据(不需要验证Token)(已进行单位转换,使用的是信号显示单位) /// [AllowAnonymous] [Route("GetByMonitorPointIDOfMonth@V2.1")] [HttpGet] public List 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 获取年区间内的数据 /// /// 通过 MonitorPointID 获取年区间内的数据(未进行单位转换,使用的是系统单位) /// [Route("GetByMonitorPointIDOfYearRange@V1.0")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取年区间内的数据(不需要验证Token)(未进行单位转换,使用的是系统单位) /// [AllowAnonymous] [Route("GetByMonitorPointIDOfYearRange@V1.1")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取年区间内的数据(已进行单位转换,使用的是信号显示单位) /// [Route("GetByMonitorPointIDOfYearRange@V2.0")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取年区间内的数据(不需要验证Token)(已进行单位转换,使用的是信号显示单位) /// [AllowAnonymous] [Route("GetByMonitorPointIDOfYearRange@V2.1")] [HttpGet] public List 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 获取月区间内的数据 /// /// 通过 MonitorPointID 获取月区间内的数据(未进行单位转换,使用的是系统单位) /// [Route("GetByMonitorPointIDOfMonthRange@V1.0")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取月区间内的数据(不需要验证Token)(未进行单位转换,使用的是系统单位) /// [AllowAnonymous] [Route("GetByMonitorPointIDOfMonthRange@V1.1")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取月区间内的数据(已进行单位转换,使用的是信号显示单位) /// [Route("GetByMonitorPointIDOfMonthRange@V2.0")] [HttpGet] public List 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; } /// /// 通过 MonitorPointID 获取月区间内的数据(不需要验证Token)(已进行单位转换,使用的是信号显示单位) /// [AllowAnonymous] [Route("GetByMonitorPointIDOfMonthRange@V2.1")] [HttpGet] public List 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 补录 /// /// 补录一条 /// [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(); 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(); 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(); 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; } /// /// 补录多条 /// [Route("InsertsSupplement@V1.0")] [HttpPost] public bool InsertsSupplement([Required] List 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(); 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(); 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(); 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 } }