瀏覽代碼

Merge remote-tracking branch 'origin/master'

malijun 1 年之前
父節點
當前提交
5397c9b448
共有 30 個文件被更改,包括 1157 次插入193 次删除
  1. 77 0
      common/data/src/main/java/com/gyee/gaia/common/data/power/Powermodel.java
  2. 10 0
      common/data/src/main/java/com/gyee/gaia/common/data/windturbine/Line.java
  3. 10 0
      common/data/src/main/java/com/gyee/gaia/common/data/windturbine/Project.java
  4. 80 0
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/controller/BenchmarkingController.java
  5. 91 11
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/controller/EquipPowerGenDayController.java
  6. 150 0
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/controller/UserMarkController.java
  7. 9 0
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/entity/EquipPowerGenDay.java
  8. 103 0
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/entity/LossCapacityUserMark.java
  9. 62 0
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/entity/R.java
  10. 12 0
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/entity/ResultCode.java
  11. 35 0
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/entity/UserMark.java
  12. 41 4
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/init/CacheContext.java
  13. 3 0
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/iservice/IEquipPowerGenDayService.java
  14. 16 0
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/iservice/ILossCapacityUserMarkService.java
  15. 83 31
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/job/CalcEquipPowerGenDay.java
  16. 18 0
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/mapper/LossCapacityUserMarkMapper.java
  17. 71 0
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/serviceimpl/EquipPowerGenDayServiceImpl.java
  18. 20 0
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/serviceimpl/LossCapacityUserMarkServiceImpl.java
  19. 2 1
      electricity/wind/src/main/resources/bootstrap.yaml
  20. 0 40
      electricity/wind/src/test/java/com/gyee/gaia/MyAppTests.java
  21. 35 0
      electricity/wind/src/test/java/com/gyee/gaia/WindPowergenAppTests.java
  22. 15 0
      realtime/wind/src/main/java/com/gyee/gaia/realtime/wind/init/CacheContext.java
  23. 8 1
      realtime/wind/src/main/java/com/gyee/gaia/realtime/wind/job/CauseJobHandler.java
  24. 6 1
      realtime/wind/src/main/java/com/gyee/gaia/realtime/wind/job/DataFillJobHandler.java
  25. 8 0
      realtime/wind/src/test/java/com/gyee/gaia/MyAppTests.java
  26. 136 103
      state/cause/src/main/java/com/gyee/gaia/cause/service/CalculateService.java
  27. 3 1
      state/cause/src/test/java/com/gyee/gaia/MyTest.java
  28. 18 0
      timeseries/dao-interface/src/main/java/com/gyee/gaia/dao/power/PowermodelMapper.java
  29. 16 0
      timeseries/dao-sql/src/main/java/com/gyee/gaia/dao/sql/power/IPowermodelService.java
  30. 19 0
      timeseries/dao-sql/src/main/java/com/gyee/gaia/dao/sql/power/PowermodelServiceImpl.java

+ 77 - 0
common/data/src/main/java/com/gyee/gaia/common/data/power/Powermodel.java

@@ -0,0 +1,77 @@
+package com.gyee.gaia.common.data.power;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author gfhd
+ * @since 2023-06-08
+ */
+public class Powermodel implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+
+    private String windturbineid;
+
+    private Double speed;
+
+    private Double power;
+
+    private String model;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getWindturbineid() {
+        return windturbineid;
+    }
+
+    public void setWindturbineid(String windturbineid) {
+        this.windturbineid = windturbineid;
+    }
+
+    public Double getSpeed() {
+        return speed;
+    }
+
+    public void setSpeed(Double speed) {
+        this.speed = speed;
+    }
+
+    public Double getPower() {
+        return power;
+    }
+
+    public void setPower(Double power) {
+        this.power = power;
+    }
+
+    public String getModel() {
+        return model;
+    }
+
+    public void setModel(String model) {
+        this.model = model;
+    }
+
+    @Override
+    public String toString() {
+        return "Powermodel{" +
+            "id = " + id +
+            ", windturbineid = " + windturbineid +
+            ", speed = " + speed +
+            ", power = " + power +
+            ", model = " + model +
+        "}";
+    }
+}

+ 10 - 0
common/data/src/main/java/com/gyee/gaia/common/data/windturbine/Line.java

@@ -88,6 +88,8 @@ public class Line implements Serializable {
      */
     private String spare4;
 
+    private String code;
+
     public String getId() {
         return id;
     }
@@ -200,6 +202,14 @@ public class Line implements Serializable {
         this.spare4 = spare4;
     }
 
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
     @Override
     public String toString() {
         return "Line{" +

+ 10 - 0
common/data/src/main/java/com/gyee/gaia/common/data/windturbine/Project.java

@@ -119,6 +119,8 @@ public class Project implements Serializable {
      */
     private String spare4;
 
+    private String code;
+
     public String getId() {
         return id;
     }
@@ -279,6 +281,14 @@ public class Project implements Serializable {
         this.spare4 = spare4;
     }
 
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
     @Override
     public String toString() {
         return "Project{" +

+ 80 - 0
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/controller/BenchmarkingController.java

@@ -0,0 +1,80 @@
+package com.gyee.gaia.electricity.wind.controller;
+
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.gaia.electricity.wind.entity.EquipPowerGenDay;
+import com.gyee.gaia.electricity.wind.entity.R;
+import com.gyee.gaia.electricity.wind.init.CacheContext;
+import com.gyee.gaia.electricity.wind.iservice.IEquipPowerGenDayService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@RestController
+@RequestMapping("/benchmarking")
+public class BenchmarkingController {
+    @Autowired
+    private IEquipPowerGenDayService equipPowerGenDayService;
+
+    /**
+     * 风机绩效榜
+     *
+     * @param wpids
+     * @param projectids
+     * @param lineids
+     * @param beginDate
+     * @param endDate
+     * @param type
+     * @return
+     */
+    @GetMapping("/fjjxb")
+    public R fjjxb(@RequestParam(value = "wpids", required = true) String wpids,
+                   @RequestParam(value = "projectids", required = true) String projectids,
+                   @RequestParam(value = "lineids", required = true) String lineids,
+                   @RequestParam(value = "beginDate", required = true) String beginDate,
+                   @RequestParam(value = "endDate", required = true) String endDate,
+                   @RequestParam(value = "type", required = true) String type,
+                   @RequestParam(value = "target", required = true) String target,
+                   @RequestParam(value = "sort", required = true) String sort
+    ) {
+        List<EquipPowerGenDay> fjjxb = equipPowerGenDayService.fjjxb(wpids, projectids, lineids, beginDate, endDate, type, target, sort);
+        if (fjjxb.size() > 0){
+            return R.ok(fjjxb.size()).data(fjjxb);
+        }else {
+            return R.error().message("获取失败");
+        }
+    }
+    /**
+     * 风机绩效榜明细
+     * @param wpids
+     * @param projectids
+     * @param lineids
+     * @param beginDate
+     * @param endDate
+     * @param type
+     * @return
+     */
+    @GetMapping("/fjjxbmx")
+    public R fjjxbmx(@RequestParam(value = "wpids",required = true) String wpids,
+                     @RequestParam(value = "projectids",required = true) String projectids,
+                     @RequestParam(value = "lineids",required = true) String lineids,
+                     @RequestParam(value = "beginDate",required = true) String beginDate,
+                     @RequestParam(value = "endDate",required = true) String endDate,
+                     @RequestParam(value = "type",required = true) String type,
+                     @RequestParam(value = "target",required = true) String target,
+                     @RequestParam(value = "sort",required = true) String sort
+    ){
+        List<EquipPowerGenDay> fjjxb = equipPowerGenDayService.fjjxb(wpids,projectids,lineids,beginDate,endDate,type,target,sort);
+
+        if (fjjxb.size() > 0){
+            return R.ok(fjjxb.size()).data(fjjxb);
+        }else {
+            return R.error().message("获取失败");
+        }
+    }
+}

+ 91 - 11
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/controller/EquipPowerGenDayController.java

@@ -9,12 +9,15 @@ import com.gyee.gaia.common.data.windturbine.Project;
 import com.gyee.gaia.electricity.wind.entity.EquipPowerGenDay;
 import com.gyee.gaia.electricity.wind.init.CacheContext;
 import com.gyee.gaia.electricity.wind.iservice.IEquipPowerGenDayService;
+import org.jetbrains.annotations.NotNull;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -35,10 +38,10 @@ public class EquipPowerGenDayController {
                                  @RequestParam(value = "startDate", required = false) String startDate,
                                  @RequestParam(value = "endDate", required = false) String endDate) {
         QueryWrapper<EquipPowerGenDay> epgdWrapper = new QueryWrapper<>();
-        epgdWrapper.select("facility_id", "round(sum(generating_capacity)/1000,2) generating_capacity", "round(sum(theory_generation)/1000,2) theory_generation"
-                , "round(sum(loss_power)/1000,2) loss_power", "round(sum(fault_loss_power)/1000,2) fault_loss_power"
-                , "round(sum(maintain_loss_power)/1000,2) maintain_loss_power", "round(sum(implicate_loss_power)/1000,2) implicate_loss_power"
-                , "round(sum(limit_loss_power)/1000,2) limit_loss_power", "round(sum(performance_loss_power)/1000,2) performance_loss_power"
+        epgdWrapper.select("facility_id", "round(sum(generating_capacity)/10000,2) generating_capacity", "round(sum(theory_generation)/10000,2) theory_generation"
+                , "round(sum(loss_power)/10000,2) loss_power", "round(sum(fault_loss_power)/10000,2) fault_loss_power"
+                , "round(sum(maintain_loss_power)/10000,2) maintain_loss_power", "round(sum(implicate_loss_power)/10000,2) implicate_loss_power"
+                , "round(sum(limit_loss_power)/10000,2) limit_loss_power", "round(sum(performance_loss_power)/10000,2) performance_loss_power"
                 , "round(avg(mean_wind_speed),2) mean_wind_speed");
         if (StrUtil.isNotBlank(lines)) {
             epgdWrapper.eq("category", "line").in("facility_id", lines.split(","));
@@ -53,7 +56,14 @@ public class EquipPowerGenDayController {
                 .groupBy("facility_id");
 
         List<EquipPowerGenDay> list = equipPowerGenDayService.list(epgdWrapper);
-        list = list.stream().peek(d -> d.setUniformCode(CacheContext.splssMap.get(d.getFacilityId()))).collect(Collectors.toList());
+
+        EquipPowerGenDay powerGenDay = new EquipPowerGenDay();
+        if (list.size() > 0){
+            powerGenDay.setUniformCode("合计");
+            CacheContext.summation(powerGenDay, list);
+            list = list.stream().peek(d -> d.setUniformCode(CacheContext.splssMap.get(d.getFacilityId()))).sorted(Comparator.comparing(EquipPowerGenDay::getFacilityId)).collect(Collectors.toList());
+            list.add(powerGenDay);
+        }
 
         JSONObject json = new JSONObject();
         json.put("code", 200);
@@ -69,7 +79,7 @@ public class EquipPowerGenDayController {
         JSONObject json = new JSONObject();
         json.put("code", 200);
         json.put("msg", "成功!");
-        json.put("data", CacheContext.stationList.stream().filter(s->s.getId().contains("_FDC_")).collect(Collectors.toList()));
+        json.put("data", CacheContext.stationList.stream().filter(s -> s.getId().contains("_FDC_")).collect(Collectors.toList()));
 
         return json;
     }
@@ -105,16 +115,86 @@ public class EquipPowerGenDayController {
             List<Line> list = new ArrayList<>();
             for (String s : split) {
                 list.addAll(CacheContext.projectLinesMap.get(s));
-            }json.put("data", list);
+            }
+            json.put("data", list);
         }
 
         return json;
     }
 
-    private boolean hasStr(String[] split, String key) {
-        for (String s : split) {
-            if (Objects.equals(s, key)) return true;
+    private List<EquipPowerGenDay> oldlist;
+    private List<EquipPowerGenDay> oldlist2;
+
+    @GetMapping("/lost")
+    private JSONObject getLost() {
+
+        JSONObject json = new JSONObject();
+        json.put("code", 200);
+        json.put("msg", "成功!");
+
+        QueryWrapper<EquipPowerGenDay> epgdWrapper = new QueryWrapper<>();
+        epgdWrapper.eq("date", DateUtil.date().toLocalDateTime().toLocalDate());
+
+        List<EquipPowerGenDay> list = equipPowerGenDayService.list(epgdWrapper.clone().eq("category", "station"));
+        List<EquipPowerGenDay> list2 = equipPowerGenDayService.list(epgdWrapper.clone().eq("category", "windpower"));
+
+        if (list.isEmpty()) {
+            list = oldlist;
+        } else {
+            oldlist = list;
+        }
+
+        if (list2.isEmpty()) {
+            list2 = oldlist2;
+        } else {
+            oldlist2 = list2;
+        }
+        if (list.isEmpty() || list2.isEmpty()) return json;
+
+        BigDecimal fdzqf = BigDecimal.ZERO;
+        BigDecimal mhsqf = BigDecimal.ZERO;
+        BigDecimal nssqf = BigDecimal.ZERO;
+        BigDecimal qsqf = BigDecimal.ZERO;
+        BigDecimal sbqqf = BigDecimal.ZERO;
+        BigDecimal xsqf = BigDecimal.ZERO;
+
+        fdzqf = getDivide(list2.get(0));
+
+        for (EquipPowerGenDay day : list) {
+            switch (day.getFacilityId()) {
+                case "NX_GDDL_MHS_FDC_STA":
+                    mhsqf = getDivide(day);
+                    break;
+                case "NX_GDDL_NSS_FDC_STA":
+                    nssqf = getDivide(day);
+                    break;
+                case "NX_GDDL_QS_FDC_STA":
+                    qsqf = getDivide(day);
+                    break;
+                case "NX_GDDL_SBQ_FDC_STA":
+                    sbqqf = getDivide(day);
+                    break;
+                case "NX_GDDL_XS_FDC_STA":
+                    xsqf = getDivide(day);
+                    break;
+            }
         }
-        return false;
+        Map<String, BigDecimal> sbdm = new HashMap<>();
+
+        sbdm.put("fdzqf", fdzqf);
+        sbdm.put("mhsqf", mhsqf);
+        sbdm.put("nssqf", nssqf);
+        sbdm.put("qsqf", qsqf);
+        sbdm.put("sbqqf", sbqqf);
+        sbdm.put("xsqf", xsqf);
+
+        json.put("data", sbdm);
+
+        return json;
+    }
+
+    @NotNull
+    private BigDecimal getDivide(EquipPowerGenDay day) {
+        return day.getLossPower().divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_EVEN);
     }
 }

+ 150 - 0
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/controller/UserMarkController.java

@@ -0,0 +1,150 @@
+package com.gyee.gaia.electricity.wind.controller;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.gaia.common.data.windturbine.Equipment;
+import com.gyee.gaia.electricity.wind.entity.LossCapacityUserMark;
+import com.gyee.gaia.electricity.wind.entity.R;
+import com.gyee.gaia.electricity.wind.entity.StateCause;
+import com.gyee.gaia.electricity.wind.entity.UserMark;
+import com.gyee.gaia.electricity.wind.init.CacheContext;
+import com.gyee.gaia.electricity.wind.iservice.ILossCapacityUserMarkService;
+import com.gyee.gaia.electricity.wind.iservice.IStateCauseService;
+import com.gyee.gaia.electricity.wind.job.CalcEquipPowerGenDay;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 用户标记故障、计划检修、受累、限电时间
+ *
+ * @author gfhd
+ * @date 2023-05-30
+ */
+@RestController
+@RequestMapping("/mark")
+public class UserMarkController {
+    @Resource
+    private ILossCapacityUserMarkService lossCapacityUserMarkService;
+    @Resource
+    private IStateCauseService stateCauseService;
+    @Resource
+    private CalcEquipPowerGenDay calcEquipPowerGenDay;
+
+    @PostMapping("/info")
+    private R setInfo(@RequestBody UserMark userMark) {
+        if (StrUtil.isBlank(userMark.getStation())) return R.error().message("场站不能为空!");
+
+        DateTime startTime = DateUtil.parse(userMark.getStartTime());
+        DateTime endTime = DateUtil.parse(userMark.getEndTime());
+        if (!DateUtil.isSameDay(startTime, endTime)) return R.error().message("跨天请分2次提交!");
+
+        QueryWrapper<StateCause> scWrapper = new QueryWrapper<>();
+        scWrapper.select("tbname", "start_time", "end_time", "event", "advance_state", "after_state", "time", "station_id", "equipment_id")
+                .ge("start_time", startTime.getTime())
+                .le("end_time", endTime.getTime());
+
+        String equipment = userMark.getEquipment();
+        List<LossCapacityUserMark> lcumList = new ArrayList<>();
+        if (StrUtil.isNotBlank(equipment)) {
+            String[] split = equipment.split(",");
+            scWrapper.in("equipment_id", split);
+            for (String s : split) {
+                LossCapacityUserMark lcum = new LossCapacityUserMark();
+                BeanUtil.copyProperties(userMark, lcum);
+                lcum.setEquipment(s);
+                lcum.setId(userMark.getStation() + "-" + s + "-" + userMark.getStartTime());
+                lcumList.add(lcum);
+            }
+        } else {
+            scWrapper.eq("station_id", userMark.getStation());
+            LossCapacityUserMark lcum = new LossCapacityUserMark();
+            BeanUtil.copyProperties(userMark, lcum);
+            lcum.setId(userMark.getStation() + "-" + userMark.getStartTime());
+            lcumList.add(lcum);
+        }
+        boolean b = lossCapacityUserMarkService.saveOrUpdateBatch(lcumList);
+
+        //插入五损时间计算表用户标记
+        List<StateCause> scList = stateCauseService.list(scWrapper);
+        scList = scList.stream().peek(sc -> sc.setUserFlag(userMark.getEvent())).collect(Collectors.toList());
+        //更新user_flag
+        stateCauseService.saveBatch(scList);
+
+        calcEquipPowerGenDay.recalculationGeneratingCapacity(startTime);
+
+        if (b) {
+            return R.ok();
+        } else {
+            return R.error();
+        }
+    }
+
+    @GetMapping("/info")
+    private R getInfo(@RequestParam(value = "station") String station,
+                      @RequestParam(value = "windturbines", required = false) String windturbines,
+                      @RequestParam(value = "startDate") String startDate,
+                      @RequestParam(value = "endDate") String endDate) {
+        QueryWrapper<LossCapacityUserMark> lcumWrapper = new QueryWrapper<>();
+        lcumWrapper.eq(StrUtil.isNotBlank(station), "station", station);
+        if (StrUtil.isNotBlank(windturbines)) {
+            String[] split = windturbines.split(",");
+            lcumWrapper.in("equipment", split);
+        }
+        lcumWrapper.ge("start_time", DateUtil.parse(startDate))
+                .le("end_time", DateUtil.parse(endDate));
+        List<LossCapacityUserMark> list = lossCapacityUserMarkService.list(lcumWrapper);
+        list = list.stream().peek(um->um.setStation(CacheContext.stationMap.get(um.getStation()).getName())).collect(Collectors.toList());
+        return R.ok().data(list);
+    }
+
+    @GetMapping("/equipmentList")
+    private R equipmentList(@RequestParam(value = "stationId", required = false) String stationId) {
+
+        List<Equipment> equipments;
+        if (StrUtil.isBlank(stationId)) {
+            equipments = new ArrayList<>();
+        } else {
+            equipments = CacheContext.stationEquipmentsMap.get(stationId);
+        }
+        return R.ok().data(equipments);
+    }
+
+    @DeleteMapping("/{id}")
+    private R deleteInfo(@PathVariable String id) {
+        QueryWrapper<LossCapacityUserMark> lcumWrapper = new QueryWrapper<>();
+        lcumWrapper.eq("id", id);
+        boolean b = lossCapacityUserMarkService.removeById(id);
+
+        LossCapacityUserMark byId = lossCapacityUserMarkService.getById(id);
+        String equipment = byId.getEquipment();
+        //同时删除五损时间用户标记
+        QueryWrapper<StateCause> scWrapper = new QueryWrapper<>();
+        scWrapper.select("tbname", "start_time", "end_time", "event", "advance_state", "after_state", "time", "station_id", "equipment_id")
+                .ge("start_time", byId.getStartTime().getTime())
+                .le("end_time", byId.getEndTime().getTime());
+        if (StrUtil.isNotBlank(equipment)) {
+            String[] split = equipment.split(",");
+            scWrapper.in("equipment_id", split);
+        } else {
+            scWrapper.eq("station_id", byId.getStation());
+        }
+        List<StateCause> scList = stateCauseService.list(scWrapper);
+        scList = scList.stream().peek(sc -> sc.setUserFlag("")).collect(Collectors.toList());
+        //更新user_flag
+        stateCauseService.saveBatch(scList);
+
+        calcEquipPowerGenDay.recalculationGeneratingCapacity(DateTime.of(byId.getStartTime()));
+        if (b) {
+            return R.ok();
+        } else {
+            return R.error();
+        }
+    }
+}

+ 9 - 0
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/entity/EquipPowerGenDay.java

@@ -147,6 +147,7 @@ public class EquipPowerGenDay implements Serializable {
     private BigDecimal meanWindSpeed;
 
     public BigDecimal getMeanWindSpeed() {
+        if(meanWindSpeed==null) meanWindSpeed = BigDecimal.ZERO;
         return meanWindSpeed;
     }
 
@@ -203,6 +204,7 @@ public class EquipPowerGenDay implements Serializable {
     }
 
     public BigDecimal getGeneratingCapacity() {
+        if(generatingCapacity==null) generatingCapacity = BigDecimal.ZERO;
         return generatingCapacity;
     }
 
@@ -211,6 +213,7 @@ public class EquipPowerGenDay implements Serializable {
     }
 
     public BigDecimal getTheoryGeneration() {
+        if(theoryGeneration==null) theoryGeneration = BigDecimal.ZERO;
         return theoryGeneration;
     }
 
@@ -219,6 +222,7 @@ public class EquipPowerGenDay implements Serializable {
     }
 
     public BigDecimal getLossPower() {
+        if(lossPower==null) lossPower = BigDecimal.ZERO;
         return lossPower;
     }
 
@@ -227,6 +231,7 @@ public class EquipPowerGenDay implements Serializable {
     }
 
     public BigDecimal getFaultLossPower() {
+        if(faultLossPower==null) faultLossPower = BigDecimal.ZERO;
         return faultLossPower;
     }
 
@@ -235,6 +240,7 @@ public class EquipPowerGenDay implements Serializable {
     }
 
     public BigDecimal getMaintainLossPower() {
+        if(maintainLossPower==null) maintainLossPower = BigDecimal.ZERO;
         return maintainLossPower;
     }
 
@@ -243,6 +249,7 @@ public class EquipPowerGenDay implements Serializable {
     }
 
     public BigDecimal getImplicateLossPower() {
+        if(implicateLossPower==null) implicateLossPower = BigDecimal.ZERO;
         return implicateLossPower;
     }
 
@@ -251,6 +258,7 @@ public class EquipPowerGenDay implements Serializable {
     }
 
     public BigDecimal getLimitLossPower() {
+        if(limitLossPower==null) limitLossPower = BigDecimal.ZERO;
         return limitLossPower;
     }
 
@@ -259,6 +267,7 @@ public class EquipPowerGenDay implements Serializable {
     }
 
     public BigDecimal getPerformanceLossPower() {
+        if(performanceLossPower==null) performanceLossPower = BigDecimal.ZERO;
         return performanceLossPower;
     }
 

+ 103 - 0
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/entity/LossCapacityUserMark.java

@@ -0,0 +1,103 @@
+package com.gyee.gaia.electricity.wind.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author gfhd
+ * @since 2023-05-31
+ */
+@TableName("loss_capacity_user_mark")
+public class LossCapacityUserMark implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+
+    private String station;
+
+    private String equipment;
+
+    private Date startTime;
+
+    private Date endTime;
+
+    private String event;
+
+    private String eventDescription;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getStation() {
+        return station;
+    }
+
+    public void setStation(String station) {
+        this.station = station;
+    }
+
+    public String getEquipment() {
+        return equipment;
+    }
+
+    public void setEquipment(String equipment) {
+        this.equipment = equipment;
+    }
+
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Date startTime) {
+        this.startTime = startTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+    public String getEvent() {
+        return event;
+    }
+
+    public void setEvent(String event) {
+        this.event = event;
+    }
+
+    public String getEventDescription() {
+        return eventDescription;
+    }
+
+    public void setEventDescription(String eventDescription) {
+        this.eventDescription = eventDescription;
+    }
+
+    @Override
+    public String toString() {
+        return "LossCapacityUserMark{" +
+            "station = " + station +
+            ", equipment = " + equipment +
+            ", startTime = " + startTime +
+            ", endTime = " + endTime +
+            ", event = " + event +
+            ", eventDescription = " + eventDescription +
+        "}";
+    }
+}

+ 62 - 0
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/entity/R.java

@@ -0,0 +1,62 @@
+package com.gyee.gaia.electricity.wind.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+/**
+ * @ClassName : R
+ * @Author : xieshengjie
+ * @Date: 2021/5/16 16:59
+ * @Description : 结果集
+ */
+@Data
+public class R implements Serializable {
+    private Boolean success;
+    private Integer code;
+    private String message;
+    private Integer count;
+    private Object data = new Object();
+    private R(){}
+    public static R ok(){
+        R r = new R();
+        r.setSuccess(true);
+        r.setCode(ResultCode.SUCCESS);
+        r.setData(new ArrayList<>());
+        r.setMessage("成功");
+        return r;
+    }
+    public static R ok(Integer count){
+        R r = new R();
+        r.setSuccess(true);
+        r.setCode(ResultCode.SUCCESS);
+        r.setMessage("成功");
+        r.setCount(count);
+        return r;
+    }
+    public static R error(){
+        R r = new R();
+        r.setSuccess(false);
+        r.setCode(ResultCode.ERROR);
+        r.setData(new ArrayList<>());
+        r.setMessage("失败");
+        return r;
+    }
+    public R success(Boolean success){
+        this.setSuccess(success);
+        return this;
+    }
+    public R message(String message){
+        this.setMessage(message);
+        return this;
+    }
+    public R code(Integer code){
+        this.setCode(code);
+        return this;
+    }
+    public R data(Object value){
+        this.setData(value);
+        return this;
+    }
+}

+ 12 - 0
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/entity/ResultCode.java

@@ -0,0 +1,12 @@
+package com.gyee.gaia.electricity.wind.entity;
+
+/**
+ * @ClassName : ResultCode
+ * @Author : xieshengjie
+ * @Date: 2021/5/16 17:01
+ * @Description : 结果状态
+ */
+public class ResultCode {
+    public static Integer SUCCESS = 200;
+    public static Integer ERROR = 500;
+}

+ 35 - 0
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/entity/UserMark.java

@@ -0,0 +1,35 @@
+package com.gyee.gaia.electricity.wind.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author gfhd
+ * @since 2023-05-31
+ */
+@Data
+public class UserMark implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+
+    private String station;
+
+    private String equipment;
+
+    private String startTime;
+
+    private String endTime;
+
+    private String event;
+
+    private String eventDescription;
+}

+ 41 - 4
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/init/CacheContext.java

@@ -1,6 +1,7 @@
 package com.gyee.gaia.electricity.wind.init;
 
 import com.gyee.gaia.common.data.power.ModelPowerDetails;
+import com.gyee.gaia.common.data.power.Powermodel;
 import com.gyee.gaia.common.data.windturbine.Equipment;
 import com.gyee.gaia.common.data.windturbine.Line;
 import com.gyee.gaia.common.data.windturbine.Powerstation;
@@ -10,6 +11,8 @@ import com.gyee.gaia.dao.sql.Windturbine.ILineService;
 import com.gyee.gaia.dao.sql.Windturbine.IPowerstationService;
 import com.gyee.gaia.dao.sql.Windturbine.IProjectService;
 import com.gyee.gaia.dao.sql.power.IModelPowerDetailsService;
+import com.gyee.gaia.dao.sql.power.IPowermodelService;
+import com.gyee.gaia.electricity.wind.entity.EquipPowerGenDay;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationRunner;
@@ -17,6 +20,8 @@ import org.springframework.core.annotation.Order;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -41,6 +46,9 @@ public class CacheContext implements ApplicationRunner {
     @Resource
     private ILineService lineService;
 
+    /**
+     * 机型、风速、功率
+     */
     public static Map<String, Map<Double, Double>> modelPowerMap;
     /**
      * 风机号,Equipment
@@ -90,22 +98,30 @@ public class CacheContext implements ApplicationRunner {
      * 期次id,线路
      */
     public static Map<String, List<Line>> projectLinesMap;
+    /**
+     * 场站id,风机
+     */
+    public static Map<String, List<Equipment>> stationEquipmentsMap;
+
+    public static Map<String, String> old2NewIdMap = new HashMap<>();
 
     @Override
     public void run(ApplicationArguments args) throws Exception {
 
-        log.info("加载风速功率!");
+        log.info("加载机型风速功率!");
         List<ModelPowerDetails> mpList = modelPowerDetailsService.list();
         modelPowerMap = mpList.stream().collect(Collectors.groupingBy(ModelPowerDetails::getModelId, Collectors.toMap(ModelPowerDetails::getSpeed, ModelPowerDetails::getTheoryPower)));
 
         log.info("加载风机!");
         List<Equipment> emList = equipmentService.list();
+        old2NewIdMap.putAll(emList.stream().collect(Collectors.toMap(Equipment::getCode,Equipment::getId)));
         equipMap = emList.stream().collect(Collectors.toMap(Equipment::getId, Function.identity()));
         equipModelMap = emList.stream().collect(Collectors.toMap(Equipment::getId, Equipment::getModelId));
 
         log.info("加载风场信息!");
         stationList = powerstationService.list();
         stationMap = stationList.stream().collect(Collectors.toMap(Powerstation::getId, Function.identity()));
+        old2NewIdMap.putAll(stationList.stream().collect(Collectors.toMap(Powerstation::getCode,Powerstation::getId)));
 
         log.info("加载线路、期次、风场信息!");
         List<Equipment> emCollect = emList.stream().filter(e -> "WT".equals(e.getSpare1())).collect(Collectors.toList());
@@ -114,16 +130,37 @@ public class CacheContext implements ApplicationRunner {
         lineEquipidMap = emCollect.stream().collect(Collectors.groupingBy(Equipment::getLineId, Collectors.mapping(Equipment::getId, Collectors.toList())));
 
         pList = projectService.list();
+        old2NewIdMap.putAll(pList.stream().collect(Collectors.toMap(Project::getCode,Project::getId)));
+
         lList = lineService.list();
+        old2NewIdMap.putAll(lList.stream().collect(Collectors.toMap(Line::getCode,Line::getId)));
         Map<String, String> sssMap = stationList.stream().collect(Collectors.toMap(Powerstation::getId, Powerstation::getName));
         Map<String, String> pssMap = pList.stream().collect(Collectors.toMap(Project::getId, Project::getName));
         Map<String, String> lssMap = lList.stream().collect(Collectors.toMap(Line::getId, Line::getName));
+        Map<String, String> essMap = emList.stream().collect(Collectors.toMap(Equipment::getId, Equipment::getName));
         splssMap.putAll(sssMap);
         splssMap.putAll(pssMap);
         splssMap.putAll(lssMap);
-        stationProjectsMap = pList.stream().collect(Collectors.groupingBy(Project::getWindpowerstationId, Collectors.mapping(Function.identity(), Collectors.toList())));
-        projectLinesMap = lList.stream().collect(Collectors.groupingBy(Line::getProjectId, Collectors.mapping(Function.identity(), Collectors.toList())));
-
+        splssMap.putAll(essMap);
+        splssMap.put("FD", "风电");
+        splssMap.put("GF", "光伏");
+        splssMap.put("GS", "全场");
+        stationEquipmentsMap = emList.stream().collect(Collectors.groupingBy(Equipment::getWindpowerstationId));
+        stationProjectsMap = pList.stream().collect(Collectors.groupingBy(Project::getWindpowerstationId));
+        projectLinesMap = lList.stream().collect(Collectors.groupingBy(Line::getProjectId));
         //calcEquipPowerGenDay.calcEquipPowerGenDay();
     }
+
+    public static void summation(EquipPowerGenDay genDay, List<EquipPowerGenDay> filterStream) {
+        genDay.setGeneratingCapacity(filterStream.stream().map(e -> e.getGeneratingCapacity() != null ? e.getGeneratingCapacity() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
+        genDay.setTheoryGeneration(filterStream.stream().map(e -> e.getTheoryGeneration() != null ? e.getTheoryGeneration() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
+        genDay.setLossPower(filterStream.stream().map(e -> e.getLossPower() != null ? e.getLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
+
+        genDay.setFaultLossPower(filterStream.stream().map(e -> e.getFaultLossPower() != null ? e.getFaultLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
+        genDay.setMaintainLossPower(filterStream.stream().map(e -> e.getMaintainLossPower() != null ? e.getMaintainLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
+        genDay.setImplicateLossPower(filterStream.stream().map(e -> e.getImplicateLossPower() != null ? e.getImplicateLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
+        genDay.setLimitLossPower(filterStream.stream().map(e -> e.getLimitLossPower() != null ? e.getLimitLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
+        genDay.setPerformanceLossPower(filterStream.stream().map(e -> e.getPerformanceLossPower() != null ? e.getPerformanceLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
+        genDay.setMeanWindSpeed(BigDecimal.valueOf(filterStream.stream().filter(e -> e.getMeanWindSpeed() != null && e.getMeanWindSpeed().doubleValue() != 0).mapToDouble(e -> e.getMeanWindSpeed().doubleValue()).average().getAsDouble()).setScale(2, RoundingMode.HALF_UP));
+    }
 }

+ 3 - 0
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/iservice/IEquipPowerGenDayService.java

@@ -3,6 +3,8 @@ package com.gyee.gaia.electricity.wind.iservice;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.gyee.gaia.electricity.wind.entity.EquipPowerGenDay;
 
+import java.util.List;
+
 /**
  * <p>
  * 服务类
@@ -13,4 +15,5 @@ import com.gyee.gaia.electricity.wind.entity.EquipPowerGenDay;
  */
 public interface IEquipPowerGenDayService extends IService<EquipPowerGenDay> {
 
+    List<EquipPowerGenDay> fjjxb(String wpids, String projectids, String lineids, String beginDate, String endDate, String type, String target, String sort);
 }

+ 16 - 0
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/iservice/ILossCapacityUserMarkService.java

@@ -0,0 +1,16 @@
+package com.gyee.gaia.electricity.wind.iservice;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.gaia.electricity.wind.entity.LossCapacityUserMark;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2023-05-31
+ */
+public interface ILossCapacityUserMarkService extends IService<LossCapacityUserMark> {
+
+}

+ 83 - 31
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/job/CalcEquipPowerGenDay.java

@@ -49,13 +49,11 @@ public class CalcEquipPowerGenDay {
      * 风机id,1分钟理论发电量
      */
     private Map<String, List<RealtimeAverageTarget>> ratsListMap;
-    /**
-     * 风机id,日信息
-     */
-    private Map<String, EquipPowerGenDay> sepgdMap;
 
     @XxlJob("CalcEquipPowerGenDay")
     public void calcEquipPowerGenDay() {
+        //风机id,日信息
+        Map<String, EquipPowerGenDay> sepgdMap = new HashMap<>();
 
         String command = XxlJobHelper.getJobParam();
         Map<String, String> map = new HashMap<>();
@@ -74,9 +72,9 @@ public class CalcEquipPowerGenDay {
         DateTime startDateTime = DateUtil.beginOfDay(date);
         DateTime endDateTime = DateUtil.endOfDay(date);
 
-        calcGeneratingCapacity(startDateTime, endDateTime);
-        calcTheoryGeneration(startDateTime, endDateTime);
-        calcLossPower(startDateTime, endDateTime);
+        calcGeneratingCapacity(sepgdMap, startDateTime, endDateTime);
+        calcTheoryGeneration(sepgdMap, startDateTime, endDateTime);
+        calcLossPower(sepgdMap, startDateTime, endDateTime);
 
         //删除旧数据
         QueryWrapper<EquipPowerGenDay> epgdWrapper = new QueryWrapper<>();
@@ -90,6 +88,48 @@ public class CalcEquipPowerGenDay {
         equipPowerGenDayService.saveBatch(clpsw);
     }
 
+    @XxlJob("FiveMinutesCalcGenDay")
+    public void fiveMinutesCalcGenDay() {
+        DateTime date = DateUtil.date();
+        DateTime startDateTime = DateUtil.beginOfDay(date);
+        DateTime endDateTime = date;
+
+        //风机id,日信息
+        Map<String, EquipPowerGenDay> sepgdMap = new HashMap<>();
+
+        calcGeneratingCapacity(sepgdMap, startDateTime, endDateTime);
+        calcTheoryGeneration(sepgdMap, startDateTime, endDateTime);
+        calcLossPower(sepgdMap, startDateTime, endDateTime);
+
+        /*List<EquipPowerGenDay> list1 = sepgdMap.values().stream().collect(Collectors.toList());
+
+        QueryWrapper<EquipPowerGenDay> epgdWrapper = new QueryWrapper<>();
+        epgdWrapper.eq("date", startDateTime.toLocalDateTime());
+        List<EquipPowerGenDay> list2 = equipPowerGenDayService.list(epgdWrapper);
+
+        if (list2.size() > 0) {
+            list1.forEach(equip1 ->
+                    list2.stream().filter(equip2 ->
+                                    equip1.getStation().equals(equip2.getStation()) &&
+                                            equip1.getCategory().equals(equip2.getCategory()) &&
+                                            equip1.getFacilityId().equals(equip2.getFacilityId()) &&
+                                            equip1.getDate().equals(equip2.getDate()))
+                            .findFirst().ifPresent(equip2 -> equip1.setId(equip2.getId())));
+            list1 = list1.stream().filter(l -> l.getId() != null).collect(Collectors.toList());
+        }*/
+        //删除旧数据
+        QueryWrapper<EquipPowerGenDay> epgdWrapper = new QueryWrapper<>();
+        epgdWrapper.eq("date", startDateTime.toLocalDateTime());
+        equipPowerGenDayService.remove(epgdWrapper);
+
+        //保存风机数据
+        equipPowerGenDayService.saveBatch(sepgdMap.values());
+
+        List<EquipPowerGenDay> clpsw = calcLineProjectStationWindpower(startDateTime.toLocalDateTime().toLocalDate());
+        //保存线路、期次、场站,风电数据
+        equipPowerGenDayService.saveOrUpdateBatch(clpsw);
+    }
+
     /**
      * 计算线路、期次、场站,风电的日电量信息(发电量、理论电量、损失电量、五损电量)
      */
@@ -107,7 +147,7 @@ public class CalcEquipPowerGenDay {
             genDay.setCategory("line");
             genDay.setFacilityId(line);
             List<EquipPowerGenDay> filterStream = epgdList.stream().filter(epgd -> equipidList.contains(epgd.getFacilityId())).collect(Collectors.toList());
-            extracted(genDay, filterStream);
+            CacheContext.summation(genDay, filterStream);
             equipPowerGenDayList.add(genDay);
         });
         CacheContext.projectEquipidMap.forEach((project, equipidList) -> {
@@ -117,7 +157,7 @@ public class CalcEquipPowerGenDay {
             genDay.setCategory("project");
             genDay.setFacilityId(project);
             List<EquipPowerGenDay> filterStream = epgdList.stream().filter(epgd -> equipidList.contains(epgd.getFacilityId())).collect(Collectors.toList());
-            extracted(genDay, filterStream);
+            CacheContext.summation(genDay, filterStream);
             equipPowerGenDayList.add(genDay);
         });
         CacheContext.stationEquipidMap.forEach((station, equipidList) -> {
@@ -127,36 +167,23 @@ public class CalcEquipPowerGenDay {
             genDay.setCategory("station");
             genDay.setFacilityId(station);
             List<EquipPowerGenDay> filterStream = epgdList.stream().filter(epgd -> equipidList.contains(epgd.getFacilityId())).collect(Collectors.toList());
-            extracted(genDay, filterStream);
+            CacheContext.summation(genDay, filterStream);
             equipPowerGenDayList.add(genDay);
         });
         EquipPowerGenDay genDay = new EquipPowerGenDay();
         genDay.setDate(time1);
         genDay.setCategory("windpower");
-        genDay.setFacilityId("NX");
-        extracted(genDay, epgdList);
+        genDay.setFacilityId("FD");
+        CacheContext.summation(genDay, epgdList);
         equipPowerGenDayList.add(genDay);
 
         return equipPowerGenDayList;
     }
 
-    private void extracted(EquipPowerGenDay genDay, List<EquipPowerGenDay> filterStream) {
-        genDay.setGeneratingCapacity(filterStream.stream().map(e -> e.getGeneratingCapacity() != null ? e.getGeneratingCapacity() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
-        genDay.setTheoryGeneration(filterStream.stream().map(e -> e.getTheoryGeneration() != null ? e.getTheoryGeneration() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
-        genDay.setLossPower(filterStream.stream().map(e -> e.getLossPower() != null ? e.getLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
-
-        genDay.setFaultLossPower(filterStream.stream().map(e -> e.getFaultLossPower() != null ? e.getFaultLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
-        genDay.setMaintainLossPower(filterStream.stream().map(e -> e.getMaintainLossPower() != null ? e.getMaintainLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
-        genDay.setImplicateLossPower(filterStream.stream().map(e -> e.getImplicateLossPower() != null ? e.getImplicateLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
-        genDay.setLimitLossPower(filterStream.stream().map(e -> e.getLimitLossPower() != null ? e.getLimitLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
-        genDay.setPerformanceLossPower(filterStream.stream().map(e -> e.getPerformanceLossPower() != null ? e.getPerformanceLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
-        genDay.setMeanWindSpeed(BigDecimal.valueOf(filterStream.stream().filter(e -> e.getMeanWindSpeed() != null && e.getMeanWindSpeed().doubleValue() != 0).mapToDouble(e -> e.getMeanWindSpeed().doubleValue()).average().getAsDouble()).setScale(2, RoundingMode.HALF_UP));
-    }
-
     /**
      * 计算损失电量
      */
-    private void calcLossPower(DateTime time1, DateTime time2) {
+    private void calcLossPower(Map<String, EquipPowerGenDay> sepgdMap, DateTime time1, DateTime time2) {
 
         //查询1分钟理论发电量
         QueryWrapper<RealtimeAverageTarget> ratWrapper = new QueryWrapper<>();
@@ -180,7 +207,10 @@ public class CalcEquipPowerGenDay {
         scWrapper.select("start_time", "end_time", "event", "time", "station_id", "equipment_id").ne("event", "待机")
                 .ge("start_time", time1).le("end_time", time2);
         List<StateCause> scList = stateCauseService.list(scWrapper);
-        Map<String, List<StateCause>> scsListMap = scList.stream().collect(Collectors.groupingBy(StateCause::getEquipmentId));
+        //读取用户标记并按风机分类
+        Map<String, List<StateCause>> scsListMap = scList.stream().peek(sc->{
+            if(StrUtil.isNotBlank(sc.getUserFlag())) sc.setEvent(sc.getUserFlag());
+        }).collect(Collectors.groupingBy(StateCause::getEquipmentId));
 
         String equipId;
         EquipPowerGenDay epgd;
@@ -259,7 +289,7 @@ public class CalcEquipPowerGenDay {
     /**
      * 计算理论电量
      */
-    private void calcTheoryGeneration(DateTime time1, DateTime time2) {
+    private void calcTheoryGeneration(Map<String, EquipPowerGenDay> sepgdMap, DateTime time1, DateTime time2) {
 
         //查询1分钟平均风速
         QueryWrapper<RealtimeAverageTarget> ratWrapper = new QueryWrapper<>();
@@ -308,15 +338,13 @@ public class CalcEquipPowerGenDay {
     /**
      * 计算日发电量
      */
-    private void calcGeneratingCapacity(DateTime time1, DateTime time2) {
+    private void calcGeneratingCapacity(Map<String, EquipPowerGenDay> sepgdMap, DateTime time1, DateTime time2) {
 
         //开始时间00:00:01
         //DateTime dateTime1 = DateUtil.offsetSecond(time1, 1);
         //结束时间第二天00:00:01
         //DateTime dateTime2 = DateUtil.offsetSecond(time2, 2);
 
-        sepgdMap = new HashMap<>();
-
         //1,在testingpoint中根据 uniform_code=AI064 和code like "%_FJ_%" 取出所有风机的电量测点code
         List<TestingPoint> testingPointList = testingPointService.list(new QueryWrapper<TestingPoint>().eq("uniform_code", "AI064").eq("thing_type", "windturbine"));
         //2,遍历list,每次取出一个code
@@ -387,6 +415,30 @@ public class CalcEquipPowerGenDay {
         }
     }
 
+    public synchronized void recalculationGeneratingCapacity(DateTime date){
+
+        //风机id,日信息
+        Map<String, EquipPowerGenDay> sepgdMap = new HashMap<>();
+
+        //2,获取当前日期,当日开始时间
+        DateTime startDateTime = DateUtil.beginOfDay(date);
+        DateTime endDateTime = DateUtil.endOfDay(date);
+
+        calcGeneratingCapacity(sepgdMap, startDateTime, endDateTime);
+        calcTheoryGeneration(sepgdMap, startDateTime, endDateTime);
+        calcLossPower(sepgdMap, startDateTime, endDateTime);
+
+        //删除旧数据
+        QueryWrapper<EquipPowerGenDay> epgdWrapper = new QueryWrapper<>();
+        epgdWrapper.eq("date", startDateTime.toLocalDateTime());
+        equipPowerGenDayService.remove(epgdWrapper);
+        //保存风机数据
+        equipPowerGenDayService.saveBatch(sepgdMap.values());
+
+        List<EquipPowerGenDay> clpsw = calcLineProjectStationWindpower(startDateTime.toLocalDateTime().toLocalDate());
+        //保存线路、期次、场站,风电数据
+        equipPowerGenDayService.saveBatch(clpsw);
+    }
 }
 
 

+ 18 - 0
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/mapper/LossCapacityUserMarkMapper.java

@@ -0,0 +1,18 @@
+package com.gyee.gaia.electricity.wind.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.gaia.electricity.wind.entity.LossCapacityUserMark;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author gfhd
+ * @since 2023-05-31
+ */
+@Mapper
+public interface LossCapacityUserMarkMapper extends BaseMapper<LossCapacityUserMark> {
+
+}

+ 71 - 0
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/serviceimpl/EquipPowerGenDayServiceImpl.java

@@ -1,11 +1,23 @@
 package com.gyee.gaia.electricity.wind.serviceimpl;
 
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gyee.gaia.electricity.wind.entity.EquipPowerGenDay;
+import com.gyee.gaia.electricity.wind.entity.R;
+import com.gyee.gaia.electricity.wind.init.CacheContext;
 import com.gyee.gaia.electricity.wind.iservice.IEquipPowerGenDayService;
 import com.gyee.gaia.electricity.wind.mapper.EquipPowerGenDayMapper;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * <p>
  * 服务实现类
@@ -17,4 +29,63 @@ import org.springframework.stereotype.Service;
 @Service
 public class EquipPowerGenDayServiceImpl extends ServiceImpl<EquipPowerGenDayMapper, EquipPowerGenDay> implements IEquipPowerGenDayService {
 
+    @Override
+    public List<EquipPowerGenDay> fjjxb(String wpids, String projectids, String lineids, String beginDate, String endDate, String type, String target, String sort) {
+        QueryWrapper<EquipPowerGenDay> epgdWrapper = new QueryWrapper<>();
+        epgdWrapper.select("facility_id", "round(sum(generating_capacity)/1000,2) generating_capacity", "round(sum(theory_generation)/1000,2) theory_generation"
+                , "round(sum(loss_power)/1000,2) loss_power", "round(sum(fault_loss_power)/1000,2) fault_loss_power"
+                , "round(sum(maintain_loss_power)/1000,2) maintain_loss_power", "round(sum(implicate_loss_power)/1000,2) implicate_loss_power"
+                , "round(sum(limit_loss_power)/1000,2) limit_loss_power", "round(sum(performance_loss_power)/1000,2) performance_loss_power"
+                , "round(avg(mean_wind_speed),2) mean_wind_speed");
+
+        if("1".equals(type)){
+            epgdWrapper.eq("category", "station");
+        }else if("2".equals(type)){
+            epgdWrapper.eq("category", "project");
+        }else if("3".equals(type)){
+            epgdWrapper.eq("category", "line");
+        }else {
+            if (StrUtil.isNotBlank(lineids)) {
+                String[] split = lineids.split(",");
+                List<String> windturbines = new ArrayList<>();
+                for (String s : split) {
+                    s = CacheContext.old2NewIdMap.get(s);
+                    List<String> strings = CacheContext.lineEquipidMap.get(s);
+                    windturbines.addAll(strings);
+                }
+                epgdWrapper.eq("category", "windturbine")
+                        .in("facility_id", windturbines);
+            } else if (StrUtil.isNotBlank(projectids)) {
+                String[] split = projectids.split(",");
+                List<String> windturbines = new ArrayList<>();
+                for (String s : split) {
+                    s = CacheContext.old2NewIdMap.get(s);
+                    List<String> strings = CacheContext.projectEquipidMap.get(s);
+                    windturbines.addAll(strings);
+                }
+                epgdWrapper.eq("category", "windturbine")
+                        .in("facility_id", windturbines);
+            } else if (StrUtil.isNotBlank(wpids)) {
+                wpids = CacheContext.old2NewIdMap.get(wpids);
+                epgdWrapper.eq("category", "windturbine")
+                        .in("facility_id", CacheContext.stationEquipidMap.get(wpids));
+            } else {
+                epgdWrapper.eq("category", "windturbine");
+            }
+        }
+
+        epgdWrapper.between("date", DateUtil.parse(beginDate).toLocalDateTime().toLocalDate(), DateUtil.parse(endDate).toLocalDateTime().toLocalDate())
+                .groupBy("facility_id");
+
+        EquipPowerGenDay powerGenDay = new EquipPowerGenDay();
+
+        List<EquipPowerGenDay> list = baseMapper.selectList(epgdWrapper);
+        if (list.size() > 0){
+            powerGenDay.setUniformCode("合计");
+            CacheContext.summation(powerGenDay, list);
+            list = list.stream().peek(d -> d.setUniformCode(CacheContext.splssMap.get(d.getFacilityId()))).sorted(Comparator.comparing(EquipPowerGenDay::getFacilityId)).collect(Collectors.toList());
+            list.add(powerGenDay);
+        }
+        return list;
+    }
 }

+ 20 - 0
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/serviceimpl/LossCapacityUserMarkServiceImpl.java

@@ -0,0 +1,20 @@
+package com.gyee.gaia.electricity.wind.serviceimpl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.gaia.electricity.wind.entity.LossCapacityUserMark;
+import com.gyee.gaia.electricity.wind.iservice.ILossCapacityUserMarkService;
+import com.gyee.gaia.electricity.wind.mapper.LossCapacityUserMarkMapper;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2023-05-31
+ */
+@Service
+public class LossCapacityUserMarkServiceImpl extends ServiceImpl<LossCapacityUserMarkMapper, LossCapacityUserMark> implements ILossCapacityUserMarkService {
+
+}

+ 2 - 1
electricity/wind/src/main/resources/bootstrap.yaml

@@ -99,12 +99,13 @@ mybatis-plus:
     #配置JdbcTypeForNull, oracle数据库必须配置
     jdbc-type-for-null: 'null'
     callSettersOnNulls: true
-    #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 
 xxl:
   job:
     admin:
       addresses: http://192.168.1.67:8080/xxl-job-admin
+      #addresses: http://192.168.10.18:8080/xxl-job-admin
     accessToken:
     executor:
       appname: ${spring.application.name}

+ 0 - 40
electricity/wind/src/test/java/com/gyee/gaia/MyAppTests.java

@@ -1,40 +0,0 @@
-package com.gyee.gaia;
-
-import com.gyee.gaia.electricity.wind.adapter.IShardingApi;
-import org.junit.jupiter.api.Test;
-import org.springframework.boot.test.context.SpringBootTest;
-
-import javax.annotation.Resource;
-
-@SpringBootTest(classes = WindPowergenApp.class)
-class MyAppTests {
-
-    @Resource
-    private IShardingApi shardingApi;
-
-    @Test
-    void test() {
-
-        /*QueryWrapper<StateCause> scWrapper = new QueryWrapper<>();
-        scWrapper.select("max(end_time)");
-        Map<String, Object> map = stateCauseService.getMap(scWrapper);*/
-        /*List<FaultInfo> infos = shardingApi.getFaultInfoList("SYZ", "2023-05-10", "2023-05-13", CacheContext.stationMap.get("NX_GDDL_XS_FDC_STA").getCode(), null, null);
-        if(infos.size()>0){
-            infos = infos.stream().filter(fi -> fi.getAlertText().contains("位状态")).collect(Collectors.toList());
-            if(infos.isEmpty()) return;
-
-            Map<String, List<FaultInfo>> map = infos.stream().map(fi -> {
-                fi.setConfirmPerson(fi.getAlertText().substring(fi.getAlertText().indexOf("--")));
-                fi.setAlertText(fi.getAlertText().substring(0, fi.getAlertText().indexOf("--")));
-                return fi;
-            }).collect(Collectors.groupingBy(FaultInfo::getAlertText));
-
-            for (List<FaultInfo> value : map.values()) {
-                //判断当前故障是分位状态
-                if(value.get(0).getConfirmPerson().equals("分位状态")) return;
-            }
-        }*/
-
-
-    }
-}

+ 35 - 0
electricity/wind/src/test/java/com/gyee/gaia/WindPowergenAppTests.java

@@ -0,0 +1,35 @@
+package com.gyee.gaia;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.gaia.common.data.taos.RealtimeAverageTarget;
+import com.gyee.gaia.dao.sql.taos.IRealtimeAverageTargetService;
+import com.gyee.gaia.electricity.wind.adapter.IShardingApi;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@SpringBootTest(classes = WindPowergenApp.class)
+class WindPowergenAppTests {
+
+    @Resource
+    private IShardingApi shardingApi;
+    @Resource
+    private IRealtimeAverageTargetService realtimeAverageTargetService;
+
+    @Test
+    void test() {
+
+        QueryWrapper<RealtimeAverageTarget> ratWrapper = new QueryWrapper<>();
+        ratWrapper.select("time", "theory_generation", "equipment_id").eq("uniform_code", "1FZPJZB")
+                .between("time", 1686118549000L, 1686122149000L);
+        List<RealtimeAverageTarget> ratList = realtimeAverageTargetService.list(ratWrapper);
+
+    }
+
+    public static void main(String[] args) {
+        Integer k = 1;
+        System.out.println(k==1);
+    }
+}

+ 15 - 0
realtime/wind/src/main/java/com/gyee/gaia/realtime/wind/init/CacheContext.java

@@ -3,6 +3,7 @@ package com.gyee.gaia.realtime.wind.init;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.gyee.gaia.common.data.point.TestingPoint;
 import com.gyee.gaia.common.data.power.ModelPowerDetails;
+import com.gyee.gaia.common.data.power.Powermodel;
 import com.gyee.gaia.common.data.taos.RealtimeAverageTarget;
 import com.gyee.gaia.common.data.windturbine.Equipment;
 import com.gyee.gaia.common.data.windturbine.Powerstation;
@@ -10,6 +11,7 @@ import com.gyee.gaia.dao.sql.Windturbine.IEquipmentService;
 import com.gyee.gaia.dao.sql.Windturbine.IPowerstationService;
 import com.gyee.gaia.dao.sql.point.ITestingPointService;
 import com.gyee.gaia.dao.sql.power.IModelPowerDetailsService;
+import com.gyee.gaia.dao.sql.power.IPowermodelService;
 import com.gyee.gaia.dao.sql.taos.IRealtimeAverageTargetService;
 import com.gyee.gaia.realtime.wind.config.AppConfig;
 import lombok.extern.slf4j.Slf4j;
@@ -63,6 +65,13 @@ public class CacheContext implements ApplicationRunner {
     private ITestingPointService testingPointService;
     @Resource
     private AppConfig appConfig;
+    @Resource
+    private IPowermodelService powermodelService;
+
+    /**
+     * 风机、风速、功率
+     */
+    public static Map<String, Map<Double, Double>> powerModelMap;
 
     /**
      * 风机id,1分钟平均指标测点
@@ -84,6 +93,7 @@ public class CacheContext implements ApplicationRunner {
         equipMap = emList.stream().collect(Collectors.toMap(Equipment::getId, Function.identity()));
         stationEquipMap = emList.stream().collect(Collectors.groupingBy(Equipment::getWindpowerstationId));
         equipModelMap = emList.stream().collect(Collectors.toMap(Equipment::getId, Equipment::getModelId));
+        Map<String, String> equipIdOld2New = emList.stream().collect(Collectors.toMap(Equipment::getCode, Equipment::getId));
 
         log.info("加载风场信息!");
         List<Powerstation> stationList = powerstationService.list();
@@ -122,5 +132,10 @@ public class CacheContext implements ApplicationRunner {
         }
 
         pointCodes = sb.delete(0, 1).toString();
+
+        log.info("加载风机风速功率!");
+        List<Powermodel> pmList = powermodelService.list();
+        powerModelMap=pmList.stream().collect(Collectors.groupingBy(pm->equipIdOld2New.get(pm.getWindturbineid()), Collectors.toMap(Powermodel::getSpeed, Powermodel::getPower)));
+
     }
 }

+ 8 - 1
realtime/wind/src/main/java/com/gyee/gaia/realtime/wind/job/CauseJobHandler.java

@@ -111,13 +111,20 @@ public class CauseJobHandler implements ApplicationRunner {
 
                 pointCode = entryValue.get(uniformcodeOne.get("wind-speed"));
                 if (pointCode != null) {
+                    //风速
                     v = pdaqMap.get(pointCode).stream().mapToDouble(PointData::getDoubleValue).average().orElse(0);
                     speed = NumberUtil.round(v, 2).doubleValue();
                     target.setWindSpeed((float) speed);
+
                     if (speed < 3) {
                         power = 0.0;
                     } else {
-                        power = CacheContext.mpdsMapMap.get(CacheContext.equipModelMap.get(entry.getKey())).get(speed);
+                        Map<Double, Double> map = CacheContext.powerModelMap.get(entry.getKey());
+                        if (map != null && map.size() > 0) {
+                            power = map.get(speed);
+                        } else {
+                            power = CacheContext.mpdsMapMap.get(CacheContext.equipModelMap.get(entry.getKey())).get(speed);
+                        }
                     }
                     if (power == null) {
                         power = 0.0;

+ 6 - 1
realtime/wind/src/main/java/com/gyee/gaia/realtime/wind/job/DataFillJobHandler.java

@@ -137,7 +137,12 @@ public class DataFillJobHandler {
         if (speed < 3) {
             rat.setTheoryGeneration(0f);
         } else {
-            rat.setTheoryGeneration(NumberUtil.round(CacheContext.mpdsMapMap.get(CacheContext.equipModelMap.get(equipId)).get(speed) / 60, 4).floatValue());
+            Map<Double, Double> map = CacheContext.powerModelMap.get(equipId);
+            if (map != null && map.size() > 0) {
+                rat.setTheoryGeneration(NumberUtil.round(map.get(speed) / 60, 4).floatValue());
+            } else {
+                rat.setTheoryGeneration(NumberUtil.round(CacheContext.mpdsMapMap.get(CacheContext.equipModelMap.get(equipId)).get(speed) / 60, 4).floatValue());
+            }
         }
     }
 }

+ 8 - 0
realtime/wind/src/test/java/com/gyee/gaia/MyAppTests.java

@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
 
 import javax.annotation.Resource;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -42,4 +43,11 @@ class MyAppTests {
 
 
     }
+
+    public static void main(String[] args) {
+        HashMap<Double, Double> map = new HashMap<>();
+        map.put(3.60, 3.66);
+        double k = 3.6;
+        System.out.println((float) k);
+    }
 }

+ 136 - 103
state/cause/src/main/java/com/gyee/gaia/cause/service/CalculateService.java

@@ -91,7 +91,7 @@ public class CalculateService {
                     LinkedHashMap<Long, Long> map = calcElectricityRation(thingId, advanceTime, ts);
                     StateCause cause;
                     for (Map.Entry<Long, Long> entry : map.entrySet()) {
-                        if (ts==entry.getKey()) {
+                        if (ts == entry.getKey()) {
                             cause = new StateCause(CacheContext.scEquipTbMap.get(thingId), stateMap.get(8.0), new Timestamp(entry.getKey()),
                                     new Timestamp(entry.getValue()), stateMap.get(4.0), stateMap.get(doubleValue), entry.getValue() - entry.getKey());
                         } else {
@@ -126,7 +126,6 @@ public class CalculateService {
                         stateCauseList.add(cause);
                     }
                 } else if (advanceState == 5) {
-                    if (ts - advanceTime < 30000) continue;
                     if (ts - advanceTime < appConfig.getLongTime().get("fault-min")) continue;
                     //计算受累、故障
                     calcBurdened(stateCauseList, thingId, advanceTime, ts, 5, doubleValue);
@@ -187,13 +186,144 @@ public class CalculateService {
         //List<StateCause> collect = stateCauseList.stream().filter(sc -> stationid.equals(sc.getStationId()) && stateMap.get(8.0).equals(sc.getEvent())
         //        && sc.getStartTime().getTime() >= start && sc.getEndTime().getTime() <= end).collect(Collectors.toList());
 
-        //有功设定小于应发的70% 并且 出线功率大于有功设定80% 并且 当前场站限电台数大于等于3
+        //有功设定小于应发的75% 并且 出线功率大于有功设定85% 并且 当前场站限电台数大于等于5
         String stationid = thingId2StationId(thingId);
-        return apsDouble <= apDouble * 0.7 && opDouble >= apsDouble * 0.8 && electricityRationCount(stationid, start, end) >= 3;
+        return apsDouble <= apDouble * 0.75 && opDouble >= apsDouble * 0.85 && electricityRationCount(stationid, start, end) > 4;
     }
 
     /**
-     * 计算风电场当前时刻限电台数--大于3返回优化计算速度
+     * 计算限电
+     *
+     * @param equipment 设备id
+     * @param start     并网开始时间
+     * @param end       并网结束时间
+     */
+    private LinkedHashMap<Long, Long> calcElectricityRation(String equipment, long start, long end) {
+        Booststation boostStation = thingId2BoostStation(equipment);
+        TestingPoint apsTp = CacheContext.pointMapMap.get("active-power-set").get(boostStation.getId());
+        List<PointData> apsRbk = adapterApi.getValuesByKey(apsTp.getCode(), start, end, 30);
+        TestingPoint apTp = CacheContext.pointMapMap.get("apparent-power").get(boostStation.getId());
+        List<PointData> apRbk = adapterApi.getValuesByKey(apTp.getCode(), start, end, 30);
+        TestingPoint opTp = CacheContext.pointMapMap.get("output-power").get(boostStation.getId());
+        List<PointData> opRbk = adapterApi.getValuesByKey(opTp.getCode(), start, end, 30);
+        //有功设定
+        double apsDouble = 0;
+        if (apsRbk.size() > 0)
+            apsDouble = apsRbk.stream().mapToDouble(PointData::getDoubleValue).average().getAsDouble() * (apsTp.getRate() == null ? 1 : apsTp.getRate());
+        //应发功率
+        double apDouble = 0;
+        if (apRbk.size() > 0) {
+            if (boostStation.getId().contains("QS")) {
+                TestingPoint apTp2 = CacheContext.pointMapMap.get("apparent-power").get(boostStation.getId() + "2");
+                List<PointData> apRbk2 = adapterApi.getValuesByKey(apTp2.getCode(), start, end, 30);
+                apDouble = apRbk.stream().mapToDouble(PointData::getDoubleValue).average().getAsDouble() * (apTp.getRate() == null ? 1 : apTp.getRate());
+
+                if (apRbk2.size() > 0)
+                    apDouble += apRbk2.stream().mapToDouble(PointData::getDoubleValue).average().getAsDouble() * (apTp.getRate() == null ? 1 : apTp.getRate());
+
+            } else {
+                apDouble = apRbk.stream().mapToDouble(PointData::getDoubleValue).average().getAsDouble() * (apTp.getRate() == null ? 1 : apTp.getRate());
+            }
+        }
+        //出线功率
+        double opDouble = 0;
+        if (opRbk.size() > 0)
+            opDouble = opRbk.stream().mapToDouble(PointData::getDoubleValue).average().getAsDouble() * (opTp.getRate() == null ? 1 : opTp.getRate());
+
+        //满发功率和满发最小风速
+        ModelPower modelPower = CacheContext.fullSpeeds.get(CacheContext.equipMap.get(equipment).getModelId());
+        //并网时间内的风速列表
+        List<PointData> speedList = adapterApi.getValuesByKey(CacheContext.pointMapMap.get("speed").get(equipment).getCode(), start, end, 5);
+        List<PointData> bladeAngleList = adapterApi.getValuesByKey(CacheContext.pointMapMap.get("blade-angle").get(equipment).getCode(), start, end, 5);
+        List<PointData> activePowerList = adapterApi.getValuesByKey(CacheContext.pointMapMap.get("active-power").get(equipment).getCode(), start, end, 5);
+        if (bladeAngleList.size() < speedList.size() || activePowerList.size() < speedList.size())
+            return new LinkedHashMap<>();
+        //是否限电
+        boolean isElectricityRation = false;
+        //限电开始时间
+        long ts1 = 0;
+
+        long ts;
+        double speedPd;
+        double bladeAnglePd;
+        double activePowerPd;
+        //记录限电的开始时间和结束时间
+        LinkedHashMap<Long, Long> llm = new LinkedHashMap<>();
+        for (int i = 0; i < speedList.size(); i++) {
+            ts = speedList.get(i).getTs();
+            speedPd = speedList.get(i).getDoubleValue();
+            //当前时间戳的桨叶角度
+            bladeAnglePd = bladeAngleList.get(i).getDoubleValue();
+            //当前时间戳的有功功率
+            activePowerPd = activePowerList.get(i).getDoubleValue();
+
+            //有功设定小于应发的75% 并且 出线功率大于有功设定85%
+            if (apsDouble <= apDouble * 0.75 && opDouble >= apsDouble * 0.85) {
+                //风速小于11并且桨叶角度大于2
+                if (speedPd <= modelPower.getSpeed() && bladeAnglePd > 2) {
+                    //限电首次时间
+                    if (!isElectricityRation) {
+                        ts1 = ts;
+                    }
+                    isElectricityRation = true;
+                    //风速大于11并且有功功率小于满发功率减100
+                } else if (speedPd > modelPower.getSpeed() && activePowerPd < modelPower.getTheoryPower() - 100) {
+                    //限电首次时间
+                    if (!isElectricityRation) {
+                        ts1 = ts;
+                    }
+                    isElectricityRation = true;
+                } else if (isElectricityRation) {
+                    //记录限电
+                    llm.put(ts1, ts);
+                /*StateCause cause;
+                if(i==speedList.size()-1) {
+                    cause = new StateCause(thingId2StationId(equipment), equipment, stateMap.get(8.0),
+                            new Date(t1), new Date(ts), stateMap.get(4.0), stateMap.get(endeventstate), ts - t1);
+                }else {
+                    cause = new StateCause(thingId2StationId(equipment), equipment, stateMap.get(8.0),
+                            new Date(t1), new Date(ts), stateMap.get(4.0), stateMap.get(4.0), ts - t1);
+                }
+                stateCauseList.add(cause);*/
+                    isElectricityRation = false;
+                }
+            }
+        }
+        //限电跳变处理
+        long t0 = 0;
+        long t1;
+        long tstart = 0;
+        long tend = 0;
+        LinkedHashMap<Long, Long> llm2 = new LinkedHashMap<>();
+        //限电列表key2-key1小于3分钟,记录为一个限电,大于3分钟,记录为另一个限电
+        for (Map.Entry<Long, Long> entry : llm.entrySet()) {
+            if (t0 == 0) {
+                t0 = entry.getKey();
+                tstart = entry.getKey();
+                tend = llm.get(t0);
+                continue;
+            }
+            t1 = entry.getKey();
+            if (t1 - t0 < appConfig.getLongTime().get("ration")) {
+                tend = llm.get(t1);
+            } else {
+                //3分钟内的限电忽略
+                if (tend - tstart > appConfig.getLongTime().get("ration-min")) {
+                    llm2.put(tstart, tend);
+                }
+                tend = llm.get(t1);
+                tstart = t1;
+            }
+            t0 = t1;
+        }
+        if (tend - tstart > appConfig.getLongTime().get("ration-min")) {
+            llm2.put(tstart, tend);
+        }
+        return llm2;
+    }
+
+    /**
+     * 计算风电场当前时刻限电台数--大于等于5返回优化计算速度
      */
     private int electricityRationCount(String stationid, long start, long end) {
         int count = 0;
@@ -222,7 +352,7 @@ public class CalculateService {
                 }
             }
             if (incount / speedPdl.size() > 0.5) count++;
-            if (count > 3) return count;
+            if (count > 4) return count;
         }
         return count;
     }
@@ -369,101 +499,4 @@ public class CalculateService {
             stateCauseList.add(cause);
         }*/
     }
-
-    /**
-     * 计算限电
-     *
-     * @param equipment 设备id
-     * @param start     并网开始时间
-     * @param end       并网结束时间
-     */
-    private LinkedHashMap<Long, Long> calcElectricityRation(String equipment, long start, long end) {
-        //满发功率和满发最小风速
-        ModelPower modelPower = CacheContext.fullSpeeds.get(CacheContext.equipMap.get(equipment).getModelId());
-        //并网时间内的风速列表
-        List<PointData> speedList = adapterApi.getValuesByKey(CacheContext.pointMapMap.get("speed").get(equipment).getCode(), start, end, 5);
-        List<PointData> bladeAngleList = adapterApi.getValuesByKey(CacheContext.pointMapMap.get("blade-angle").get(equipment).getCode(), start, end, 5);
-        List<PointData> activePowerList = adapterApi.getValuesByKey(CacheContext.pointMapMap.get("active-power").get(equipment).getCode(), start, end, 5);
-        if (bladeAngleList.size() < speedList.size() || activePowerList.size() < speedList.size())
-            return new LinkedHashMap<>();
-        //是否限电
-        boolean isElectricityRation = false;
-        //限电开始时间
-        long ts1 = 0;
-
-        long ts;
-        double speedPd;
-        double bladeAnglePd;
-        double activePowerPd;
-        //记录限电的开始时间和结束时间
-        LinkedHashMap<Long, Long> llm = new LinkedHashMap<>();
-        for (int i = 0; i < speedList.size(); i++) {
-            ts = speedList.get(i).getTs();
-            speedPd = speedList.get(i).getDoubleValue();
-            //当前时间戳的桨叶角度
-            bladeAnglePd = bladeAngleList.get(i).getDoubleValue();
-            //当前时间戳的有功功率
-            activePowerPd = activePowerList.get(i).getDoubleValue();
-
-            //风速小于11并且桨叶角度大于2
-            if (speedPd <= modelPower.getSpeed() && bladeAnglePd > 2) {
-                //限电首次时间
-                if (!isElectricityRation) {
-                    ts1 = ts;
-                }
-                isElectricityRation = true;
-                //风速大于11并且有功功率小于满发功率减100
-            } else if (speedPd > modelPower.getSpeed() && activePowerPd < modelPower.getTheoryPower() - 100) {
-                //限电首次时间
-                if (!isElectricityRation) {
-                    ts1 = ts;
-                }
-                isElectricityRation = true;
-            } else if (isElectricityRation) {
-                //记录限电
-                llm.put(ts1, ts);
-                /*StateCause cause;
-                if(i==speedList.size()-1) {
-                    cause = new StateCause(thingId2StationId(equipment), equipment, stateMap.get(8.0),
-                            new Date(t1), new Date(ts), stateMap.get(4.0), stateMap.get(endeventstate), ts - t1);
-                }else {
-                    cause = new StateCause(thingId2StationId(equipment), equipment, stateMap.get(8.0),
-                            new Date(t1), new Date(ts), stateMap.get(4.0), stateMap.get(4.0), ts - t1);
-                }
-                stateCauseList.add(cause);*/
-                isElectricityRation = false;
-            }
-        }
-        //限电跳变处理
-        long t0 = 0;
-        long t1;
-        long tstart = 0;
-        long tend = 0;
-        LinkedHashMap<Long, Long> llm2 = new LinkedHashMap<>();
-        //限电列表key2-key1小于3分钟,记录为一个限电,大于3分钟,记录为另一个限电
-        for (Map.Entry<Long, Long> entry : llm.entrySet()) {
-            if (t0 == 0) {
-                t0 = entry.getKey();
-                tstart = entry.getKey();
-                tend = llm.get(t0);
-                continue;
-            }
-            t1 = entry.getKey();
-            if (t1 - t0 < appConfig.getLongTime().get("ration")) {
-                tend = llm.get(t1);
-            } else {
-                //3分钟内的限电忽略
-                if (tend - tstart > appConfig.getLongTime().get("ration-min")) {
-                    llm2.put(tstart, tend);
-                }
-                tend = llm.get(t1);
-                tstart = t1;
-            }
-            t0 = t1;
-        }
-        if (tend - tstart > appConfig.getLongTime().get("ration-min")) {
-            llm2.put(tstart, tend);
-        }
-        return llm2;
-    }
 }

+ 3 - 1
state/cause/src/test/java/com/gyee/gaia/MyTest.java

@@ -2,6 +2,8 @@ package com.gyee.gaia;
 
 public class MyTest {
     public static void main(String[] args) {
-
+        Long kk = null;
+        long bb = 0;
+        System.out.println(bb==kk);
     }
 }

+ 18 - 0
timeseries/dao-interface/src/main/java/com/gyee/gaia/dao/power/PowermodelMapper.java

@@ -0,0 +1,18 @@
+package com.gyee.gaia.dao.power;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.gaia.common.data.power.Powermodel;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author gfhd
+ * @since 2023-06-08
+ */
+@Mapper
+public interface PowermodelMapper extends BaseMapper<Powermodel> {
+
+}

+ 16 - 0
timeseries/dao-sql/src/main/java/com/gyee/gaia/dao/sql/power/IPowermodelService.java

@@ -0,0 +1,16 @@
+package com.gyee.gaia.dao.sql.power;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.gaia.common.data.power.Powermodel;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2023-06-08
+ */
+public interface IPowermodelService extends IService<Powermodel> {
+
+}

+ 19 - 0
timeseries/dao-sql/src/main/java/com/gyee/gaia/dao/sql/power/PowermodelServiceImpl.java

@@ -0,0 +1,19 @@
+package com.gyee.gaia.dao.sql.power;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.gaia.common.data.power.Powermodel;
+import com.gyee.gaia.dao.power.PowermodelMapper;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2023-06-08
+ */
+@Service
+public class PowermodelServiceImpl extends ServiceImpl<PowermodelMapper, Powermodel> implements IPowermodelService {
+
+}