Browse Source

场站属性获取

xushili 7 tháng trước cách đây
mục cha
commit
f66ef5e8b2

+ 51 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/JavaFunctionJobHandler.java

@@ -4057,6 +4057,57 @@ public class JavaFunctionJobHandler extends IJobHandler {
         stationInfoMinService.saveOrUpdateBatch(byDate);
     }
 
+    public void calcStationSjglAgcPjfsHjwdDlMin(Date begin, Date end, String stId) {
+        //AGC
+        List<PointInfo> entityAgc = getEntity("AGC002", "booster");
+        entityAgc = entityAgc.stream().filter(e -> stId.equals(e.getStationId())).collect(Collectors.toList());
+        Map<String, PointInfo> statMapAgc = getStatDataByEntity(entityAgc, goldenUri(), begin, end, PointInfo::getStationId);
+        //出线
+        List<PointInfo> entityCx = getEntity("AGC001", "booster");
+        entityCx = entityCx.stream().filter(e -> stId.equals(e.getStationId())).collect(Collectors.toList());
+        Map<String, PointInfo> statMapCx = getStatDataByEntity(entityCx, goldenUri(), begin, end, PointInfo::getStationId);
+        //风速
+        List<PointInfo> entityFs = getEntity("AI066", "turbine");
+        entityFs = entityFs.stream().filter(e -> stId.equals(e.getStationId())).collect(Collectors.toList());
+        getStatDataByEntity(entityFs, goldenUri(), begin, end);
+        Map<String, List<PointInfo>> fssMap = entityFs.stream().collect(Collectors.groupingBy(PointInfo::getStationId));
+        //环境温度
+        List<PointInfo> entityHjwd = getEntity("AI072", "turbine");
+        entityHjwd = entityHjwd.stream().filter(e -> stId.equals(e.getStationId())).collect(Collectors.toList());
+        getStatDataByEntity(entityHjwd, goldenUri(), begin, end);
+        Map<String, List<PointInfo>> hjwdsMap = entityHjwd.stream().collect(Collectors.groupingBy(PointInfo::getStationId));
+        //日发电量
+        List<PointInfo> entity = getEntity("Z-ZXYG-JX", "meter");
+        entity = entity.stream().filter(e -> !"".equals(e.getProjectId()) && stId.equals(e.getStationId())).collect(Collectors.toList());
+        getSectionDataByEntity(entity, goldenUri(), begin, end);
+        Map<String, List<PointInfo>> fdlsMap = entity.stream().collect(Collectors.groupingBy(PointInfo::getStationId));
+
+        List<StationInfoMin> byDate = getStationinfoByMin(end, entityAgc);
+
+        for (StationInfoMin day : byDate) {
+            String id = day.getStationId();
+            PointInfo agcInfo = statMapAgc.get(id);
+            PointInfo cxInfo = statMapCx.get(id);
+            List<PointInfo> fsInfos = fssMap.get(id);
+            double pjfs = fsInfos.stream().mapToDouble(pi -> pi.getPointDatas().get(0).getValue()).average().orElse(0);
+            List<PointInfo> hjwdInfos = hjwdsMap.get(id);
+            double hjwd = hjwdInfos.stream().mapToDouble(pi -> pi.getPointDatas().get(0).getValue()).average().orElse(0);
+            List<PointInfo> fdlInfos = fdlsMap.get(id);
+            double rfdl = fdlInfos.stream().mapToDouble(pi -> {
+                double v = (pi.getPointDatas().get(1).getValue() - pi.getPointDatas().get(0).getValue()) * pi.getCoef();
+                if (v < 0 || v > 720000) v = 0;
+                return v;
+            }).sum();
+
+            day.setAgc(agcInfo.getPointDatas().get(0).getValue() * agcInfo.getCoef());
+            day.setPjgl(cxInfo.getPointDatas().get(0).getValue() * cxInfo.getCoef());
+            day.setPjfs(pjfs);
+            day.setRfdl(rfdl);
+            day.setHjwd(hjwd);
+        }
+        stationInfoMinService.saveOrUpdateBatch(byDate);
+    }
+
     public void calcPredictExamin(Date date) {
         DateTime end = DateUtil.beginOfDay(date);
         DateTime begin = DateUtil.offsetDay(end, -1);

+ 35 - 20
ruoyi-admin/src/test/java/com/ruoyi/GetDataTest.java

@@ -8,20 +8,20 @@ import cn.hutool.core.thread.ExecutorBuilder;
 import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.core.util.CharsetUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.ruoyi.ucp.entity.*;
+import com.ruoyi.ucp.entity.GlycSj;
+import com.ruoyi.ucp.entity.PointData;
+import com.ruoyi.ucp.entity.PointInfo;
 import com.ruoyi.ucp.feign.AdapterApi;
-import com.ruoyi.ucp.service.*;
+import com.ruoyi.ucp.service.IPointInfoService;
 import com.ruoyi.web.controller.JavaFunctionJobHandler;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.scheduling.annotation.Async;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import javax.annotation.Resource;
 import java.net.URI;
 import java.util.*;
-import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
@@ -39,25 +39,40 @@ public class GetDataTest {
     private JavaFunctionJobHandler task;
 
     @Test
+    public void test2() {
+        DateTime begin = DateUtil.parse("2023-03-21");
+        DateTime end = DateUtil.parse("2024-10-30");
+        int i = 1;
+        DateTime minBegin = begin, minEnd = DateUtil.offsetMinute(begin, 15);
+        while (minEnd.isBefore(end)) {
+            minEnd = DateUtil.offsetMinute(begin, i * 15);
+            task.calcStationSjglAgcPjfsHjwdDlMin(minBegin, minEnd, "GJNY_SXGS_LJS_FDC_STA");
+            System.out.println(minBegin.toString() + "," + minEnd.toString());
+            i++;
+            minBegin = minEnd;
+        }
+    }
+
+    @Test
     public void test() {
         DateTime start = DateUtil.parse("2023-03-20");
         DateTime end = DateUtil.parse("2024-10-16");
-//        DateTime start = DateUtil.offsetMonth(end, -30);
-//        String[] names = {"AI004", "AI005", "AI006", "AI007", "AI008", "AI009", "AI073", "AI037", "AI039", "AI038", "AI047", "AI048", "AI056", "AI057", "AI060", "DI022", "AI066", "AI067", "AI069", "AI072", "AI074", "DI025", "DI080", "AI082", "AI084", "AI083", "AI065","AI114"};
+        //        DateTime start = DateUtil.offsetMonth(end, -30);
+        //        String[] names = {"AI004", "AI005", "AI006", "AI007", "AI008", "AI009", "AI073", "AI037", "AI039", "AI038", "AI047", "AI048", "AI056", "AI057", "AI060", "DI022", "AI066", "AI067", "AI069", "AI072", "AI074", "DI025", "DI080", "AI082", "AI084", "AI083", "AI065","AI114"};
         String[] names = {"AI114", "AI066", "AI060", "AI067", "AI082", "AI073", "AI004", "AI047", "AI072", "AI074"};
-//        String[] names = {"AI067"};
+        //        String[] names = {"AI067"};
         QueryWrapper<PointInfo> wrapper = new QueryWrapper<>();
         wrapper.lambda().eq(PointInfo::getInstitutionType, "turbine")
-//                .eq(PointInfo::getTurbineId, "GJNY_SXGS_LJS_F_WT_0011_EQ")
+                //                .eq(PointInfo::getTurbineId, "GJNY_SXGS_LJS_F_WT_0011_EQ")
                 .in(PointInfo::getUniformCode, names);
         List<PointInfo> list = pointInfoService.list(wrapper);
-//        String a = "GJNY_SXGS_ZZ_F_WT_0005_EQGJNY_SXGS_ZZ_F_WT_0028_EQGJNY_SXGS_ZZ_F_WT_0022_EQGJNY_SXGS_ZZ_F_WT_0045_EQGJNY_SXGS_ZZ_F_WT_0038_EQGJNY_SXGS_ZZ_F_WT_0035_EQGJNY_SXGS_ZZ_F_WT_0050_EQGJNY_SXGS_ZZ_F_WT_0019_EQGJNY_SXGS_ZZ_F_WT_0012_EQGJNY_SXGS_ZZ_F_WT_0002_EQGJNY_SXGS_ZZ_F_WT_0031_EQ";
-//        String a = "GJNY_SXGS_FSG_FDC_STA";
+        //        String a = "GJNY_SXGS_ZZ_F_WT_0005_EQGJNY_SXGS_ZZ_F_WT_0028_EQGJNY_SXGS_ZZ_F_WT_0022_EQGJNY_SXGS_ZZ_F_WT_0045_EQGJNY_SXGS_ZZ_F_WT_0038_EQGJNY_SXGS_ZZ_F_WT_0035_EQGJNY_SXGS_ZZ_F_WT_0050_EQGJNY_SXGS_ZZ_F_WT_0019_EQGJNY_SXGS_ZZ_F_WT_0012_EQGJNY_SXGS_ZZ_F_WT_0002_EQGJNY_SXGS_ZZ_F_WT_0031_EQ";
+        //        String a = "GJNY_SXGS_FSG_FDC_STA";
         String a = "GJNY_SXGS_FSG_F_WT_0022_EQ\n" +
                 "GJNY_SXGS_FSG_F_WT_0064_EQ\n";
-//        list=list.stream().filter(pi->a.equals(pi.getStationId())).collect(Collectors.toList());
-        list=list.stream().filter(pi->a.contains(pi.getTurbineId())).collect(Collectors.toList());
-//        list = list.stream().filter(pi -> "GJNY_SXGS_LJS_F_WT_0007_EQ".equals(pi.getTurbineId())).collect(Collectors.toList());
+        //        list=list.stream().filter(pi->a.equals(pi.getStationId())).collect(Collectors.toList());
+        list = list.stream().filter(pi -> a.contains(pi.getTurbineId())).collect(Collectors.toList());
+        //        list = list.stream().filter(pi -> "GJNY_SXGS_LJS_F_WT_0007_EQ".equals(pi.getTurbineId())).collect(Collectors.toList());
         Map<String, Map<String, List<PointInfo>>> collect = list.stream().collect(Collectors.groupingBy(PointInfo::getStationId, Collectors.groupingBy(PointInfo::getTurbineId)));
 
         ExecutorService executor = ExecutorBuilder.create()
@@ -80,8 +95,8 @@ public class GetDataTest {
                             GlycSj glycSj = null;
                             //AI066	风速,AI060	发电机转速,AI065	风机状态点,AI067	风向,AI082	桨叶1角度,AI073	机舱方向/对风角度
                             //AI004	U1绕组温度,AI047	电机温度2,AI072	环境温度,AI074	机舱温度
-                            if(s==null||s.isEmpty()){
-                                System.out.println(tbId+","+info.getUniformCode());
+                            if (s == null || s.isEmpty()) {
+                                System.out.println(tbId + "," + info.getUniformCode());
                             }
                             switch (info.getUniformCode()) {
                                 case "AI114":
@@ -94,10 +109,10 @@ public class GetDataTest {
                                         }
                                         glycSj.setGl(s.get(i).getValue());
 
-                                        glycSj.setZt(zt.get(i)==null?null:zt.get(i).getValue());
-//                                        glycSj.setActualTime(DateUtil.formatDateTime(DateUtil.date(zt.get(i)==null?0L:zt.get(i).getTs())));
+                                        glycSj.setZt(zt.get(i) == null ? null : zt.get(i).getValue());
+                                        //                                        glycSj.setActualTime(DateUtil.formatDateTime(DateUtil.date(zt.get(i)==null?0L:zt.get(i).getTs())));
                                         j += 60 * 1000 * 5;//GJNY_SXGS_LJS_F_WT_
-//                                    glycSj.setTurbineId(info.getTurbineId().replaceFirst("GJNY_SXGS_","").replaceFirst("F_WT_","").replaceFirst("_EQ",""));
+                                        //                                    glycSj.setTurbineId(info.getTurbineId().replaceFirst("GJNY_SXGS_","").replaceFirst("F_WT_","").replaceFirst("_EQ",""));
                                         glycSj.setTurbineId(info.getTurbineId().replaceFirst("GJNY_SXGS_.+_F_WT_", "").replaceFirst("_EQ", ""));
                                     }
                                     break;
@@ -229,7 +244,7 @@ public class GetDataTest {
                             e.printStackTrace();
                         }
                     }
-                    Future<String> b=ThreadUtil.execAsync(() -> {
+                    Future<String> b = ThreadUtil.execAsync(() -> {
                         writerData(map.values(), stId, tbId);
                         return "ok";
                     });
@@ -258,7 +273,7 @@ public class GetDataTest {
             }
         }
         //按行写出
-//        writer.write(new String[]{"时间", "时间戳", "对齐时间戳", "值"});
+        //        writer.write(new String[]{"时间", "时间戳", "对齐时间戳", "值"});
         /*writer.write(new String[]{"时间", "时间戳", "对齐时间戳", "值"});
         for (PointInfo pi : list) {
             if (pi.getPointKey().equals("INITIAL")) {

+ 2 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/StationInfoMin.java

@@ -44,4 +44,6 @@ public class StationInfoMin implements Serializable {
     private Double cdqycgl;
 
     private Double rfdl;
+
+    private Double hjwd;
 }