xushili 1 рік тому
батько
коміт
bca6a03cd0
20 змінених файлів з 1279 додано та 123 видалено
  1. 2 0
      benchmarking-impala/src/main/java/com/gyee/benchmarkingimpala/BenchmarkingImpalaApplication.java
  2. 2 4
      gyee-sample-impala/src/main/java/com/gyee/impala/common/config/datasource/MasterDataSourceConfig.java
  3. 308 0
      power-fitting/src/main/java/com/gyee/power/fitting/common/alg/CurrentVoltageCalc.java
  4. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/common/alg/CurveFitting.java
  5. 30 9
      power-fitting/src/main/java/com/gyee/power/fitting/common/alg/PolynomialCurveFitting.java
  6. 2 2
      power-fitting/src/main/java/com/gyee/power/fitting/common/alg/TimeCostCalculator.java
  7. 1 2
      power-fitting/src/main/java/com/gyee/power/fitting/common/config/GyeeConfig.java
  8. 79 17
      power-fitting/src/main/java/com/gyee/power/fitting/common/spring/InitialRunner.java
  9. 20 21
      power-fitting/src/main/java/com/gyee/power/fitting/common/util/DateUtils.java
  10. 6 1
      power-fitting/src/main/java/com/gyee/power/fitting/common/util/FileUtil.java
  11. 2 2
      power-fitting/src/main/java/com/gyee/power/fitting/common/util/PowerFittingUtil.java
  12. 145 0
      power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/PhotovoltaicController.java
  13. 20 5
      power-fitting/src/main/java/com/gyee/power/fitting/controller/base/WindInfoController.java
  14. 18 55
      power-fitting/src/main/java/com/gyee/power/fitting/model/custom/FjjxbVo.java
  15. 63 0
      power-fitting/src/main/java/com/gyee/power/fitting/model/custom/PhotovoltaicInfo.java
  16. 5 1
      power-fitting/src/main/java/com/gyee/power/fitting/service/IWindpowerstationtestingpoint2Service.java
  17. 2 1
      power-fitting/src/main/java/com/gyee/power/fitting/service/Windturbinetestingpointai2Service.java
  18. 534 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/impl/IvPvCurveFittingService.java
  19. 19 1
      power-fitting/src/main/java/com/gyee/power/fitting/service/impl/Windpowerstationtestingpoint2ServiceImpl.java
  20. 20 1
      power-fitting/src/main/java/com/gyee/power/fitting/service/impl/Windturbinetestingpointai2ServiceImpl.java

+ 2 - 0
benchmarking-impala/src/main/java/com/gyee/benchmarkingimpala/BenchmarkingImpalaApplication.java

@@ -3,7 +3,9 @@ package com.gyee.benchmarkingimpala;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableScheduling;
 
+@EnableScheduling
 @SpringBootApplication
 @MapperScan("com.gyee.benchmarkingimpala.mapper")
 public class BenchmarkingImpalaApplication {

+ 2 - 4
gyee-sample-impala/src/main/java/com/gyee/impala/common/config/datasource/MasterDataSourceConfig.java

@@ -1,8 +1,6 @@
 package com.gyee.impala.common.config.datasource;
 
-import com.baomidou.mybatisplus.core.MybatisConfiguration;
 import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
-import org.apache.ibatis.logging.stdout.StdOutImpl;
 import org.apache.ibatis.session.SqlSessionFactory;
 import org.mybatis.spring.SqlSessionTemplate;
 import org.mybatis.spring.annotation.MapperScan;
@@ -42,9 +40,9 @@ public class MasterDataSourceConfig {
     public SqlSessionFactory masterSqlSessionFactory(@Qualifier("master") DataSource dataSource) throws Exception {
         MybatisSqlSessionFactoryBean sessionFactoryBean = new MybatisSqlSessionFactoryBean();
         sessionFactoryBean.setDataSource(dataSource);
-        MybatisConfiguration mybatisConfiguration = new MybatisConfiguration();
+        /*MybatisConfiguration mybatisConfiguration = new MybatisConfiguration();
         mybatisConfiguration.setLogImpl(StdOutImpl.class);
-        sessionFactoryBean.setConfiguration(mybatisConfiguration);
+        sessionFactoryBean.setConfiguration(mybatisConfiguration);*/
         sessionFactoryBean.setMapperLocations(
                 new PathMatchingResourcePatternResolver().getResources("classpath*:mapper/master/*.xml"));
 

+ 308 - 0
power-fitting/src/main/java/com/gyee/power/fitting/common/alg/CurrentVoltageCalc.java

@@ -0,0 +1,308 @@
+package com.gyee.power.fitting.common.alg;
+
+import com.gyee.power.fitting.model.custom.PhotovoltaicInfo;
+import com.gyee.power.fitting.model.custom.TsDoubleData;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+public class CurrentVoltageCalc {
+
+    private static final double a = 0.0025;
+    private static final double b = 0.5;
+    private static final double c = 0.00288;
+    //标准点
+    private static Map<String, PhotovoltaicInfo> aFixe = new HashMap<>();
+    private static Map<String, PhotovoltaicInfo> bFixe = new HashMap<>();
+    private static Map<String, PhotovoltaicInfo> cFixe = new HashMap<>();
+    //电压系数
+    private final double dyxs = 1.22;
+    //电流系数
+    private final double dlxs = 1.07;
+
+    /**
+     * 计算任意温度下的I、V
+     *
+     * @param Tp 待计算IV的温度
+     * @param Sp 待计算IV的光照
+     * @param T  已测量温度
+     * @param S  已测量光照
+     * @param Im 已测量I
+     * @param Vm 已测量V
+     * @return 待计算I、V
+     */
+    public static PhotovoltaicInfo Calculate(double Tp, double Sp, double T, double S, double Im, double Vm) {
+
+        PhotovoltaicInfo pi = new PhotovoltaicInfo();
+
+        if (Sp < 1 || S < 1) {
+            pi.setT(Tp);
+            pi.setS(Sp);
+            pi.setI(0);
+            pi.setV(0);
+        } else {
+            double DTp = Tp - 25;
+            double DSp = Sp / 1000 - 1;
+            double DT = T - 25;
+            double DS = S / 1000 - 1;
+
+            double Imp = (Im * Sp * (1 + a * DTp)) / (S * (1 + a * DT));
+            double Vmp = (Vm * (1 - c * DTp) * Math.log(Math.E + b * DSp)) / ((1 - c * DT) * Math.log(Math.E + b * DS));
+
+            pi.setT(Tp);
+            pi.setS(Sp);
+            pi.setI(Imp);
+            pi.setV(Vmp);
+        }
+
+        return pi;
+    }
+
+    public static double influencingFactor(double T, double S) {
+
+        if (S < 1) {
+            return 0;
+        } else {
+            double DT = T - 25;
+            double DS = S / 1000 - 1;
+
+            double factor = (S * (1 + a * DT)) * ((1 - c * DT) * Math.log(Math.E + b * DS));
+            return factor;
+        }
+
+    }
+
+    /**
+     * 把每个测点值当成现场测量值,选优
+     *
+     * @param fc 光电场
+     * @param fj 逆变器
+     * @param zl 支路
+     * @return 最优测量点 List<Double> time, T, S, Im, Vm
+     */
+    public static PhotovoltaicInfo ChoosePoint(String fc, String fj, String zl, List<TsDoubleData> T, List<TsDoubleData> S, List<TsDoubleData> Im, List<TsDoubleData> Vm) throws Exception {
+
+        PhotovoltaicInfo standardPI = new PhotovoltaicInfo();
+
+        List<PhotovoltaicInfo> calc = new ArrayList<>();
+
+        for (int m = 0; m < T.size(); m++) {
+            double Tm = T.get(m).getDoubleValue();
+            double Sm = S.get(m).getDoubleValue();
+            double Imm = Im.get(m).getDoubleValue();
+            double Vmm = Vm.get(m).getDoubleValue();
+            long ts = T.get(m).getTs();
+            if (Sm < 5 || Imm < 3 || Vmm < 3) continue;
+            //System.out.println(T.get(m).getTs());
+            PhotovoltaicInfo c = CurrentVoltageCalc.Calculate(20, 400, Tm, Sm, Imm, Vmm);
+            c.setTime(ts);
+            calc.add(c);
+            /*String s = DateUtils.date2StringL(new Date(T.get(m).getTs()));
+            System.out.print(s+","+Tm+","+Sm+","+Imm+","+Vmm+","+c.getI()+","+c.getV());
+            System.out.println();
+            if(standardPI==null){
+                standardPI = new PhotovoltaicInfo();
+                standardPI.setStation(fc);
+                standardPI.setInverter(fj);
+                standardPI.setBranch(zl);
+                standardPI.setT(Tm);
+                standardPI.setS(Sm);
+                standardPI.setI(Imm);
+                standardPI.setV(Vmm);
+            } else if (c.getI() > standardPI.getI() && c.getV() > standardPI.getV() &&
+                    c.getI() < standardPI.getI() * 1.5 && c.getV() < standardPI.getV() * 1.5 &&
+                    c.getI() * c.getV() < 2 * standardPI.getI() * standardPI.getV()) {
+                standardPI.setT(Tm);
+                standardPI.setS(Sm);
+                standardPI.setI(Imm);
+                standardPI.setV(Vmm);
+            }*/
+        }
+        calc = calc.stream().sorted(Comparator.comparing(PhotovoltaicInfo::getP)).collect(Collectors.toList());
+        long time = calc.get(calc.size() / 2).getTime();
+
+        standardPI.setStation(fc);
+        standardPI.setInverter(fj);
+        standardPI.setBranch(zl);
+        standardPI.setTime(time);
+        double TValue = T.stream().filter(t -> t.getTs() == time).findFirst().get().getDoubleValue();
+        double SValue = S.stream().filter(t -> t.getTs() == time).findFirst().get().getDoubleValue();
+        double ImValue = Im.stream().filter(t -> t.getTs() == time).findFirst().get().getDoubleValue();
+        double VmValue = Vm.stream().filter(t -> t.getTs() == time).findFirst().get().getDoubleValue();
+        standardPI.setT(TValue);
+        standardPI.setS(SValue);
+        standardPI.setI(ImValue);
+        standardPI.setV(VmValue);
+
+        return standardPI;
+    }
+
+    public static List<PhotovoltaicInfo> Calculate(List<TsDoubleData> Tp, List<TsDoubleData> Sp, double T, double S, double Im, double Vm) {
+
+        List<PhotovoltaicInfo> pis = new ArrayList<>();
+        for (int i = 0; i < Tp.size(); i++) {
+            PhotovoltaicInfo c = CurrentVoltageCalc.Calculate(Tp.get(i).getDoubleValue(), Sp.get(i).getDoubleValue(), T, S, Im, Vm);
+            c.setTime(Tp.get(i).getTs());
+            pis.add(c);
+        }
+        return pis;
+    }
+
+    public static PhotovoltaicInfo info2Photovoltaic(String station, String inverter, String branch, List<TsDoubleData> zjwdDatas, List<TsDoubleData> zfsDatas, List<TsDoubleData> dlDatas, List<TsDoubleData> dyDatas) {
+        PhotovoltaicInfo pi = new PhotovoltaicInfo();
+        int j = 0;
+        double k = 0;
+        for (int i = 0; i < zjwdDatas.size(); i++) {
+            double v = dlDatas.get(i).getDoubleValue() * dyDatas.get(i).getDoubleValue();
+            if (v > k) {
+                k = v;
+                j = i;
+            }
+        }
+        pi.setStation(station);
+        pi.setInverter(inverter);
+        pi.setBranch(branch);
+        pi.setTime(zjwdDatas.get(j).getTs());
+        pi.setT(zjwdDatas.get(j).getDoubleValue());
+        pi.setS(zfsDatas.get(j).getDoubleValue());
+        pi.setI(dlDatas.get(j).getDoubleValue());
+        pi.setV(dyDatas.get(j).getDoubleValue());
+        return pi;
+    }
+
+    public static List<PhotovoltaicInfo> CalcTheoryPower(List<PhotovoltaicInfo> infos, Map<String, PhotovoltaicInfo> bzcldMap) {
+        //计算理论功率
+        for (PhotovoltaicInfo info : infos) {
+            double theoryPower1 = CurrentVoltageCalc.Calculate(info, bzcldMap.get(info.getInverter()));
+            info.setIdeaP(theoryPower1);
+        }
+        return infos;
+    }
+
+    public static List<PhotovoltaicInfo> CalcTheoryPowerHZJ(List<PhotovoltaicInfo> infos, Map<String, PhotovoltaicInfo> bzcldMap) {
+        //获取标准测量点
+        /*double pMax1 = 0,pMax2 = 0,pMax3 = 0;
+        int j1 = 0, j2 = 0, j3 = 0;
+        for (int i = 0; i <infos.size(); i++) {
+            PhotovoltaicInfo info = infos.get(i);
+            double p1 = info.getAI() * info.getAV();
+            double p2 = info.getBI() * info.getBV();
+            double p3 = info.getCI() * info.getCV();
+            if(p1>pMax1) {
+                pMax1 = p1;
+                j1 = i;
+            }
+            if(p2>pMax2) {
+                pMax2 = p2;
+                j2 = i;
+            }
+            if(p3>pMax3) {
+                pMax3 = p3;
+                j3 = i;
+            }
+        }
+        String inverter = infos.get(0).getInverter();
+        PhotovoltaicInfo aInfo = infos.get(j1);
+        PhotovoltaicInfo bInfo = infos.get(j2);
+        PhotovoltaicInfo cInfo = infos.get(j3);
+        aInfo.setI(aInfo.getAI());
+        aInfo.setV(aInfo.getAV());
+        bInfo.setI(bInfo.getBI());
+        bInfo.setV(bInfo.getBV());
+        cInfo.setI(cInfo.getCI());
+        cInfo.setV(cInfo.getCV());
+        if(!aFixe.containsKey(inverter)){
+            aFixe.put(inverter, aInfo);
+        }else if(aFixe.get(inverter).getAI()*aFixe.get(inverter).getAV()< aInfo.getAI()* aInfo.getAV()){
+            aFixe.put(inverter, aInfo);
+        }
+        if(!bFixe.containsKey(inverter)){
+            bFixe.put(inverter, bInfo);
+        }else if(bFixe.get(inverter).getBI()*bFixe.get(inverter).getBV()< bInfo.getBI()* bInfo.getBV()){
+            bFixe.put(inverter, bInfo);
+        }
+        if(!cFixe.containsKey(inverter)){
+            cFixe.put(inverter, cInfo);
+        }else if(cFixe.get(inverter).getCI()*cFixe.get(inverter).getCV()< cInfo.getCI()* cInfo.getCV()){
+            cFixe.put(inverter, cInfo);
+        }*/
+        //计算理论功率
+        for (PhotovoltaicInfo info : infos) {
+            PhotovoltaicInfo bzcld = bzcldMap.get(info.getInverter());
+            bzcld.setI(bzcld.getAI());
+            bzcld.setV(bzcld.getAV());
+            double theoryPower1 = CurrentVoltageCalc.Calculate(info, bzcld);
+            bzcld.setI(bzcld.getBI());
+            bzcld.setV(bzcld.getBV());
+            double theoryPower2 = CurrentVoltageCalc.Calculate(info, bzcld);
+            bzcld.setI(bzcld.getCI());
+            bzcld.setV(bzcld.getCV());
+            double theoryPower3 = CurrentVoltageCalc.Calculate(info, bzcld);
+            info.setIdeaP(theoryPower1 + theoryPower2 + theoryPower3);
+        }
+        return infos;
+    }
+
+    /**
+     * 计算理论功率
+     *
+     * @param info    需要计算的光照Sp、温度Tp
+     * @param infoMax 标准点
+     * @return
+     */
+    public static double Calculate(PhotovoltaicInfo info, PhotovoltaicInfo infoMax) {
+
+        double p = 0;
+        double Sp = info.getS();
+        double S = infoMax.getS();
+        double Tp = info.getT();
+        double T = infoMax.getT();
+        double Im = infoMax.getI();
+        double Vm = infoMax.getV();
+
+        if (Sp < 1 || S < 1) {
+            return 0;
+        } else {
+            double DTp = Tp - 25;
+            double DSp = Sp / 1000 - 1;
+            double DT = T - 25;
+            double DS = S / 1000 - 1;
+
+            double Imp = (Im * Sp * (1 + a * DTp)) / (S * (1 + a * DT));
+            double Vmp = (Vm * (1 - c * DTp) * Math.log(Math.E + b * DSp)) / ((1 - c * DT) * Math.log(Math.E + b * DS));
+
+            p = Imp * Vmp;
+        }
+        return p;
+    }
+
+    //计算理论功率
+    public static double[] Calculate(double s, double t, PhotovoltaicInfo infoMax) {
+
+        double p = 0;
+        double Sp = s;
+        double S = infoMax.getS();
+        double Tp = t;
+        double T = infoMax.getT();
+        double Im = infoMax.getI();
+        double Vm = infoMax.getV();
+
+        double[] db = new double[2];
+
+        if (Sp < 1 || S < 1) {
+            return db;
+        } else {
+            double DTp = Tp - 25;
+            double DSp = Sp / 1000 - 1;
+            double DT = T - 25;
+            double DS = S / 1000 - 1;
+
+            double Imp = (Im * Sp * (1 + a * DTp)) / (S * (1 + a * DT));
+            double Vmp = (Vm * (1 - c * DTp) * Math.log(Math.E + b * DSp)) / ((1 - c * DT) * Math.log(Math.E + b * DS));
+
+            db[0] = Imp;
+            db[1] = Vmp;
+        }
+        return db;
+    }
+}

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

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

+ 30 - 9
power-fitting/src/main/java/com/gyee/power/fitting/common/alg/PolynomialCurveFitting.java

@@ -7,13 +7,15 @@ 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 org.springframework.stereotype.Component;
 
 import java.util.*;
 
+@Component
 public class PolynomialCurveFitting implements CurveFitting {
 
     private WeightedObservedPoints points = null;
-    private final int degree = 1; // 阶数
+    private final int degree = 3; // 阶数
 
     private double[] inputDataX = null;
     private double[] inputDataY = null;
@@ -41,11 +43,9 @@ public class PolynomialCurveFitting implements CurveFitting {
         System.out.println("初始化完成");
     }
 
-    @Override
-    public Object run(List<Object> params) {
+    public double[] run(List<WeightedObservedPoint> params) {
         PolynomialCurveFitter fitter = PolynomialCurveFitter.create(degree);
-        WeightedObservedPoints points = (WeightedObservedPoints) params.get(0);
-        double[] result = fitter.fit(points.toList());
+        double[] result = fitter.fit(params);
         return result;
     }
 
@@ -99,11 +99,32 @@ public class PolynomialCurveFitting implements CurveFitting {
         }
         System.out.print("\n\n\nX轴数据\n\n");
         for (Double d : dataX) {
-            System.out.print(d+",");
+            System.out.print(d + ",");
+        }
+        System.out.print("\n\n\nY轴数据\n\n");
+        for (Double y : dataY) {
+            System.out.print(y + ",");
+        }
+        System.out.println();
+    }
+
+    public void printResultAll2(List<Double> points, double[] result, double accuracy) {
+        List<Double> dataX = new ArrayList<>();
+        List<Double> dataY = new ArrayList<>();
+
+        for (double index = points.get(0); index < points.get(points.size() - 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 d : dataX) {
+            System.out.print(d + ",");
         }
         System.out.print("\n\n\nY轴数据\n\n");
         for (Double y : dataY) {
-            System.out.print(y+",");
+            System.out.print(y + ",");
         }
         System.out.println();
     }
@@ -112,14 +133,14 @@ public class PolynomialCurveFitting implements CurveFitting {
         System.out.print("\n\n\nY轴数据\n\n");
         String ss = "";
         for (TsDoubleData v : x) {
-            double y = calcPoly(v.getDoubleValue(),result);
+            double y = calcPoly(v.getDoubleValue(), result);
             String s = y + ",";
             ss += s;
         }
         return ss;
     }
 
-    private double calcPoly(double x, double[] factor) {
+    public double calcPoly(double x, double[] factor) {
         double y = 0;
         for (int deg = 0; deg < factor.length; deg++) {
             y += Math.pow(x, deg) * factor[deg];

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

@@ -12,9 +12,9 @@ public class TimeCostCalculator {
         List<Object> params = testCase.getParams();
         long startTime = System.nanoTime();
         //拟合结果通过一个double数组返回,按元素顺序依次是常数项、一次项、二次项、……。
-        Object result = testCase.run(params);
+        //Object result = testCase.run(params);
         long stopTime = System.nanoTime();
-        testCase.printResult(result,0.5);
+        //testCase.printResult(result,0.5);
         //System.out.println("start: " + startTime + " / stop: " + stopTime);
         double timeCost = (stopTime - startTime) * 1.0e-9;
         return timeCost;

+ 1 - 2
power-fitting/src/main/java/com/gyee/power/fitting/common/config/GyeeConfig.java

@@ -3,7 +3,6 @@ package com.gyee.power.fitting.common.config;
 import com.gyee.power.fitting.model.anno.AnnotationTool;
 import com.gyee.power.fitting.model.anno.FixedVo;
 import com.gyee.power.fitting.model.custom.PowerPointData;
-import com.gyee.power.fitting.model.custom.TableTitle;
 import lombok.Data;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -11,7 +10,6 @@ import org.springframework.boot.system.ApplicationHome;
 import org.springframework.stereotype.Component;
 
 import java.io.File;
-import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -24,6 +22,7 @@ public class GyeeConfig {
     {
         ApplicationHome h = new ApplicationHome(getClass());
         jarF = h.getSource();
+        //jarF = new File("D:\\java\\sis-background\\power-fitting\\target\\classes");
     }
 
     /** 数据适配器网址 **/

+ 79 - 17
power-fitting/src/main/java/com/gyee/power/fitting/common/spring/InitialRunner.java

@@ -14,6 +14,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 /**
@@ -44,41 +45,83 @@ public class InitialRunner implements CommandLineRunner {
     private LineService lineService;
 
 
-    /**场站所有信息**/
+    /**
+     * 场站所有信息
+     **/
     public static List<Windpowerstation> wpList = new ArrayList<>();
-    /** <MHS_FDC, 麻黄山风电场> **/
+    /**
+     * <MHS_FDC, 麻黄山风电场>
+     **/
     public static Map<String, String> stationMap = new HashMap<>();
 
-    /**所有的风机**/
+    /**
+     * 所有的风机
+     **/
     public static List<Windturbine> wtList = new ArrayList<>();
-    /** key:wtId NG01_01 **/
+    /**
+     * key:wtId NG01_01
+     **/
     public static Map<String, Windturbine> wtMap = new HashMap<>();
-    /**场站的风机**/
+    /**
+     * 场站的风机
+     **/
     public static Map<String, List<Windturbine>> wpMap = new HashMap<>();
 
-    /**期次**/
+    /**
+     * 光伏
+     */
+    public static List<Windpowerstation> gfwpList = new ArrayList<>();
+    public static Map<String, String> gfstationMap = new HashMap<>();
+    public static List<Windturbine> gfwtList = new ArrayList<>();
+    public static Map<String, Windturbine> gfwtMap = new HashMap<>();
+    public static Map<String, List<Windturbine>> gfwpMap = new HashMap<>();
+    /**
+     * 光照强度-场站
+     */
+    public static Map<String, Windpowerstationtestingpoint2> zfsMap = new HashMap<>();
+    /**
+     * 组件温度-场站
+     */
+    public static Map<String, Windpowerstationtestingpoint2> zjwdMap = new HashMap<>();
+    /**
+     * 功率-场站
+     */
+    public static Map<String, List<Windturbinetestingpointai2>> zglMap = new HashMap<>();
+    /**
+     * 期次
+     **/
     public static List<Project> projectList = new ArrayList<>();
-    public static Map<String, Project> projectMap = new HashMap<>();
-    /**线路**/
+    /**
+     * 线路
+     **/
     public static List<Line> lineList = new ArrayList<>();
+    public static Map<String, Project> projectMap = new HashMap<>();
+    /**
+     * 所有设备型号
+     **/
+    public static List<Equipmentmodel> equipmentList = new ArrayList<>();
     public static Map<String, Line> lineMap = new HashMap<>();
 
-    /** key: NG01_01 **/
+    /**
+     * key: NG01_01
+     **/
     public static Map<String, List<Windturbinetestingpointai2>> pointMap = new HashMap<>();
-
-    /**所有设备型号**/
-    public static List<Equipmentmodel> equipmentList = new ArrayList<>();
+    @Resource
+    private IWindpowerstationtestingpoint2Service windpowerstationtestingpoint2Service;
     public static Map<String, Equipmentmodel> equipmentMap = new HashMap<>();
 
     /**功率曲线拟合的风速功率点**/
-    /** key: model  UP82 **/
+    /**
+     * key: model  UP82
+     **/
     public static Map<String, List<Modelpower>> modelPowerMap = new HashMap<>();
-    /** key: model  UP82 **/
+    /**
+     * key: model  UP82
+     **/
     public static Map<String, List<Modelpowerdetails>> modelPowerDetailMap = new HashMap<>();
 
-
     @Override
-    public void run(String... args){
+    public void run(String... args) {
         System.out.println(">>>>>>>>>>>>>>>服务启动,正在缓存数据<<<<<<<<<<<<<<");
 
         cacheStation();
@@ -87,17 +130,28 @@ public class InitialRunner implements CommandLineRunner {
         cacheModelPower();
         cacheProject();
         cacheLine();
+        cachePhotovoltaicInfo();
 
         System.out.println(">>>>>>>>>>>>>>>数据缓存完成<<<<<<<<<<<<<<");
     }
 
+    private void cachePhotovoltaicInfo() {
+        List<Windpowerstationtestingpoint2> zfsPoints = windpowerstationtestingpoint2Service.getPoints("GDC", "SSFS");
+        List<Windpowerstationtestingpoint2> zjwdPoints = windpowerstationtestingpoint2Service.getPoints("GDC", "FCCFTWD");
+        zfsMap = zfsPoints.stream().collect(Collectors.toMap(Windpowerstationtestingpoint2::getWindpowerstationid, Function.identity()));
+        zjwdMap = zjwdPoints.stream().collect(Collectors.toMap(Windpowerstationtestingpoint2::getWindpowerstationid, Function.identity()));
+        List<Windturbinetestingpointai2> zglPoints = pointService.getPoints("GDC", null, "AI130");
+        zglMap = zglPoints.stream().collect(Collectors.groupingBy(Windturbinetestingpointai2::getWindpowerstationid));
+    }
+
     /**
      * 缓存场站、风机数据
      * 数据新增或删除后需要更新,故每次清空
      */
-    public void cacheStation(){
+    public void cacheStation() {
         List<Windpowerstation> stations = windpowerstationService.selectList();
         wpList = stations.stream().filter(f -> f.getId().contains("FDC")).collect(Collectors.toList());
+        gfwpList = stations.stream().filter(f -> f.getId().contains("GDC")).collect(Collectors.toList());
         wpList.stream().forEach(obj -> {
             List<Windturbine> wts = windturbineService.selectList(obj.getId());
             stationMap.put(obj.getId(), obj.getName());
@@ -106,6 +160,14 @@ public class InitialRunner implements CommandLineRunner {
 
             wts.stream().forEach(u -> wtMap.put(u.getId(), u));
         });
+        gfwpList.stream().forEach(obj -> {
+            List<Windturbine> wts = windturbineService.selectList(obj.getId());
+            gfstationMap.put(obj.getId(), obj.getName());
+            gfwpMap.put(obj.getId(), wts);
+            gfwtList.addAll(wts);
+
+            wts.stream().forEach(u -> gfwtMap.put(u.getId(), u));
+        });
     }
 
     /**

+ 20 - 21
power-fitting/src/main/java/com/gyee/power/fitting/common/util/DateUtils.java

@@ -1,5 +1,6 @@
 package com.gyee.power.fitting.common.util;
 
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -32,11 +33,17 @@ public class DateUtils {
      * @return Date类型信息
      * @throws Exception 抛出异常
      */
-    public static Date string2DateL(String dateString) throws Exception {
+    public static Date string2DateL(String dateString) {
         if (dateString == null) {
             return null;
         }
-        return sdfl.parse(dateString);
+        Date parse = null;
+        try {
+            parse = sdfl.parse(dateString);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return parse;
     }
 
     /**
@@ -63,7 +70,7 @@ public class DateUtils {
      * @return 字符串时间
      * @throws Exception 抛出异常
      */
-    public static String date2StringS(Date date) throws Exception {
+    public static String date2StringS(Date date) {
         if (date == null) {
             return null;
         }
@@ -77,7 +84,7 @@ public class DateUtils {
      * @return 字符串时间
      * @throws Exception 抛出异常
      */
-    public static String date2StringL(Date date) throws Exception {
+    public static String date2StringL(Date date) {
         if (date == null) {
             return null;
         }
@@ -92,7 +99,7 @@ public class DateUtils {
      * @return 字符串时间
      * @throws Exception 抛出异常
      */
-    public static String date2String(Date date, String pattern) throws Exception {
+    public static String date2String(Date date, String pattern) {
         if (date == null) {
             return null;
         }
@@ -104,7 +111,7 @@ public class DateUtils {
     /**
      * 获取当前时间的0点
      */
-    public static Calendar getZero(Calendar c){
+    public static Calendar getZero(Calendar c) {
         Calendar time = (Calendar) c.clone();
         time.set(Calendar.HOUR_OF_DAY, 0);
         time.set(Calendar.MINUTE, 0);
@@ -112,27 +119,18 @@ public class DateUtils {
         time.set(Calendar.MILLISECOND, 0);
         return time;
     }
+
     /**
      * 获取当前时间的最晚点
      */
-    public static Calendar getNight(Calendar c){
+    public static Calendar getNight(Calendar c) {
         Calendar time = getZero(c);
         time.add(Calendar.DATE, 1);
-        time.add(Calendar.MILLISECOND,-1);
+        time.add(Calendar.MILLISECOND, -1);
         return time;
     }
 
 
-
-
-
-
-
-
-
-
-
-
     /**
      * 获取当前日期的本周一是几号
      *
@@ -303,6 +301,7 @@ public class DateUtils {
         c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek() + 6);
         return c.getTime();
     }
+
     //获得上周一的日期
     public static Date geLastWeekMonday(Date date) {
         Calendar cal = Calendar.getInstance();
@@ -338,14 +337,14 @@ public class DateUtils {
     }
 
     //获得今天日期
-    public static Date getToday(){
+    public static Date getToday() {
         return new Date();
     }
 
     //获得本月一日的日期
-    public static Date getFirstDay4ThisMonth(){
+    public static Date getFirstDay4ThisMonth() {
         Calendar calendar = Calendar.getInstance();
-        calendar.set(Calendar.DAY_OF_MONTH,1);
+        calendar.set(Calendar.DAY_OF_MONTH, 1);
         return calendar.getTime();
     }
 

+ 6 - 1
power-fitting/src/main/java/com/gyee/power/fitting/common/util/FileUtil.java

@@ -25,8 +25,13 @@ public class FileUtil {
 
         try {
             File file = new File(fileName);
-            if (!file.exists())
+            if (!file.exists()) {
+                fileName = fileName.substring(0, fileName.lastIndexOf("\\"));
+                File file1 = new File(fileName);
+                file1.mkdirs();
                 file.createNewFile();
+            }
+
 
             bw = new BufferedWriter(new FileWriter(file, true));
 

+ 2 - 2
power-fitting/src/main/java/com/gyee/power/fitting/common/util/PowerFittingUtil.java

@@ -17,8 +17,8 @@ public class PowerFittingUtil {
         Map<String, Map<String, Map<String, List<Powerfittinganalysis>>>> map = list.stream().
                 collect(Collectors.groupingBy(Powerfittinganalysis::getInterval, TreeMap::new,
                         Collectors.groupingBy(Powerfittinganalysis::getTime,
-                                Collectors.groupingBy(Powerfittinganalysis::getStationcn))));
-
+                                Collectors.groupingBy(Powerfittinganalysis::getStationcn, TreeMap::new, Collectors.toList()))));
+        //map.values().stream().sorted(Comparator.comparing(s -> s.get)).collect(Collectors.toList());
         List<Object> result = new ArrayList<>();
         map.forEach((k, v) -> {
             List<Object> l1 = new ArrayList<>();

+ 145 - 0
power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/PhotovoltaicController.java

@@ -0,0 +1,145 @@
+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.model.anno.AnnotationTool;
+import com.gyee.power.fitting.model.anno.FixedVo;
+import com.gyee.power.fitting.model.custom.FjjxbVo;
+import com.gyee.power.fitting.model.custom.PhotovoltaicInfo;
+import com.gyee.power.fitting.model.custom.TableTitle;
+import com.gyee.power.fitting.service.impl.IvPvCurveFittingService;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@RestController("/photovol")
+public class PhotovoltaicController {
+
+    @Resource
+    private IvPvCurveFittingService curveFittingService;
+
+    @GetMapping("/filelist")
+    private JSONObject getFileList(@RequestParam("station") String station,
+                                   @RequestParam("inverters") List<String> inverters,
+                                   @RequestParam("startdate") long startdate,
+                                   @RequestParam("enddate") long enddate) {
+        List<String> fileList = curveFittingService.getFileList(station, inverters, startdate, enddate, false);
+        if (fileList == null) {
+            try {
+                curveFittingService.getDatas2File(station, startdate, enddate);
+                curveFittingService.standardPointCalculate2();
+            } catch (Exception e) {
+                return JsonResult.error(ResultCode.ERROR_FILE_NO);
+            }
+
+            fileList = curveFittingService.getFileList(station, inverters, startdate, enddate, true);
+        }
+        //Map<String, Object> table = curveFittingService.getTable(fileList.get(0));
+        //table.put("filelist", fileList);
+
+        List<Object> fileLists = curveFittingService.str2FileList(fileList);
+        return JsonResult.successData(ResultCode.SUCCESS, fileLists);
+    }
+
+    @GetMapping("/allfilelist")
+    private JSONObject getFileList() {
+        List<String> fileList = curveFittingService.getAllFileList();
+        List<Object> objects = curveFittingService.str2FileList(fileList);
+        return JsonResult.successData(ResultCode.SUCCESS, objects);
+    }
+
+    /**
+     * 单文件表格显示
+     *
+     * @param filename
+     * @return
+     */
+    @GetMapping("/datas")
+    private JSONObject getDatas(@RequestParam("filename") String filename) {
+        Map<String, Object> table = curveFittingService.getTable(filename);
+        return JsonResult.successData(ResultCode.SUCCESS, table);
+    }
+
+    //功率-时间曲线,根据条件,暂时不用
+    @GetMapping("/analysis/powertime")
+    private JSONObject powerTimeAnalysis(@RequestParam("station") String station,
+                                         @RequestParam("inverters") List<String> inverters,
+                                         @RequestParam("startdate") long startdate,
+                                         @RequestParam("enddate") long enddate) {
+        List<String> fileList = curveFittingService.getFileList(station, inverters, startdate, enddate, true);
+        Map<String, List<PhotovoltaicInfo>> infos = curveFittingService.calculatAnalysis(fileList);
+
+        List<FixedVo> fixedVos = AnnotationTool.getFixedVoList(PhotovoltaicInfo.class);
+        String[] ss = {"station", "datetime", "T", "S", "actualP"};
+        List<String> strings = Arrays.asList(ss);
+        List<TableTitle> collect = fixedVos.stream().map(d -> new TableTitle(d.getName(), d.getDes())).collect(Collectors.toList());
+        collect = collect.stream().filter(c -> strings.contains(c.getKey())).collect(Collectors.toList());
+        TableTitle title = new TableTitle();
+        title.setKey("ideaP");
+        title.setDes("理论功率");
+        collect.add(title);
+
+        Map<String, Object> table = new HashMap<>();
+        table.put("title", collect);
+        table.put("data", infos);
+        return JsonResult.successData(ResultCode.SUCCESS, table);
+    }
+
+    //功率-时间曲线,根据文件
+    @GetMapping("/analysis/powertimefile")
+    private JSONObject powerTimeFile(@RequestParam("filelist") List<String> fileList) {
+        Map<String, List<PhotovoltaicInfo>> infos = curveFittingService.calculatAnalysis(fileList);
+
+        List<TableTitle> collect = curveFittingService.getTheoryTitel();
+
+        Map<String, Object> table = new HashMap<>();
+        table.put("title", collect);
+        table.put("data", infos);
+        return JsonResult.successData(ResultCode.SUCCESS, table);
+    }
+
+    @GetMapping("/test")
+    private void test() {
+        curveFittingService.standardPointCalculate2();
+    }
+
+    @GetMapping("/gfjxb")
+    public JSONObject gfjxb(@RequestParam("startdate") long startdate,
+                            @RequestParam("enddate") long enddate) {
+        List<FjjxbVo> voList = curveFittingService.getPhotovoltaicPerformanceList(startdate, enddate);
+        return JsonResult.successData(ResultCode.SUCCESS, voList);
+    }
+
+    //功率-光照-温度曲线
+    @PostMapping("/analysis/powerbeam")
+    private JSONObject powerBeamTemperature(@RequestBody JSONObject filename) {
+        String fn = filename.getString("filename");
+        String[] split = fn.split(",");
+        if (split.length > 450) return JsonResult.error(ResultCode.PARAM_NOT_VALID);
+        List<PhotovoltaicInfo> infos = curveFittingService.calculatFitting(Arrays.asList(split));
+        List<double[]> b = curveFittingService.oneFileFitting(infos);
+        infos = infos.stream().filter(i -> i.getS() > 1).sorted(Comparator.comparing(PhotovoltaicInfo::getS)).collect(Collectors.toList());
+
+        List<double[]> a = new ArrayList<>();
+        for (PhotovoltaicInfo pi : infos) {
+
+            double[] scatter = new double[3];
+
+            scatter[0] = pi.getS();
+            scatter[1] = pi.getActualP();
+            scatter[2] = pi.getT();
+
+            a.add(scatter);
+        }
+
+        HashMap<String, Object> map = new HashMap<>();
+        map.put("scatter", a);
+        map.put("curve", b);
+
+        return JsonResult.successData(ResultCode.SUCCESS, map);
+    }
+
+}

+ 20 - 5
power-fitting/src/main/java/com/gyee/power/fitting/controller/base/WindInfoController.java

@@ -4,7 +4,10 @@ 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.common.spring.InitialRunner;
-import com.gyee.power.fitting.model.*;
+import com.gyee.power.fitting.model.Line;
+import com.gyee.power.fitting.model.Project;
+import com.gyee.power.fitting.model.Windpowerstation;
+import com.gyee.power.fitting.model.Windturbine;
 import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -24,25 +27,37 @@ import java.util.stream.Collectors;
 public class WindInfoController {
 
     @GetMapping("station")
-    public JSONObject getStation(){
+    public JSONObject getStation() {
         List<Windpowerstation> list = InitialRunner.wpList;
         return JsonResult.successData(ResultCode.SUCCESS, list);
     }
 
     @GetMapping("windturbine")
-    public JSONObject getWindTurbine(String stationId){
+    public JSONObject getWindTurbine(String stationId) {
         List<Windturbine> list = InitialRunner.wpMap.get(stationId);
         return JsonResult.successData(ResultCode.SUCCESS, list);
     }
 
+    @GetMapping("/gfstation")
+    public JSONObject getGFStation() {
+        List<Windpowerstation> list = InitialRunner.gfwpList;
+        return JsonResult.successData(ResultCode.SUCCESS, list);
+    }
+
+    @GetMapping("/inverter")
+    public JSONObject getInverter(String stationId) {
+        List<Windturbine> list = InitialRunner.gfwpMap.get(stationId);
+        return JsonResult.successData(ResultCode.SUCCESS, list);
+    }
+
     @GetMapping("project")
-    public JSONObject getProject(String stationId){
+    public JSONObject getProject(String stationId) {
         List<Project> list = InitialRunner.projectList.stream().filter(f -> f.getWindpowerstationid().equals(stationId)).collect(Collectors.toList());
         return JsonResult.successData(ResultCode.SUCCESS, list);
     }
 
     @GetMapping("line")
-    public JSONObject getLine(String projectId){
+    public JSONObject getLine(String projectId) {
         List<Line> list = new ArrayList<>();
         String[] projects = projectId.split(",");
         Map<String, List<Line>> map = InitialRunner.lineList.stream().collect(Collectors.groupingBy(Line::getProjectid));

+ 18 - 55
power-fitting/src/main/java/com/gyee/power/fitting/model/custom/FjjxbVo.java

@@ -1,64 +1,27 @@
 package com.gyee.power.fitting.model.custom;
 
-import com.gyee.power.fitting.model.Powerlossinfo;
-import com.gyee.power.fitting.model.anno.Desc;
 import lombok.Data;
 
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.List;
+import java.io.Serializable;
 
+/**
+ * @ClassName : FjjxbVo
+ * @Author : xieshengjie
+ * @Date: 2021/6/16 10:55
+ * @Description : 风机绩效榜vo
+ */
 @Data
-public class FjjxbVo implements ToData<List<Powerlossinfo>>{
+public class FjjxbVo implements Serializable {
+    private static final long serialVersionUID = -8275715166269543409L;
 
-    private String id;
-    @Desc(des = "名称")
     private String name;
-    @Desc(des = "理论发电量(万kWh)")
-    private double llfdl;
-    @Desc(des = "实际发电量(万kWh)")
-    private double sjfdl;
-    @Desc(des = "平均风速(m/s)")
-    private double speed;
-    @Desc(des = "计划检修(万kWh)")
-    private double fjhjx;
-    @Desc(des = "非计划检修(万kWh)")
-    private double jhjx;
-    @Desc(des = "受累(万kWh)")
-    private double sl;
-    @Desc(des = "限电(万kWh)")
-    private double xd;
-    @Desc(des = "性能(万kWh)")
-    private double xn;
-    @Desc(des = "风能利用率(%)")
-    private double fnlly;
-
-
-    @Override
-    public FjjxbVo toData(List<Powerlossinfo> ls) {
-        FjjxbVo vo = new FjjxbVo();
-
-        double fdl = ls.stream().mapToDouble(Powerlossinfo::getGenecapacity).sum();
-        double llfdl = ls.stream().mapToDouble(Powerlossinfo::getTherogenecapacity).sum();
-        double speed = ls.stream().mapToDouble(Powerlossinfo::getSpeed).average().getAsDouble();
-        double fjh = ls.stream().mapToDouble(Powerlossinfo::getDayfjhjxssdl).sum();
-        double jh = ls.stream().mapToDouble(Powerlossinfo::getDayjhjxssdl).sum();
-        double sl = ls.stream().mapToDouble(Powerlossinfo::getDayslssdl).sum();
-        double xd = ls.stream().mapToDouble(Powerlossinfo::getDayxdssdl).sum();
-        double xn = ls.stream().mapToDouble(Powerlossinfo::getDayxnssdl).sum();
-        vo.setLlfdl(new BigDecimal(llfdl/10000).setScale(2, RoundingMode.CEILING).doubleValue());
-        vo.setSjfdl(new BigDecimal(fdl/10000).setScale(2, RoundingMode.CEILING).doubleValue());
-        vo.setSpeed(new BigDecimal(speed).setScale(2, RoundingMode.CEILING).doubleValue());
-        vo.setFjhjx(new BigDecimal(fjh/10000).setScale(2, RoundingMode.CEILING).doubleValue());
-        vo.setJhjx(new BigDecimal(jh/10000).setScale(2, RoundingMode.CEILING).doubleValue());
-        vo.setSl(new BigDecimal(sl/10000).setScale(2, RoundingMode.CEILING).doubleValue());
-        vo.setXd(new BigDecimal(xd/10000).setScale(2, RoundingMode.CEILING).doubleValue());
-        vo.setXn(new BigDecimal(xn/10000).setScale(2, RoundingMode.CEILING).doubleValue());
-        if (llfdl > 0)
-            vo.setFnlly(new BigDecimal((fdl / llfdl)*100).setScale(2, RoundingMode.CEILING).doubleValue());
-        else
-            vo.setFnlly(82.35);
-
-        return vo;
-    }
+    private Double llfdl;
+    private Double sjfdl;
+    private Double speed;
+    private Double fjhjx;
+    private Double jhjx;
+    private Double sl;
+    private Double xd;
+    private Double xn;
+    private Double fnlly;
 }

+ 63 - 0
power-fitting/src/main/java/com/gyee/power/fitting/model/custom/PhotovoltaicInfo.java

@@ -0,0 +1,63 @@
+package com.gyee.power.fitting.model.custom;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.gyee.power.fitting.model.anno.Desc;
+import lombok.Data;
+
+@Data
+public class PhotovoltaicInfo {
+
+    @Desc(des = "场站")
+    private String station;
+    @Desc(des = "逆变器")
+    private String inverter;
+    private String branch;//支路
+    private long time;//时间
+    @Desc(des = "时间")
+    private String datetime;
+    @Desc(des = "组件温度")
+    @JsonProperty("T")
+    private double T;
+    @Desc(des = "光照强度")
+    @JsonProperty("S")
+    private double S;
+
+    @Desc(des = "电流")
+    @JsonProperty("I")
+    private double I;
+    @Desc(des = "电压")
+    @JsonProperty("V")
+    private double V;
+    @JsonProperty("P")
+    private double P;
+    @Desc(des = "功率")
+    private double actualP;
+    private double ideaP;
+
+    @Desc(des = "A相电流")
+    @JsonProperty("aI")
+    private double aI;
+    @Desc(des = "A相电压")
+    @JsonProperty("aV")
+    private double aV;
+    @Desc(des = "B相电流")
+    @JsonProperty("bI")
+    private double bI;
+    @Desc(des = "B相电压")
+    @JsonProperty("bV")
+    private double bV;
+    @Desc(des = "C相电流")
+    @JsonProperty("cI")
+    private double cI;
+    @Desc(des = "C相电压")
+    @JsonProperty("cV")
+    private double cV;
+
+    /*public double getP() {
+        if (I != 0 && V != 0) {
+            return I * V;
+        } else {
+            return this.P;
+        }
+    }*/
+}

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

@@ -3,9 +3,11 @@ package com.gyee.power.fitting.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.gyee.power.fitting.model.Windpowerstationtestingpoint2;
 
+import java.util.List;
+
 /**
  * <p>
- *  服务类
+ * 服务类
  * </p>
  *
  * @author gfhd
@@ -14,4 +16,6 @@ import com.gyee.power.fitting.model.Windpowerstationtestingpoint2;
 public interface IWindpowerstationtestingpoint2Service extends IService<Windpowerstationtestingpoint2> {
 
     Windpowerstationtestingpoint2 getStationIllumination(String gdc);
+
+    List<Windpowerstationtestingpoint2> getPoints(String station, String uniformcode);
 }

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

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.gyee.power.fitting.model.Windturbinetestingpointai2;
 
 import java.util.List;
-import java.util.Map;
 
 /**
  * <p>
@@ -21,4 +20,6 @@ public interface Windturbinetestingpointai2Service extends IService<Windturbinet
     void getZlTag(String wtid);
 
     List<Windturbinetestingpointai2> getFaultCodes();
+
+    List<Windturbinetestingpointai2> getPoints(String station, String windturbine, String uniformcode);
 }

+ 534 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/impl/IvPvCurveFittingService.java

@@ -0,0 +1,534 @@
+package com.gyee.power.fitting.service.impl;
+
+import com.gyee.power.fitting.common.alg.CurrentVoltageCalc;
+import com.gyee.power.fitting.common.alg.PolynomialCurveFitting;
+import com.gyee.power.fitting.common.config.GyeeConfig;
+import com.gyee.power.fitting.common.constants.Constants;
+import com.gyee.power.fitting.common.feign.IAdapterService;
+import com.gyee.power.fitting.common.spring.InitialRunner;
+import com.gyee.power.fitting.common.util.DateUtils;
+import com.gyee.power.fitting.common.util.FileUtil;
+import com.gyee.power.fitting.common.util.PowerFittingUtil;
+import com.gyee.power.fitting.model.Powerfittinganalysis;
+import com.gyee.power.fitting.model.Windpowerstationtestingpoint2;
+import com.gyee.power.fitting.model.Windturbinetestingpointai2;
+import com.gyee.power.fitting.model.anno.AnnotationTool;
+import com.gyee.power.fitting.model.anno.FixedVo;
+import com.gyee.power.fitting.model.custom.FjjxbVo;
+import com.gyee.power.fitting.model.custom.PhotovoltaicInfo;
+import com.gyee.power.fitting.model.custom.TableTitle;
+import com.gyee.power.fitting.model.custom.TsDoubleData;
+import com.gyee.power.fitting.service.IWindpowerstationtestingpoint2Service;
+import com.gyee.power.fitting.service.Windturbinetestingpointai2Service;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.math3.fitting.WeightedObservedPoints;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.io.File;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+@Service
+public class IvPvCurveFittingService {
+
+    @Resource
+    private IWindpowerstationtestingpoint2Service windpowerstationtestingpoint2Service;
+    @Resource
+    private Windturbinetestingpointai2Service windturbinetestingpointai2Service;
+    @Resource
+    private IAdapterService adpClient;
+    @Resource
+    private GyeeConfig config;
+    @Resource
+    private PolynomialCurveFitting pncf;
+
+    public void getDatas2File(String stationid, long start, long end) {
+
+        int daym = 24 * 60 * 60 * 1000;
+
+        //按天
+        for (long i = start; i < end; i += daym) {
+
+            List<List<PhotovoltaicInfo>> datas = getDatas(stationid, i, i + daym);
+            infos2File(datas);
+
+        }
+
+    }
+
+    private void infos2File(List<List<PhotovoltaicInfo>> datas) {
+
+        //文件第一行
+        List<FixedVo> fixedVos = AnnotationTool.getFixedVoList(PhotovoltaicInfo.class);
+        String columnName = fixedVos.stream().map(FixedVo::getDes).collect(Collectors.joining(","));
+        //遍历逆变器
+        for (List<PhotovoltaicInfo> data : datas) {
+            PhotovoltaicInfo info = data.get(0);
+            String station = info.getStation();
+            String fileName = config.getFilePathPrepare() + "gf\\" + station + "-" + info.getInverter() + "-" + DateUtils.date2StringS(new Date(info.getTime())) + ".csv";
+            File file = new File(fileName);
+            if (file.exists()) continue;
+            StringBuilder sb = new StringBuilder();
+            sb.append(columnName).append("\n");
+            for (PhotovoltaicInfo datum : data) {
+                sb.append(datum.getStation()).append(",").append(datum.getInverter()).append(",").append(DateUtils.date2StringL(new Date(datum.getTime())))
+                        .append(",").append(datum.getT()).append(",").append(datum.getS()).append(",").append(datum.getI()).append(",").append(datum.getV())
+                        .append(",").append(datum.getActualP()).append(",").append(datum.getAI()).append(",").append(datum.getAV()).append(",")
+                        .append(datum.getBI()).append(",").append(datum.getBV()).append(",").append(datum.getCI()).append(",").append(datum.getCV())
+                        .append("\n");
+            }
+            FileUtil.writeFile(fileName, sb.toString());
+        }
+    }
+
+    public List<String> getFileList(String station, List<String> nbq, long startdate, long enddate, boolean isOffline) {
+        List<String> fileList = new ArrayList<>();
+        //获取文件位置
+        File file = new File(config.getFilePathPrepare() + "gf");
+        //获取文件列表
+        File[] files = file.listFiles();
+        //如果文件不够,返回null
+        for (long i = startdate; i < enddate; i += 24 * 60 * 60 * 1000) {
+            int size = fileList.size();
+            String s = DateUtils.date2StringS(new Date(i));
+            for (File f : files) {
+                if (f.getName().contains(station) && f.getName().contains(s) && jiancha(f.getName(), nbq))
+                    fileList.add(f.getName());
+            }
+            if (fileList.size() == size && !isOffline) return null;
+        }
+        return fileList;
+    }
+
+    private boolean jiancha(String name, List<String> nbq) {
+        for (String s : nbq) {
+            if (name.contains(s)) return true;
+        }
+        return false;
+    }
+
+    public Map<String, Object> getTable(String s) {
+        List<FixedVo> fixedVos = AnnotationTool.getFixedVoList(PhotovoltaicInfo.class);
+        List<TableTitle> collect = fixedVos.stream().map(d -> new TableTitle(d.getName(), d.getDes())).collect(Collectors.toList());
+        Map<String, Object> tableMap = new HashMap<>();
+        String fs = config.getFilePathPrepare() + "gf\\" + s;
+        List<PhotovoltaicInfo> infos = file2Info(fs, false);
+        tableMap.put("data", infos);
+        tableMap.put("title", collect);
+        return tableMap;
+    }
+
+    private List<PhotovoltaicInfo> file2Info(String path, boolean isAll) {
+        List<String> strings = FileUtil.readFile(path, isAll);
+        List<PhotovoltaicInfo> infos = new ArrayList<>();
+        for (int i = 1; i < strings.size(); i++) {
+            String[] split = strings.get(i).split(",");
+            PhotovoltaicInfo info = new PhotovoltaicInfo();
+            try {
+                info.setStation(split[0]);
+                info.setInverter(split[1]);
+                if (!"".equals(split[2])) {
+                    info.setTime(DateUtils.string2DateL(split[2]).getTime());
+                    info.setDatetime(split[2]);
+                }
+                info.setT(StringUtils.isBlank(split[3]) ? 0 : Double.parseDouble(split[3]));
+                info.setS(StringUtils.isBlank(split[4]) ? 0 : Double.parseDouble(split[4]));
+                info.setI(StringUtils.isBlank(split[5]) ? 0 : Double.parseDouble(split[5]));
+                info.setV(StringUtils.isBlank(split[6]) ? 0 : Double.parseDouble(split[6]));
+                info.setActualP(StringUtils.isBlank(split[7]) ? 0 : Double.parseDouble(split[7]));
+                info.setAI(StringUtils.isBlank(split[8]) ? 0 : Double.parseDouble(split[8]));
+                info.setAV(StringUtils.isBlank(split[9]) ? 0 : Double.parseDouble(split[9]));
+                info.setBI(StringUtils.isBlank(split[10]) ? 0 : Double.parseDouble(split[10]));
+                info.setBV(StringUtils.isBlank(split[11]) ? 0 : Double.parseDouble(split[11]));
+                info.setCI(StringUtils.isBlank(split[12]) ? 0 : Double.parseDouble(split[12]));
+                info.setCV(StringUtils.isBlank(split[13]) ? 0 : Double.parseDouble(split[13]));
+            } catch (Exception e) {
+                System.out.println();
+            }
+
+            infos.add(info);
+        }
+        return infos;
+    }
+
+    /**
+     * 计算理论功率加入原列表
+     *
+     * @return
+     */
+    public Map<String, List<PhotovoltaicInfo>> calculatAnalysis(List<String> fileList) {
+
+        String bzcldPath = config.getFilePathPrepare() + "bzd\\标准点.csv";
+        List<PhotovoltaicInfo> bzclds = file2Info(bzcldPath, true);
+        Map<String, PhotovoltaicInfo> bzcldMap = bzclds.stream().collect(Collectors.toMap(PhotovoltaicInfo::getInverter, Function.identity()));
+
+        String fs = config.getFilePathPrepare() + "gf\\";
+        Map<String, List<PhotovoltaicInfo>> stringListMap = new HashMap<>();
+        for (String s : fileList) {
+            //读取一个文件
+            List<PhotovoltaicInfo> infos = file2Info(fs + s, true);
+            List<PhotovoltaicInfo> theoryInfos;
+            if (s.contains("HZJ_GDC") || s.contains("AK_GDC")) {
+                theoryInfos = CurrentVoltageCalc.CalcTheoryPowerHZJ(infos, bzcldMap);
+            } else {
+                theoryInfos = CurrentVoltageCalc.CalcTheoryPower(infos, bzcldMap);
+            }
+            //按逆变器聚合数据
+            if (stringListMap.containsKey(theoryInfos.get(0).getInverter())) {
+                stringListMap.get(theoryInfos.get(0).getInverter()).addAll(theoryInfos);
+            } else {
+                stringListMap.put(theoryInfos.get(0).getInverter(), theoryInfos);
+            }
+        }
+        return stringListMap;
+    }
+
+    /**
+     * 合并同逆变器文件
+     *
+     * @param fileList
+     * @return
+     */
+    public Map<String, List<PhotovoltaicInfo>> mergeCalculat(List<String> fileList) {
+
+        String fs = config.getFilePathPrepare() + "gf\\";
+        Map<String, List<PhotovoltaicInfo>> stringListMap = new HashMap<>();
+        for (String s : fileList) {
+            //读取一个文件
+            List<PhotovoltaicInfo> infos = file2Info(fs + s, true);
+            //按逆变器聚合数据
+            if (stringListMap.containsKey(infos.get(0).getInverter())) {
+                stringListMap.get(infos.get(0).getInverter()).addAll(infos);
+            } else {
+                stringListMap.put(infos.get(0).getInverter(), infos);
+            }
+        }
+        return stringListMap;
+    }
+
+    public List<Object> str2FileList(List<String> fileList) {
+        List<Powerfittinganalysis> fileLists = new ArrayList<>();
+        for (String s : fileList) {
+            String[] split = s.split("-");
+            Powerfittinganalysis fl = new Powerfittinganalysis();
+            /*fl.setPath(s);
+            fl.setStation(split[0]);
+            fl.setStationcn(InitialRunner.gfstationMap.get(split[0]));
+            fl.setWindturbine(split[1]);
+            fl.setTime(split[2]+"年"+split[3]+"月");
+            fl.setInterval("五分钟");*/
+            fl.setPath(s);
+            fl.setStation(split[0]);
+            fl.setStationcn(split[1]);
+            fl.setWindturbine(split[1]);
+            fl.setTime(InitialRunner.gfstationMap.get(split[0]));
+            fl.setInterval(split[2] + "年" + split[3] + "月");
+            fileLists.add(fl);
+        }
+        List<Object> objects = PowerFittingUtil.powerDataTree(fileLists, Constants.DATA_FITTING);
+        return objects;
+    }
+
+    public List<String> getAllFileList() {
+        //获取文件位置
+        File file = new File(config.getFilePathPrepare() + "gf");
+        //获取文件列表
+        File[] files = file.listFiles();
+        List<String> fileList = Arrays.stream(files).map(f -> f.getName()).collect(Collectors.toList());
+        return fileList;
+    }
+
+    /**
+     * 标准点计算
+     */
+    public void standardPointCalculate2() {
+        List<String> allFileList = getAllFileList();
+        Map<String, List<PhotovoltaicInfo>> stringListMap = mergeCalculat(allFileList);
+
+        List<PhotovoltaicInfo> ptInfos = new ArrayList<>();
+        for (Map.Entry<String, List<PhotovoltaicInfo>> entry : stringListMap.entrySet()) {
+            List<PhotovoltaicInfo> value = entry.getValue();
+            Optional<PhotovoltaicInfo> first = value.stream().sorted(Comparator.comparing(PhotovoltaicInfo::getActualP).reversed()).findFirst();
+            ptInfos.add(first.get());
+        }
+
+        //文件第一行
+        List<FixedVo> fixedVos = AnnotationTool.getFixedVoList(PhotovoltaicInfo.class);
+        StringBuilder sb = new StringBuilder();
+        String columnName = fixedVos.stream().map(FixedVo::getDes).collect(Collectors.joining(","));
+        sb.append(columnName).append("\n");
+        for (PhotovoltaicInfo ptInfo : ptInfos) {
+            sb.append(ptInfo.getStation()).append(",").append(ptInfo.getInverter()).append(",")
+                    .append(DateUtils.date2StringL(new Date(ptInfo.getTime()))).append(",")
+                    .append(ptInfo.getT()).append(",").append(ptInfo.getS()).append(",")
+                    .append(ptInfo.getI()).append(",").append(ptInfo.getV())
+                    .append(",").append(ptInfo.getActualP()).append(",")
+                    .append(ptInfo.getAI()).append(",").append(ptInfo.getAV())
+                    .append(",").append(ptInfo.getBI()).append(",").append(ptInfo.getBV())
+                    .append(",").append(ptInfo.getCI()).append(",").append(ptInfo.getCV())
+                    .append("\n");
+        }
+        String fileName = config.getFilePathPrepare() + "bzd\\标准点.csv";
+        File file = new File(fileName);
+        file.delete();
+        FileUtil.writeFile(fileName, sb.toString());
+
+    }
+
+    public List<TableTitle> getTheoryTitel() {
+
+        List<FixedVo> fixedVos = AnnotationTool.getFixedVoList(PhotovoltaicInfo.class);
+        String[] ss = {"station", "datetime", "T", "S", "actualP"};
+        List<String> strings = Arrays.asList(ss);
+        List<TableTitle> collect = fixedVos.stream().map(d -> new TableTitle(d.getName(), d.getDes())).collect(Collectors.toList());
+        collect = collect.stream().filter(c -> strings.contains(c.getKey())).collect(Collectors.toList());
+        TableTitle title = new TableTitle();
+        title.setKey("ideaP");
+        title.setDes("理论功率");
+        collect.add(title);
+
+        return collect;
+    }
+
+    /**
+     * 获得所有文件的值
+     *
+     * @param fileList
+     * @return
+     */
+    public List<PhotovoltaicInfo> calculatFitting(List<String> fileList) {
+
+        String fs = config.getFilePathPrepare() + "gf\\";
+        List<PhotovoltaicInfo> infoList = new ArrayList<>();
+        for (String s : fileList) {
+            List<PhotovoltaicInfo> infos = file2Info(fs + s, true);
+            if (infoList.size() == 0 || Objects.equals(infos.get(0).getStation(), infoList.get(0).getStation())) {
+                infoList.addAll(infos);
+            }
+        }
+
+        return infoList;
+    }
+
+    public List<double[]> oneFileFitting(List<PhotovoltaicInfo> infos) {
+
+        WeightedObservedPoints points = new WeightedObservedPoints();
+        double max = 0;
+        for (PhotovoltaicInfo info : infos) {
+            if (info.getS() < 1) {
+                points.add(0, 0);
+            }
+            points.add(info.getS(), info.getActualP());
+            if (info.getS() > max) {
+                max = info.getS();
+            }
+        }
+        double[] result = pncf.run(points);
+
+        List<double[]> b = new ArrayList<>();
+        for (int i = 0; i < max; i += 5) {
+            double[] curve = new double[2];
+            curve[0] = i;
+            curve[1] = pncf.calcPoly(i, result);
+            b.add(curve);
+        }
+        return b;
+    }
+
+    /**
+     * 光伏绩效榜
+     *
+     * @param startdate
+     * @param enddate
+     */
+    public List<FjjxbVo> getPhotovoltaicPerformanceList(long startdate, long enddate) {
+        int oneday = 24 * 60 * 60;
+
+        String bzcldPath = config.getFilePathPrepare() + "bzd\\标准点.csv";
+        List<PhotovoltaicInfo> bzclds = file2Info(bzcldPath, true);
+        Map<String, PhotovoltaicInfo> bzcldMap = bzclds.stream().collect(Collectors.toMap(PhotovoltaicInfo::getInverter, Function.identity()));
+
+        //获取实际发电量
+        List<Windpowerstationtestingpoint2> rfdl = windpowerstationtestingpoint2Service.getPoints(null, "RFDL");
+        List<FjjxbVo> infos = new ArrayList<>();
+        //遍历逆变器
+        for (Windpowerstationtestingpoint2 wstp : rfdl) {
+            //场站
+            String stationid = wstp.getWindpowerstationid();
+
+            List<TsDoubleData> history = adpClient.getHistorySnap(wstp.getCode(), startdate + oneday * 1000, enddate, oneday);
+            double d = 0;
+            for (TsDoubleData data : history) {
+                d += data.getDoubleValue();
+            }
+            FjjxbVo vo = new FjjxbVo();
+            vo.setName(InitialRunner.gfstationMap.get(stationid));
+            vo.setSjfdl(d);
+
+            //理论发电量
+            double llfdl = 0;
+            //光照平均值
+            double gz = 0;
+            int i = 0;
+            double t = 5 / 60;
+
+            List<List<PhotovoltaicInfo>> datas = getDatas(stationid, startdate, enddate);
+            //遍历逆变器
+            for (List<PhotovoltaicInfo> data : datas) {
+
+                if ("HZJ_GDC".equals(stationid) || "AK_GDC".equals(stationid)) {
+                    CurrentVoltageCalc.CalcTheoryPowerHZJ(data, bzcldMap);
+                } else {
+                    CurrentVoltageCalc.CalcTheoryPower(data, bzcldMap);
+                }
+
+                for (PhotovoltaicInfo datum : data) {
+                    llfdl += datum.getIdeaP() * t;
+                    gz += datum.getS();
+                    i++;
+                }
+            }
+            vo.setLlfdl(llfdl);
+            vo.setSpeed(gz / i);
+            vo.setFnlly(vo.getSjfdl() / vo.getLlfdl() * 100);
+            infos.add(vo);
+        }
+        return infos;
+    }
+
+    /**
+     * 获取数据
+     *
+     * @return 逆变器,列表
+     */
+    public List<List<PhotovoltaicInfo>> getDatas(String stationid, long start, long end) {
+
+        //间隔
+        int interval = 5 * 60;
+        //获得测点
+        Map<String, String> zglpoints = getPoints(stationid, "zgl");
+        Map<String, String> adypoints = getPoints(stationid, "ady");
+        Map<String, String> bdypoints = getPoints(stationid, "bdy");
+        Map<String, String> cdypoints = getPoints(stationid, "cdy");
+        Map<String, String> adlpoints = getPoints(stationid, "adl");
+        Map<String, String> bdlpoints = getPoints(stationid, "bdl");
+        Map<String, String> cdlpoints = getPoints(stationid, "cdl");
+        Windpowerstationtestingpoint2 zfsPoint = InitialRunner.zfsMap.get(stationid);
+        Windpowerstationtestingpoint2 zjwdPoint = InitialRunner.zjwdMap.get(stationid);
+
+        //总辐射
+        List<TsDoubleData> zfsDatas = adpClient.getHistorySnap(zfsPoint.getCode(), start, end, interval);
+        //组件温度
+        List<TsDoubleData> zjwdDatas = adpClient.getHistorySnap(zjwdPoint.getCode(), start, end, interval);
+
+        List<List<PhotovoltaicInfo>> infosLit = new ArrayList<>();
+        //按逆变器
+        for (String wtid : zglpoints.keySet()) {
+
+            //总功率
+            List<TsDoubleData> zglDatas = adpClient.getHistorySnap(zglpoints.get(wtid), start, end, interval);
+
+            //电网A相电压
+            List<TsDoubleData> adyDatas = adpClient.getHistorySnap(adypoints.get(wtid), start, end, interval);
+            //电网A相电流
+            List<TsDoubleData> adlDatas = adpClient.getHistorySnap(adlpoints.get(wtid), start, end, interval);
+
+            List<PhotovoltaicInfo> infos = new ArrayList<>();
+
+            List<TsDoubleData> bdyDatas = null, cdyDatas = null, bdlDatas = null, cdlDatas = null;
+            if ("HZJ_GDC".equals(stationid) || "AK_GDC".equals(stationid)) {
+                //电网B相电压
+                bdyDatas = adpClient.getHistorySnap(bdypoints.get(wtid), start, end, interval);
+                //电网C相电压
+                cdyDatas = adpClient.getHistorySnap(cdypoints.get(wtid), start, end, interval);
+                //电网B相电流
+                bdlDatas = adpClient.getHistorySnap(bdlpoints.get(wtid), start, end, interval);
+                //电网C相电流
+                cdlDatas = adpClient.getHistorySnap(cdlpoints.get(wtid), start, end, interval);
+            }
+
+            for (int j = 0; j < zfsDatas.size(); j++) {
+                PhotovoltaicInfo info = new PhotovoltaicInfo();
+                info.setStation(stationid);
+                info.setInverter(wtid);
+                long ts = zfsDatas.get(j).getTs();
+                info.setTime(ts);
+                info.setDatetime(DateUtils.date2StringL(new Date(ts)));
+
+                info.setT(double3Decimal(zjwdDatas.get(j).getDoubleValue()));
+                info.setS(double3Decimal(zfsDatas.get(j).getDoubleValue(), false));
+                if ("HZJ_GDC".equals(stationid) || "AK_GDC".equals(stationid)) {
+                    info.setAI(double3Decimal(adlDatas.get(j).getDoubleValue(), false));
+                    info.setBI(double3Decimal(bdlDatas.get(j).getDoubleValue(), false));
+                    info.setCI(double3Decimal(cdlDatas.get(j).getDoubleValue(), false));
+                    info.setAV(double3Decimal(adyDatas.get(j).getDoubleValue(), true));
+                    info.setBV(double3Decimal(bdyDatas.get(j).getDoubleValue(), true));
+                    info.setCV(double3Decimal(cdyDatas.get(j).getDoubleValue(), true));
+                } else {
+                    info.setI(double3Decimal(adlDatas.get(j).getDoubleValue(), false));
+                    info.setV(double3Decimal(adyDatas.get(j).getDoubleValue(), true));
+                }
+                info.setActualP(double3Decimal(zglDatas.get(j).getDoubleValue(), false));
+                infos.add(info);
+            }
+            infosLit.add(infos);
+        }
+
+        return infosLit;
+    }
+
+    private double double3Decimal(double d) {
+        BigDecimal bd = new BigDecimal(d);
+        return bd.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
+    }
+
+    private double double3Decimal(double d, boolean isMultFactor) {
+        d = d < 1 ? 0 : d;
+        if (isMultFactor) {
+            d = d * 0.001;
+        }
+        return double3Decimal(d);
+    }
+
+    /**
+     * 获得测点
+     * 逆变器,测点
+     */
+    private Map<String, String> getPoints(String stationid, String key) {
+
+        switch (key) {
+            case "zgl":
+                //总功率
+                return InitialRunner.zglMap.get(stationid).stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
+            case "ady":
+                List<Windturbinetestingpointai2> adyPoints = null;
+                if ("HZJ_GDC".equals(stationid)) {
+                    //电网A相电压
+                    adyPoints = windturbinetestingpointai2Service.getPoints(stationid, null, "AIG063");
+                } else {
+                    //电网A相电压
+                    adyPoints = windturbinetestingpointai2Service.getPoints(stationid, null, "AIG061");
+                }
+                return adyPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
+            case "bdy":
+                List<Windturbinetestingpointai2> bdyPoints = windturbinetestingpointai2Service.getPoints(stationid, null, "AIG061A");
+                return bdyPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
+            case "cdy":
+                List<Windturbinetestingpointai2> cdyPoints = windturbinetestingpointai2Service.getPoints(stationid, null, "AIG065");
+                return cdyPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
+            case "adl":
+                List<Windturbinetestingpointai2> adlPoints = windturbinetestingpointai2Service.getPoints(stationid, null, "AIG060");
+                return adlPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
+            case "bdl":
+                List<Windturbinetestingpointai2> bdlPoints = windturbinetestingpointai2Service.getPoints(stationid, null, "AIG062");
+                return bdlPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
+            case "cdl":
+                List<Windturbinetestingpointai2> cdlPoints = windturbinetestingpointai2Service.getPoints(stationid, null, "AIG064");
+                return cdlPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
+        }
+        return new HashMap<>();
+    }
+}

+ 19 - 1
power-fitting/src/main/java/com/gyee/power/fitting/service/impl/Windpowerstationtestingpoint2ServiceImpl.java

@@ -5,11 +5,14 @@ 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.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author gfhd
@@ -24,4 +27,19 @@ public class Windpowerstationtestingpoint2ServiceImpl extends ServiceImpl<Windpo
         wrapper.eq("UNIFORMCODE", "SSFS").eq("WINDPOWERSTATIONID", gdc);
         return baseMapper.selectList(wrapper).get(0);
     }
+
+    @Override
+    public List<Windpowerstationtestingpoint2> getPoints(String station, String uniformcode) {
+        QueryWrapper<Windpowerstationtestingpoint2> wrapper = new QueryWrapper<>();
+        if ("GDC".equals(station)) {
+            wrapper.like("WINDPOWERSTATIONID", "_GDC");
+        } else if ("FDC".equals(station)) {
+            wrapper.like("WINDPOWERSTATIONID", "_FDC");
+        } else {
+            wrapper.eq(StringUtils.isNotEmpty(station), "WINDPOWERSTATIONID", station);
+        }
+
+        wrapper.eq("UNIFORMCODE", uniformcode);
+        return baseMapper.selectList(wrapper);
+    }
 }

+ 20 - 1
power-fitting/src/main/java/com/gyee/power/fitting/service/impl/Windturbinetestingpointai2ServiceImpl.java

@@ -6,11 +6,12 @@ import com.gyee.power.fitting.common.base.ExcludeQueryWrapper;
 import com.gyee.power.fitting.mapper.Windturbinetestingpointai2Mapper;
 import com.gyee.power.fitting.model.Windturbinetestingpointai2;
 import com.gyee.power.fitting.service.Windturbinetestingpointai2Service;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 /**
  * <p>
@@ -24,7 +25,9 @@ import java.util.Map;
 public class Windturbinetestingpointai2ServiceImpl extends ServiceImpl<Windturbinetestingpointai2Mapper, Windturbinetestingpointai2> implements Windturbinetestingpointai2Service {
 
     private List<Windturbinetestingpointai2> faultCodes;
+
     @Override
+    @Cacheable
     public List<Windturbinetestingpointai2> selectList(String station, List<String> points) {
         List<Windturbinetestingpointai2> list = new ArrayList();
 
@@ -55,4 +58,20 @@ public class Windturbinetestingpointai2ServiceImpl extends ServiceImpl<Windturbi
         }
         return faultCodes;
     }
+
+    @Override
+    @Cacheable
+    public List<Windturbinetestingpointai2> getPoints(String station, String windturbine, String uniformcode) {
+        QueryWrapper<Windturbinetestingpointai2> wrapper = new QueryWrapper<>();
+        if ("GDC".equals(station)) {
+            wrapper.like("WINDPOWERSTATIONID", "_GDC");
+        } else if ("FDC".equals(station)) {
+            wrapper.like("WINDPOWERSTATIONID", "_FDC");
+        } else {
+            wrapper.eq(StringUtils.isNotEmpty(station), "WINDPOWERSTATIONID", station);
+        }
+        wrapper.eq(StringUtils.isNotEmpty(windturbine), "WINDTURBINEID", windturbine);
+        wrapper.eq("UNIFORMCODE", uniformcode).orderByAsc("WINDTURBINEID");
+        return baseMapper.selectList(wrapper);
+    }
 }