42db58e6 张雷

奥体项目接口开发

1 个父辈 5b848fa0
...@@ -31,19 +31,40 @@ public class OlympicCenterController { ...@@ -31,19 +31,40 @@ public class OlympicCenterController {
31 31
32 @ApiOperation(value="获取整体实时数据", notes="获取整体实时数据") 32 @ApiOperation(value="获取整体实时数据", notes="获取整体实时数据")
33 @GetMapping(value = "/getRealTimeData") 33 @GetMapping(value = "/getRealTimeData")
34 public Result<Map<String,Object>> getRealTimeData(){ 34 public Result<Map<String,Object>> getRealTimeData(String sourceType){
35 Result<Map<String,Object>> result = new Result<Map<String,Object>>(); 35 Result<Map<String,Object>> result = new Result<Map<String,Object>>();
36 Map<String,Object> map = olympicCenterService.getRealTimeData(); 36 Map<String,Object> map = olympicCenterService.getRealTimeData(sourceType);
37 result.setResult(map); 37 result.setResult(map);
38 result.setSuccess(true); 38 result.setSuccess(true);
39 return result; 39 return result;
40 } 40 }
41 41
42 @ApiOperation(value="获取指标历史趋势曲线", notes="获取指标历史趋势曲线") 42 /**
43 * 获取泵站指标历史趋势曲线
44 * @param field ssll:瞬时流量 ljll:累计流量 rll:日流量
45 * @param sourceType feed:给水泵房 hot:热水锅炉站 fire:消防泵站
46 * @return
47 */
48 @ApiOperation(value="获取泵站指标历史趋势曲线", notes="获取泵站指标历史趋势曲线")
43 @GetMapping(value = "/getHistoryData") 49 @GetMapping(value = "/getHistoryData")
44 public Result<Map<String,Object>> getHistoryData(String field){ 50 public Result<List<EchartResult>> getHistoryData(String field,String sourceType){
51 Result<List<EchartResult>> result = new Result<List<EchartResult>>();
52 List<EchartResult> list = olympicCenterService.getHistoryData(field,sourceType);
53 result.setResult(list);
54 result.setSuccess(true);
55 return result;
56 }
57
58 /**
59 * 获取泵站指标实时数据
60 * @param sourceType feed:给水泵房 hot:热水锅炉站 fire:消防泵站
61 * @return
62 */
63 @ApiOperation(value="获取泵站指标实时数据", notes="获取泵站指标实时数据")
64 @GetMapping(value = "/getBzRealTimeData")
65 public Result<Map<String,Object>> getBzRealTimeData(String sourceType){
45 Result<Map<String,Object>> result = new Result<Map<String,Object>>(); 66 Result<Map<String,Object>> result = new Result<Map<String,Object>>();
46 Map<String,Object> map = olympicCenterService.getHistoryData(field); 67 Map<String,Object> map = olympicCenterService.getBzRealTimeData(sourceType);
47 result.setResult(map); 68 result.setResult(map);
48 result.setSuccess(true); 69 result.setSuccess(true);
49 return result; 70 return result;
...@@ -60,12 +81,18 @@ public class OlympicCenterController { ...@@ -60,12 +81,18 @@ public class OlympicCenterController {
60 return result; 81 return result;
61 } 82 }
62 83
63 @ApiOperation(value="获取压力趋势图", notes="获取压力趋势图") 84 /**
85 * 获取趋势图
86 * @param equipId
87 * @param type p:压力 f:流量计 t:温度计
88 * @return
89 */
90 @ApiOperation(value="获取趋势图", notes="获取趋势图")
64 @GetMapping(value = "/getPressureChart") 91 @GetMapping(value = "/getPressureChart")
65 public Result<List<EchartResult>> getPressureChart(String equipId){ 92 public Result<List<EchartResult>> getPressureChart(String equipId,String type){
66 Result<List<EchartResult>> result = new Result<List<EchartResult>>(); 93 Result<List<EchartResult>> result = new Result<List<EchartResult>>();
67 List<EchartResult> list = new ArrayList<EchartResult>(); 94 List<EchartResult> list = new ArrayList<EchartResult>();
68 list = olympicCenterService.getPressureChart(equipId); 95 list = olympicCenterService.getPressureChart(equipId,type);
69 result.setResult(list); 96 result.setResult(list);
70 result.setSuccess(true); 97 result.setSuccess(true);
71 return result; 98 return result;
......
...@@ -10,11 +10,13 @@ import java.util.Map; ...@@ -10,11 +10,13 @@ import java.util.Map;
10 */ 10 */
11 public interface IOlympicCenterService { 11 public interface IOlympicCenterService {
12 12
13 Map<String,Object> getRealTimeData(); 13 Map<String,Object> getRealTimeData(String sourceType);
14 14
15 Map<String, Object> getHistoryData(String field); 15 List<EchartResult> getHistoryData(String field,String sourceType);
16 16
17 List<EchartResult> getWaterChart(String sourceType, String dateType, String start, String end); 17 List<EchartResult> getWaterChart(String sourceType, String dateType, String start, String end);
18 18
19 List<EchartResult> getPressureChart(String equipId); 19 List<EchartResult> getPressureChart(String equipId,String type);
20
21 Map<String, Object> getBzRealTimeData(String sourceType);
20 } 22 }
......
...@@ -3,6 +3,7 @@ package com.skua.modules.business.service.impl; ...@@ -3,6 +3,7 @@ package com.skua.modules.business.service.impl;
3 import com.skua.core.service.IPgQueryService; 3 import com.skua.core.service.IPgQueryService;
4 import com.skua.modules.business.service.IOlympicCenterService; 4 import com.skua.modules.business.service.IOlympicCenterService;
5 import com.skua.modules.business.vo.EchartResult; 5 import com.skua.modules.business.vo.EchartResult;
6 import com.skua.modules.business.vo.TextResult;
6 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.stereotype.Service; 8 import org.springframework.stereotype.Service;
8 9
...@@ -15,23 +16,120 @@ import java.util.*; ...@@ -15,23 +16,120 @@ import java.util.*;
15 @Service 16 @Service
16 public class OlympicCenterServiceImpl implements IOlympicCenterService { 17 public class OlympicCenterServiceImpl implements IOlympicCenterService {
17 18
18 @Autowired 19 // @Autowired
19 private IPgQueryService pgQueryService; 20 // private IPgQueryService pgQueryService;
20 21
21 @Override 22 @Override
22 public Map<String,Object> getRealTimeData() { 23 public Map<String,Object> getRealTimeData(String sourceType) {
23 Map<String,Object> map = new HashMap<>(); 24 Map<String,Object> map = new HashMap<>();
24 String jsFields = "BKYHWSC_JS_Tag2,BKYHWSC_JS_Tag3"; 25 // String jsFields = "BKYHWSC_JS_Tag2,BKYHWSC_JS_Tag3";
25 List<Map<String, Object>> monitorList = pgQueryService.queryFactoryMonitorFromRealTimeData("",jsFields); 26 // List<Map<String, Object>> monitorList = pgQueryService.queryFactoryMonitorFromRealTimeData("",jsFields);
26 if(monitorList.size()==1){ 27 // if(monitorList.size()==1){
27 map = monitorList.get(0); 28 // map = monitorList.get(0);
29 // }
30 List<TextResult> pList = new ArrayList<>();
31 List<TextResult> fList = new ArrayList<>();
32 List<TextResult> wList = new ArrayList<>();
33 if("feed".equals(sourceType)){//压力14流量8
34 for (int i = 0; i < 14; i++) {
35 TextResult textResult = new TextResult();
36 textResult.setTitle("压力表"+(i+1));
37 if(i==8){
38 textResult.setValue("0.41");
39 }else{
40 textResult.setValue("0.00");
41 }
42 pList.add(i,textResult);
43 }
44 for (int j = 0; j < 8; j++) {
45 TextResult textResult = new TextResult();
46 textResult.setTitle("流量计"+(j+1));
47 textResult.setValue("0.00");
48 fList.add(j,textResult);
49 }
50 map.put("pressure",pList);
51 map.put("flow",fList);
52 }else if("hot".equals(sourceType)){//压力10流量4温度4;
53 for (int i = 0; i < 10; i++) {
54 TextResult textResult = new TextResult();
55 textResult.setTitle("压力表"+(i+1));
56 textResult.setValue("0.00");
57 pList.add(i,textResult);
58 }
59 for (int j = 0; j < 4; j++) {
60 TextResult textResult = new TextResult();
61 textResult.setTitle("流量计"+(j+1));
62 textResult.setValue("0.00");
63 fList.add(j,textResult);
64 }
65 for (int k = 0; k < 4; k++) {
66 TextResult textResult = new TextResult();
67 textResult.setTitle("温度计"+(k+1));
68 textResult.setValue("--");
69 wList.add(k,textResult);
70 }
71 map.put("pressure",pList);
72 map.put("flow",fList);
73 map.put("temperature",wList);
74 }else if("fire".equals(sourceType)){//压力9流量2.
75 for (int i = 0; i < 9; i++) {
76 TextResult textResult = new TextResult();
77 textResult.setTitle("压力表"+(i+1));
78 textResult.setValue("0.00");
79 pList.add(i,textResult);
80 }
81 for (int j = 0; j < 2; j++) {
82 TextResult textResult = new TextResult();
83 textResult.setTitle("流量计"+(j+1));
84 textResult.setValue("0.00");
85 fList.add(j,textResult);
86 }
87 map.put("pressure",pList);
88 map.put("flow",fList);
89 }else{
90 for (int i = 0; i < 33; i++) {
91 TextResult textResult = new TextResult();
92 textResult.setTitle("压力表"+(i+1));
93 if(i==8){
94 textResult.setValue("0.41");
95 }else{
96 textResult.setValue("0.00");
97 }
98 pList.add(i,textResult);
99 }
100 for (int j = 0; j < 14; j++) {
101 TextResult textResult = new TextResult();
102 textResult.setTitle("流量计"+(j+1));
103 textResult.setValue("0.00");
104 fList.add(j,textResult);
105 }
106 for (int k = 0; k < 4; k++) {
107 TextResult textResult = new TextResult();
108 textResult.setTitle("温度计"+(k+1));
109 textResult.setValue("--");
110 wList.add(k,textResult);
111 }
112 map.put("pressure",pList);
113 map.put("flow",fList);
114 map.put("temperature",wList);
28 } 115 }
29 return map; 116 return map;
30 } 117 }
31 118
32 @Override 119 @Override
33 public Map<String, Object> getHistoryData(String field) { 120 public List<EchartResult> getHistoryData(String field,String sourceType) {
34 return null; 121 List<EchartResult> list = new ArrayList<>();
122 for (int i = 0; i < 24; i++) {
123 Calendar date = Calendar.getInstance();
124 date.add(Calendar.HOUR, i-24);
125 String newHour = new SimpleDateFormat("HH:00").format(date.getTime());
126 EchartResult echartResult = new EchartResult();
127 echartResult.setName(newHour);
128 echartResult.setValue(formatDouble(getRandom(0.00,1.00)).toString());
129 echartResult.setSeries(field);
130 list.add(echartResult);
131 }
132 return list;
35 } 133 }
36 134
37 @Override 135 @Override
...@@ -61,7 +159,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { ...@@ -61,7 +159,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
61 } 159 }
62 160
63 @Override 161 @Override
64 public List<EchartResult> getPressureChart(String equipId) { 162 public List<EchartResult> getPressureChart(String equipId,String type) {//p:压力 f:流量计 t:温度计
65 List<EchartResult> list = new ArrayList<>(); 163 List<EchartResult> list = new ArrayList<>();
66 for (int i = 0; i < 30; i++) { 164 for (int i = 0; i < 30; i++) {
67 Calendar date = Calendar.getInstance(); 165 Calendar date = Calendar.getInstance();
...@@ -69,18 +167,102 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { ...@@ -69,18 +167,102 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
69 String newDate = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime()).substring(5,10); 167 String newDate = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime()).substring(5,10);
70 EchartResult echartResult = new EchartResult(); 168 EchartResult echartResult = new EchartResult();
71 echartResult.setName(newDate); 169 echartResult.setName(newDate);
170 if("p".equals(type)){
72 echartResult.setValue(formatDouble(getRandom(0.40,0.50)).toString()); 171 echartResult.setValue(formatDouble(getRandom(0.40,0.50)).toString());
73 echartResult.setSeries("压力表"); 172 echartResult.setSeries("压力表");
173 }else if("f".equals(type)){
174 echartResult.setValue("0.00");
175 echartResult.setSeries("流量计");
176 }else if("t".equals(type)){
177 echartResult.setValue("0.00");
178 echartResult.setSeries("温度计");
179 }else{
180 echartResult.setValue("--");
181 echartResult.setSeries("--");
182 }
74 list.add(echartResult); 183 list.add(echartResult);
75 } 184 }
76 return list; 185 return list;
77 } 186 }
78 187
188 @Override
189 public Map<String, Object> getBzRealTimeData(String sourceType) {
190 Map<String,Object> map = new HashMap<>();
191 List<TextResult> bList = new ArrayList<>();
192 if("feed".equals(sourceType)){
193 TextResult ssllResult = new TextResult();
194 ssllResult.setTitle("瞬时流量");
195 ssllResult.setValue("0.00");
196 TextResult ljllResult = new TextResult();
197 ljllResult.setTitle("累计流量");
198 ljllResult.setValue("0.00");
199 TextResult rllResult = new TextResult();
200 rllResult.setTitle("日流量");
201 rllResult.setValue("0.00");
202 for (int i = 0; i < 4; i++) {
203 TextResult textResult = new TextResult();
204 textResult.setTitle("泵"+(i+1));
205 textResult.setValue("0");
206 bList.add(i,textResult);
207 }
208 map.put("ssll",ssllResult);
209 map.put("ljll",ljllResult);
210 map.put("rll",rllResult);
211 map.put("equip",bList);
212 }else if("hot".equals(sourceType)){//压力10流量4温度4;
213 TextResult ssllResult = new TextResult();
214 ssllResult.setTitle("瞬时流量");
215 ssllResult.setValue("0.00");
216 TextResult ljllResult = new TextResult();
217 ljllResult.setTitle("累计流量");
218 ljllResult.setValue("0.00");
219 TextResult rllResult = new TextResult();
220 rllResult.setTitle("日流量");
221 rllResult.setValue("0.00");
222 for (int i = 0; i < 3; i++) {
223 TextResult textResult = new TextResult();
224 textResult.setTitle("泵"+(i+1));
225 textResult.setValue("0");
226 bList.add(i,textResult);
227 }
228 map.put("ssll",ssllResult);
229 map.put("ljll",ljllResult);
230 map.put("rll",rllResult);
231 map.put("equip",bList);
232 }else if("fire".equals(sourceType)){//压力9流量2.
233 TextResult ssllResult = new TextResult();
234 ssllResult.setTitle("瞬时流量");
235 ssllResult.setValue("0.00");
236 TextResult ljllResult = new TextResult();
237 ljllResult.setTitle("累计流量");
238 ljllResult.setValue("0.00");
239 TextResult rllResult = new TextResult();
240 rllResult.setTitle("日流量");
241 rllResult.setValue("0.00");
242 for (int i = 0; i < 4; i++) {
243 TextResult textResult = new TextResult();
244 textResult.setTitle("泵"+(i+1));
245 textResult.setValue("0");
246 bList.add(i,textResult);
247 }
248 map.put("ssll",ssllResult);
249 map.put("ljll",ljllResult);
250 map.put("rll",rllResult);
251 map.put("equip",bList);
252 }else{
253 map.put("ssll",new TextResult());
254 map.put("ljll",new TextResult());
255 map.put("rll",new TextResult());
256 map.put("equip",new ArrayList<>());
257 }
258 return map;
259 }
260
79 public static void main(String[] args) { 261 public static void main(String[] args) {
80 for (int i = 0; i < 30; i++) { 262 for (int i = 0; i < 24; i++) {
81 Calendar date = Calendar.getInstance(); 263 Calendar date = Calendar.getInstance();
82 date.add(Calendar.DATE, i-30); 264 date.add(Calendar.HOUR, i-24);
83 String newDate = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime()).substring(5,10); 265 String newDate = new SimpleDateFormat("HH:00").format(date.getTime());
84 System.out.println("=========="+newDate+"============"); 266 System.out.println("=========="+newDate+"============");
85 } 267 }
86 } 268 }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!