Procházet zdrojové kódy

状态实时计算

GYEE před 9 měsíci
rodič
revize
a7e8195251

+ 89 - 33
ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java

@@ -1777,14 +1777,11 @@ public class JavaFunctionJobHandler extends IJobHandler {
         List<ProEconReportIndicatorPool> pools = reportIndicatorPoolService.list(wrapperrp);
 
 
-
-
-
         QueryWrapper<ProEconReportIndicatorPool> wrapperrp2 = new QueryWrapper<>();
         wrapperrp2.eq("record_date", time0).eq("foreign_key_id", "GJNY_SXGS_DBXNY_ZGS0");
         ProEconReportIndicatorPool pools2 = reportIndicatorPoolService.getOne(wrapperrp2);
 
-        if (pools2 == null){
+        if (pools2 == null) {
             ProEconReportIndicatorPool GSPJFS = new ProEconReportIndicatorPool();
             GSPJFS.setRecordDate(time0.toLocalDateTime().toLocalDate());
             GSPJFS.setForeignKeyId("GJNY_SXGS_DBXNY_ZGS0");
@@ -1945,12 +1942,11 @@ public class JavaFunctionJobHandler extends IJobHandler {
         List<ProEconReportIndicatorPool> pools = reportIndicatorPoolService.list(wrapperrp);
 
 
-
         QueryWrapper<ProEconReportIndicatorPool> wrapperrp2 = new QueryWrapper<>();
         wrapperrp2.eq("record_date", time0).eq("foreign_key_id", "GJNY_SXGS_DBXNY_ZGS0");
         ProEconReportIndicatorPool pools2 = reportIndicatorPoolService.getOne(wrapperrp2);
 
-        if (pools2 == null){
+        if (pools2 == null) {
             ProEconReportIndicatorPool GSPJFS = new ProEconReportIndicatorPool();
             GSPJFS.setRecordDate(time0.toLocalDateTime().toLocalDate());
             GSPJFS.setForeignKeyId("GJNY_SXGS_DBXNY_ZGS0");
@@ -1997,15 +1993,13 @@ public class JavaFunctionJobHandler extends IJobHandler {
     }
 
 
-
     public void calcRealtimeTurbineZt() {
         DateTime date = DateUtil.date();
-
         List<PointInfo> turbineZt = calcRealtimeTurbineDizt();
         List<PointInfo> turbineAizt = calcRealtimeTurbineAizt();
         turbineZt.addAll(turbineAizt);
         turbineZt = turbineZt.stream().peek(t -> {
-            if (t.getPointDatas().get(0).getTs() + 9 * 60 * 1000 <= date.getTime()) {
+            if (t.getPointDatas().get(0).getTs() + 12 * 60 * 1000 <= date.getTime()) {
                 t.getPointDatas().get(0).setDoubleValue(12.0);
             }
         }).collect(Collectors.toList());
@@ -2017,25 +2011,14 @@ public class JavaFunctionJobHandler extends IJobHandler {
         //出线
         List<PointInfo> entityCx = getEntity("AGC001", "booster");
         getSnapDataByEntity(entityCx, DateUtil.offsetMinute(date, -5), date, 15);
-        //叶轮转速给定
-        List<PointInfo> entityYlzsgd = getEntity("AI110", "turbine");
-        getLatestByEntity(entityYlzsgd);
         //风速
         List<PointInfo> entityFs = getEntity("AI066", "turbine");
         getSnapDataByEntity(entityFs, DateUtil.offsetMinute(date, -5), date, 15);
-        //功率
-        List<PointInfo> entityGl = getEntity("AI114", "turbine");
-        //getLatestByEntity(entityFs);
-        getLatestByEntity(entityGl);
 
         Map<String, PointInfo> collectAgc = entityAgc.stream().collect(Collectors.toMap(PointInfo::getStationId, Function.identity()));
         Map<String, PointInfo> collectCx = entityCx.stream().collect(Collectors.toMap(PointInfo::getStationId, Function.identity()));
-        Map<String, Map<String, List<PointData>>> collectYlzsgd = entityYlzsgd.stream().collect(Collectors.groupingBy(PointInfo::getStationId,
-                Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas)));
         Map<String, Map<String, PointInfo>> fsMapMap = entityFs.stream().collect(Collectors.groupingBy(PointInfo::getStationId,
                 Collectors.toMap(PointInfo::getTurbineId, Function.identity())));
-        Map<String, Map<String, List<PointData>>> glMapMap = entityGl.stream().collect(Collectors.groupingBy(PointInfo::getStationId,
-                Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas)));
 
         ztMapMap.forEach((stId, ztMap) -> {
             PointInfo agcInfo = collectAgc.get(stId);
@@ -2064,19 +2047,38 @@ public class JavaFunctionJobHandler extends IJobHandler {
             }).collect(Collectors.toList());
             cxInfo.setPointDatas(cxc);
 
+
             //风机风速、功率->场站风速、功率
             List<PointData> firstZsgl = new ArrayList<>();
-            double v3 = pdsZsglMap.values().stream().mapToDouble(pds -> pds.get(0).getValue()).sum();
-            firstZsgl.add(new PointData(date.getTime(), v3));
+            double v3;
+            for (int i = 0; i < 20; i++) {
+                int finalI = i;
+                long ts = date.getTime() + i * 15000;
+                v3 = pdsZsglMap.values().stream().mapToDouble(pds -> pds.get(finalI).getValue()).sum();
+                firstZsgl.add(new PointData(ts, v3));
+            }
 
-            List<PointData> czxd = calcStationXd2(agcInfo, cxInfo.getPointDatas(), firstZsgl);
-            ztMap.forEach((wtId, ztInfo) -> {
-                List<PointData> fss = fsMap.get(wtId).getPointDatas();
-                List<PointData> gls = glMapMap.get(stId).get(wtId);
+            boolean czxd = calcRealtimeStationXd(agcInfo, cxInfo.getPointDatas(), firstZsgl);
+            if (czxd) {
                 //叶轮转速给定
-                List<PointData> ylzsgds = collectYlzsgd.get(stId).get(wtId);
-                calcRealtimeTurbineXd(ztInfo, gls.get(0), fss.get(fss.size() - 1), ylzsgds.get(0), czxd.get(czxd.size() - 1));
-            });
+                List<PointInfo> entityYlzsgd = getEntity("AI110", "turbine");
+                getLatestByEntity(entityYlzsgd);
+                //功率
+                List<PointInfo> entityGl = getEntity("AI114", "turbine");
+                getLatestByEntity(entityGl);
+                Map<String, Map<String, List<PointData>>> collectYlzsgd = entityYlzsgd.stream().collect(Collectors.groupingBy(PointInfo::getStationId,
+                        Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas)));
+                Map<String, Map<String, List<PointData>>> glMapMap = entityGl.stream().collect(Collectors.groupingBy(PointInfo::getStationId,
+                        Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas)));
+
+                ztMap.forEach((wtId, ztInfo) -> {
+                    List<PointData> fss = fsMap.get(wtId).getPointDatas();
+                    List<PointData> gls = glMapMap.get(stId).get(wtId);
+                    //叶轮转速给定
+                    List<PointData> ylzsgds = collectYlzsgd.get(stId).get(wtId);
+                    calcRealtimeTurbineXd(ztInfo, gls.get(0), fss.get(fss.size() - 1), ylzsgds.get(0));
+                });
+            }
         });
 
         Map<String, String> entityMxzt = getEntityMap("MXZT", "turbine");
@@ -2121,12 +2123,13 @@ public class JavaFunctionJobHandler extends IJobHandler {
         entity.addAll(entity2);
         entity.addAll(entity4);
         entity.addAll(entity6);
-        List<String> keys = entity.stream().map(PointInfo::getPointKey).collect(Collectors.toList());
-        Map<String, PointData> latest = adapter.getLatest(goldenUri(), String.join(",", keys));
+        String keys = entity.stream().map(PointInfo::getPointKey).collect(Collectors.joining(","));
+        Map<String, PointData> latest = adapter.getLatest(goldenUri(), keys);
 
         Map<String, Map<String, PointInfo>> wtUcPis = entity.stream().collect(Collectors.groupingBy
                 (PointInfo::getTurbineId, Collectors.toMap(PointInfo::getUniformCode, Function.identity())));
         wtUcPis.forEach((wtId, map) -> {
+            String collect = map.values().stream().map(PointInfo::getPointKey).collect(Collectors.joining(","));
             PointInfo info2 = map.get("MX002");
             PointData data2 = latest.get(info2.getPointKey());
             if (data2.getValue() == 1.0) {
@@ -2167,6 +2170,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
                                 info1.setPointDatas(Collections.singletonList(data1));
                                 result.add(info1);
                             } else {
+                                Map<String, PointData> latest2 = adapter.getLatest(goldenUri(), collect);
                                 data1.setDoubleValue(2.0);
                                 System.out.println("wtId: " + wtId + ",状态值无批配: " + data1.getValue());
                                 info1.setPointDatas(Collections.singletonList(data1));
@@ -2207,12 +2211,12 @@ public class JavaFunctionJobHandler extends IJobHandler {
         }
     }
 
-    public void calcRealtimeTurbineXd(PointInfo ztInfo, PointData gl, PointData fs, PointData ylzsgd, PointData czxd) {
+    public void calcRealtimeTurbineXd(PointInfo ztInfo, PointData gl, PointData fs, PointData ylzsgd) {
         Map<String, EquipmentModel> map = equipmentModelService.map();
         Double capacity = map.get(ztInfo.getSpare()).getPowerProduction();
         PointData zt = ztInfo.getPointDatas().get(0);
 
-        if (czxd.isBooleanValue() && gl.getValue() < capacity * 0.9) {
+        if (gl.getValue() < capacity * 0.9) {
             if (fs.getValue() >= 12) {
                 zt.setDoubleValue(8.0);
             }
@@ -2221,6 +2225,58 @@ public class JavaFunctionJobHandler extends IJobHandler {
             }
         }
     }
+
+    //此处加公式
+    public boolean calcRealtimeStationXd(PointInfo agcInfo, List<PointData> cxSnap, List<PointData> zsglSnap) {
+        String stId = agcInfo.getStationId();
+
+        List<PointData> agcSnap = agcInfo.getPointDatas();
+        List<PointData> zsgl5s = get5Avg(zsglSnap);
+        List<PointData> agc5s = get5Avg(agcSnap);
+        List<PointData> cx5s = get5Avg(cxSnap);
+        //之前是否限电
+        boolean iszqxd = false;
+        for (int i = 0; i < zsglSnap.size(); i++) {
+            boolean isxd = false;
+            double zsgl = zsglSnap.get(i).getValue();
+            double zsgl5 = zsgl5s.get(i).getValue();
+            double agc = agcSnap.get(i).getValue();
+            double agc5 = agc5s.get(i).getValue();
+            double cxgl = cxSnap.get(i).getValue();
+            double cxgl5 = cx5s.get(i).getValue();
+
+            boolean k;   //agc一直不变
+            //第一次初始化复制实时数据到缓存
+            if (CalcCache.powerCacheRt.get(stId) == null || CalcCache.powerCacheRt.get(stId) != agc) {
+                CalcCache.powerCacheRt.put(stId, agc);
+                k = false;
+            } else {
+                k = true;
+            }
+            if (agc != 0) {
+                //如果场站限电状态为不限电
+                if (zsgl5 >= agcInfo.getSpare2() * 40) {
+                    if (agc5 <= cxgl5) {
+                        isxd = true;
+                    } else if (iszqxd) {
+                        if (zsgl / agc > 1.15) {
+                            isxd = true;
+                        } else if (zsgl > agc && agc5 - cxgl5 < 400) {
+                            isxd = true;
+                        }
+                    } else if (zsgl / agc >= 1.2 && agc - cxgl <= 200) {
+                        isxd = true;
+                    }
+                } else if (k) {
+                    if (zsgl / agc >= 1.1 && agc5 - cxgl5 <= 200) {
+                        isxd = true;
+                    }
+                }
+            }
+            iszqxd = isxd;
+        }
+        return iszqxd;
+    }
 }
 
 

+ 3 - 2
ruoyi-admin/src/test/java/com/ruoyi/NewTests.java

@@ -58,11 +58,12 @@ public class NewTests {
 //            task.calcTurbine5s2(date);
 
         }
-        task.calcGlqxnh(start,end);
+//        task.calcGlqxnh(start,end);
 //        calcTurbineRFDL(date);
-        task.calcTurbine5s2(date);
+//        task.calcTurbine5s2(date);
 //        writeReportPool(date);
 
 //        task.calcStationSspjfs();
+        task.calcRealtimeTurbineZt();
     }
 }

+ 2 - 2
ruoyi-admin/src/test/java/com/ruoyi/Test.java

@@ -125,8 +125,8 @@ public class Test {
     @org.junit.Test
     public void test1() {
         Date date = DateUtil.date().toJdkDate();
-        javaFunctionJobHandler.writeReportPool(date);
-        javaFunctionJobHandler.writeReportPoolProject(date);
+//        javaFunctionJobHandler.writeReportPool(date);
+//        javaFunctionJobHandler.writeReportPoolProject(date);
         javaFunctionJobHandler.writeReportPoolPjfs(date);
 
     }

+ 1 - 1
universal-computing-platform/src/main/java/com/ruoyi/ucp/feign/AdapterApi.java

@@ -54,6 +54,6 @@ public interface AdapterApi {
     @PostMapping("/latest2")
     Boolean writeHistory(URI baseUri, @RequestBody PointData tsData);
 
-    @PostMapping("/latest/batch2")
+    @PostMapping("/latest2/batch")
     Boolean writeHistoryBatch(URI baseUri, @RequestBody List<PointData> tsData);
 }

+ 1 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/util/CalcCache.java

@@ -12,6 +12,7 @@ public class CalcCache {
     public static Map<String, ConcurrentHashMap<Double, Double>> wtMcfMap = new ConcurrentHashMap<>();
     public static Map<String, ConcurrentHashMap<Double, Double>> fitcoef = new ConcurrentHashMap<>();
     public static Map<String, Double> powerCache = new ConcurrentHashMap<>();
+    public static Map<String, Double> powerCacheRt = new ConcurrentHashMap<>();
     /**
      * 保证功率
      */