Просмотр исходного кода

温度矩阵排序问题修复

wangb 1 месяц назад
Родитель
Сommit
f273f2dd78

+ 20 - 10
runeconomy-xk/src/main/java/com/gyee/runeconomy/init/CacheContext.java

@@ -7,6 +7,7 @@ import com.gyee.common.model.StringUtils;
 import com.gyee.runeconomy.config.GyeeConfig;
 import com.gyee.runeconomy.controller.agc.AgcDeviateConfig;
 import com.gyee.runeconomy.controller.agc.FileService;
+import com.gyee.runeconomy.model.TemperatureComponentInfo;
 import com.gyee.runeconomy.model.TemperatureInfo;
 import com.gyee.runeconomy.model.auto.*;
 import com.gyee.runeconomy.service.auto.*;
@@ -19,9 +20,6 @@ import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
 import java.io.File;
-import java.math.BigDecimal;
-import java.time.LocalDate;
-import java.time.temporal.TemporalAdjusters;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -96,7 +94,6 @@ public class CacheContext implements CommandLineRunner {
     @Resource
     GyeeConfig config;
 
-
     /**
      * 温度矩阵信息
      */
@@ -194,9 +191,11 @@ public class CacheContext implements CommandLineRunner {
     /**
      * AGC信息缓存
      */
-    public static Map<String, AgcDeviateConfig> agcDeviateConfigMap= new HashMap<>();
+    public static Map<String, AgcDeviateConfig> agcDeviateConfigMap = new HashMap<>();
     public static Map<String, List<String>> files = new HashMap<>();
 
+    private final List<String> order = Arrays.asList("风机信息", "主轴", "发电机", "齿轮箱", "变桨", "液压", "其他");
+
     @Override
     public void run(String... args) throws Exception {
         logger.info("缓存开始------------------------------------------------------------");
@@ -707,7 +706,8 @@ public class CacheContext implements CommandLineRunner {
         wpls.stream().forEach(d -> list.addAll(proBasicEquipmentPointService.selectList(d.getId(), config.getPoints())));
         pointNewMap.putAll(list.stream().collect(Collectors.groupingBy(u -> u.getWindturbineId())));
     }
-    private void cacheAGC(){
+
+    private void cacheAGC() {
 
         AgcDeviateConfig[] adcs = fileService.getFromFile(config.getFilePathPower() + "agc_info_net.json", AgcDeviateConfig[].class);
         initFiles();
@@ -718,7 +718,7 @@ public class CacheContext implements CommandLineRunner {
 
     private void initFiles() {
         files = new HashMap<>();
-        File f = new File(config.getFilePathPower() );
+        File f = new File(config.getFilePathPower());
         File[] fs = f.listFiles();
         for (File v : fs) {
             if (v.isDirectory()) {
@@ -735,12 +735,10 @@ public class CacheContext implements CommandLineRunner {
             files.get(name).add(v.getPath());
         }
     }
+
     private void initTemperatureInfo() {
         Map<String, TemperatureInfo> tis = new HashMap<>();
-//        Map<String, StationStatus> ssm = getStationStatusMap();
-
         try {
-//            List<TemperatureInfoEntity> ls = temperatureinfoRepository.findAll();
             List<Temperatureinfo> ls = iTemperatureinfoService.list();
             for (Temperatureinfo ti : ls) {
                 if (ti == null || ti.getWindturbineid() == null || "".equals(ti.getWindturbineid())) {
@@ -761,6 +759,18 @@ public class CacheContext implements CommandLineRunner {
                 }
                 tis.get(ti.getWindturbineid()).addTemperaturePoint(ti);
             }
+            for (TemperatureInfo ti : tis.values()) {
+                List<TemperatureComponentInfo> temperatureComponentInfos = ti.getTemperatureComponentInfos();
+                if (temperatureComponentInfos != null) {
+                    Comparator<TemperatureComponentInfo> comparator = (info1, info2) -> {
+                        int index1 = order.indexOf(info1.getName());
+                        int index2 = order.indexOf(info2.getName());
+                        return Integer.compare(index1, index2);
+                    };
+                   temperatureComponentInfos.sort(comparator);
+                }
+
+            }
             temperatureInfos = new ArrayList<>(tis.values());
             temperatureInfos.sort((x, y) -> {
                 if (x.getStationId().equals(y.getStationId())) {

+ 2 - 2
runeconomy-xk/src/main/java/com/gyee/runeconomy/model/TemperatureInfo.java

@@ -23,8 +23,6 @@ public class TemperatureInfo implements Serializable {
     private List<TemperatureComponentInfo> temperatureComponentInfos;
     private int windturbineIndex;
 
-    private final List<String> order = Arrays.asList("风机信息", "主轴", "发电机", "齿轮箱", "变桨", "液压", "其他");
-
     /**
      * 是否排序
      */
@@ -58,6 +56,8 @@ public class TemperatureInfo implements Serializable {
         this.code = code;
     }
 
+
+
     /**
      * 转速
      */

+ 9 - 8
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/homepage/EconomyPointHomePageService.java

@@ -1979,21 +1979,22 @@ public class EconomyPointHomePageService {
             rfdl.setBfb(new BigDecimal(rbfb * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
             ls.add(rfdl);
             generatingCapacity15min.put(rfdl.getName(), rfdl);
+
             GeneratingCapacityVo yfdl = new GeneratingCapacityVo();
             yfdl.setName("月发电量");
-
             String s = LocalDate.now().getYear() + "-" + LocalDate.now().getMonthValue();
             BigDecimal monCache = yfdlCal.get(s);
-            yfdl.setValue(monCache.add(new BigDecimal(rfdl.getValue())).setScale(2, RoundingMode.HALF_UP).doubleValue());
-            yfdl.setTotal(calDivide(yllfdlCal.get(s).add(new BigDecimal(rfdl.getTotal())).doubleValue(), 4.0));
+            yfdl.setValue(monCache.add(BigDecimal.valueOf(rfdl.getValue())).setScale(2, RoundingMode.HALF_UP).doubleValue());
+            yfdl.setTotal(calDivide(yllfdlCal.get(s).add(BigDecimal.valueOf(rfdl.getTotal())).doubleValue(), 4.0));
             Double ybfb = calDivide(yfdl.getValue(), yfdl.getTotal());
             yfdl.setBfb(new BigDecimal(ybfb).setScale(2, RoundingMode.HALF_UP).doubleValue());
             ls.add(yfdl);
             generatingCapacity15min.put(yfdl.getName(), yfdl);
+
             GeneratingCapacityVo nfdl = new GeneratingCapacityVo();
             nfdl.setName("年发电量");
-            nfdl.setValue(nfdlCal.get(LocalDate.now().getYear()).add(new BigDecimal(rfdl.getValue())).setScale(2, RoundingMode.HALF_UP).doubleValue());
-            nfdl.setTotal(calDivide(nllfdlCal.get(LocalDate.now().getYear()).add(new BigDecimal(rfdl.getTotal())).doubleValue(), 4.0));
+            nfdl.setValue(nfdlCal.get(LocalDate.now().getYear()).add(BigDecimal.valueOf(rfdl.getValue())).setScale(2, RoundingMode.HALF_UP).doubleValue());
+            nfdl.setTotal(calDivide(nllfdlCal.get(LocalDate.now().getYear()).add(BigDecimal.valueOf(rfdl.getTotal())).doubleValue(), 4.0));
             Double nbfb = calDivide(nfdl.getValue(), nfdl.getTotal());
             nfdl.setBfb(new BigDecimal(nbfb).setScale(2, RoundingMode.HALF_UP).doubleValue());
             ls.add(nfdl);
@@ -2091,7 +2092,7 @@ public class EconomyPointHomePageService {
                 .groupBy("station_id");
         List<TurbineInfoDay> yearData = iTurbineInfoDayService.list(currentqw);
         Integer intYear = LocalDate.now().getYear();
-        Double nfdlc = calDivide(yearData.get(0).getRfdl().doubleValue(), 1000.0);
+        Double nfdlc = calDivide(yearData.get(0).getRfdl(), 1000.0);
         Double nllfdlc = calDivide(yearData.get(0).getLlfdl(), 1000.0);
         nfdlCal.put(intYear, new BigDecimal(nfdlc));
         nllfdlCal.put(intYear, new BigDecimal(nllfdlc));
@@ -2103,7 +2104,7 @@ public class EconomyPointHomePageService {
                 .groupBy("station_id");
         List<TurbineInfoDay> monthData = iTurbineInfoDayService.list(currentqw);
         String yearAndMonth = LocalDate.now().getYear() + "-" + LocalDate.now().getMonthValue();
-        Double yfdlc = calDivide(monthData.get(0).getRfdl().doubleValue(), 1000.0);
+        Double yfdlc = calDivide(monthData.get(0).getRfdl(), 1000.0);
         Double yllfdlc = calDivide(monthData.get(0).getLlfdl(), 1000.0);
         yfdlCal.put(yearAndMonth, new BigDecimal(yfdlc));
         yllfdlCal.put(yearAndMonth, new BigDecimal(yllfdlc));
@@ -2127,7 +2128,7 @@ public class EconomyPointHomePageService {
         if (null == weekData || weekData.isEmpty()) {
             return 0.0;
         }
-        Double weekfdlc = calDivide(weekData.get(0).getRfdl().doubleValue(), 1000.0);
+        Double weekfdlc = calDivide(weekData.get(0).getRfdl(), 1000.0);
         return weekfdlc + generatingCapacity15min.get("日发电量").getValue();
     }