tangxu
2022-11-02 05f522e321a742f03bf1e3e26edaeb5147da42f4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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/Demo/Run")]
    [ApiDescriptionSettings("LargeScreen", Name = "Demo(运行)", Order = 666)]
    public class DemoRun_Controller : IDynamicApiController, ITransient 
    {
        private readonly IHttpContextAccessor _httpContextAccessor;
 
        /// <summary>
        /// 
        /// </summary>
        public DemoRun_Controller(IHttpContextAccessor httpContextAccessor)
        {
            _httpContextAccessor = httpContextAccessor; 
        }
 
        private const long _corpId = 3;
 
        /// <summary>
        /// 通过 MonitorPointID 获取最近一条实时数据
        /// </summary>
        [Route("GetLastRealRecordByMonitorPointID")]
        [HttpGet]
        public List<DemoMonitorRealRecordDto> GetLastRealRecordByMonitorPointID([FromQuery][Required] MonitorPointIDUnderCorpInput input)
        {
            var list = new Service.MonitorRealRecord().GetLastRecord(input.CorpID, input.MonitorPointID);
            var vm_list = list?.Select(x => x.Adapt<Model.MonitorRealRecordPure, DemoMonitorRealRecordDto>()).ToList();
            return vm_list;
        }
 
        /// <summary>
        /// 通过 MonitorPointIds  获取最近一条数据
        /// </summary>
        [Route("GetLastRecordByMonitorPointIds")]
        [HttpGet]
        public List<DemoMonitorRecordDto> GetLastRecordByMonitorPointIds([FromQuery][Required] MonitorPointIdsUnderCorpInput input)
        {
            var corpId = input.CorpID;
            var ids = LongListHelper.ToList(input.MonitorPointIds);
            var list = new Service.MonitorRecord().GetLastRecord(corpId, ids);
            return list?.Select(x => new DemoMonitorRecordDto(x)).ToList(); 
        }
 
        /// <summary>
        /// 通过 MonitorPointID 获取某天的实时数据
        /// </summary>
        [Route("GetRealRecordListByMonitorPointIDOfDay")]
        [HttpGet]
        public List<DemoMonitorRealRecordDto> GetRealRecordListByMonitorPointIDOfDay
            (
                [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 = new Service.MonitorRealRecord().GetByMonitorPointIDOfDay(CorpID, MonitorPointID, Day);
            return list?.Select(x => new DemoMonitorRealRecordDto(x)).ToList();
        }
 
 
        /// <summary>
        /// 获取监测报警记录模糊分页列表
        /// </summary>
        [Route("GetMonitorAlarmRecordFluzzyPageList")]
        [HttpGet]
        public PageListOutput<DemoMonitorAlarmRecordDto> GetMonitorAlarmRecordFluzzyPageList([FromQuery][Required] DemoGetMonitorAlarmRecordFluzzyPageListInput input)
        {
            int total = 0;
            var list = new Service.MonitorAlarmRecord().GetFluzzyPageList
                (input.CorpID, LongListHelper.ToList(input.MonitorPointIds), input.AlarmType, input.AlarmLevel, input.HandleStatus, input.StartTime, input.EndTime, input.PageIndex, input.PageSize, ref total);
            var vm_list = list?.Select(x => x.Adapt<Model.MonitorAlarmRecord, DemoMonitorAlarmRecordDto>()).ToList();
            return new PageListOutput<DemoMonitorAlarmRecordDto>() { Total = total, List = vm_list };
        }
 
    }
}