瀏覽代碼

修正首页数据异常

shilin 2 年之前
父節點
當前提交
bb6b8bdeaa

+ 6 - 9
web/monitor-web-sxjn/src/main/java/com/gyee/frame/service/websocket/GenreSetPushService.java

@@ -45,10 +45,7 @@ public class GenreSetPushService {
     private WeatherDay5Service weatherDay5Service;
     @Resource
     private PowerToPowerService powerToPowerService;
-    @Resource
-    private RecommenmainMsSqlService recommenmainMsSqlService;
-    @Resource
-    private WobugeqService wobugeqService;
+
     @Resource
     private RecommenmainService recommenmainService;
 
@@ -1359,7 +1356,7 @@ public class GenreSetPushService {
             Date end= cal.getTime();
             int tjsl=totalTarget(id,begin,end);
             gxkmap.put("tjsl", Double.valueOf(tjsl));
-            int gdsl=wobugeqService.totalNum(DateUtils.truncate(begin),DateUtils.truncate(end));
+            int gdsl=0;
 
             if(gdsl!=0)
             {
@@ -1403,7 +1400,7 @@ public class GenreSetPushService {
                 end= cal.getTime();
                 int tjsl_hb=totalTarget(id,begin,end);
                 gxkmap.put("tjsl_hb", Double.valueOf(tjsl_hb));
-                int gdsl_hb=wobugeqService.totalNum(DateUtils.truncate(begin),DateUtils.truncate(end));
+                int gdsl_hb=0;
 
                 if(gdsl_hb!=0)
                 {
@@ -2636,7 +2633,7 @@ public class GenreSetPushService {
             Date end= cal.getTime();
             int tjsl=totalTarget(id,begin,end);
             gxkmap.put("tjsl", Double.valueOf(tjsl));
-            int gdsl=wobugeqService.totalNum(DateUtils.truncate(begin),DateUtils.truncate(end));
+            int gdsl=0;
 
             if(gdsl!=0)
             {
@@ -2720,7 +2717,7 @@ public class GenreSetPushService {
                 end= cal.getTime();
                 int tjsl_hb=totalTarget(id,begin,end);
                 gxkmap.put("tjsl_hb", Double.valueOf(tjsl_hb));
-                int gdsl_hb=wobugeqService.totalNum(DateUtils.truncate(begin),DateUtils.truncate(end));
+                int gdsl_hb=0;
 
                 if(gdsl_hb!=0)
                 {
@@ -2880,7 +2877,7 @@ public class GenreSetPushService {
             {
                 wtId=String.valueOf(sb.substring(0,sb.length()-1));
             }
-            num=recommenmainMsSqlService.totalList(wpId,wtId,beginDate,endDate);
+            num=0;
         }
         return num;
     }

+ 2 - 6
web/monitor-web-sxjn/src/main/java/com/gyee/frame/service/websocket/MatrixDetialPushService.java

@@ -15,7 +15,6 @@ import com.gyee.frame.service.WindpowerinfodayService;
 import com.gyee.frame.util.IRealTimeDataBaseUtil;
 import com.gyee.frame.util.MathUtil;
 import com.gyee.frame.util.RealTimeDataBaseFactory;
-import com.gyee.frame.util.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -333,11 +332,8 @@ public class MatrixDetialPushService {
 
                     MatrixVo vo = new MatrixVo();
                     vo.setWtId(wt.getId());
-                    if (StringUtils.notEmp(wt.getStatus())) {
-                        String num = wt.getStatus().substring(wt.getStatus().length() - 3);
-                        vo.setWtnum(num);
-
-                    }
+                    String num = wt.getId().substring(wt.getId().indexOf("_")+1);
+                    vo.setWtnum(num);
 
                     vo.setFjzt(MathUtil.twoBit(fjzblist.get(i * step).getPointValueInDouble()));
                     vo.setFs(MathUtil.twoBit(fjzblist.get(i * step + 1).getPointValueInDouble()));

+ 137 - 246
web/monitor-web-sxjn/src/main/java/com/gyee/frame/util/golden/EdosUtil.java

@@ -601,140 +601,86 @@ public class EdosUtil implements IRealTimeDataBaseUtil {
     public List<PointData> getRealData(String... pointids) throws Exception {
 
 
-        if(StringUtils.notEmp(pointids) )
-        {
-            List<String> idls=new ArrayList<>();
-            for(String str:pointids)
-            {
-                if(StringUtils.notEmp(str) && !V2Config.getInitialcode().equals(str))
-                {
-                    idls.add(str);
-                }
+        String pointIdString = StringUtil.join(pointids, ",");
+        Optional<String> keys = Optional.ofNullable(pointIdString);
+        String url = baseURL + "/latest?null=0";
+        try {
+            if (keys.isPresent())
+                url = url + "&keys=" + keys.get();
+            else {
+                return ErrorRequest.RequestListError(pointids);
             }
-            if(!idls.isEmpty()  )
-            {
-                String pointIdString = StringUtil.join(idls.toArray(), ",");
-                Optional<String> keys = Optional.ofNullable(pointIdString);
-                String url = baseURL + "/latest?null=0";
-                try {
-                    if (keys.isPresent())
-                        url = url + "&keys=" + keys.get();
-                    else {
-                        return ErrorRequest.RequestListError(pointids);
+            ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
+            JSONObject jsonObject = resp.getBody();
+            if (jsonObject != null) {
+                //对结果进行有序返回
+                int len = pointids.length;
+                List<PointData> result = new ArrayList<>();
+                HashMap<String, PointData> pointDataHashMap = new HashMap<>();
+                for (int i = 0; i < len; i++) {
+
+                    if (pointDataHashMap.containsKey(pointids[i]) == false){
+                        PointData pd = new PointData();
+                        pd.setPointName(pointids[i]);
+                        pd.setEdnaId(pointids[i]);
+                        result.add(pd);
+
+                        pointDataHashMap.put(pd.getPointName(), pd);
+                    }
+                    else{
+                        result.add(pointDataHashMap.get(pointids[i]));
                     }
-                    ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
-                    JSONObject jsonObject = resp.getBody();
-                    if (jsonObject != null) {
-                        //对结果进行有序返回
-                        int len = idls.size();
-                        List<PointData> result = new ArrayList<>();
-                        HashMap<String, PointData> pointDataHashMap = new HashMap<>();
-                        for (int i = 0; i < len; i++) {
-
-
-                            PointData pd = new PointData();
-                            pd.setPointName(pointids[i]);
-                            pd.setEdnaId(pointids[i]);
-                            pd.setPointValueInDouble(0.0);
-                            pd.setPointTime(0l);
-                            result.add(pd);
-
-                            pointDataHashMap.put(pd.getPointName(), pd);
-
-//                            if (pointDataHashMap.containsKey(idls.get(i)) == false){
-//                                PointData pd = new PointData();
-//                                pd.setPointName(idls.get(i));
-//                                pd.setEdnaId(idls.get(i));
-//                                result.add(pd);
-//
-//                                pointDataHashMap.put(pd.getPointName(), pd);
-//                            }
-//                            else{
-//                                result.add(pointDataHashMap.get(idls.get(i)));
-//                            }
 
-                        }
-                        Iterator<String> sIterator = jsonObject.keySet().iterator();
-                        while (sIterator.hasNext()) {
-                            // 获得key
-                            String key = sIterator.next();
-                            PointData pointData = pointDataHashMap.get(key);
-                            if (pointData == null)
-                                continue;
-                            // 根据key获得value, value也可以是JSONObject,JSONArray,使用对应的参数接收即可
-                            JSONObject jsonData = jsonObject.getJSONObject(key);
-                            Long ts = jsonData.getLong("ts");
-                            String pointValue = null;
-                            if (jsonData.containsKey("doubleValue")) {
-                                pointValue = jsonData.getString("doubleValue");
-                            } else if (jsonData.containsKey("booleanValue")) {
-                                pointValue = jsonData.getString("booleanValue");
-                            } else if (jsonData.containsKey("longValue")) {
-                                pointValue = jsonData.getString("longValue");
-                            } else if (jsonData.containsKey("stringValue")) {
-                                pointValue = jsonData.getString("stringValue");
-                            }
+                }
+                Iterator<String> sIterator = jsonObject.keySet().iterator();
+                while (sIterator.hasNext()) {
+                    // 获得key
+                    String key = sIterator.next();
+                    PointData pointData = pointDataHashMap.get(key);
+                    if (pointData == null)
+                        continue;
+                    // 根据key获得value, value也可以是JSONObject,JSONArray,使用对应的参数接收即可
+                    JSONObject jsonData = jsonObject.getJSONObject(key);
+                    Long ts = jsonData.getLong("ts");
+                    String pointValue = null;
+                    if (jsonData.containsKey("doubleValue")) {
+                        pointValue = jsonData.getString("doubleValue");
+                    } else if (jsonData.containsKey("booleanValue")) {
+                        pointValue = jsonData.getString("booleanValue");
+                    } else if (jsonData.containsKey("longValue")) {
+                        pointValue = jsonData.getString("longValue");
+                    } else if (jsonData.containsKey("stringValue")) {
+                        pointValue = jsonData.getString("stringValue");
+                    }
 //                    pointData.setPointValue(pointValue);
 //                    pointData.setPointValueInDouble(Double.parseDouble(pointValue));
 
-                            if(pointValue.equals("true"))
-                            {
-                                pointData.setPointValueInDouble(1.0);
-                            }else if(pointValue.equals("false"))
-                            {
-                                pointData.setPointValueInDouble(0.0);
-                            }else
-                            {
-                                pointData.setPointValueInDouble(Double.parseDouble(pointValue));
-                            }
-                            pointData.setPointValue(pointValue);
-                            // //System.out.println("key= " + key + ", ts = " + ts + ", value = " + pointValue);
-                        }
-                        return result;
-
-                    } else {
-                        return ErrorRequest.RequestListError(pointids);
-                    }
-
-                } catch (HttpClientErrorException exception) {
-                    if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
-                        //System.out.println("404请求错误");
-                        return ErrorRequest.RequestListError(pointids);
-                    } else {
-                        throw exception;
+                    if(pointValue.equals("true"))
+                    {
+                        pointData.setPointValueInDouble(1.0);
+                    }else if(pointValue.equals("false"))
+                    {
+                        pointData.setPointValueInDouble(0.0);
+                    }else
+                    {
+                        pointData.setPointValueInDouble(Double.parseDouble(pointValue));
                     }
+                    pointData.setPointValue(pointValue);
+                    // //System.out.println("key= " + key + ", ts = " + ts + ", value = " + pointValue);
                 }
-            }else
-            {
+                return result;
 
-                List<PointData> pols=new ArrayList<>();
-
-                for(String str:pointids)
-                {
-                    PointData po=new PointData();
-                    po.setEdnaId(str);
-                    po.setPointValueInDouble(0.0);
-                    po.setPointTime(0l);
-                    pols.add(po);
-
-                }
-                return pols;
+            } else {
+                return ErrorRequest.RequestListError(pointids);
             }
-        }else
-        {
-
-            List<PointData> pols=new ArrayList<>();
-
-            for(String str:pointids)
-            {
-                PointData po=new PointData();
-                po.setEdnaId(str);
-                po.setPointValueInDouble(0.0);
-                po.setPointTime(0l);
-                pols.add(po);
 
+        } catch (HttpClientErrorException exception) {
+            if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
+                //System.out.println("404请求错误");
+                return ErrorRequest.RequestListError(pointids);
+            } else {
+                throw exception;
             }
-            return pols;
         }
 
 
@@ -746,143 +692,88 @@ public class EdosUtil implements IRealTimeDataBaseUtil {
     public List<PointData> getRealData(List<String> pointids) throws Exception {
 
 
-        if(StringUtils.notEmp(pointids) )
-        {
-            List<String> idls=new ArrayList<>();
-            for(String str:pointids)
-            {
-                if(StringUtils.notEmp(str) && !V2Config.getInitialcode().equals(str))
-                {
-                    idls.add(str);
-                }
+        String pointIdString = StringUtil.join(pointids.toArray(), ",");
+        Optional<String> keys = Optional.ofNullable(pointIdString);
+        String url = baseURL + "/latest?null=0";
+        try {
+            if (keys.isPresent())
+                url = url + "&keys=" + keys.get();
+            else {
+                String[] arr = new String[pointids.size()];
+                return ErrorRequest.RequestListError(pointids.toArray(arr));
             }
-            if(!idls.isEmpty()   )
-            {
-                String pointIdString = StringUtil.join(idls.toArray(), ",");
-                Optional<String> keys = Optional.ofNullable(pointIdString);
-                String url = baseURL + "/latest?null=0";
-                try {
-                    if (keys.isPresent())
-                        url = url + "&keys=" + keys.get();
-                    else {
-                        String[] arr = new String[idls.size()];
-                        return ErrorRequest.RequestListError(idls.toArray(arr));
-                    }
-
-                    ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
-                    JSONObject jsonObject = resp.getBody();
-                    if (jsonObject != null) {
-
-
-                        //对结果进行有序返回
-                        int len = pointids.size();
-                        List<PointData> result = new ArrayList<>();
-                        HashMap<String, PointData> pointDataHashMap = new HashMap<>();
-                        for (int i = 0; i < len; i++) {
-
-                            PointData pd = new PointData();
-                            pd.setPointName(pointids.get(i));
-                            pd.setEdnaId(pointids.get(i));
-                            pd.setPointValueInDouble(0.0);
-                            pd.setPointTime(0l);
-                            result.add(pd);
-
-                            pointDataHashMap.put(pd.getPointName(), pd);
 
+            ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
+            JSONObject jsonObject = resp.getBody();
+            if (jsonObject != null) {
 
-//                            if (pointDataHashMap.containsKey(idls.get(i)) == false){
-//                                PointData pd = new PointData();
-//                                pd.setPointName(idls.get(i));
-//                                pd.setEdnaId(idls.get(i));
-//                                result.add(pd);
-//
-//                                pointDataHashMap.put(pd.getPointName(), pd);
-//                            }
-//                            else{
-//                                result.add(pointDataHashMap.get(idls.get(i)));
-//                            }
-                        }
-                        Iterator<String> sIterator = jsonObject.keySet().iterator();
-                        while (sIterator.hasNext()) {
-                            // 获得key
-                            String key = sIterator.next();
-                            PointData pointData = pointDataHashMap.get(key);
-                            if (pointData == null)
-                                continue;
-                            // 根据key获得value, value也可以是JSONObject,JSONArray,使用对应的参数接收即可
-                            JSONObject jsonData = jsonObject.getJSONObject(key);
-                            Long ts = jsonData.getLong("ts");
-                            String pointValue = null;
-                            if (jsonData.containsKey("doubleValue")) {
-                                pointValue = jsonData.getString("doubleValue");
-                            } else if (jsonData.containsKey("booleanValue")) {
-                                pointValue = jsonData.getString("booleanValue");
-                            } else if (jsonData.containsKey("longValue")) {
-                                pointValue = jsonData.getString("longValue");
-                            } else if (jsonData.containsKey("stringValue")) {
-                                pointValue = jsonData.getString("stringValue");
-                            }
-                            if(pointValue.equals("true"))
-                            {
-                                pointData.setPointValueInDouble(1.0);
-                            }else if(pointValue.equals("false"))
-                            {
-                                pointData.setPointValueInDouble(0.0);
-                            }else
-                            {
-                                pointData.setPointValueInDouble(Double.parseDouble(pointValue));
-                            }
-                            pointData.setPointValue(pointValue);
 
-                            //  //System.out.println("key= " + key + ", ts = " + ts + ", value = " + pointValue);
-                        }
-                        return result;
+                //对结果进行有序返回
+                int len = pointids.size();
+                List<PointData> result = new ArrayList<>();
+                HashMap<String, PointData> pointDataHashMap = new HashMap<>();
+                for (int i = 0; i < len; i++) {
+                    if (pointDataHashMap.containsKey(pointids.get(i)) == false){
+                        PointData pd = new PointData();
+                        pd.setPointName(pointids.get(i));
+                        pd.setEdnaId(pointids.get(i));
+                        result.add(pd);
 
-                    } else {
-                        String[] arr = new String[pointids.size()];
-                        return ErrorRequest.RequestListError(pointids.toArray(arr));
+                        pointDataHashMap.put(pd.getPointName(), pd);
                     }
-
-                } catch (HttpClientErrorException exception) {
-                    if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
-                        //System.out.println("404请求错误");
-                        String[] arr = new String[pointids.size()];
-                        return ErrorRequest.RequestListError(pointids.toArray(arr));
-                    } else {
-                        throw exception;
+                    else{
+                        result.add(pointDataHashMap.get(pointids.get(i)));
                     }
                 }
-            }else
-            {
-
-                List<PointData> pols=new ArrayList<>();
-
-                for(String str:pointids)
-                {
-                    PointData po=new PointData();
-                    po.setEdnaId(str);
-                    po.setPointValueInDouble(0.0);
-                    po.setPointTime(0l);
-                    pols.add(po);
+                Iterator<String> sIterator = jsonObject.keySet().iterator();
+                while (sIterator.hasNext()) {
+                    // 获得key
+                    String key = sIterator.next();
+                    PointData pointData = pointDataHashMap.get(key);
+                    if (pointData == null)
+                        continue;
+                    // 根据key获得value, value也可以是JSONObject,JSONArray,使用对应的参数接收即可
+                    JSONObject jsonData = jsonObject.getJSONObject(key);
+                    Long ts = jsonData.getLong("ts");
+                    String pointValue = null;
+                    if (jsonData.containsKey("doubleValue")) {
+                        pointValue = jsonData.getString("doubleValue");
+                    } else if (jsonData.containsKey("booleanValue")) {
+                        pointValue = jsonData.getString("booleanValue");
+                    } else if (jsonData.containsKey("longValue")) {
+                        pointValue = jsonData.getString("longValue");
+                    } else if (jsonData.containsKey("stringValue")) {
+                        pointValue = jsonData.getString("stringValue");
+                    }
+                    if(pointValue.equals("true"))
+                    {
+                        pointData.setPointValueInDouble(1.0);
+                    }else if(pointValue.equals("false"))
+                    {
+                        pointData.setPointValueInDouble(0.0);
+                    }else
+                    {
+                        pointData.setPointValueInDouble(Double.parseDouble(pointValue));
+                    }
+                    pointData.setPointValue(pointValue);
 
+                    //  //System.out.println("key= " + key + ", ts = " + ts + ", value = " + pointValue);
                 }
-                return pols;
-            }
-        }else
-        {
-
-            List<PointData> pols=new ArrayList<>();
+                return result;
 
-            for(String str:pointids)
-            {
-                PointData po=new PointData();
-                po.setEdnaId(str);
-                po.setPointValueInDouble(0.0);
-                po.setPointTime(0l);
-                pols.add(po);
+            } else {
+                String[] arr = new String[pointids.size()];
+                return ErrorRequest.RequestListError(pointids.toArray(arr));
+            }
 
+        } catch (HttpClientErrorException exception) {
+            if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
+                //System.out.println("404请求错误");
+                String[] arr = new String[pointids.size()];
+                return ErrorRequest.RequestListError(pointids.toArray(arr));
+            } else {
+                throw exception;
             }
-            return pols;
         }
 
     }