Browse Source

代码优化

Koishi 1 year ago
parent
commit
3a30270f15

+ 19 - 9
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/impl/IvPvCurveFittingService.java

@@ -59,6 +59,9 @@ public class IvPvCurveFittingService {
     @Resource
     private ProBasicEquipmentPointService proBasicEquipmentPointService;
 
+    @Resource
+    private ProBasicWeatherStationServiceImpl weatherStationService;
+
     public void getDatas2File(String stationid, long start, long end) {
 
         int daym = 24 * 60 * 60 * 1000;
@@ -99,7 +102,7 @@ public class IvPvCurveFittingService {
         String columnName = getFixedVos().stream().map(FixedVo::getDes).collect(Collectors.joining(","));
         //遍历逆变器
         for (List<PhotovoltaicInfo> data : datas) {
-            PhotovoltaicInfo info = data.get(0);
+            PhotovoltaicInfo info = data.get(data.size()-1);
             String station = info.getStation();
             String fileName = config.getGfDataPath() + station + "-" + info.getInverter() + "-" + DateUtils.date2StringS(new Date(info.getTime())) + ".csv";
             File file = new File(fileName);
@@ -264,8 +267,8 @@ public class IvPvCurveFittingService {
             fl.setPath(s);
             fl.setStation(split[0]);
             fl.setStationcn(split[1]);
-            //fl.setWindturbine(split[1]);
-            fl.setTime(InitialRunner.gfstationMap.get(split[0]));
+            fl.setWindturbineId(split[1]);
+            fl.setTime(InitialRunner.newgfstationMap.get(split[0]));
             fl.setInterval(split[2] + "年" + split[3] + "月");
             fileLists.add(fl);
         }
@@ -312,9 +315,7 @@ public class IvPvCurveFittingService {
                     .append("\n");
         }
         String fileName = config.getFilePathPrepare() + "bzd" + File.separator + "标准点.csv";
-        File file = new File(fileName);
-        file.delete();
-        FileUtil.writeFile(fileName, sb.toString());
+        boolean flag =FileUtil.writeFile(fileName, sb.toString());
 
     }
 
@@ -489,7 +490,7 @@ public class IvPvCurveFittingService {
 
         //间隔
         if (interval == null)
-            interval = 5 * 60; //5分钟-300
+            interval = 15 * 60; //5分钟-300
 
         //获得测点
         Map<String, String> zglpoints = getPoints(stationid, "zgl");
@@ -499,13 +500,20 @@ public class IvPvCurveFittingService {
         Map<String, String> adlpoints = getPoints(stationid, "adl");
         Map<String, String> bdlpoints = getPoints(stationid, "bdl");
         Map<String, String> cdlpoints = getPoints(stationid, "cdl");
+
+        List<ProBasicWeatherStation> weatherStations = weatherStationService.getBaseMapper().selectList(null);
+        List<ProBasicWeatherStation> collect = weatherStations.stream().filter(c -> stationid.equals(c.getWindpowerstationId())).collect(Collectors.toList());
+
+        String station = collect.get(0).getId();
+
+
         ProBasicPowerstationPoint zfsPoint = InitialRunner.newzfsMap.get(stationid);
-        ProBasicPowerstationPoint zjwdPoint = InitialRunner.newzjwdMap.get(stationid);
+        ProBasicPowerstationPoint zjwdPoint = InitialRunner.newzjwdMap.get(station);
 
         //总辐射
         List<TsDoubleData> zfsDatas = remoteService.adapterfd().getHistorySnap(zfsPoint.getNemCode(), start, end, interval);
         //组件温度
-        List<TsDoubleData> zjwdDatas = remoteService.adaptergf().getHistorySnap(zjwdPoint.getNemCode(), start, end, interval);
+        List<TsDoubleData> zjwdDatas = remoteService.adapterfd().getHistorySnap(zjwdPoint.getNemCode(), start, end, interval);
         List<List<PhotovoltaicInfo>> infosLit = new ArrayList<>();
         //按逆变器
         for (String wtid : zglpoints.keySet()) {
@@ -567,6 +575,8 @@ public class IvPvCurveFittingService {
                 }
                 infos.add(info);
             }
+
+            String s = DateUtils.date2StringS(new Date(start));
             infosLit.add(infos);
         }