GYEE 10 months ago
parent
commit
507f651332
1 changed files with 31 additions and 9 deletions
  1. 31 9
      ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java

+ 31 - 9
ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java

@@ -2502,7 +2502,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         List<PointInfo> turbineAizt = calcRealtimeTurbineAizt();
         turbineZt.addAll(turbineAizt);
         turbineZt = turbineZt.stream().peek(t -> {
-            if (t.getPointDatas().get(0).getTs() + 12 * 60 * 1000 <= date.getTime()) {
+            if (t.getPointDatas().get(0).getTs() + 35 * 60 * 1000 <= date.getTime()) {
                 t.getPointDatas().get(0).setDoubleValue(12.0);
             }
         }).collect(Collectors.toList());
@@ -2520,6 +2520,10 @@ public class JavaFunctionJobHandler extends IJobHandler {
         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, PointInfo>> fsMapMap = entityFs.stream().collect(Collectors.groupingBy(PointInfo::getStationId, Collectors.toMap(PointInfo::getTurbineId, Function.identity())));
+        //功率
+        List<PointInfo> entityGl = getEntity("AI114", "turbine");
+        getLatestByEntity(entityGl);
+        Map<String, List<PointData>> glMap = entityGl.stream().collect(Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas));
 
         ztMapMap.forEach((stId, ztMap) -> {
             PointInfo agcInfo = collectAgc.get(stId);
@@ -2547,7 +2551,6 @@ public class JavaFunctionJobHandler extends IJobHandler {
             }).collect(Collectors.toList());
             cxInfo.setPointDatas(cxc);
 
-
             //风机风速、功率->场站风速、功率
             List<PointData> firstZsgl = new ArrayList<>();
             double v3;
@@ -2563,23 +2566,32 @@ public class JavaFunctionJobHandler extends IJobHandler {
                 //叶轮转速给定
                 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)));
+
+                Map<String, List<PointData>> collectYlzsgd = entityYlzsgd.stream().collect(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> gls = glMap.get(wtId);
                     //叶轮转速给定
-                    List<PointData> ylzsgds = collectYlzsgd.get(stId).get(wtId);
+                    List<PointData> ylzsgds = collectYlzsgd.get(wtId);
                     calcRealtimeTurbineXd(ztInfo, gls.get(0), fss.get(fss.size() - 1), ylzsgds.get(0));
                 });
             }
         });
 
         Map<String, String> entityMxzt = getEntityMap("MXZT", "turbine");
+        Map<String, String>  entityQfzt = getEntityMap("SSQFZT", "turbine");
+
+        List<PointData> qfztDataList = entityFs.stream().map(qfzt->{
+            String wtId = qfzt.getTurbineId();
+            PointData data = qfzt.getPointDatas().get(qfzt.getPointDatas().size()-1);
+            data.setTs(date.getTime());
+            data.setTagName(entityQfzt.get(wtId));
+            data.setDoubleValue(calcQfzt(glMap.get(wtId).get(0).getValue(),CalcCache.fitcoef.get(wtId).get(data.getValue())));
+            return data;
+        }).collect(Collectors.toList());
+
+        //风机状态转换为写适配器的测点与值
         List<PointData> dataList = turbineZt.stream().map(zt -> {
             PointData data = zt.getPointDatas().get(0);
             data.setTs(date.getTime());
@@ -2588,6 +2600,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         }).collect(Collectors.toList());
         if (isOnMin) {
             adapter.writeHistoryBatch(taosUri(), dataList);
+            adapter.writeHistoryBatch(taosUri(), qfztDataList);
         } else {
             List<PointData> collect = dataList.stream().filter(d -> {
                 if (Objects.equals(CalcCache.statusCache.get(d.getTagName()), d.getValue())) {
@@ -2597,7 +2610,16 @@ public class JavaFunctionJobHandler extends IJobHandler {
                     return true;
                 }
             }).collect(Collectors.toList());
+            List<PointData> collect2 = qfztDataList.stream().filter(d -> {
+                if (Objects.equals(CalcCache.qfztCache.get(d.getTagName()), d.getValue())) {
+                    return false;
+                } else {
+                    CalcCache.qfztCache.put(d.getTagName(), d.getValue());
+                    return true;
+                }
+            }).collect(Collectors.toList());
             adapter.writeHistoryBatch(taosUri(), collect);
+            adapter.writeHistoryBatch(taosUri(), collect2);
         }
     }
     //此处加公式