Преглед изворни кода

增加毛容系数计算;
增加设备自算功率,用于计算电量分析

chenminghua пре 1 година
родитељ
комит
ff96267fe8
30 измењених фајлова са 567 додато и 341 уклоњено
  1. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/MapperGenerator.java
  2. 10 13
      power-fitting/src/main/java/com/gyee/power/fitting/PowerBootApplication.java
  3. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/common/result/ResultCode.java
  4. 34 26
      power-fitting/src/main/java/com/gyee/power/fitting/common/spring/InitialRunner.java
  5. 12 3
      power-fitting/src/main/java/com/gyee/power/fitting/common/util/DateUtil.java
  6. 5 2
      power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/DataFittingController.java
  7. 0 16
      power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/ElectricQuantityController.java
  8. 5 3
      power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/FiveLossInfoController.java
  9. 3 2
      power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/PowerTemperatureController.java
  10. 35 0
      power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/RatedPowerController.java
  11. 17 4
      power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/WindDirectionController.java
  12. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/PhotovoltaicController.java
  13. 0 21
      power-fitting/src/main/java/com/gyee/power/fitting/mapper/ModelpowerMapper.java
  14. 16 0
      power-fitting/src/main/java/com/gyee/power/fitting/mapper/PowerwindinfoMapper.java
  15. 4 4
      power-fitting/src/main/java/com/gyee/power/fitting/model/Equipmentmodel.java
  16. 26 16
      power-fitting/src/main/java/com/gyee/power/fitting/model/Modelpower.java
  17. 0 19
      power-fitting/src/main/java/com/gyee/power/fitting/service/ModelpowerService.java
  18. 2 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/PowermodelService.java
  19. 32 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/PowerwindinfoService.java
  20. 27 11
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/DataFittingService.java
  21. 0 95
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/electricquantity/ElectricQuantityService.java
  22. 50 47
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/fiveloss/FiveLossService.java
  23. 64 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/ratedpower/RatedPowerService.java
  24. 23 21
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/temperature/PowerTemperatureService.java
  25. 97 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/windresource/AvgSpeedInfoService.java
  26. 4 1
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/windresource/RatioService.java
  27. 0 34
      power-fitting/src/main/java/com/gyee/power/fitting/service/impl/ModelpowerServiceImpl.java
  28. 10 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/impl/PowermodelServiceImpl.java
  29. 68 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/impl/PowerwindinfoServiceImpl.java
  30. 20 0
      power-fitting/src/main/resources/mapper/PowerwindinfoMapper.xml

+ 1 - 1
power-fitting/src/main/java/com/gyee/power/fitting/MapperGenerator.java

@@ -27,7 +27,7 @@ public class MapperGenerator {
     //作者
     private static String authorName = "chenmh";
     //要生成的表名
-    private static String[] tables = {"POWERMODEL"};
+    private static String[] tables = {"POWERWINDINFO"};
     //table前缀
     private static String prefix = "";
 

+ 10 - 13
power-fitting/src/main/java/com/gyee/power/fitting/PowerBootApplication.java

@@ -17,7 +17,7 @@ import java.io.File;
  * 禁用springboot默认加载的application.properties单数据源配置
  * 关闭springBoot关于mybatisPlus的一些自动注入
  */
-@EnableAsync
+@EnableAsync(proxyTargetClass = true)
 @EnableCaching
 @EnableScheduling
 @SpringBootApplication
@@ -30,20 +30,17 @@ public class PowerBootApplication {
         createFile();
     }
 
+    /**
+     * 创建数据准备、数据预处理、数据拟合.......目录
+     */
     private static void createFile(){
         GyeeConfig bean = SpringContextUtil.getBean(GyeeConfig.class);
-        File f1 = new File(bean.getFilePathPrepare());
-        File f2 = new File(bean.getFilePathProcess());
-        File f3 = new File(bean.getFilePathFitting());
-        File f4 = new File(bean.getFilePathDownload());
-        if (!f1.exists())
-            f1.mkdirs();
-        if (!f2.exists())
-            f2.mkdirs();
-        if (!f3.exists())
-            f3.mkdirs();
-        if (!f4.exists())
-            f4.mkdirs();
+        String[] fileName = {bean.getFilePathPrepare(), bean.getFilePathProcess(), bean.getFilePathFitting(), bean.getFilePathDownload()};
+        for (String path : fileName){
+            File file = new File(path);
+            if (!file.exists())
+                file.mkdirs();
+        }
     }
 
 }

+ 1 - 1
power-fitting/src/main/java/com/gyee/power/fitting/common/result/ResultCode.java

@@ -21,7 +21,7 @@ public enum ResultCode {
     ERROR_DATA(4006, "数据库操作失败"),
     ERROR_DATA_REPEAT(4007, "数据已存在"),
     ERROR_SQL(4008, "sql语法不正确"),
-    ERROR_MODEL(4009, "同场站不同机型至少启用一个模型"),
+    ERROR_MODEL(4009, "自算功率数据为空"),
 
 
     /* 参数错误:1000~1999 */

+ 34 - 26
power-fitting/src/main/java/com/gyee/power/fitting/common/spring/InitialRunner.java

@@ -4,9 +4,10 @@ import com.gyee.power.fitting.common.config.GyeeConfig;
 import com.gyee.power.fitting.model.*;
 import com.gyee.power.fitting.service.*;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.core.annotation.Order;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
@@ -25,7 +26,7 @@ import java.util.stream.Collectors;
 @Order(1)
 public class InitialRunner implements CommandLineRunner {
 
-    @Autowired
+    @Resource
     GyeeConfig config;
     @Resource
     private WindturbineService windturbineService;
@@ -36,8 +37,6 @@ public class InitialRunner implements CommandLineRunner {
     @Resource
     private EquipmentmodelService equipmentmodelService;
     @Resource
-    private ModelpowerService modelpowerService;
-    @Resource
     private ModelpowerdetailsService modelpowerdetailsService;
     @Resource
     private ProjectService projectService;
@@ -64,13 +63,8 @@ public class InitialRunner implements CommandLineRunner {
      * key:wtId NG01_01
      **/
     public static Map<String, Windturbine> wtMap = new HashMap<>();
-<<<<<<< HEAD
+
     /**场站的风机  key:NSS_FDC**/
-=======
-    /**
-     * 场站的风机
-     **/
->>>>>>> 4d0c049d8a05efec5b002eb76260ecea9cfeb31d
     public static Map<String, List<Windturbine>> wpMap = new HashMap<>();
 
     /**
@@ -115,18 +109,12 @@ public class InitialRunner implements CommandLineRunner {
     @Resource
     private IWindpowerstationtestingpoint2Service windpowerstationtestingpoint2Service;
     public static Map<String, Equipmentmodel> equipmentMap = new HashMap<>();
-
-    /**功率曲线拟合的风速功率点**/
-    /**
-     * key: model  UP82
-     **/
-    public static Map<String, List<Modelpower>> modelPowerMap = new HashMap<>();
     /**
      * key: model  UP82
      **/
     public static Map<String, List<Modelpowerdetails>> modelPowerDetailMap = new HashMap<>();
-    /** key: NG01_01 **/
-    public static Map<String, List<Powermodel>> zsllglMap = new HashMap<>();
+    /** key: NG01_01, speed, power**/
+    public static Map<String, Map<Double, Double>> zsllglMap = new HashMap<>();
 
     @Override
     public void run(String... args) {
@@ -135,11 +123,20 @@ public class InitialRunner implements CommandLineRunner {
         cacheStation();
         cachePoints();
         cacheEquipment();
-        cacheModelPower();
         cacheProject();
         cacheLine();
         cachePhotovoltaicInfo();
 
+        // 耗时缓存
+        new Thread(){
+            @Override
+            public void run() {
+                super.run();
+                cacheModelPower();
+                cacheZSLLGL(null);
+            }
+        }.start();
+
         System.out.println(">>>>>>>>>>>>>>>数据缓存完成<<<<<<<<<<<<<<");
     }
 
@@ -160,13 +157,13 @@ public class InitialRunner implements CommandLineRunner {
         List<Windpowerstation> stations = windpowerstationService.selectList();
         wpList = stations.stream().filter(f -> f.getId().contains("FDC")).collect(Collectors.toList());
         gfwpList = stations.stream().filter(f -> f.getId().contains("GDC")).collect(Collectors.toList());
-        wpList.stream().forEach(obj -> {
+        wpList.forEach(obj -> {
             List<Windturbine> wts = windturbineService.selectList(obj.getId());
             stationMap.put(obj.getId(), obj.getName());
             wpMap.put(obj.getId(), wts);
             wtList.addAll(wts);
 
-            wts.stream().forEach(u -> wtMap.put(u.getId(), u));
+            wts.forEach(u -> wtMap.put(u.getId(), u));
         });
         gfwpList.stream().forEach(obj -> {
             List<Windturbine> wts = windturbineService.selectList(obj.getId());
@@ -176,6 +173,7 @@ public class InitialRunner implements CommandLineRunner {
 
             wts.stream().forEach(u -> gfwtMap.put(u.getId(), u));
         });
+        log.info("场站数据缓存完成");
     }
 
     /**
@@ -185,7 +183,7 @@ public class InitialRunner implements CommandLineRunner {
         List<Windturbinetestingpointai2> list = new ArrayList<>();
         wpList.stream().forEach(d -> list.addAll(pointService.selectList(d.getId(), config.getPoints())));
         pointMap.putAll(list.stream().collect(Collectors.groupingBy(u -> u.getWindturbineid())));
-        System.out.println("cachePoints: " + pointMap.size());
+        log.info("cachePoints: " + pointMap.size());
         if (pointMap.size() == 0)
             log.error("cachePoints", "测点数据缓存失败");
     }
@@ -197,31 +195,41 @@ public class InitialRunner implements CommandLineRunner {
         equipmentList.addAll(equipmentmodelService.selectList());
         for (Equipmentmodel eq : equipmentList)
             equipmentMap.put(eq.getId(), eq);
+        log.info("设备型号数据缓存完成");
     }
 
     private void cacheModelPower() {
-        List<Modelpower> lsMP = modelpowerService.selectList();
         List<Modelpowerdetails> lsMPD = modelpowerdetailsService.selectList();
-        modelPowerMap.putAll(lsMP.stream().collect(Collectors.groupingBy(u -> u.getModelid())));
         modelPowerDetailMap.putAll(lsMPD.stream().collect(Collectors.groupingBy(u -> u.getModelid())));
+        log.info("保证功率数据缓存完成");
     }
 
     private void cacheProject(){
         projectList.addAll(projectService.selectList());
         projectList.forEach(f -> projectMap.put(f.getId(), f));
+        log.info("期次数据缓存完成");
     }
 
     private void cacheLine(){
         lineList.addAll(lineService.selectList());
         lineList.forEach(f -> lineMap.put(f.getId(), f));
+        log.info("线路数据缓存完成");
     }
 
     /**
      * 自算理论功率
      */
     public void cacheZSLLGL(String wtId){
-        List<Powermodel> list = powermodelService.selectByWtId(wtId);
-        zsllglMap.replace(wtId, list);
+        if (StringUtils.isEmpty(wtId)){
+            zsllglMap = powermodelService.selectList().stream()
+                    .collect(Collectors.groupingBy(Powermodel::getWindturbineid,
+                            Collectors.toMap(Powermodel::getSpeed, Powermodel::getPower)));
+        }else{
+            List<Powermodel> list = powermodelService.selectByWtId(wtId);
+            Map<Double, Double> collect = list.stream().collect(Collectors.toMap(Powermodel::getSpeed, Powermodel::getPower));
+            zsllglMap.replace(wtId, collect);
+        }
+        log.info("自算功率数据缓存完成");
     }
 
 }

+ 12 - 3
power-fitting/src/main/java/com/gyee/power/fitting/common/util/DateUtil.java

@@ -9,6 +9,7 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.GregorianCalendar;
 import java.util.TimeZone;
 
 @Slf4j
@@ -522,9 +523,17 @@ public class DateUtil extends DateUtils {
     }
 
 
-    public static void main(String[] args) {
-        System.out.println(getPreviousDate(3 * 360 * 24));
-        System.out.println(covertDateTimestamp("2021-12-30 00:00:00"));
+    /**
+     * 获取去年同一时间
+     * @return
+     */
+
+    public static String getLastYearCurrentDate(String date, String pattern){
+        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(parseStrtoDate(date, pattern));
+        cal.add(Calendar.YEAR, -1);
+        return sdf.format(cal.getTime());
     }
 
     /**

+ 5 - 2
power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/DataFittingController.java

@@ -10,6 +10,7 @@ import com.gyee.power.fitting.service.custom.curve.DataFittingService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
 
@@ -22,7 +23,7 @@ import java.util.Map;
 @RequestMapping("/power/fitting")
 public class DataFittingController {
 
-    @Autowired
+    @Resource
     private DataFittingService fittingService;
 
 
@@ -125,7 +126,9 @@ public class DataFittingController {
     }
 
     /**
-     * 获取多风机的运行时间 统计并网时间  3-5m   5-10m   10-12m   12-25m
+     * 获取多风机的运行时间
+     * 不运行时间  3-5m风速运行时间   5-10m风速运行时间   10-12m风速运行时间   12-25m风速运行时间
+     * 到达切入风速但未运行的时间
      * @param ids  拟合好的数据ID
      * @return
      */

+ 0 - 16
power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/ElectricQuantityController.java

@@ -1,16 +0,0 @@
-package com.gyee.power.fitting.controller.fj;
-
-
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * 电量统计
- */
-
-@RestController
-@CrossOrigin
-@RequestMapping("/dl")
-public class ElectricQuantityController {
-}

+ 5 - 3
power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/FiveLossInfoController.java

@@ -1,6 +1,5 @@
 package com.gyee.power.fitting.controller.fj;
 
-
 import com.alibaba.fastjson.JSONObject;
 import com.gyee.power.fitting.common.result.JsonResult;
 import com.gyee.power.fitting.common.result.ResultCode;
@@ -28,8 +27,11 @@ public class FiveLossInfoController {
 
     @GetMapping("five/loss/cal")
     public JSONObject fiveLossCal(String ids){
-        Map<String, Object> map = fiveLossService.fiveLossCal(ids);
-        return JsonResult.successData(ResultCode.SUCCESS, map);
+        Map<String, Object> map = fiveLossService.fiveLossCalByZSGL(ids);
+        if (map.size() > 0)
+            return JsonResult.successData(ResultCode.SUCCESS, map);
+
+        return JsonResult.error(ResultCode.ERROR_MODEL);
     }
 
 

+ 3 - 2
power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/PowerTemperatureController.java

@@ -8,6 +8,7 @@ import com.gyee.power.fitting.service.custom.temperature.PowerTemperatureService
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import java.util.Map;
 
 /**
@@ -18,11 +19,11 @@ import java.util.Map;
 @RequestMapping("/temperature")
 public class PowerTemperatureController {
 
-    @Autowired
+    @Resource
     private PowerTemperatureService powerTemperatureService;
 
     /***
-     * 与温度有关的定功率
+     * 与温度有关的定功率
      * @param ids  预处理数据的id
      * @return
      */

+ 35 - 0
power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/RatedPowerController.java

@@ -0,0 +1,35 @@
+package com.gyee.power.fitting.controller.fj;
+
+import com.alibaba.fastjson.JSONObject;
+import com.gyee.power.fitting.common.result.JsonResult;
+import com.gyee.power.fitting.common.result.ResultCode;
+import com.gyee.power.fitting.service.custom.ratedpower.RatedPowerService;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+/**
+ * 额定功率分析
+ */
+@RestController
+@CrossOrigin
+@RequestMapping("rated/power")
+public class RatedPowerController {
+
+    @Resource
+    private RatedPowerService ratedPowerService;
+
+    /***
+     * 额定功率分析
+     * @param ids
+     * @return
+     */
+    @GetMapping("")
+    public JSONObject ratedPowerAnalysis(String ids){
+        Object o = ratedPowerService.ratePowerAnalysis(ids);
+        return JsonResult.successData(ResultCode.SUCCESS, o);
+    }
+}

+ 17 - 4
power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/WindDirectionController.java

@@ -1,14 +1,15 @@
 package com.gyee.power.fitting.controller.fj;
 
-
 import com.alibaba.fastjson.JSONObject;
 import com.gyee.power.fitting.common.result.JsonResult;
 import com.gyee.power.fitting.common.result.ResultCode;
+import com.gyee.power.fitting.service.custom.windresource.AvgSpeedInfoService;
 import com.gyee.power.fitting.service.custom.windresource.RatioService;
 import com.gyee.power.fitting.service.custom.windresource.WindDirectionService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 
 /**
  * 风向玫瑰图
@@ -18,10 +19,11 @@ import org.springframework.web.bind.annotation.*;
 @RequestMapping("/wind")
 public class WindDirectionController {
 
-    @Autowired
+    @Resource
     private RatioService ratioService;
-
-    @Autowired
+    @Resource
+    private AvgSpeedInfoService avgSpeedInfoService;
+    @Resource
     private WindDirectionService windDirectionService;
 
     /***
@@ -62,4 +64,15 @@ public class WindDirectionController {
         Object o = ratioService.windDeviationRatio(ids, mode);
         return JsonResult.successData(ResultCode.SUCCESS, o);
     }
+
+    /**
+     * 平均风速及毛容系数
+     * @param ids 预处理数据 ids
+     * @return
+     */
+    @GetMapping("avg/speed")
+    public JSONObject avgSpeedInfo(String ids){
+        Object o = avgSpeedInfoService.avgSpeedInfo(ids);
+        return JsonResult.successData(ResultCode.SUCCESS, o);
+    }
 }

+ 1 - 1
power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/PhotovoltaicController.java

@@ -1,4 +1,4 @@
-package com.gyee.power.fitting.controller.analyse;
+package com.gyee.power.fitting.controller.gf;
 
 import com.alibaba.fastjson.JSONObject;
 import com.gyee.power.fitting.common.result.JsonResult;

+ 0 - 21
power-fitting/src/main/java/com/gyee/power/fitting/mapper/ModelpowerMapper.java

@@ -1,21 +0,0 @@
-package com.gyee.power.fitting.mapper;
-
-import com.gyee.power.fitting.model.Modelpower;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import org.apache.ibatis.annotations.Mapper;
-
-import java.util.List;
-
-/**
- * <p>
- *  Mapper 接口
- * </p>
- *
- * @author chenmh
- * @since 2022-11-08
- */
-@Mapper
-public interface ModelpowerMapper extends BaseMapper<Modelpower> {
-
-    List<Modelpower> selectList();
-}

+ 16 - 0
power-fitting/src/main/java/com/gyee/power/fitting/mapper/PowerwindinfoMapper.java

@@ -0,0 +1,16 @@
+package com.gyee.power.fitting.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.power.fitting.model.Powerwindinfo;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author chenmh
+ * @since 2023-03-03
+ */
+public interface PowerwindinfoMapper extends BaseMapper<Powerwindinfo> {
+
+}

+ 4 - 4
power-fitting/src/main/java/com/gyee/power/fitting/model/Equipmentmodel.java

@@ -36,16 +36,16 @@ public class Equipmentmodel extends Model<Equipmentmodel> {
     private String description;
 
     @TableField("POWERPRODUCTION")
-    private String powerproduction;
+    private Double powerproduction;
 
     @TableField("CUTINWINDSPEED")
-    private String cutinwindspeed;
+    private Double cutinwindspeed;
 
     @TableField("RATEDWINDSPEED")
-    private String ratedwindspeed;
+    private Double ratedwindspeed;
 
     @TableField("CUTOUTWINDSPEED")
-    private String cutoutwindspeed;
+    private Double cutoutwindspeed;
 
     @TableField("WINDTURBINEMANUFACTURERID")
     private String windturbinemanufacturerid;

+ 26 - 16
power-fitting/src/main/java/com/gyee/power/fitting/model/Modelpower.java

@@ -1,47 +1,57 @@
 package com.gyee.power.fitting.model;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableField;
-import java.io.Serializable;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.io.Serializable;
+import java.util.Date;
+
 /**
  * <p>
  * 
  * </p>
  *
  * @author chenmh
- * @since 2022-11-08
+ * @since 2023-03-03
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
-@TableName("MODELPOWER")
-public class Modelpower extends Model<Modelpower> {
+@TableName("POWERWINDINFO")
+public class Powerwindinfo extends Model<Powerwindinfo> {
 
     private static final long serialVersionUID=1L;
 
-      @TableId("ID")
+    @TableField("ID")
     private String id;
 
-    @TableField("MODELID")
-    private String modelid;
+    @TableField("STATION")
+    private String station;
+
+    @TableField("WINDTURBINE")
+    private String windturbine;
 
-    @TableField("SPEED")
-    private String speed;
+    @TableField("TIME")
+    private String time;
 
-    @TableField("THEORYPOWER")
-    private String theorypower;
+    /**
+     * 平均风速
+     */
+    @TableField("AVGSPEED")
+    private Double avgspeed;
 
-    @TableField("ENSUREPOWER")
-    private String ensurepower;
+    /**
+     * 毛容系数
+     */
+    @TableField("MRXS")
+    private Double mrxs;
 
 
     @Override
     protected Serializable pkVal() {
-        return this.id;
+        return null;
     }
 
 }

+ 0 - 19
power-fitting/src/main/java/com/gyee/power/fitting/service/ModelpowerService.java

@@ -1,19 +0,0 @@
-package com.gyee.power.fitting.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.gyee.power.fitting.model.Modelpower;
-
-import java.util.List;
-
-/**
- * <p>
- *  服务类
- * </p>
- *
- * @author chenmh
- * @since 2022-11-08
- */
-public interface ModelpowerService extends IService<Modelpower> {
-
-    List<Modelpower> selectList();
-}

+ 2 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/PowermodelService.java

@@ -20,4 +20,6 @@ public interface PowermodelService extends IService<Powermodel> {
     boolean deleteItem(String wtId);
 
     List<Powermodel> selectByWtId(String wtId);
+
+    List<Powermodel> selectList();
 }

+ 32 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/PowerwindinfoService.java

@@ -0,0 +1,32 @@
+package com.gyee.power.fitting.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.power.fitting.model.Powerwindinfo;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author chenmh
+ * @since 2023-03-03
+ */
+public interface PowerwindinfoService extends IService<Powerwindinfo> {
+
+
+    /**
+     * 通过风机ID和日期查询
+     * @param wtIds
+     * @param dates
+     * @return
+     */
+    List<Powerwindinfo> selectListByWtIdAndTime(String wtId, List<String> dates);
+
+
+    void insertBatch(List<Powerwindinfo> list);
+
+    void deleteBatch(String wtId, List<String> dates);
+}

+ 27 - 11
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/DataFittingService.java

@@ -20,6 +20,7 @@ import com.gyee.power.fitting.service.PowermodelService;
 import lombok.extern.slf4j.Slf4j;
 import lombok.val;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -38,6 +39,8 @@ public class DataFittingService {
     @Resource
     private GyeeConfig config;
     @Resource
+    private InitialRunner initialRunner;
+    @Resource
     private PowermodelService modelService;
     @Resource
     private DataScanService dataScanService;
@@ -474,21 +477,23 @@ public class DataFittingService {
 
         list.forEach(item -> {
             Map<String, Object> map = new HashMap<>();
-            int[] time = new int[5];  //不运行 3-5m   5-10m   10-12m  12-25m(全功率)
+            int[] time1 = new int[5];  //0:不运行 1:3-5m   2:5-10m   3:10-12m  4:12-25m(全功率)
+            int[] time2 = new int[4];  //0:3-5m   1:5-10m   2:10-12m  3:12-25m(全功率)
             String[] split = item.getProcessid().split(",");//数据准备ID,获取文件
             for (String id : split){
                 List<String> line = FileUtil.readFile(powerService.getById(id).getPath(), true);
-                timeTotal(time, line);
+                timeTotal(time1, time2, line);
             }
             map.put("wtId", item.getWindturbine());
-            map.put("time", time);
+            map.put("time1", time1);
+            map.put("time2", time2);
             result.add(map);
         });
 
         return result;
     }
 
-    private void timeTotal(int[] time, List<String> line){
+    private void timeTotal(int[] time1, int[] time2, List<String> line){
         List<PowerPointData> list = new ArrayList<>();
         double interval = DateUtil.getTimeDiff(line.get(1).split(",")[0], line.get(2).split(",")[0]); //两条数据的间隔时间
         for (int i = 1; i < line.size(); i++){
@@ -496,15 +501,24 @@ public class DataFittingService {
         }
         for (PowerPointData item : list){
             if (item.getMxzt() != 2)
-                time[0] += interval;
+                time1[0] += interval;
             if (item.getSpeed() >= 3.0 && item.getSpeed() < 5.0 && item.getMxzt() == 2)
-                time[1] += interval;
+                time1[1] += interval;
             if (item.getSpeed() >= 5.0 && item.getSpeed() < 10.0 && item.getMxzt() == 2)
-                time[2] += interval;
+                time1[2] += interval;
             if (item.getSpeed() >= 10.0 && item.getSpeed() < 12.0 && item.getMxzt() == 2)
-                time[3] += interval;
+                time1[3] += interval;
             if (item.getSpeed() >= 12.0 && item.getSpeed() <= 25.0 && item.getMxzt() == 2)
-                time[4] += interval;
+                time1[4] += interval;
+
+            if (item.getSpeed() >= 3.0 && item.getSpeed() < 5.0 && item.getMxzt() != 2)
+                time2[0] += interval;
+            if (item.getSpeed() >= 5.0 && item.getSpeed() < 10.0 && item.getMxzt() != 2)
+                time2[1] += interval;
+            if (item.getSpeed() >= 10.0 && item.getSpeed() < 12.0 && item.getMxzt() != 2)
+                time2[2] += interval;
+            if (item.getSpeed() >= 12.0 && item.getSpeed() <= 25.0 && item.getMxzt() != 2)
+                time2[3] += interval;
         }
     }
 
@@ -512,6 +526,7 @@ public class DataFittingService {
      * 通过拟合的id保存理论功率
      * @param ids
      */
+    @Async
     public void curveSave(String ids) {
         List<Powerfittinganalysis> list = powerService.selectListByIds(ids);
         if (list.size() == 0)
@@ -526,12 +541,13 @@ public class DataFittingService {
                     Powermodel obj = new Powermodel();
                     obj.setWindturbineid(f.getWindturbine());
                     obj.setModel(InitialRunner.wtMap.get(f.getWindturbine()).getModelid());
-                    obj.setSpeed(new BigDecimal(split[0]).setScale(2, RoundingMode.CEILING).doubleValue());
-                    obj.setPower(new BigDecimal(split[1]).setScale(2, RoundingMode.CEILING).doubleValue());
+                    obj.setSpeed(new BigDecimal(split[0]).setScale(2, RoundingMode.FLOOR).doubleValue());
+                    obj.setPower(new BigDecimal(split[1]).setScale(2, RoundingMode.FLOOR).doubleValue());
                     result.add(obj);
                 }
                 modelService.deleteItem(f.getWindturbine());
                 modelService.insertBatch(result);
+                initialRunner.cacheZSLLGL(f.getWindturbine());
             }catch (Exception e){
                 log.error(e.getMessage());
             }

+ 0 - 95
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/electricquantity/ElectricQuantityService.java

@@ -1,95 +0,0 @@
-package com.gyee.power.fitting.service.custom.electricquantity;
-
-
-import com.gyee.power.fitting.common.util.FileUtil;
-import com.gyee.power.fitting.model.Powerfittinganalysis;
-import com.gyee.power.fitting.model.custom.PowerPointData;
-import com.gyee.power.fitting.service.PowerfittinganalysisService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@Service
-public class ElectricQuantityService {
-
-    @Autowired
-    private PowerfittinganalysisService powerService;
-
-
-    /**
-     * 电量统计(包含发电量和损失电量)
-     * @param ids
-     * @return
-     */
-    public Object dlLosses(String ids){
-        List<Powerfittinganalysis> list = powerService.selectListByIds(ids);
-        if (list == null || list.size() == 0)
-            return null;
-
-        List<Object> result = new ArrayList<>();
-//        for (Powerfittinganalysis obj : list) {
-//            List<PowerPointData> ls = csvParse(obj);
-//
-//        }
-
-        return null;
-    }
-
-
-    /**
-     * csv 文件解析成对象
-     * @param obj
-     * @return
-     */
-    private List<PowerPointData> csvParse(Powerfittinganalysis obj){
-        List<PowerPointData> ls = new ArrayList<>();
-        List<String> content = FileUtil.readFile(obj.getPath(), true);
-        for (int i = 1; i < content.size(); i++){
-            String[] split = content.get(i).split(",");
-            PowerPointData data = new PowerPointData(split, true);
-            ls.add(data);
-        }
-
-        return ls;
-    }
-
-
-    //0-待机
-    //1-手动停机
-    //2-正常发电
-    //3-缺陷降出力
-    //4-限电降出力
-    //5-限电停机
-    //6-故障停机
-    //7-场内受累停机
-    //8-检修停机
-    //9-场内受累检修
-    //10-电网受累
-    //11-环境受累
-    //12-风机离
-    private void calLosses(List<PowerPointData> datas){
-        if (datas == null || datas.size() == 0)
-            return;
-
-        int zt = 0;
-        double fdl = 0;
-        double gzss = 0;
-        double jxss = 0;
-        double xnss = 0;
-        double xdss = 0;
-        double slss = 0;
-        for (int i = 0; i < datas.size() - 1; i++) {
-            PowerPointData obj = datas.get(i);
-            PowerPointData obj2 = datas.get(i + 1);
-            if (obj2.getMxzt() == 2)
-//                fdl += ((obj2.getDl() - obj.getDl() > 0 ? );
-            if (obj2.getMxzt() == 2)
-                fdl += obj2.getDl();
-        }
-    }
-
-}

+ 50 - 47
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/fiveloss/FiveLossService.java

@@ -118,7 +118,7 @@ public class FiveLossService {
     public void fiveLossCal() {
         log.info("======风机绩效榜计算开始.............");
         Map<String, Windturbine> wtmap = InitialRunner.wtMap;
-        Map<String, List<Powermodel>> modelmap = InitialRunner.zsllglMap;
+        Map<String, Map<Double, Double>> zsglmap = InitialRunner.zsllglMap;
 
         List<Powerfittinganalysis> analyses = analysisService.selectListByIsCal(Constants.DATA_PREPARE, 0);
         if (analyses.size() == 0){
@@ -149,17 +149,17 @@ public class FiveLossService {
                 double xnssdl = 0;//性能损失电量
 
                 List<PowerPointData> pdl = ls.stream().map(mp -> new PowerPointData(mp.split(","), false)).collect(Collectors.toList());
-                double zcfd = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 2); //正常发电
-                xdssdl = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 5);  //限电损失电量
-                double qxjcl = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 3); //缺陷降出力损失电量
-                double xdjcl = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 4); //限电降出力损失电量
-                double cnsltj = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 7); //场内受累停机损失电量
-                double cnsljx = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 9); //场内受累检修损失电量
-                double dwsl = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 10); //电网受累损失电量
-                double hjsl = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 11); //环境受累损失电量
-
-                gzssdl = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 6);
-                jhjxssdl = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 8);
+                double zcfd = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 2); //正常发电
+                xdssdl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 5);  //限电损失电量
+                double qxjcl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 3); //缺陷降出力损失电量
+                double xdjcl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 4); //限电降出力损失电量
+                double cnsltj = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 7); //场内受累停机损失电量
+                double cnsljx = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 9); //场内受累检修损失电量
+                double dwsl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 10); //电网受累损失电量
+                double hjsl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 11); //环境受累损失电量
+
+                gzssdl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 6);
+                jhjxssdl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 8);
                 fjhjxssdl = gzssdl;
                 xdssdl = xdssdl + xdjcl;
                 slssdl = cnsltj + dwsl + hjsl + cnsljx + cnsljx;
@@ -205,31 +205,32 @@ public class FiveLossService {
      * @param status   风机当前状态
      * @return
      */
-    private double generalLoss(List<PowerPointData> ztmxData, List<Powermodel> zsglData, int interval, double status) {
+    private double generalLoss(List<PowerPointData> ztmxData, Map<Double, Double> zsglData, int interval, double status) {
         double ssdl = 0.0;
         List<PowerPointData> pointData = ztmxData.stream().filter(zt -> zt.getMxzt() == status).collect(Collectors.toList());
-        List<Powermodel> theoryData = zsglData.stream().filter(f -> f.getPower() > 0.0).collect(Collectors.toList());
-        if (status == 0.0 || status == 2.0 || status == 3.0 || status == 4.0 || status == 9.0 || status == 11.0) {
+        if (status == 0.0 || status == 2.0 || status == 3.0 || status == 4.0 || status == 9.0 || status == 10.0 || status == 11.0) {
             for (PowerPointData obj : pointData) {
-                for (int i = 0; i < theoryData.size(); i++) {
-                    if (String.format("%.2f", obj.getSpeed()).equals(String.format("%.2f", theoryData.get(i).getSpeed()))) {
-                        double zsgl = theoryData.get(i).getPower();
-                        double power = obj.getPower();
-                        double temp = (zsgl - power) > 0 ? zsgl - power : 0;
-                        ssdl = ssdl + (temp / 60) * (interval / 60);
-                        break;
-                    }
-                }
+                double speed = new BigDecimal(obj.getSpeed()).setScale(2, RoundingMode.FLOOR).doubleValue();
+                double zsgl = zsglData.get(speed);
+                double power = obj.getPower();
+                double temp = (zsgl - power) > 0 ? zsgl - power : 0;
+                ssdl = ssdl + (temp / 60) * (interval / 60);
             }
         } else {
             for (PowerPointData obj : pointData) {
-                for (int i = 0; i < theoryData.size(); i++) {
-                    if (String.format("%.2f", obj.getSpeed()).equals(String.format("%.2f", theoryData.get(i).getSpeed()))) {
-                        double zsgl = theoryData.get(i).getPower();
-                        ssdl = ssdl + (zsgl / 60) * (interval / 60);
-                        break;
-                    }
-                }
+                if (obj.getSpeed() < 3.0) continue;
+                double speed = new BigDecimal(obj.getSpeed()).setScale(2, RoundingMode.FLOOR).doubleValue();
+                double zsgl = zsglData.get(speed);
+                ssdl = ssdl + (zsgl / 60) * (interval / 60);
+            }
+        }
+        //理论发电量 status < 0
+        if (status < 0){
+            for (PowerPointData obj : ztmxData) {
+                if (obj.getSpeed() < 3.0) continue;
+                double speed = new BigDecimal(obj.getSpeed()).setScale(2, RoundingMode.FLOOR).doubleValue();
+                double zsgl = zsglData.get(speed);
+                ssdl = ssdl + (zsgl / 60) * (interval / 60);
             }
         }
 
@@ -348,25 +349,25 @@ public class FiveLossService {
     }
 
     /**
-     * 使用文件计算五损数据
+     * 使用文件,通过自诉案功率计算五损数据
      * @param ids  准备的数据ID
      */
-    public Map<String, Object> fiveLossCal(String ids) {
+    public Map<String, Object> fiveLossCalByZSGL(String ids) {
         log.info("======风机绩效榜计算开始.............");
         Map<String, Object> promise = new HashMap<>();
         List<FjjxbVo> result = new ArrayList<>();
-        Map<String, List<Powermodel>> zsglmap = InitialRunner.zsllglMap;
+        Map<String, Map<Double, Double>> zsglmap = InitialRunner.zsllglMap;
 
         List<Powerfittinganalysis> analyses = analysisService.selectListByIds(ids);
-        if (analyses.size() == 0 || zsglmap.size() == 0){
-            log.info("======风机榜效帮计算结束,自算理论功率数据为空.............");
+        if (analyses.size() == 0){
+            log.info("======风机榜效帮计算结束,数据为空.............");
             throw new CustomException(ResultCode.ERROR);
         }
 
         for (Powerfittinganalysis p : analyses) {
             List<String> content = FileUtil.readFile(p.getPath(), true);
-            if (content.size() == 0){
-                log.info("======风机榜效帮计算结束,文件内容为空.............");
+            if (content.size() == 0 || zsglmap.size() == 0 || zsglmap.get(p.getWindturbine()) == null){
+                log.info("======风机榜效帮计算结束," + p.getWindturbine() + "文件内容或当前风机的自算功率为空.............");
                 continue;
             }
             log.info("======风机绩效榜计算:" + p.getWindturbine());
@@ -409,18 +410,19 @@ public class FiveLossService {
             FjjxbVo vo = new FjjxbVo();
             vo.setId(p.getWindturbine());
             vo.setName(p.getWindturbine());
-            vo.setLlfdl(llfdl);
-            vo.setSjfdl(rfdl);
-            vo.setJhjx(jhjxssdl);
-            vo.setFjhjx(fjhjxssdl);
-            vo.setXd(xdssdl);
-            vo.setXn(xnssdl);
-            vo.setSl(slssdl);
-            vo.setSpeed(new BigDecimal(speed/content.size()).setScale(2, RoundingMode.CEILING).doubleValue());
-            vo.setFnlly(llfdl > 0 ? new BigDecimal(rfdl / llfdl).setScale(2, RoundingMode.CEILING).doubleValue() : 0);
+            vo.setLlfdl(new BigDecimal(llfdl).setScale(2, RoundingMode.FLOOR).doubleValue());
+            vo.setSjfdl(new BigDecimal(rfdl).setScale(2, RoundingMode.FLOOR).doubleValue());
+            vo.setJhjx(new BigDecimal(jhjxssdl).setScale(2, RoundingMode.FLOOR).doubleValue());
+            vo.setFjhjx(new BigDecimal(fjhjxssdl).setScale(2, RoundingMode.FLOOR).doubleValue());
+            vo.setXd(new BigDecimal(xdssdl).setScale(2, RoundingMode.FLOOR).doubleValue());
+            vo.setXn(new BigDecimal(xnssdl).setScale(2, RoundingMode.FLOOR).doubleValue());
+            vo.setSl(new BigDecimal(slssdl).setScale(2, RoundingMode.FLOOR).doubleValue());
+            vo.setSpeed(new BigDecimal(speed/content.size()).setScale(2, RoundingMode.FLOOR).doubleValue());
+            vo.setFnlly(llfdl > 0 ? new BigDecimal(rfdl / llfdl).setScale(2, RoundingMode.FLOOR).doubleValue() : 0);
             result.add(vo);
         }
         log.info("======风机榜效帮计算结束.............");
+        result.stream().sorted(Comparator.comparing(FjjxbVo::getId));
         /** 添加标题 **/
         List<FixedVo> fxList = AnnotationTool.getFixedVoList(FjjxbVo.class);
         List<TableTitle> lt = fxList.stream().map(d -> new TableTitle(d.getName(), d.getDes())).collect(Collectors.toList());
@@ -429,4 +431,5 @@ public class FiveLossService {
 
         return promise;
     }
+    
 }

+ 64 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/ratedpower/RatedPowerService.java

@@ -0,0 +1,64 @@
+package com.gyee.power.fitting.service.custom.ratedpower;
+
+import com.gyee.power.fitting.common.util.FileUtil;
+import com.gyee.power.fitting.model.Powerfittinganalysis;
+import com.gyee.power.fitting.model.custom.PowerPointData;
+import com.gyee.power.fitting.service.PowerfittinganalysisService;
+import lombok.val;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 额定功率分析
+ * 风机在12-25m风速之间、风机小于额定功率的分析数据
+ */
+@Service
+public class RatedPowerService {
+
+    @Resource
+    private PowerfittinganalysisService powerService;
+
+    public Object ratePowerAnalysis(String ids) {
+        Map<String, Object> result = new HashMap<>();
+        List<Powerfittinganalysis> list = powerService.selectListByIds(ids);
+        if (list == null || list.size() == 0)
+            return result;
+
+        List<PowerPointData> all = new ArrayList<>();
+        Map<String, Double> map = new HashMap<>();
+        for (Powerfittinganalysis obj : list){
+            List<PowerPointData> ls = csvParse(obj);
+            all.addAll(ls);
+            map.put(obj.getWindturbine(), ls.stream().mapToDouble(PowerPointData::getPower).average().getAsDouble());
+        }
+        double avgData = all.stream().mapToDouble(PowerPointData::getPower).average().getAsDouble();
+
+        result.put("avg", avgData);
+        result.put("data", map);
+
+        return result;
+    }
+
+    /**
+     * csv 文件解析成对象
+     * @param obj
+     * @return
+     */
+    private List<PowerPointData> csvParse(Powerfittinganalysis obj){
+        List<PowerPointData> list = new ArrayList<>();
+        val content = FileUtil.readFile(obj.getPath(), true);
+        for (int i = 1; i < content.size(); i++){
+            String[] split = content.get(i).split(",");
+            PowerPointData data = new PowerPointData(split, false);
+            if (data.getSpeed() >= 12.0)
+                list.add(data);
+        }
+
+        return list;
+    }
+}

+ 23 - 21
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/temperature/PowerTemperatureService.java

@@ -9,9 +9,9 @@ import com.gyee.power.fitting.model.anno.AnnotationTool;
 import com.gyee.power.fitting.model.anno.FixedVo;
 import com.gyee.power.fitting.model.custom.*;
 import com.gyee.power.fitting.service.PowerfittinganalysisService;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -19,7 +19,7 @@ import java.util.stream.Collectors;
 @Service
 public class PowerTemperatureService {
 
-    @Autowired
+    @Resource
     private PowerfittinganalysisService powerService;
 
     /**
@@ -27,25 +27,29 @@ public class PowerTemperatureService {
      * @param ids
      */
     public Object ratedPower(String ids) {
+        List<Object> result = new ArrayList<>();
         List<Powerfittinganalysis> list = powerService.selectListByIds(ids);
         if (list == null || list.size() == 0)
-            return null;
+            return result;
 
-        List<Object> result = new ArrayList<>();
         for (Powerfittinganalysis obj : list){
-            List<Modelpowerdetails> ls = InitialRunner.modelPowerDetailMap.get(InitialRunner.wtMap.get(obj.getWindturbine()).getModelid());
-            Double theoryPower = ls.get(ls.size() - 1).getTheorypower(); //理论功率
-            Map<String, Object> map = csvParse(obj);//数据解析
-            List<PowerPointData> data = (List<PowerPointData>) map.get("data");
-            Object res = PowerTemperatureAlg.temperatureRatedPower(data, theoryPower, (Double) map.get("minT"), (Double) map.get("maxT"));
-            List<int[]> rp = PowerTemperatureAlg.temperatureRatedPower(data);
-
-            Map<String, Object> mp = new HashMap<>();
-            mp.put("wt", obj.getWindturbine());
-            mp.put("power", InitialRunner.equipmentMap.get(InitialRunner.wtMap.get(obj.getWindturbine()).getModelid()));
-            mp.put("res1", res); //额定功率vs.温度分析
-            mp.put("res2", rp);  //额定功率vs.温度分析
-            result.add(mp);
+            String[] pids = obj.getProcessid().split(",");
+            for (String id : pids){
+                Powerfittinganalysis pf = powerService.selectItemById(id);
+                List<Modelpowerdetails> ls = InitialRunner.modelPowerDetailMap.get(InitialRunner.wtMap.get(obj.getWindturbine()).getModelid());
+                Double theoryPower = ls.get(ls.size() - 1).getTheorypower(); //理论功率
+                Map<String, Object> map = csvParse(pf);//数据解析
+                List<PowerPointData> data = (List<PowerPointData>) map.get("data");
+                Object res = PowerTemperatureAlg.temperatureRatedPower(data, theoryPower, (Double) map.get("minT"), (Double) map.get("maxT"));
+                List<int[]> rp = PowerTemperatureAlg.temperatureRatedPower(data);
+
+                Map<String, Object> mp = new HashMap<>();
+                mp.put("wt", pf.getWindturbine());
+                mp.put("power", InitialRunner.equipmentMap.get(InitialRunner.wtMap.get(pf.getWindturbine()).getModelid()));
+                mp.put("res1", res); //额定功率vs.温度分析
+                mp.put("res2", rp);  //额定功率vs.温度分析
+                result.add(mp);
+            }
         }
 
         return result;
@@ -53,11 +57,10 @@ public class PowerTemperatureService {
 
 
     public Object curveAnalysis(String id) {
+        Map<String, Object> map = new HashMap<>();
         Powerfittinganalysis obj = powerService.selectItemById(id);
         if (obj == null)
-            return null;
-
-        Map<String, Object> map = new HashMap<>();
+            return map;
 
         //实际功率
         List<Object> sjglList = new ArrayList<>();
@@ -70,7 +73,6 @@ public class PowerTemperatureService {
         //保证功率
         List<Modelpowerdetails> modelPower = InitialRunner.modelPowerDetailMap.get(InitialRunner.wtMap.get(obj.getWindturbine()).getModelid());
         List<Object> bzglList = modelPower.stream().sorted(Comparator.comparing(Modelpowerdetails::getSpeed)).map(m -> new double[]{m.getSpeed(), m.getEnsurepower()}).collect(Collectors.toList());
-
         //散点
         List<Object[]> scatter = new ArrayList<>();
 

+ 97 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/windresource/AvgSpeedInfoService.java

@@ -0,0 +1,97 @@
+package com.gyee.power.fitting.service.custom.windresource;
+
+
+import com.gyee.power.fitting.common.spring.InitialRunner;
+import com.gyee.power.fitting.common.util.DateUtil;
+import com.gyee.power.fitting.common.util.FileUtil;
+import com.gyee.power.fitting.model.Equipmentmodel;
+import com.gyee.power.fitting.model.Powerfittinganalysis;
+import com.gyee.power.fitting.model.Powerwindinfo;
+import com.gyee.power.fitting.model.Windturbine;
+import com.gyee.power.fitting.model.custom.PowerPointData;
+import com.gyee.power.fitting.service.PowerfittinganalysisService;
+import com.gyee.power.fitting.service.PowerwindinfoService;
+import lombok.val;
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 平均风速、毛容系数
+ */
+@Service
+public class AvgSpeedInfoService {
+
+    @Resource
+    private PowerwindinfoService windInfoService;
+    @Resource
+    private PowerfittinganalysisService powerService;
+
+    /**
+     * 平均风速、毛容系数
+     */
+    public Object avgSpeedInfo(String ids){
+        List<Object> result = new ArrayList<>();
+        Map<String, Equipmentmodel> eqMap = InitialRunner.equipmentMap;
+        Map<String, Windturbine> wtMap = InitialRunner.wtMap;
+        List<Powerfittinganalysis> listObj = powerService.selectListByIds(ids);
+        if (listObj == null || listObj.size() == 0)
+            return result;
+
+        for (Powerfittinganalysis obj : listObj){
+            TreeMap<String, Object> map = new TreeMap<>();
+            List<Powerwindinfo> currentList = new ArrayList<>();
+            List<PowerPointData> ls = csvParse(obj);
+            Map<String, List<PowerPointData>> collect = ls.stream().collect(Collectors.groupingBy(PowerPointData::getTime));
+            collect.forEach((k, v) -> {
+                Powerwindinfo info = new Powerwindinfo();
+                info.setStation(obj.getStation());
+                info.setWindturbine(obj.getWindturbine());
+                info.setTime(DateUtil.format(k, DateUtil.DATE_PATTERN));
+                double speed = v.stream().mapToDouble(PowerPointData::getSpeed).average().getAsDouble();
+                //毛容系数=生产电量(MWh)/ (风机容量MW * 总时间(h))
+                double mrxs = (v.get(v.size() - 1).getDl() / 1000) / (eqMap.get(wtMap.get(obj.getWindturbine()).getModelid()).getPowerproduction() / 1000 * 24);
+                info.setAvgspeed(new BigDecimal(speed).setScale(2, RoundingMode.FLOOR).doubleValue());
+                info.setMrxs(new BigDecimal(mrxs).setScale(4, RoundingMode.FLOOR).doubleValue());
+                currentList.add(info);
+            });
+            // 删除已有数据同时保存新数据
+            List<String> dates = currentList.stream().map(m -> m.getTime()).collect(Collectors.toList());
+            windInfoService.deleteBatch(obj.getWindturbine(), dates);
+            windInfoService.insertBatch(currentList);
+
+            //同期数据
+            List<String> preDate = dates.stream().map(f -> DateUtil.getLastYearCurrentDate(f, DateUtil.DATE_PATTERN)).collect(Collectors.toList());
+            List<Powerwindinfo> preList = windInfoService.selectListByWtIdAndTime(obj.getWindturbine(), preDate);
+
+            map.put("wtId", obj.getWindturbine());
+            map.put("currentData", currentList);
+            map.put("preData", preList);
+
+            result.add(map);
+        }
+
+        return result;
+    }
+
+    /**
+     * csv 文件解析成对象
+     * @param obj
+     * @return
+     */
+    private List<PowerPointData> csvParse(Powerfittinganalysis obj){
+        List<PowerPointData> list = new ArrayList<>();
+        val content = FileUtil.readFile(obj.getPath(), true);
+        for (int i = 1; i < content.size(); i++){
+            String[] split = content.get(i).split(",");
+            PowerPointData data = new PowerPointData(split, false);
+            data.setTime(DateUtil.format(data.getTime(), DateUtil.DATE_PATTERN));
+            list.add(data);
+        }
+
+        return list;
+    }
+}

+ 4 - 1
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/windresource/RatioService.java

@@ -1,7 +1,6 @@
 package com.gyee.power.fitting.service.custom.windresource;
 
 
-import com.gyee.power.fitting.common.alg.PowerFittingALG;
 import com.gyee.power.fitting.common.alg.WindDirectionALG;
 import com.gyee.power.fitting.common.util.FileUtil;
 import com.gyee.power.fitting.model.Powerfittinganalysis;
@@ -16,6 +15,10 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+
+/**
+ * 对风偏差分析
+ */
 @Service
 public class RatioService {
 

+ 0 - 34
power-fitting/src/main/java/com/gyee/power/fitting/service/impl/ModelpowerServiceImpl.java

@@ -1,34 +0,0 @@
-package com.gyee.power.fitting.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.gyee.power.fitting.mapper.ModelpowerMapper;
-import com.gyee.power.fitting.model.Modelpower;
-import com.gyee.power.fitting.service.ModelpowerService;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * <p>
- *  服务实现类
- * </p>
- *
- * @author chenmh
- * @since 2022-11-08
- */
-@Service
-public class ModelpowerServiceImpl extends ServiceImpl<ModelpowerMapper, Modelpower> implements ModelpowerService {
-
-    @Override
-    public List<Modelpower> selectList() {
-        List<Modelpower> list = new ArrayList<>();
-        try{
-            list = baseMapper.selectList(null);
-        }catch (Exception e){
-            log.error("ModelpowerServiceImpl--selectList", e);
-        }
-
-        return list;
-    }
-}

+ 10 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/impl/PowermodelServiceImpl.java

@@ -63,4 +63,14 @@ public class PowermodelServiceImpl extends ServiceImpl<PowermodelMapper, Powermo
         }
         return Collections.EMPTY_LIST;
     }
+
+    @Override
+    public List<Powermodel> selectList() {
+        try{
+            return baseMapper.selectList(null);
+        }catch (Exception e){
+            log.error("PowermodelServiceImpl--selectList", e);
+        }
+        return Collections.EMPTY_LIST;
+    }
 }

+ 68 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/impl/PowerwindinfoServiceImpl.java

@@ -0,0 +1,68 @@
+package com.gyee.power.fitting.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.power.fitting.common.base.ExcludeQueryWrapper;
+import com.gyee.power.fitting.common.util.CollectUtil;
+import com.gyee.power.fitting.common.util.SnowFlakeUtil;
+import com.gyee.power.fitting.mapper.PowerwindinfoMapper;
+import com.gyee.power.fitting.model.Powerlossinfo;
+import com.gyee.power.fitting.model.Powerwindinfo;
+import com.gyee.power.fitting.service.PowerwindinfoService;
+import org.springframework.stereotype.Service;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author chenmh
+ * @since 2023-03-03
+ */
+@Service
+public class PowerwindinfoServiceImpl extends ServiceImpl<PowerwindinfoMapper, Powerwindinfo> implements PowerwindinfoService {
+
+    @Override
+    public List<Powerwindinfo> selectListByWtIdAndTime(String wtIds, List<String> dates) {
+        ExcludeQueryWrapper<Powerwindinfo> wrapper = new ExcludeQueryWrapper<>();
+        wrapper.eq("windturbine", wtIds)
+                .in("time", dates);
+        try{
+            return baseMapper.selectList(wrapper);
+        } catch (Exception e){
+            log.error("PowerwindinfoServiceImpl--selectListByWtIdAndTime", e);
+        }
+        return Collections.EMPTY_LIST;
+    }
+
+    @Override
+    public void insertBatch(List<Powerwindinfo> list) {
+        list.forEach(item -> item.setId(SnowFlakeUtil.generateId()));
+        try{
+            if (list.size() > 1000){
+                List<List<Powerwindinfo>> coll = CollectUtil.groupListByQty(list, 1000);
+                coll.forEach(ls -> saveBatch(ls));
+            } else {
+                saveBatch(list);
+            }
+        }catch (Exception e){
+            log.error("PowerwindinfoServiceImpl--insertBatch", e);
+        }
+    }
+
+    @Override
+    public void deleteBatch(String wtId, List<String> dates) {
+        QueryWrapper<Powerwindinfo> wrapper = new QueryWrapper<>();
+        wrapper.eq("windturbine", wtId);
+        wrapper.in("time", dates);
+        try{
+            baseMapper.delete(wrapper);
+        }catch (Exception e){
+            log.error("PowerwindinfoServiceImpl--deleteBatch", e);
+        }
+    }
+}

+ 20 - 0
power-fitting/src/main/resources/mapper/PowerwindinfoMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.gyee.power.fitting.mapper.PowerwindinfoMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.gyee.power.fitting.model.Powerwindinfo">
+        <result column="ID" property="id" />
+        <result column="STATION" property="station" />
+        <result column="WINDTURBINE" property="windturbine" />
+        <result column="TIME" property="time" />
+        <result column="AVGSPEED" property="avgspeed" />
+        <result column="MRXS" property="mrxs" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        ID, STATION, WINDTURBINE, TIME, AVGSPEED, MRXS
+    </sql>
+
+</mapper>