Selaa lähdekoodia

简单矩阵功能调整

xieshengjie 3 vuotta sitten
vanhempi
commit
f40524301a

+ 3 - 2
common/src/main/java/com/gyee/common/contant/Contant.java

@@ -49,9 +49,10 @@ public class Contant {
     public static final String TPOINT_WP_YFGL = "ZZSGL";// 应发功率
     public static final String TPOINT_WP_SJGL = "SSZGL";// 实际功率
     public static final String TPOINT_WP_AGC = "AGC002";// agc
-    public static final String TPOINT_WP_CXGL = "AGC001";// 出线功率
+    public static final String TPOINT_WP_CXGL = "AGC001";// 出线功率SSFS
+    public static final String TPOINT_WP_SSFS = "SSFS";// 实时风速
 
-    public static final String TPOINT_WP_MATRIX = "XDTS,YXTS,DJTS,WHTJ,GZTJ,TXZD,DWSLNUM,HJSLNUM,FCFGCDQ0001,ZBZGL,ZZSGL,SSZGL,AGC002,AGC001";
+    public static final String TPOINT_WP_MATRIX = "XDTS,YXTS,DJTS,WHTJ,GZTJ,TXZD,SSFS,DWSLNUM,HJSLNUM,FCFGCDQ0001,ZBZGL,ZZSGL,SSZGL,AGC002,AGC001";
 
 
     public static final String TPOINT_WT_FJZT = "FJZT" ;

+ 13 - 15
common/src/main/java/com/gyee/common/vo/matrix/MatrixVo.java

@@ -10,20 +10,18 @@ import lombok.Data;
  */
 @Data
 public class MatrixVo {
-    private String wpid;
-    private Integer yxts;
-    private Integer djts;
-    private Integer xdts;
-    private Integer gzts;
-    private Integer whts;
-    private Integer slts;
-    private Integer lxts;
-    private Double ycgl;
-    private Double bzgl;
-    private Double yfgl;
-    private Double sjgl;
-    private Double agc;
-    private Double cxgl;
+
     private String wtid;
-    private Integer staus;
+
+    private Double staus;
+
+    private String wpid;
+
+    public MatrixVo(String wtid, Double staus, String wpid) {
+        this.wtid = wtid;
+        this.staus = staus;
+        this.wpid = wpid;
+    }
+
+
 }

+ 7 - 4
web/consumer/src/main/resources/application-dev.yml

@@ -12,7 +12,7 @@ spring:
   cloud:
     nacos:
       discovery:
-        server-addr: 10.83.68.97:8848
+        server-addr: 192.168.2.216:8848
         #指定yaml格式的配置
         file-extension: yaml
         cluster-name: master
@@ -73,11 +73,15 @@ spring:
       max-request-size: 215MB
 # feign调用超时时间配置
 feign:
+  sentinel:
+    enabled: true
+  httpclient:
+    enabled: true
   client:
     config:
       default:
-        connectTimeout: 60000
-        readTimeout: 600000
+        read-timeout: 60000
+        connect-timeout: 60000
 
 mybatis-plus:
   configuration:
@@ -98,4 +102,3 @@ logging:
     root: info
     com.example: debug
 
-

+ 2 - 2
web/consumer/src/main/resources/application.yml

@@ -1,5 +1,5 @@
 spring:
   profiles:
-    active: hf
-#    active: dev
+#    active: hf
+    active: dev
 #    active: test

+ 1 - 1
web/monitor-web/src/main/java/com/gyee/monitor/controller/matrix/MatrixController.java

@@ -25,7 +25,7 @@ public class MatrixController {
     @CrossOrigin(origins = "*", maxAge = 3600)
     public R matrixDatas()  {
 
-        Map<String, Map<String,Double>> resultMap = matrixService.matrixDatas();
+        Map<String, Object> resultMap = matrixService.matrixDatas();
         if (StringUtils.isNotNull(resultMap)) {
             return R.ok(resultMap.size()).data(resultMap);
         }else{

+ 80 - 19
web/monitor-web/src/main/java/com/gyee/monitor/service/matrix/MatrixService.java

@@ -2,6 +2,9 @@ package com.gyee.monitor.service.matrix;
 
 import com.gyee.common.contant.Contant;
 import com.gyee.common.model.PointData;
+import com.gyee.common.model.StringUtils;
+import com.gyee.common.util.SortUtils;
+import com.gyee.common.vo.matrix.MatrixVo;
 import com.gyee.monitor.init.CacheContext;
 import com.gyee.monitor.model.auto.Windpowerstation;
 import com.gyee.monitor.model.auto.Windpowerstationpointnew;
@@ -30,35 +33,60 @@ public class MatrixService {
     private IEdosUtil edosUtil;
 
 
-    public Map<String,Map<String,Double>> matrixDatas()  {
-        Map<String,Map<String,Double>> resultMap = new HashMap<>();
-        Map<String,Double> wpMap = Collections.synchronizedMap(new HashMap<>());
-        Map<String,Double> wtMap = Collections.synchronizedMap(new HashMap<>());
+    public Map<String,Object> matrixDatas()  {
+        Map<String,Object> resultMap = new HashMap<>();
+        Map<String,Map<String,Object>> wpresultMap = new HashMap<>();
+
+        Map<String,List<MatrixVo>> wtMap = Collections.synchronizedMap(new HashMap<>());
+
+
         Map<String, Map<String, Windpowerstationpointnew>> wpPointmap = CacheContext.wpPointmap;
         Map<String, Map<String, Windturbinetestingpointnew>> wtPointmap = CacheContext.wtPointmap;
 
         List<Windpowerstation> wpls = CacheContext.wpls;
-        Windpowerstation windpowerstation = new Windpowerstation();
-        windpowerstation.setId("0");
-        windpowerstation.setQuantity(wpls.stream().mapToDouble(Windpowerstation::getQuantity).sum());
-        wpls.add(windpowerstation);
-        wpls.parallelStream().forEach(wp-> {
-            wpMap.put(wp.getId()+"_jrts",wp.getQuantity());
+        List<Windpowerstation> companyWp = wpls.stream().filter(wp -> wp.getId().equals("0") || wp.getId().equals("-1") || wp.getId().equals("-2")).collect(Collectors.toList());
+        if (!StringUtils.isNotEmpty(companyWp)){
+            Windpowerstation comany = new Windpowerstation();
+            comany.setId("0");
+            comany.setQuantity(wpls.stream().mapToDouble(Windpowerstation::getQuantity).sum());
+            comany.setOrdernum(0.0);
+            wpls.add(comany);
+            //如果有光伏将下面注释打开
+//            Windpowerstation fd = new Windpowerstation();
+//            fd.setId("-1");
+//            fd.setQuantity(wpls.stream().filter(i->i.getId().endsWith("FDC")).mapToDouble(Windpowerstation::getQuantity).sum());
+//            wpls.add(fd);
+//            Windpowerstation gf = new Windpowerstation();
+//            gf.setId("-2");
+//            gf.setQuantity(wpls.stream().filter(i->i.getId().endsWith("GDC")).mapToDouble(Windpowerstation::getQuantity).sum());
+//            wpls.add(gf);
+        }
+        SortUtils.sort(wpls,"ordernum",SortUtils.ASC);
+        wpls.stream().forEach(wp-> {
+            Map<String,Object> wpMap = Collections.synchronizedMap(new HashMap<>());
+            wpMap.put("JRTS",wp.getQuantity());
+            wpMap.put("WPNAME",wp.getName());
             List<String> pointList = new ArrayList<>();
             Map<String,String> pointMap = new HashMap<>();
             Map<String, Windpowerstationpointnew> stringWindpowerstationtestingpointMap = wpPointmap.get(wp.getId());
             String[] wppoints = Contant.TPOINT_WP_MATRIX.split(",");
             Arrays.stream(wppoints).forEach(uniformcode -> {
-                Windpowerstationpointnew windpowerstationtestingpoint = stringWindpowerstationtestingpointMap.get(uniformcode);
-                if (!windpowerstationtestingpoint.getCode().trim().equals("INITIAL")){
-                    pointList.add(windpowerstationtestingpoint.getCode());
+                if (stringWindpowerstationtestingpointMap.containsKey(uniformcode)){
+                    Windpowerstationpointnew windpowerstationtestingpoint = stringWindpowerstationtestingpointMap.get(uniformcode);
+                    if (!windpowerstationtestingpoint.getCode().trim().equals("INITIAL")){
+                        pointList.add(windpowerstationtestingpoint.getCode());
+                    }
+                    pointMap.put(windpowerstationtestingpoint.getCode(),uniformcode);
                 }
-                pointMap.put(windpowerstationtestingpoint.getCode(),wp.getId()+"_"+uniformcode);
             });
             try {
                 List<PointData> realData = edosUtil.getRealData(pointList);
                 realData.parallelStream().forEach(i -> {
-                    wpMap.put(pointMap.get(i.getEdnaId()), i.getPointValueInDouble());
+                    String uniform = pointMap.get(i.getEdnaId());
+                    if (uniform.equals(Contant.TPOINT_WP_BZGL) || uniform.equals(Contant.TPOINT_WP_YFGL))
+                        wpMap.put(pointMap.get(i.getEdnaId()), i.getPointValueInDouble()/1000);
+                    else
+                        wpMap.put(pointMap.get(i.getEdnaId()), i.getPointValueInDouble());
                 });
                 List<String> pointids = realData.stream().map(i -> i.getEdnaId()).collect(Collectors.toList());
                 Set<String> totalpointids = pointMap.keySet();
@@ -67,11 +95,15 @@ public class MatrixService {
                 notexists.stream().forEach(n->{
                     wpMap.put(pointMap.get(n),0.0);
                 });
+                wpresultMap.put(wp.getId(),wpMap);
             } catch (Exception e) {
                 e.printStackTrace();
             }
         });
-        resultMap.put("wp",wpMap);
+
+        resultMap.put("wp",wpresultMap);
+
+
         List<Windturbine> wtls = CacheContext.wtls;
         List<String> synchronizedList = Collections.synchronizedList(new ArrayList<>());
         Map<String,String> synchronizedMap = Collections.synchronizedMap(new HashMap<>());
@@ -79,20 +111,49 @@ public class MatrixService {
             Windturbinetestingpointnew windturbinetestingpointnew = wtPointmap.get(wt.getId()).get(Contant.TPOINT_WT_FJZT);
             if (!windturbinetestingpointnew.getCode().trim().equals("INITIAL")){
                 synchronizedList.add(windturbinetestingpointnew.getCode());
-                synchronizedMap.put(windturbinetestingpointnew.getCode(),wt.getId());
             }else{
                 log.info(windturbinetestingpointnew);
             }
+            synchronizedMap.put(windturbinetestingpointnew.getCode(),wt.getId()+"!"+wt.getWindpowerstationid());
         });
         try {
             List<PointData> realData = edosUtil.getRealData(synchronizedList);
-            realData.parallelStream().forEach(i -> {
-                wtMap.put(synchronizedMap.get(i.getEdnaId()), i.getPointValueInDouble());
+            realData.stream().forEach(i -> {
+                String[] split = synchronizedMap.get(i.getEdnaId()).split("!");
+                MatrixVo vo = new MatrixVo(split[0],i.getPointValueInDouble(),split[1]);
+                if (wtMap.containsKey(split[1])){
+                    wtMap.get(split[1]).add(vo);
+                }else {
+                    List<MatrixVo> wtResultList = new ArrayList<>();
+                    wtResultList.add(vo);
+                    wtMap.put(split[1],wtResultList);
+                }
+            });
+            List<String> pointids = realData.stream().map(i -> i.getEdnaId()).collect(Collectors.toList());
+            Set<String> totalpointids = synchronizedMap.keySet();
+            Collection notexists=new ArrayList<String>(totalpointids);
+            notexists.removeAll(pointids);
+            notexists.stream().forEach(n->{
+                String[] split = synchronizedMap.get(n).split("!");
+                MatrixVo vo = new MatrixVo(split[0],0.0,split[1]);
+                if (wtMap.containsKey(split[1])){
+                    wtMap.get(split[1]).add(vo);
+                }else {
+                    List<MatrixVo> wtResultList = new ArrayList<>();
+                    wtResultList.add(vo);
+                    wtMap.put(split[1],wtResultList);
+                }
             });
         } catch (Exception e) {
             e.printStackTrace();
         }
+        Set<String> wpids = wtMap.keySet();
+        wpids.stream().forEach(i->{
+            SortUtils.sort(wtMap.get(i),"wtid",SortUtils.ASC);
+        });
         resultMap.put("wt",wtMap);
         return resultMap;
     }
+
+
 }

+ 1 - 1
web/monitor-web/src/main/resources/application-test.yml

@@ -1,5 +1,5 @@
 server:
-  port: 8086
+  port: 8089
   servlet:
     context-path: /