Selaa lähdekoodia

Merge branch 'master' of http://124.70.43.205:3000/xieshengjie/sis-background

# Conflicts:
#	power-fitting/src/main/java/com/gyee/power/fitting/common/config/GyeeConfig.java
chenminghua 1 vuosi sitten
vanhempi
commit
8514b03051

+ 24 - 6
power-fitting/src/main/java/com/gyee/power/fitting/common/config/GyeeConfig.java

@@ -41,16 +41,30 @@ public class GyeeConfig {
     private String filePathFitting;
     /** 配置文件路径 **/
     private String filePathPower;
-    /** 数据压缩下载 **/
+    /**
+     * 数据压缩下载
+     **/
     private String filePathDownload;
-    /** 功率曲线拟合测点 **/
+    /**
+     * 功率曲线拟合测点
+     **/
     private String points;
-    /** 适配器读取数据等间隔时间 **/
+    /**
+     * 适配器读取数据等间隔时间
+     **/
     private Integer interval;
-    /** 数据是否离线执行 **/
+    /**
+     * 数据是否离线执行
+     **/
     private boolean offLine;
-    /** 是否实时计算 **/
+    /**
+     * 是否实时计算
+     **/
     private boolean realTimeCal;
+    /**
+     * 光伏数据准备路径
+     */
+    private String gfDataPath;
 
     public List<String> getPoints() {
         return getUniformCodes();
@@ -96,11 +110,15 @@ public class GyeeConfig {
         this.filePathPower = filePathPower;
     }
 
-    private List<String> getUniformCodes(){
+    private List<String> getUniformCodes() {
         List<FixedVo> fxList = annotationTool.getFixedVoList(PowerPointData.class);
         List<String> codes = fxList.stream().filter(f -> !StringUtils.isEmpty(f.getUniformCode()))
                 .map(d -> d.getUniformCode()).collect(Collectors.toList());
 
         return codes;
     }
+
+    public String getGfDataPath() {
+        return getFilePathPrepare()+"gf"+File.separator;
+    }
 }

+ 6 - 4
power-fitting/src/main/java/com/gyee/power/fitting/common/spring/InitialRunner.java

@@ -6,11 +6,11 @@ import com.gyee.power.fitting.common.util.FileUtil;
 import com.gyee.power.fitting.model.*;
 import com.gyee.power.fitting.model.agc.AgcDeviateConfig;
 import com.gyee.power.fitting.service.*;
+import com.gyee.power.fitting.service.impl.IvPvCurveFittingService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.core.annotation.Order;
-import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
@@ -47,6 +47,8 @@ public class InitialRunner implements CommandLineRunner {
     private LineService lineService;
     @Resource
     private PowermodelService powermodelService;
+    @Resource
+    private IvPvCurveFittingService ipcfService;
 
 
     /**
@@ -142,11 +144,11 @@ public class InitialRunner implements CommandLineRunner {
     }
 
     private void cachePhotovoltaicInfo() {
-        List<Windpowerstationtestingpoint2> zfsPoints = windpowerstationtestingpoint2Service.getPoints("GDC", "SSFS");
-        List<Windpowerstationtestingpoint2> zjwdPoints = windpowerstationtestingpoint2Service.getPoints("GDC", "FCCFTWD");
+        List<Windpowerstationtestingpoint2> zfsPoints = windpowerstationtestingpoint2Service.getPoints("GDC", ipcfService.getUniforcodes().get("光照强度"));
+        List<Windpowerstationtestingpoint2> zjwdPoints = windpowerstationtestingpoint2Service.getPoints("GDC", ipcfService.getUniforcodes().get("组件温度"));
         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");
+        List<Windturbinetestingpointai2> zglPoints = pointService.getPoints("GDC", null, ipcfService.getUniforcodes().get("功率"));
         zglMap = zglPoints.stream().collect(Collectors.groupingBy(Windturbinetestingpointai2::getWindpowerstationid));
     }
 

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

@@ -1,6 +1,7 @@
 package com.gyee.power.fitting.common.util;
 
 
+import java.io.File;
 import java.math.BigDecimal;
 
 /**
@@ -65,7 +66,7 @@ public class NumberUtil {
         StringBuffer sb = new StringBuffer();
         //将小数点后面的零给去除
         String numStr = bigDecimalNum.abs().stripTrailingZeros().toPlainString();
-        String[] split = numStr.split("\\.");
+        String[] split = numStr.split(File.separator);
         String integerStr = int2chineseNum(Integer.parseInt(split[0]));
         sb.append(integerStr);
         //如果传入的数有小数,则进行切割,将整数与小数部分分离

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

@@ -15,10 +15,10 @@ public class PhotovoltaicInfo {
     private long time;//时间
     @Desc(des = "时间")
     private String datetime;
-    @Desc(des = "组件温度")
+    @Desc(des = "组件温度", uniformCode = "${uniformcode.gfzjwd:FCCFTWD}")
     @JsonProperty("T")
     private double T;
-    @Desc(des = "光照强度")
+    @Desc(des = "光照强度", uniformCode = "${uniformcode.gfgzqd:SSFS}")
     @JsonProperty("S")
     private double S;
 
@@ -30,26 +30,26 @@ public class PhotovoltaicInfo {
     private double V;
     @JsonProperty("P")
     private double P;
-    @Desc(des = "功率")
+    @Desc(des = "功率", uniformCode = "${uniformcode.power:AI130}")
     private double actualP;
     private double ideaP;
 
-    @Desc(des = "A相电流")
+    @Desc(des = "A相电流", uniformCode = "${uniformcode.gfadl:AIG060}")
     @JsonProperty("aI")
     private double aI;
-    @Desc(des = "A相电压")
+    @Desc(des = "A相电压", uniformCode = "${uniformcode.gfady:AIG061}")
     @JsonProperty("aV")
     private double aV;
-    @Desc(des = "B相电流")
+    @Desc(des = "B相电流", uniformCode = "${uniformcode.gfbdl:AIG062}")
     @JsonProperty("bI")
     private double bI;
-    @Desc(des = "B相电压")
+    @Desc(des = "B相电压", uniformCode = "${uniformcode.gfbdy:AIG061A}")
     @JsonProperty("bV")
     private double bV;
-    @Desc(des = "C相电流")
+    @Desc(des = "C相电流", uniformCode = "${uniformcode.gfcdl:AIG064}")
     @JsonProperty("cI")
     private double cI;
-    @Desc(des = "C相电压")
+    @Desc(des = "C相电压", uniformCode = "${uniformcode.gfcdy:AIG065}")
     @JsonProperty("cV")
     private double cV;
 

+ 53 - 29
power-fitting/src/main/java/com/gyee/power/fitting/service/impl/IvPvCurveFittingService.java

@@ -22,6 +22,7 @@ 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.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -48,6 +49,12 @@ public class IvPvCurveFittingService {
     @Resource
     private AnnotationTool annotationTool;
 
+    private List<FixedVo> fixedVos;
+    private Map<String, String> uniforcodes;
+
+    @Value("${gf3xjscz}")
+    private String gf3xjscz;
+
 
     public void getDatas2File(String stationid, long start, long end) {
 
@@ -66,13 +73,12 @@ public class IvPvCurveFittingService {
     private void infos2File(List<List<PhotovoltaicInfo>> datas) {
 
         //文件第一行
-        List<FixedVo> fixedVos = annotationTool.getFixedVoList(PhotovoltaicInfo.class);
-        String columnName = fixedVos.stream().map(FixedVo::getDes).collect(Collectors.joining(","));
+        String columnName = getFixedVos().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";
+            String fileName = config.getGfDataPath() + station + "-" + info.getInverter() + "-" + DateUtils.date2StringS(new Date(info.getTime())) + ".csv";
             File file = new File(fileName);
             if (file.exists()) continue;
             StringBuilder sb = new StringBuilder();
@@ -115,10 +121,9 @@ public class IvPvCurveFittingService {
     }
 
     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());
+        List<TableTitle> collect = getFixedVos().stream().map(d -> new TableTitle(d.getName(), d.getDes())).collect(Collectors.toList());
         Map<String, Object> tableMap = new HashMap<>();
-        String fs = config.getFilePathPrepare() + "gf\\" + s;
+        String fs = config.getGfDataPath() + s;
         List<PhotovoltaicInfo> infos = file2Info(fs, false);
         tableMap.put("data", infos);
         tableMap.put("title", collect);
@@ -169,17 +174,24 @@ public class IvPvCurveFittingService {
         List<PhotovoltaicInfo> bzclds = file2Info(bzcldPath, true);
         Map<String, PhotovoltaicInfo> bzcldMap = bzclds.stream().collect(Collectors.toMap(PhotovoltaicInfo::getInverter, Function.identity()));
 
-        String fs = config.getFilePathPrepare() + "gf\\";
+        String fs = config.getGfDataPath();
         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")) {
+
+            boolean b = false;
+            String[] split = gf3xjscz.split(",");
+            for (String s1 : split) {
+                if (s.contains(s1)) b = true;
+            }
+            if (b) {
                 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);
@@ -198,7 +210,7 @@ public class IvPvCurveFittingService {
      */
     public Map<String, List<PhotovoltaicInfo>> mergeCalculat(List<String> fileList) {
 
-        String fs = config.getFilePathPrepare() + "gf\\";
+        String fs = config.getGfDataPath();
         Map<String, List<PhotovoltaicInfo>> stringListMap = new HashMap<>();
         for (String s : fileList) {
             //读取一个文件
@@ -260,9 +272,8 @@ public class IvPvCurveFittingService {
         }
 
         //文件第一行
-        List<FixedVo> fixedVos = annotationTool.getFixedVoList(PhotovoltaicInfo.class);
         StringBuilder sb = new StringBuilder();
-        String columnName = fixedVos.stream().map(FixedVo::getDes).collect(Collectors.joining(","));
+        String columnName = getFixedVos().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(",")
@@ -275,7 +286,7 @@ public class IvPvCurveFittingService {
                     .append(",").append(ptInfo.getCI()).append(",").append(ptInfo.getCV())
                     .append("\n");
         }
-        String fileName = config.getFilePathPrepare() + "bzd\\标准点.csv";
+        String fileName = config.getFilePathPrepare() + "bzd" + File.separator + "标准点.csv";
         File file = new File(fileName);
         file.delete();
         FileUtil.writeFile(fileName, sb.toString());
@@ -284,10 +295,9 @@ public class IvPvCurveFittingService {
 
     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());
+        List<TableTitle> collect = getFixedVos().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");
@@ -305,7 +315,7 @@ public class IvPvCurveFittingService {
      */
     public List<PhotovoltaicInfo> calculatFitting(List<String> fileList) {
 
-        String fs = config.getFilePathPrepare() + "gf\\";
+        String fs = config.getGfDataPath();
         List<PhotovoltaicInfo> infoList = new ArrayList<>();
         for (String s : fileList) {
             List<PhotovoltaicInfo> infos = file2Info(fs + s, true);
@@ -351,7 +361,7 @@ public class IvPvCurveFittingService {
     public List<FjjxbVo> getPhotovoltaicPerformanceList(long startdate, long enddate) {
         int oneday = 24 * 60 * 60;
 
-        String bzcldPath = config.getFilePathPrepare() + "bzd\\标准点.csv";
+        String bzcldPath = config.getFilePathPrepare() + "bzd" + File.separator + "标准点.csv";
         List<PhotovoltaicInfo> bzclds = file2Info(bzcldPath, true);
         Map<String, PhotovoltaicInfo> bzcldMap = bzclds.stream().collect(Collectors.toMap(PhotovoltaicInfo::getInverter, Function.identity()));
 
@@ -383,7 +393,7 @@ public class IvPvCurveFittingService {
             //遍历逆变器
             for (List<PhotovoltaicInfo> data : datas) {
 
-                if ("HZJ_GDC".equals(stationid) || "AK_GDC".equals(stationid)) {
+                if (gf3xjscz.contains(stationid)) {
                     CurrentVoltageCalc.CalcTheoryPowerHZJ(data, bzcldMap);
                 } else {
                     CurrentVoltageCalc.CalcTheoryPower(data, bzcldMap);
@@ -443,7 +453,7 @@ public class IvPvCurveFittingService {
             List<PhotovoltaicInfo> infos = new ArrayList<>();
 
             List<TsDoubleData> bdyDatas = null, cdyDatas = null, bdlDatas = null, cdlDatas = null;
-            if ("HZJ_GDC".equals(stationid) || "AK_GDC".equals(stationid)) {
+            if (gf3xjscz.contains(stationid)) {
                 //电网B相电压
                 bdyDatas = adpClient.getHistorySnap(bdypoints.get(wtid), start, end, interval);
                 //电网C相电压
@@ -464,7 +474,7 @@ public class IvPvCurveFittingService {
 
                 info.setT(double3Decimal(zjwdDatas.get(j).getDoubleValue()));
                 info.setS(double3Decimal(zfsDatas.get(j).getDoubleValue(), false));
-                if ("HZJ_GDC".equals(stationid) || "AK_GDC".equals(stationid)) {
+                if (gf3xjscz.contains(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));
@@ -502,7 +512,8 @@ public class IvPvCurveFittingService {
      * 逆变器,测点
      */
     private Map<String, String> getPoints(String stationid, String key) {
-
+        //获取unifromcode
+        getFixedVos();
         switch (key) {
             case "zgl":
                 //总功率
@@ -514,30 +525,30 @@ public class IvPvCurveFittingService {
                     adyPoints = windPointService.getPoints(stationid, null, "AIG063");
                 } else {
                     //电网A相电压
-                    adyPoints = windPointService.getPoints(stationid, null, "AIG061");
+                    adyPoints = windPointService.getPoints(stationid, null, uniforcodes.get("A相电压"));
                 }
                 return adyPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
             case "bdy":
-                List<Windturbinetestingpointai2> bdyPoints = windPointService.getPoints(stationid, null, "AIG061A");
+                List<Windturbinetestingpointai2> bdyPoints = windPointService.getPoints(stationid, null, uniforcodes.get("B相电压"));
                 return bdyPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
             case "cdy":
-                List<Windturbinetestingpointai2> cdyPoints = windPointService.getPoints(stationid, null, "AIG065");
+                List<Windturbinetestingpointai2> cdyPoints = windPointService.getPoints(stationid, null, uniforcodes.get("C相电压"));
                 return cdyPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
             case "adl":
-                List<Windturbinetestingpointai2> adlPoints = windPointService.getPoints(stationid, null, "AIG060");
+                List<Windturbinetestingpointai2> adlPoints = windPointService.getPoints(stationid, null, uniforcodes.get("A相电流"));
                 return adlPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
             case "bdl":
-                List<Windturbinetestingpointai2> bdlPoints = windPointService.getPoints(stationid, null, "AIG062");
+                List<Windturbinetestingpointai2> bdlPoints = windPointService.getPoints(stationid, null, uniforcodes.get("B相电流"));
                 return bdlPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
             case "cdl":
-                List<Windturbinetestingpointai2> cdlPoints = windPointService.getPoints(stationid, null, "AIG064");
+                List<Windturbinetestingpointai2> cdlPoints = windPointService.getPoints(stationid, null, uniforcodes.get("C相电流"));
                 return cdlPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
         }
         return new HashMap<>();
     }
 
     public int deleteFiles(List<String> fileList) {
-        String fs = config.getFilePathPrepare() + "gf\\";
+        String fs = config.getGfDataPath();
         List<PhotovoltaicInfo> infoList = new ArrayList<>();
         int count = 0;
         for (String s : fileList) {
@@ -549,7 +560,7 @@ public class IvPvCurveFittingService {
 
     public void downFiles(List<String> strings, HttpServletResponse response) {
         List<File> files = path2File(strings);
-        String path = config.getFilePathPrepare() + "zip\\" + System.currentTimeMillis() + ".zip";
+        String path = config.getFilePathPrepare() + "zip" + File.separator + System.currentTimeMillis() + ".zip";
         String s = FileUtil.zipFiles(files, new File(path));
         FileUtil.download(s, response);
     }
@@ -557,8 +568,21 @@ public class IvPvCurveFittingService {
     private List<File> path2File(List<String> strings) {
         List<File> files = new ArrayList<>();
         for (String string : strings) {
-            files.add(new File(config.getFilePathPrepare() + "gf\\" + string));
+            files.add(new File(config.getGfDataPath() + string));
         }
         return files;
     }
+
+    public List<FixedVo> getFixedVos() {
+        if (fixedVos == null) {
+            fixedVos = annotationTool.getFixedVoList(PhotovoltaicInfo.class);
+            uniforcodes = fixedVos.stream().filter(fv -> fv.getUniformCode() != null).collect(Collectors.toMap(FixedVo::getDes, FixedVo::getUniformCode));
+        }
+        return fixedVos;
+    }
+
+    public Map<String, String> getUniforcodes() {
+        getFixedVos();
+        return uniforcodes;
+    }
 }

+ 11 - 0
power-fitting/src/main/resources/application.yaml

@@ -95,5 +95,16 @@ uniformcode:
   yp1: AI085  #叶片1
   yp2: AI086  #叶片2
   yp3: AI087  #叶片3
+  gfgzqd: SSFS #光伏光照强度
+  gfzjwd: FCCFTWD #光伏组件温度
+  gfady: AIG061 #光伏A相电压
+  gfbdy: AIG061A #光伏B相电压
+  gfcdy: AIG065 #光伏C相电压
+  gfadl: AIG060 #光伏A相电流
+  gfbdl: AIG062 #光伏B相电流
+  gfcdl: AIG064 #光伏C相电流
+
+#光伏三相电流电压计算功率的场站
+gf3xjscz: HZJ_GDC,AK_GDC