Browse Source

新增光伏曲线拟合

wangb@gyee-china.com 1 year ago
parent
commit
9185c9a726

+ 29 - 7
power-fitting-JN/src/main/java/com.gyee.power.fitting/controller/gf/NewPhotovoltaicController.java

@@ -10,6 +10,7 @@ import com.gyee.power.fitting.common.spring.InitialRunner;
 import com.gyee.power.fitting.model.ProBasicEquipment;
 import com.gyee.power.fitting.model.custom.FjjxbVo;
 import com.gyee.power.fitting.model.custom.PhotovoltaicInfo;
+import com.gyee.power.fitting.model.custom.PowerPointData;
 import com.gyee.power.fitting.model.custom.TableTitle;
 import com.gyee.power.fitting.service.ProBasicEquipmentService;
 import com.gyee.power.fitting.service.impl.NewIvPvCurveFittingService;
@@ -38,17 +39,18 @@ public class NewPhotovoltaicController {
             @RequestParam(value = "station", required = true) String station,
             @RequestParam(value = "inverters", required = true) List<String> inverters,
             @RequestParam(value = "startdate", required = true) long startdate,
+            @RequestParam("interval") int interval,
             @RequestParam(value = "enddate", required = true) long enddate) {
-        List<String> fileList = curveFittingService.getFileList(station, inverters, startdate, enddate, false);
+        List<String> fileList = curveFittingService.getFileList(station, inverters, startdate,interval, enddate, false);
         if (fileList == null) {
             try {
-                curveFittingService.getDatas2File(station, startdate, enddate);
+                curveFittingService.getDatas2File(station, startdate, enddate,interval);
                 curveFittingService.standardPointCalculate2();
             } catch (Exception e) {
                 return JsonResult.error(ResultCode.ERROR_FILE_NO);
             }
 
-            fileList = curveFittingService.getFileList(station, inverters, startdate, enddate, true);
+            fileList = curveFittingService.getFileList(station, inverters, startdate,interval, enddate, true);
         }
         //Map<String, Object> table = curveFittingService.getTable(fileList.get(0));
         //table.put("filelist", fileList);
@@ -81,8 +83,12 @@ public class NewPhotovoltaicController {
     private JSONObject powerTimeFile(@RequestParam("station") String station,
                                      @RequestParam("inverters") List<String> inverters,
                                      @RequestParam("startdate") long startdate,
+                                     @RequestParam("interval") int interval,
                                      @RequestParam("enddate") long enddate) {
-        List<String> fileList = curveFittingService.getFileList(station, inverters, startdate, enddate, false);
+        List<String> fileList = curveFittingService.getFileList(station, inverters, startdate,interval, enddate, false);
+
+//        List<List<List<PhotovoltaicInfo>>> feill =   curveFittingService.getDatas2File(station, startdate, enddate,interval);
+
         Map<String, List<PhotovoltaicInfo>> infos = curveFittingService.calculatAnalysis(fileList);
 
         List<TableTitle> collect = curveFittingService.getTheoryTitel();
@@ -106,8 +112,9 @@ public class NewPhotovoltaicController {
 
     @GetMapping("/gfjxb")
     public JSONObject gfjxb(@RequestParam("startdate") long startdate,
-                            @RequestParam("enddate") long enddate) {
-        List<FjjxbVo> voList = curveFittingService.getPhotovoltaicPerformanceList(startdate, enddate);
+                            @RequestParam("enddate") long enddate,
+                            @RequestParam("interval") int interval) {
+        List<FjjxbVo> voList = curveFittingService.getPhotovoltaicPerformanceList(startdate, enddate,interval);
         return JsonResult.successData(ResultCode.SUCCESS, voList);
     }
 
@@ -117,11 +124,12 @@ public class NewPhotovoltaicController {
     private JSONObject powerBeamTemperature(@RequestParam("station") String station,
                                             @RequestParam("inverters") List<String> inverters,
                                             @RequestParam("startdate") long startdate,
+                                            @RequestParam("interval") int interval,
                                             @RequestParam("enddate") long enddate) {
 
 //        List<String> strings = jsonObj2List(null);
 //        if (strings.size() > 450) return JsonResult.error(ResultCode.PARAM_NOT_VALID);
-        List<String> fileList = curveFittingService.getFileList(station, inverters, startdate, enddate, false);
+        List<String> fileList = curveFittingService.getFileList(station, inverters, startdate,interval, enddate, false);
         List<PhotovoltaicInfo> infos = curveFittingService.calculatFitting(fileList);
         List<double[]> b = curveFittingService.oneFileFitting(infos);
         infos = infos.stream().filter(i -> i.getS() > 1).sorted(Comparator.comparing(PhotovoltaicInfo::getS)).collect(Collectors.toList());
@@ -145,6 +153,20 @@ public class NewPhotovoltaicController {
         return JsonResult.successData(ResultCode.SUCCESS, map);
     }
 
+    /**
+     * 通过key获取原始数据
+     * 对应前端的圈选功能
+     * @param yk  有用点的key
+     * @param wk  无用点的key
+     * @return
+     */
+    @GetMapping("/filter")
+    public JSONObject dataFittingFilter(String yk, String wk){
+        List<PhotovoltaicInfo> list = curveFittingService.dataOrigin(yk, wk);
+        return JsonResult.successData(ResultCode.SUCCESS, list);
+    }
+
+
 
     //文件删除
     @DeleteMapping("/delete/files")

+ 21 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/custom/curve/DataScangfService.java

@@ -0,0 +1,21 @@
+package com.gyee.power.fitting.service.custom.curve;
+
+import com.gyee.power.fitting.model.custom.PhotovoltaicInfo;
+import com.gyee.power.fitting.model.custom.PowerPointData;
+import lombok.Data;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 散点聚合实例
+ */
+@Data
+@Component
+public class DataScangfService {
+
+    public Map<String, List<PhotovoltaicInfo>> mapYY;
+
+    public Map<String, List<PhotovoltaicInfo>> mapWY;
+}

+ 90 - 16
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/impl/NewIvPvCurveFittingService.java

@@ -14,11 +14,9 @@ import com.gyee.power.fitting.common.util.PowerFittingUtil;
 import com.gyee.power.fitting.model.*;
 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.model.custom.*;
 import com.gyee.power.fitting.service.*;
+import com.gyee.power.fitting.service.custom.curve.DataScangfService;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.math3.fitting.WeightedObservedPoints;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -62,20 +60,37 @@ public class NewIvPvCurveFittingService {
     private List<FixedVo> fixedVos;
     private Map<String, String> uniforcodes;
 
-    public void getDatas2File(String stationid, long start, long end) {
+    @Resource
+    private DataScangfService dataScangfService;
+
+    public  void getDatas2File(String stationid, long start, long end ,int interval) {
 
         int daym = 24 * 60 * 60 * 1000;
 
         //按天
         for (long i = start; i < end; i += daym) {
 
-            List<List<PhotovoltaicInfo>> datas = getDatas(stationid, i, i + daym);
+            List<List<PhotovoltaicInfo>> datas = getDatas(stationid, i, i + daym,interval);
             infos2File(datas);
 
         }
-
     }
+    public   List<List<List<PhotovoltaicInfo>>>  getDatas2File1(String stationid, long start, long end ,int interval) {
+
+        int daym = 24 * 60 * 60 * 1000;
+
+        List<List<List<PhotovoltaicInfo>>> wj = new ArrayList<>();
+        //按天
+        for (long i = start; i < end; i += daym) {
+
+            List<List<PhotovoltaicInfo>> datas = getDatas(stationid, i, i + daym,interval);
+            wj.add(datas);
+//            infos2File(datas);
 
+        }
+
+        return wj;
+    }
 
     private void infos2File(List<List<PhotovoltaicInfo>> datas) {
 
@@ -86,7 +101,7 @@ public class NewIvPvCurveFittingService {
         for (List<PhotovoltaicInfo> data : datas) {
             PhotovoltaicInfo info = data.get(0);
             String station = info.getStation();
-            String fileName = config.getFilePathPrepare() + "gf"+File.separator + station + "-" + info.getInverter() + "-" + DateUtils.date2StringS(new Date(info.getTime())) + ".csv";
+            String fileName = config.getFilePathPrepare() + "gf" +File.separator+ "一秒" +File.separator + station + "-" + info.getInverter() + "-" + DateUtils.date2StringS(new Date(info.getTime())) + ".csv";
             File file = new File(fileName);
             if (file.exists()) continue;
             StringBuilder sb = new StringBuilder();
@@ -102,10 +117,15 @@ public class NewIvPvCurveFittingService {
         }
     }
 
-    public List<String> getFileList(String station, List<String> nbq, long startdate, long enddate, boolean isOffline) {
+    public List<String> getFileList(String station, List<String> nbq, long startdate,int interval, long enddate, boolean isOffline) {
         List<String> fileList = new ArrayList<>();
-        //获取文件位置
-        File file = new File(config.getFilePathPrepare() + "gf" +File.separator);
+        File file = null;
+                //获取文件位置
+        if (interval == 1) {
+            file = new File(config.getFilePathPrepare() + "gf" + File.separator + "一秒" + File.separator);
+        }else if (interval == 1){
+            file = new File(config.getFilePathPrepare() + "gf" + File.separator + "一秒" + File.separator);
+        }
         //获取文件列表
         File[] files = file.listFiles();
         //如果文件不够,返回null
@@ -205,6 +225,34 @@ public class NewIvPvCurveFittingService {
         return stringListMap;
     }
 
+//    public Map<String, List<PhotovoltaicInfo>> calculatAnalysis1(List<List<List<PhotovoltaicInfo>>> feill) {
+//
+//        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()));
+//
+//        String fs = config.getFilePathPrepare() + "gf" +File.separator;
+//        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;
+//    }
+
     /**
      * 合并同逆变器文件
      *
@@ -253,7 +301,7 @@ public class NewIvPvCurveFittingService {
 
     public List<String> getAllFileList() {
         //获取文件位置
-        File file = new File(config.getFilePathPrepare() + "gf" );
+        File file = new File(config.getFilePathPrepare() + "gf" + "一秒"  );
         //获取文件列表
         File[] files = file.listFiles();
         List<String> fileList = Arrays.stream(files).map(f -> f.getName()).collect(Collectors.toList());
@@ -363,7 +411,7 @@ public class NewIvPvCurveFittingService {
      * @param startdate
      * @param enddate
      */
-    public List<FjjxbVo> getPhotovoltaicPerformanceList(long startdate, long enddate) {
+    public List<FjjxbVo> getPhotovoltaicPerformanceList(long startdate, long enddate,int interval) {
         int oneday = 24 * 60 * 60;
 
         String bzcldPath = config.getFilePathPrepare() + "bzd"+File.separator+"标准点.csv";
@@ -394,7 +442,7 @@ public class NewIvPvCurveFittingService {
             int i = 0;
             double t = 5 / 60;
 
-            List<List<PhotovoltaicInfo>> datas = getDatas(stationid, startdate, enddate);
+            List<List<PhotovoltaicInfo>> datas = getDatas(stationid, startdate, enddate,interval);
             //遍历逆变器
             for (List<PhotovoltaicInfo> data : datas) {
 
@@ -423,9 +471,10 @@ public class NewIvPvCurveFittingService {
      *
      * @return 逆变器,列表
      */
-    public List<List<PhotovoltaicInfo>> getDatas(String stationid, long start, long end) {
+    public List<List<PhotovoltaicInfo>> getDatas(String stationid, long start, long end ,int interval) {
         //间隔
-        int interval = 5 * 60;
+         interval = 5 * 60; //5分钟-300
+
         //获得测点
         Map<String, String> zglpoints = getPoints(stationid, "zgl");
         Map<String, String> llglpoints = getPoints(stationid, "llgl");
@@ -637,4 +686,29 @@ public class NewIvPvCurveFittingService {
 
         return equipmentList;
     }
+
+    /**
+     * 通过大点的key获取小散点
+     * @param yk
+     * @param wk
+     * @return
+     */
+    public List<PhotovoltaicInfo> dataOrigin(String yk, String wk) {
+        List<PhotovoltaicInfo> list = new ArrayList<>();
+
+        if (!StringUtils.isEmpty(yk)){
+            String[] key = yk.split(",");
+            for (String k : key){
+                list.addAll(dataScangfService.getMapYY().get(k));
+            }
+        }
+        if (!StringUtils.isEmpty(wk)){
+            String[] kew = wk.split(",");
+            for (String k : kew){
+                list.addAll(dataScangfService.getMapWY().get(k));
+            }
+        }
+
+        return list;
+    }
 }