Browse Source

性能等级评估,等级重新计算

wangb 2 months ago
parent
commit
544fff5b99

+ 2 - 0
runeconomy-xk/src/main/java/com/gyee/runeconomy/model/auto/TurbineInfoDay.java

@@ -64,4 +64,6 @@ public class TurbineInfoDay implements Serializable {
     private Double klyl;
     private Double fnlyl;
     private Double bll;
+    private Double score;
+    private String level;
 }

+ 2 - 1
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/ITurbineInfoDayService.java

@@ -4,6 +4,7 @@ import com.gyee.runeconomy.model.auto.TurbineInfoDay;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.text.ParseException;
+import java.time.LocalDate;
 import java.util.Date;
 import java.util.List;
 
@@ -23,7 +24,7 @@ public interface ITurbineInfoDayService extends IService<TurbineInfoDay> {
     /**
      * 获取所有风机一段时间电量的和
      */
-    List<TurbineInfoDay> getTurbineMonthList(String windpowerstationId, Date startDate, Date endDate);
+    List<TurbineInfoDay> getTurbineMonthList(String windpowerstationId, LocalDate startDate, LocalDate endDate);
 
     /**
      * 获取单台风机一段时间电量的和

+ 38 - 7
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/ProEconEquipmentInfoDayTopServiceImpl.java

@@ -63,6 +63,8 @@ public class ProEconEquipmentInfoDayTopServiceImpl extends ServiceImpl<ProEconEq
         Map<String, TurbineInfoDay> dayMap = tidRecords.stream().collect(Collectors.toMap(TurbineInfoDay::getTurbineId, Function.identity()));
         peeidtRecords.forEach(peeidt -> {
             TurbineInfoDay day = dayMap.get(peeidt.getWindturbineId());
+            Date recordDate = day.getRecordDate();
+            int i = DateUtil.dayOfMonth(recordDate);
             peeidt.setDayfdl(NumberUtil.round(day.getRfdl() / 1000, 2).doubleValue());
             peeidt.setDayllfdl(NumberUtil.round(day.getLlfdl() / 1000, 2).doubleValue());
             peeidt.setDayfs(NumberUtil.round(day.getPjfs(), 2).doubleValue());
@@ -74,18 +76,47 @@ public class ProEconEquipmentInfoDayTopServiceImpl extends ServiceImpl<ProEconEq
             peeidt.setDaysbklyl(NumberUtil.round(day.getKlyl(), 2).doubleValue());
             peeidt.setDayyxfss(NumberUtil.round(day.getYxfss(), 2).doubleValue());
             peeidt.setDayjfpl(NumberUtil.round(day.getJfpl(), 2).doubleValue());
+            peeidt.setDayRank(Integer.valueOf(day.getLevel()));
+            peeidt.setDayLevel(level(day.getScore(), i-1));
         });
         return peeidtRecords;
     }
 
-    public List<TurbineInfoDay> getTopAndList(String windpowerstationId, String date, Integer pageNum, Integer pageSize) {
-        LocalDate d = LocalDate.parse(date, DateTimeFormatter.ISO_LOCAL_DATE);
-        LocalDate firstDayOfMonth = d.withDayOfMonth(1);
-        Date startDate = Date.from(firstDayOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant());
-        Date endDate = DateUtil.parse(date);
 
-        List<TurbineInfoDay> turbineMonthList = turbineInfoDayService.getTurbineMonthList(windpowerstationId, startDate, endDate);
 
+
+    private String level(Double score, int i) {
+        score = 0 != i ? score / i : 0.0;
+        String top;
+        if (score >= 67) {
+            top = "AAA";
+        } else if (score >= 60) {
+            top = "AA";
+        } else if (score >= 56) {
+            top = "A";
+        } else if (score >= 53) {
+            top = "BBB";
+        } else if (score >= 46) {
+            top = "BB";
+        } else if (score >= 42) {
+            top = "B";
+        } else if (score >= 28) {
+            top = "C";
+        } else {
+            top = "C-";
+        }
+        return top;
+    }
+
+    public List<TurbineInfoDay> getTopAndList(String windpowerstationId, String date, Integer pageNum, Integer pageSize) {
+        LocalDate endDate = LocalDate.parse(date, DateTimeFormatter.ISO_LOCAL_DATE);
+        endDate = endDate.minusDays(1);
+        LocalDate startDate = endDate.withDayOfMonth(1);
+        List<TurbineInfoDay> turbineMonthList = turbineInfoDayService.getTurbineMonthList(windpowerstationId, startDate, endDate);
+        List<TurbineInfoDay> collect = turbineMonthList.stream().sorted((t1, t2) -> t2.getScore().compareTo(t1.getScore())).collect(Collectors.toList());
+        for (int i = 1; i <= collect.size(); i++) {
+            collect.get(i-1).setLevel(String.valueOf(i));
+        }
         if (pageNum == null || pageSize == null || pageNum < 1 || pageSize < 1) {
             return turbineMonthList;
         }
@@ -238,7 +269,7 @@ public class ProEconEquipmentInfoDayTopServiceImpl extends ServiceImpl<ProEconEq
 
         if (StringUtils.isNotEmpty(beginDate) && StringUtils.isNotEmpty(endDate))
             qw.lambda().ge(ProEconEquipmentInfoDayTop::getRecordDate, DateUtils.parseDate(beginDate)).
-                    le(ProEconEquipmentInfoDayTop::getRecordDate, DateUtils.parseDate(endDate));
+                    lt(ProEconEquipmentInfoDayTop::getRecordDate, DateUtils.parseDate(endDate));
 
         qw.orderByAsc("record_date");
         List<ProEconEquipmentInfoDayTop> list = baseMapper.selectList(qw);

+ 4 - 2
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/TurbineInfoDayServiceImpl.java

@@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.util.Date;
 import java.util.List;
 
@@ -83,7 +84,7 @@ public class TurbineInfoDayServiceImpl extends ServiceImpl<TurbineInfoDayMapper,
     }
 
     @Override
-    public List<TurbineInfoDay> getTurbineMonthList(String windpowerstationId, Date startDate, Date endDate) {
+    public List<TurbineInfoDay> getTurbineMonthList(String windpowerstationId, LocalDate startDate, LocalDate endDate) {
         QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
         qw.eq("station_id", windpowerstationId)
                 .between("record_date", startDate, endDate)
@@ -126,7 +127,8 @@ public class TurbineInfoDayServiceImpl extends ServiceImpl<TurbineInfoDayMapper,
                         "SUM(lyxs) as lyxs",
                         "AVG(klyl) as klyl",
                         "AVG(fnlyl) as fnlyl",
-                        "AVG(bll) as bll"
+                        "AVG(bll) as bll",
+                        "SUM(score) as score"
                         );
         return baseMapper.selectList(qw);
     }

+ 1 - 1
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/goodness/WindturbinegoodnessService.java

@@ -963,7 +963,7 @@ public class WindturbinegoodnessService {
                         vos.get(i).setValue2(NumberUtil.round(tm.getJhjxss() + tm.getFjhjxss(), 2).doubleValue());
                         vos.get(i).setValue3(NumberUtil.round(tm.getGzss(), 2).doubleValue());
                         vos.get(i).setValue4(NumberUtil.round(tm.getXdss(), 2).doubleValue());
-                        vos.get(i).setValue4(NumberUtil.round(tm.getXnss(), 2).doubleValue());
+                        vos.get(i).setValue5(NumberUtil.round(tm.getXnss(), 2).doubleValue());
                     }
                 }
             }