Browse Source

2个细则

xushili 6 months atrás
parent
commit
d84c3f0eaa

+ 147 - 12
ruoyi-admin/src/main/java/com/ruoyi/web/controller/JavaFunctionJobHandler.java

@@ -58,6 +58,10 @@ public class JavaFunctionJobHandler extends IJobHandler {
     private IStationInfoMinService stationInfoMinService;
     @Resource
     private IProBasicProjectPlanService proBasicProjectPlanService;
+    @Resource
+    private IHistoryPredictService historyPredictService;
+    @Resource
+    private IPredictExaminService predictExaminService;
 
     @Override
     public void execute() throws Exception {
@@ -281,10 +285,10 @@ public class JavaFunctionJobHandler extends IJobHandler {
         String tbId = piZt.getTurbineId();
         //        Map<Double, Long> collect = piZt.getPointDatas().stream().collect(Collectors.groupingBy(PointData::getValue, Collectors.counting()));
         double sumfs = fsList.stream().mapToDouble(PointData::getValue).sum();
-//        double xs = 1;
-//        if (rfdl > 0 && sum1 > 0) {
-//            xs = rfdl / (sum1 / 240);
-//        }
+        //        double xs = 1;
+        //        if (rfdl > 0 && sum1 > 0) {
+        //            xs = rfdl / (sum1 / 240);
+        //        }
         //        double sum2 = fsList.stream().mapToDouble(pd -> {
         //            Double v = CalcCache.fitcoef.get(tbId).get(pd.getValue());
         //            if (v == null) v = 0.0;
@@ -1406,18 +1410,18 @@ public class JavaFunctionJobHandler extends IJobHandler {
             cxInfo.setPointDatas(cxc);
 
             //风机风速、功率->场站风速、功率
-//            List<PointData> firstFs = new ArrayList<>();
-//            List<PointData> firstGl = new ArrayList<>();
+            //            List<PointData> firstFs = new ArrayList<>();
+            //            List<PointData> firstGl = new ArrayList<>();
             List<PointData> firstZsgl = new ArrayList<>();
             double v1, v2, v3;
             for (int i = 0; i < agcInfo.getPointDatas().size(); i++) {
                 int finalI = i;
                 long ts = start.getTime() + i * 15000L;
-//                v1 = fsMap.values().stream().mapToDouble(pds -> pds.getPointDatas().get(finalI).getValue()).average().orElse(0.0);
-//                v2 = glMap.values().stream().mapToDouble(pds -> pds.getPointDatas().get(finalI).getValue()).sum();
+                //                v1 = fsMap.values().stream().mapToDouble(pds -> pds.getPointDatas().get(finalI).getValue()).average().orElse(0.0);
+                //                v2 = glMap.values().stream().mapToDouble(pds -> pds.getPointDatas().get(finalI).getValue()).sum();
                 v3 = pdsZsglMap.values().stream().mapToDouble(pds -> pds.get(finalI).getValue()).sum();
-//                firstFs.add(new PointData(ts, v1));
-//                firstGl.add(new PointData(ts, v2));
+                //                firstFs.add(new PointData(ts, v1));
+                //                firstGl.add(new PointData(ts, v2));
                 firstZsgl.add(new PointData(ts, v3));
             }
 
@@ -1802,7 +1806,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         Map<String, Map<Integer, Integer>> collectAi = list.stream().collect(Collectors.groupingBy(StateAi::getModel, Collectors.toMap(StateAi::getOriginalState, StateAi::getMappingState)));
 
         //        Map<String, Map<Double,Double>> fitMap = new HashMap<>();
-//        entityFs = entityFs.stream().filter(ef -> !CalcCache.keys.contains(ef.getTurbineId())).collect(Collectors.toList());
+        //        entityFs = entityFs.stream().filter(ef -> !CalcCache.keys.contains(ef.getTurbineId())).collect(Collectors.toList());
         for (PointInfo ef : entityFs) {
             String wtId = ef.getTurbineId();
             PointInfo glInfo = glMap.get(wtId);
@@ -3988,7 +3992,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
             if (pdCx.getTs() + 10 * 60 * 1000 > end.getTime()) {
                 if (llgl < sjgl) llgl = sjgl * 1.0005;
                 if (llgl > sjgl * 1.5) llgl = sjgl * 1.5;
-            }else {
+            } else {
                 System.out.println("实际功率测点离线");
             }
             PointData data = new PointData();
@@ -4052,6 +4056,137 @@ public class JavaFunctionJobHandler extends IJobHandler {
         }
         stationInfoMinService.saveOrUpdateBatch(byDate);
     }
+
+    public void calcPredictExamin(Date date) {
+        DateTime end = DateUtil.beginOfDay(date);
+        DateTime begin = DateUtil.offsetDay(end, -1);
+        List<PointInfo> entity = getEntity("MX000", "state");
+        List<PointInfo> entity1 = getEntity("AI422", "state");
+        entity.addAll(entity1);
+        Map<String, EquipmentModel> map = equipmentModelService.map();
+
+        Map<String, Double> tbPowerMap = entity.stream().collect(Collectors.toMap(pi -> pi.getTurbineId(), pi -> map.get(pi.getTurbineId()).getPowerProduction()));
+        List<PointInfo> entityGl = getEntity("AI114", "turbine");
+        getSnapDataByEntity(entityGl, begin, end, 15 * 60);
+        Map<String, PointInfo> glpisMap = entityGl.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
+        QueryWrapper<HistoryPredict> predictWrapper = new QueryWrapper<>();
+        predictWrapper.lambda().eq(HistoryPredict::getPredictType, "CDQ").eq(HistoryPredict::getDataTime, begin)
+                .orderByAsc(HistoryPredict::getDataTime);
+        List<HistoryPredict> predictList = historyPredictService.list(predictWrapper);
+        Map<String, List<HistoryPredict>> predictsMap = predictList.stream().collect(Collectors.groupingBy(HistoryPredict::getTurbineId));
+        //超短期
+        List<HistoryPredict> cdqPredicts = new ArrayList<>();
+        predictsMap.forEach((stId, hps) -> {
+            cdqPredicts.addAll(hps.subList(0, 16));
+        });
+        for (int i = 1; i < 6; i++) {
+            DateTime hour = DateUtil.offsetHour(begin, 4 * i);
+            DateTime hour2 = DateUtil.offsetHour(hour, 4);
+            QueryWrapper<HistoryPredict> wrapper = new QueryWrapper<>();
+            wrapper.lambda().eq(HistoryPredict::getPredictType, "CDQ").eq(HistoryPredict::getDataTime, hour)
+                    .between(HistoryPredict::getPredictTime, hour, hour2).orderByAsc(HistoryPredict::getDataTime);
+            List<HistoryPredict> predicts = historyPredictService.list(predictWrapper);
+            cdqPredicts.addAll(predicts);
+        }
+        Map<String, List<HistoryPredict>> cdqPredictsMap = cdqPredicts.stream().collect(Collectors.groupingBy(HistoryPredict::getTurbineId));
+
+        List<PredictExamin> peList = new ArrayList<>();
+        predictsMap.forEach((stId, hps) -> {
+            List<Double> predictPower = hps.stream().map(HistoryPredict::getPredictPower).collect(Collectors.toList());
+            List<Double> actualPower = glpisMap.get(stId).getPointDatas().stream().map(PointData::getValue).collect(Collectors.toList());
+            Double installCapacity = tbPowerMap.get(stId);
+            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.setPeriodId(predict.getPeriodId());
+            examin.setLineId(predict.getLineId());
+            examin.setTurbineId(predict.getTurbineId());
+            examin.setExaminScore(calcExaminScore(predictPower, actualPower, installCapacity));
+            examin.setAccuracyRate(calcAccuracyRate(predictPower, actualPower, installCapacity));
+            peList.add(examin);
+            //超短期
+            List<Double> predictPowerCdq = cdqPredictsMap.get(stId).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.setPeriodId(predict.getPeriodId());
+            e.setLineId(predict.getLineId());
+            e.setTurbineId(predict.getTurbineId());
+            e.setExaminScore(calcExaminScore(predictPowerCdq, actualPower, installCapacity));
+            e.setAccuracyRate(calcAccuracyRate(predictPowerCdq, actualPower, installCapacity));
+            peList.add(e);
+        });
+        predictExaminService.saveBatch(peList);
+    }
+
+    /**
+     * 计算功率日预测曲线最大误差值
+     *
+     * @param predictPower    96个点的预测功率值
+     * @param actualPower     96个点的实际功率值
+     * @param installCapacity 装机容量
+     * @return 结果
+     */
+    public double calcExaminScore(List<Double> predictPower, List<Double> actualPower, Double installCapacity) {
+        if (CollUtil.isEmpty(predictPower) || CollUtil.isEmpty(actualPower) || installCapacity == null) return 0;
+        int n = predictPower.size();
+        if (n != actualPower.size()) return 0;
+        double maxErrorPercentage = 0.0;
+        for (int i = 0; i < n; i++) {
+            double errorPercentage = 0.0;
+            if (predictPower.get(i) == 0) {
+                if (Math.abs(actualPower.get(i)) <= 0.03 * installCapacity) {
+                    continue; // 不考核
+                } else {
+                    errorPercentage = 100.0;
+                }
+            } else {
+                errorPercentage = Math.abs(predictPower.get(i) - actualPower.get(i)) / predictPower.get(i) * 100;
+            }
+            if (errorPercentage > maxErrorPercentage) {
+                maxErrorPercentage = errorPercentage;
+            }
+        }
+        return maxErrorPercentage;
+    }
+
+    /**
+     * 计算功率超短期预测曲线准确率
+     *
+     * @param predictPower    96个点的预测功率值
+     * @param actualPower     96个点的实际功率值
+     * @param installCapacity 装机容量
+     * @return 结果
+     */
+    public double calcAccuracyRate(List<Double> predictPower, List<Double> actualPower, Double installCapacity) {
+        if (CollUtil.isEmpty(predictPower) || CollUtil.isEmpty(actualPower) || installCapacity == null) return 0;
+        int n = predictPower.size();
+        if (n != actualPower.size()) return 0;
+        double totalError = 0.0;
+        int validPoints = 0;
+        for (int i = 0; i < n; i++) {
+            double errorPercentage = 0.0;
+            if (Math.abs(predictPower.get(i) - actualPower.get(i)) <= 0.03 * installCapacity) {
+                // 该点不计入误差计算
+                continue;
+            }
+            errorPercentage = Math.abs(predictPower.get(i) - actualPower.get(i)) / installCapacity * 100;
+            totalError += errorPercentage;
+            validPoints++;
+        }
+        if (validPoints == 0) {
+            return 100.0; // 所有点均在3%以内,准确率为100%
+        } else {
+            return 100 - totalError / validPoints;
+        }
+    }
 }
 
 

+ 146 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/PredictExamin.java

@@ -0,0 +1,146 @@
+package com.ruoyi.ucp.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-10-29
+ */
+@TableName("predict_examin")
+public class PredictExamin implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private Integer id;
+
+    private String modelId;
+
+    private String predictType;
+
+    private String deviceType;
+
+    private Date time;
+
+    private String siteId;
+
+    private String periodId;
+
+    private String lineId;
+
+    private String turbineId;
+
+    private Double examinScore;
+
+    private Double accuracyRate;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getModelId() {
+        return modelId;
+    }
+
+    public void setModelId(String modelId) {
+        this.modelId = modelId;
+    }
+
+    public String getPredictType() {
+        return predictType;
+    }
+
+    public void setPredictType(String predictType) {
+        this.predictType = predictType;
+    }
+
+    public String getDeviceType() {
+        return deviceType;
+    }
+
+    public void setDeviceType(String deviceType) {
+        this.deviceType = deviceType;
+    }
+
+    public Date getTime() {
+        return time;
+    }
+
+    public void setTime(Date time) {
+        this.time = time;
+    }
+
+    public String getSiteId() {
+        return siteId;
+    }
+
+    public void setSiteId(String siteId) {
+        this.siteId = siteId;
+    }
+
+    public String getPeriodId() {
+        return periodId;
+    }
+
+    public void setPeriodId(String periodId) {
+        this.periodId = periodId;
+    }
+
+    public String getLineId() {
+        return lineId;
+    }
+
+    public void setLineId(String lineId) {
+        this.lineId = lineId;
+    }
+
+    public String getTurbineId() {
+        return turbineId;
+    }
+
+    public void setTurbineId(String turbineId) {
+        this.turbineId = turbineId;
+    }
+
+    public Double getExaminScore() {
+        return examinScore;
+    }
+
+    public void setExaminScore(Double examinScore) {
+        this.examinScore = examinScore;
+    }
+
+    public Double getAccuracyRate() {
+        return accuracyRate;
+    }
+
+    public void setAccuracyRate(Double accuracyRate) {
+        this.accuracyRate = accuracyRate;
+    }
+
+    @Override
+    public String toString() {
+        return "PredictExamin{" +
+            "id = " + id +
+            ", modelId = " + modelId +
+            ", predictType = " + predictType +
+            ", deviceType = " + deviceType +
+            ", time = " + time +
+            ", siteId = " + siteId +
+            ", periodId = " + periodId +
+            ", lineId = " + lineId +
+            ", turbineId = " + turbineId +
+            ", examinScore = " + examinScore +
+            ", accuracyRate = " + accuracyRate +
+        "}";
+    }
+}

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

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

+ 18 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/service/IPredictExaminService.java

@@ -0,0 +1,18 @@
+package com.ruoyi.ucp.service;
+
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.ruoyi.ucp.entity.PredictExamin;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-10-29
+ */
+@DS("glyc")
+public interface IPredictExaminService extends IService<PredictExamin> {
+
+}

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

@@ -0,0 +1,20 @@
+package com.ruoyi.ucp.service.impl;
+
+import com.ruoyi.ucp.entity.PredictExamin;
+import com.ruoyi.ucp.mapper.PredictExaminMapper;
+import com.ruoyi.ucp.service.IPredictExaminService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-10-29
+ */
+@Service
+public class PredictExaminServiceImpl extends ServiceImpl<PredictExaminMapper, PredictExamin> implements IPredictExaminService {
+
+}