GYEE 6 月之前
父節點
當前提交
fee258ce69

+ 18 - 22
ruoyi-admin/src/main/java/com/ruoyi/web/controller/JavaFunctionJobHandler.java

@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateField;
 import cn.hutool.core.date.DateRange;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.lang.Dict;
 import cn.hutool.core.text.StrBuilder;
 import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.core.util.NumberUtil;
@@ -35,6 +36,7 @@ import java.util.function.Function;
 import java.util.stream.Collectors;
 
 @Service
+//@Service
 public class JavaFunctionJobHandler extends IJobHandler {
     private static Logger logger = LoggerFactory.getLogger(JavaFunctionJobHandler.class);
 
@@ -536,7 +538,8 @@ public class JavaFunctionJobHandler extends IJobHandler {
             }
             wrapper.clear();
             wrapper.lambda().between(StationInfoDay::getRecordDate, beginTq, endTq);
-            List<StationInfoDay> sids = stationInfoDayService.list(wrapper);
+//            List<StationInfoDay> sids = stationInfoDayService.list(wrapper);
+            List<StationInfoDay> sids = null;
             Map<String, List<StationInfoDay>> sidMap;
             if (CollUtil.isNotEmpty(sids)) {
                 sidMap = sids.stream().collect(Collectors.groupingBy(StationInfoDay::getStationId));
@@ -955,7 +958,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
 
         List<PointInfo> entity = getEntity("Z-ZXYG-JX", "meter");
         entity = entity.stream().filter(e -> !"".equals(e.getProjectId())).collect(Collectors.toList());
-        getZeroNextData(entity, time0, time);
+        getSectionDataByEntity(entity,goldenUri(), time0, time);
         Map<String, PointInfo> swdlMap = entity.stream().collect(Collectors.toMap(PointInfo::getLineId, Function.identity()));
         List<LineInfoDay> byDate = getLineinfoByDate(time0, entity);
         String lineId;
@@ -1452,6 +1455,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
             infoDay.setSlss(0.0);
             infoDay.setDjss(loss.get("djss"));
             infoDay.setGzss(loss.get("gzss"));
+            infoDay.setXnss(loss.get("xnss"));
             //if (infoDay.getRfdl() == 0) {
             //    infoDay.setXnss(0.0);
             //} else {
@@ -3582,9 +3586,9 @@ public class JavaFunctionJobHandler extends IJobHandler {
                                 info1.setPointDatas(Collections.singletonList(data1));
                                 result.add(info1);
                             } else {
+                                System.out.println("wtId: " + wtId + ",状态值无批配: " + data1.getValue());
                                 //                                Map<String, PointData> latest2 = adapter.getLatest(goldenUri(), collect);
                                 data1.setDoubleValue(2.0);
-                                System.out.println("wtId: " + wtId + ",状态值无批配: " + data1.getValue());
                                 info1.setPointDatas(Collections.singletonList(data1));
                                 result.add(info1);
                             }
@@ -3656,8 +3660,8 @@ public class JavaFunctionJobHandler extends IJobHandler {
                                 info1.setPointDatas(Collections.singletonList(data1));
                                 result.add(info1);
                             } else {
-                                data1.setDoubleValue(2.0);
                                 System.out.println("wtId: " + wtId + ",状态值无批配: " + data1.getValue());
+                                data1.setDoubleValue(2.0);
                                 info1.setPointDatas(Collections.singletonList(data1));
                                 result.add(info1);
                             }
@@ -4361,7 +4365,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         List<PointInfo> entityFdl = getEntity("AI121", "turbine");
         getSectionDataByEntity(entityFdl, goldenUri(), start, date);
 
-        List<TurbineInfoMin> mins = getTurbineinfoByMin(date, entityFs);
+        List<TurbineInfoMin> mins = getTurbineinfoByMin(start, entityFs);
         for (TurbineInfoMin min : mins) {
             String tbId = min.getTurbineId();
             List<PointData> fsDatas = rawMapFs.get(tbId).getPointDatas();
@@ -4557,8 +4561,8 @@ public class JavaFunctionJobHandler extends IJobHandler {
                                 info1.setPointDatas(Collections.singletonList(data1));
                                 result.add(info1);
                             } else {
-                                data1.setDoubleValue(2.0);
                                 System.out.println("wtId: " + wtId + ",状态值无批配: " + data1.getValue());
+                                data1.setDoubleValue(2.0);
                                 info1.setPointDatas(Collections.singletonList(data1));
                                 result.add(info1);
                             }
@@ -4590,7 +4594,8 @@ public class JavaFunctionJobHandler extends IJobHandler {
         return entityAiZt;
     }
 
-    public void calcStationSjglAgcPjfsHjwdDlMin(Date time,Map<String, Double> fjhjwd) {
+    public void calcStationSjglAgcPjfsHjwdDlMin(Date time) {
+        Dict fjhjwd = CalcCache.dictMap.get("fjhjwd");
         DateTime end = DateUtil.beginOfMinute(time);
         int i = Math.floorDiv(end.minute(), 15) * 15;
         end.setMinutes(i);
@@ -4613,10 +4618,10 @@ public class JavaFunctionJobHandler extends IJobHandler {
         Map<String, List<PointInfo>> fdlsMap = entity.stream().collect(Collectors.groupingBy(PointInfo::getStationId));
 
         QueryWrapper<TurbineInfoMin> wrapper = new QueryWrapper<>();
-        wrapper.select("sum(llgl) llgl,sum(kygl) kygl,avg(pjfs) pjfs,station_id").eq("record_date", end).groupBy("station_id");
+        wrapper.select("sum(llgl) llgl,sum(kygl) kygl,avg(pjfs) pjfs,station_id").eq("record_date", begin).groupBy("station_id");
         List<TurbineInfoMin> list = turbineInfoMinService.list(wrapper);
         Map<String, TurbineInfoMin> minMap = list.stream().collect(Collectors.toMap(TurbineInfoMin::getStationId, Function.identity()));
-        List<StationInfoMin> byDate = getStationinfoByMin(end, entityAgc);
+        List<StationInfoMin> byDate = getStationinfoByMin(begin, entityAgc);
         Map<String, Map<Double, Long>> zttsMap = calcSectionStationZtts(end);
         for (StationInfoMin day : byDate) {
             String id = day.getStationId();
@@ -4637,6 +4642,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
             double rfdl = fdlInfos.stream().mapToDouble(pi -> {
                 double v = (pi.getPointDatas().get(1).getValue() - pi.getPointDatas().get(0).getValue()) * pi.getCoef();
                 if (v < 0) v = 0;
+                System.out.println(pi.getLineId()+","+v);
                 return v;
             }).sum();
             if (rfdl >= 42400.0) rfdl = day.getPjgl() / 4.0;
@@ -4657,7 +4663,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
                 double v = wd.getPointDatas().stream().filter(p -> p.getValue() != 0.0).mapToDouble(PointData::getValue).average().orElse(0.0);
                 if (v > 83) v = 0;
                 if (v == 0) {
-                    v = fjhjwd.getOrDefault(wd.getTurbineId(), 0.0);
+                    v = fjhjwd.get(wd.getTurbineId(), 0.0);
                 } else {
                     fjhjwd.put(wd.getTurbineId(), v);
                 }
@@ -5732,7 +5738,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         }
     }
 
-    public void calcCdqKhfs(Date date) {
+    public void calcKhfs(Date date) {
         DateTime begin = DateUtil.offsetDay(DateUtil.beginOfDay(date), -1);
         DateTime end = DateUtil.offsetDay(DateUtil.endOfDay(date), -1);
         DateTime beginDq = DateUtil.offsetDay(begin, -2);
@@ -5827,7 +5833,6 @@ public class JavaFunctionJobHandler extends IJobHandler {
                 calculateForecastScore(examin2, ycglss, sjglss, WIND_STANDARD, capacity, pdtHour.getHours());
                 peList.add(examin2);
             });
-
         }
         QueryWrapper<PredictExamin2> examin2Wrapper = new QueryWrapper<>();
         examin2Wrapper.eq("predict_type", "DQ").eq("device_type", "station")
@@ -5894,8 +5899,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         double Q_D2 = calculatePenalty(splitForecast.get(1), Pi_rs1, capacity, dtlMap);
         List<Double> Pi_rs2 = splitActual.get(2).stream().map(StationInfoMin::getPjgl).collect(Collectors.toList());
         double Q_D3 = calculatePenalty(splitForecast.get(2), Pi_rs2, capacity, dtlMap);
-        double[] weights = {0.6, 0.3, 0.1};
-        return Q_D1 * weights[0] + Q_D2 * weights[1] + Q_D3 * weights[2];
+        return Q_D1 * 0.6d + Q_D2 * 0.3d + Q_D3 * 0.1d;
     }
 
     /**
@@ -5963,14 +5967,6 @@ public class JavaFunctionJobHandler extends IJobHandler {
         return K;
     }
 
-    //    private double calculateWeightedSum(double[] integralDifferences, double weight) {
-    //        double sum = 0;
-    //        for (double diff : integralDifferences) {
-    //            sum += diff;
-    //        }
-    //        return sum * weight;
-    //    }
-
     /**
      * 计算超短期预测考核总分
      */

+ 3 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/runner/LoadDataSourceRunner.java

@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateRange;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.io.file.FileReader;
+import cn.hutool.core.lang.Dict;
 import com.alibaba.druid.pool.DruidDataSource;
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.TypeReference;
@@ -32,6 +33,7 @@ import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Collectors;
 
+//@Component
 @Component
 public class LoadDataSourceRunner implements CommandLineRunner {
     @Resource
@@ -72,6 +74,7 @@ public class LoadDataSourceRunner implements CommandLineRunner {
         List<DruidDataSource> dataSources = BeanUtil.copyToList(list, DruidDataSource.class);
         dynamicDataSource.createDataSource(dataSources);
 
+        CalcCache.dictMap.put("fjhjwd", Dict.create());
         //engine.put("adapter", adapter);
         //engine.put("pointService", pointService);
         //engine.put("stationInfoDayService", stationInfoDayService);

+ 50 - 0
ruoyi-admin/src/test/java/com/ruoyi/GetDataTest.java

@@ -9,6 +9,8 @@ import cn.hutool.core.text.csv.CsvWriter;
 import cn.hutool.core.thread.ExecutorBuilder;
 import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.core.util.CharsetUtil;
+import cn.hutool.poi.excel.BigExcelWriter;
+import cn.hutool.poi.excel.ExcelUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ruoyi.ucp.entity.*;
 import com.ruoyi.ucp.feign.AdapterApi;
@@ -17,6 +19,7 @@ import com.ruoyi.ucp.service.IProjectInfoMin2Service;
 import com.ruoyi.ucp.service.IStationInfoMin2Service;
 import com.ruoyi.ucp.service.IStationInfoMinService;
 import com.ruoyi.web.controller.JavaFunctionJobHandler;
+import com.ruoyi.web.controller.PredictController;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.boot.test.context.SpringBootTest;
@@ -47,6 +50,8 @@ public class GetDataTest {
     private IStationInfoMin2Service stationInfoMin2Service;
     @Resource
     private IProjectInfoMin2Service projectInfoMin2Service;
+    @Resource
+    private PredictController predictController;
 
     @Test
     public void test2() {
@@ -406,4 +411,49 @@ public class GetDataTest {
         writer.writeBeans(values);
         writer.flush();
     }
+
+    @Test
+    public void test13() {
+        QueryWrapper<PointInfo> wrapper = new QueryWrapper<>();
+        wrapper.lambda().eq(PointInfo::getInstitutionType, "project")
+                .in(PointInfo::getUniformCode, "YXTS");
+        List<PointInfo> pjl = pointInfoService.list(wrapper);
+        Map<String, String> pjMap = pjl.stream().collect(Collectors.toMap(PointInfo::getProjectId, PointInfo::getSpare));
+
+        DateTime begin = DateUtil.parse("2024-01-01 00:15:00");
+        DateTime end = DateUtil.parse("2024-12-06 00:15:00");
+        QueryWrapper<ProjectInfoMin2> min2=new QueryWrapper<>();
+        min2.lambda().between(ProjectInfoMin2::getRecordDate,begin,end).orderByAsc(ProjectInfoMin2::getRecordDate);
+        List<ProjectInfoMin2> list = projectInfoMin2Service.list(min2);
+        list.forEach(l->l.setRecordDate(DateUtil.offsetMinute(l.getRecordDate(),-15)));
+        Map<String, TreeMap<String, List<ProjectInfoMin2>>> collect = list.stream().collect(Collectors.groupingBy(ProjectInfoMin2::getProjectId, Collectors
+                .groupingBy(l -> DateUtil.format(l.getRecordDate(), "yyyy-MM-dd HH"), TreeMap::new, Collectors.toList())));
+        BigExcelWriter writer= ExcelUtil.getBigWriter("d:/dl.xlsx");
+        collect.forEach((pjId,pim2Map)->{
+            List<ProjectInfoMin2> pim2s=new ArrayList<>();
+            pim2Map.forEach((time,pims)->{
+                ProjectInfoMin2 infoMin2 = new ProjectInfoMin2();
+                infoMin2.setStationId(pims.get(0).getStationId());
+                infoMin2.setProjectId(pims.get(0).getProjectId());
+                infoMin2.setRecordDate(DateUtil.parse(time,"yyyy-MM-dd HH"));
+                infoMin2.setRfdl(pims.stream().mapToDouble(ProjectInfoMin2::getRfdl).sum());
+                pim2s.add(infoMin2);
+            });
+            writer.setSheet(pjMap.get(pjId));
+            // 一次性写出内容,使用默认样式
+            writer.write(pim2s,true);
+        });
+        writer.flush();
+        // 关闭writer,释放内存
+        writer.close();
+    }
+    @Test
+    public void test14() {
+        DateTime begin = DateUtil.parse("2024-11-24");
+        DateTime end = DateUtil.parse("2024-12-06 00:15:00");
+        List<String> pjs=Arrays.asList("GJNY_SXGS_CSLF01_EG","GJNY_SXGS_FSGF01_EG","GJNY_SXGS_FSGF02_EG","GJNY_SXGS_JSLF01_EG","GJNY_SXGS_JSLF02_EG","GJNY_SXGS_JSLF03_EG","GJNY_SXGS_LJSF01_EG","GJNY_SXGS_LJSF02_EG","GJNY_SXGS_XZF01_EG","GJNY_SXGS_XZF02_EG","GJNY_SXGS_ZZF01_EG","GJNY_SXGS_ZZF02_EG");
+        for (String pj : pjs) {
+            predictController.latestProject(pj,"2024-11-24","2024-12-06 01:00:00");
+        }
+    }
 }

+ 23 - 13
ruoyi-admin/src/test/java/com/ruoyi/NewTests.java

@@ -62,12 +62,12 @@ public class NewTests {
         System.out.println(sb3);
         System.out.println();*/
 
-        Date date = DateUtil.parse("2024-10-10");
+        Date date = DateUtil.parse("2024-12-04");
 //        task.calcTurbineSsfsQx(date);
 //        task.ambientTemperature();
 
 //        task.calcTurbine5s2(date);
-//        task.calcLineRfdl(date);
+        task.calcLineRfdl(date);
 
 //        task.calcStationZhcyRfDl(date,"GJNY_SXGS_XZ_FDC_STA");
 //        task.writeReportPool(date);
@@ -213,8 +213,20 @@ public class NewTests {
     @Test
     public void test5() {
         DateTime date = DateUtil.date();
+//        DateTime date = DateUtil.parseDate("2023-01-01");
         //task.calcTurbineStateMin(date);
-        task.calcStationRjhfdl(date);
+//        task.calcStationRjhfdl(date);
+//        task.calcKhfs(date);
+
+        task.calcTurbine5s2(date);
+        //风机状态时间
+        task.calcTurbineStateMin(date);
+        task.writeReportPool5SPjfsLlfdlZtsj(date);
+        //风机日切入
+        task.cutInWindSpeed();
+        //风机日额定风速
+        task.calcGlqxnh_edfs();
+        task.calcPredictExamin2(date);
     }
 
     public static void main(String[] args) {
@@ -227,21 +239,19 @@ public class NewTests {
 
     @Test
     public void test6() {
-        DateTime begin = DateUtil.parse("2024-11-07 22:30:00");
-        DateTime end = DateUtil.parse("2024-11-07 22:46:00");
+        DateTime begin = DateUtil.parse("2024-12-04 00:00:00");
+        DateTime end = DateUtil.parse("2024-12-05 00:00:00");
 //        DateTime date = DateUtil.date();
 //        DateTime begin = DateUtil.beginOfDay(date);
 //        begin = DateUtil.offsetMinute(begin, 15);
 //        DateTime end = date;
-        int i = 1;
-        DateTime minBegin = begin, minEnd = DateUtil.offsetMinute(begin, 15);
+        DateTime minEnd = begin;
         while (minEnd.isBefore(end)) {
-            minEnd = DateUtil.offsetMinute(begin, i * 15);
-            task.calcStationLlglKyglSjglAgcMin(minBegin, 15);
-//            task.calcStationSjglAgcPjfsHjwdDlMin(minEnd);
-            System.out.println(minBegin.toString() + "," + minEnd.toString());
-            i++;
-            minBegin = minEnd;
+            minEnd = DateUtil.offsetMinute(begin, 15);
+            task.calcTurbinePjfsPjglKyglLlglMin(minEnd);
+            task.calcStationSjglAgcPjfsHjwdDlMin(minEnd);
+            System.out.println(begin + "," + minEnd);
+            begin = minEnd;
         }
     }
     @Test

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

@@ -129,6 +129,7 @@ public class HistoryPredict implements Serializable {
     }
 
     public void setPredictPower(Double predictPower) {
+        if (predictPower == null || predictPower < 0) predictPower = 0.0;
         this.predictPower = predictPower;
     }
 
@@ -137,6 +138,7 @@ public class HistoryPredict implements Serializable {
     }
 
     public void setPredictEnergy(Double predictEnergy) {
+        if (predictEnergy == null || predictEnergy < 0) predictEnergy = 0.0;
         this.predictEnergy = predictEnergy;
     }
 

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

@@ -1,6 +1,7 @@
 package com.ruoyi.ucp.util;
 
 import cn.hutool.core.date.DateTime;
+import cn.hutool.core.lang.Dict;
 
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
@@ -29,4 +30,5 @@ public class CalcCache {
     public static List<String> already=new ArrayList<>();
 
     public static String keys = "";
+    public static Map<String, Dict> dictMap = new ConcurrentHashMap<>();
 }