Browse Source

Merge remote-tracking branch 'origin/master'

宁檬 1 year ago
parent
commit
1ef1bdf313
62 changed files with 1794 additions and 184 deletions
  1. 12 12
      benchmarking-impala/src/main/java/com/gyee/benchmarkingimpala/service/BenchmarkingService.java
  2. 2 10
      benchmarking-impala/src/main/java/com/gyee/benchmarkingimpala/task/SaticScheduleTask.java
  3. 11 1
      gradeevaluation/src/main/java/com/gyee/gradeevaluation/service/bigscreen/BigScreenService.java
  4. 4 0
      gradeevaluation/src/main/java/com/gyee/gradeevaluation/variable/MainConstant.java
  5. 5 1
      gyee-sample-impala/pom.xml
  6. 1 1
      gyee-sample-impala/src/main/java/com/gyee/impala/common/config/datasource/KuduDataSourceConfig.java
  7. 1 1
      gyee-sample-impala/src/main/java/com/gyee/impala/common/config/datasource/SlaveDataSourceConfig.java
  8. 0 1
      gyee-sample-impala/src/main/java/com/gyee/impala/common/feign/RemoteServiceBuilder.java
  9. 1 1
      gyee-sample-impala/src/main/java/com/gyee/impala/controller/diagnose/HostparamController.java
  10. 1 2
      gyee-sample-impala/src/main/java/com/gyee/impala/schdule/TaskStatistic.java
  11. 2 3
      gyee-sample-impala/src/main/java/com/gyee/impala/schdule/TaskWeather.java
  12. 2 3
      gyee-sample-impala/src/main/java/com/gyee/impala/schdule/TaskWindspeedForecast.java
  13. 1 0
      gyee-sample-impala/src/main/java/com/gyee/impala/service/custom/diagnose/AutoCmdService.java
  14. 35 28
      gyee-sample-impala/src/main/java/com/gyee/impala/service/impl/master/WindspeedforecastshorttermServiceImpl.java
  15. 12 31
      gyee-sample-impala/src/main/resources/application.yaml
  16. 2 0
      power-fitting/src/main/java/com/gyee/power/fitting/PowerBootApplication.java
  17. 9 0
      power-fitting/src/main/java/com/gyee/power/fitting/common/alg/CurveFitting.java
  18. 0 19
      power-fitting/src/main/java/com/gyee/power/fitting/common/alg/MpptFittingAlg.java
  19. 180 0
      power-fitting/src/main/java/com/gyee/power/fitting/common/alg/PolynomialCurveFitting.java
  20. 3 4
      power-fitting/src/main/java/com/gyee/power/fitting/common/alg/PowerFittingALG.java
  21. 78 0
      power-fitting/src/main/java/com/gyee/power/fitting/common/alg/PowerTemperatureAlg.java
  22. 22 0
      power-fitting/src/main/java/com/gyee/power/fitting/common/alg/TimeCostCalculator.java
  23. 6 4
      power-fitting/src/main/java/com/gyee/power/fitting/common/alg/WindDirectionALG.java
  24. 11 1
      power-fitting/src/main/java/com/gyee/power/fitting/common/feign/IAdapterService.java
  25. 360 0
      power-fitting/src/main/java/com/gyee/power/fitting/common/util/DateUtils.java
  26. 32 0
      power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/PowerTemperatureController.java
  27. 0 33
      power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/RatioController.java
  28. 18 1
      power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/WindDirectionController.java
  29. 23 0
      power-fitting/src/main/java/com/gyee/power/fitting/controller/base/CurveFittingController.java
  30. 16 0
      power-fitting/src/main/java/com/gyee/power/fitting/mapper/PhotovoltaiccapacityMapper.java
  31. 18 0
      power-fitting/src/main/java/com/gyee/power/fitting/mapper/PhotovoltaicivMapper.java
  32. 18 0
      power-fitting/src/main/java/com/gyee/power/fitting/mapper/Windpowerstationtestingpoint2Mapper.java
  33. 78 0
      power-fitting/src/main/java/com/gyee/power/fitting/model/Photovoltaiccapacity.java
  34. 77 0
      power-fitting/src/main/java/com/gyee/power/fitting/model/Photovoltaiciv.java
  35. 199 0
      power-fitting/src/main/java/com/gyee/power/fitting/model/Windpowerstationtestingpoint2.java
  36. 5 1
      power-fitting/src/main/java/com/gyee/power/fitting/model/custom/PowerPointData.java
  37. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/service/EquipmentmodelService.java
  38. 16 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/IPhotovoltaiccapacityService.java
  39. 16 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/IPhotovoltaicivService.java
  40. 17 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/IWindpowerstationtestingpoint2Service.java
  41. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/service/ModelpowerService.java
  42. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/service/ModelpowerdetailsService.java
  43. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/service/PowerfittinganalysisService.java
  44. 5 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/Windturbinetestingpointai2Service.java
  45. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/DataFittingService.java
  46. 8 2
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/DataPrepareService.java
  47. 7 2
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/DataProcessService.java
  48. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/ratio/RatioService.java
  49. 83 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/temperature/PowerTemperatureService.java
  50. 7 2
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/fx/WindDirectionService.java
  51. 2 2
      power-fitting/src/main/java/com/gyee/power/fitting/service/impl/EquipmentmodelServiceImpl.java
  52. 2 2
      power-fitting/src/main/java/com/gyee/power/fitting/service/impl/ModelpowerServiceImpl.java
  53. 2 2
      power-fitting/src/main/java/com/gyee/power/fitting/service/impl/ModelpowerdetailsServiceImpl.java
  54. 20 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/impl/PhotovoltaiccapacityServiceImpl.java
  55. 20 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/impl/PhotovoltaicivServiceImpl.java
  56. 2 2
      power-fitting/src/main/java/com/gyee/power/fitting/service/impl/PowerfittinganalysisServiceImpl.java
  57. 27 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/impl/Windpowerstationtestingpoint2ServiceImpl.java
  58. 18 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/impl/Windturbinetestingpointai2ServiceImpl.java
  59. 2 2
      power-fitting/src/main/resources/application.yaml
  60. 4 4
      power-fitting/src/test/java/AlgTest.java
  61. 14 0
      power-fitting/src/test/java/CurveFittingTest.java
  62. 271 0
      power-fitting/src/test/java/PhotovoltaicEconomicOperationTest.java

+ 12 - 12
benchmarking-impala/src/main/java/com/gyee/benchmarkingimpala/service/BenchmarkingService.java

@@ -12,13 +12,9 @@ import com.gyee.benchmarkingimpala.model.vo.*;
 import com.gyee.benchmarkingimpala.service.auto.*;
 import com.gyee.benchmarkingimpala.util.*;
 import com.gyee.benchmarkingimpala.util.taos.EdosUtil;
-import com.gyee.benchmarkingimpala.util.taos.StringUtil;
-import org.apache.poi.ss.formula.functions.T;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.lang.annotation.Target;
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -2345,11 +2341,11 @@ public class BenchmarkingService  {
                 "sum(daynhxdssdl) daynhxdssdl," +
                 "sum(daynhqfdl) daynhqfdl," +
                 "sum(daynhcfdl) daynhcfdl, " +
-                "isnull(sum(actualpower)/nullif(sum(theoreticalpower),0),0)*100 windenergy, " +
-                "isnull(sum(daynhxdssdl)/nullif(sum(theoreticalpower),0),0)*100 powerlossrate, " +
-                "isnull(sum(daynhqfdl)/nullif(sum(theoreticalpower),0),0)*100 performancelossrate, " +
-                "isnull(sum(daynhgzssdl)/nullif(sum(theoreticalpower),0),0)*100 failurelossrate, " +
-                "isnull(sum(daynhwhssdl)/nullif(sum(theoreticalpower),0),0)*100 mainlossrate," +
+                "nvl(sum(actualpower),0)/nvl(sum(theoreticalpower),1)*100 windenergy, " +
+                "nvl(sum(daynhxdssdl),0)/nvl(sum(theoreticalpower),1)*100 powerlossrate, " +
+                "nvl(sum(daynhqfdl),0)/nvl(sum(theoreticalpower),1)*100 performancelossrate, " +
+                "nvl(sum(daynhgzssdl),0)/nvl(sum(theoreticalpower),1)*100 failurelossrate, " +
+                "nvl(sum(daynhwhssdl),0)/nvl(sum(theoreticalpower),1)*100 mainlossrate," +
                 "avg(comprehensiverate) comprehensiverate,sum(actualpower)/avg(capacity) utilizationhours," +
                 "avg(windpoweraccuracy) windpoweraccuracy," +
                 "avg(agccurvefollowing) agccurvefollowing," +
@@ -2361,7 +2357,8 @@ public class BenchmarkingService  {
                 "avg(eliminationrate) eliminationrate," +
                 "avg(speed) speed," +
                 "avg(staticwindfrequency) staticwindfrequency," +
-                "avg(effectivewindhourrate) effectivewindhourrate");if (foreigntype.equals("风电")){
+                "avg(effectivewindhourrate) effectivewindhourrate");
+        if (foreigntype.equals("风电")){
             qw.like("foreignkeyid","_FDC");
         }else {
             qw.like("foreignkeyid","_GDC");
@@ -2520,8 +2517,11 @@ public class BenchmarkingService  {
         qw.ge("recorddate",begin).le("recorddate",end);
         List<Benchmark> tbList = benchmarkService.list(qw);
         if (StringUtils.isNotNull(tbList)  && StringUtils.isNotEmpty(tbList)){
-            tbList.get(0).setForeignkeyid("同比");
-            resultList.add(tbList.get(0));
+            Benchmark benchmark = tbList.get(0);
+            if(benchmark!=null){
+                benchmark.setForeignkeyid("同比");
+                resultList.add(benchmark);
+            }
         }
     }
     public void getJz(String timetype, String foreigntype,List<Benchmark> resultList) throws Exception {

+ 2 - 10
benchmarking-impala/src/main/java/com/gyee/benchmarkingimpala/task/SaticScheduleTask.java

@@ -1,22 +1,14 @@
 package com.gyee.benchmarkingimpala.task;
 
 
-
-import com.gyee.benchmarkingimpala.model.auto.Operationrecord;
 import com.gyee.benchmarkingimpala.service.BenchmarkingService;
 import com.gyee.benchmarkingimpala.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
 
-import java.text.ParseException;
 import java.util.Date;
-import java.util.List;
 
 /**
  * @ClassName : SaticScheduleTask
@@ -37,7 +29,7 @@ public class SaticScheduleTask {
     @Scheduled(cron = "0 0 1 * * ?")
     //或直接指定时间间隔,例如:5秒
     //@Scheduled(fixedRate=5000)
-    private void configureTasks1()  {
+    public void configureTasks1()  {
         Date yestday = DateUtils.getYestday(new Date());
         String date = DateUtils.toDate1(yestday);
         String data1 = DateUtils.toDate1(new Date());
@@ -58,7 +50,7 @@ public class SaticScheduleTask {
     @Scheduled(cron = "0 0 4 * * ?")
     //或直接指定时间间隔,例如:5秒
     //@Scheduled(fixedRate=5000)
-    private void configureTasks2()  {
+    public void configureTasks2()  {
         Date yestday = DateUtils.getYestday(new Date());
         String date = DateUtils.toDate1(yestday);
         String data1 = DateUtils.toDate1(new Date());

+ 11 - 1
gradeevaluation/src/main/java/com/gyee/gradeevaluation/service/bigscreen/BigScreenService.java

@@ -224,7 +224,12 @@ public class BigScreenService {
         double hzjfdl = ednaApiUtil.getRealData(MainConstant.JSFW_HZJRFDLB).getPointValueInDouble();
         double hzjgl = ednaApiUtil.getRealData(MainConstant.JSFW_HZJSSZGL).getPointValueInDouble();
         double hzjrzqd = ednaApiUtil.getRealData(MainConstant.HZJFS).getPointValueInDouble();
-        double gfrzqd = new BigDecimal(dwkrzqd + plrzqd + xhrzqd + mchrzqd + hzjrzqd) .divide(new BigDecimal(3), 2, RoundingMode.HALF_EVEN).doubleValue();
+
+        double akfdl = ednaApiUtil.getRealData(MainConstant.JSFW_AKRFDLB).getPointValueInDouble();//埃肯发电量
+        double akgl = ednaApiUtil.getRealData(MainConstant.JSFW_AKSSZGL).getPointValueInDouble();//埃肯功率
+        double akrzqd = ednaApiUtil.getRealData(MainConstant.AKFS).getPointValueInDouble();//埃肯光照强度
+
+        double gfrzqd = new BigDecimal(dwkrzqd + plrzqd + xhrzqd + mchrzqd + hzjrzqd+akrzqd) .divide(new BigDecimal(3), 2, RoundingMode.HALF_EVEN).doubleValue();
         map.put("dwkgl",dwkgl);
         map.put("plgl",plgl);
         map.put("xhgl",xhgl-mchgl);
@@ -234,6 +239,11 @@ public class BigScreenService {
         map.put("hzjrzqd",hzjrzqd);
         map.put("gfrzqd",gfrzqd);
 
+        map.put("akfdl",akfdl);
+        map.put("akgl",akgl);
+        map.put("akrzqd",akrzqd);
+
+
         double fwjsl = 93.58;
         double zhjsl = 96.12;
         double xqjsl = 94.67;

+ 4 - 0
gradeevaluation/src/main/java/com/gyee/gradeevaluation/variable/MainConstant.java

@@ -70,6 +70,9 @@ public class MainConstant {
     public static final String JSFW_HZJSSFS = "HZJGDCJSFW.NX_GD_HZJG_XX_XX_XXX_XXX_CI0134"; //海子井日照强度
     public static final String JSFW_HZJSSZGL = "HZJDQ.NX_GD_HZJG_DQ_P1_L1_001_AI0052"; //海子井总功率
 
+    public static final String JSFW_AKRFDLB = "AKGDCJSFW.NX_GD_AKG_XX_XX_XXX_XXX_CI0088"; //埃肯日发电量
+    public static final String JSFW_AKSSZGL = "AKDQ.NX_GD_AKG_DQ_P1_L1_001_AI0139"; //埃肯总功率
+
 
 
     public static final String JSFW_XHRFDLB = "XHGDCJSFW.NX_GD_XHG_XX_XX_XXX_XXX_CI0088"; // 宣和日发电量
@@ -164,6 +167,7 @@ public class MainConstant {
     public static final String XHFS = "XHGGL.NX_GD_XHG_YC_P1_L1_001_QXZ001"; // 宣和日照强度
     public static final String MCHFS = "MCHGGL.NX_GD_MCHG_YC_P1_L1_001_QXZ001"; // 马场湖日照强度
     public static final String HZJFS = "HZJGGL.NX_GD_HZJG_YC_P1_L1_001_QXZ001"; // 海子井日照强度
+    public static final String AKFS = "AKDQ.NX_GD_AKG_DQ_P1_L1_001_AI0157"; // 埃肯日照强度
 
 
 }

+ 5 - 1
gyee-sample-impala/pom.xml

@@ -53,7 +53,11 @@
             <artifactId>spring-boot-configuration-processor</artifactId>
             <optional>true</optional>
         </dependency>
-
+        <dependency>
+            <groupId>org.postgresql</groupId>
+            <artifactId>postgresql</artifactId>
+            <version>42.4.0</version>
+        </dependency>
         <dependency>
             <groupId>com.alibaba</groupId>
             <artifactId>fastjson</artifactId>

+ 1 - 1
gyee-sample-impala/src/main/java/com/gyee/impala/common/config/datasource/KuduDataSourceConfig.java

@@ -34,7 +34,7 @@ public class KuduDataSourceConfig {
     public void initKuDu(){
         if (kuduClient == null)
             kuduClient = new KuduClient
-                    .KuduClientBuilder(gyeeConfig.getKuduHost() + ":7051")//7051,21050
+                    .KuduClientBuilder(gyeeConfig.getKuduHost() )//7051,21050
                     .defaultOperationTimeoutMs(6000)
                     .build();
     }

+ 1 - 1
gyee-sample-impala/src/main/java/com/gyee/impala/common/config/datasource/SlaveDataSourceConfig.java

@@ -51,7 +51,7 @@ public class SlaveDataSourceConfig {
     @Bean
     public PaginationInterceptor paginationInterceptor() {
         PaginationInterceptor page = new PaginationInterceptor();
-        page.setDbType(DbType.ORACLE);
+        page.setDbType(DbType.POSTGRE_SQL);
         return page;
     }
 }

+ 0 - 1
gyee-sample-impala/src/main/java/com/gyee/impala/common/feign/RemoteServiceBuilder.java

@@ -38,7 +38,6 @@ public class RemoteServiceBuilder {
                 .retryer(new Retryer.Default(10000, 10000, 3))
                 .target(IShardingService.class, config.getAlertUrl());
     }
-
     @Bean
     public IHostService hostparam() {
         return Feign.builder()

+ 1 - 1
gyee-sample-impala/src/main/java/com/gyee/impala/controller/diagnose/HostparamController.java

@@ -22,7 +22,7 @@ public class HostparamController {
     @GetMapping("/{host}/{port}")
     public JSONObject getHostParam(@PathVariable String  host,@PathVariable int port) {
         JSONObject  json = hostparamService.exec(host,port);
-        return json;
+        return new JSONObject();
     }
 
 }

+ 1 - 2
gyee-sample-impala/src/main/java/com/gyee/impala/schdule/TaskStatistic.java

@@ -5,7 +5,6 @@ import com.gyee.impala.model.master.Casefaultalg;
 import com.gyee.impala.service.master.CasefaultalgService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 import java.util.List;
@@ -24,7 +23,7 @@ public class TaskStatistic {
     /**
      * 统计算法准确率
      */
-    @Scheduled(initialDelay = 60 * 1000, fixedRate = 1 * 60 * 60 * 1000)
+    //@Scheduled(initialDelay = 60 * 1000, fixedRate = 1 * 60 * 60 * 1000)
     public void accuracyStatisticTask() {
         if (0 == InitialRunner.historyList.size())
             return;

+ 2 - 3
gyee-sample-impala/src/main/java/com/gyee/impala/schdule/TaskWeather.java

@@ -10,7 +10,6 @@ import com.gyee.impala.model.master.Weatherforecast;
 import com.gyee.impala.service.decision.WfNwpDataService;
 import com.gyee.impala.service.master.WeatherforecastService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
@@ -43,7 +42,7 @@ public class TaskWeather {
     }
 
 
-    @Scheduled(cron = "0 0 1 * * ?")
+    //@Scheduled(cron = "0 0 1 * * ?")
     public void weatherForecastTask(){
         MAP_STATION.forEach((k, v) -> {
             Weatherforecast forecast = forecastService.getOneMaxTimeByStation(v);
@@ -67,7 +66,7 @@ public class TaskWeather {
     /**
      * 天气样本库加入实际风速
      */
-    @Scheduled(cron = "0 15 1 * * ?")
+    //@Scheduled(cron = "0 15 1 * * ?")
     public void weatherAddActualspeedTask(){
         QueryWrapper<Weatherforecast> wrapper1 = new QueryWrapper<>();
         wrapper1.between("time",DateUtil.getPreviousDate(26),new Date());

+ 2 - 3
gyee-sample-impala/src/main/java/com/gyee/impala/schdule/TaskWindspeedForecast.java

@@ -11,7 +11,6 @@ import com.gyee.impala.service.master.IWindspeedforecastshorttermService;
 import com.gyee.impala.service.master.IWindspeedforecastspshorttermService;
 import lombok.SneakyThrows;
 import org.apache.kudu.client.KuduException;
-import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
@@ -108,7 +107,7 @@ public class TaskWindspeedForecast {
     }
     
     @SneakyThrows
-    @Scheduled(cron = "0 25 2 * * ?")
+    //@Scheduled(cron = "0 25 2 * * ?")
     //短期
     public void shortTerm() {
         Calendar today = Calendar.getInstance();
@@ -344,7 +343,7 @@ public class TaskWindspeedForecast {
     }
 
     @SneakyThrows
-    @Scheduled(cron = "0 45 2 * * ?")
+    //@Scheduled(cron = "0 45 2 * * ?")
     //超短期
     public void specialShortTerm() {
 

+ 1 - 0
gyee-sample-impala/src/main/java/com/gyee/impala/service/custom/diagnose/AutoCmdService.java

@@ -32,6 +32,7 @@ public class AutoCmdService {
         System.out.println(new Date() + "开始执行脚本...");
         Process p;
         String cmdPath = gyeeConfig.getDiagnosePath();
+        if(InitialRunner.historyModelMap.size()<1) return;
         try {
             Diagnosetrainhistory history = InitialRunner.historyModelMap.get(fi.getStationId() + "_" + fi.getModelId()).get(0);
             System.out.println("脚本调用成功: " + history.toString());

+ 35 - 28
gyee-sample-impala/src/main/java/com/gyee/impala/service/impl/master/WindspeedforecastshorttermServiceImpl.java

@@ -26,7 +26,7 @@ import java.util.stream.Collectors;
 
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author gfhd
@@ -42,6 +42,7 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
     /**
      * 由于mybatis-plus存储的中文乱码
      * 采用原生写法
+     *
      * @param list
      * @return
      */
@@ -50,13 +51,13 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
         KuduTable kuduTable = kuduConfig.kuduClient.openTable("impala::gyee_sample_kudu.windspeedforecastshortterm");
         KuduSession kuduSession = kuduConfig.kuduSession();
         int i = 0;
-        for (Windspeedforecastshortterm boj : list){
+        for (Windspeedforecastshortterm boj : list) {
             Insert insert = kuduTable.newInsert();
             // 获取Row对象,设置插入的值
             PartialRow row = insert.getRow();
             row.addObject("id", SnowFlakeUtil.generateIdL());
-            long time = boj.getCalctime().getTime()+28800000;
-            row.addObject("calctime", time*1000);
+            long time = boj.getCalctime().getTime() + 28800000;
+            row.addObject("calctime", time * 1000);
             row.addObject("forecasttype", boj.getForecasttype());
             row.addObject("stationid", boj.getStationid());
             row.addObject("projectid", boj.getProjectid());
@@ -74,7 +75,7 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
 
             // 先不提交kudu
             kuduSession.apply(insert);
-            i ++;
+            i++;
             if (i % kuduConfig.getCount() == 0)
                 kuduSession.flush(); //批量写入kudu
         }
@@ -94,16 +95,16 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
 
     @Override
     public JSONObject getContrast(String stationid, Date starttime, Date endtime, int timescale) {
-        Date dateStartQntq = DateUtil.dateTimeAddYear(starttime,-1);
-        Date dateEndQntq = DateUtil.dateTimeAddYear(endtime,-1);
+        Date dateStartQntq = DateUtil.dateTimeAddYear(starttime, -1);
+        Date dateEndQntq = DateUtil.dateTimeAddYear(endtime, -1);
 
         //list1短期 list2超短期 list3去年同期短期 list4去年同期超短期
-        List<Windspeedforecastshortterm> list1 = getShortterm(stationid,starttime,endtime);
-        List<Windspeedforecastspshortterm> list2 = getSpShortterm(stationid,starttime,endtime,timescale);
-        List<Windspeedforecastshortterm> list3 = getShortterm(stationid,dateStartQntq,dateEndQntq);
-        List<Windspeedforecastspshortterm> list4 = getSpShortterm(stationid,dateStartQntq,dateEndQntq,timescale);
+        List<Windspeedforecastshortterm> list1 = getShortterm(stationid, starttime, endtime);
+        List<Windspeedforecastspshortterm> list2 = getSpShortterm(stationid, starttime, endtime, timescale);
+        List<Windspeedforecastshortterm> list3 = getShortterm(stationid, dateStartQntq, dateEndQntq);
+        List<Windspeedforecastspshortterm> list4 = getSpShortterm(stationid, dateStartQntq, dateEndQntq, timescale);
         List<WindspeedforecastContrast> windspeedforecastContrasts = new ArrayList<>();
-        list1.forEach(l->{
+        list1.forEach(l -> {
             WindspeedforecastContrast wsfcc = new WindspeedforecastContrast();
             wsfcc.setCalctime(l.getCalctime());
             wsfcc.setActualpower(l.getActualpower());
@@ -112,25 +113,31 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
             wsfcc.setForecastwindspeed(l.getForecastwindspeed());
             windspeedforecastContrasts.add(wsfcc);
         });
-        Map<Date, WindspeedforecastContrast> contrastMap = windspeedforecastContrasts.stream().collect(Collectors.toMap(WindspeedforecastContrast::getCalctime, Function.identity(),(key1,key2)->key2));
+        Map<Date, WindspeedforecastContrast> contrastMap = windspeedforecastContrasts.stream().collect(Collectors.toMap(WindspeedforecastContrast::getCalctime, Function.identity(), (key1, key2) -> key2));
 
-        list2.forEach(l-> {
+        list2.forEach(l -> {
             WindspeedforecastContrast wsfcc = contrastMap.get(l.getCalctime());
-            wsfcc.setForecastpowersp(l.getForecastpower());
-            wsfcc.setForecastwindspeedsp(l.getForecastwindspeed());
+            if (wsfcc != null) {
+                wsfcc.setForecastpowersp(l.getForecastpower());
+                wsfcc.setForecastwindspeedsp(l.getForecastwindspeed());
+            }
         });
         //给年份加一年,然后匹配
-        list3.forEach(l-> {
-            WindspeedforecastContrast wsfcc = contrastMap.get(DateUtil.dateTimeAddYear(l.getCalctime(),1));
-            wsfcc.setActualpowertq(l.getActualpower());
-            wsfcc.setForecastpowertq(l.getForecastpower());
-            wsfcc.setActualwindspeedtq(l.getActualwindspeed());
-            wsfcc.setForecastwindspeedtq(l.getForecastwindspeed());
+        list3.forEach(l -> {
+            WindspeedforecastContrast wsfcc = contrastMap.get(DateUtil.dateTimeAddYear(l.getCalctime(), 1));
+            if (wsfcc != null) {
+                wsfcc.setActualpowertq(l.getActualpower());
+                wsfcc.setForecastpowertq(l.getForecastpower());
+                wsfcc.setActualwindspeedtq(l.getActualwindspeed());
+                wsfcc.setForecastwindspeedtq(l.getForecastwindspeed());
+            }
         });
-        list4.forEach(l-> {
-            WindspeedforecastContrast wsfcc = contrastMap.get(DateUtil.dateTimeAddYear(l.getCalctime(),1));
-            wsfcc.setForecastpowersptq(l.getForecastpower());
-            wsfcc.setForecastwindspeedsptq(l.getForecastwindspeed());
+        list4.forEach(l -> {
+            WindspeedforecastContrast wsfcc = contrastMap.get(DateUtil.dateTimeAddYear(l.getCalctime(), 1));
+            if (wsfcc != null) {
+                wsfcc.setForecastpowersptq(l.getForecastpower());
+                wsfcc.setForecastwindspeedsptq(l.getForecastwindspeed());
+            }
         });
 
         //根据时间排序
@@ -145,7 +152,7 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
     private List<Windspeedforecastshortterm> getShortterm(String stationid, Date dateStart, Date dateEnd) {
         QueryWrapper<Windspeedforecastshortterm> wrapper = new QueryWrapper<>();
         wrapper.eq("stationid", stationid)
-                .eq("algorithmmodel","风电_极限学习机_功率_中国大陆")
+                .eq("algorithmmodel", "风电_极限学习机_功率_中国大陆")
                 .between("calctime", dateStart, dateEnd).orderByDesc("calctime");
         return baseMapper.selectList(wrapper);
     }
@@ -153,7 +160,7 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
     /**
      * 超短期功率
      */
-    private List<Windspeedforecastspshortterm> getSpShortterm(String stationid, Date dateStart, Date dateEnd,int timescale) {
+    private List<Windspeedforecastspshortterm> getSpShortterm(String stationid, Date dateStart, Date dateEnd, int timescale) {
         QueryWrapper<Windspeedforecastspshortterm> wrapper = new QueryWrapper<>();
         wrapper.eq("stationid", stationid)
                 .between("calctime", dateStart, dateEnd)

+ 12 - 31
gyee-sample-impala/src/main/resources/application.yaml

@@ -1,17 +1,15 @@
 gyee:
   # golden实时适配器的url
-  golden-url: http://10.155.32.4:8011
+  golden-url: http://18.6.30.63:8011
   # 报警url
-  alert-url: http://192.168.1.14:8075
-  #alert-url: http://localhost:8075
-  host-url: http://10.155.32.14:8520
+  alert-url: http://18.6.30.53:8075
   # 样本数据统计开始时间
   init-time: 2022-01-01 00:00:00
   # 故障样本数据导入模板路径
   template-path-window: D://java//kudu//template/
   template-path-linux: /home/gyee/fault_digonsis/services/template/
   # kudu的host
-  kudu-host: 192.168.1.60
+  kudu-host: 18.6.30.73:21050
   # 故障诊断脚本路径
   diagnose-path-window: D://test//
   diagnose-path-linux: /home/gyee/fault_digonsis/scripts/
@@ -20,6 +18,7 @@ gyee:
   diagnose-file-linux: /home/gyee/fault_digonsis/data/
   # 报警规则是否加密
   rule-encryption: false
+  host-url: http://18.6.30.66:8520
 
 server:
   port: 9002
@@ -45,25 +44,13 @@ spring:
       #kudu数据库
       master:
         driver-class-name: com.cloudera.impala.jdbc41.Driver
-        jdbc-url: jdbc:impala://192.168.1.62:21050/gyee_sample_kudu
-      #三区oracle数据库
+        jdbc-url: jdbc:impala://18.6.30.71:21050/gyee_sample_kudu
+      #一区postgresql数据库
       slave:
-        jdbc-url: jdbc:oracle:thin:@192.168.1.105:1521:gdnxfd
-        username: nxfdprod
+        jdbc-url: jdbc:postgresql://18.6.30.71:5432/wisdom_cs
+        username: postgres
         password: gdnxfd123
-        driver-class-name: oracle.jdbc.OracleDriver
-      #网源oracle数据库 -- 数据采集
-      decision:
-        jdbc-url: jdbc:oracle:thin:@10.155.32.7:1521:ORCL
-        username: gyee
-        password: FRWIND
-        driver-class-name: oracle.jdbc.OracleDriver
-      #国电oracle数据库 -- oa
-      gdoa:
-        jdbc-url: jdbc:oracle:thin:@192.168.1.10:1521:ORCL
-        username: mis
-        password: GDnxXNY_2020#!
-        driver-class-name: oracle.jdbc.OracleDriver
+        driver-class-name: org.postgresql.Driver
       # 初始化大小,最小,最大
       initial-size: 1
       min-idle: 1
@@ -85,13 +72,13 @@ spring:
 ####################三区大数据服务器 SFTP  hive 配置####################
 hiveconfig:
   protocols: sftp
-  host: 192.168.1.60
+  host: 18.6.30.70
   port: 22
   username: root
   password: Admin@2019
   path: /home/gyee/kudu/dataprocess/
   driver: org.apache.hive.jdbc.HiveDriver
-  url: jdbc:hive2://192.168.1.60:10000/default
+  url: jdbc:hive2://18.6.30.70:10000/default
 ####################三区大数据服务器 SFTP EXEC 配置####################
 
 
@@ -99,7 +86,6 @@ hiveconfig:
 mybatis-plus:
   configuration:
     map-underscore-to-camel-case: true # 数据库下划线自动转驼峰标示关闭
-    # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 ####################Mybatis Plus配置####################
 
 
@@ -110,9 +96,4 @@ logging:
     root: info
     com.example: debug
   file:
-    path: ./logs
-
-
-## 故障诊断部署  运行  source activate tensorflow-gpu   ##
-## java -jar -Xms512m -Xmx1024m -XX:PermSize=256M -XX:MaxPerSize=512M  /home/gyee/fault_digonsis/services/diagnose-kudu/gyee-sample-impala-0.0.1-SNAPSHOT.jar ##
-
+    path: ./logs

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

@@ -2,6 +2,7 @@ package com.gyee.power.fitting;
 
 import com.gyee.power.fitting.common.config.GyeeConfig;
 import com.gyee.power.fitting.common.spring.SpringContextUtil;
+import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cache.annotation.EnableCaching;
@@ -20,6 +21,7 @@ import java.io.File;
 @EnableCaching
 @EnableScheduling
 @SpringBootApplication
+@MapperScan("com.gyee.power.fitting.mapper")
 public class PowerBootApplication {
 
     public static void main(String[] args) {

+ 9 - 0
power-fitting/src/main/java/com/gyee/power/fitting/common/alg/CurveFitting.java

@@ -0,0 +1,9 @@
+package com.gyee.power.fitting.common.alg;
+
+import java.util.List;
+
+public interface CurveFitting {
+    Object run(List<Object> params);
+    List<Object> getParams(); 
+    void printResult(Object result,double accuracy);
+}

+ 0 - 19
power-fitting/src/main/java/com/gyee/power/fitting/common/alg/MpptFittingAlg.java

@@ -1,29 +1,10 @@
 package com.gyee.power.fitting.common.alg;
 
-//package easyexcel;
-
-import com.alibaba.excel.EasyExcel;
-import com.alibaba.excel.context.AnalysisContext;
-import com.alibaba.excel.event.AnalysisEventListener;
-import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-//绘制曲线需要
-import  java.awt.*;
-import  javax.swing.*;
-import  java.awt.geom.GeneralPath;
-
 
-import com.gyee.power.fitting.model.custom.LineCurveFitting;
 import com.gyee.power.fitting.model.custom.PointVo;
 
 import java.util.ArrayList;
-import java.util.List;
-
-import java.math.BigDecimal;
 
 import org.apache.commons.math3.fitting.PolynomialCurveFitter;
 import org.apache.commons.math3.fitting.WeightedObservedPoints;

+ 180 - 0
power-fitting/src/main/java/com/gyee/power/fitting/common/alg/PolynomialCurveFitting.java

@@ -0,0 +1,180 @@
+package com.gyee.power.fitting.common.alg;
+
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.gyee.power.fitting.model.custom.TsDoubleData;
+import org.apache.commons.math3.fitting.PolynomialCurveFitter;
+import org.apache.commons.math3.fitting.WeightedObservedPoint;
+import org.apache.commons.math3.fitting.WeightedObservedPoints;
+
+import java.util.*;
+
+public class PolynomialCurveFitting implements CurveFitting {
+
+    private WeightedObservedPoints points = null;
+    private final int degree = 1; // 阶数
+
+    private double[] inputDataX = null;
+    private double[] inputDataY = null;
+
+    public void CalcCurveFitting() {
+        inputDataX = new double[17];
+        inputDataY = new double[17];
+        importdata_1("data1", inputDataX);
+        importdata_1("data2", inputDataY);
+        System.out.print("本算例用于计算多项式曲线拟合。已加载计算数据(" + inputDataX.length + "点, " + degree + "阶)... ...");
+        /*double[] factor = new double[degree + 1];
+        // N阶多项式会有N+1个系数,其中之一为常数项
+        for (int index = 0; index < factor.length; index++) {
+            factor[index] = index + 1;
+        }
+        for (int index = 0; index < inputDataY.length; index++) {
+            inputDataX[index] = index * 0.1;
+            inputDataY[index] = calcPoly(inputDataX[index], factor); // y = sum(x[n) * fact[n])
+            // System.out.print(inputDataY[index] + ", ");
+        }*/
+        points = new WeightedObservedPoints();
+        for (int index = 0; index < inputDataX.length; index++) {
+            points.add(inputDataX[index], inputDataY[index]);
+        }
+        System.out.println("初始化完成");
+    }
+
+    @Override
+    public Object run(List<Object> params) {
+        PolynomialCurveFitter fitter = PolynomialCurveFitter.create(degree);
+        WeightedObservedPoints points = (WeightedObservedPoints) params.get(0);
+        double[] result = fitter.fit(points.toList());
+        return result;
+    }
+
+    public double[] run(WeightedObservedPoints params) {
+        PolynomialCurveFitter fitter = PolynomialCurveFitter.create(degree);
+        double[] result = fitter.fit(params.toList());
+        return result;
+    }
+
+    @Override
+    public List<Object> getParams() {
+        CalcCurveFitting();
+        List<Object> params = new ArrayList<Object>();
+        params.add(points);
+        return params;
+    }
+
+    @Override
+    //例如 3,4,2,6 y=3*x^3+4*x^2+2*x+6
+    public void printResult(Object r,double accuracy) {
+        double[] result = (double[]) r;
+
+        List<Double> dataX = new ArrayList<>();
+        List<Double> dataY = new ArrayList<>();
+
+        for (double index = inputDataX[0]; index < inputDataX[inputDataX.length-1]; index+=accuracy) {
+            //int i = 0;
+            dataX.add(index);
+            dataY.add(calcPoly(index, result));
+            //i++;
+        }
+        System.out.print("\n\n\nX轴数据\n\n");
+        for (Double x : dataX) {
+            System.out.println(x+",");
+        }
+        System.out.print("\n\n\nY轴数据\n\n");
+        for (Double y : dataY) {
+            System.out.println(y+",");
+        }
+    }
+    public void printResultAll(List<TsDoubleData> x, double[] result,double accuracy) {
+
+        List<Double> dataX = new ArrayList<>();
+        List<Double> dataY = new ArrayList<>();
+
+        for (double index = x.get(0).getDoubleValue(); index < x.get(x.size()-1).getDoubleValue(); index+=accuracy) {
+            //int i = 0;
+            dataX.add(index);
+            dataY.add(calcPoly(index, result));
+            //i++;
+        }
+        System.out.print("\n\n\nX轴数据\n\n");
+        for (Double d : dataX) {
+            System.out.print(d+",");
+        }
+        System.out.print("\n\n\nY轴数据\n\n");
+        for (Double y : dataY) {
+            System.out.print(y+",");
+        }
+        System.out.println();
+    }
+
+    public String printResultY(List<TsDoubleData> x, double[] result) {
+        System.out.print("\n\n\nY轴数据\n\n");
+        String ss = "";
+        for (TsDoubleData v : x) {
+            double y = calcPoly(v.getDoubleValue(),result);
+            String s = y + ",";
+            ss += s;
+        }
+        return ss;
+    }
+
+    private double calcPoly(double x, double[] factor) {
+        double y = 0;
+        for (int deg = 0; deg < factor.length; deg++) {
+            y += Math.pow(x, deg) * factor[deg];
+        }
+        return y;
+    }
+
+    public double calcLow(Map<Double, Double> points, double[] factor) {
+        double sum = 0;
+        for (Map.Entry<Double, Double> dde : points.entrySet()) {
+            sum += dde.getValue() - calcPoly(dde.getKey(), factor);
+        }
+        return sum/points.size();
+    }
+
+    /**
+     * 从execl中导入数据
+     */
+    public static void importdata_1(String sheet, final double[] data)
+    {
+        int i=0;
+        List<Map<Integer,String>> list = new LinkedList<>(); //初始化列表
+
+        EasyExcel.read("D:/光伏经济运行/WTest0.xlsx") //文件路径
+                .sheet(sheet) //表单名
+                .registerReadListener(new AnalysisEventListener<Map<Integer,String>>() { //监听器,以行的形式读取Excel
+
+                    //一行一行读取Excel,在这里处理读取到的数据
+                    @Override
+                    public void invoke(Map<Integer, String> integerStringMap, AnalysisContext analysisContext) {
+                        // TODO Auto-generated method stub
+                        list.add(integerStringMap); //将读取到的每一行为一组存入列表中
+                    }
+
+                    //数据读取完毕后运行下面
+                    @Override
+                    public void doAfterAllAnalysed(AnalysisContext context) {
+                        System.out.println("数据读取完毕");
+                    }
+                }).headRowNumber(1).doRead(); //headRowNumber(num)为指定前num行为表头,从num+1开始读,默认为1
+
+        //遍历列表存储数据
+        for (Map<Integer, String> integerStringMap : list)
+        {
+            Set<Integer> keySet =integerStringMap.keySet();
+            Iterator<Integer> iterator = keySet.iterator();
+            while (iterator.hasNext())
+            {
+                Integer key = iterator.next();
+                Double val = Double.valueOf(integerStringMap.get(key));
+                System.out.print(val+",");
+                data[i++] = val;
+            }
+        }
+        System.out.println();
+        System.out.println(i+"条数据已导入");
+    }
+}

+ 3 - 4
power-fitting/src/main/java/com/gyee/power/fitting/common/alg/PowerFittingALG.java

@@ -381,7 +381,7 @@ public class PowerFittingALG {
         //过滤对风偏差
         for (int i = 0; i < points.size(); i++){
             PowerPointData item = points.get(i);
-            if (item.getSpeed() < 4.5 || item.getSpeed() >= 10.5)
+            if (item.getSpeed() < 4.5 || item.getSpeed() >= 10.5 && item.getMxzt() != 2)
                 continue;
 
             list.add(item);
@@ -392,7 +392,7 @@ public class PowerFittingALG {
             double[] value = map.get(speed);
             double power = item.getPower() < 0 ? 0 : item.getPower();
             value[0] = power < value[0] ? power : value[0]; //最小值
-            value[1] = power > value[1] ? power : value[1]; //最
+            value[1] = power > value[1] ? power : value[1]; //最
         }
 
         DecimalFormat sf = new DecimalFormat("0.00");
@@ -401,7 +401,7 @@ public class PowerFittingALG {
             Integer speed = Math.toIntExact(Math.round(item.getSpeed()));
             int ele = (int) (Math.abs(item.getFx()) + Math.abs(item.getAngle()));
             int index = ele - 180;
-            if (index >= -15 && index <= 15) {
+            if (index >= -30 && index <= 30 && item.getPower() > 0) {
                 double[] value = map.get(speed);
                 double v = (item.getPower() - value[0]) / (value[1] - value[0]);
                 double s[] = {speed, index, Double.valueOf(sf.format(v)).doubleValue()};
@@ -409,7 +409,6 @@ public class PowerFittingALG {
             }
         }
 
-
         return result;
     }
 

+ 78 - 0
power-fitting/src/main/java/com/gyee/power/fitting/common/alg/PowerTemperatureAlg.java

@@ -0,0 +1,78 @@
+package com.gyee.power.fitting.common.alg;
+
+
+import com.gyee.power.fitting.model.custom.PowerPointData;
+
+import java.util.*;
+
+/**
+ * 温度功率算法
+ */
+public class PowerTemperatureAlg {
+
+
+    /**
+     * 风速大于12m时的平均额定功率与额定功率的差值
+     * @param points  测点数据
+     * @param power   该型号风机的额定功率
+     * @param minT    最小温度
+     * @param maxT    最大温度
+     * 统计跨度温度内是否欠满发   实发总功率/次数 - 理论功率
+     */
+    public static Map<String, Integer> temperatureRatedPower(List<PowerPointData> points, double power, double minT, double maxT){
+        Map<Integer, int[]> map = new TreeMap<>(); //[0]计数  [1]功率求和
+        int mint = (int) minT;
+        int maxt = (int) maxT;
+        int split = 5;  //温度间隔步调5°
+
+        points.stream().filter(f -> !(f.getSpeed() < 12.0 || f.getSpeed() > 25.0 || f.getMxzt() != 2))
+                .sorted(Comparator.comparing(PowerPointData::getHjwd)).forEach(item -> {
+            int T = (int) item.getHjwd();
+            if (!map.containsKey(T)) {
+                map.put(T, new int[2]);
+            }
+            int[] value = map.get(T);
+            value[0]++;
+            value[1] += item.getPower();
+        });
+
+        Map<String, Integer> result = new LinkedHashMap<>();
+        for (int i = mint; i <= maxt; i+=split){
+            int count = 0;
+            double totalPower = 0;
+            for (int j = 0; j < split; j++){
+                if (!map.containsKey(i + j))
+                    continue;
+                count += map.get(i + j)[0];
+                totalPower += map.get(i + j)[1];
+            }
+            result.put("(" + i + "," + (i + split) + "]", (int)(totalPower/count - power));
+        }
+
+        return result;
+    }
+
+
+    /**
+     * 额定功率vs.温度分析
+     * @param points  测点
+     * @return  风速大于12m/s满发状态时的
+     */
+    public static List<int[]> temperatureRatedPower(List<PowerPointData> points){
+        List<int[]> list = new ArrayList<>();
+        points.stream().filter(f -> f.getSpeed() >= 12.0 && f.getSpeed() <= 25.0 && f.getMxzt() == 2)
+                .sorted(Comparator.comparing(PowerPointData::getHjwd)).forEach(item -> {
+                    int t = (int) item.getHjwd();
+                    int v = (int) item.getPower();
+                    int[] temp = new int[]{t, v};
+                    list.add(temp);
+                });
+        return list;
+    }
+
+
+    public static void main(String[] args){
+        for (int i = -4; i <= 28; i+=5)
+            System.out.println(i);
+    }
+}

+ 22 - 0
power-fitting/src/main/java/com/gyee/power/fitting/common/alg/TimeCostCalculator.java

@@ -0,0 +1,22 @@
+package com.gyee.power.fitting.common.alg;
+
+import java.util.List;
+
+public class TimeCostCalculator {
+    /**
+     * 计算指定对象的运行时间开销。
+     * @param testCase 指定被测对象。
+     * @return 返回sub.run的时间开销,单位为s。
+     */
+    public double calcTimeCost(CurveFitting testCase) {
+        List<Object> params = testCase.getParams();
+        long startTime = System.nanoTime();
+        //拟合结果通过一个double数组返回,按元素顺序依次是常数项、一次项、二次项、……。
+        Object result = testCase.run(params);
+        long stopTime = System.nanoTime();
+        testCase.printResult(result,0.5);
+        //System.out.println("start: " + startTime + " / stop: " + stopTime);
+        double timeCost = (stopTime - startTime) * 1.0e-9;
+        return timeCost;
+    }
+}

+ 6 - 4
power-fitting/src/main/java/com/gyee/power/fitting/common/alg/WindDirectionALG.java

@@ -55,10 +55,12 @@ public class WindDirectionALG {
      * @return
      */
     public static int[] fxRadarRoses(List<PowerPointData> list){
-        int[] count = new int[32];
+        int[] count = new int[16];
         list.stream().sorted(Comparator.comparing(PowerPointData::getSpeed)).forEach(item -> {
             int df = windDFAngle(item.getDfwc());
-            count[df] ++;
+            if (count[df] < 1000) {
+                count[df]++;
+            }
         });
 
         return count;
@@ -88,10 +90,10 @@ public class WindDirectionALG {
      * 2:90-135
      * .。。。。。。
      * @param
-     * @return params: 0,1,2。。。。。15
+     * @return
      */
     private static int windDFAngle(double angle){
-        int split = 32;  //风向分为16个角度
+        int split = 16;  //风向分为8个角度
         double interval = (double)360 / split;
         angle = angle > 360 ? 720 - 360 : angle;
         int index = (int) (Math.abs(angle) / interval);

+ 11 - 1
power-fitting/src/main/java/com/gyee/power/fitting/common/feign/IAdapterService.java

@@ -5,6 +5,7 @@ import com.gyee.power.fitting.model.custom.TsDoubleData;
 import feign.Headers;
 import feign.Param;
 import feign.RequestLine;
+import org.springframework.web.bind.annotation.GetMapping;
 
 import java.util.List;
 
@@ -16,9 +17,18 @@ public interface IAdapterService {
     @RequestLine("GET /ts/latest?keys={points}")
     JSONObject getLatest(@Param(value = "points") String points);
 
-
     @Headers({"Content-Type: application/json", "Accept: application/json"})
     @RequestLine("GET /ts/history/snap?tagName={tagName}&startTs={startTs}&endTs={endTs}&interval={interval}")
     List<TsDoubleData> getHistorySnap(@Param(value = "tagName") String tagName, @Param(value = "startTs") long startTs,
                                         @Param(value = "endTs") long endTs, @Param(value = "interval") Integer interval);
+    
+    @Headers({"Content-Type: application/json", "Accept: application/json"})
+    @RequestLine("GET /ts/history/snap?tagName={tagName}&startTs={startTs}&endTs={endTs}&interval={interval}")
+    List<TsDoubleData> getValuesByKey(@Param(value = "tagName") String tagName, @Param(value = "startTs") long startTs,
+                                   @Param(value = "endTs") long endTs, @Param(value = "interval") int interval);
+    
+    @Headers({"Content-Type: application/json", "Accept: application/json"})
+    @RequestLine("GET /ts/history/raw?tagName={tagName}&startTs={startTs}&endTs={endTs}")
+    List<TsDoubleData> getRawValuesByKey(@Param(value = "tagName") String tagName, @Param(value = "startTs") long startTs,
+                                      @Param(value = "endTs") long endTs);
 }

+ 360 - 0
power-fitting/src/main/java/com/gyee/power/fitting/common/util/DateUtils.java

@@ -0,0 +1,360 @@
+package com.gyee.power.fitting.common.util;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * 日期操作工具类
+ */
+public class DateUtils {
+
+    private static final SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd");
+    private static final SimpleDateFormat sdfl = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+    /**
+     * 日期转换-  String -> Date
+     *
+     * @param dateString 字符串时间
+     * @return Date类型信息
+     * @throws Exception 抛出异常
+     */
+    public static Date string2DateS(String dateString) throws Exception {
+        if (dateString == null) {
+            return null;
+        }
+        return sdfs.parse(dateString);
+    }
+
+    /**
+     * 日期转换-  String -> Date
+     *
+     * @param dateString 字符串时间
+     * @return Date类型信息
+     * @throws Exception 抛出异常
+     */
+    public static Date string2DateL(String dateString) throws Exception {
+        if (dateString == null) {
+            return null;
+        }
+        return sdfl.parse(dateString);
+    }
+
+    /**
+     * 日期转换-  String -> Date
+     *
+     * @param dateString 字符串时间
+     * @param pattern    格式模板
+     * @return Date类型信息
+     * @throws Exception 抛出异常
+     */
+    public static Date string2Date(String dateString, String pattern) throws Exception {
+        if (dateString == null) {
+            return null;
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
+        Date date = sdf.parse(dateString);
+        return date;
+    }
+
+    /**
+     * 日期转换 Date -> String
+     *
+     * @param date Date类型信息
+     * @return 字符串时间
+     * @throws Exception 抛出异常
+     */
+    public static String date2StringS(Date date) throws Exception {
+        if (date == null) {
+            return null;
+        }
+        return sdfs.format(date);
+    }
+
+    /**
+     * 日期转换 Date -> String
+     *
+     * @param date Date类型信息
+     * @return 字符串时间
+     * @throws Exception 抛出异常
+     */
+    public static String date2StringL(Date date) throws Exception {
+        if (date == null) {
+            return null;
+        }
+        return sdfl.format(date);
+    }
+
+    /**
+     * 日期转换 Date -> String
+     *
+     * @param date    Date类型信息
+     * @param pattern 格式模板
+     * @return 字符串时间
+     * @throws Exception 抛出异常
+     */
+    public static String date2String(Date date, String pattern) throws Exception {
+        if (date == null) {
+            return null;
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
+        String strDate = sdf.format(date);
+        return strDate;
+    }
+
+    /**
+     * 获取当前时间的0点
+     */
+    public static Calendar getZero(Calendar c){
+        Calendar time = (Calendar) c.clone();
+        time.set(Calendar.HOUR_OF_DAY, 0);
+        time.set(Calendar.MINUTE, 0);
+        time.set(Calendar.SECOND, 0);
+        time.set(Calendar.MILLISECOND, 0);
+        return time;
+    }
+    /**
+     * 获取当前时间的最晚点
+     */
+    public static Calendar getNight(Calendar c){
+        Calendar time = getZero(c);
+        time.add(Calendar.DATE, 1);
+        time.add(Calendar.MILLISECOND,-1);
+        return time;
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+    /**
+     * 获取当前日期的本周一是几号
+     *
+     * @return 本周一的日期
+     */
+    public static Date getThisWeekMonday() {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(new Date());
+        // 获得当前日期是一个星期的第几天
+        int dayWeek = cal.get(Calendar.DAY_OF_WEEK);
+        if (1 == dayWeek) {
+            cal.add(Calendar.DAY_OF_MONTH, -1);
+        }
+        // 设置一个星期的第一天,按中国的习惯一个星期的第一天是星期一
+        cal.setFirstDayOfWeek(Calendar.MONDAY);
+        // 获得当前日期是一个星期的第几天
+        int day = cal.get(Calendar.DAY_OF_WEEK);
+        // 根据日历的规则,给当前日期减去星期几与一个星期第一天的差值
+        cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - day);
+        return cal.getTime();
+    }
+
+    /**
+     * 获取当前日期周的最后一天
+     *
+     * @return 当前日期周的最后一天
+     */
+    public static Date getSundayOfThisWeek() {
+        Calendar c = Calendar.getInstance();
+        int dayOfWeek = c.get(Calendar.DAY_OF_WEEK) - 1;
+        if (dayOfWeek == 0) {
+            dayOfWeek = 7;
+        }
+        c.add(Calendar.DATE, -dayOfWeek + 7);
+        return c.getTime();
+    }
+
+    /**
+     * 根据日期区间获取月份列表
+     *
+     * @param minDate 开始时间
+     * @param maxDate 结束时间
+     * @return 月份列表
+     * @throws Exception
+     */
+    public static List<String> getMonthBetween(String minDate, String maxDate, String format) throws Exception {
+        ArrayList<String> result = new ArrayList<>();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+
+        Calendar min = Calendar.getInstance();
+        Calendar max = Calendar.getInstance();
+
+        min.setTime(sdf.parse(minDate));
+        min.set(min.get(Calendar.YEAR), min.get(Calendar.MONTH), 1);
+
+        max.setTime(sdf.parse(maxDate));
+        max.set(max.get(Calendar.YEAR), max.get(Calendar.MONTH), 2);
+        SimpleDateFormat sdf2 = new SimpleDateFormat(format);
+
+        Calendar curr = min;
+        while (curr.before(max)) {
+            result.add(sdf2.format(curr.getTime()));
+            curr.add(Calendar.MONTH, 1);
+        }
+
+        return result;
+    }
+
+    /**
+     * 根据日期获取年度中的周索引
+     *
+     * @param date 日期
+     * @return 周索引
+     * @throws Exception
+     */
+    public static Integer getWeekOfYear(String date) throws Exception {
+        Date useDate = string2DateS(date);
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(useDate);
+        return cal.get(Calendar.WEEK_OF_YEAR);
+    }
+
+    /**
+     * 根据年份获取年中周列表
+     *
+     * @param year 年分
+     * @return 周列表
+     * @throws Exception
+     */
+    public static Map<Integer, String> getWeeksOfYear(String year) throws Exception {
+        Date useDate = string2Date(year, "yyyy");
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(useDate);
+        //获取年中周数量
+        int weeksCount = cal.getWeeksInWeekYear();
+        Map<Integer, String> mapWeeks = new HashMap<>(55);
+        for (int i = 0; i < weeksCount; i++) {
+            cal.get(Calendar.DAY_OF_YEAR);
+            mapWeeks.put(i + 1, date2StringS(getFirstDayOfWeek(cal.get(Calendar.YEAR), i)));
+        }
+        return mapWeeks;
+    }
+
+    /**
+     * 获取某年的第几周的开始日期
+     *
+     * @param year 年分
+     * @param week 周索引
+     * @return 开始日期
+     * @throws Exception
+     */
+    public static Date getFirstDayOfWeek(int year, int week) throws Exception {
+        Calendar c = new GregorianCalendar();
+        c.set(Calendar.YEAR, year);
+        c.set(Calendar.MONTH, Calendar.JANUARY);
+        c.set(Calendar.DATE, 1);
+
+        Calendar cal = (GregorianCalendar) c.clone();
+        cal.add(Calendar.DATE, week * 7);
+
+        return getFirstDayOfWeek(cal.getTime());
+    }
+
+    /**
+     * 获取某年的第几周的结束日期
+     *
+     * @param year 年份
+     * @param week 周索引
+     * @return 结束日期
+     * @throws Exception
+     */
+    public static Date getLastDayOfWeek(int year, int week) throws Exception {
+        Calendar c = new GregorianCalendar();
+        c.set(Calendar.YEAR, year);
+        c.set(Calendar.MONTH, Calendar.JANUARY);
+        c.set(Calendar.DATE, 1);
+
+        Calendar cal = (GregorianCalendar) c.clone();
+        cal.add(Calendar.DATE, week * 7);
+
+        return getLastDayOfWeek(cal.getTime());
+    }
+
+    /**
+     * 获取当前时间所在周的开始日期
+     *
+     * @param date 当前时间
+     * @return 开始时间
+     */
+    public static Date getFirstDayOfWeek(Date date) {
+        Calendar c = new GregorianCalendar();
+        c.setFirstDayOfWeek(Calendar.SUNDAY);
+        c.setTime(date);
+        c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek());
+        return c.getTime();
+    }
+
+    /**
+     * 获取当前时间所在周的结束日期
+     *
+     * @param date 当前时间
+     * @return 结束日期
+     */
+    public static Date getLastDayOfWeek(Date date) {
+        Calendar c = new GregorianCalendar();
+        c.setFirstDayOfWeek(Calendar.SUNDAY);
+        c.setTime(date);
+        c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek() + 6);
+        return c.getTime();
+    }
+    //获得上周一的日期
+    public static Date geLastWeekMonday(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(getThisWeekMonday(date));
+        cal.add(Calendar.DATE, -7);
+        return cal.getTime();
+    }
+
+    //获得本周一的日期
+    public static Date getThisWeekMonday(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        // 获得当前日期是一个星期的第几天
+        int dayWeek = cal.get(Calendar.DAY_OF_WEEK);
+        if (1 == dayWeek) {
+            cal.add(Calendar.DAY_OF_MONTH, -1);
+        }
+        // 设置一个星期的第一天,按中国的习惯一个星期的第一天是星期一
+        cal.setFirstDayOfWeek(Calendar.MONDAY);
+        // 获得当前日期是一个星期的第几天
+        int day = cal.get(Calendar.DAY_OF_WEEK);
+        // 根据日历的规则,给当前日期减去星期几与一个星期第一天的差值
+        cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - day);
+        return cal.getTime();
+    }
+
+    //获得下周一的日期
+    public static Date getNextWeekMonday(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(getThisWeekMonday(date));
+        cal.add(Calendar.DATE, 7);
+        return cal.getTime();
+    }
+
+    //获得今天日期
+    public static Date getToday(){
+        return new Date();
+    }
+
+    //获得本月一日的日期
+    public static Date getFirstDay4ThisMonth(){
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.DAY_OF_MONTH,1);
+        return calendar.getTime();
+    }
+
+    public static void main(String[] args) {
+        try {
+            System.out.println("本周一" + date2StringS(getThisWeekMonday()));
+            System.out.println("本月一日" + date2StringS(getFirstDay4ThisMonth()));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 32 - 0
power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/PowerTemperatureController.java

@@ -0,0 +1,32 @@
+package com.gyee.power.fitting.controller.analyse;
+
+
+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.temperature.PowerTemperatureService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 功率温度分析
+ */
+@RestController
+@CrossOrigin
+@RequestMapping("/temperature")
+public class PowerTemperatureController {
+
+    @Autowired
+    private PowerTemperatureService powerTemperatureService;
+
+    /***
+     * 与温度有关的稳定功率
+     * @param ids  预处理数据的id
+     * @return
+     */
+    @GetMapping("rated/power")
+    public JSONObject ratedPower(String ids){
+        Object o = powerTemperatureService.ratedPower(ids);
+        return JsonResult.successData(ResultCode.SUCCESS, o);
+    }
+}

+ 0 - 33
power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/RatioController.java

@@ -1,33 +0,0 @@
-package com.gyee.power.fitting.controller.analyse;
-
-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.ratio.RatioService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-/**
- */
-@RestController
-@CrossOrigin
-@RequestMapping("/wind")
-public class RatioController {
-
-    @Autowired
-    private RatioService ratioService;
-
-    /**
-     * 对风偏差分析
-     * @param ids  预处理数据 ids
-     * @param mode 拟合方式  0:单台统计   1:合并统计
-     * @return
-     */
-    @GetMapping("deviation/ratio")
-    public JSONObject fsRoses(String ids, @RequestParam(value = "mode",  required = false) Integer mode){
-        mode = mode == null ? 0 : mode;
-        Object o = ratioService.windDeviationRatio(ids, mode);
-        return JsonResult.successData(ResultCode.SUCCESS, o);
-    }
-
-}

+ 18 - 1
power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/WindDirectionController.java

@@ -4,7 +4,8 @@ package com.gyee.power.fitting.controller.analyse;
 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.fx.WindDirectionService;
+import com.gyee.power.fitting.service.custom.socket.RatioService;
+import com.gyee.power.fitting.service.custom.windresource.WindDirectionService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -18,6 +19,9 @@ import org.springframework.web.bind.annotation.*;
 public class WindDirectionController {
 
     @Autowired
+    private RatioService ratioService;
+
+    @Autowired
     private WindDirectionService windDirectionService;
 
     /***
@@ -45,4 +49,17 @@ public class WindDirectionController {
         Object o = windDirectionService.fxCountRoses(ids, mode);
         return JsonResult.successData(ResultCode.SUCCESS, o);
     }
+
+    /**
+     * 对风偏差分析
+     * @param ids  预处理数据 ids
+     * @param mode 拟合方式  0:单台统计   1:合并统计
+     * @return
+     */
+    @GetMapping("deviation/ratio")
+    public JSONObject fsDeviationRatio(String ids, @RequestParam(value = "mode",  required = false) Integer mode){
+        mode = mode == null ? 0 : mode;
+        Object o = ratioService.windDeviationRatio(ids, mode);
+        return JsonResult.successData(ResultCode.SUCCESS, o);
+    }
 }

+ 23 - 0
power-fitting/src/main/java/com/gyee/power/fitting/controller/base/CurveFittingController.java

@@ -0,0 +1,23 @@
+package com.gyee.power.fitting.controller.base;
+
+import com.gyee.power.fitting.common.feign.IAdapterService;
+import com.gyee.power.fitting.service.Windturbinetestingpointai2Service;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+@RestController("curvefitting")
+public class CurveFittingController {
+    @Resource
+    private Windturbinetestingpointai2Service windturbinetestingpointai2Service;
+    @Resource
+    private IAdapterService iAdapterService;
+
+    @GetMapping("/")
+    private void get(@RequestParam("wtid") String wtid){
+        wtid = "HZJ01_01";
+        windturbinetestingpointai2Service.getZlTag(wtid);
+    }
+}

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

@@ -0,0 +1,16 @@
+package com.gyee.power.fitting.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.power.fitting.model.Photovoltaiccapacity;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author gfhd
+ * @since 2022-12-13
+ */
+public interface PhotovoltaiccapacityMapper extends BaseMapper<Photovoltaiccapacity> {
+
+}

+ 18 - 0
power-fitting/src/main/java/com/gyee/power/fitting/mapper/PhotovoltaicivMapper.java

@@ -0,0 +1,18 @@
+package com.gyee.power.fitting.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.power.fitting.model.Photovoltaiciv;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author gfhd
+ * @since 2022-12-13
+ */
+@Mapper
+public interface PhotovoltaicivMapper extends BaseMapper<Photovoltaiciv> {
+
+}

+ 18 - 0
power-fitting/src/main/java/com/gyee/power/fitting/mapper/Windpowerstationtestingpoint2Mapper.java

@@ -0,0 +1,18 @@
+package com.gyee.power.fitting.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.power.fitting.model.Windpowerstationtestingpoint2;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author gfhd
+ * @since 2022-12-13
+ */
+@Mapper
+public interface Windpowerstationtestingpoint2Mapper extends BaseMapper<Windpowerstationtestingpoint2> {
+
+}

+ 78 - 0
power-fitting/src/main/java/com/gyee/power/fitting/model/Photovoltaiccapacity.java

@@ -0,0 +1,78 @@
+package com.gyee.power.fitting.model;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author gfhd
+ * @since 2022-12-13
+ */
+public class Photovoltaiccapacity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+
+    private Short branchesnum;
+
+    private Integer platesnum;
+
+    private BigDecimal ratedcapacity;
+
+    private String stationid;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public Short getBranchesnum() {
+        return branchesnum;
+    }
+
+    public void setBranchesnum(Short branchesnum) {
+        this.branchesnum = branchesnum;
+    }
+
+    public Integer getPlatesnum() {
+        return platesnum;
+    }
+
+    public void setPlatesnum(Integer platesnum) {
+        this.platesnum = platesnum;
+    }
+
+    public BigDecimal getRatedcapacity() {
+        return ratedcapacity;
+    }
+
+    public void setRatedcapacity(BigDecimal ratedcapacity) {
+        this.ratedcapacity = ratedcapacity;
+    }
+
+    public String getStationid() {
+        return stationid;
+    }
+
+    public void setStationid(String stationid) {
+        this.stationid = stationid;
+    }
+
+    @Override
+    public String toString() {
+        return "Photovoltaiccapacity{" +
+            "id = " + id +
+            ", branchesnum = " + branchesnum +
+            ", platesnum = " + platesnum +
+            ", ratedcapacity = " + ratedcapacity +
+            ", stationid = " + stationid +
+        "}";
+    }
+}

+ 77 - 0
power-fitting/src/main/java/com/gyee/power/fitting/model/Photovoltaiciv.java

@@ -0,0 +1,77 @@
+package com.gyee.power.fitting.model;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author gfhd
+ * @since 2022-12-13
+ */
+public class Photovoltaiciv implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+
+    private String windturbineid;
+
+    private Short branchnum;
+
+    private String electric;
+
+    private String description;
+
+    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 Short getBranchnum() {
+        return branchnum;
+    }
+
+    public void setBranchnum(Short branchnum) {
+        this.branchnum = branchnum;
+    }
+
+    public String getElectric() {
+        return electric;
+    }
+
+    public void setElectric(String electric) {
+        this.electric = electric;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Override
+    public String toString() {
+        return "Photovoltaiciv{" +
+            "id = " + id +
+            ", windturbineid = " + windturbineid +
+            ", branchnum = " + branchnum +
+            ", electric = " + electric +
+            ", description = " + description +
+        "}";
+    }
+}

+ 199 - 0
power-fitting/src/main/java/com/gyee/power/fitting/model/Windpowerstationtestingpoint2.java

@@ -0,0 +1,199 @@
+package com.gyee.power.fitting.model;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author gfhd
+ * @since 2022-12-13
+ */
+public class Windpowerstationtestingpoint2 implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private String code;
+
+    private String name;
+
+    private String model;
+
+    private String valueunit;
+
+    private String englishname;
+
+    private String typeid;
+
+    private String modelid;
+
+    private BigDecimal maxval;
+
+    private BigDecimal minval;
+
+    private BigDecimal reasonablemaxval;
+
+    private BigDecimal reasonableminval;
+
+    private String uniformcode;
+
+    private String shortid;
+
+    private String longid;
+
+    private String windpowerstationid;
+
+    private String realtimeid;
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getModel() {
+        return model;
+    }
+
+    public void setModel(String model) {
+        this.model = model;
+    }
+
+    public String getValueunit() {
+        return valueunit;
+    }
+
+    public void setValueunit(String valueunit) {
+        this.valueunit = valueunit;
+    }
+
+    public String getEnglishname() {
+        return englishname;
+    }
+
+    public void setEnglishname(String englishname) {
+        this.englishname = englishname;
+    }
+
+    public String getTypeid() {
+        return typeid;
+    }
+
+    public void setTypeid(String typeid) {
+        this.typeid = typeid;
+    }
+
+    public String getModelid() {
+        return modelid;
+    }
+
+    public void setModelid(String modelid) {
+        this.modelid = modelid;
+    }
+
+    public BigDecimal getMaxval() {
+        return maxval;
+    }
+
+    public void setMaxval(BigDecimal maxval) {
+        this.maxval = maxval;
+    }
+
+    public BigDecimal getMinval() {
+        return minval;
+    }
+
+    public void setMinval(BigDecimal minval) {
+        this.minval = minval;
+    }
+
+    public BigDecimal getReasonablemaxval() {
+        return reasonablemaxval;
+    }
+
+    public void setReasonablemaxval(BigDecimal reasonablemaxval) {
+        this.reasonablemaxval = reasonablemaxval;
+    }
+
+    public BigDecimal getReasonableminval() {
+        return reasonableminval;
+    }
+
+    public void setReasonableminval(BigDecimal reasonableminval) {
+        this.reasonableminval = reasonableminval;
+    }
+
+    public String getUniformcode() {
+        return uniformcode;
+    }
+
+    public void setUniformcode(String uniformcode) {
+        this.uniformcode = uniformcode;
+    }
+
+    public String getShortid() {
+        return shortid;
+    }
+
+    public void setShortid(String shortid) {
+        this.shortid = shortid;
+    }
+
+    public String getLongid() {
+        return longid;
+    }
+
+    public void setLongid(String longid) {
+        this.longid = longid;
+    }
+
+    public String getWindpowerstationid() {
+        return windpowerstationid;
+    }
+
+    public void setWindpowerstationid(String windpowerstationid) {
+        this.windpowerstationid = windpowerstationid;
+    }
+
+    public String getRealtimeid() {
+        return realtimeid;
+    }
+
+    public void setRealtimeid(String realtimeid) {
+        this.realtimeid = realtimeid;
+    }
+
+    @Override
+    public String toString() {
+        return "Windpowerstationtestingpoint2{" +
+            "code = " + code +
+            ", name = " + name +
+            ", model = " + model +
+            ", valueunit = " + valueunit +
+            ", englishname = " + englishname +
+            ", typeid = " + typeid +
+            ", modelid = " + modelid +
+            ", maxval = " + maxval +
+            ", minval = " + minval +
+            ", reasonablemaxval = " + reasonablemaxval +
+            ", reasonableminval = " + reasonableminval +
+            ", uniformcode = " + uniformcode +
+            ", shortid = " + shortid +
+            ", longid = " + longid +
+            ", windpowerstationid = " + windpowerstationid +
+            ", realtimeid = " + realtimeid +
+        "}";
+    }
+}

+ 5 - 1
power-fitting/src/main/java/com/gyee/power/fitting/model/custom/PowerPointData.java

@@ -26,6 +26,7 @@ public class PowerPointData {
             this.fx = Double.valueOf(df.format(Double.valueOf(str[7])));
             this.dfwc = Double.valueOf(df.format(Double.valueOf(str[8])));
             this.angle = Double.valueOf(df.format(Double.valueOf(str[9])));
+            this.hjwd = Double.valueOf(df.format(Double.valueOf(str[10])));
         }
         if (isFilter)
             this.filter = Integer.valueOf(str[str.length - 1]);
@@ -47,7 +48,7 @@ public class PowerPointData {
     @Desc(value = "转速", remark = "1")
     private double rr = 0;
 
-    //明细状态
+    //明细状态  0-待机  1-手动停机  2-正常发电  3-缺陷降出力  4-限电降出力  5-限电停机  6-故障停机  7-场内受累停机  8-检修停机  9-场内受累检修  10-电网受累  11-环境受累  12-风机离线
     @Desc(value = "风机状态", remark = "1")
     private int mxzt = 0;
 
@@ -71,6 +72,9 @@ public class PowerPointData {
     @Desc(value = "偏航角度", remark = "1")
     private double angle = 0;
 
+    @Desc(value = "环境温度", remark = "1")
+    private double hjwd = 0;
+
     //是否过滤  0:不过滤 1:过滤
     @Desc(value = "筛选", remark = "0")
     private int filter = 0;

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

@@ -1,7 +1,7 @@
 package com.gyee.power.fitting.service;
 
-import com.gyee.power.fitting.model.Equipmentmodel;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.power.fitting.model.Equipmentmodel;
 
 import java.util.List;
 

+ 16 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/IPhotovoltaiccapacityService.java

@@ -0,0 +1,16 @@
+package com.gyee.power.fitting.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.power.fitting.model.Photovoltaiccapacity;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2022-12-13
+ */
+public interface IPhotovoltaiccapacityService extends IService<Photovoltaiccapacity> {
+
+}

+ 16 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/IPhotovoltaicivService.java

@@ -0,0 +1,16 @@
+package com.gyee.power.fitting.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.power.fitting.model.Photovoltaiciv;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2022-12-13
+ */
+public interface IPhotovoltaicivService extends IService<Photovoltaiciv> {
+
+}

+ 17 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/IWindpowerstationtestingpoint2Service.java

@@ -0,0 +1,17 @@
+package com.gyee.power.fitting.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.power.fitting.model.Windpowerstationtestingpoint2;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2022-12-13
+ */
+public interface IWindpowerstationtestingpoint2Service extends IService<Windpowerstationtestingpoint2> {
+
+    Windpowerstationtestingpoint2 getStationIllumination(String gdc);
+}

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

@@ -1,7 +1,7 @@
 package com.gyee.power.fitting.service;
 
-import com.gyee.power.fitting.model.Modelpower;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.power.fitting.model.Modelpower;
 
 import java.util.List;
 

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

@@ -1,7 +1,7 @@
 package com.gyee.power.fitting.service;
 
-import com.gyee.power.fitting.model.Modelpowerdetails;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.power.fitting.model.Modelpowerdetails;
 
 import java.util.List;
 

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

@@ -1,7 +1,7 @@
 package com.gyee.power.fitting.service;
 
-import com.gyee.power.fitting.model.Powerfittinganalysis;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.power.fitting.model.Powerfittinganalysis;
 
 import java.util.List;
 

+ 5 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/Windturbinetestingpointai2Service.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.gyee.power.fitting.model.Windturbinetestingpointai2;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -16,4 +17,8 @@ import java.util.List;
 public interface Windturbinetestingpointai2Service extends IService<Windturbinetestingpointai2> {
 
     List<Windturbinetestingpointai2> selectList(String station, List<String> points);
+
+    void getZlTag(String wtid);
+
+    List<Windturbinetestingpointai2> getFaultCodes();
 }

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

@@ -1,12 +1,12 @@
 package com.gyee.power.fitting.service.custom.curve;
 
 import com.gyee.power.fitting.common.alg.DBSCANPointALG;
+import com.gyee.power.fitting.common.alg.PowerFittingALG;
 import com.gyee.power.fitting.common.config.GyeeConfig;
 import com.gyee.power.fitting.common.constants.Constants;
 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.common.alg.PowerFittingALG;
 import com.gyee.power.fitting.common.util.PowerFittingUtil;
 import com.gyee.power.fitting.common.util.SnowFlakeUtil;
 import com.gyee.power.fitting.model.Modelpowerdetails;

+ 8 - 2
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/DataPrepareService.java

@@ -6,7 +6,10 @@ import com.gyee.power.fitting.common.feign.RemoteServiceBuilder;
 import com.gyee.power.fitting.common.result.JsonResult;
 import com.gyee.power.fitting.common.result.ResultCode;
 import com.gyee.power.fitting.common.spring.InitialRunner;
-import com.gyee.power.fitting.common.util.*;
+import com.gyee.power.fitting.common.util.DateUtil;
+import com.gyee.power.fitting.common.util.FileUtil;
+import com.gyee.power.fitting.common.util.NumberUtil;
+import com.gyee.power.fitting.common.util.PowerFittingUtil;
 import com.gyee.power.fitting.model.Powerfittinganalysis;
 import com.gyee.power.fitting.model.Windturbinetestingpointai2;
 import com.gyee.power.fitting.model.anno.AnnotationTool;
@@ -23,7 +26,10 @@ import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
 import java.text.DecimalFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 @Slf4j

+ 7 - 2
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/DataProcessService.java

@@ -5,7 +5,9 @@ import com.gyee.power.fitting.common.alg.PowerProcessALG;
 import com.gyee.power.fitting.common.config.GyeeConfig;
 import com.gyee.power.fitting.common.constants.Constants;
 import com.gyee.power.fitting.common.spring.InitialRunner;
-import com.gyee.power.fitting.common.util.*;
+import com.gyee.power.fitting.common.util.FileUtil;
+import com.gyee.power.fitting.common.util.PowerFittingUtil;
+import com.gyee.power.fitting.common.util.SnowFlakeUtil;
 import com.gyee.power.fitting.model.Modelpowerdetails;
 import com.gyee.power.fitting.model.Powerfittinganalysis;
 import com.gyee.power.fitting.model.anno.AnnotationTool;
@@ -17,7 +19,10 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 @Service

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

@@ -1,4 +1,4 @@
-package com.gyee.power.fitting.service.custom.ratio;
+package com.gyee.power.fitting.service.custom.socket;
 
 
 import com.gyee.power.fitting.common.alg.PowerFittingALG;

+ 83 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/temperature/PowerTemperatureService.java

@@ -0,0 +1,83 @@
+package com.gyee.power.fitting.service.custom.temperature;
+
+import com.gyee.power.fitting.common.alg.PowerTemperatureAlg;
+import com.gyee.power.fitting.common.spring.InitialRunner;
+import com.gyee.power.fitting.common.util.FileUtil;
+import com.gyee.power.fitting.model.Modelpowerdetails;
+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 PowerTemperatureService {
+
+    @Autowired
+    private PowerfittinganalysisService powerService;
+
+    /**
+     * 与温度有关的额定功率
+     * @param ids
+     */
+    public Object ratedPower(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<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);
+            mp.put("res2", rp);
+            result.add(mp);
+        }
+
+        return result;
+    }
+
+
+
+    /**
+     * csv 文件解析成对象
+     * @param obj
+     * @return
+     */
+    private Map<String, Object> csvParse(Powerfittinganalysis obj){
+        Map<String, Object> map = new HashMap<>();
+        double minT = 0.0;
+        double maxT = 0.0;
+        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);
+            if (data.getSpeed() < 0 || data.getPower() < 0)
+                continue;
+            data.setWtId(obj.getWindturbine());
+
+            minT = data.getHjwd() < minT ? data.getHjwd() : minT;
+            maxT = data.getHjwd() > maxT ? data.getHjwd() : maxT;
+            ls.add(data);
+        }
+        map.put("data", ls);
+        map.put("minT", minT);
+        map.put("maxT", maxT);
+        return map;
+    }
+}

+ 7 - 2
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/fx/WindDirectionService.java

@@ -1,4 +1,4 @@
-package com.gyee.power.fitting.service.custom.fx;
+package com.gyee.power.fitting.service.custom.windresource;
 
 import com.gyee.power.fitting.common.alg.PowerFittingALG;
 import com.gyee.power.fitting.common.alg.WindDirectionALG;
@@ -9,7 +9,12 @@ import com.gyee.power.fitting.service.PowerfittinganalysisService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.*;;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+;
 
 
 @Service

+ 2 - 2
power-fitting/src/main/java/com/gyee/power/fitting/service/impl/EquipmentmodelServiceImpl.java

@@ -1,9 +1,9 @@
 package com.gyee.power.fitting.service.impl;
 
-import com.gyee.power.fitting.model.Equipmentmodel;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gyee.power.fitting.mapper.EquipmentmodelMapper;
+import com.gyee.power.fitting.model.Equipmentmodel;
 import com.gyee.power.fitting.service.EquipmentmodelService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;

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

@@ -1,9 +1,9 @@
 package com.gyee.power.fitting.service.impl;
 
-import com.gyee.power.fitting.model.Modelpower;
+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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;

+ 2 - 2
power-fitting/src/main/java/com/gyee/power/fitting/service/impl/ModelpowerdetailsServiceImpl.java

@@ -1,10 +1,10 @@
 package com.gyee.power.fitting.service.impl;
 
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gyee.power.fitting.common.base.ExcludeQueryWrapper;
-import com.gyee.power.fitting.model.Modelpowerdetails;
 import com.gyee.power.fitting.mapper.ModelpowerdetailsMapper;
+import com.gyee.power.fitting.model.Modelpowerdetails;
 import com.gyee.power.fitting.service.ModelpowerdetailsService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;

+ 20 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/impl/PhotovoltaiccapacityServiceImpl.java

@@ -0,0 +1,20 @@
+package com.gyee.power.fitting.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.power.fitting.mapper.PhotovoltaiccapacityMapper;
+import com.gyee.power.fitting.model.Photovoltaiccapacity;
+import com.gyee.power.fitting.service.IPhotovoltaiccapacityService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2022-12-13
+ */
+@Service
+public class PhotovoltaiccapacityServiceImpl extends ServiceImpl<PhotovoltaiccapacityMapper, Photovoltaiccapacity> implements IPhotovoltaiccapacityService {
+
+}

+ 20 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/impl/PhotovoltaicivServiceImpl.java

@@ -0,0 +1,20 @@
+package com.gyee.power.fitting.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.power.fitting.mapper.PhotovoltaicivMapper;
+import com.gyee.power.fitting.model.Photovoltaiciv;
+import com.gyee.power.fitting.service.IPhotovoltaicivService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2022-12-13
+ */
+@Service
+public class PhotovoltaicivServiceImpl extends ServiceImpl<PhotovoltaicivMapper, Photovoltaiciv> implements IPhotovoltaicivService {
+
+}

+ 2 - 2
power-fitting/src/main/java/com/gyee/power/fitting/service/impl/PowerfittinganalysisServiceImpl.java

@@ -1,11 +1,11 @@
 package com.gyee.power.fitting.service.impl;
 
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gyee.power.fitting.common.base.ExcludeQueryWrapper;
 import com.gyee.power.fitting.common.util.SnowFlakeUtil;
-import com.gyee.power.fitting.model.Powerfittinganalysis;
 import com.gyee.power.fitting.mapper.PowerfittinganalysisMapper;
+import com.gyee.power.fitting.model.Powerfittinganalysis;
 import com.gyee.power.fitting.service.PowerfittinganalysisService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;

+ 27 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/impl/Windpowerstationtestingpoint2ServiceImpl.java

@@ -0,0 +1,27 @@
+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.mapper.Windpowerstationtestingpoint2Mapper;
+import com.gyee.power.fitting.model.Windpowerstationtestingpoint2;
+import com.gyee.power.fitting.service.IWindpowerstationtestingpoint2Service;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2022-12-13
+ */
+@Service
+public class Windpowerstationtestingpoint2ServiceImpl extends ServiceImpl<Windpowerstationtestingpoint2Mapper, Windpowerstationtestingpoint2> implements IWindpowerstationtestingpoint2Service {
+
+    @Override
+    public Windpowerstationtestingpoint2 getStationIllumination(String gdc) {
+        QueryWrapper<Windpowerstationtestingpoint2> wrapper = new QueryWrapper<>();
+        wrapper.eq("UNIFORMCODE", "SSFS").eq("WINDPOWERSTATIONID", gdc);
+        return baseMapper.selectList(wrapper).get(0);
+    }
+}

+ 18 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/impl/Windturbinetestingpointai2ServiceImpl.java

@@ -1,5 +1,6 @@
 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.mapper.Windturbinetestingpointai2Mapper;
@@ -9,6 +10,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -21,6 +23,7 @@ import java.util.List;
 @Service
 public class Windturbinetestingpointai2ServiceImpl extends ServiceImpl<Windturbinetestingpointai2Mapper, Windturbinetestingpointai2> implements Windturbinetestingpointai2Service {
 
+    private List<Windturbinetestingpointai2> faultCodes;
     @Override
     public List<Windturbinetestingpointai2> selectList(String station, List<String> points) {
         List<Windturbinetestingpointai2> list = new ArrayList();
@@ -37,4 +40,19 @@ public class Windturbinetestingpointai2ServiceImpl extends ServiceImpl<Windturbi
 
         return list;
     }
+
+    @Override
+    public void getZlTag(String wtid) {
+        QueryWrapper<Windturbinetestingpointai2> wrapper = new QueryWrapper<>();
+    }
+
+    @Override
+    public List<Windturbinetestingpointai2> getFaultCodes() {
+        if (faultCodes == null) {
+            QueryWrapper<Windturbinetestingpointai2> wrapper = new QueryWrapper<>();
+            wrapper.eq("UNIFORMCODE", "AI0001").eq("WINDTURBINEID", "HZJ01_01");
+            faultCodes = baseMapper.selectList(wrapper);
+        }
+        return faultCodes;
+    }
 }

+ 2 - 2
power-fitting/src/main/resources/application.yaml

@@ -9,8 +9,8 @@ gyee:
   file-path-fitting: data\fitting\
   # 数据压缩下载
   file-path-download: data\zip\
-  # 风机实发功率\风机风速\发电机转速\明细状态\风机日发电量\实时欠发状态\风向\对风角度(对风误差)\偏航角度  顺序不能乱
-  points: AI130,AI022,AI128,ZTMX,RFDL,RSSQFZT,AI008,AI036,AI034
+  # 风机实发功率\风机风速\发电机转速\明细状态\风机日发电量\实时欠发状态\风向\对风角度(对风误差)\偏航角度\环境温度  顺序不能乱
+  points: AI130,AI022,AI128,ZTMX,RFDL,RSSQFZT,AI008,AI036,AI034,AI056
   # 数据准备时由于数据量太大,初始一个默认间隔,用于适配器取数
   interval: 20
   # 当前是否是离线环境

+ 4 - 4
power-fitting/src/test/java/AlgTest.java

@@ -15,9 +15,9 @@ public class AlgTest {
 
         int order = 2;
         double[] result = new double[3];
-    //   MpptFittingAlg.BuildLine_PV_Poly(arrX,arrY,order);
-       MpptFittingAlg.BuildLine_PV_LSC(arrX,arrY,10,10,0.1);
-      //  MpptFittingAlg.BuildLine_IV_LSC(arrX,arrY,10,10,0.1);
+       MpptFittingAlg.BuildLine_PV_Poly(arrX,arrY,order);
+       //MpptFittingAlg.BuildLine_PV_LSC(arrX,arrY,10,10,0.1);
+       //MpptFittingAlg.BuildLine_IV_LSC(arrX,arrY,10,10,0.1);
     }
 
     /**
@@ -28,7 +28,7 @@ public class AlgTest {
         int i=0;
         List<Map<Integer,String>> list = new LinkedList<>(); //初始化列表
 
-        EasyExcel.read("D:/JavaCode/WTest.xlsx") //文件路径
+        EasyExcel.read("D:/光伏经济运行/WTest.xlsx") //文件路径
                 .sheet(sheet) //表单名
                 .registerReadListener(new AnalysisEventListener<Map<Integer,String>>() { //监听器,以行的形式读取Excel
 

+ 14 - 0
power-fitting/src/test/java/CurveFittingTest.java

@@ -0,0 +1,14 @@
+
+import com.gyee.power.fitting.common.alg.PolynomialCurveFitting;
+import com.gyee.power.fitting.common.alg.TimeCostCalculator;
+
+public class CurveFittingTest {
+    public static void main(String[] args) {
+        TimeCostCalculator tcc = new TimeCostCalculator();
+        double timeCost;
+        System.out.println("--------------------------------------------------------------------------");
+        timeCost = tcc.calcTimeCost(new PolynomialCurveFitting());
+        System.out.println("time cost is: " + timeCost + "s");
+        System.out.println("--------------------------------------------------------------------------");
+    }
+}

+ 271 - 0
power-fitting/src/test/java/PhotovoltaicEconomicOperationTest.java

@@ -0,0 +1,271 @@
+
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.power.fitting.PowerBootApplication;
+import com.gyee.power.fitting.common.alg.PolynomialCurveFitting;
+import com.gyee.power.fitting.common.feign.IAdapterService;
+import com.gyee.power.fitting.common.util.DateUtils;
+import com.gyee.power.fitting.model.Photovoltaiccapacity;
+import com.gyee.power.fitting.model.Photovoltaiciv;
+import com.gyee.power.fitting.model.Windpowerstationtestingpoint2;
+import com.gyee.power.fitting.model.custom.TsDoubleData;
+import com.gyee.power.fitting.service.IPhotovoltaiccapacityService;
+import com.gyee.power.fitting.service.IPhotovoltaicivService;
+import com.gyee.power.fitting.service.IWindpowerstationtestingpoint2Service;
+import com.gyee.power.fitting.service.Windturbinetestingpointai2Service;
+import org.apache.commons.math3.fitting.WeightedObservedPoint;
+import org.apache.commons.math3.fitting.WeightedObservedPoints;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import javax.annotation.Resource;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 光伏经济运行
+ */
+@SpringBootTest(classes = PowerBootApplication.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+public class PhotovoltaicEconomicOperationTest {
+
+    @Resource
+    private Windturbinetestingpointai2Service windturbinetestingpointai2Service;
+    @Resource
+    private IAdapterService adpClient;
+    @Resource
+    private IPhotovoltaicivService photovoltaicivService;
+    @Resource
+    private IWindpowerstationtestingpoint2Service windpowerstationtestingpoint2Service;
+    @Resource
+    private IPhotovoltaiccapacityService photovoltaiccapacityService;
+
+    @Test()
+    public void test() throws Exception {
+        PolynomialCurveFitting pncf = new PolynomialCurveFitting();
+        //HZJGGL.NX_GD_HZJG_YC_P1_L1_001_QXZ006
+        List<String> list = new ArrayList<>(); //初始化列表
+
+        EasyExcel.read("D:/工作簿2.xlsx") //文件路径
+                .sheet("Sheet1") //表单名
+                .registerReadListener(new AnalysisEventListener<Map<Integer,String>>() { //监听器,以行的形式读取Excel
+
+                    //一行一行读取Excel,在这里处理读取到的数据
+                    @Override
+                    public void invoke(Map<Integer, String> integerStringMap, AnalysisContext analysisContext) {
+                        // TODO Auto-generated method stub
+                        list.add(integerStringMap.get(0)); //将读取到的每一行为一组存入列表中
+                    }
+
+                    //数据读取完毕后运行下面
+                    @Override
+                    public void doAfterAllAnalysed(AnalysisContext context) {
+                        System.out.println("数据读取完毕");
+                    }
+                }).headRowNumber(0).doRead();
+        /*QueryWrapper<Photovoltaiccapacity> wrap = new QueryWrapper<>();
+        wrap.eq("STATIONID", "HZJ_GDC");
+        List<Photovoltaiccapacity> list = photovoltaiccapacityService.list(wrap);*/
+        WeightedObservedPoints points = new WeightedObservedPoints();
+        //获取场站光照测点
+        Windpowerstationtestingpoint2 hzj_gdc = windpowerstationtestingpoint2Service.getStationIllumination("HZJ_GDC");
+        long start = DateUtils.string2DateL("2022-12-10 00:00:00").getTime();
+        long end = DateUtils.string2DateL("2022-12-10 23:59:59").getTime();
+        //获取场站光照值
+        List<TsDoubleData> rawValues = adpClient.getRawValuesByKey(hzj_gdc.getCode(), start, end);
+        rawValues=rawValues.stream().filter(rw->rw.getDoubleValue()!=0.0).collect(Collectors.toList());
+        List<TsDoubleData> rawValues2=rawValues.stream().sorted(Comparator.comparing(TsDoubleData::getDoubleValue)).collect(Collectors.toList());
+
+        long tsstart = rawValues.get(0).getTs();
+        long tsend = rawValues.get(rawValues.size() - 1).getTs() + 5*60*1000;
+
+        double[] index = {0.751897050683247, 0.0131420628997927};
+        pncf.printResultAll(rawValues2,index,2);
+        String s1 = pncf.printResultY(rawValues2, index);
+
+
+        List<TsDoubleData> WDvalues = adpClient.getValuesByKey("HZJGGL.NX_GD_HZJG_YC_P1_L1_001_QXZ006", tsstart, tsend, 5 * 60);
+
+        //获取光伏逆变器支路电流电压测点
+        QueryWrapper<Photovoltaiciv> wrapper = new QueryWrapper<>();
+        //wrapper.eq("electric", "电压").lt("rownum",19).orderByAsc("windturbineid");
+        wrapper.eq("electric", "电压");
+        //电压测点
+        List<Photovoltaiciv> DYlist = photovoltaicivService.list(wrapper);
+        wrapper.clear();
+        //wrapper.eq("electric", "电流").lt("rownum",19).orderByAsc("windturbineid");
+        wrapper.eq("electric", "电流");
+        //电流测点
+        List<Photovoltaiciv> DLlist = photovoltaicivService.list(wrapper);
+
+        DYlist=DYlist.stream().filter(dl->!list.contains(dl.getWindturbineid()+dl.getBranchnum())).collect(Collectors.toList());
+        DLlist=DLlist.stream().filter(dl->!list.contains(dl.getWindturbineid()+dl.getBranchnum())).collect(Collectors.toList());
+
+        //逆变器+支路号,时间,电压值
+        Map<String, Map<Long, Double>> DYMapMap = new HashMap<>();
+        //逆变器+支路号,时间,电流值
+        Map<String, Map<Long, Double>> DLMapMap = new HashMap<>();
+        //逆变器+支路号,光照强度,功率
+        Map<String, Map<Double, Double>> GLMapMap = new HashMap<>();
+        Map<String, WeightedObservedPoints> PointsMap = new HashMap<>();
+
+        for (Photovoltaiciv ptvtc : DYlist) {
+            //电压值
+            List<TsDoubleData> DYrawValues = adpClient.getValuesByKey(ptvtc.getId(), tsstart, tsend, 5*60);
+            Map<Long, Double> collect = DYrawValues.stream().collect(Collectors.toMap(TsDoubleData::getTs, TsDoubleData::getDoubleValue));
+            DYMapMap.put(ptvtc.getWindturbineid()+ptvtc.getBranchnum(), collect);
+        }
+
+        for (Photovoltaiciv ptvtc : DLlist) {
+            //电流值
+            List<TsDoubleData> DLrawValues = adpClient.getValuesByKey(ptvtc.getId(), tsstart, tsend, 5*60);
+            Map<Long, Double> collect = DLrawValues.stream().collect(Collectors.toMap(TsDoubleData::getTs, TsDoubleData::getDoubleValue));
+            DLMapMap.put(ptvtc.getWindturbineid()+ptvtc.getBranchnum(), collect);
+        }
+        for (Photovoltaiciv ptvtc : DYlist) {
+            //逆变器+支路号
+            String nbqzl = ptvtc.getWindturbineid() + ptvtc.getBranchnum();
+            Map<Double, Double> GLMap = new LinkedHashMap<>();
+            WeightedObservedPoints pointsOne = new WeightedObservedPoints();
+            for (TsDoubleData rv : rawValues2) {
+                double v = DYMapMap.get(nbqzl).get(rv.getTs()) * 0.001 * DLMapMap.get(nbqzl).get(rv.getTs());
+                /*if((rv.getDoubleValue()<318.0&&v>7.3)||(rv.getDoubleValue()<190.0&&v>4.3)){
+                    System.out.println(nbqzl+","+DYMapMap.get(nbqzl).get(rv.getTs())+","+DLMapMap.get(nbqzl).get(rv.getTs())+","+rv.getTs());
+                }*/
+                GLMap.put(rv.getDoubleValue(), v);
+                points.add(rv.getDoubleValue(), v);
+                pointsOne.add(rv.getDoubleValue(), v);
+            }
+            PointsMap.put(nbqzl, pointsOne);
+            GLMapMap.put(nbqzl, GLMap);
+        }
+        /*for (WeightedObservedPoint point : points.toList()) {
+            System.out.print("[");
+            System.out.printf("%.2f", point.getX());
+            System.out.print(",");
+            System.out.printf("%.2f", point.getY());
+            System.out.println("],\n");
+        }*/
+
+        /*File files = new File("D:/光伏光照强度-功率.txt");
+
+        FileOutputStream fos = new FileOutputStream(files);
+        // 逐行写入
+        PrintWriter pw = new PrintWriter(fos);
+        for (WeightedObservedPoint point : points.toList()) {
+            String s = "[" + String.format("%.2f", point.getX()) + "," + String.format("%.2f", point.getY()) + "],";
+            pw.println(s);
+        }
+        pw.close();*/
+
+        File files = new File("D:/光伏光照强度-功率.txt");
+
+        FileOutputStream fos = new FileOutputStream(files);
+        // 逐行写入
+        PrintWriter pw = new PrintWriter(fos);
+        //文件写入光照强度
+        for (TsDoubleData rawValue : rawValues2) {
+            pw.print(String.format("%.2f", rawValue.getDoubleValue()) + ",");
+        }
+        pw.println();
+        //文件写入各支路功率
+        for (Map.Entry<String, Map<Double, Double>> sme : GLMapMap.entrySet()) {
+            pw.println(sme.getKey());
+            for (Double value : sme.getValue().values()) {
+                String s = String.format("%.2f", value) + ",";
+                pw.print(s);
+            }
+            pw.println();
+        }
+        pw.close();
+
+
+        //double[] run = pncf.run(points);
+        double[] hzj01_22416s = pncf.run(PointsMap.get("HZJ01_22416"));
+        double[] hzj01_1893s = pncf.run(PointsMap.get("HZJ01_1893"));
+
+        /*//计算最差的和最好的
+        for (Map.Entry<String, Map<Double, Double>> sme : GLMapMap.entrySet()) {
+            double v = pncf.calcLow(sme.getValue(), run);
+            System.out.println(sme.getKey()+","+v);
+        }*/
+
+        pncf.printResultAll(rawValues2,index,2);
+        pncf.printResultAll(rawValues2,hzj01_22416s,2);
+        pncf.printResultAll(rawValues2,hzj01_1893s,2);
+    }
+
+    void test2(){
+        String faultCode = windturbinetestingpointai2Service.getFaultCodes().get(0).getId();
+        Calendar instance = Calendar.getInstance();
+        instance.add(Calendar.DATE, -2);
+        long start = DateUtils.getZero(instance).getTimeInMillis();
+        long end = DateUtils.getNight(instance).getTimeInMillis();
+
+        Map<Integer, Map<Long, Double>> 电流MapMap = new HashMap<>();
+        Map<Integer, Map<Long, Double>> 电压MapMap = new HashMap<>();
+        Map<Integer, Map<Long, Double>> 功率MapMap = new HashMap<>();
+        List<List<TsDoubleData>> 电流ListList = new ArrayList<>();
+        List<List<TsDoubleData>> 电压ListList = new ArrayList<>();
+        List<List<Double>> 功率ListList = new ArrayList<>();
+        for (int i = 1; i < 19; i++) {
+            String s = String.valueOf(i);
+            String code = faultCode.substring(0, faultCode.length() - s.length()) + s;
+            //List<TsDoubleData> rawValuesByKey = adpClient.getRawValuesByKey(code, start, end);
+            List<TsDoubleData> rawValuesByKey = adpClient.getValuesByKey(code, start, end, 60);
+            //Map<Long, Double> 电压Map = rawValuesByKey.stream().collect(Collectors.toMap(TsDoubleData::getTs, TsDoubleData::getDoubleValue));
+            //电压MapMap.put(i, 电压Map);
+            电压ListList.add(rawValuesByKey);
+        }
+        for (int j = 19; j < 37; j++) {
+            String s = String.valueOf(j);
+            String code = faultCode.substring(0, faultCode.length() - s.length()) + s;
+            List<TsDoubleData> valuesByKey = adpClient.getValuesByKey(code, start, end, 60);
+            //Map<Long, Double> 电流Map = valuesByKey.stream().collect(Collectors.toMap(TsDoubleData::getTs, TsDoubleData::getDoubleValue));
+            //电流MapMap.put(j - 18, 电流Map);
+            电流ListList.add(valuesByKey);
+        }
+        /*电压MapMap.forEach((i,pdata)->{
+            Map<Long, Double> 功率Map = new HashMap<>();
+            pdata.forEach((ts,data)->{
+                //电流值
+                Double aDouble = 电流MapMap.get(i).get(ts);
+                功率Map.put(ts, data * 0.001 * aDouble);
+            });
+            功率MapMap.put(i, 功率Map);
+        });
+        功率MapMap.forEach((i,pdata)->{
+            System.out.println(i);
+            pdata.forEach((ts,data)->{
+                System.out.print(ts+",");
+            });
+            pdata.forEach((ts,data)->{
+                System.out.print(data+",");
+            });
+        });*/
+        for (int i = 0; i < 电压ListList.size(); i++) {
+            List<TsDoubleData> dyData = 电压ListList.get(i);
+            List<TsDoubleData> dlData = 电流ListList.get(i);
+            List<Double> glData = new ArrayList<>();
+            System.out.println("\n\n\n" + i);
+            for (int j = 0; j < dyData.size(); j++) {
+                double v = dyData.get(j).getDoubleValue() * 0.001 * dlData.get(j).getDoubleValue();
+                glData.add(v);
+            }
+            for (Double glDatum : glData) {
+                System.out.printf("%.2f", glDatum);
+                System.out.print(",");
+            }
+            功率ListList.add(glData);
+        }
+        System.out.println("\n\n\n");
+        for (TsDoubleData dyDatum : 电压ListList.get(0)) {
+            System.out.print(dyDatum.getTs() + ",");
+        }
+    }
+
+}