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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
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/Station")]
    [ApiDescriptionSettings("LargeScreen", Name = "Demo(泵站)", Order = 666)]
    public class DemoStation_Controller : IDynamicApiController, ITransient 
    {
        private readonly IHttpContextAccessor _httpContextAccessor;
 
        /// <summary>
        /// 
        /// </summary>
        public DemoStation_Controller(IHttpContextAccessor httpContextAccessor)
        { 
            _httpContextAccessor = httpContextAccessor;
        }
 
        /// <summary>
        /// 获取泵站主页汇总信息(左上部分)
        /// </summary>
        /// <param name="StationID">泵站ID</param>
        [Route("GetLeftTopInfo")]
        [HttpGet]
        public DemoStationLeftTopInfoDto GetLeftTopInfo(long StationID)
        {
            DemoStationLeftTopInfoDto info_list = new DemoStationLeftTopInfoDto();
            var r = new Random();
            info_list.StationName = "松花江泵站";
            info_list.RecordInfos = new List<DemoStationRecordInfoDto>();
            info_list.RecordInfos.Add(new DemoStationRecordInfoDto() { ID = 1, Name = "出口压力", Value = (r.Next(10, 30) / 200.0 + 0.341).ToString(), Unit = "MPa" });
            info_list.RecordInfos.Add(new DemoStationRecordInfoDto() { ID = 2, Name = "出口流量", Value = (r.Next(510, 530) + 2).ToString(), Unit = "m³/h" });
            info_list.RecordInfos.Add(new DemoStationRecordInfoDto() { ID = 3, Name = "总功率", Value = (r.Next(210, 230) + 1.2).ToString(), Unit = "kW" });
            info_list.RecordInfos.Add(new DemoStationRecordInfoDto() { ID = 4, Name = "单位能耗", Value = (r.Next(10, 30) + 73.2).ToString(), Unit = "kW/千吨水" });
 
 
            info_list.RunInfos = new List<DemoStationRunInfoDto>();
            info_list.RunInfos.Add(new DemoStationRunInfoDto() { ID = 1, Name = "一号泵", OpenStatus = 1 });
            info_list.RunInfos.Add(new DemoStationRunInfoDto() { ID = 2, Name = "二号泵", OpenStatus = 0 });
            info_list.RunInfos.Add(new DemoStationRunInfoDto() { ID = 3, Name = "三号泵", OpenStatus = 0 });
            info_list.RunInfos.Add(new DemoStationRunInfoDto() { ID = 4, Name = "四号泵", OpenStatus = 1 });
            info_list.RunInfos.Add(new DemoStationRunInfoDto() { ID = 5, Name = "五号泵", OpenStatus = -1 });
            info_list.RunInfos.Add(new DemoStationRunInfoDto() { ID = 6, Name = "六号泵", OpenStatus = 1 });
 
 
 
            return info_list;
        }
 
        /// <summary>
        /// 获取泵站数据分析汇总信息(左中部分)
        /// </summary>
        /// <param name="StationID">泵站ID</param>
        /// <param name="StaticType">汇总类型(1按日  2 按周 3 按月 4 按年)</param> 
        /// <returns></returns>
        [Route("GetLeftMiddleInfo")]
        [HttpGet]
        public List<DemoStationLeftMiddleItemInfoDto> GetLeftMiddleInfo(long StationID, int StaticType)
        {
            var r = new Random();
            List<DemoStationLeftMiddleItemInfoDto> info_list = new List<DemoStationLeftMiddleItemInfoDto>();
            if (StaticType == 1 || StaticType <= 0)
            {
                for (DateTime day = DateTime.Today.AddMonths(-1); day < DateTime.Today; day = day.AddDays(1))
                {
                    DemoStationLeftMiddleItemInfoDto item = new DemoStationLeftMiddleItemInfoDto();
                    item.Label = day.ToString("yyyy-MM-dd");
                    item.SupplyWater = r.Next(260, 280);
                    item.EnergyConsumption = r.Next(280, 295);
                    info_list.Add(item);
                }
            }
            else if (StaticType == 3 || StaticType == 2)
            {//2 按周 3 按月
                for (int month = 1; month < DateTime.Today.Month; month = month + 1)
                {
                    DemoStationLeftMiddleItemInfoDto item = new DemoStationLeftMiddleItemInfoDto();
                    item.Label = month.ToString();
                    item.SupplyWater = r.Next(260, 280) * 30;
                    item.EnergyConsumption = r.Next(220, 235) * 30;
                    info_list.Add(item);
                }
            }
            else
            {//4 按年
                for (int year = 1; year < 4; year = year + 1)
                {
                    DemoStationLeftMiddleItemInfoDto item = new DemoStationLeftMiddleItemInfoDto();
                    item.Label = (DateTime.Today.Year - 3 + year).ToString();
                    item.SupplyWater = r.Next(260, 280) * 270;
                    item.EnergyConsumption = r.Next(260, 275) * 270;
                    info_list.Add(item);
                }
            }
            return info_list;
        }
 
        /// <summary>
        /// 获取泵站数据分析明细信息(左下部分)
        /// </summary>
        /// <param name="StationID">泵站ID</param>
        /// <param name="StaticType">汇总类型(1按日  2 按周 3 按月 4 按年)</param> 
        /// <returns></returns>
        [Route("GetLeftBottomInfo")]
        [HttpGet]
        public List<DemoStationLeftBottomItemInfoDto> GetLeftBottomInfo(long StationID, int StaticType)
        {
            var r = new Random();
            List<DemoStationLeftBottomItemInfoDto> info_list = new List<DemoStationLeftBottomItemInfoDto>();
 
            int ratio = 1;
            if (StaticType == 2)
                ratio = 7;
            if (StaticType == 3)
                ratio = 30;
            if (StaticType == 4)
                ratio = 350;
 
            var product_name_list = new List<string>() { "一号泵", "二号泵", "三号泵", "四号泵", "五号泵", "六号泵" };
 
            int ID = 1;
            foreach (var name in product_name_list)
            {
                DemoStationLeftBottomItemInfoDto item = new DemoStationLeftBottomItemInfoDto();
                item.ID = ID;
                item.Name = name;
                item.SupplyWater = r.Next(260, 270) * ratio;
                item.EnergyConsumption = r.Next(260, 275) * ratio;
                item.UnitEnergyConsumption = r.Next(183, 195) / 10.0;
                info_list.Add(item);
 
                ID++;
            }
 
            return info_list;
        }
 
        /// <summary>
        /// 获取首页报警和信息公告(中间底部)
        /// </summary>
        /// <param name="StationID">泵站ID</param>
        /// <param name="InfoType">信息类型(1公告信息  2报警信息)</param> 
        [Route("GetCenterBottomInfo")]
        [HttpGet]
        public List<DemoStationCenterBottomItemInfoDto> GetCenterBottomInfo(long StationID, int InfoType)
        {
            var r = new Random();
            List<DemoStationCenterBottomItemInfoDto> info_list = new List<DemoStationCenterBottomItemInfoDto>();
 
            if (InfoType == 1)
            {
                DemoStationCenterBottomItemInfoDto item1 = new DemoStationCenterBottomItemInfoDto();
                item1.Title = "一号泵";
                item1.UserName = "管理员";
                item1.Content = "2020年8月26日,控江路管道维修抢修完成。";
                info_list.Add(item1);
 
                DemoStationCenterBottomItemInfoDto item2 = new DemoStationCenterBottomItemInfoDto();
                item2.Title = "二号泵";
                item2.UserName = "管理员";
                item2.Content = "2020年9月11日,二号泵电机振动过大,进行大修。";
                info_list.Add(item2);
 
 
                DemoStationCenterBottomItemInfoDto item3 = new DemoStationCenterBottomItemInfoDto();
                item3.Title = "二号泵";
                item3.UserName = "管理员";
                item3.Content = "2020年9月22日,巡检员张坤成在人民广场附件发现曝管。";
                info_list.Add(item2);
            }
            else
            {
                DemoStationCenterBottomItemInfoDto item1 = new DemoStationCenterBottomItemInfoDto();
                item1.Title = "二号泵";
                item1.UserName = "李三林";
                item1.Content = "2020年9月20日 12时30分,一号机漏水严重。";
                info_list.Add(item1);
 
                DemoStationCenterBottomItemInfoDto item2 = new DemoStationCenterBottomItemInfoDto();
                item2.Title = "二号泵";
                item2.UserName = "李三林";
                item2.Content = "2020年9月21日 12时30分,一号机漏水严重。";
                info_list.Add(item2);
 
 
                DemoStationCenterBottomItemInfoDto item3 = new DemoStationCenterBottomItemInfoDto();
                item3.Title = "二号泵";
                item3.UserName = "管理员";
                item3.Content = "2020年9月25日 12时30分,二号电机电流超标。";
                info_list.Add(item2);
            }
 
            return info_list;
        }
 
        /// <summary>
        /// 获取表单状态统计占比(右部上)
        /// </summary>
        /// <param name="StationID">泵站ID</param>
        /// <param name="StaticType">统计类型(1按日  2 按周 3 按月 4 按年) </param> 
        [Route("GetRightTopInfo")]
        [HttpGet]
        public DemoStationRightTopInfoDto GetRightTopInfo(long StationID, int StaticType)
        {
            var r = new Random();
            int ratio = 1;
            if (StaticType == 2)
                ratio = 5;
            if (StaticType == 3)
                ratio = 20;
            if (StaticType == 4)
                ratio = 250;
 
            DemoStationRightTopInfoDto item1 = new DemoStationRightTopInfoDto();
 
            item1.ProcessedForm = r.Next(1, 2) * ratio;
            item1.ProcessingForm = r.Next(1, 3) * ratio;
            item1.UnProcessingForm = r.Next(0, 1) * ratio;
            item1.TotalForm = item1.ProcessedForm + item1.ProcessingForm + item1.UnProcessingForm;
 
            return item1;
        }
 
        /// <summary>
        /// 获取表单类型统计占比(右部中)
        /// </summary>
        /// <param name="StationID">泵站ID</param>
        /// <param name="StaticType">统计类型(1按日  2 按周 3 按月 4 按年)</param> 
        [Route("GetRightCenterInfo")]
        [HttpGet]
        public List<DemoStationRightCenterInfoDto> GetRightCenterInfo(long StationID, int StaticType)
        {
            var r = new Random();
            List<DemoStationRightCenterInfoDto> info_list = new List<DemoStationRightCenterInfoDto>();
            int ratio = 1;
            if (StaticType == 2)
                ratio = 7;
            if (StaticType == 3)
                ratio = 30;
            if (StaticType == 4)
                ratio = 350;
 
 
            DemoStationRightCenterInfoDto item1 = new DemoStationRightCenterInfoDto();
            item1.Label = "机组故障";
            item1.Number = r.Next(1, 3) * ratio;
            info_list.Add(item1);
 
 
            DemoStationRightCenterInfoDto item2 = new DemoStationRightCenterInfoDto();
            item2.Label = "管道维修";
            item2.Number = r.Next(0, 3) * ratio;
            info_list.Add(item2);
 
 
            DemoStationRightCenterInfoDto item3 = new DemoStationRightCenterInfoDto();
            item3.Label = "阀门维修";
            item3.Number = r.Next(0, 3) * ratio;
            info_list.Add(item3);
 
            DemoStationRightCenterInfoDto item4 = new DemoStationRightCenterInfoDto();
            item4.Label = "仪表";
            item4.Number = r.Next(0, 4) * ratio;
            info_list.Add(item4);
 
            DemoStationRightCenterInfoDto item5 = new DemoStationRightCenterInfoDto();
            item5.Label = "其他";
            item5.Number = r.Next(0, 5) * ratio;
            info_list.Add(item5);
            return info_list;
        }
 
        /// <summary>
        /// 通过 ID 获取详细
        /// </summary>
        [Route("GetDetailByID")]
        [HttpGet]
        public DemoStationDetailDto GetDetailByID([FromQuery][Required] IDUnderCorpInput input)
        {
            var model = new Service.Station().GetByID(input.CorpID, input.ID);
            return model == null ? null : new DemoStationDetailDto(model);
        }
 
    }
}