ebb278a6 张雷

奥体项目数据报表接口修改

1 个父辈 a30d7c24
...@@ -39,7 +39,7 @@ public class OlympicCenterController { ...@@ -39,7 +39,7 @@ public class OlympicCenterController {
39 return result; 39 return result;
40 } 40 }
41 41
42 @ApiOperation(value="获取整体实时数据", notes="获取整体实时数据") 42 @ApiOperation(value="获取整体实时数据new", notes="获取整体实时数据new")
43 @GetMapping(value = "/getRealTimeDataNew") 43 @GetMapping(value = "/getRealTimeDataNew")
44 public Result<Map<String,Object>> getRealTimeDataNew(String sourceType){ 44 public Result<Map<String,Object>> getRealTimeDataNew(String sourceType){
45 Result<Map<String,Object>> result = new Result<Map<String,Object>>(); 45 Result<Map<String,Object>> result = new Result<Map<String,Object>>();
...@@ -59,7 +59,7 @@ public class OlympicCenterController { ...@@ -59,7 +59,7 @@ public class OlympicCenterController {
59 return result; 59 return result;
60 } 60 }
61 61
62 @ApiOperation(value="获取整体实时数据给UE", notes="获取整体实时数据给UE") 62 @ApiOperation(value="新获取整体实时数据给UE", notes="新获取整体实时数据给UE")
63 @GetMapping(value = "/getRealTimeDataToUENew") 63 @GetMapping(value = "/getRealTimeDataToUENew")
64 public Result<Map<String,Object>> getRealTimeDataToUENew(){ 64 public Result<Map<String,Object>> getRealTimeDataToUENew(){
65 Result<Map<String,Object>> result = new Result<Map<String,Object>>(); 65 Result<Map<String,Object>> result = new Result<Map<String,Object>>();
...@@ -128,7 +128,7 @@ public class OlympicCenterController { ...@@ -128,7 +128,7 @@ public class OlympicCenterController {
128 return result; 128 return result;
129 } 129 }
130 130
131 @ApiOperation(value="获取趋势图", notes="获取趋势图") 131 @ApiOperation(value="获取趋势图new", notes="获取趋势图new")
132 @GetMapping(value = "/getPressureChartNew") 132 @GetMapping(value = "/getPressureChartNew")
133 public Result<List<EchartResult>> getPressureChartNew(String equipId,String type){ 133 public Result<List<EchartResult>> getPressureChartNew(String equipId,String type){
134 Result<List<EchartResult>> result = new Result<List<EchartResult>>(); 134 Result<List<EchartResult>> result = new Result<List<EchartResult>>();
...@@ -139,4 +139,26 @@ public class OlympicCenterController { ...@@ -139,4 +139,26 @@ public class OlympicCenterController {
139 return result; 139 return result;
140 } 140 }
141 141
142 @ApiOperation(value="获取流量计详细数据", notes="获取流量计详细数据")
143 @GetMapping(value = "/getFlowData")
144 public Result<List<Map<String,Object>>> getFlowData(String equipId){
145 Result<List<Map<String,Object>>> result = new Result<List<Map<String,Object>>>();
146 List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
147 list = olympicCenterService.getFlowData(equipId);
148 result.setResult(list);
149 result.setSuccess(true);
150 return result;
151 }
152
153 @ApiOperation(value="获取实时数据报表", notes="获取实时数据报表")
154 @GetMapping(value = "/getRealTimeReport")
155 public Result<List<Map<String,Object>>> getRealTimeReport(String dataType,String loction){
156 Result<List<Map<String,Object>>> result = new Result<List<Map<String,Object>>>();
157 List<Map<String,Object>> list = new ArrayList<>();
158 list = olympicCenterService.getRealTimeReport(dataType, loction);
159 result.setResult(list);
160 result.setSuccess(true);
161 return result;
162 }
163
142 } 164 }
......
...@@ -44,6 +44,9 @@ public class WhatStructData { ...@@ -44,6 +44,9 @@ public class WhatStructData {
44 /**点实时值*/ 44 /**点实时值*/
45 @ApiModelProperty(value = "点实时值") 45 @ApiModelProperty(value = "点实时值")
46 private String monitorValue; 46 private String monitorValue;
47 /**缩放倍数*/
48 @ApiModelProperty(value = "缩放倍数")
49 private String monitorZoom;
47 /**所属泵站*/ 50 /**所属泵站*/
48 @ApiModelProperty(value = "所属泵站") 51 @ApiModelProperty(value = "所属泵站")
49 private String pumpCode; 52 private String pumpCode;
......
...@@ -21,4 +21,10 @@ public interface WhatStructDataMapper { ...@@ -21,4 +21,10 @@ public interface WhatStructDataMapper {
21 List<WhatStructData> getDataList(@Param("equipId") String equipId); 21 List<WhatStructData> getDataList(@Param("equipId") String equipId);
22 22
23 List<WhatStructData> getListForUENew(); 23 List<WhatStructData> getListForUENew();
24
25 List<WhatStructData> getFlowList(@Param("loction") String loction);
26
27 List<WhatStructData> getPressureList(@Param("loction") String loction);
28
29 List<WhatStructData> getTemperatureList(@Param("loction") String loction);
24 } 30 }
......
...@@ -33,4 +33,25 @@ ...@@ -33,4 +33,25 @@
33 select * from what_struct_data_bak order by monitor_sort 33 select * from what_struct_data_bak order by monitor_sort
34 </select> 34 </select>
35 35
36 <select id="getFlowList" resultType="com.skua.modules.business.entity.WhatStructData">
37 select * from what_struct_data_bak where equip_type like CONCAT('flow','%')
38 <if test="loction!=null and loction!=''">
39 and pump_code = #{loction}
40 </if>
41 </select>
42
43 <select id="getPressureList" resultType="com.skua.modules.business.entity.WhatStructData">
44 select * from what_struct_data_bak where equip_type like CONCAT('pressure','%')
45 <if test="loction!=null and loction!=''">
46 and pump_code = #{loction}
47 </if>
48 </select>
49
50 <select id="getTemperatureList" resultType="com.skua.modules.business.entity.WhatStructData">
51 select * from what_struct_data_bak where equip_type like CONCAT('temperature','%')
52 <if test="loction!=null and loction!=''">
53 and pump_code = #{loction}
54 </if>
55 </select>
56
36 </mapper> 57 </mapper>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -27,4 +27,8 @@ public interface IOlympicCenterService { ...@@ -27,4 +27,8 @@ public interface IOlympicCenterService {
27 List<EchartResult> getPressureChartNew(String equipId, String type); 27 List<EchartResult> getPressureChartNew(String equipId, String type);
28 28
29 Map<String, Object> getRealTimeDataToUENew(); 29 Map<String, Object> getRealTimeDataToUENew();
30
31 List<Map<String, Object>> getFlowData(String equipId);
32
33 List<Map<String, Object>> getRealTimeReport(String dataType, String loction);
30 } 34 }
......
...@@ -76,7 +76,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { ...@@ -76,7 +76,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
76 if(monitorMap.get(pybList.get(i).getMonitorId())==null){ 76 if(monitorMap.get(pybList.get(i).getMonitorId())==null){
77 textResult.setValue("--"); 77 textResult.setValue("--");
78 }else{ 78 }else{
79 double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())/100); 79 double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())*Double.parseDouble(pybList.get(i).getMonitorZoom()));
80 textResult.setValue(String.valueOf(pResult)); 80 textResult.setValue(String.valueOf(pResult));
81 } 81 }
82 }else{ 82 }else{
...@@ -125,7 +125,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { ...@@ -125,7 +125,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
125 if(monitorMap.get(pybList.get(i).getMonitorId())==null){ 125 if(monitorMap.get(pybList.get(i).getMonitorId())==null){
126 textResult.setValue("--"); 126 textResult.setValue("--");
127 }else{ 127 }else{
128 double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())/100); 128 double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())*Double.parseDouble(pybList.get(i).getMonitorZoom()));
129 textResult.setValue(String.valueOf(pResult)); 129 textResult.setValue(String.valueOf(pResult));
130 } 130 }
131 }else{ 131 }else{
...@@ -190,7 +190,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { ...@@ -190,7 +190,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
190 if(monitorMap.get(pybList.get(i).getMonitorId())==null){ 190 if(monitorMap.get(pybList.get(i).getMonitorId())==null){
191 textResult.setValue("--"); 191 textResult.setValue("--");
192 }else{ 192 }else{
193 double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())/100); 193 double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())*Double.parseDouble(pybList.get(i).getMonitorZoom()));
194 textResult.setValue(String.valueOf(pResult)); 194 textResult.setValue(String.valueOf(pResult));
195 } 195 }
196 }else{ 196 }else{
...@@ -387,7 +387,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { ...@@ -387,7 +387,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
387 EchartResult echartResult = new EchartResult(); 387 EchartResult echartResult = new EchartResult();
388 echartResult.setName(map.get("time").toString()); 388 echartResult.setName(map.get("time").toString());
389 if("p".equals(type)){ 389 if("p".equals(type)){
390 double pResult = formatDouble(Double.parseDouble(map.get(whatStructData.getMonitorId()).toString())/100); 390 double pResult = formatDouble(Double.parseDouble(map.get(whatStructData.getMonitorId()).toString())*Double.parseDouble(whatStructData.getMonitorZoom()));
391 echartResult.setValue(String.valueOf(pResult)); 391 echartResult.setValue(String.valueOf(pResult));
392 echartResult.setSeries("压力表"); 392 echartResult.setSeries("压力表");
393 }else if("f".equals(type)){ 393 }else if("f".equals(type)){
...@@ -530,7 +530,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { ...@@ -530,7 +530,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
530 for (WhatStructData whatStructData:list) { 530 for (WhatStructData whatStructData:list) {
531 if(whatStructData.getMonitorId()!=null){ 531 if(whatStructData.getMonitorId()!=null){
532 if("pressure".equals(whatStructData.getEquipType())){ 532 if("pressure".equals(whatStructData.getEquipType())){
533 double pResult = formatDouble(Double.parseDouble(monitorMap.get(whatStructData.getMonitorId()).toString())/100); 533 double pResult = formatDouble(Double.parseDouble(monitorMap.get(whatStructData.getMonitorId()).toString())*Double.parseDouble(whatStructData.getMonitorZoom()));
534 map.put(whatStructData.getId(),String.valueOf(pResult)); 534 map.put(whatStructData.getId(),String.valueOf(pResult));
535 }else{ 535 }else{
536 map.put(whatStructData.getId(),monitorMap.get(whatStructData.getMonitorId())); 536 map.put(whatStructData.getId(),monitorMap.get(whatStructData.getMonitorId()));
...@@ -591,7 +591,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { ...@@ -591,7 +591,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
591 if(monitorMap.get(pybList.get(i).getMonitorId())==null){ 591 if(monitorMap.get(pybList.get(i).getMonitorId())==null){
592 textResult.setValue("--"); 592 textResult.setValue("--");
593 }else{ 593 }else{
594 double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())/100); 594 double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())*Double.parseDouble(pybList.get(i).getMonitorZoom()));
595 textResult.setValue(String.valueOf(pResult)); 595 textResult.setValue(String.valueOf(pResult));
596 } 596 }
597 }else{ 597 }else{
...@@ -667,7 +667,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { ...@@ -667,7 +667,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
667 if(monitorMap.get(pybList.get(i).getMonitorId())==null){ 667 if(monitorMap.get(pybList.get(i).getMonitorId())==null){
668 textResult.setValue("--"); 668 textResult.setValue("--");
669 }else{ 669 }else{
670 double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())/100); 670 double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())*Double.parseDouble(pybList.get(i).getMonitorZoom()));
671 textResult.setValue(String.valueOf(pResult)); 671 textResult.setValue(String.valueOf(pResult));
672 } 672 }
673 }else{ 673 }else{
...@@ -759,7 +759,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { ...@@ -759,7 +759,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
759 if(monitorMap.get(pybList.get(i).getMonitorId())==null){ 759 if(monitorMap.get(pybList.get(i).getMonitorId())==null){
760 textResult.setValue("--"); 760 textResult.setValue("--");
761 }else{ 761 }else{
762 double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())/100); 762 double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())*Double.parseDouble(pybList.get(i).getMonitorZoom()));
763 textResult.setValue(String.valueOf(pResult)); 763 textResult.setValue(String.valueOf(pResult));
764 } 764 }
765 }else{ 765 }else{
...@@ -890,7 +890,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { ...@@ -890,7 +890,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
890 EchartResult echartResult = new EchartResult(); 890 EchartResult echartResult = new EchartResult();
891 echartResult.setName(map.get("time").toString()); 891 echartResult.setName(map.get("time").toString());
892 if("p".equals(type)){ 892 if("p".equals(type)){
893 double pResult = formatDouble(Double.parseDouble(map.get(wList.get(0).getMonitorId()).toString())/100); 893 double pResult = formatDouble(Double.parseDouble(map.get(wList.get(0).getMonitorId()).toString())*Double.parseDouble(wList.get(0).getMonitorZoom()));
894 echartResult.setValue(String.valueOf(pResult)); 894 echartResult.setValue(String.valueOf(pResult));
895 echartResult.setSeries("压力表"); 895 echartResult.setSeries("压力表");
896 list.add(echartResult); 896 list.add(echartResult);
...@@ -977,7 +977,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { ...@@ -977,7 +977,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
977 for (WhatStructData whatStructData:otherList) { 977 for (WhatStructData whatStructData:otherList) {
978 if(whatStructData.getMonitorId()!=null){ 978 if(whatStructData.getMonitorId()!=null){
979 if("pressure".equals(whatStructData.getEquipType())){ 979 if("pressure".equals(whatStructData.getEquipType())){
980 double pResult = formatDouble(Double.parseDouble(monitorMap.get(whatStructData.getMonitorId()).toString())/100); 980 double pResult = formatDouble(Double.parseDouble(monitorMap.get(whatStructData.getMonitorId()).toString())*Double.parseDouble(whatStructData.getMonitorZoom()));
981 map.put(whatStructData.getId(),String.valueOf(pResult)); 981 map.put(whatStructData.getId(),String.valueOf(pResult));
982 }else{ 982 }else{
983 map.put(whatStructData.getId(),monitorMap.get(whatStructData.getMonitorId())); 983 map.put(whatStructData.getId(),monitorMap.get(whatStructData.getMonitorId()));
...@@ -1001,14 +1001,134 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { ...@@ -1001,14 +1001,134 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
1001 return map; 1001 return map;
1002 } 1002 }
1003 1003
1004 // public static void main(String[] args) { 1004 @Override
1005 // for (int i = 0; i < 24; i++) { 1005 public List<Map<String, Object>> getFlowData(String equipId) {
1006 // Calendar date = Calendar.getInstance(); 1006 List<Map<String, Object>> list = new ArrayList<>();
1007 // date.add(Calendar.HOUR, i-24); 1007 List<WhatStructData> wList = whatStructDataMapper.getDataList(equipId);
1008 // String newDate = new SimpleDateFormat("HH:00").format(date.getTime()); 1008 String pgField = "";
1009 // System.out.println("=========="+newDate+"============"); 1009 if(wList.size() == 0){
1010 // } 1010 list = getMnData();
1011 // } 1011 return list;
1012 }else{
1013 for (WhatStructData whatStructData:wList) {
1014 pgField = pgField +","+whatStructData.getMonitorId();
1015 }
1016 }
1017 Map<String, Object> monitorMap = new HashMap<>();
1018 List<Map<String, Object>> monitorList = fmPgQueryService.queryFactoryMonitorFromRealTimeData(AT_ID,pgField);
1019 if(monitorList.size()==1){
1020 monitorMap = monitorList.get(0);
1021 for (WhatStructData whatStructData:wList) {
1022 Map<String, Object> map = new HashMap<>();
1023 map.put("name", whatStructData.getEquipType());
1024 if(monitorMap.get(whatStructData.getMonitorId())==null){
1025 map.put("value","--");
1026 }else{
1027 map.put("value",monitorMap.get(whatStructData.getMonitorId()));
1028 }
1029 list.add(map);
1030 }
1031 }else{
1032 list = getMnData();
1033 return list;
1034 }
1035 return list;
1036 }
1037
1038 @Override
1039 public List<Map<String, Object>> getRealTimeReport(String dataType, String loction) {
1040 List<Map<String, Object>> list = new ArrayList<>();
1041 List<WhatStructData> wList = new ArrayList<>();
1042 List<WhatStructData> flowList = new ArrayList<>();
1043 Map<String, Object> flowMap = new HashMap<>();
1044 String pgField = "";
1045 if("flow".equals(dataType)){
1046 wList = whatStructDataMapper.getFlowList(loction);
1047 for (WhatStructData whatStructData:wList) {
1048 flowMap.put(whatStructData.getMonitorId(),whatStructData.getId());
1049 if("flow".equals(whatStructData.getEquipType())){
1050 flowList.add(whatStructData);
1051 }
1052 }
1053 }else if("pressure".equals(dataType)){
1054 wList = whatStructDataMapper.getPressureList(loction);
1055 }else if("temperature".equals(dataType)){
1056 wList = whatStructDataMapper.getTemperatureList(loction);
1057 }else{
1058 return list;
1059 }
1060 for (WhatStructData whatStructData:wList) {
1061 pgField = pgField +","+whatStructData.getMonitorId();
1062 }
1063 List<Map<String, Object>> monitorList = fmPgQueryService.queryMonitorForReport(AT_ID,pgField);
1064 if("flow".equals(dataType)){
1065 for (Map<String, Object> beanMap : monitorList ) {
1066 boolean status = flowMap.get(beanMap.get("monitorid")).toString().contains("_");
1067 if(status){
1068 beanMap.put("equipId",flowMap.get(beanMap.get("monitorid")).toString().split("_")[0]);
1069 String type = flowMap.get(beanMap.get("monitorid")).toString().split("_")[1];
1070 if("LJLL".equals(type)){
1071 beanMap.put("equipType","flow_ljll");
1072 }else if("RLJLL".equals(type)){
1073 beanMap.put("equipType","flow_rljll");
1074 }else{
1075 beanMap.put("equipType","");
1076 }
1077 }else{
1078 beanMap.put("equipId",flowMap.get(beanMap.get("monitorid")));
1079 beanMap.put("equipType","flow");
1080 }
1081 }
1082 for (WhatStructData whatStructData:flowList) {
1083 Map<String, Object> map = new HashMap<>();
1084 map.put("id",whatStructData.getId());
1085 map.put("name",whatStructData.getId());
1086 map.put("time","");
1087 map.put("flow","");
1088 map.put("flow_ljll","");
1089 map.put("flow_rljll","");
1090 for (Map<String, Object> mMap : monitorList ) {
1091 if(whatStructData.getId().equals(mMap.get("equipId"))){
1092 map.put("time",mMap.get("time"));
1093 if("flow".equals(mMap.get("equipType"))){
1094 map.put("flow",mMap.get("monitorvalue"));
1095 }else if("flow_ljll".equals(mMap.get("equipType"))){
1096 map.put("flow_ljll",mMap.get("monitorvalue"));
1097 }else if("flow_rljll".equals(mMap.get("equipType"))){
1098 map.put("flow_rljll",mMap.get("monitorvalue"));
1099 }else{
1100 map.put("other",mMap.get("monitorvalue"));
1101 }
1102 }
1103 }
1104 list.add(map);
1105 }
1106 }else if("pressure".equals(dataType)){
1107 return list;
1108 }else if("temperature".equals(dataType)){
1109 return list;
1110 }else{
1111 return list;
1112 }
1113 return list;
1114 }
1115
1116 private List<Map<String, Object>> getMnData(){
1117 List<Map<String, Object>> list = new ArrayList<>();
1118 Map<String, Object> flowMap = new HashMap<>();
1119 flowMap.put("name","flow");
1120 flowMap.put("value","--");
1121 Map<String, Object> fflowMap = new HashMap<>();//
1122 fflowMap.put("name","flow_ljll");
1123 fflowMap.put("value","--");
1124 Map<String, Object> rflowMap = new HashMap<>();//
1125 rflowMap.put("name","flow_rljll");
1126 rflowMap.put("value","--");
1127 list.add(flowMap);
1128 list.add(fflowMap);
1129 list.add(rflowMap);
1130 return list;
1131 }
1012 1132
1013 /** 1133 /**
1014 * 获取大于等于min,小于max的随机小数 1134 * 获取大于等于min,小于max的随机小数
......
...@@ -10,4 +10,6 @@ public interface IFmPgQueryService { ...@@ -10,4 +10,6 @@ public interface IFmPgQueryService {
10 10
11 List<Map<String, Object>> queryFactoryMonitorFromRealTimeData(String factoryId, String fields); 11 List<Map<String, Object>> queryFactoryMonitorFromRealTimeData(String factoryId, String fields);
12 12
13 List<Map<String, Object>> queryMonitorForReport(String factoryId, String fields);
14
13 } 15 }
......
...@@ -11,7 +11,7 @@ import java.text.SimpleDateFormat; ...@@ -11,7 +11,7 @@ import java.text.SimpleDateFormat;
11 import java.util.*; 11 import java.util.*;
12 12
13 /** 13 /**
14 * 数据指标信息表 14 * 实时数据查询
15 */ 15 */
16 @Service 16 @Service
17 public class FmPgQueryServiceImpl implements IFmPgQueryService { 17 public class FmPgQueryServiceImpl implements IFmPgQueryService {
...@@ -94,4 +94,44 @@ public class FmPgQueryServiceImpl implements IFmPgQueryService { ...@@ -94,4 +94,44 @@ public class FmPgQueryServiceImpl implements IFmPgQueryService {
94 } 94 }
95 return timeStemp/1000; 95 return timeStemp/1000;
96 } 96 }
97
98 @Override
99 public List<Map<String, Object>> queryMonitorForReport(String factoryId, String fields) {
100 String[] factoryIdArray = factoryId.split(",");
101 String sqlPart = "";
102 for(String id : factoryIdArray) {
103 sqlPart = sqlPart +",'"+id+"'";
104 }
105 sqlPart = sqlPart.substring(1);
106 JdbcTemplate pgDb = (JdbcTemplate) SpringContextUtils.getBean("pg-db");
107 List<Map<String,Object>> result = new ArrayList<Map<String,Object>>();
108 JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
109 List<Map<String, Object>> factoryDesign = masterDB
110 .queryForList("select * from sys_factory_device where factory_id in ("+sqlPart+")");
111 if(factoryDesign==null||factoryDesign.size()==0) {
112 return result;
113 }
114 StringBuilder str = new StringBuilder();
115 String[] fieldsArr = fields.split(",");
116 for (int i = 0; i < fieldsArr.length; ++i){
117 if(!StringUtils.isEmpty(fieldsArr[i])&&!fieldsArr[i].equals("null")) {
118 str.append("'"+fieldsArr[i]+"'").append(",");
119 }
120 }
121 if(fieldsArr.length > 0){
122 str.append("''");
123 }else{
124 return result;
125 }
126 String deviceIds = "";
127 for(Map<String,Object> map: factoryDesign) {
128 deviceIds = deviceIds +",'"+map.get("device_id")+"'";
129 }
130 deviceIds = deviceIds.substring(1);
131
132 //获取pg数据库时间,向前推采集频率的三倍时间,做数据容错
133 String sql = "select ts as time,nm as monitorId,v as monitorValue from realtimedata where nm in("+str.toString()+") and factoryname in ("+deviceIds+")";
134 result = pgDb.queryForList(sql);
135 return result;
136 }
97 } 137 }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!