78eebf40 张雷

奥体项目数据报表时间修改

1 个父辈 9873efc0
...@@ -4,6 +4,7 @@ import com.skua.core.api.vo.Result; ...@@ -4,6 +4,7 @@ import com.skua.core.api.vo.Result;
4 import com.skua.modules.business.service.IOlympicCenterService; 4 import com.skua.modules.business.service.IOlympicCenterService;
5 import com.skua.modules.business.service.ISynthesizeService; 5 import com.skua.modules.business.service.ISynthesizeService;
6 import com.skua.modules.business.vo.EchartResult; 6 import com.skua.modules.business.vo.EchartResult;
7 import com.skua.modules.business.vo.InputQueryParams;
7 import io.swagger.annotations.Api; 8 import io.swagger.annotations.Api;
8 import io.swagger.annotations.ApiOperation; 9 import io.swagger.annotations.ApiOperation;
9 import lombok.extern.slf4j.Slf4j; 10 import lombok.extern.slf4j.Slf4j;
...@@ -204,4 +205,25 @@ public class OlympicCenterController { ...@@ -204,4 +205,25 @@ public class OlympicCenterController {
204 return result; 205 return result;
205 } 206 }
206 207
208 @ApiOperation(value="获取系统的压力和流量趋势图", notes="获取系统的压力和流量趋势图")
209 @GetMapping(value = "/getPumpOrFlowChart")
210 public Result<Map<String,Object>> getPumpOrFlowChart(InputQueryParams inputQueryParams){
211 Result<Map<String,Object>> result = new Result<Map<String,Object>>();
212 Map<String,Object> map = olympicCenterService.getPumpOrFlowChart(inputQueryParams);
213 result.setResult(map);
214 result.setSuccess(true);
215 return result;
216 }
217
218 @ApiOperation(value="获取趋势图", notes="获取趋势图")
219 @GetMapping(value = "/getHistoryTrendsByDate")
220 public Result<List<EchartResult>> getHistoryTrendsByDate(InputQueryParams inputQueryParams){
221 Result<List<EchartResult>> result = new Result<List<EchartResult>>();
222 List<EchartResult> list = new ArrayList<EchartResult>();
223 list = olympicCenterService.getHistoryTrendsByDate(inputQueryParams);
224 result.setResult(list);
225 result.setSuccess(true);
226 return result;
227 }
228
207 } 229 }
......
...@@ -31,4 +31,6 @@ public interface WhatStructDataMapper { ...@@ -31,4 +31,6 @@ public interface WhatStructDataMapper {
31 List<WhatStructData> getEquipDataList(@Param("sourceType") String sourceType, @Param("pumpId") String pumpId); 31 List<WhatStructData> getEquipDataList(@Param("sourceType") String sourceType, @Param("pumpId") String pumpId);
32 32
33 List<WhatStructData> getEquipDataListBySource(@Param("sourceType") String sourceType); 33 List<WhatStructData> getEquipDataListBySource(@Param("sourceType") String sourceType);
34
35 List<WhatStructData> getSumEquipListBySource(@Param("sourceType") String sourceType);
34 } 36 }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
15 </select> 15 </select>
16 16
17 <select id="getListByType" resultType="com.skua.modules.business.entity.WhatStructData"> 17 <select id="getListByType" resultType="com.skua.modules.business.entity.WhatStructData">
18 select * from what_struct_data_bak 18 select * from what_struct_data
19 where 1=1 19 where 1=1
20 <if test="sourceType!=null and sourceType!=''"> 20 <if test="sourceType!=null and sourceType!=''">
21 and system_code = #{sourceType} 21 and system_code = #{sourceType}
...@@ -24,44 +24,54 @@ ...@@ -24,44 +24,54 @@
24 </select> 24 </select>
25 25
26 <select id="getDataList" resultType="com.skua.modules.business.entity.WhatStructData"> 26 <select id="getDataList" resultType="com.skua.modules.business.entity.WhatStructData">
27 select * from what_struct_data_bak 27 select * from what_struct_data
28 where id LIKE CONCAT( #{equipId},'%') 28 where id LIKE CONCAT( #{equipId},'%')
29 order by monitor_sort 29 order by monitor_sort
30 </select> 30 </select>
31 31
32 <select id="getListForUENew" resultType="com.skua.modules.business.entity.WhatStructData"> 32 <select id="getListForUENew" resultType="com.skua.modules.business.entity.WhatStructData">
33 select * from what_struct_data_bak order by monitor_sort 33 select * from what_struct_data order by monitor_sort
34 </select> 34 </select>
35 35
36 <select id="getFlowList" resultType="com.skua.modules.business.entity.WhatStructData"> 36 <select id="getFlowList" resultType="com.skua.modules.business.entity.WhatStructData">
37 select * from what_struct_data_bak where equip_type like CONCAT('flow','%') 37 select * from what_struct_data where equip_type like CONCAT('flow','%')
38 <if test="loction!=null and loction!=''"> 38 <if test="loction!=null and loction!=''">
39 and pump_code = #{loction} 39 and pump_code = #{loction}
40 </if> 40 </if>
41 </select> 41 </select>
42 42
43 <select id="getPressureList" resultType="com.skua.modules.business.entity.WhatStructData"> 43 <select id="getPressureList" resultType="com.skua.modules.business.entity.WhatStructData">
44 select * from what_struct_data_bak where equip_type like CONCAT('pressure','%') 44 select * from what_struct_data where equip_type like CONCAT('pressure','%')
45 <if test="loction!=null and loction!=''"> 45 <if test="loction!=null and loction!=''">
46 and pump_code = #{loction} 46 and pump_code = #{loction}
47 </if> 47 </if>
48 </select> 48 </select>
49 49
50 <select id="getTemperatureList" resultType="com.skua.modules.business.entity.WhatStructData"> 50 <select id="getTemperatureList" resultType="com.skua.modules.business.entity.WhatStructData">
51 select * from what_struct_data_bak where equip_type like CONCAT('temperature','%') 51 select * from what_struct_data where equip_type like CONCAT('temperature','%')
52 <if test="loction!=null and loction!=''"> 52 <if test="loction!=null and loction!=''">
53 and pump_code = #{loction} 53 and pump_code = #{loction}
54 </if> 54 </if>
55 </select> 55 </select>
56 56
57 <select id="getEquipDataList" resultType="com.skua.modules.business.entity.WhatStructData"> 57 <select id="getEquipDataList" resultType="com.skua.modules.business.entity.WhatStructData">
58 select * from what_struct_data_bak 58 select * from what_struct_data
59 where pump_code = #{sourceType} and equip_code = #{pumpId} 59 where pump_code = #{sourceType} and equip_code = #{pumpId}
60 </select> 60 </select>
61 61
62 <select id="getEquipDataListBySource" resultType="com.skua.modules.business.entity.WhatStructData"> 62 <select id="getEquipDataListBySource" resultType="com.skua.modules.business.entity.WhatStructData">
63 select * from what_struct_data_bak 63 select * from what_struct_data
64 where pump_code = #{sourceType} 64 where pump_code = #{sourceType}
65 </select> 65 </select>
66 66
67 <select id="getSumEquipListBySource" resultType="com.skua.modules.business.entity.WhatStructData">
68 SELECT
69 *
70 FROM
71 what_struct_data
72 WHERE
73 system_code = #{sourceType}
74 AND is_sum = 1
75 </select>
76
67 </mapper> 77 </mapper>
...\ No newline at end of file ...\ No newline at end of file
......
1 package com.skua.modules.business.service; 1 package com.skua.modules.business.service;
2 2
3 import com.skua.modules.business.vo.EchartResult; 3 import com.skua.modules.business.vo.EchartResult;
4 import com.skua.modules.business.vo.InputQueryParams;
4 5
5 import java.util.List; 6 import java.util.List;
6 import java.util.Map; 7 import java.util.Map;
...@@ -39,4 +40,8 @@ public interface IOlympicCenterService { ...@@ -39,4 +40,8 @@ public interface IOlympicCenterService {
39 List<Map<String, Object>> getHistoryReportClos(String dataType, String loction); 40 List<Map<String, Object>> getHistoryReportClos(String dataType, String loction);
40 41
41 List<Map<String, Object>> getHistoryReportData(String dataType, String loction); 42 List<Map<String, Object>> getHistoryReportData(String dataType, String loction);
43
44 Map<String, Object> getPumpOrFlowChart(InputQueryParams inputQueryParams);
45
46 List<EchartResult> getHistoryTrendsByDate(InputQueryParams inputQueryParams);
42 } 47 }
......
...@@ -5,6 +5,7 @@ import com.skua.modules.business.entity.WhatStructData; ...@@ -5,6 +5,7 @@ import com.skua.modules.business.entity.WhatStructData;
5 import com.skua.modules.business.mapper.WhatStructDataMapper; 5 import com.skua.modules.business.mapper.WhatStructDataMapper;
6 import com.skua.modules.business.service.IOlympicCenterService; 6 import com.skua.modules.business.service.IOlympicCenterService;
7 import com.skua.modules.business.vo.EchartResult; 7 import com.skua.modules.business.vo.EchartResult;
8 import com.skua.modules.business.vo.InputQueryParams;
8 import com.skua.modules.business.vo.TextResult; 9 import com.skua.modules.business.vo.TextResult;
9 import com.skua.modules.monitor.service.IFmPgQueryService; 10 import com.skua.modules.monitor.service.IFmPgQueryService;
10 import lombok.extern.slf4j.Slf4j; 11 import lombok.extern.slf4j.Slf4j;
...@@ -296,6 +297,12 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { ...@@ -296,6 +297,12 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
296 start = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime()); 297 start = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime());
297 end = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); 298 end = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
298 } 299 }
300 if("".equals(start)||"".equals(end)){
301 Calendar date = Calendar.getInstance();
302 date.add(Calendar.DATE, -30);
303 start = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime());
304 end = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
305 }
299 } 306 }
300 try{ 307 try{
301 Long startTime = df.parse(start).getTime(); 308 Long startTime = df.parse(start).getTime();
...@@ -890,8 +897,12 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { ...@@ -890,8 +897,12 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
890 EchartResult echartResult = new EchartResult(); 897 EchartResult echartResult = new EchartResult();
891 echartResult.setName(map.get("time").toString()); 898 echartResult.setName(map.get("time").toString());
892 if("p".equals(type)){ 899 if("p".equals(type)){
893 double pResult = formatDouble(Double.parseDouble(map.get(wList.get(0).getMonitorId()).toString())*Double.parseDouble(wList.get(0).getMonitorZoom())); 900 if(map.get(wList.get(0).getMonitorId())==null){
894 echartResult.setValue(String.valueOf(pResult)); 901 echartResult.setValue("");
902 }else{
903 double pResult = formatDouble(Double.parseDouble(map.get(wList.get(0).getMonitorId()).toString())*Double.parseDouble(wList.get(0).getMonitorZoom()));
904 echartResult.setValue(String.valueOf(pResult));
905 }
895 echartResult.setSeries("压力表"); 906 echartResult.setSeries("压力表");
896 list.add(echartResult); 907 list.add(echartResult);
897 }else if("f".equals(type)){ 908 }else if("f".equals(type)){
...@@ -1352,6 +1363,204 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { ...@@ -1352,6 +1363,204 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
1352 return list; 1363 return list;
1353 } 1364 }
1354 1365
1366 @Override
1367 public Map<String, Object> getPumpOrFlowChart(InputQueryParams inputQueryParams) {
1368 Map<String, Object> map = new HashMap<>();
1369 Map<String, Object> monitorMap = new HashMap<>();
1370 List<Map<String, Object>> pumpList = new ArrayList<>();
1371 List<Map<String, Object>> flowList = new ArrayList<>();
1372 map.put("pump", new ArrayList<>());
1373 map.put("flow", new ArrayList<>());
1374 String timeStep = "hour";
1375 Calendar cal = Calendar.getInstance();
1376 cal.add(Calendar.DATE, -7);
1377 String startDate = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
1378 String start = startDate + " 00:00:00";
1379 String endDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
1380 String end = endDate + " 23:59:59";
1381 String timeType = inputQueryParams.getTimeType();
1382 if("today".equals(timeType)){
1383 timeStep = "hour";
1384 start = endDate + " 00:00:00";
1385 end = endDate + " 23:59:59";
1386 }else if("week".equals(timeType)){
1387 timeStep = "hour";
1388 }else if("month".equals(timeType)){
1389 timeStep = "day";
1390 cal.add(Calendar.DATE, -30);
1391 start = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()) + " 00:00:00";
1392 end = endDate + " 23:59:59";
1393 }else if("6month".equals(timeType)){
1394 timeStep = "day";
1395 cal.add(Calendar.DATE, -180);
1396 start = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()) + " 00:00:00";
1397 end = endDate + " 23:59:59";
1398 }else if("custom".equals(timeType)){
1399 timeStep = "day";
1400 start = inputQueryParams.getStart();
1401 end = inputQueryParams.getEnd();
1402 }else {
1403 timeStep = "day";
1404 }
1405 String sourceType = inputQueryParams.getSourceType();
1406 List<WhatStructData> equipList = whatStructDataMapper.getSumEquipListBySource(sourceType);
1407 String pPgField = "";
1408 String fPgField = "";
1409 if(equipList.size() == 0){
1410 return map;
1411 }else{
1412 for (WhatStructData whatStructData:equipList) {
1413 if("flow".equals(whatStructData.getEquipType())){
1414 fPgField = fPgField +","+whatStructData.getMonitorId();
1415 }else if("pressure".equals(whatStructData.getEquipType())){
1416 pPgField = pPgField +","+whatStructData.getMonitorId();
1417 }else{}
1418 if(whatStructData.getMonitorId()!=null){
1419 monitorMap.put(whatStructData.getMonitorId(),whatStructData.getId());
1420 }
1421 }
1422 }
1423 List<Map<String, Object>> pDataList = factoryInfoService.queryReportData(AT_ID, pPgField, start, end, timeStep);
1424 for (Map<String, Object> bmap : pDataList) {
1425 Map<String, Object> newMap = new HashMap<>();
1426 for (Map.Entry<String, Object> entry : bmap.entrySet()) {
1427 if("time".equals(entry.getKey())){
1428 newMap.put(entry.getKey(),entry.getValue());
1429 }else {
1430 newMap.put(monitorMap.get(entry.getKey()).toString(),entry.getValue());
1431 }
1432 }
1433 pumpList.add(newMap);
1434 }
1435 List<Map<String, Object>> fDataList = factoryInfoService.queryReportData(AT_ID, fPgField, start, end, timeStep);
1436 for (Map<String, Object> bmap : fDataList) {
1437 Map<String, Object> newMap = new HashMap<>();
1438 for (Map.Entry<String, Object> entry : bmap.entrySet()) {
1439 if("time".equals(entry.getKey())){
1440 newMap.put(entry.getKey(),entry.getValue());
1441 }else {
1442 newMap.put(monitorMap.get(entry.getKey()).toString(),entry.getValue());
1443 }
1444 }
1445 flowList.add(newMap);
1446 }
1447 map.put("pump", pumpList);
1448 map.put("flow", flowList);
1449 return map;
1450 }
1451
1452 @Override
1453 public List<EchartResult> getHistoryTrendsByDate(InputQueryParams inputQueryParams) {
1454 List<EchartResult> list = new ArrayList<>();
1455 String type = inputQueryParams.getEquipType();
1456 List<WhatStructData> wList = whatStructDataMapper.getDataList(inputQueryParams.getEquipId());
1457 String pgField = "";
1458 if(wList.size() == 0){
1459 return list;
1460 }else{
1461 for (WhatStructData whatStructData:wList) {
1462 pgField = pgField +","+whatStructData.getMonitorId();
1463 }
1464 }
1465 String timeStep = "hour";
1466 Calendar cal = Calendar.getInstance();
1467 cal.add(Calendar.DATE, -7);
1468 String startDate = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
1469 String start = startDate + " 00:00:00";
1470 String endDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
1471 String end = endDate + " 23:59:59";
1472 String timeType = inputQueryParams.getTimeType();
1473 if("today".equals(timeType)){
1474 timeStep = "hour";
1475 start = endDate + " 00:00:00";
1476 end = endDate + " 23:59:59";
1477 }else if("week".equals(timeType)){
1478 timeStep = "hour";
1479 }else if("month".equals(timeType)){
1480 timeStep = "day";
1481 cal.add(Calendar.DATE, -30);
1482 start = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()) + " 00:00:00";
1483 end = endDate + " 23:59:59";
1484 }else if("6month".equals(timeType)){
1485 timeStep = "day";
1486 cal.add(Calendar.DATE, -180);
1487 start = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()) + " 00:00:00";
1488 end = endDate + " 23:59:59";
1489 }else if("custom".equals(timeType)){
1490 timeStep = "day";
1491 start = inputQueryParams.getStart();
1492 end = inputQueryParams.getEnd();
1493 }else {
1494 timeStep = "day";
1495 }
1496 List<Map<String, Object>> dataList = factoryInfoService.queryReportData(AT_ID, pgField, start, end, timeStep);
1497 if(dataList.size()>0){
1498 for (Map<String, Object> map:dataList) {
1499 EchartResult echartResult = new EchartResult();
1500 echartResult.setName(map.get("time").toString());
1501 if("p".equals(type)){
1502 if(map.get(wList.get(0).getMonitorId())==null){
1503 echartResult.setValue("");
1504 }else{
1505 double pResult = formatDouble(Double.parseDouble(map.get(wList.get(0).getMonitorId()).toString())*Double.parseDouble(wList.get(0).getMonitorZoom()));
1506 echartResult.setValue(String.valueOf(pResult));
1507 }
1508 echartResult.setSeries("压力表");
1509 list.add(echartResult);
1510 }else if("f".equals(type)){
1511 for (WhatStructData whatStructData:wList) {
1512 EchartResult eResult = new EchartResult();
1513 eResult.setName(map.get("time").toString());
1514 if(whatStructData.getMonitorId()==null){
1515 eResult.setValue("");
1516 }else{
1517 eResult.setValue(map.get(whatStructData.getMonitorId()).toString());
1518 }
1519 if("flow".equals(whatStructData.getEquipType())){
1520 eResult.setSeries("瞬时流量");
1521 }else if("flow_ljll".equals(whatStructData.getEquipType())){
1522 eResult.setSeries("正向累计流量");
1523 }else if("flow_rljll".equals(whatStructData.getEquipType())){
1524 eResult.setSeries("反向累计流量");
1525 }else{
1526 eResult.setSeries(whatStructData.getEquipType());
1527 }
1528 list.add(eResult);
1529 }
1530 }else if("t".equals(type)){
1531 echartResult.setValue(map.get(wList.get(0).getMonitorId()).toString());
1532 echartResult.setSeries("温度计");
1533 list.add(echartResult);
1534 }else{
1535 echartResult.setValue("--");
1536 echartResult.setSeries("--");
1537 list.add(echartResult);
1538 }
1539
1540 }
1541 }else{
1542 for (int i = 0; i < 7; i++) {
1543 Calendar date = Calendar.getInstance();
1544 date.add(Calendar.DATE, i-7);
1545 String newDate = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime()).substring(5,10);
1546 EchartResult echartResult = new EchartResult();
1547 echartResult.setName(newDate);
1548 echartResult.setValue("--");
1549 if("p".equals(type)){
1550 echartResult.setSeries("压力表");
1551 }else if("f".equals(type)){
1552 echartResult.setSeries("流量计");
1553 }else if("t".equals(type)){
1554 echartResult.setSeries("温度计");
1555 }else{
1556 echartResult.setSeries("--");
1557 }
1558 list.add(echartResult);
1559 }
1560 }
1561 return list;
1562 }
1563
1355 private String getStatus1(Map<String, Object> map, List<Map<String, Object>> list, String pumpId) { 1564 private String getStatus1(Map<String, Object> map, List<Map<String, Object>> list, String pumpId) {
1356 String status = "停止"; 1565 String status = "停止";
1357 Map<String, Object> bean = list.get(0); 1566 Map<String, Object> bean = list.get(0);
......
1 package com.skua.modules.business.vo;
2
3 import lombok.Data;
4
5 /**
6 * 返回数据实体
7 */
8 @Data
9 public class InputQueryParams {
10
11 /**设备编码*/
12 private String equipId;
13 /**设备类型 压力:p,流量:f,温度:t*/
14 private String equipType;
15 /**系统类型*/
16 private String sourceType;
17 /**时间粒度 今日:today,本周:week,本月:month,近6月:6month,自定义:custom*/
18 private String timeType;
19 /**开始时间 yyyy-MM-DD*/
20 private String start;
21 /**结束时间 yyyy-MM-DD*/
22 private String end;
23 }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!