Browse Source

获取数据2

GYEE 4 months ago
parent
commit
d1a6d86c5f

+ 714 - 13
ruoyi-admin/src/main/java/com/ruoyi/web/controller/JavaFunctionJobHandler.java

@@ -62,6 +62,8 @@ public class JavaFunctionJobHandler extends IJobHandler {
     private IHistoryPredictService historyPredictService;
     @Resource
     private IPredictExaminService predictExaminService;
+    @Resource
+    private IStationInfoMin2Service stationInfoMin2Service;
 
     @Override
     public void execute() throws Exception {
@@ -143,6 +145,18 @@ public class JavaFunctionJobHandler extends IJobHandler {
         return list;
     }
 
+    public StationInfoMin2 getStationinfoByMin2(Date date, String stId) {
+        QueryWrapper<StationInfoMin2> wrapper = new QueryWrapper<>();
+        wrapper.eq("record_date", date).eq("station_id", stId);
+        StationInfoMin2 list = stationInfoMin2Service.getOne(wrapper, false);
+        if (list == null) {
+            list = new StationInfoMin2();
+            list.setStationId(stId);
+            list.setRecordDate(date);
+        }
+        return list;
+    }
+
     public StationInfoMin getStationinfoByMinOne(Date date, String stId) {
         QueryWrapper<StationInfoMin> wrapper = new QueryWrapper<>();
         wrapper.eq("record_date", date).eq("station_id", stId);
@@ -324,7 +338,8 @@ public class JavaFunctionJobHandler extends IJobHandler {
                 Double v = CalcCache.fitcoef.get(tbId).get(fsList.get(i).getValue());
                 if (v == null) v = 0.0;
                 v = v - glList.get(i).getValue();
-                double v2 = v > 0 ? v : 0;
+//                double v2 = v > 0 ? v : 0;
+                double v2 = v;
                 switch ((int) collectZt.get(i).getValue()) {
                     //计划检修损失:
                     case 6:
@@ -365,14 +380,14 @@ public class JavaFunctionJobHandler extends IJobHandler {
                 }
             }
         }
-        if (jxss > 30000) jxss = 0;
-        if (sdtj > 30000) sdtj = 0;
-        if (gzss > 30000) gzss = 0;
-        if (djss > 30000) djss = 0;
-        if (xnss > 30000) xnss = 0;
-        if (fdjcl > 30000) fdjcl = 0;
-        if (xdjcl > 30000) xdjcl = 0;
-        if (xdtj > 30000) xdtj = 0;
+        if (jxss > 3600000) jxss = 3600000;
+        if (sdtj > 3600000) sdtj = 3600000;
+        if (gzss > 3600000) gzss = 3600000;
+        if (djss > 3600000) djss = 3600000;
+        if (xnss > 3600000) xnss = 3600000;
+        if (fdjcl > 3600000) fdjcl = 3600000;
+        if (xdjcl > 3600000) xdjcl = 3600000;
+        if (xdtj > 3600000) xdtj = 3600000;
         //15秒*60分钟
         map.put("jxss", jxss > 0 ? jxss / 240 : 0);
         map.put("sdtj", sdtj > 0 ? sdtj / 240 : 0);
@@ -4145,8 +4160,13 @@ public class JavaFunctionJobHandler extends IJobHandler {
             ztDatas = doublePointDatasFull(2, ztDatas, start.getTime(), date.getTime(), 1);
             Map<Long, Double> ztMap = ztDatas.stream().collect(Collectors.toMap(PointData::getTs, PointData::getValue));
             double pjfs = fsDatas.stream().mapToDouble(PointData::getValue).average().orElse(0.0);
-            fsDatas.stream().peek(pd -> pd.setDoubleValue(pd.getValue() > 25 ? 25 : pd.getValue() < 0 ? 0 : NumberUtil.round(pd.getValue(), 2).doubleValue())).collect(Collectors.toList());
-            double llgl = fsDatas.stream().mapToDouble(pd -> pd.getValue() < 3 ? 0d : CalcCache.llgl.get(tbId).get(pd.getValue())).average().orElse(0.0);
+            fsDatas = fsDatas.stream().peek(pd -> pd.setDoubleValue(pd.getValue() >= 23 ? 23 : pd.getValue() < 0 ? 0 : NumberUtil.round(pd.getValue(), 2).doubleValue())).collect(Collectors.toList());
+            for (PointData fsData : fsDatas) {
+                if (fsData.getValue() > 3 && CalcCache.llgl.get(tbId).get(fsData.getValue()) == null) {
+                    System.out.println();
+                }
+            }
+            double llgl = fsDatas.stream().mapToDouble(pd -> pd.getValue() <= 3 ? 0d : CalcCache.llgl.get(tbId).get(pd.getValue())).average().orElse(0.0);
             double kygl = fsDatas.stream().filter(pd -> ztMap.get(pd.getTs()) != 4 || ztMap.get(pd.getTs()) != 6)
                     .mapToDouble(pd -> CalcCache.fitcoef.get(tbId).get(pd.getValue())).average().orElse(0.0);
             double sjgl = rawMapGl.get(tbId).getPointDatas().stream().mapToDouble(PointData::getValue).average().orElse(0.0);
@@ -4176,7 +4196,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         for (PointInfo fsPi : entityFs) {
             List<PointData> pds = fsPi.getPointDatas();
             Double pd = pds.stream().mapToDouble(PointData::getValue).average().orElse(0);
-            double fs = pd > 25 ? 25 : pd < 0 ? 0 : NumberUtil.round(pd, 2).doubleValue();
+            double fs = pd > 25 ? 24.99 : pd < 0 ? 0 : NumberUtil.round(pd, 2).doubleValue();
             double llgl = fs < 3 ? 0d : CalcCache.llgl.get(fsPi.getTurbineId()).get(fs);
             fsPi.setSpare2(llgl);
         }
@@ -4254,6 +4274,202 @@ public class JavaFunctionJobHandler extends IJobHandler {
         stationInfoMinService.saveOrUpdateBatch(byDate);
     }
 
+    public Map<String, Map<Double, Long>> calcSectionStationZtts(Date time) {
+        List<PointInfo> diztTs = calcSectionStationDiztTs(time);
+        List<PointInfo> aiztTs = calcSectionStationAiztTs(time);
+        diztTs.addAll(aiztTs);
+        Map<String, Map<Double, Long>> sdlMap = new HashMap<>();
+        //Map<Double, Long> longMap = result.stream().collect(Collectors.groupingBy(pi -> pi.getPointDatas().get(0).getValue(), Collectors.counting()));
+        Map<String, List<PointInfo>> collect = diztTs.stream().collect(Collectors.groupingBy(PointInfo::getStationId));
+        for (Map.Entry<String, List<PointInfo>> entry : collect.entrySet()) {
+            Map<Double, Long> map = entry.getValue().stream().collect(Collectors.groupingBy(pi -> pi.getPointDatas().get(0).getValue(), Collectors.counting()));
+            sdlMap.put(entry.getKey(), map);
+        }
+        return sdlMap;
+    }
+
+    public List<PointInfo> calcSectionStationDiztTs(Date time) {
+        List<PointInfo> entity = new ArrayList<>();
+        List<PointInfo> result = new ArrayList<>();
+        List<PointInfo> entity0 = getEntity("MX000", "state");
+        List<PointInfo> entity1 = getEntity("MX001", "state");
+        List<PointInfo> entity2 = getEntity("MX002", "state");
+        List<PointInfo> entity4 = getEntity("MX004", "state");
+        List<PointInfo> entity6 = getEntity("MX006", "state");
+        entity.addAll(entity0);
+        entity.addAll(entity1);
+        entity.addAll(entity2);
+        entity.addAll(entity4);
+        entity.addAll(entity6);
+        String keys = entity.stream().map(PointInfo::getPointKey).collect(Collectors.joining(","));
+        Map<String, PointData> latest = adapter.getHistorySection(goldenUri(), keys, time.getTime());
+
+        Map<String, Map<String, PointInfo>> wtUcPis = entity.stream().collect(Collectors.groupingBy(PointInfo::getTurbineId, Collectors.toMap(PointInfo::getUniformCode, Function.identity())));
+        wtUcPis.forEach((wtId, map) -> {
+            PointInfo info2 = map.get("MX002");
+            PointData data2 = latest.get(info2.getPointKey());
+            if (data2.getValue() == 1.0) {
+                data2.setDoubleValue(2.0);
+                data2.setBooleanValue(false);
+                info2.setPointDatas(Collections.singletonList(data2));
+                result.add(info2);
+            } else {
+                PointInfo info0 = map.get("MX000");
+                PointData data0 = latest.get(info0.getPointKey());
+                if (data0.getValue() == 1.0) {
+                    data0.setDoubleValue(0.0);
+                    data0.setBooleanValue(false);
+                    info0.setPointDatas(Collections.singletonList(data0));
+                    result.add(info0);
+                } else {
+                    PointInfo info6 = map.get("MX006");
+                    PointData data6 = latest.get(info6.getPointKey());
+                    if (data6.getValue() == 1.0) {
+                        data6.setDoubleValue(6.0);
+                        data6.setBooleanValue(false);
+                        info6.setPointDatas(Collections.singletonList(data6));
+                        result.add(info6);
+                    } else {
+                        PointInfo info4 = map.get("MX004");
+                        PointData data4 = latest.get(info4.getPointKey());
+                        if (data4.getValue() == 1.0) {
+                            data4.setDoubleValue(4.0);
+                            data4.setBooleanValue(false);
+                            info4.setPointDatas(Collections.singletonList(data4));
+                            result.add(info4);
+                        } else {
+                            PointInfo info1 = map.get("MX001");
+                            PointData data1 = latest.get(info1.getPointKey());
+                            if (data1.getValue() == 1.0) {
+                                data1.setDoubleValue(1.0);
+                                data1.setBooleanValue(false);
+                                info1.setPointDatas(Collections.singletonList(data1));
+                                result.add(info1);
+                            } else {
+                                data1.setDoubleValue(2.0);
+                                System.out.println("wtId: " + wtId + ",状态值无批配: " + data1.getValue());
+                                info1.setPointDatas(Collections.singletonList(data1));
+                                result.add(info1);
+                            }
+                        }
+                    }
+                }
+            }
+        });
+        return result;
+    }
+
+    public List<PointInfo> calcSectionStationAiztTs(Date time) {
+        List<PointInfo> entityAiZt = getEntity("AI422", "state");
+        List<StateAi> list = stateAiService.list();
+        //机型,源状态,目标状态
+        Map<String, Map<Integer, Integer>> collectAi = list.stream().collect(Collectors.groupingBy(StateAi::getModel, Collectors.toMap(StateAi::getOriginalState, StateAi::getMappingState)));
+        String collect = entityAiZt.stream().map(PointInfo::getPointKey).collect(Collectors.joining(","));
+        Map<String, PointData> latest = adapter.getHistorySection(goldenUri(), collect, time.getTime());
+        for (PointInfo info : entityAiZt) {
+            PointData data = latest.get(info.getPointKey());
+            Integer m = collectAi.get(info.getSpare()).get((int) data.getValue());
+            if (m == null) {
+                m = 2;
+                System.out.println("ai状态未配对:" + data.getValue());
+            }
+            data.setDoubleValue(m);
+            info.setPointDatas(Collections.singletonList(data));
+        }
+        return entityAiZt;
+    }
+
+    public void calcStationSjglAgcPjfsHjwdDlMin(Date time) {
+        DateTime end = DateUtil.beginOfMinute(time);
+        int i = Math.floorDiv(end.minute(), 15) * 15;
+        end.setMinutes(i);
+        DateTime begin = DateUtil.offsetMinute(end, -15);
+        //AGC
+        List<PointInfo> entityAgc = getEntity("AGC002", "booster");
+        getSectionDataByEntity(entityAgc, goldenUri(), end);
+        Map<String, PointInfo> mapAgc = entityAgc.stream().collect(Collectors.toMap(PointInfo::getStationId, Function.identity()));
+        //出线
+        List<PointInfo> entityCx = getEntity("AGC001", "booster");
+        Map<String, PointInfo> statMapCx = getRawDataByEntity(entityCx, goldenUri(), begin, end, PointInfo::getStationId);
+        //风速
+        List<PointInfo> entityFs = getEntity("AI066", "turbine");
+        getRawDataByEntity(entityFs, goldenUri(), begin, end);
+        Map<String, List<PointInfo>> fssMap = entityFs.stream().collect(Collectors.groupingBy(PointInfo::getStationId));
+        //环境温度
+        List<PointInfo> entityHjwd = getEntity("AI072", "turbine");
+        getRawDataByEntity(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())).collect(Collectors.toList());
+        getSectionDataByEntity(entity, goldenUri(), begin, end);
+        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");
+        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);
+        Map<String, Map<Double, Long>> zttsMap = calcSectionStationZtts(end);
+        for (StationInfoMin day : byDate) {
+            String id = day.getStationId();
+            TurbineInfoMin min = minMap.get(id);
+            Map<Double, Long> map = zttsMap.get(id);
+            List<PointInfo> fsInfos = fssMap.get(id);
+            double pjfs = fsInfos.stream().mapToDouble(pi -> pi.getPointDatas().stream().mapToDouble(PointData::getValue).average().orElse(0.0)).average().orElse(0);
+            day.setPjfs(pjfs);
+            PointInfo cxInfo = statMapCx.get(id);
+            double cxgl = cxInfo.getPointDatas().stream().mapToDouble(PointData::getValue).average().orElse(0.0);
+            cxgl = cxgl * cxInfo.getCoef();
+            if (cxgl > 169600 && day.getPjfs() < 3) cxgl = 0;
+            day.setPjgl(cxgl);
+            PointInfo agcInfo = mapAgc.get(id);
+            double agc = agcInfo.getPointDatas().get(0).getValue() * agcInfo.getCoef();
+            if (agc < day.getPjgl()) agc = day.getPjgl();
+            day.setAgc(agc);
+            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 = 0;
+                return v;
+            }).sum();
+            if ((rfdl < 660 && day.getPjgl() > 0) || rfdl >= 45500) rfdl = day.getPjgl() / 4.0;
+            day.setRfdl(rfdl);
+            if (day.getPjgl() == 169600.0 && rfdl != 42400.0) {
+                day.setPjgl(rfdl * 4);
+                day.setAgc(day.getPjgl());
+            }
+            if (day.getPjgl() == 0.0 && rfdl != 0.0) {
+                day.setPjgl(rfdl * 4);
+            }
+            if (day.getAgc() == 170000 && rfdl != 42400.0) {
+                day.setAgc(rfdl * 4);
+            }
+            List<PointInfo> hjwdInfos = hjwdsMap.get(id);
+            List<Double> hjwds = new ArrayList<>();
+            for (PointInfo wd : hjwdInfos) {
+                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);
+                } else {
+                    fjhjwd.put(wd.getTurbineId(), v);
+                }
+                hjwds.add(v);
+            }
+            day.setHjwd(hjwds.stream().filter(d -> d != 0.0).mapToDouble(Double::doubleValue).average().orElse(0.0));
+            //0 待机-,1 停机,2 发电-,4 故障-,6 检修,8 限电,12 离线
+            day.setDjts(map.get(0.0));
+            day.setYxts(map.get(2.0));
+            day.setGzts(map.get(4.0));
+            day.setJxts(map.get(6.0));
+
+            day.setLlgl(min.getLlgl());
+            day.setKygl(min.getKygl());
+        }
+        stationInfoMinService.saveOrUpdateBatch(byDate);
+    }
+
     public void calcStationSjglAgcPjfsHjwdDlMin(Date begin, Date end, String stId) {
         //AGC
         List<PointInfo> entityAgc = getEntity("AGC002", "booster");
@@ -4394,6 +4610,9 @@ public class JavaFunctionJobHandler extends IJobHandler {
                 day.setPjgl(rfdl * 4);
                 day.setAgc(day.getPjgl());
             }
+            if (day.getPjgl() == 0.0 && rfdl != 0.0) {
+                day.setPjgl(rfdl * 4);
+            }
             if (day.getAgc() == 170000 && rfdl != 42400.0) {
                 day.setAgc(rfdl * 4);
             }
@@ -4437,7 +4656,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         System.out.println();
     }
 
-    public void calcPredictExamin(Date date) {
+    public void calcPredictExaminFj(Date date) {
         DateTime end = DateUtil.beginOfDay(date);
         DateTime begin = DateUtil.offsetDay(end, -1);
         List<PointInfo> entity = getEntity("MX000", "state");
@@ -4493,6 +4712,68 @@ public class JavaFunctionJobHandler extends IJobHandler {
         predictExaminService.saveBatch(peList);
     }
 
+    public void calcPredictExamin(Date date) {
+        DateTime end = DateUtil.beginOfDay(date);
+        DateTime begin = DateUtil.offsetDay(end, -1);
+        //实际功率
+        List<PointInfo> entityGl = getEntity("AGC001", "booster");
+        getSnapDataByEntity(entityGl, begin, end, 15 * 60);
+        Map<String, PointInfo> glpisMap = entityGl.stream().collect(Collectors.toMap(PointInfo::getStationId, Function.identity()));
+        //短期 predictType + "_" + modelId + "_" + sstId + t
+        QueryWrapper<HistoryPredict> dqWrapper = new QueryWrapper<>();
+        dqWrapper.eq("device_type", "station").eq("predict_type", "DQ").eq("data_time", begin)
+                .between("predict_time", begin, end).orderByAsc("data_time");
+        List<HistoryPredict> dqList = historyPredictService.list(dqWrapper);
+        Map<String, List<HistoryPredict>> dqMap = dqList.stream().collect(Collectors.groupingBy(HistoryPredict::getSiteId));
+        //超短期
+        List<HistoryPredict> cdqList = new ArrayList<>();
+        for (int i = 0; i < 6; i++) {
+            DateTime hour = DateUtil.offsetHour(begin, 4 * i);
+            DateTime hour2 = DateUtil.offsetHour(hour, 4);
+            QueryWrapper<HistoryPredict> wrapper = new QueryWrapper<>();
+            wrapper.eq("device_type", "station").eq("predict_type", "CDQ").eq("data_time", hour)
+                    .between("predict_time", hour, hour2).orderByAsc("data_time");
+            List<HistoryPredict> predicts = historyPredictService.list(wrapper);
+            cdqList.addAll(predicts);
+        }
+        QueryWrapper<HistoryPredict> cdqWrapper = new QueryWrapper<>();
+        cdqWrapper.eq("device_type", "station").eq("predict_type", "CDQ").eq("data_time", begin).orderByAsc("data_time");
+        Map<String, List<HistoryPredict>> cdqMap = cdqList.stream().collect(Collectors.groupingBy(HistoryPredict::getSiteId));
+
+        List<PredictExamin> peList = new ArrayList<>();
+        dqMap.forEach((stId, hps) -> {
+            //短期
+            List<Double> predictPower = hps.stream().map(HistoryPredict::getPredictPower).collect(Collectors.toList());
+            PointInfo glinfo = glpisMap.get(stId);
+            List<Double> actualPower = glinfo.getPointDatas().stream().map(PointData::getValue).collect(Collectors.toList());
+            Double installCapacity = glinfo.getSpare2() * 1000;
+            HistoryPredict predict = hps.get(0);
+            PredictExamin examin = new PredictExamin();
+            examin.setModelId(predict.getModelId());
+            examin.setPredictType("DQ");
+            examin.setDeviceType(predict.getDeviceType());
+            examin.setTime(begin);
+            examin.setSiteId(predict.getSiteId());
+            examin.setExaminScore(calcExaminScore(predictPower, actualPower, installCapacity));
+            examin.setAccuracyRate(calcAccuracyRate(predictPower, actualPower, installCapacity));
+            peList.add(examin);
+            //超短期
+            List<HistoryPredict> cdqhps = cdqMap.get(stId);
+            if (CollUtil.isEmpty(cdqhps)) return;
+            List<Double> predictPowerCdq = cdqhps.stream().map(HistoryPredict::getPredictPower).collect(Collectors.toList());
+            PredictExamin e = new PredictExamin();
+            e.setModelId(predict.getModelId());
+            e.setPredictType("CDQ");
+            e.setDeviceType(predict.getDeviceType());
+            e.setTime(begin);
+            e.setSiteId(predict.getSiteId());
+            e.setExaminScore(calcExaminScore(predictPowerCdq, actualPower, installCapacity));
+            e.setAccuracyRate(calcAccuracyRate(predictPowerCdq, actualPower, installCapacity));
+            peList.add(e);
+        });
+        predictExaminService.saveBatch(peList);
+    }
+
     /**
      * 计算功率日预测曲线最大误差值
      *
@@ -4554,6 +4835,426 @@ public class JavaFunctionJobHandler extends IJobHandler {
             return 100 - totalError / validPoints;
         }
     }
+
+    private Map<String, Double> fjhjwd = new HashMap<>();
+    private Map<String, Double> fjfs = new HashMap<>();
+
+    public void calcStationPjfsHjwdMin(Date begin, Date end, String stId, StationInfoMin min) {
+        //风速
+        List<PointInfo> entityFs = getEntity("AI066", "turbine");
+        entityFs = entityFs.stream().filter(e -> stId.equals(e.getStationId())).collect(Collectors.toList());
+        getRawDataByEntity(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());
+        getRawDataByEntity(entityHjwd, goldenUri(), begin, end);
+        Map<String, List<PointInfo>> hjwdsMap = entityHjwd.stream().collect(Collectors.groupingBy(PointInfo::getStationId));
+//        StationInfoMin2 min2 = getStationinfoByMin2(end, stId);
+        StationInfoMin2 min2 = new StationInfoMin2();
+        min2.setStationId(stId);
+        min2.setRecordDate(end);
+        min2.setPjgl(min.getPjgl());
+        min2.setRfdl(min.getRfdl());
+        min2.setYxts(min.getYxts());
+        List<PointInfo> fsInfos = fssMap.get(stId);
+        fsInfos = fsInfos.stream().sorted(Comparator.comparing(PointInfo::getTurbineId)).collect(Collectors.toList());
+        for (int i = 0; i < fsInfos.size(); i++) {
+            setpjfs(min2, fsInfos.get(i), i + 1);
+        }
+        List<PointInfo> hjwdInfos = hjwdsMap.get(stId);
+        List<Double> hjwds = new ArrayList<>();
+        for (PointInfo wd : hjwdInfos) {
+            double v = wd.getPointDatas().stream().filter(p -> p.getValue() != 0.0).mapToDouble(PointData::getValue).average().orElse(0.0);
+            if (v > 83 || v < -60) v = 0;
+            if (v == 0) {
+                v = fjhjwd.getOrDefault(wd.getTurbineId(), 0.0);
+            } else {
+                fjhjwd.put(wd.getTurbineId(), v);
+            }
+            hjwds.add(v);
+        }
+        min2.setHjwd(hjwds.stream().filter(d -> d != 0.0).mapToDouble(Double::doubleValue).average().orElse(0.0));
+//        stationInfoMin2Service.saveOrUpdate(min2);
+        stationInfoMin2Service.save(min2);
+    }
+
+    public StationInfoMin2 calcStationPjfsHjwdMin2(Date end, String stId) {
+        DateTime begin = DateUtil.offsetMinute(end, -15);
+        //出线
+        List<PointInfo> entityCx = getEntity("AGC001", "booster");
+        entityCx = entityCx.stream().filter(e -> stId.equals(e.getStationId())).collect(Collectors.toList());
+        Map<String, PointInfo> statMapCx = getRawDataByEntity(entityCx, goldenUri(), begin, end, 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<PointInfo> entityFs = getEntity("AI066", "turbine");
+        entityFs = entityFs.stream().filter(e -> stId.equals(e.getStationId())).collect(Collectors.toList());
+        getRawDataByEntity(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());
+        getRawDataByEntity(entityHjwd, goldenUri(), begin, end);
+        Map<String, List<PointInfo>> hjwdsMap = entityHjwd.stream().collect(Collectors.groupingBy(PointInfo::getStationId));
+
+        Map<Double, Long> zttsMap = calcSectionStationZtts(end, stId);
+        PointInfo cxInfo = statMapCx.get(stId);
+        double cxgl = cxInfo.getPointDatas().stream().mapToDouble(PointData::getValue).average().orElse(0.0);
+        cxgl = cxgl * cxInfo.getCoef();
+        List<PointInfo> fdlInfos = fdlsMap.get(stId);
+        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;
+            return v;
+        }).sum();
+        if ((rfdl < 660 && cxgl > 0) || rfdl >= 42400.0) rfdl = cxgl / 4.0;
+        if (cxgl > 169600.0 && rfdl < 42400.0) {
+            cxgl = rfdl * 4;
+        }
+        if (cxgl == 0.0 && rfdl != 0.0) {
+            cxgl = rfdl * 4;
+        }
+        StationInfoMin2 min2 = new StationInfoMin2();
+        min2.setStationId(stId);
+        min2.setRecordDate(end);
+        min2.setPjgl(cxgl);
+        min2.setRfdl(rfdl);
+        Long l = zttsMap.get(2.0);
+        if (l == null) l = 0L;
+        min2.setYxts(l);
+        List<PointInfo> fsInfos = fssMap.get(stId);
+        fsInfos = fsInfos.stream().sorted(Comparator.comparing(PointInfo::getTurbineId)).collect(Collectors.toList());
+        for (int i = 0; i < fsInfos.size(); i++) {
+            setpjfs(min2, fsInfos.get(i), i + 1);
+        }
+        List<PointInfo> hjwdInfos = hjwdsMap.get(stId);
+        List<Double> hjwds = new ArrayList<>();
+        for (PointInfo wd : hjwdInfos) {
+            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);
+            } else {
+                fjhjwd.put(wd.getTurbineId(), v);
+            }
+            hjwds.add(v);
+        }
+        min2.setHjwd(hjwds.stream().filter(d -> d != 0.0).mapToDouble(Double::doubleValue).average().orElse(0.0));
+        return min2;
+    }
+
+    private void setpjfs(StationInfoMin2 min2, PointInfo pi, int i) {
+        double v = 0;
+        if (pi == null || pi.getPointDatas().isEmpty()) {
+            v = fjfs.getOrDefault(pi.getTurbineId(), 0.0);
+        } else {
+            v = pi.getPointDatas().stream().mapToDouble(p -> p.getValue() > 23 ? 23.0 : p.getValue() < 0 ? 0.0 : p.getValue()).average().orElse(0.0);
+            fjfs.put(pi.getTurbineId(), v);
+        }
+        switch (i) {
+            case 1:
+                min2.setpjfs1(v);
+                break;
+            case 2:
+                min2.setpjfs2(v);
+                break;
+            case 3:
+                min2.setpjfs3(v);
+                break;
+            case 4:
+                min2.setpjfs4(v);
+                break;
+            case 5:
+                min2.setpjfs5(v);
+                break;
+            case 6:
+                min2.setpjfs6(v);
+                break;
+            case 7:
+                min2.setpjfs7(v);
+                break;
+            case 8:
+                min2.setpjfs8(v);
+                break;
+            case 9:
+                min2.setpjfs9(v);
+                break;
+            case 10:
+                min2.setPjfs10(v);
+                break;
+            case 11:
+                min2.setPjfs11(v);
+                break;
+            case 12:
+                min2.setPjfs12(v);
+                break;
+            case 13:
+                min2.setPjfs13(v);
+                break;
+            case 14:
+                min2.setPjfs14(v);
+                break;
+            case 15:
+                min2.setPjfs15(v);
+                break;
+            case 16:
+                min2.setPjfs16(v);
+                break;
+            case 17:
+                min2.setPjfs17(v);
+                break;
+            case 18:
+                min2.setPjfs18(v);
+                break;
+            case 19:
+                min2.setPjfs19(v);
+                break;
+            case 20:
+                min2.setPjfs20(v);
+                break;
+            case 21:
+                min2.setPjfs21(v);
+                break;
+            case 22:
+                min2.setPjfs22(v);
+                break;
+            case 23:
+                min2.setPjfs23(v);
+                break;
+            case 24:
+                min2.setPjfs24(v);
+                break;
+            case 25:
+                min2.setPjfs25(v);
+                break;
+            case 26:
+                min2.setPjfs26(v);
+                break;
+            case 27:
+                min2.setPjfs27(v);
+                break;
+            case 28:
+                min2.setPjfs28(v);
+                break;
+            case 29:
+                min2.setPjfs29(v);
+                break;
+            case 30:
+                min2.setPjfs30(v);
+                break;
+            case 31:
+                min2.setPjfs31(v);
+                break;
+            case 32:
+                min2.setPjfs32(v);
+                break;
+            case 33:
+                min2.setPjfs33(v);
+                break;
+            case 34:
+                min2.setPjfs34(v);
+                break;
+            case 35:
+                min2.setPjfs35(v);
+                break;
+            case 36:
+                min2.setPjfs36(v);
+                break;
+            case 37:
+                min2.setPjfs37(v);
+                break;
+            case 38:
+                min2.setPjfs38(v);
+                break;
+            case 39:
+                min2.setPjfs39(v);
+                break;
+            case 40:
+                min2.setPjfs40(v);
+                break;
+            case 41:
+                min2.setPjfs41(v);
+                break;
+            case 42:
+                min2.setPjfs42(v);
+                break;
+            case 43:
+                min2.setPjfs43(v);
+                break;
+            case 44:
+                min2.setPjfs44(v);
+                break;
+            case 45:
+                min2.setPjfs45(v);
+                break;
+            case 46:
+                min2.setPjfs46(v);
+                break;
+            case 47:
+                min2.setPjfs47(v);
+                break;
+            case 48:
+                min2.setPjfs48(v);
+                break;
+            case 49:
+                min2.setPjfs49(v);
+                break;
+            case 50:
+                min2.setPjfs50(v);
+                break;
+            case 51:
+                min2.setPjfs51(v);
+                break;
+            case 52:
+                min2.setPjfs52(v);
+                break;
+            case 53:
+                min2.setPjfs53(v);
+                break;
+            case 54:
+                min2.setPjfs54(v);
+                break;
+            case 55:
+                min2.setPjfs55(v);
+                break;
+            case 56:
+                min2.setPjfs56(v);
+                break;
+            case 57:
+                min2.setPjfs57(v);
+                break;
+            case 58:
+                min2.setPjfs58(v);
+                break;
+            case 59:
+                min2.setPjfs59(v);
+                break;
+            case 60:
+                min2.setPjfs60(v);
+                break;
+            case 61:
+                min2.setPjfs61(v);
+                break;
+            case 62:
+                min2.setPjfs62(v);
+                break;
+            case 63:
+                min2.setPjfs63(v);
+                break;
+            case 64:
+                min2.setPjfs64(v);
+                break;
+            case 65:
+                min2.setPjfs65(v);
+                break;
+            case 66:
+                min2.setPjfs66(v);
+                break;
+            case 67:
+                min2.setPjfs67(v);
+                break;
+            case 68:
+                min2.setPjfs68(v);
+                break;
+            case 69:
+                min2.setPjfs69(v);
+                break;
+            case 70:
+                min2.setPjfs70(v);
+                break;
+            case 71:
+                min2.setPjfs71(v);
+                break;
+            case 72:
+                min2.setPjfs72(v);
+                break;
+            case 73:
+                min2.setPjfs73(v);
+                break;
+            case 74:
+                min2.setPjfs74(v);
+                break;
+            case 75:
+                min2.setPjfs75(v);
+                break;
+            case 76:
+                min2.setPjfs76(v);
+                break;
+            case 77:
+                min2.setPjfs77(v);
+                break;
+            case 78:
+                min2.setPjfs78(v);
+                break;
+            case 79:
+                min2.setPjfs79(v);
+                break;
+            case 80:
+                min2.setPjfs80(v);
+                break;
+            case 81:
+                min2.setPjfs81(v);
+                break;
+            case 82:
+                min2.setPjfs82(v);
+                break;
+            case 83:
+                min2.setPjfs83(v);
+                break;
+            case 84:
+                min2.setPjfs84(v);
+                break;
+            case 85:
+                min2.setPjfs85(v);
+                break;
+            case 86:
+                min2.setPjfs86(v);
+                break;
+            case 87:
+                min2.setPjfs87(v);
+                break;
+            case 88:
+                min2.setPjfs88(v);
+                break;
+            case 89:
+                min2.setPjfs89(v);
+                break;
+            case 90:
+                min2.setPjfs90(v);
+                break;
+            case 91:
+                min2.setPjfs91(v);
+                break;
+            case 92:
+                min2.setPjfs92(v);
+                break;
+            case 93:
+                min2.setPjfs93(v);
+                break;
+            case 94:
+                min2.setPjfs94(v);
+                break;
+            case 95:
+                min2.setPjfs95(v);
+                break;
+            case 96:
+                min2.setPjfs96(v);
+                break;
+            case 97:
+                min2.setPjfs97(v);
+                break;
+            case 98:
+                min2.setPjfs98(v);
+                break;
+            case 99:
+                min2.setPjfs99(v);
+                break;
+        }
+    }
 }
 
 

+ 5 - 0
ruoyi-admin/src/main/resources/application-druid.yml

@@ -39,6 +39,11 @@ spring:
         password: GYee@#56
 #        driver-class-name: org.postgresql.Driver
         enabled: true
+      glyc:
+        url: jdbc:postgresql://172.16.12.102:5432/power_forecast
+        username: postgres
+        password: GYee@#56
+        enabled: true
       # 初始连接数
       initialSize: 5
       # 最小连接池数量

+ 63 - 0
ruoyi-admin/src/main/resources/application-druid2.yml

@@ -0,0 +1,63 @@
+# 数据源配置
+spring:
+  datasource:
+    type: com.alibaba.druid.pool.DruidDataSource            # 当前数据源操作类型
+    driver-class-name: org.postgresql.Driver                # pgsql驱动包
+    druid:
+      master:
+        url: jdbc:postgresql://123.60.219.66:5432/calc_hub
+        username: postgres
+        password: gyeepd@123
+      glyc:
+        url: jdbc:postgresql://123.60.219.66:5432/power_forecast
+        username: postgres
+        password: gyeepd@123
+      slave:
+        url: jdbc:postgresql://123.60.219.66:5432/power_lcm
+        username: postgres
+        password: gyeepd@123
+        enabled: true
+      # 初始连接数
+      initialSize: 5
+      # 最小连接池数量
+      minIdle: 10
+      # 最大连接池数量
+      maxActive: 20
+      # 配置获取连接等待超时的时间
+      maxWait: 60000
+      # 配置连接超时时间
+      connectTimeout: 30000
+      # 配置网络超时时间
+      socketTimeout: 60000
+      # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+      timeBetweenEvictionRunsMillis: 60000
+      # 配置一个连接在池中最小生存的时间,单位是毫秒
+      minEvictableIdleTimeMillis: 300000
+      # 配置一个连接在池中最大生存的时间,单位是毫秒
+      maxEvictableIdleTimeMillis: 900000
+      # 配置检测连接是否有效
+      #      validationQuery: SELECT 1 FROM DUAL
+      validationQuery: SELECT 1
+      testWhileIdle: true
+      testOnBorrow: false
+      testOnReturn: false
+      webStatFilter:
+        enabled: true
+      statViewServlet:
+        enabled: true
+        # 设置白名单,不填则允许所有访问
+        allow:
+        url-pattern: /druid/*
+        # 控制台管理用户名和密码
+        login-username: ruoyi
+        login-password: 123456
+      filter:
+        stat:
+          enabled: true
+          # 慢SQL记录
+          log-slow-sql: true
+          slow-sql-millis: 1000
+          merge-sql: true
+        wall:
+          config:
+            multi-statement-allow: true

+ 4 - 3
ruoyi-admin/src/main/resources/application.yml

@@ -101,7 +101,8 @@ spring:
         max-wait: -1ms
   cache:
     type: redis
-
+  jackson:
+    date-format: yyyy-MM-dd HH:mm:ss.SSS
 # token配置
 token:
   # 令牌自定义标识
@@ -151,7 +152,7 @@ feign:
   client:
     config:
       default:
-        connect-timeout: 5000
-        read-timeout: 900000
+        connect-timeout: 15000
+        read-timeout: 7200000
 
 power_curve_month: "glqxnh:8:"

+ 39 - 10
ruoyi-admin/src/test/java/com/ruoyi/GetDataTest.java

@@ -13,8 +13,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ruoyi.ucp.entity.GlycSj;
 import com.ruoyi.ucp.entity.PointData;
 import com.ruoyi.ucp.entity.PointInfo;
+import com.ruoyi.ucp.entity.StationInfoMin;
 import com.ruoyi.ucp.feign.AdapterApi;
 import com.ruoyi.ucp.service.IPointInfoService;
+import com.ruoyi.ucp.service.IStationInfoMinService;
 import com.ruoyi.web.controller.JavaFunctionJobHandler;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -40,14 +42,16 @@ public class GetDataTest {
     private AdapterApi adapterApi;
     @Resource
     private JavaFunctionJobHandler task;
+    @Resource
+    private IStationInfoMinService stationInfoMinService;
 
     @Test
     public void test2() {
 //        DateTime begin = DateUtil.parse("2023-03-21");
-        DateTime begin = DateUtil.parse("2023-04-18");
+        DateTime begin = DateUtil.parse("2024-11-08 17:30:00");
 //        DateTime begin = DateUtil.parse("2024-08-19 11:00:00");
 //        DateTime end = DateUtil.parse("2024-08-08 14:00:00");
-        DateTime end = DateUtil.parse("2024-11-03");
+        DateTime end = DateUtil.parse("2024-11-09 11:21:00");
 //        DateTime end = DateUtil.parse("2024-08-19 11:30:00");
 //        DateTime end = DateUtil.parse("2024-08-08 13:45:00");
         //LJS,FSG,JSL,ZZ,XZ,CSL
@@ -55,7 +59,30 @@ public class GetDataTest {
         DateTime minBegin = begin, minEnd = DateUtil.offsetMinute(begin, 15);
         while (minEnd.isBefore(end)) {
             minEnd = DateUtil.offsetMinute(begin, i * 15);
-            task.calcStationSjglAgcPjfsHjwdDlMin(minBegin, minEnd, "GJNY_SXGS_CSL_FDC_STA");
+//            task.calcStationSjglAgcPjfsHjwdDlMin(minBegin, minEnd, "GJNY_SXGS_CSL_FDC_STA");
+//            task.calcTurbinePjfsPjglKyglLlglMin(minEnd, 15);
+            task.calcStationSjglAgcPjfsHjwdDlMin(minEnd);
+            System.out.println(minBegin.toString() + "," + minEnd.toString());
+            i++;
+            minBegin = minEnd;
+        }
+    }
+    @Test
+    public void test9() {
+        DateTime begin = DateUtil.parse("2023-04-18");
+//        DateTime begin = DateUtil.parse("2023-04-22 14:30:00");
+        DateTime end = DateUtil.parse("2024-11-07");
+        String stId = "GJNY_SXGS_XZ_FDC_STA";
+        QueryWrapper<StationInfoMin> wrapper=new QueryWrapper<>();
+        wrapper.lambda().eq(StationInfoMin::getStationId,stId).between(StationInfoMin::getRecordDate,begin,end);
+        List<StationInfoMin> list = stationInfoMinService.list(wrapper);
+        Map<String, StationInfoMin> collect = list.stream().collect(Collectors.toMap(im -> DateUtil.date(im.getRecordDate()).toString(), Function.identity()));
+        //LJS,FSG,JSL,ZZ,XZ,CSL
+        int i = 1;
+        DateTime minBegin = begin, minEnd = DateUtil.offsetMinute(begin, 15);
+        while (minEnd.isBefore(end)) {
+            minEnd = DateUtil.offsetMinute(begin, i * 15);
+            task.calcStationPjfsHjwdMin(minBegin, minEnd, stId,collect.get(DateUtil.date(minEnd).toString()));
             System.out.println(minBegin.toString() + "," + minEnd.toString());
             i++;
             minBegin = minEnd;
@@ -74,7 +101,7 @@ public class GetDataTest {
         DateTime minBegin = begin, minEnd = DateUtil.offsetMinute(begin, 15);
         while (minEnd.isBefore(end)) {
             minEnd = DateUtil.offsetMinute(begin, i * 15);
-            task.calcStationMinZtts(minEnd, "GJNY_SXGS_JSL_FDC_STA");
+//            task.calcStationMinZtts(minEnd, "GJNY_SXGS_JSL_FDC_STA");
             System.out.println(minBegin.toString() + "," + minEnd.toString());
             i++;
             minBegin = minEnd;
@@ -82,12 +109,14 @@ public class GetDataTest {
     }
     @Test
     public void test3() {
-        DateTime start = DateUtil.parse("2024-10-31");
-        DateTime end = DateUtil.parse("2024-11-03");
-        DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR);
-        for (DateTime date : range) {
-            task.calcPredictExamin(date);
-        }
+//        DateTime start = DateUtil.parse("2024-11-06");
+//        DateTime end = DateUtil.parse("2024-11-06");
+//        DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR);
+//        for (DateTime date : range) {
+//            task.calcPredictExamin(date);
+//        }
+        DateTime date = DateUtil.yesterday();
+        task.calcPredictExamin(date);
     }
 
     @Test

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

@@ -32,6 +32,8 @@ public class NewTests {
 
     @Resource
     private JavaFunctionJobHandler task;
+    @Resource
+    private IStationInfoMinService stationInfoMinService;
 
     @Test
     public void test() {
@@ -61,7 +63,7 @@ public class NewTests {
         System.out.println();*/
 
         Date date = DateUtil.parse("2024-10-10");
-        task.calcTurbineSsfsQx(date);
+//        task.calcTurbineSsfsQx(date);
 //        task.ambientTemperature();
 
 //        task.calcTurbine5s2(date);
@@ -147,9 +149,9 @@ public class NewTests {
     @Test
     public void test2() {
         // 创建日期范围生成器
-        DateTime start = DateUtil.parse("2024-10-19");
-        DateTime end = DateUtil.parse("2024-10-25");
-        DateRange range = DateUtil.range(start, end, DateField.HOUR_OF_DAY);
+        DateTime start = DateUtil.parse("2024-10-02");
+        DateTime end = DateUtil.parse("2024-11-09");
+        DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR);
         for (DateTime date : range) {
             System.out.println(DateUtil.date() + ":" + date);
 //            task.calcAQTS(date);
@@ -160,16 +162,17 @@ public class NewTests {
 //            task.writeReportPool(date);
 //            task.writeReportPoolProject(date);
 //            task.calcStationHourPjglRfdl(DateUtil.date());
-//            task.calcTurbine5s2(date);
+            task.calcTurbine5s2(date);
         }
 //        task.calcStationHourPjglRfdl(DateUtil.date());
         DateTime date = DateUtil.date();
 //        task.calcStationHourPJGL(date);
 //        task.calcLineRfdl(date);
 //        task.calcStationHourRFDL(date);
-        task.calcTurbinePjfsPjglKyglLlglMin(DateUtil.date(), 15);
+//        task.calcTurbinePjfsPjglKyglLlglMin(DateUtil.date(), 15);
 //        task.calcStationLlglKyglSjglAgcMin(date, 15);
     }
+
     @Test
     public void test3() {
         // 创建日期范围生成器
@@ -178,21 +181,108 @@ public class NewTests {
         DateRange range = DateUtil.range(start, end, DateField.MONTH);
         for (DateTime date : range) {
             System.out.println(DateUtil.date() + ":" + date);
-            task.calcStationRjhfdl(date);
+//            task.calcStationRjhfdl(date);
 
         }
     }
+
     @Test
     public void test4() {
-//        while (true){
-//            task.calcStationRealtimeLLgl();
-//            ThreadUtil.sleep(60000);
+        while (true){
+            task.calcStationRealtimeLLgl();
+            ThreadUtil.sleep(60000);
+        }
+//        DateTime start = DateUtil.parse("2024-01-02");
+//        DateTime end = DateUtil.parse("2024-11-05");
+//        DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR);
+//        List<String> stIds = new ArrayList<>();
+//        stIds.add("GJNY_SXGS_FSG_FDC_STA");
+//        stIds.add("GJNY_SXGS_JSL_FDC_STA");
+//        stIds.add("GJNY_SXGS_CSL_FDC_STA");
+//        stIds.add("GJNY_SXGS_ZZ_FDC_STA");
+//        stIds.add("GJNY_SXGS_XZ_FDC_STA");
+//        stIds.add("GJNY_SXGS_LJS_FDC_STA");
+//        for (DateTime date : range) {
+////            task.calcTurbineStateMin(date);
+////            task.khjfbc(stIds,date);
 //        }
+//        task.calcGlqxnhSurplus(start, end);
 
-        DateTime start = DateUtil.parse("2023-08-01");
-        DateTime end = DateUtil.parse("2023-11-01");
-        task.calcGlqxnhSurplus(start, end);
+    }
 
+    @Test
+    public void test5() {
+        DateTime date = DateUtil.date();
+        task.calcTurbineStateMin(date);
     }
 
+    @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 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);
+        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;
+        }
+    }
+    @Test
+    public void test7() {
+        DateTime begin = DateUtil.parse("2024-01-01");
+        DateTime end = DateUtil.parse("2024-11-05 14:30:00");
+        int i = 1;
+        DateTime minBegin = begin, minEnd = DateUtil.offsetMinute(begin, 15);
+        List<String> stIds = new ArrayList<>();
+        stIds.add("GJNY_SXGS_FSG_FDC_STA");
+        stIds.add("GJNY_SXGS_JSL_FDC_STA");
+        stIds.add("GJNY_SXGS_CSL_FDC_STA");
+        stIds.add("GJNY_SXGS_ZZ_FDC_STA");
+        stIds.add("GJNY_SXGS_XZ_FDC_STA");
+        stIds.add("GJNY_SXGS_LJS_FDC_STA");
+        QueryWrapper<StationInfoMin> wrapper=new QueryWrapper<>();
+        wrapper.lambda().between(StationInfoMin::getRecordDate,begin,end);
+        List<StationInfoMin> list = stationInfoMinService.list(wrapper);
+        Map<String, List<StationInfoMin>> collect = list.stream().collect(Collectors.groupingBy(m -> DateUtil.date(m.getRecordDate()).toString()));
+        while (minEnd.isBefore(end)) {
+            minEnd = DateUtil.offsetMinute(begin, i * 15);
+//            task.ycbs(stIds,minBegin,minEnd,collect.get(minEnd.toString()));
+            System.out.println(minBegin.toString() + "," + minEnd.toString());
+            i++;
+            minBegin = minEnd;
+        }
+    }
+    @Test
+    public void test8() {
+        DateTime begin = DateUtil.parse("2024-11-05 14:30:00");
+        DateTime end = DateUtil.parse("2024-11-07 10:00:00");
+        int i = 1;
+        DateTime minBegin = begin, minEnd = DateUtil.offsetMinute(begin, 15);
+        List<String> stIds = new ArrayList<>();
+        stIds.add("GJNY_SXGS_FSG_FDC_STA");
+        stIds.add("GJNY_SXGS_JSL_FDC_STA");
+        stIds.add("GJNY_SXGS_CSL_FDC_STA");
+        stIds.add("GJNY_SXGS_ZZ_FDC_STA");
+        stIds.add("GJNY_SXGS_XZ_FDC_STA");
+        stIds.add("GJNY_SXGS_LJS_FDC_STA");
+        QueryWrapper<StationInfoMin> wrapper=new QueryWrapper<>();
+        wrapper.lambda().between(StationInfoMin::getRecordDate,begin,end);
+        List<StationInfoMin> list = stationInfoMinService.list(wrapper);
+        Map<String, List<StationInfoMin>> collect = list.stream().collect(Collectors.groupingBy(m -> DateUtil.date(m.getRecordDate()).toString()));
+        while (minEnd.isBefore(end)) {
+            minEnd = DateUtil.offsetMinute(begin, i * 15);
+//            task.ycbs2(stIds,minBegin,minEnd,collect.get(minEnd.toString()));
+            System.out.println(minBegin.toString() + "," + minEnd.toString());
+            i++;
+            minBegin = minEnd;
+        }
+    }
 }

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

@@ -1,144 +1,144 @@
-package com.ruoyi;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.util.NumberUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.ruoyi.ucp.entity.*;
-import com.ruoyi.ucp.feign.AdapterApi;
-import com.ruoyi.ucp.service.ITurbineInfoDayService;
-import com.ruoyi.ucp.util.CalcCache;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import javax.annotation.Resource;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
-/**
- * Author: malijun
- * Data  : 2024: 07: 03
- **/
-@SpringBootTest
-@RunWith(SpringRunner.class)
-public class Test {
-
-    @Resource
-    private AdapterApi adapter;
-    @Resource
-    private JavaFunctionJobHandler javaFunctionJobHandler;
-    @Resource
-    private ITurbineInfoDayService turbineInfoDayService;
-
-
-    @org.junit.Test
-    public void test() {
-        javaFunctionJobHandler.cutInWindSpeed();
-        javaFunctionJobHandler.calcGlqxnh_edfs();
-    }
-
-    //平均温度
-    @org.junit.Test
-    public void ambientTemperature() {
-        //date当天零点
-        DateTime timeNow00 = DateUtil.beginOfDay(new Date());
-        //date昨天零点
-        DateTime timeBegin00 = DateUtil.offsetDay(timeNow00, -1);
-        //上个月
-        DateTime timeBegin2 = DateUtil.offsetMonth(timeBegin00, -1);
-        //上个月第一天
-        DateTime timeBegin1 = DateUtil.beginOfMonth(timeBegin2);
-        //上个月最后一天
-        DateTime timeEnd2 = DateUtil.endOfMonth(timeBegin2);
-        //上个月天数
-        int days = (int) DateUtil.betweenDay(timeBegin1, timeEnd2, false);
-        //遍历天数
-        for (int i = 1; i <= days; i++) {
-            DateTime timeNow = DateUtil.offsetDay(timeBegin1, i);
-            DateTime timeBegin = DateUtil.offsetDay(timeBegin1, i - 1);
-
-
-            //所有风机的温度
-            QueryWrapper<PointInfo> queryWrapper = new QueryWrapper<>();
-            queryWrapper.eq("uniform_code", "AI072");
-
-            List<PointInfo> pointInfos = javaFunctionJobHandler.getEntity("AI072", "turbine");
-
-            //插入集合
-            List<TurbineInfoDay> interest = new ArrayList<>();
-            //更新集合
-            List<TurbineInfoDay> update = new ArrayList<>();
-
-
-            //遍历pointInfos
-            for (PointInfo turbine : pointInfos) {
-                List<PointData> pointDatas = adapter.getHistorySnap(javaFunctionJobHandler.goldenUri(), turbine.getPointKey(), timeBegin.getTime(), timeNow.getTime(), 10);
-                //遍历pointDatas,取出数据算平均值
-                double avgCutInWindSpeed = 0;
-                for (PointData pointData : pointDatas) {
-                    avgCutInWindSpeed += pointData.getValue();
-                }
-                avgCutInWindSpeed /= pointDatas.size();
-
-                //存入数据库
-                String turbineId = turbine.getTurbineId();
-                Date jdkDate = timeBegin.toJdkDate();
-                System.out.println(turbineId + " " + jdkDate);
-                QueryWrapper<TurbineInfoDay> turbineInfoDayQueryWrapper = new QueryWrapper<>();
-                turbineInfoDayQueryWrapper.eq("turbine_id", turbine.getTurbineId());
-                turbineInfoDayQueryWrapper.eq("record_date", timeBegin.toJdkDate());
-                TurbineInfoDay one = turbineInfoDayService.getOne(turbineInfoDayQueryWrapper);
-                System.out.println(one);
-                if (one == null) {
-                    TurbineInfoDay turbineInfoDay = new TurbineInfoDay();
-                    turbineInfoDay.setTurbineId(turbine.getTurbineId());
-                    turbineInfoDay.setRecordDate(timeBegin.toJdkDate());
-                    turbineInfoDay.setHjwd(avgCutInWindSpeed);
-                    System.out.println(turbineInfoDay);
-                    interest.add(turbineInfoDay);
-//                turbineInfoDayService.save(turbineInfoDay);
-                } else {
-                    one.setHjwd(avgCutInWindSpeed);
-                    System.out.println(one);
-                    update.add(one);
-//                turbineInfoDayService.updateById(one);
-                }
-
-            }
-//        //批量插入
-//        turbineInfoDayService.saveBatch(interest);
-//        //批量更新
-//        turbineInfoDayService.updateBatchById(update);
-//        //批量插入或更新
-        turbineInfoDayService.saveOrUpdateBatch(interest);
-        turbineInfoDayService.saveOrUpdateBatch(update);
-        }
-
-    }
-
-
-    @org.junit.Test
-    public void test1() {
-        Date date = DateUtil.date().toJdkDate();
-//        javaFunctionJobHandler.writeReportPool(date);
-//        javaFunctionJobHandler.writeReportPoolProject(date);
-        javaFunctionJobHandler.writeReportPoolPjfs(date);
-
-    }
-
-    @org.junit.Test
-    public void test2() {
-        Date date = DateUtil.date().toJdkDate();
-//        javaFunctionJobHandler.gongsizhibiao(date);
-        javaFunctionJobHandler.writeReportPoolLLFDL(date);
-
-    }
-
-
-}
-
+//package com.ruoyi;
+//
+//import cn.hutool.core.collection.CollUtil;
+//import cn.hutool.core.date.DateTime;
+//import cn.hutool.core.date.DateUtil;
+//import cn.hutool.core.util.NumberUtil;
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.ruoyi.ucp.entity.*;
+//import com.ruoyi.ucp.feign.AdapterApi;
+//import com.ruoyi.ucp.service.ITurbineInfoDayService;
+//import com.ruoyi.ucp.util.CalcCache;
+//import org.junit.runner.RunWith;
+//import org.springframework.boot.test.context.SpringBootTest;
+//import org.springframework.test.context.junit4.SpringRunner;
+//
+//import javax.annotation.Resource;
+//import java.util.*;
+//import java.util.concurrent.ConcurrentHashMap;
+//import java.util.concurrent.atomic.AtomicReference;
+//import java.util.function.Function;
+//import java.util.stream.Collectors;
+//
+///**
+// * Author: malijun
+// * Data  : 2024: 07: 03
+// **/
+//@SpringBootTest
+//@RunWith(SpringRunner.class)
+//public class Test {
+//
+//    @Resource
+//    private AdapterApi adapter;
+//    @Resource
+//    private JavaFunctionJobHandler javaFunctionJobHandler;
+//    @Resource
+//    private ITurbineInfoDayService turbineInfoDayService;
+//
+//
+//    @org.junit.Test
+//    public void test() {
+//        javaFunctionJobHandler.cutInWindSpeed();
+//        javaFunctionJobHandler.calcGlqxnh_edfs();
+//    }
+//
+//    //平均温度
+//    @org.junit.Test
+//    public void ambientTemperature() {
+//        //date当天零点
+//        DateTime timeNow00 = DateUtil.beginOfDay(new Date());
+//        //date昨天零点
+//        DateTime timeBegin00 = DateUtil.offsetDay(timeNow00, -1);
+//        //上个月
+//        DateTime timeBegin2 = DateUtil.offsetMonth(timeBegin00, -1);
+//        //上个月第一天
+//        DateTime timeBegin1 = DateUtil.beginOfMonth(timeBegin2);
+//        //上个月最后一天
+//        DateTime timeEnd2 = DateUtil.endOfMonth(timeBegin2);
+//        //上个月天数
+//        int days = (int) DateUtil.betweenDay(timeBegin1, timeEnd2, false);
+//        //遍历天数
+//        for (int i = 1; i <= days; i++) {
+//            DateTime timeNow = DateUtil.offsetDay(timeBegin1, i);
+//            DateTime timeBegin = DateUtil.offsetDay(timeBegin1, i - 1);
+//
+//
+//            //所有风机的温度
+//            QueryWrapper<PointInfo> queryWrapper = new QueryWrapper<>();
+//            queryWrapper.eq("uniform_code", "AI072");
+//
+//            List<PointInfo> pointInfos = javaFunctionJobHandler.getEntity("AI072", "turbine");
+//
+//            //插入集合
+//            List<TurbineInfoDay> interest = new ArrayList<>();
+//            //更新集合
+//            List<TurbineInfoDay> update = new ArrayList<>();
+//
+//
+//            //遍历pointInfos
+//            for (PointInfo turbine : pointInfos) {
+//                List<PointData> pointDatas = adapter.getHistorySnap(javaFunctionJobHandler.goldenUri(), turbine.getPointKey(), timeBegin.getTime(), timeNow.getTime(), 10);
+//                //遍历pointDatas,取出数据算平均值
+//                double avgCutInWindSpeed = 0;
+//                for (PointData pointData : pointDatas) {
+//                    avgCutInWindSpeed += pointData.getValue();
+//                }
+//                avgCutInWindSpeed /= pointDatas.size();
+//
+//                //存入数据库
+//                String turbineId = turbine.getTurbineId();
+//                Date jdkDate = timeBegin.toJdkDate();
+//                System.out.println(turbineId + " " + jdkDate);
+//                QueryWrapper<TurbineInfoDay> turbineInfoDayQueryWrapper = new QueryWrapper<>();
+//                turbineInfoDayQueryWrapper.eq("turbine_id", turbine.getTurbineId());
+//                turbineInfoDayQueryWrapper.eq("record_date", timeBegin.toJdkDate());
+//                TurbineInfoDay one = turbineInfoDayService.getOne(turbineInfoDayQueryWrapper);
+//                System.out.println(one);
+//                if (one == null) {
+//                    TurbineInfoDay turbineInfoDay = new TurbineInfoDay();
+//                    turbineInfoDay.setTurbineId(turbine.getTurbineId());
+//                    turbineInfoDay.setRecordDate(timeBegin.toJdkDate());
+//                    turbineInfoDay.setHjwd(avgCutInWindSpeed);
+//                    System.out.println(turbineInfoDay);
+//                    interest.add(turbineInfoDay);
+////                turbineInfoDayService.save(turbineInfoDay);
+//                } else {
+//                    one.setHjwd(avgCutInWindSpeed);
+//                    System.out.println(one);
+//                    update.add(one);
+////                turbineInfoDayService.updateById(one);
+//                }
+//
+//            }
+////        //批量插入
+////        turbineInfoDayService.saveBatch(interest);
+////        //批量更新
+////        turbineInfoDayService.updateBatchById(update);
+////        //批量插入或更新
+//        turbineInfoDayService.saveOrUpdateBatch(interest);
+//        turbineInfoDayService.saveOrUpdateBatch(update);
+//        }
+//
+//    }
+//
+//
+//    @org.junit.Test
+//    public void test1() {
+//        Date date = DateUtil.date().toJdkDate();
+////        javaFunctionJobHandler.writeReportPool(date);
+////        javaFunctionJobHandler.writeReportPoolProject(date);
+//        javaFunctionJobHandler.writeReportPoolPjfs(date);
+//
+//    }
+//
+//    @org.junit.Test
+//    public void test2() {
+//        Date date = DateUtil.date().toJdkDate();
+////        javaFunctionJobHandler.gongsizhibiao(date);
+//        javaFunctionJobHandler.writeReportPoolLLFDL(date);
+//
+//    }
+//
+//
+//}
+//

+ 1 - 0
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@@ -109,6 +109,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
                 .authorizeRequests()
                 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
                 .antMatchers("/login", "/register", "/captchaImage","/predict/**").permitAll()
+                .antMatchers(HttpMethod.PUT, "/monitor/**").permitAll()
                 // 静态资源,可匿名访问
                 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
                 .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()

+ 1 - 1
ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java

@@ -130,7 +130,7 @@ public class SysJobController extends BaseController {
     /**
      * 定时任务立即执行一次
      */
-    @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
+//    @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
     @Log(title = "定时任务", businessType = BusinessType.UPDATE)
     @PutMapping("/run")
     public AjaxResult run(@RequestBody SysJob job) throws SchedulerException {

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

@@ -61,6 +61,16 @@ public class StationInfoMin implements Serializable {
     private Long gzts;
     private Long jxts;
 
+    public void setLlgl(Double llgl) {
+        if (llgl == null) llgl = 0.0;
+        this.llgl = llgl;
+    }
+
+    public void setKygl(Double kygl) {
+        if (kygl == null) kygl = 0.0;
+        this.kygl = kygl;
+    }
+
     public void setDjts(Long djts) {
         if (djts == null) djts = 0L;
         this.djts = djts;

File diff suppressed because it is too large
+ 1236 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/StationInfoMin2.java


+ 7 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/TurbineInfoDay.java

@@ -49,4 +49,11 @@ public class TurbineInfoDay implements Serializable {
     private Double jxMin;
     private Double xdMin;
     private Double lxMin;
+    private Long djcs;
+    private Long tjcs;
+    private Long yxcs;
+    private Long gzcs;
+    private Long jxcs;
+    private Long xdcs;
+    private Long lxcs;
 }

+ 16 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/mapper/StationInfoMin2Mapper.java

@@ -0,0 +1,16 @@
+package com.ruoyi.ucp.mapper;
+
+import com.ruoyi.ucp.entity.StationInfoMin2;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-11-08
+ */
+public interface StationInfoMin2Mapper extends BaseMapper<StationInfoMin2> {
+
+}

+ 16 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/service/IStationInfoMin2Service.java

@@ -0,0 +1,16 @@
+package com.ruoyi.ucp.service;
+
+import com.ruoyi.ucp.entity.StationInfoMin2;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-11-08
+ */
+public interface IStationInfoMin2Service extends IService<StationInfoMin2> {
+
+}

+ 44 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/service/impl/StationInfoMin2ServiceImpl.java

@@ -0,0 +1,44 @@
+package com.ruoyi.ucp.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.ruoyi.common.annotation.DataSource;
+import com.ruoyi.common.enums.DataSourceType;
+import com.ruoyi.ucp.entity.StationInfoMin2;
+import com.ruoyi.ucp.mapper.StationInfoMin2Mapper;
+import com.ruoyi.ucp.service.IStationInfoMin2Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-11-08
+ */
+@Service
+@DataSource(DataSourceType.SLAVE)
+public class StationInfoMin2ServiceImpl extends ServiceImpl<StationInfoMin2Mapper, StationInfoMin2> implements IStationInfoMin2Service {
+    @Override
+    public StationInfoMin2 getOne(Wrapper<StationInfoMin2> queryWrapper, boolean throwEx) {
+        return super.getOne(queryWrapper, throwEx);
+    }
+
+    @Override
+    public boolean saveOrUpdate(StationInfoMin2 entity) {
+        return super.saveOrUpdate(entity);
+    }
+
+    @Override
+    public List<StationInfoMin2> list(Wrapper<StationInfoMin2> queryWrapper) {
+        return super.list(queryWrapper);
+    }
+
+    @Override
+    public boolean save(StationInfoMin2 entity) {
+        return super.save(entity);
+    }
+}