xushili před 6 měsíci
rodič
revize
9db57f7e0d

+ 79 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/Fq.java

@@ -806,4 +806,83 @@
 //    entityAiZt = filterPointInfo(entityAiZt, "NX_FGS_HA_F_WT_0002_EQ", PointInfo::getTurbineId);
 //    getRawDataByEntity(entityAiZt, goldenUri(), begin, end);
 //    System.out.println();
+//}
+
+
+//public void calcTurbine5s(DateTime begin, DateTime end, double ssxs) {
+//    List<PointInfo> isFubing = getIsFubing(begin, end);
+//    Map<String, List<PointData>> isFubingMap = isFubing.stream().collect(Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas));
+//    //风速
+//    List<PointInfo> entityFs = getEntity("AI066", "turbine");
+//    getSnapDataByEntity(entityFs, begin, end, 15);
+//    Map<String, List<PointData>> fsMap = entityFs.stream().collect(Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas));
+//    //功率
+//    List<PointInfo> entityGl = getEntity("AI114", "turbine");
+//    getSnapDataByEntity(entityGl, begin, end, 15);
+//    Map<String, List<PointData>> glMap = entityGl.stream().collect(Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas));
+//    //状态
+//    List<PointInfo> ztMapMap = calcTurbineZt(begin, end, entityFs, entityGl);
+//    Map<String, Map<String, PointInfo>> ztMapMapInfos = ztMapMap.stream().collect(
+//            Collectors.groupingBy(PointInfo::getStationId, Collectors.toMap(PointInfo::getTurbineId, Function.identity())));
+//    //发电量
+//    List<PointInfo> fdlEntity = getEntity("AI121", "turbine");
+//    getSnapDataByEntity(fdlEntity, begin, end, 15);
+//    Map<String, PointInfo> fdlMap = fdlEntity.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
+//
+//    List<PointData> glpdss = entityGl.get(0).getPointDatas();
+//    List<Long> tss = glpdss.stream().map(PointData::getTs).collect(Collectors.toList());
+//    List<Double> zeroList = IntStream.range(0, glpdss.size()).mapToObj(i -> 0.0).collect(Collectors.toList());
+//    List<PointData> tbFsPdList = new ArrayList<>();
+//    List<PowerLosses> turbineLosses = new ArrayList<>();
+//    Map<String, TurbineInfoDay> dayMap = getTurbineinfoMap(begin, entityFs);
+//    ztMapMapInfos.forEach((stId, ztMapInfo) -> ztMapInfo.forEach((wtId, ztInfo) -> {
+//        //0 待机,1 手动停机,2 正常发电,3 发电降出力,4 故障,5 故障受累,6 检修,7 检修受累,8 限电降出力,
+//        // 9 限电停机,10 电网受累,11 环境受累,12 通讯中断,13 设备离线
+//        List<PointData> fsPds = fsMap.get(wtId);
+//        TurbineInfoDay infoDay = dayMap.get(wtId);
+//        List<Double> turbineZeroList = IntStream.range(0, glpdss.size()).mapToObj(i -> 0.0).collect(Collectors.toList());
+//        getXdQx(turbineZeroList, zeroList, ztInfo, fsPds, glMap.get(wtId));
+//        Map<String, Double> loss = getTurbinePowerLoss2(isFubingMap.get(wtId), ztInfo, fsPds, glMap.get(wtId));
+//        infoDay.setJhjxss(loss.get("jxss") * ssxs);
+//        infoDay.setFjhjxss(loss.get("gzss") * ssxs + loss.get("fdjcl") * ssxs + loss.get("sdtj") * ssxs);
+//        infoDay.setXdss(loss.get("xdjcl") * ssxs + loss.get("xdtj") * ssxs);
+//        infoDay.setSlss(loss.get("slss") * ssxs);
+//        infoDay.setDjss(loss.get("xdtj") * ssxs);
+//        infoDay.setGzss(loss.get("gzss") * ssxs);
+//        infoDay.setXnss(loss.get("xnss") * ssxs + loss.get("djss") * ssxs);
+//        infoDay.setLlfdl(infoDay.getRfdl() + infoDay.getJhjxss() + infoDay.getFjhjxss() + infoDay.getXdss() + infoDay.getSlss() + infoDay.getXnss());
+//        //风机限电时段
+//        List<Double> collect = turbineZeroList.stream().map(v -> v / 240).collect(Collectors.toList());
+//        List<PowerLosses> tblss = calcLossPeriods(collect, tss);
+//        PointInfo fdlPis = fdlMap.get(wtId);
+//        List<PointData> fdlPds = fdlPis.getPointDatas();
+//        for (PowerLosses pl : tblss) {
+//            pl.setItem("turbine");
+//            pl.setStationId(stId);
+//            pl.setTurbineId(wtId);
+//            List<PointData> tbXdPdsn = fdlPds.stream().filter(pd -> isTimeIn(pd.getTs(), pl)).collect(Collectors.toList());
+//            List<PointData> tbFsPdsn = fsPds.stream().filter(pd -> isTimeIn(pd.getTs(), pl)).collect(Collectors.toList());
+//            pl.setFdl(calcHaDl(tbXdPdsn, fdlPis.getCoef()));
+//            double pjfs = tbFsPdsn.stream().mapToDouble(pd -> pd.getValue()).average().orElse(0d);
+//            pl.setPjfs(pjfs);
+//            tbFsPdList.addAll(tbFsPdsn);
+//        }
+//        turbineLosses.addAll(tblss);
+//    }));
+//    //场站限电时段
+//    List<Double> collect = zeroList.stream().map(v -> v / 240).collect(Collectors.toList());
+//    List<PowerLosses> losses = calcLossPeriods(collect, tss);
+//    for (PowerLosses loss : losses) {
+//        loss.setItem("station");
+//        double pjfs = tbFsPdList.stream().filter(pd -> isTimeIn(pd.getTs(), loss)).mapToDouble(pd -> pd.getValue()).average().orElse(0d);
+//        loss.setPjfs(pjfs);
+//        double fdl = turbineLosses.stream().filter(tl -> isTimeIn(tl, loss)).mapToDouble(PowerLosses::getFdl).sum();
+//        loss.setFdl(fdl);
+//    }
+//    QueryWrapper<PowerLosses> queryWrapper = new QueryWrapper<>();
+//    queryWrapper.eq("record_date", new Date(begin.getTime()));
+//    //powerLossesService.remove(queryWrapper);
+//    //powerLossesService.saveBatch(losses);
+//    ////powerLossesService.saveBatch(turbineLosses);
+//    //turbineInfoDayService.saveOrUpdateBatch(dayMap.values());
 //}

+ 371 - 124
ruoyi-admin/src/main/java/com/ruoyi/web/controller/JavaFunctionJobHandler.java

@@ -346,6 +346,10 @@ public class JavaFunctionJobHandler extends IJobHandler {
         //return URI.create("http://127.0.0.1:8011/ts");
     }
 
+    public URI mqttUri() {
+        return URI.create("http://127.0.0.1:8111/mqtt");
+    }
+
     public Map<String, String> getEntityMap(String uniformCode, String institutionType) {
         PointInfo pi = new PointInfo();
         pi.setUniformCode(uniformCode);
@@ -507,6 +511,79 @@ public class JavaFunctionJobHandler extends IJobHandler {
         return map;
     }
 
+    public Map<String, Double> getTurbinePowerLoss(PointInfo piZt, List<PointData> fsList, List<PointData> glList) {
+        String tbId = piZt.getTurbineId();
+        double sumfs = fsList.stream().mapToDouble(PointData::getValue).sum();
+
+        List<PointData> collectZt = piZt.getPointDatas();
+        double jxss = 0, sdtj = 0, gzss = 0, djss = 0, xnss = 0, fdjcl = 0, xdjcl = 0, xdtj = 0;
+        Map<String, Double> map = new HashMap<>();
+        if (Math.abs(collectZt.size() - fsList.size()) < 9 && Math.abs(fsList.size() - glList.size()) < 9) {
+            int min = Math.min(collectZt.size(), Math.min(fsList.size(), glList.size()));
+            for (int i = 0; i < min; i++) {
+                Double v = CalcCache.fitcoef.get(tbId).get(fsList.get(i).getValue());
+                if (v == null) v = 0.0;
+                v = v - glList.get(i).getValue();
+                switch ((int) collectZt.get(i).getValue()) {
+                    //计划检修损失:
+                    case 6:
+                        //检修
+                        jxss += v;
+                        break;
+                    case 1:
+                        //手动停机
+                        sdtj += v;
+                        break;
+                    //非计划检修损失:
+                    case 4:
+                        //故障
+                        gzss += v;
+                        break;
+                    case 0:
+                        //待机
+                        djss += v;
+                        break;
+                    //性能损失:
+                    case 2:
+                        //性能
+                        xnss += v;
+                        break;
+                    case 3:
+                        //发电降出力
+                        fdjcl += v;
+                        break;
+                    //限电损失:
+                    case 8:
+                        //限电降出力
+                        xdjcl += v > 0d ? v : 0d;
+                        break;
+                    case 9:
+                        //限电停机
+                        xdtj += v;
+                        break;
+                }
+            }
+        }
+        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);
+        map.put("gzss", gzss > 0 ? gzss / 240 : 0);
+        map.put("djss", djss > 0 ? djss / 240 : 0);
+        map.put("xnss", xnss > 0 ? xnss / 240 : 0);
+        map.put("fdjcl", fdjcl > 0 ? fdjcl / 240 : 0);
+        map.put("xdjcl", xdjcl > 0 ? xdjcl / 240 : 0);
+        map.put("xdtj", xdtj > 0 ? xdtj / 240 : 0);
+        return map;
+    }
+
     public Map<String, Double> getTurbinePowerLoss2(List<PointData> isfb, PointInfo piZt, List<PointData> fsList, List<PointData> glList) {
 
         String tbId = piZt.getTurbineId();
@@ -1836,7 +1913,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
             try {
                 double pdsfdl0 = fdlMap0.get(lineId).getPointDatas().stream().mapToDouble(PointData::getValue).max().orElse(0);
                 double pdsfdl = pifdl.getPointDatas().stream().mapToDouble(PointData::getValue).max().orElse(0);
-                fdl = NumberUtil.round((pdsfdl - pdsfdl0),2).doubleValue() * pifdl.getCoef();
+                fdl = NumberUtil.round((pdsfdl - pdsfdl0), 2).doubleValue() * pifdl.getCoef();
             } catch (Exception e) {
                 e.printStackTrace();
             }
@@ -2016,6 +2093,244 @@ public class JavaFunctionJobHandler extends IJobHandler {
         turbineInfoDayService.saveOrUpdateBatch(infoDays);
     }
 
+    public void calcTurbine5sSameDay(DateTime begin, DateTime end) {
+        //风速
+        List<PointInfo> entityFs = getEntity("AI066", "turbine");
+        getSnapDataByEntity(entityFs, begin, end, 15);
+        Map<String, Map<String, List<PointData>>> fsMapMap = entityFs.stream().collect(Collectors.groupingBy
+                (PointInfo::getStationId, Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas)));
+        //功率
+        List<PointInfo> entityGl = getEntity("AI114", "turbine");
+        getSnapDataByEntity(entityGl, begin, end, 15);
+        Map<String, Map<String, List<PointData>>> glMapMap = entityGl.stream().collect(Collectors.groupingBy
+                (PointInfo::getStationId, Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas)));
+        //状态
+        List<PointInfo> ztMapMap = calcTurbineZt(begin, end, entityFs, entityGl);
+        Map<String, Map<String, PointInfo>> ztMapMapInfos = ztMapMap.stream().collect(Collectors.groupingBy
+                (PointInfo::getStationId, Collectors.toMap(PointInfo::getTurbineId, Function.identity())));
+        //AGC
+        List<PointInfo> entityAgc = getEntity("AGC002", "booster");
+        getSnapDataByEntity(entityAgc, begin, end, 15);
+        //出线
+        List<PointInfo> entityCx = getEntity("AGC020", "booster");
+        getSnapDataByEntity(entityCx, begin, end, 15);
+        //可用功率
+        List<PointData> kyglpds = adapter.getHistorySnap(goldenUri(), "区域集控.惠安风场.升压站.中车风机设备信息.可用发电功率", begin.getTime(), end.getTime(), 15);
+        List<PointData> kyglpds2 = adapter.getHistorySnap(goldenUri(), "区域集控.惠安风场.升压站.联合动力能管信息.可用发电功率", begin.getTime(), end.getTime(), 15);
+        CollUtil.forEach(kyglpds, (pd, i) -> pd.setDoubleValue(pd.getValue() + kyglpds2.get(i).getValue()));
+        //信息表
+        Map<String, TurbineInfoMin> dayMap = getTurbineinfoByMinMap(begin, entityFs);
+        List<TurbineInfoMin> infoDays = new ArrayList<>();
+        ztMapMapInfos.forEach((stId, ztMapInfo) -> ztMapInfo.forEach((wtId, ztInfo) -> {
+            //0 待机,1 手动停机,2 正常发电,3 发电降出力,4 故障,5 故障受累,6 检修,7 检修受累,8 限电降出力,
+            // 9 限电停机,10 电网受累,11 环境受累,12 通讯中断,13 设备离线
+            TurbineInfoMin infoDay = dayMap.get(wtId);
+            Map<String, Double> loss = getTurbinePowerLoss(ztMapMapInfos.get(stId).get(wtId), fsMapMap.get(stId).get(wtId), glMapMap.get(stId).get(wtId));
+            infoDay.setJhjxss(loss.get("jxss") + loss.get("sdtj"));
+            infoDay.setFjhjxss(loss.get("gzss") + loss.get("fdjcl"));
+            infoDay.setXdss(loss.get("xdjcl") + loss.get("xdtj"));
+            infoDay.setSlss(0.0);
+            infoDay.setDjss(loss.get("djss"));
+            infoDay.setGzss(loss.get("gzss"));
+            infoDay.setXnss(loss.get("xnss") + loss.get("djss"));
+            infoDay.setLlfdl(infoDay.getJhjxss() + infoDay.getFjhjxss() +
+                    infoDay.getXdss() + infoDay.getSlss() + infoDay.getXnss());
+            infoDays.add(infoDay);
+        }));
+        turbineInfoMinService.saveOrUpdateBatch(infoDays);
+    }
+
+    public void calcTurbine5sMin(DateTime begin, DateTime end, double ssxs) {
+        //if (end.equals(DateUtil.beginOfDay(end))) return;
+        List<PointInfo> isFubing = getIsFubing(begin, end);
+        Map<String, List<PointData>> isFubingMap = isFubing.stream().collect(Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas));
+        //风速
+        List<PointInfo> entityFs = getEntity("AI066", "turbine");
+        getSnapDataByEntity(entityFs, begin, end, 15);
+        Map<String, Map<String, List<PointData>>> fsMapMap = entityFs.stream().collect(Collectors.groupingBy(PointInfo::getStationId,
+                Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas)));
+        //功率
+        List<PointInfo> entityGl = getEntity("AI114", "turbine");
+        getSnapDataByEntity(entityGl, begin, end, 15);
+        Map<String, Map<String, List<PointData>>> glMapMap = entityGl.stream().collect(Collectors.groupingBy(PointInfo::getStationId,
+                Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas)));
+        //状态
+        List<PointInfo> ztMapMap = calcTurbineZt(begin, end, entityFs, entityGl);
+        Map<String, Map<String, PointInfo>> ztMapMapInfos = ztMapMap.stream().collect(
+                Collectors.groupingBy(PointInfo::getStationId, Collectors.toMap(PointInfo::getTurbineId, Function.identity())));
+        //AGC
+        List<PointInfo> entityAgc = getEntity("AGC002", "booster");
+        getSnapDataByEntity(entityAgc, begin, end, 15);
+        //出线
+        List<PointInfo> entityCx = getEntity("AGC020", "booster");
+        getSnapDataByEntity(entityCx, begin, end, 15);
+        //可用功率
+        List<PointData> kyglpds = adapter.getHistorySnap(goldenUri(), "区域集控.惠安风场.升压站.中车风机设备信息.可用发电功率", begin.getTime(), end.getTime(), 15);
+        List<PointData> kyglpds2 = adapter.getHistorySnap(goldenUri(), "区域集控.惠安风场.升压站.联合动力能管信息.可用发电功率", begin.getTime(), end.getTime(), 15);
+        CollUtil.forEach(kyglpds, (pd, i) -> pd.setDoubleValue(pd.getValue() + kyglpds2.get(i).getValue()));
+        //信息表
+        Map<String, TurbineInfoMin> dayMap = getTurbineinfoByMinMap(begin, entityFs);
+        ztMapMapInfos.forEach((stId, ztMapInfo) -> ztMapInfo.forEach((wtId, ztInfo) -> {
+            //0 待机,1 手动停机,2 正常发电,3 发电降出力,4 故障,5 故障受累,6 检修,7 检修受累,8 限电降出力,
+            // 9 限电停机,10 电网受累,11 环境受累,12 通讯中断,13 设备离线
+            TurbineInfoMin infoDay = dayMap.get(wtId);
+            Map<String, Double> loss = getTurbinePowerLoss2(isFubingMap.get(wtId), ztInfo, fsMapMap.get(stId).get(wtId), glMapMap.get(stId).get(wtId));
+            infoDay.setJhjxss(loss.get("jxss") * ssxs);
+            infoDay.setFjhjxss(loss.get("gzss") * ssxs + loss.get("fdjcl") * ssxs + loss.get("sdtj") * ssxs);
+            infoDay.setXdss(loss.get("xdjcl") * ssxs + loss.get("xdtj") * ssxs);
+            infoDay.setSlss(loss.get("slss") * ssxs);
+            infoDay.setDjss(loss.get("xdtj") * ssxs);
+            infoDay.setGzss(loss.get("gzss") * ssxs);
+            infoDay.setXnss(loss.get("xnss") * ssxs + loss.get("djss") * ssxs);
+            infoDay.setLlfdl(infoDay.getJhjxss() + infoDay.getFjhjxss() + infoDay.getXdss() + infoDay.getSlss() + infoDay.getXnss());
+        }));
+
+        PointInfo cxPi = entityCx.get(0);
+        List<PointData> cxPds = cxPi.getPointDatas();
+        List<PointData> czxd = calcStationXd2(entityAgc.get(0), cxPds, kyglpds, 0.01);
+        List<Double> xdl = new ArrayList<>();
+        //其他损失电量
+        List<Double> zssdl = new ArrayList<>();
+        for (int i = 0; i < cxPds.size(); i++) {
+            double v = kyglpds.get(i).getValue() * 1000 - cxPds.get(i).getValue() * cxPi.getCoef();
+            if (v < 0) v = 0;
+            if (czxd.get(i).isBooleanValue()) {
+                xdl.add(v);
+            } else {
+                xdl.add(0d);
+                zssdl.add(v);
+            }
+        }
+        double sumxdl = xdl.stream().mapToDouble(Double::doubleValue).sum() / 2400;
+        double sumZssdl = zssdl.stream().mapToDouble(Double::doubleValue).sum() / 2400;
+        double xdsum = dayMap.values().stream().mapToDouble(TurbineInfoMin::getXdss).sum();
+        //xd + fjh + jh + xn
+        double zsssum = dayMap.values().stream().mapToDouble(tid -> tid.getFjhjxss() + tid.getJhjxss() + tid.getXnss()).sum();
+        double xdxs = xdsum == 0d ? 0d : sumxdl / xdsum;
+        double zssXs = zsssum == 0d ? 0d : sumZssdl / zsssum;
+        dayMap.values().forEach(tid -> {
+            tid.setXdss((tid.getXdss() - tid.getDjss()) * xdxs);
+            tid.setLlfdl(tid.getXdss() + tid.getFjhjxss() + tid.getJhjxss() + tid.getXnss());
+            //
+            tid.setJhjxss(tid.getJhjxss() * zssXs);
+            tid.setFjhjxss(tid.getFjhjxss() * zssXs);
+            tid.setXnss(tid.getXnss() * zssXs);
+            tid.setDjss(tid.getDjss() * zssXs);
+            tid.setGzss(tid.getGzss() * zssXs);
+        });
+        turbineInfoMinService.saveOrUpdateBatch(dayMap.values());
+    }
+
+    public void calcStation5s(DateTime begin, DateTime end) {
+        if (end.equals(DateUtil.beginOfDay(end))) {
+            return;
+        } else {
+            begin = DateUtil.beginOfDay(begin);
+        }
+        //AGC
+        List<PointInfo> entityAgc = getEntity("AGC002", "booster");
+        getSnapDataByEntity(entityAgc, begin, end, 15);
+        //出线
+        List<PointInfo> entityCx = getEntity("AGC020", "booster");
+        getSnapDataByEntity(entityCx, begin, end, 15);
+        //可用功率
+        List<PointData> kyglpds = adapter.getHistorySnap(goldenUri(), "区域集控.惠安风场.升压站.中车风机设备信息.可用发电功率", begin.getTime(), end.getTime(), 15);
+        List<PointData> kyglpds2 = adapter.getHistorySnap(goldenUri(), "区域集控.惠安风场.升压站.联合动力能管信息.可用发电功率", begin.getTime(), end.getTime(), 15);
+        CollUtil.forEach(kyglpds, (pd, i) -> pd.setDoubleValue(pd.getValue() + kyglpds2.get(i).getValue()));
+
+        PointInfo cxPi = entityCx.get(0);
+        List<PointData> cxPds = cxPi.getPointDatas();
+        List<PointData> czxd = calcStationXd2(entityAgc.get(0), cxPds, kyglpds, 0.01);
+        List<Double> xdl = new ArrayList<>();
+
+        for (int i = 0; i < cxPds.size(); i++) {
+            double v = kyglpds.get(i).getValue() * 1000 - cxPds.get(i).getValue() * cxPi.getCoef();
+            if (v < 0) v = 0;
+            if (czxd.get(i).isBooleanValue()) {
+                xdl.add(v);
+            } else {
+                xdl.add(0d);
+            }
+        }
+        double sumxdl = xdl.stream().mapToDouble(Double::doubleValue).sum() / 2400;
+        PointData data = new PointData(end.getTime(), NumberUtil.round(sumxdl, 4).doubleValue());
+        data.setTagName("区域集控.惠安风场.统计计算.总日限电量");
+        adapter.writeHistoryBatch(mqttUri(), Collections.singletonList(data));
+    }
+
+    public void haxdRecalc(Date date) {
+        DateTime end = DateUtil.beginOfDay(date);
+        DateTime begin = DateUtil.offsetDay(end, -1);
+        //AGC
+        List<PointInfo> entityAgc = getEntity("AGC002", "booster");
+        getSnapDataByEntity(entityAgc, begin, end, 15);
+        //出线
+        List<PointInfo> entityCx = getEntity("AGC020", "booster");
+        getSnapDataByEntity(entityCx, begin, end, 15);
+        //可用功率
+        //List<PointData> kyglpds1 = adapter.getHistorySnap(goldenUri(), "区域集控.惠安风场.AGCAVC.实时可调上限", begin.getTime(), end.getTime(), 15);
+        List<PointData> cdxdlPd = adapter.getHistoryRaw(goldenUri(), "区域集控.惠安风场.统计计算.日限电量", end.getTime() - 2 * 60 * 60 * 1000, end.getTime());
+        double cdxdl = cdxdlPd.stream().mapToDouble(PointData::getValue).max().orElse(0d) * 1000;
+        List<PointData> kyglpds1 = adapter.getHistorySnap(goldenUri(), "区域集控.惠安风场.升压站.中车风机设备信息.可用发电功率", begin.getTime(), end.getTime(), 15);
+        List<PointData> kyglpds2 = adapter.getHistorySnap(goldenUri(), "区域集控.惠安风场.升压站.联合动力能管信息.可用发电功率", begin.getTime(), end.getTime(), 15);
+        for (int i = 0; i < kyglpds1.size(); i++) {
+            PointData pd = kyglpds1.get(i);
+            pd.setDoubleValue(pd.getValue() + kyglpds2.get(i).getValue());
+        }
+        PointInfo cxPi = entityCx.get(0);
+        List<PointData> cxPds = cxPi.getPointDatas();
+        List<PointData> czxd = calcStationXd2(entityAgc.get(0), cxPds, kyglpds1, 0.01);
+        List<Double> xdl = new ArrayList<>();
+        //总损失电量
+        List<Double> zssdl = new ArrayList<>();
+        for (int i = 0; i < cxPds.size(); i++) {
+            double v = kyglpds1.get(i).getValue() * 1000 - cxPds.get(i).getValue() * cxPi.getCoef();
+            if (v < 0) v = 0;
+            if (czxd.get(i).isBooleanValue()) {
+                xdl.add(v);
+            } else {
+                xdl.add(0d);
+                zssdl.add(v);
+            }
+        }
+        double sum = xdl.stream().mapToDouble(Double::doubleValue).sum() / 2400;
+        //double xdv = sum / cdxdl;
+        //if (xdv > 0.98 && xdv < 1.02) {
+        //} else {
+        //    if (xdv > 0.57) {
+        //        sum = cdxdl * 0.9 + sum * 0.1;
+        //    } else {
+        //        sum = sum * 1.44;
+        //    }
+        //}
+        double sumZssdl = zssdl.stream().mapToDouble(Double::doubleValue).sum() / 2400;
+        //List<Long> tss = entityCx.get(0).getPointDatas().stream().map(v -> v.getTs()).collect(Collectors.toList());
+        //List<PowerLosses> losses = calcLossPeriods(xdl, tss);
+        //CsvWriter writer = CsvUtil.getWriter("D:/loss.csv", CharsetUtil.CHARSET_UTF_8);
+        //writer.writeBeans(losses);
+        //writer.flush();
+        List<TurbineInfoDay> byDate = getTurbineinfoByDate(begin);
+        double xdsum = byDate.stream().mapToDouble(TurbineInfoDay::getXdss).sum();
+        //xd + fjh + jh + xn
+        double zsssum = byDate.stream().mapToDouble(tid -> tid.getFjhjxss() + tid.getJhjxss() + tid.getXnss()).sum();
+        double xs = xdsum == 0d ? 0d : sum / xdsum;
+        double zssXs = zsssum == 0d ? 0d : sumZssdl / zsssum;
+        byDate.forEach(tid -> {
+            tid.setXdss((tid.getXdss() - tid.getDjss()) * xs);
+            tid.setLlfdl(tid.getRfdl() + tid.getXdss() + tid.getFjhjxss() + tid.getJhjxss() + tid.getXnss());
+            //
+            tid.setJhjxss(tid.getJhjxss() * zssXs);
+            tid.setFjhjxss(tid.getFjhjxss() * zssXs);
+            tid.setXnss(tid.getXnss() * zssXs);
+            tid.setDjss(tid.getDjss() * zssXs);
+            tid.setGzss(tid.getGzss() * zssXs);
+        });
+        //turbineInfoDayService.saveOrUpdateBatch(byDate);
+        PointData data = new PointData(end.getTime(), NumberUtil.round(sum, 4).doubleValue());
+        data.setTagName("区域集控.惠安风场.统计计算.总日限电量");
+        adapter.writeHistoryBatch(mqttUri(), Collections.singletonList(data));
+    }
+
     public void getXdQx(List<Double> xdl, PointInfo piZt, List<PointData> fsList, List<PointData> glList) {
         String tbId = piZt.getTurbineId();
 
@@ -2364,7 +2679,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         //之前是否限电
         boolean iszqxd = false;
         for (int i = 0; i < zsglSnap.size(); i++) {
-            if (areBothRising(agcSnap.subList(Math.max(0, i - 9),i+1))) continue;
+            if (areBothRising(agcSnap.subList(Math.max(0, i - 9), i + 1))) continue;
             //是否限电
             boolean isxd = false;
             //自算理论功率
@@ -2421,7 +2736,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
      * @return true=两条曲线同时上升(允许2个误差点),false=不同时上升
      */
     public boolean areBothRising(List<PointData> agcSnap) {
-        if (agcSnap.size() <2) return false;
+        if (agcSnap.size() < 2) return false;
 
         int errorCount = 0; // 允许的误差点数
         int n = agcSnap.size();
@@ -4637,7 +4952,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         DateTime beginOfDay = DateUtil.beginOfDay(begin);
         int between0 = (int) DateUtil.between(beginOfDay, begin, DateUnit.SECOND);
         int between = (int) DateUtil.between(beginOfDay, end, DateUnit.SECOND);
-        if(between0==0) between0=60;
+        if (between0 == 0) between0 = 60;
 
         List<PointInfo> swdlEt0 = getEntity("Z-ZXYG-CX", "meter");
         List<PointInfo> swdlEt = getEntity("Z-ZXYG-CX", "meter");
@@ -4655,11 +4970,12 @@ public class JavaFunctionJobHandler extends IJobHandler {
         }
         stationInfoMinService.saveOrUpdateBatch(byDate);
     }
+
     public void calcStationSwdl(DateTime begin, DateTime end) {
         DateTime beginOfDay = DateUtil.beginOfDay(begin);
         int between0 = (int) DateUtil.between(beginOfDay, begin, DateUnit.SECOND);
         int between = (int) DateUtil.between(beginOfDay, end, DateUnit.SECOND);
-        if(between0==0) between0=60;
+        if (between0 == 0) between0 = 60;
 
         List<PointInfo> swdlEt0 = getEntity("Z-ZXYG-CX", "meter");
         List<PointInfo> swdlEtB = getEntity("Z-ZXYG-CX", "meter");
@@ -4672,7 +4988,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         for (StationInfoMin info : byDate) {
             double swdl = swdlEtE.get(0).getPointDatas().get(0).getValue() - swdlEt0.get(0).getPointDatas().get(0).getValue();
             double swdl0 = swdlEtB.get(0).getPointDatas().get(0).getValue() - swdlEt0.get(0).getPointDatas().get(0).getValue();
-            swdl = (swdl - swdl0)*swdlEt0.get(0).getCoef();
+            swdl = (swdl - swdl0) * swdlEt0.get(0).getCoef();
             info.setSwdl(swdl);
         }
         stationInfoMinService.saveOrUpdateBatch(byDate);
@@ -4745,7 +5061,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         //风速
         //List<PointData> entityFs2 = adapter.getHistoryRaw(goldenUri(), "区域集控.惠安风场.升压站.联合动力能管信息.全场平均风速", time0.getTime(), time.getTime());
         List<PointInfo> entityFs = getEntity("AI066", "turbine");
-        getSnapDataByEntity(entityFs, goldenUri(), time0, time,15);
+        getSnapDataByEntity(entityFs, goldenUri(), time0, time, 15);
         Map<String, List<PointInfo>> fssMap = entityFs.stream().collect(Collectors.groupingBy(PointInfo::getStationId));
 
         List<StationInfoDay> sids = getStationinfoByDate(time0, fsEt);
@@ -4907,7 +5223,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         List<PointData> pds = Optional.ofNullable(pi).map(PointInfo::getPointDatas).orElse(Collections.emptyList());
         pds = pi.getPointDatas().stream().filter(pd -> pd.getValue() != 0).collect(Collectors.toList());
         if (pds.size() < 2) return 0;
-        double dl = NumberUtil.round(Math.abs(pds.get(0).getValue() - pds.get(pds.size() - 1).getValue()),2).doubleValue() * pi.getCoef();
+        double dl = NumberUtil.round(Math.abs(pds.get(0).getValue() - pds.get(pds.size() - 1).getValue()), 2).doubleValue() * pi.getCoef();
         return dl;
     }
 
@@ -5086,34 +5402,28 @@ public class JavaFunctionJobHandler extends IJobHandler {
         //风速
         List<PointInfo> entityFs = getEntity("AI066", "turbine");
         getSnapDataByEntity(entityFs, begin, end, 15);
-        Map<String, List<PointData>> fsMap = entityFs.stream().collect(Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas));
+        Map<String, Map<String, List<PointData>>> fsMapMap = entityFs.stream().collect(Collectors.groupingBy(PointInfo::getStationId,
+                Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas)));
         //功率
         List<PointInfo> entityGl = getEntity("AI114", "turbine");
         getSnapDataByEntity(entityGl, begin, end, 15);
-        Map<String, List<PointData>> glMap = entityGl.stream().collect(Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas));
+        Map<String, Map<String, List<PointData>>> glMapMap = entityGl.stream().collect(Collectors.groupingBy(PointInfo::getStationId,
+                Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas)));
         //状态
         List<PointInfo> ztMapMap = calcTurbineZt(begin, end, entityFs, entityGl);
         Map<String, Map<String, PointInfo>> ztMapMapInfos = ztMapMap.stream().collect(
                 Collectors.groupingBy(PointInfo::getStationId, Collectors.toMap(PointInfo::getTurbineId, Function.identity())));
-        //发电量
-        List<PointInfo> fdlEntity = getEntity("AI121", "turbine");
-        getSnapDataByEntity(fdlEntity, begin, end, 15);
-        Map<String, PointInfo> fdlMap = fdlEntity.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
 
-        List<PointData> glpdss = entityGl.get(0).getPointDatas();
-        List<Long> tss = glpdss.stream().map(v -> v.getTs()).collect(Collectors.toList());
+        List<PointData> glpdss = entityFs.get(0).getPointDatas();
         List<Double> zeroList = IntStream.range(0, glpdss.size()).mapToObj(i -> 0.0).collect(Collectors.toList());
-        List<PointData> tbFsPdList = new ArrayList<>();
-        List<PowerLosses> turbineLosses = new ArrayList<>();
         Map<String, TurbineInfoDay> dayMap = getTurbineinfoMap(begin, entityFs);
         ztMapMapInfos.forEach((stId, ztMapInfo) -> ztMapInfo.forEach((wtId, ztInfo) -> {
             //0 待机,1 手动停机,2 正常发电,3 发电降出力,4 故障,5 故障受累,6 检修,7 检修受累,8 限电降出力,
             // 9 限电停机,10 电网受累,11 环境受累,12 通讯中断,13 设备离线
-            List<PointData> fsPds = fsMap.get(wtId);
             TurbineInfoDay infoDay = dayMap.get(wtId);
-            List<Double> turbineZeroList = IntStream.range(0, glpdss.size()).mapToObj(i -> 0.0).collect(Collectors.toList());
-            getXdQx(turbineZeroList, zeroList, ztInfo, fsPds, glMap.get(wtId));
-            Map<String, Double> loss = getTurbinePowerLoss2(isFubingMap.get(wtId), ztInfo, fsPds, glMap.get(wtId));
+            //限电曲线
+            getXdQx(zeroList, ztInfo, fsMapMap.get(stId).get(wtId), glMapMap.get(stId).get(wtId));
+            Map<String, Double> loss = getTurbinePowerLoss2(isFubingMap.get(wtId), ztInfo, fsMapMap.get(stId).get(wtId), glMapMap.get(stId).get(wtId));
             infoDay.setJhjxss(loss.get("jxss") * ssxs);
             infoDay.setFjhjxss(loss.get("gzss") * ssxs + loss.get("fdjcl") * ssxs + loss.get("sdtj") * ssxs);
             infoDay.setXdss(loss.get("xdjcl") * ssxs + loss.get("xdtj") * ssxs);
@@ -5122,40 +5432,15 @@ public class JavaFunctionJobHandler extends IJobHandler {
             infoDay.setGzss(loss.get("gzss") * ssxs);
             infoDay.setXnss(loss.get("xnss") * ssxs + loss.get("djss") * ssxs);
             infoDay.setLlfdl(infoDay.getRfdl() + infoDay.getJhjxss() + infoDay.getFjhjxss() + infoDay.getXdss() + infoDay.getSlss() + infoDay.getXnss());
-            //风机限电时段
-            List<Double> collect = turbineZeroList.stream().map(v -> v / 240).collect(Collectors.toList());
-            List<PowerLosses> tblss = calcLossPeriods(collect, tss);
-            PointInfo fdlPis = fdlMap.get(wtId);
-            List<PointData> fdlPds = fdlPis.getPointDatas();
-            for (PowerLosses pl : tblss) {
-                pl.setItem("turbine");
-                pl.setStationId(stId);
-                pl.setTurbineId(wtId);
-                List<PointData> tbXdPdsn = fdlPds.stream().filter(pd -> isTimeIn(pd.getTs(), pl)).collect(Collectors.toList());
-                List<PointData> tbFsPdsn = fsPds.stream().filter(pd -> isTimeIn(pd.getTs(), pl)).collect(Collectors.toList());
-                pl.setFdl(calcHaDl(tbXdPdsn, fdlPis.getCoef()));
-                double pjfs = tbFsPdsn.stream().mapToDouble(pd -> pd.getValue()).average().orElse(0d);
-                pl.setPjfs(pjfs);
-                tbFsPdList.addAll(tbFsPdsn);
-            }
-            turbineLosses.addAll(tblss);
         }));
-        //场站限电时段
         List<Double> collect = zeroList.stream().map(v -> v / 240).collect(Collectors.toList());
+        List<Long> tss = glpdss.stream().map(PointData::getTs).collect(Collectors.toList());
         List<PowerLosses> losses = calcLossPeriods(collect, tss);
-        for (PowerLosses loss : losses) {
-            loss.setItem("station");
-            double pjfs = tbFsPdList.stream().filter(pd -> isTimeIn(pd.getTs(), loss)).mapToDouble(pd -> pd.getValue()).average().orElse(0d);
-            loss.setPjfs(pjfs);
-            double fdl = turbineLosses.stream().filter(tl -> isTimeIn(tl, loss)).mapToDouble(PowerLosses::getFdl).sum();
-            loss.setFdl(fdl);
-        }
         QueryWrapper<PowerLosses> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("record_date", new Date(begin.getTime()));
-        //powerLossesService.remove(queryWrapper);
-        //powerLossesService.saveBatch(losses);
-        ////powerLossesService.saveBatch(turbineLosses);
-        //turbineInfoDayService.saveOrUpdateBatch(dayMap.values());
+        powerLossesService.remove(queryWrapper);
+        powerLossesService.saveBatch(losses);
+        turbineInfoDayService.saveOrUpdateBatch(dayMap.values());
     }
 
     public List<PointData> calcKygl(DateTime begin, DateTime end) {
@@ -5325,8 +5610,8 @@ public class JavaFunctionJobHandler extends IJobHandler {
             day.setLyxs(lyxs * xs);
             day.setKlyl(klyl * 100);
             day.setFnlyl(fnlyl * 100);
-            if(day.getGzcs()==0){
-                day.setXnss(day.getXnss()+day.getFjhjxss());
+            if (day.getGzcs() == 0) {
+                day.setXnss(day.getXnss() + day.getFjhjxss());
                 day.setFjhjxss(0d);
                 day.setGzss(0d);
             }
@@ -8480,7 +8765,11 @@ public class JavaFunctionJobHandler extends IJobHandler {
         lineCalcHz2(lidsBqCz, fillMapBq16, LineInfoDay::getStationId, lid -> Double.valueOf(lid.getRfdl()), eijMap, begin);
         List<PointData> sjfdlr = adapter.getHistoryRaw(goldenUri(), "区域集控.惠安风场.二期.全场日总发电量", end.getTime() - 3 * 60 * 1000, end.getTime() + 1);
         eijMap.get("区域集控.惠安风场.二期本期实际发电量").setStopCode(sjfdlr.stream().mapToDouble(PointData::getValue).max().orElse(0));
-        proEconEquipmentInfoJsService.saveOrUpdateBatch(eijMap.values());
+        //proEconEquipmentInfoJsService.saveOrUpdateBatch(eijMap.values());
+
+        List<StationInfoDay> byDate = getStationinfoByDate(begin.toJdkDate());
+        byDate.get(0).setRfdlFj((eijMap.get("区域集控.惠安风场.二期本期实际发电量").getStopCode() + eijMap.get("区域集控.惠安风场.一期本期实际发电量").getStopCode()) * 1000);
+        stationInfoDayService.saveOrUpdateBatch(byDate);
     }
 
     //计算惠安报表汇总实时
@@ -8805,9 +9094,37 @@ public class JavaFunctionJobHandler extends IJobHandler {
         eijMap.get("区域集控.惠安风场.二期月累实际发电量").setStopCode(sjfdly.stream().mapToDouble(PointData::getValue).max().orElse(0));
         List<PointData> sjfdln = adapter.getHistoryRaw(goldenUri(), "区域集控.惠安风场.二期.全场年总发电量", begin.getTime() - 3 * 60 * 1000, begin.getTime() + 1);
         eijMap.get("区域集控.惠安风场.二期年累实际发电量").setStopCode(sjfdln.stream().mapToDouble(PointData::getValue).max().orElse(0));
+
         proEconEquipmentInfoJsService.saveOrUpdateBatch(eijMap.values());
     }
 
+    public void calcStationNPjfs(DateTime date) {
+        //IService<ProEconEquipmentInfoJs> iService = serviceGroup.getService(ProEconEquipmentInfoJs.class);
+        //10号0点
+        date = DateUtil.beginOfDay(date);
+        //9号0点
+        DateTime thisDay = DateUtil.offsetDay(date, -1);
+        QueryWrapper<ProEconEquipmentInfoJs> thisWrapper = new QueryWrapper<>();
+        thisWrapper.eq("record_date", thisDay).likeLeft("meter_name", "平均风速");
+        List<ProEconEquipmentInfoJs> thisJs = proEconEquipmentInfoJsService.list(thisWrapper);
+        Map<String, ProEconEquipmentInfoJs> thisMap = thisJs.stream().collect(Collectors.toMap(ProEconEquipmentInfoJs::getMeterName, Function.identity(), (k1, k2) -> k1));
+        //8号0点
+        DateTime yesterday = DateUtil.offsetDay(thisDay, -1);
+        QueryWrapper<ProEconEquipmentInfoJs> yesterWrapper = new QueryWrapper<>();
+        yesterWrapper.eq("record_date", yesterday).likeLeft("meter_name", "平均风速");
+        List<ProEconEquipmentInfoJs> yesterJs = proEconEquipmentInfoJsService.list(yesterWrapper);
+        Map<String, ProEconEquipmentInfoJs> yesterMap = yesterJs.stream().collect(Collectors.toMap(ProEconEquipmentInfoJs::getMeterName, Function.identity(), (k1, k2) -> k1));
+
+        Map<String, PointData> yxts = adapter.getHistorySection(goldenUri(), "区域集控.惠安风场.统计计算.安全运行天数", thisDay.getTime());
+        double ts = yxts.values().iterator().next().getValue();
+        //年平均风速计算方式:比如今天10号,(8号年风速×截止到8号安全运行天数+9号日风速)÷截止到9号安全运行天数
+        double v1 = (yesterMap.get("区域集控.惠安风场.一期年累平均风速").getStopCode() * ts + thisMap.get("区域集控.惠安风场.一期本期平均风速").getStopCode()) / (ts + 1);
+        double v2 = (yesterMap.get("区域集控.惠安风场.二期年累平均风速").getStopCode() * ts + thisMap.get("区域集控.惠安风场.二期本期平均风速").getStopCode()) / (ts + 1);
+        thisMap.get("区域集控.惠安风场.一期年累平均风速").setStopCode(v1);
+        thisMap.get("区域集控.惠安风场.二期年累平均风速").setStopCode(v2);
+        proEconEquipmentInfoJsService.saveOrUpdateBatch(thisMap.values());
+    }
+
     public <T> void lineCalcHz(List<T> items, Map<String, ProBaseBackfill> fillMap, Function<T, String> type, Function<T, Double> algorithm, Map<String, ProEconEquipmentInfoJs> eijMap, DateTime yesterday) {
         for (T item : items) {
             String id = type.apply(item);
@@ -9191,76 +9508,6 @@ public class JavaFunctionJobHandler extends IJobHandler {
                 });
     }
 
-    public void haxdRecalc(Date date) {
-        DateTime end = DateUtil.beginOfDay(date);
-        DateTime begin = DateUtil.offsetDay(end, -1);
-        //AGC
-        List<PointInfo> entityAgc = getEntity("AGC002", "booster");
-        getSnapDataByEntity(entityAgc, begin, end, 15);
-        //出线
-        List<PointInfo> entityCx = getEntity("AGC020", "booster");
-        getSnapDataByEntity(entityCx, begin, end, 15);
-        //可用功率
-        //List<PointData> kyglpds1 = adapter.getHistorySnap(goldenUri(), "区域集控.惠安风场.AGCAVC.实时可调上限", begin.getTime(), end.getTime(), 15);
-        List<PointData> cdxdlPd = adapter.getHistoryRaw(goldenUri(), "区域集控.惠安风场.统计计算.日限电量", end.getTime() - 2 * 60 * 60 * 1000, end.getTime());
-        double cdxdl = cdxdlPd.stream().mapToDouble(PointData::getValue).max().orElse(0d) * 1000;
-        List<PointData> kyglpds1 = adapter.getHistorySnap(goldenUri(), "区域集控.惠安风场.升压站.中车风机设备信息.可用发电功率", begin.getTime(), end.getTime(), 15);
-        List<PointData> kyglpds2 = adapter.getHistorySnap(goldenUri(), "区域集控.惠安风场.升压站.联合动力能管信息.可用发电功率", begin.getTime(), end.getTime(), 15);
-        for (int i = 0; i < kyglpds1.size(); i++) {
-            PointData pd = kyglpds1.get(i);
-            pd.setDoubleValue(pd.getValue() + kyglpds2.get(i).getValue());
-        }
-        PointInfo cxPi = entityCx.get(0);
-        List<PointData> cxPds = cxPi.getPointDatas();
-        List<PointData> czxd = calcStationXd2(entityAgc.get(0), cxPds, kyglpds1, 0.01);
-        List<Double> xdl = new ArrayList<>();
-        //总损失电量
-        List<Double> zssdl = new ArrayList<>();
-        for (int i = 0; i < cxPds.size(); i++) {
-            double v = kyglpds1.get(i).getValue() * 1000 - cxPds.get(i).getValue() * cxPi.getCoef();
-            if (v < 0) v = 0;
-            if (czxd.get(i).isBooleanValue()) {
-                xdl.add(v);
-            } else {
-                xdl.add(0d);
-                zssdl.add(v);
-            }
-        }
-        double sum = xdl.stream().mapToDouble(Double::doubleValue).sum() / 2400;
-        //double xdv = sum / cdxdl;
-        //if (xdv > 0.98 && xdv < 1.02) {
-        //} else {
-        //    if (xdv > 0.57) {
-        //        sum = cdxdl * 0.9 + sum * 0.1;
-        //    } else {
-        //        sum = sum * 1.44;
-        //    }
-        //}
-        double sumZssdl = zssdl.stream().mapToDouble(Double::doubleValue).sum() / 2400;
-        //List<Long> tss = entityCx.get(0).getPointDatas().stream().map(v -> v.getTs()).collect(Collectors.toList());
-        //List<PowerLosses> losses = calcLossPeriods(xdl, tss);
-        //CsvWriter writer = CsvUtil.getWriter("D:/loss.csv", CharsetUtil.CHARSET_UTF_8);
-        //writer.writeBeans(losses);
-        //writer.flush();
-        List<TurbineInfoDay> byDate = getTurbineinfoByDate(begin);
-        double xdsum = byDate.stream().mapToDouble(TurbineInfoDay::getXdss).sum();
-        //xd + fjh + jh + xn
-        double zsssum = byDate.stream().mapToDouble(tid -> tid.getFjhjxss() + tid.getJhjxss() + tid.getXnss()).sum();
-        double xs = xdsum == 0d ? 0d : sum / xdsum;
-        double zssXs = zsssum == 0d ? 0d : sumZssdl / zsssum;
-        byDate.forEach(tid -> {
-            tid.setXdss((tid.getXdss() - tid.getDjss()) * xs);
-            tid.setLlfdl(tid.getRfdl() + tid.getXdss() + tid.getFjhjxss() + tid.getJhjxss() + tid.getXnss());
-            //
-            tid.setJhjxss(tid.getJhjxss() * zssXs);
-            tid.setFjhjxss(tid.getFjhjxss() * zssXs);
-            tid.setXnss(tid.getXnss() * zssXs);
-            tid.setDjss(tid.getDjss() * zssXs);
-            tid.setGzss(tid.getGzss() * zssXs);
-        });
-        //turbineInfoDayService.saveOrUpdateBatch(byDate);
-    }
-
     public double calculateIntegralDifference(List<PointData> curve1, List<PointData> curve2) {
         // 获取时间戳范围
         double xStart = curve1.get(0).getTs();

+ 58 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/influxdb/InfluxDB2Java.java

@@ -0,0 +1,58 @@
+//package com.ruoyi.web.influxdb;
+//
+//import com.influxdb.client.InfluxDBClient;
+//import com.influxdb.client.InfluxDBClientFactory;
+//import com.influxdb.client.QueryApi;
+//import com.influxdb.client.WriteApiBlocking;
+//import com.influxdb.client.domain.WritePrecision;
+//import com.influxdb.client.write.Point;
+//
+//public class InfluxDB2Java {
+//
+//    // 配置参数,请替换成你自己的
+//    private static final String url = "http://10.220.1.5:8086"; // 或 https://...
+//    private static final String token = "your-token-here"; // 你的 InfluxDB Token
+//    private static final String org = "your-org";
+//    private static final String bucket = "your-bucket";
+//
+//    public static void main(String[] args) {
+//
+//        // 1. 创建 InfluxDB 客户端
+//        InfluxDBClient client = InfluxDBClientFactory.create(url, token.toCharArray(), org, bucket);
+//
+//        try {
+//            // 2. 使用 WriteApiBlocking 写入数据(同步方式)
+//            WriteApiBlocking writeApi = client.getWriteApiBlocking();
+//
+//            // 构造一个 Point(相当于一条记录)
+//            Point point = Point.measurement("temperature")
+//                    .addTag("location", "room1")
+//                    .addField("value", 23.5)
+//                    .time(System.currentTimeMillis(), WritePrecision.MS);
+//
+//            // 写入数据
+//            writeApi.writePoint(point);
+//            System.out.println("数据写入成功");
+//
+//            // 3. 查询数据(使用 QueryApi)
+//            QueryApi queryApi = client.getQueryApi();
+//            String fluxQuery = "from(bucket: \"" + bucket + "\") " +
+//                    "|> range(start: -1h) " +
+//                    "|> filter(fn: (r) => r._measurement == \"temperature\")";
+//
+//            queryApi.query(fluxQuery, (c, record) -> {
+//                System.out.printf("时间: %s, 温度: %s%n",
+//                        record.getTime(),
+//                        record.getValueByKey("_value"));
+//            }, throwable -> {
+//                System.err.println("查询出错: " + throwable.getMessage());
+//            });
+//
+//        } finally {
+//            // 4. 关闭客户端
+//            if (client != null) {
+//                client.close();
+//            }
+//        }
+//    }
+//}

+ 43 - 89
ruoyi-admin/src/main/java/com/ruoyi/web/runner/ServiceGroup.java

@@ -1,14 +1,19 @@
 package com.ruoyi.web.runner;
 
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.ucp.entity.*;
 import com.ruoyi.ucp.service.*;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.PostConstruct;
 import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
 
 @Service
 public class ServiceGroup {
-    @Resource
-    private IPointInfoService pointInfoService;
+
+    private final Map<Class<?>, IService<?>> serviceMap = new HashMap<>();
     @Resource
     private IStationInfoHourService stationInfoHourService;
     @Resource
@@ -51,92 +56,41 @@ public class ServiceGroup {
     private IStationInfoMonthService stationInfoMonthService;
     @Resource
     private IPowerLossesService powerLossesService;
-
-    public IPointInfoService getPointInfoService() {
-        return pointInfoService;
-    }
-
-    public IStationInfoHourService getStationInfoHourService() {
-        return stationInfoHourService;
-    }
-
-    public IStationInfoDayService getStationInfoDayService() {
-        return stationInfoDayService;
-    }
-
-    public ILineInfoDayService getLineInfoDayService() {
-        return lineInfoDayService;
-    }
-
-    public IStateAiService getStateAiService() {
-        return stateAiService;
-    }
-
-    public IEquipmentModelService getEquipmentModelService() {
-        return equipmentModelService;
-    }
-
-    public ITurbineInfoDayService getTurbineInfoDayService() {
-        return turbineInfoDayService;
-    }
-
-    public IProEconReportIndicatorPoolService getReportIndicatorPoolService() {
-        return reportIndicatorPoolService;
-    }
-
-    public ITurbineInfoMinService getTurbineInfoMinService() {
-        return turbineInfoMinService;
-    }
-
-    public IStationInfoMinService getStationInfoMinService() {
-        return stationInfoMinService;
-    }
-
-    public IProBasicProjectPlanService getProBasicProjectPlanService() {
-        return proBasicProjectPlanService;
-    }
-
-    public IHistoryPredictService getHistoryPredictService() {
-        return historyPredictService;
-    }
-
-    public IPredictExaminService getPredictExaminService() {
-        return predictExaminService;
-    }
-
-    public IPredictExamin2Service getPredictExamin2Service() {
-        return predictExamin2Service;
-    }
-
-    public IStationInfoMin2Service getStationInfoMin2Service() {
-        return stationInfoMin2Service;
-    }
-
-    public IProjectInfoMin2Service getProjectInfoMin2Service() {
-        return projectInfoMin2Service;
-    }
-
-    public IRealtimePredictService getRealtimePredictService() {
-        return realtimePredictService;
-    }
-
-    public IMeterInfoDayService getMeterInfoDayService() {
-        return meterInfoDayService;
-    }
-
-    public IProEconEquipmentInfoJsService getProEconEquipmentInfoJsService() {
-        return proEconEquipmentInfoJsService;
-    }
-
-    public IProBaseBackfillService getProBaseBackfillService() {
-        return proBaseBackfillService;
-    }
-
-    public IStationInfoMonthService getStationInfoMonthService() {
-        return stationInfoMonthService;
-    }
-
-    public IPowerLossesService getPowerLossesService() {
-        return powerLossesService;
+    @Resource
+    private IPointInfoService pointService;
+
+    @PostConstruct
+    public void init() {
+        serviceMap.put(StationInfoMonth.class, stationInfoMonthService);
+        serviceMap.put(PowerLosses.class, powerLossesService);
+        serviceMap.put(ProBaseBackfill.class, proBaseBackfillService);
+        serviceMap.put(MeterInfoDay.class, meterInfoDayService);
+        serviceMap.put(ProEconEquipmentInfoJs.class, proEconEquipmentInfoJsService);
+        serviceMap.put(RealtimePredict.class, realtimePredictService);
+        serviceMap.put(ProjectInfoMin2.class, projectInfoMin2Service);
+        serviceMap.put(StationInfoMin2.class, stationInfoMin2Service);
+        serviceMap.put(PredictExamin2.class, predictExamin2Service);
+        serviceMap.put(PredictExamin.class, predictExaminService);
+        serviceMap.put(HistoryPredict.class, historyPredictService);
+        serviceMap.put(ProBasicProjectPlan.class, proBasicProjectPlanService);
+        serviceMap.put(StationInfoMin.class, stationInfoMinService);
+        serviceMap.put(TurbineInfoMin.class, turbineInfoMinService);
+        serviceMap.put(ProEconReportIndicatorPool.class, reportIndicatorPoolService);
+        serviceMap.put(TurbineInfoDay.class, turbineInfoDayService);
+        serviceMap.put(EquipmentModel.class, equipmentModelService);
+        serviceMap.put(StateAi.class, stateAiService);
+        serviceMap.put(LineInfoDay.class, lineInfoDayService);
+        serviceMap.put(StationInfoDay.class, stationInfoDayService);
+        serviceMap.put(StationInfoHour.class, stationInfoHourService);
+        serviceMap.put(PointInfo.class, pointService);
+    }
+
+    @SuppressWarnings("unchecked")
+    public <T> IService<T> getService(Class<T> clazz) {
+        IService<?> service = serviceMap.get(clazz);
+        if (service == null) {
+            throw new IllegalArgumentException("No service found for " + clazz);
+        }
+        return (IService<T>) service; // 安全转换,因为 Map 里存储的就是对应的类型
     }
 }

+ 39 - 21
ruoyi-admin/src/test/java/com/ruoyi/NewTests.java

@@ -226,13 +226,16 @@ public class NewTests {
     @Test
     public void test3() {
         // 创建日期范围生成器
-        DateTime start = DateUtil.parse("2024-01-01");
-        DateTime end = DateUtil.parse("2024-10-01");
-        DateRange range = DateUtil.range(start, end, DateField.MONTH);
-        for (DateTime date : range) {
-            System.out.println(DateUtil.date() + ":" + date);
+        DateTime start = DateUtil.parse("2025-09-08");
+        DateTime stop = DateUtil.parse("2025-09-09");
+        //DateRange range = DateUtil.range(start, end, DateField.MONTH);
+        DateRange range = DateUtil.range(start, stop, DateField.HOUR_OF_DAY);
+        for (DateTime begin : range) {
+            System.out.println(DateUtil.date() + ":" + begin);
             //            task.calcStationRjhfdl(date);
-
+            //DateTime begin = DateUtil.beginOfHour(DateUtil.date());
+            DateTime end = DateUtil.offsetHour(begin, 1);
+            task.calcTurbine5sMin(begin,end,0.1);
         }
     }
 
@@ -292,8 +295,8 @@ public class NewTests {
 
     @Test
     public void test6() {
-        DateTime begin = DateUtil.parse("2025-08-04 11:00:00");
-        DateTime end = DateUtil.parse("2025-08-04 14:30:00");
+        DateTime begin = DateUtil.parse("2025-09-08 00:00:00");
+        DateTime end = DateUtil.parse("2025-09-09 00:00:00");
         DateTime minEnd = begin;
         while (minEnd.isBefore(end)) {
             minEnd = DateUtil.offsetMinute(begin, 15);
@@ -303,7 +306,8 @@ public class NewTests {
             //task.calcTurbinePjfsPjglKyglLlglMin(begin);
             //task.calcStationSjglAgcPjfsHjwdDlMin(begin);
             //task.calcStationYcgl_ha(begin,minEnd);
-            task.calcStationSwdl(begin, minEnd);
+            //task.calcStationSwdl(begin, minEnd);
+            task.calcStation5s(begin, minEnd);
 
             System.out.println(begin + "," + minEnd);
             begin = minEnd;
@@ -364,7 +368,6 @@ public class NewTests {
 
     @Test
     public void test9() {
-        //task.calcHaBbHzSs();
         DateTime date = DateUtil.date();
         //Date date = DateUtil.parse("2025-01-09");
         //task.calcLineRfdlSameDay_ha();
@@ -381,8 +384,8 @@ public class NewTests {
 
     @Test
     public void test10() {
-        DateTime start = DateUtil.parse("2025-08-01");
-        DateTime end = DateUtil.parse("2025-08-08");
+        DateTime start = DateUtil.parse("2025-09-01");
+        DateTime end = DateUtil.parse("2025-09-01");
         DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR);
         for (DateTime date : range) {
             System.out.println(DateUtil.date() + ":" + date);
@@ -391,7 +394,7 @@ public class NewTests {
             //task.calcLineRfdl_ha(date);
             //
             ////上网购网厂用电量
-            task.calcStationSwGwCyRdl_ha(date);
+            //task.calcStationSwGwCyRdl_ha(date);
             ////风机日环境温度
             //task.ambientTemperature(date);
             ////计算日发电量--风机汇总方式
@@ -418,14 +421,14 @@ public class NewTests {
             //task.calcMeterDlHdl(date);
             //DateTime t2 = DateUtil.offsetMinute(date,-1);
             //DateTime t1 = DateUtil.beginOfDay(t2);
-            DateTime b1 = DateUtil.offsetDay(date, -1);
-            DateTime b2 = DateUtil.endOfDay(b1);
+            //DateTime b1 = DateUtil.offsetDay(date, -1);
+            DateTime b2 = DateUtil.endOfDay(date);
             ////计算综合厂用电量
             //task.calcStationZhcyRfDl_ha(b1, b2);
             //task.calcTurbineRFDL(t1, t2);
             //task.calcStationRfdlFj(b1);
-            task.calcHaBbHz(date);
-            task.calcHaBbHzSs(b1, b2);
+            //task.calcHaBbHz(date);
+            task.calcHaBbHzSs(date, b2);
             //task.calcRYNxdl(b, date);
 
             //task.calcTurbineStateMin(date);
@@ -461,7 +464,7 @@ public class NewTests {
         //DateTime begin = DateUtil.beginOfDay(end);
         //task.calcTurbineRFDL(begin, end);
         //task.calcTurbineStateMin(begin, end);
-        //task.calcTurbine5s(begin, end, 0.1);
+        task.calcTurbine5s(begin, end, 0.1);
         //task.calcTurbineLyxs(begin);
         //task.calcStationCftfsfxQfxdl(begin, end);
         //task.calcTurbineJfplFxYxfssBll(begin, end);
@@ -573,13 +576,14 @@ public class NewTests {
 
     @Test
     public void test18() {
-        DateTime parse = DateUtil.parse("2025-07-25");
+        DateTime parse = DateUtil.parse("2025-09-10");
         //task.abc(parse);
-        task.calcStationKydlzql(parse);
+        //task.calcStationKydlzql(parse);
         //task.calcCzRxd2(DateUtil.beginOfDay(parse), DateUtil.endOfDay(parse));
-        task.haxdRecalc(parse);
+        //task.haxdRecalc(parse);
         //task.calcHaBbHz(parse);
         //task.calcStationKydlzql(parse);
+        task.calcStationNPjfs(parse);
     }
 
     @Test
@@ -595,4 +599,18 @@ public class NewTests {
         //task.calcStationYcgl_ha(begin,date);
         task.calcStationSwdl(begin, end);
     }
+
+    @Test
+    public void test21() {
+        DateTime date = DateUtil.date();
+        DateTime end = DateUtil.beginOfMinute(date);
+        int i = end.minute() / 15 * 15;
+        end.setMinutes(i);
+        DateTime begin = DateUtil.offsetMinute(end, -15);
+
+        //task.calcTurbinePjfsPjglKyglLlglMin(date);
+        //task.calcStationSjglAgcPjfsHjwdDlMin(date);
+        //task.calcStationYcgl_ha(begin,date);
+        task.calcStationSwdl(begin, end);
+    }
 }

+ 5 - 0
universal-computing-platform/pom.xml

@@ -91,6 +91,11 @@
             <artifactId>taos-jdbcdriver</artifactId>
             <version>2.0.39</version>
         </dependency>
+        <!--<dependency>
+            <groupId>com.influxdb</groupId>
+            <artifactId>influxdb-client-java</artifactId>
+            <version>7.3.0</version>
+        </dependency>-->
         <!--Redis依赖-->
         <dependency>
             <groupId>org.springframework.boot</groupId>

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

@@ -35,13 +35,13 @@ public class TurbineInfoDay implements Serializable {
     private Double xdss;
     private Double slss;
     private Double xnss;
+    private Double djss;
+    private Double gzss;
     private Double llfdl;
     private Double pjfs;
     private Double edfs;
     private Double xfqrfs;
     private Double hjwd;
-    private Double djss;
-    private Double gzss;
     private Double djMin;
     private Double tjMin;
     private Double yxMin;

+ 9 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/TurbineInfoMin.java

@@ -42,4 +42,13 @@ public class TurbineInfoMin implements Serializable {
     private Double llgl;
 
     private Double kygl;
+
+    private Double jhjxss;
+    private Double fjhjxss;
+    private Double xdss;
+    private Double slss;
+    private Double xnss;
+    private Double djss;
+    private Double gzss;
+    private Double llfdl;
 }