奥体项目实时数据接口开发
正在显示
2 个修改的文件
包含
177 行增加
和
26 行删除
1 | package com.skua.modules.business.entity; | ||
2 | |||
3 | import com.baomidou.mybatisplus.annotation.IdType; | ||
4 | import com.baomidou.mybatisplus.annotation.TableId; | ||
5 | import com.baomidou.mybatisplus.annotation.TableName; | ||
6 | import com.fasterxml.jackson.annotation.JsonFormat; | ||
7 | import io.swagger.annotations.ApiModel; | ||
8 | import io.swagger.annotations.ApiModelProperty; | ||
9 | import lombok.Data; | ||
10 | import lombok.EqualsAndHashCode; | ||
11 | import lombok.experimental.Accessors; | ||
12 | import org.jeecgframework.poi.excel.annotation.Excel; | ||
13 | import org.springframework.format.annotation.DateTimeFormat; | ||
14 | |||
15 | import java.util.Date; | ||
16 | |||
17 | /** | ||
18 | * 奥体资产管理 | ||
19 | */ | ||
20 | @Data | ||
21 | @TableName("what_struct_data") | ||
22 | @ApiModel(value="what_struct_data对象", description="奥体资产管理") | ||
23 | public class WhatStructData { | ||
24 | |||
25 | /**主键id*/ | ||
26 | @TableId(type = IdType.UUID) | ||
27 | @ApiModelProperty(value = "主键id") | ||
28 | private String id; | ||
29 | /**设备编码*/ | ||
30 | @ApiModelProperty(value = "设备编码") | ||
31 | private String equipCode; | ||
32 | /**设备类型*/ | ||
33 | @ApiModelProperty(value = "设备类型") | ||
34 | private String equipType; | ||
35 | /**所属系统*/ | ||
36 | @ApiModelProperty(value = "所属系统") | ||
37 | private String systemCode; | ||
38 | /**点表ID*/ | ||
39 | @ApiModelProperty(value = "点表ID") | ||
40 | private String monitorId; | ||
41 | /**点类型*/ | ||
42 | @ApiModelProperty(value = "点类型") | ||
43 | private String monitorType; | ||
44 | /**点实时值*/ | ||
45 | @ApiModelProperty(value = "点实时值") | ||
46 | private String monitorValue; | ||
47 | /**所属泵站*/ | ||
48 | @ApiModelProperty(value = "所属泵站") | ||
49 | private String pumpCode; | ||
50 | /**备注*/ | ||
51 | @ApiModelProperty(value = "备注") | ||
52 | private String remark; | ||
53 | /**创建人id*/ | ||
54 | @ApiModelProperty(value = "创建人id") | ||
55 | private String createBy; | ||
56 | /**创建时间*/ | ||
57 | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") | ||
58 | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") | ||
59 | @ApiModelProperty(value = "创建时间") | ||
60 | private Date createTime; | ||
61 | /**修改人id*/ | ||
62 | @ApiModelProperty(value = "修改人id") | ||
63 | private String updateBy; | ||
64 | /**修改时间*/ | ||
65 | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") | ||
66 | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") | ||
67 | @ApiModelProperty(value = "修改时间") | ||
68 | private Date updateTime; | ||
69 | /**所属部门*/ | ||
70 | @ApiModelProperty(value = "所属部门") | ||
71 | private String createDept; | ||
72 | /**所属公司*/ | ||
73 | @ApiModelProperty(value = "所属公司") | ||
74 | private String createCmpy; | ||
75 | /**删除标识*/ | ||
76 | @ApiModelProperty(value = "删除标识") | ||
77 | private Integer delFlag; | ||
78 | } |
... | @@ -7,15 +7,19 @@ import com.skua.modules.business.mapper.WhatStructDataMapper; | ... | @@ -7,15 +7,19 @@ import com.skua.modules.business.mapper.WhatStructDataMapper; |
7 | import com.skua.modules.business.service.IOlympicCenterService; | 7 | import com.skua.modules.business.service.IOlympicCenterService; |
8 | import com.skua.modules.business.vo.EchartResult; | 8 | import com.skua.modules.business.vo.EchartResult; |
9 | import com.skua.modules.business.vo.TextResult; | 9 | import com.skua.modules.business.vo.TextResult; |
10 | import lombok.extern.slf4j.Slf4j; | ||
10 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
11 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
12 | 13 | ||
14 | import java.text.DateFormat; | ||
15 | import java.text.ParseException; | ||
13 | import java.text.SimpleDateFormat; | 16 | import java.text.SimpleDateFormat; |
14 | import java.util.*; | 17 | import java.util.*; |
15 | 18 | ||
16 | /** | 19 | /** |
17 | * 武汉奥体中心接口 | 20 | * 武汉奥体中心接口 |
18 | */ | 21 | */ |
22 | @Slf4j | ||
19 | @Service | 23 | @Service |
20 | public class OlympicCenterServiceImpl implements IOlympicCenterService { | 24 | public class OlympicCenterServiceImpl implements IOlympicCenterService { |
21 | 25 | ||
... | @@ -224,26 +228,88 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { | ... | @@ -224,26 +228,88 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { |
224 | 228 | ||
225 | @Override | 229 | @Override |
226 | public List<EchartResult> getWaterChart(String sourceType, String dateType, String start, String end) { | 230 | public List<EchartResult> getWaterChart(String sourceType, String dateType, String start, String end) { |
231 | DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); | ||
227 | List<EchartResult> list = new ArrayList<>(); | 232 | List<EchartResult> list = new ArrayList<>(); |
228 | for (int i = 0; i < 30; i++) { | 233 | if("30".equals(dateType)){ |
229 | Calendar date = Calendar.getInstance(); | 234 | Calendar date = Calendar.getInstance(); |
230 | date.add(Calendar.DATE, i-30); | 235 | date.add(Calendar.DATE, -30); |
231 | String newDate = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime()).substring(5,10); | 236 | start = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime()); |
232 | EchartResult rgsResult = new EchartResult(); | 237 | end = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
233 | rgsResult.setName(newDate); | 238 | }else{ |
234 | rgsResult.setValue(formatDouble(100*getRandom(2.00,3.00)).toString()); | 239 | if(start==null||end==null){ |
235 | rgsResult.setSeries("日供水量"); | 240 | Calendar date = Calendar.getInstance(); |
236 | list.add(rgsResult); | 241 | date.add(Calendar.DATE, -30); |
237 | EchartResult shResult = new EchartResult(); | 242 | start = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime()); |
238 | shResult.setName(newDate); | 243 | end = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
239 | shResult.setValue(formatDouble(getRandom(4.00,8.00)).toString()); | 244 | } |
240 | shResult.setSeries("生活用水"); | 245 | } |
241 | list.add(shResult); | 246 | try{ |
242 | EchartResult xzResult = new EchartResult(); | 247 | Long startTime = df.parse(start).getTime(); |
243 | xzResult.setName(newDate); | 248 | Long endTime = df.parse(end).getTime(); |
244 | xzResult.setValue(formatDouble(getRandom(4.00,8.00)).toString()); | 249 | Long oneDay = 1000 * 60 * 60 * 24l; |
245 | xzResult.setSeries("行政用水"); | 250 | Long time = startTime; |
246 | list.add(xzResult); | 251 | if("feed".equals(sourceType)){ |
252 | while (time <= endTime) { | ||
253 | Date d = new Date(time); | ||
254 | String newDate = df.format(d).substring(5,10); | ||
255 | EchartResult rgsResult = new EchartResult(); | ||
256 | rgsResult.setName(newDate); | ||
257 | rgsResult.setValue(formatDouble(100*getRandom(2.00,3.00)).toString()); | ||
258 | rgsResult.setSeries("日供水量"); | ||
259 | list.add(rgsResult); | ||
260 | EchartResult shResult = new EchartResult(); | ||
261 | shResult.setName(newDate); | ||
262 | shResult.setValue(formatDouble(getRandom(4.00,8.00)).toString()); | ||
263 | shResult.setSeries("生活用水1"); | ||
264 | list.add(shResult); | ||
265 | EchartResult xzResult = new EchartResult(); | ||
266 | xzResult.setName(newDate); | ||
267 | xzResult.setValue(formatDouble(getRandom(4.00,8.00)).toString()); | ||
268 | xzResult.setSeries("生活用水2"); | ||
269 | list.add(xzResult); | ||
270 | time += oneDay; | ||
271 | } | ||
272 | }else if("hot".equals(sourceType)){ | ||
273 | while (time <= endTime) { | ||
274 | Date d = new Date(time); | ||
275 | String newDate = df.format(d).substring(5,10); | ||
276 | EchartResult rgsResult = new EchartResult(); | ||
277 | rgsResult.setName(newDate); | ||
278 | rgsResult.setValue(formatDouble(100*getRandom(2.00,3.00)).toString()); | ||
279 | rgsResult.setSeries("日供水量"); | ||
280 | list.add(rgsResult); | ||
281 | time += oneDay; | ||
282 | } | ||
283 | }else if("fire".equals(sourceType)){ | ||
284 | while (time <= endTime) { | ||
285 | Date d = new Date(time); | ||
286 | String newDate = df.format(d).substring(5,10); | ||
287 | EchartResult shResult = new EchartResult(); | ||
288 | shResult.setName(newDate); | ||
289 | shResult.setValue(formatDouble(getRandom(4.00,8.00)).toString()); | ||
290 | shResult.setSeries("表1"); | ||
291 | list.add(shResult); | ||
292 | EchartResult xzResult = new EchartResult(); | ||
293 | xzResult.setName(newDate); | ||
294 | xzResult.setValue(formatDouble(getRandom(4.00,8.00)).toString()); | ||
295 | xzResult.setSeries("表2"); | ||
296 | list.add(xzResult); | ||
297 | time += oneDay; | ||
298 | } | ||
299 | }else{ | ||
300 | while (time <= endTime) { | ||
301 | Date d = new Date(time); | ||
302 | String newDate = df.format(d).substring(5,10); | ||
303 | EchartResult rgsResult = new EchartResult(); | ||
304 | rgsResult.setName(newDate); | ||
305 | rgsResult.setValue("--"); | ||
306 | rgsResult.setSeries("--"); | ||
307 | list.add(rgsResult); | ||
308 | time += oneDay; | ||
309 | } | ||
310 | } | ||
311 | }catch (Exception e){ | ||
312 | log.error(e.getMessage()); | ||
247 | } | 313 | } |
248 | return list; | 314 | return list; |
249 | } | 315 | } |
... | @@ -305,14 +371,21 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { | ... | @@ -305,14 +371,21 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { |
305 | return list; | 371 | return list; |
306 | } | 372 | } |
307 | 373 | ||
308 | public static void main(String[] args) { | 374 | public static void main(String[] args) throws ParseException { |
309 | Calendar cal = Calendar.getInstance(); | 375 | DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
310 | cal.add(Calendar.DATE, -7); | 376 | String start = "2023-04-01"; |
311 | String startDate = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()); | 377 | String end = "2023-04-24"; |
312 | String start = startDate + " 00:00:00"; | 378 | |
313 | String endDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); | 379 | Long startTime = df.parse(start).getTime(); |
314 | String end = endDate + " 23:59:59"; | 380 | Long endTime = df.parse(end).getTime(); |
315 | System.out.println(start+"-----"+end); | 381 | Long oneDay = 1000 * 60 * 60 * 24l; |
382 | |||
383 | Long time = startTime; | ||
384 | while (time <= endTime) { | ||
385 | Date d = new Date(time); | ||
386 | System.out.println(df.format(d)); | ||
387 | time += oneDay; | ||
388 | } | ||
316 | } | 389 | } |
317 | 390 | ||
318 | @Override | 391 | @Override | ... | ... |
-
请 注册 或 登录 后发表评论