tangxu
2022-10-24 1682e6f97774455726d63a856b9b5f724ce3263f
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
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/Home")]
    [ApiDescriptionSettings("LargeScreen", Name = "Demo(主页)", Order = 666)]
    public class DemoHome_Controller : IDynamicApiController, ITransient
    {
        private readonly IHttpContextAccessor _httpContextAccessor; 
 
        /// <summary>
        /// 
        /// </summary>
        public DemoHome_Controller(IHttpContextAccessor httpContextAccessor)
        {
            _httpContextAccessor = httpContextAccessor;
        }
 
        /// <summary>
        /// 获取泵站主页汇总信息(左上部分)
        /// </summary>
        /// <returns></returns>
        [Route("GetLeftTopInfo")]
        [HttpGet]
        public DemoHomeLeftTopInfoDto GetLeftTopInfo()
        {
            DemoHomeLeftTopInfoDto info_list = new DemoHomeLeftTopInfoDto();
            var r = new Random();
            info_list.StationNumber = 10;
            info_list.PumpNumber = r.Next(35, 42).ToString() + "/50";
            info_list.TotalSupplyWater = r.Next(4535, 4642);
            info_list.TotalEnergyConsumption = r.Next(12535, 12642);
 
            info_list.YesterdayUnitEnergyConsumption = r.Next(883, 915) / 10.0;
            info_list.YesterdayEnergyConsumption = r.Next(2860, 2965);
            info_list.YesterdaySupplyWater = r.Next(2600, 2800);
            return info_list;
        }
 
        /// <summary>
        /// 获取泵站数据分析汇总信息(左中部分)
        /// </summary>
        /// <param name="StaticType">汇总类型(1按日  2 按周 3 按月 4 按年)</param> 
        [Route("GetLeftMiddleInfo")]
        [HttpGet]
        public List<DemoHomeLeftMiddleItemInfoDto> GetLeftMiddleInfo(int StaticType)
        {
            var r = new Random();
            List<DemoHomeLeftMiddleItemInfoDto> info_list = new List<DemoHomeLeftMiddleItemInfoDto>();
            if (StaticType == 1 || StaticType <= 0)
            {
                for (DateTime day = DateTime.Today.AddMonths(-1); day < DateTime.Today; day = day.AddDays(1))
                {
                    DemoHomeLeftMiddleItemInfoDto item = new DemoHomeLeftMiddleItemInfoDto();
                    item.Label = day.ToString("yyyy-MM-dd");
                    item.SupplyWater = r.Next(2600, 2800);
                    item.EnergyConsumption = r.Next(2860, 2965);
                    info_list.Add(item);
                }
            }
            else if (StaticType == 3 || StaticType == 2)
            {//2按月
                for (int month = 1; month < DateTime.Today.Month; month = month + 1)
                {
                    DemoHomeLeftMiddleItemInfoDto item = new DemoHomeLeftMiddleItemInfoDto();
                    item.Label = month.ToString();
                    item.SupplyWater = r.Next(2600, 2800) * 30;
                    item.EnergyConsumption = r.Next(2860, 2965) * 30;
                    info_list.Add(item);
                }
            }
            else
            {//4 按年
                for (int year = 1; year < 4; year = year + 1)
                {
                    DemoHomeLeftMiddleItemInfoDto item = new DemoHomeLeftMiddleItemInfoDto();
                    item.Label = (DateTime.Today.Year - 3 + year).ToString();
                    item.SupplyWater = r.Next(2600, 2800) * 300;
                    item.EnergyConsumption = r.Next(2860, 2965) * 300;
                    info_list.Add(item);
                }
            }
            return info_list;
        }
 
        /// <summary>
        /// 获取泵站数据分析明细信息(左下部分)
        /// </summary>
        /// <param name="StaticType">汇总类型(1按日  2 按周 3 按月 4 按年)</param> 
        [Route("GetLeftBottomInfo")]
        [HttpGet]
        public List<DemoHomeLeftBottomItemInfoDto> GetLeftBottomInfo(int StaticType)
        {
            var r = new Random();
            List<DemoHomeLeftBottomItemInfoDto> info_list = new List<DemoHomeLeftBottomItemInfoDto>();
 
            int ratio = 1;
            if (StaticType == 2)
                ratio = 7;
            if (StaticType == 3)
                ratio = 30;
            if (StaticType == 4)
                ratio = 350;
            List<string> station_name_list = new List<string>() { "松花江泵站", "市南泵站", "市北泵站", "鸭绿江泵站", "南大泵站" };
            int ID = 1;
            foreach (var name in station_name_list)
            {
                DemoHomeLeftBottomItemInfoDto item = new DemoHomeLeftBottomItemInfoDto();
                item.ID = ID;
                item.Name = name;
                item.SupplyWater = r.Next(2600, 2800) * ratio;
                item.EnergyConsumption = r.Next(2860, 2965) * ratio;
                item.UnitEnergyConsumption = r.Next(883, 915) / 10.0;
                info_list.Add(item);
 
                ID++;
            }
 
            return info_list;
        }
 
        /// <summary>
        /// 获取首页报警和信息公告(中间底部)
        /// </summary>
        /// <param name="InfoType">信息类型(1信息  2报警)</param> 
        [Route("GetCenterBottomInfo")]
        [HttpGet]
        public List<DemoHomeCenterBottomItemInfoDto> GetCenterBottomInfo(int InfoType)
        {
            var r = new Random();
            List<DemoHomeCenterBottomItemInfoDto> info_list = new List<DemoHomeCenterBottomItemInfoDto>();
 
            if (InfoType == 1)
            {
                DemoHomeCenterBottomItemInfoDto item1 = new DemoHomeCenterBottomItemInfoDto();
                item1.Title = "松花江";
                item1.UserName = "管理员";
                item1.Content = "2020年8月26日,控江路管道维修抢修完成。";
                info_list.Add(item1);
 
                DemoHomeCenterBottomItemInfoDto item2 = new DemoHomeCenterBottomItemInfoDto();
                item2.Title = "市南泵站";
                item2.UserName = "管理员";
                item2.Content = "2020年9月11日,二号泵电机振动过大,进行大修。";
                info_list.Add(item2);
 
 
                DemoHomeCenterBottomItemInfoDto item3 = new DemoHomeCenterBottomItemInfoDto();
                item3.Title = "管网";
                item3.UserName = "管理员";
                item3.Content = "2020年9月22日,巡检员张坤成在人民广场附件发现曝管。";
                info_list.Add(item2);
            }
            else
            {
                DemoHomeCenterBottomItemInfoDto item1 = new DemoHomeCenterBottomItemInfoDto();
                item1.Title = "松花江";
                item1.UserName = "李三林";
                item1.Content = "2020年9月20日 12时30分,一号机漏水严重。";
                info_list.Add(item1);
 
                DemoHomeCenterBottomItemInfoDto item2 = new DemoHomeCenterBottomItemInfoDto();
                item2.Title = "松花江";
                item2.UserName = "李三林";
                item2.Content = "2020年9月21日 12时30分,一号机漏水严重。";
                info_list.Add(item2);
 
 
                DemoHomeCenterBottomItemInfoDto item3 = new DemoHomeCenterBottomItemInfoDto();
                item3.Title = "市南泵站";
                item3.UserName = "管理员";
                item3.Content = "2020年9月25日 12时30分,二号电机电流超标。";
                info_list.Add(item2);
            }
 
 
            return info_list;
        }
 
        /// <summary>
        /// 获取表单状态统计占比(右部上)
        /// </summary>
        /// <param name="StaticType">统计类型(1按日  2 按周 3 按月 4 按年) </param> 
        [Route("GetRightTopInfo")]
        [HttpGet]
        public DemoHomeRightTopInfoDto GetRightTopInfo(int StaticType)
        {
            var r = new Random();
            int ratio = 1;
            if (StaticType == 2)
                ratio = 5;
            if (StaticType == 3)
                ratio = 20;
            if (StaticType == 4)
                ratio = 250;
 
            DemoHomeRightTopInfoDto item1 = new DemoHomeRightTopInfoDto();
 
            item1.ProcessedForm = r.Next(6, 10) * ratio;
            item1.ProcessingForm = r.Next(4, 8) * ratio;
            item1.UnProcessingForm = r.Next(3, 7) * ratio;
            item1.TotalForm = item1.ProcessedForm + item1.ProcessingForm + item1.UnProcessingForm;
 
            return item1;
        }
 
 
        /// <summary>
        /// 获取表单类型统计占比(右部中)
        /// </summary>
        /// <param name="StaticType">统计类型(1按日  2 按周 3 按月 4 按年)</param> 
        [Route("GetRightCenterInfo")]
        [HttpGet]
        public List<DemoHomeRightCenterInfoDto> GetRightCenterInfo(int StaticType)
        {
            var r = new Random();
            List<DemoHomeRightCenterInfoDto> info_list = new List<DemoHomeRightCenterInfoDto>();
            int ratio = 1;
            if (StaticType == 2)
                ratio = 7;
            if (StaticType == 3)
                ratio = 30;
            if (StaticType == 4)
                ratio = 350;
 
 
            DemoHomeRightCenterInfoDto item1 = new DemoHomeRightCenterInfoDto();
            item1.Label = "机组故障";
            item1.Number = r.Next(8, 11) * ratio;
            info_list.Add(item1);
 
 
            DemoHomeRightCenterInfoDto item2 = new DemoHomeRightCenterInfoDto();
            item2.Label = "管道维修";
            item2.Number = r.Next(2, 5) * ratio;
            info_list.Add(item2);
 
 
            DemoHomeRightCenterInfoDto item3 = new DemoHomeRightCenterInfoDto();
            item3.Label = "阀门维修";
            item3.Number = r.Next(1, 3) * ratio;
            info_list.Add(item3);
 
            DemoHomeRightCenterInfoDto item4 = new DemoHomeRightCenterInfoDto();
            item4.Label = "仪表";
            item4.Number = r.Next(2, 4) * ratio;
            info_list.Add(item4);
 
            DemoHomeRightCenterInfoDto item5 = new DemoHomeRightCenterInfoDto();
            item5.Label = "其他";
            item5.Number = r.Next(5, 12) * ratio;
            info_list.Add(item5);
            return info_list;
        }
 
    }
}