lixiaojun
2022-07-28 9e522883df699fc2415e1cb679355efd37277050
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
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;
        }
 
 
 
 
 
    }
}