wangb 5 hari lalu
induk
melakukan
f9ac773ded

+ 191 - 52
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/ProEconEquipmentInfoDayTopServiceImpl.java

@@ -1,9 +1,6 @@
 package com.gyee.runeconomy.service.auto.impl;
 
-import cn.hutool.core.date.DateField;
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.DateUnit;
-import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.date.*;
 import cn.hutool.core.util.NumberUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -14,6 +11,7 @@ import com.gyee.common.util.DateUtils;
 import com.gyee.common.vo.healthmanager.CompareVo;
 import com.gyee.runeconomy.init.CacheContext;
 import com.gyee.runeconomy.mapper.auto.ProEconEquipmentInfoDayTopMapper;
+import com.gyee.runeconomy.model.auto.ProBasicEquipment;
 import com.gyee.runeconomy.model.auto.ProBasicPowerstation;
 import com.gyee.runeconomy.model.auto.ProEconEquipmentInfoDayTop;
 import com.gyee.runeconomy.model.auto.TurbineInfoDay;
@@ -30,6 +28,7 @@ import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * <p>
@@ -72,6 +71,8 @@ public class ProEconEquipmentInfoDayTopServiceImpl extends ServiceImpl<ProEconEq
                 i = DateUtil.dayOfMonth(offset);
                 i = i + 1;
             }
+            String nemCode = CacheContext.wtmap.get(day.getTurbineId()).getNemCode();
+            peeidt.setId(Long.valueOf(nemCode));
             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());
@@ -271,38 +272,38 @@ public class ProEconEquipmentInfoDayTopServiceImpl extends ServiceImpl<ProEconEq
 
     public List<ProEconEquipmentInfoDayTop> getEquipmentInfoDayTopHistoryList_bf(String windturbineId, Integer types, String beginDate, String endDate) {
 
-//        QueryWrapper<ProEconEquipmentInfoDayTop> qw = new QueryWrapper<>();
-//
-//        if (StringUtils.isNotEmpty(windturbineId)) {
-//            qw.lambda().eq(ProEconEquipmentInfoDayTop::getWindturbineId, windturbineId);
-//        }
-//        if (null != types) {
-//            qw.lambda().eq(ProEconEquipmentInfoDayTop::getTypes, types);
-//        }
-//
-//        if (StringUtils.isNotEmpty(beginDate) && StringUtils.isNotEmpty(endDate))
-//            qw.lambda().ge(ProEconEquipmentInfoDayTop::getRecordDate, DateUtils.parseDate(beginDate)).
-//                    lt(ProEconEquipmentInfoDayTop::getRecordDate, DateUtils.parseDate(endDate));
-//
-//        qw.orderByAsc("record_date");
-//        List<ProEconEquipmentInfoDayTop> list = baseMapper.selectList(qw);
-//        list.stream().forEach(i -> {
-//            i.setNemCode(CacheContext.wtmap.get(i.getWindturbineId()).getAname());
-//        });
-        List<ProEconEquipmentInfoDayTop> list = new ArrayList<>();
+        QueryWrapper<ProEconEquipmentInfoDayTop> qw = new QueryWrapper<>();
+
+        if (StringUtils.isNotEmpty(windturbineId)) {
+            qw.lambda().eq(ProEconEquipmentInfoDayTop::getWindturbineId, windturbineId);
+        }
+        if (null != types) {
+            qw.lambda().eq(ProEconEquipmentInfoDayTop::getTypes, types);
+        }
+
+        if (StringUtils.isNotEmpty(beginDate) && StringUtils.isNotEmpty(endDate))
+            qw.lambda().ge(ProEconEquipmentInfoDayTop::getRecordDate, DateUtils.parseDate(beginDate)).
+                    lt(ProEconEquipmentInfoDayTop::getRecordDate, DateUtils.parseDate(endDate));
+
+        qw.orderByAsc("record_date");
+        List<ProEconEquipmentInfoDayTop> list = baseMapper.selectList(qw);
+        list.stream().forEach(i -> {
+            i.setNemCode(CacheContext.wtmap.get(i.getWindturbineId()).getAname());
+        });
+//        List<ProEconEquipmentInfoDayTop> list = new ArrayList<>();
         long days = DateUtil.between(
                 DateUtil.parse(beginDate),
                 DateUtil.parse(endDate),
                 DateUnit.DAY
         );
-        for (int i = 0; i < days; i++) {
-            ProEconEquipmentInfoDayTop ed = new ProEconEquipmentInfoDayTop();
-            ed.setRecordDate(DateUtil.offsetDay(DateUtil.parse(beginDate), i));
-            ed.setNemCode(CacheContext.wtmap.get(windturbineId).getAname());
-            ed.setWindpowerstationId("NX_FGS_HA_FDC_STA");
-            ed.setWindturbineId(windturbineId);
-            list.add(ed);
-        }
+//        for (int i = 0; i < days; i++) {
+//            ProEconEquipmentInfoDayTop ed = new ProEconEquipmentInfoDayTop();
+//            ed.setRecordDate(DateUtil.offsetDay(DateUtil.parse(beginDate), i));
+//            ed.setNemCode(CacheContext.wtmap.get(windturbineId).getAname());
+//            ed.setWindpowerstationId("NX_FGS_HA_FDC_STA");
+//            ed.setWindturbineId(windturbineId);
+//            list.add(ed);
+//        }
         return list;
     }
 
@@ -384,34 +385,173 @@ public class ProEconEquipmentInfoDayTopServiceImpl extends ServiceImpl<ProEconEq
 //    }
 
 
+//    @Override
+//    public Map<String, Object> getEquipmentInfoDayTopCompareList(List<Long> ids, Integer types) {
+//        Map<String, Object> resultMap = new HashMap<>();
+//        Map<String, Object> chartsMap = new HashMap<>();
+//        Date recordDate = new Date();
+//        DateTime start = DateUtil.beginOfMonth(recordDate);
+//        QueryWrapper<ProEconEquipmentInfoDayTop> qw = new QueryWrapper<>();
+//        if (null != ids && ids.size() > 0) {
+//            qw.lambda().in(ProEconEquipmentInfoDayTop::getId, ids);
+//        }
+//        List<ProEconEquipmentInfoDayTop> list = baseMapper.selectList(qw);
+//        list.stream().forEach(i -> {
+//            i.setNemCode(CacheContext.wtmap.get(i.getWindturbineId()).getAname());
+//        });
+//        resultMap.put("data", list);
+//        if (!list.isEmpty()) {
+//            recordDate = list.get(0).getRecordDate();
+//        }
+//        int dayOfMonth = DateUtil.dayOfMonth(recordDate);
+//        List<TurbineInfoDay> turls = turbineInfoDayService.getTurbineMonthList("NX_FGS_HA_FDC_STA", start.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), recordDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
+//        List<TurbineInfoDay> turSorted = turls.stream().sorted(Comparator.comparing(TurbineInfoDay::getScore).reversed().thenComparing(TurbineInfoDay::getTurbineId)).collect(Collectors.toList());
+//
+//        for (int i = 1; i < turSorted.size(); i++) {
+//            turSorted.get(i - 1).setEdfs((double) i);
+//        }
+//
+//        Map<String, TurbineInfoDay> turMap = turls.stream().collect(Collectors.toMap(TurbineInfoDay::getTurbineId, Function.identity()));
+//        list.stream().forEach(i -> {
+//            TurbineInfoDay tur = turMap.get(i.getWindturbineId());
+//            i.setNemCode(CacheContext.wtmap.get(i.getWindturbineId()).getAname());
+//            i.setDayfdl(NumberUtil.round(tur.getRfdl() / 1000, 2).doubleValue());
+//            i.setDayllfdl(NumberUtil.round(tur.getLlfdl() / 1000, 2).doubleValue());
+//            i.setDayfs(NumberUtil.round(tur.getPjfs(), 2).doubleValue());
+//            i.setDaygzssdl(NumberUtil.round(tur.getGzss() / 1000, 2).doubleValue());
+//            i.setDayxdssdl(NumberUtil.round(tur.getXdss() / 1000, 2).doubleValue());
+//            i.setDaywhssdl(NumberUtil.round(tur.getJhjxss() / 1000, 2).doubleValue());
+//            i.setDaygzsj(NumberUtil.round(tur.getGzMin() / 60, 2).doubleValue());
+//            i.setDaywhsj(NumberUtil.round(tur.getJxMin() / 60, 2).doubleValue());
+//            i.setDayyxsj(NumberUtil.round(tur.getYxMin() / 60, 2).doubleValue());
+//            i.setDaytjsj(NumberUtil.round(tur.getTjMin() / 60, 2).doubleValue());
+//            i.setDayxnssdl(NumberUtil.round(tur.getXnss() / 1000, 2).doubleValue());
+//            i.setDaynhyd(NumberUtil.round(tur.getNhyd(), 2).doubleValue());
+//            i.setDayglyzxxs(NumberUtil.round(tur.getGlyzxxs(), 2).doubleValue());
+//            i.setDaylyxs(NumberUtil.round(tur.getLyxs(), 2).doubleValue());
+//            i.setDaysbklyl(NumberUtil.round(tur.getKlyl(), 2).doubleValue());
+//            double dxkyxs = (24 * (dayOfMonth - 1) - tur.getGzMin() / 60 - tur.getJxMin() / 60) / (0.24 * (dayOfMonth - 1));
+//            i.setDaydxkyxs(NumberUtil.round(dxkyxs, 2).doubleValue());
+//            i.setDayyxfss(NumberUtil.round(tur.getYxfss(), 2).doubleValue());
+//            i.setDayxfqr(NumberUtil.round(tur.getXfqrfs(), 2).doubleValue());
+//            i.setDayjfpl(NumberUtil.round(tur.getJfpl(), 2).doubleValue());
+//            double rank = tur.getEdfs();
+//            i.setDayRank((int)rank);
+//            i.setDayLevel(level(tur.getScore(), DateUtil.dayOfMonth(i.getRecordDate()) - 1));
+//            i.setDayjfpl(NumberUtil.round(tur.getJfpl() * 100, 2).doubleValue());
+//        });
+//        resultMap.put("data", list);
+//
+//
+//        list.stream().forEach(wtd -> {
+//            List<CompareVo> compareList = new ArrayList<>();
+//
+//            for (int i = 0; i < 10; i++) {
+//                CompareVo vo = new CompareVo();
+//
+//                switch (i) {
+//                    case 0:
+//                        vo.setTarget("平均切入风速");
+//                        vo.setData(wtd.getDayxfqr());
+//                        break;
+//                    case 1:
+//                        vo.setTarget("性能损失电量");
+//                        vo.setData(wtd.getDayxnssdl());
+//                        break;
+//                    case 2:
+//                        vo.setTarget("拟合优度");
+//                        vo.setData(wtd.getDaynhyd());
+//                        break;
+//                    case 3:
+//                        vo.setTarget("功率一致性系数");
+//                        vo.setData(wtd.getDayglyzxxs());
+//                        break;
+//                    case 4:
+//                        vo.setTarget("利用小时");
+//                        vo.setData(wtd.getDaylyxs());
+//                        break;
+//                    case 5:
+//                        vo.setTarget("设备可利用率");
+//                        vo.setData(wtd.getDaysbklyl());
+//                        break;
+//                    case 6:
+//                        vo.setTarget("等效可利用系数");
+//                        vo.setData(wtd.getDaydxkyxs());
+//                        break;
+//                    case 7:
+//                        vo.setTarget("有效风时数");
+//                        vo.setData(wtd.getDayyxfss());
+//                        break;
+//                    case 8:
+//                        vo.setTarget("平均风速");
+//                        vo.setData(wtd.getDayfs());
+//                        break;
+//                    case 9:
+//                        vo.setTarget("静风频率");
+//                        vo.setData(wtd.getDayjfpl());
+//                        break;
+//                    default:
+//                        break;
+//                }
+//                compareList.add(vo);
+//            }
+//            chartsMap.put(wtd.getNemCode(), compareList);
+//
+//        });
+//        resultMap.put("charts", chartsMap);
+//        return resultMap;
+//    }
+
+
     @Override
     public Map<String, Object> getEquipmentInfoDayTopCompareList(List<Long> ids, Integer types) {
         Map<String, Object> resultMap = new HashMap<>();
         Map<String, Object> chartsMap = new HashMap<>();
-        Date recordDate = new Date();
-        DateTime start = DateUtil.beginOfMonth(recordDate);
-        QueryWrapper<ProEconEquipmentInfoDayTop> qw = new QueryWrapper<>();
-        if (null != ids && ids.size() > 0) {
-            qw.lambda().in(ProEconEquipmentInfoDayTop::getId, ids);
+
+        LocalDate recordDate = LocalDate.now();
+        LocalDate start;
+        LocalDate end;
+        if (recordDate.getDayOfMonth() == 1) {
+            start = recordDate.minusMonths(1).withDayOfMonth(1);
+            end = recordDate.minusDays(1);
+        } else {
+            start = recordDate.withDayOfMonth(1);
+            end = recordDate;
         }
-        List<ProEconEquipmentInfoDayTop> list = baseMapper.selectList(qw);
-        list.stream().forEach(i -> {
-            i.setNemCode(CacheContext.wtmap.get(i.getWindturbineId()).getAname());
-        });
-        resultMap.put("data", list);
-        if (!list.isEmpty()) {
-            recordDate = list.get(0).getRecordDate();
+        int dayOfMonth = DateUtil.dayOfMonth(DateUtil.date(end));
+        List<TurbineInfoDay> turbineMonthList = turbineInfoDayService.getTurbineMonthList("NX_FGS_HA_FDC_STA", start, end);
+        List<ProEconEquipmentInfoDayTop> ptls = new ArrayList<>();
+        ProEconEquipmentInfoDayTop pt1 = new ProEconEquipmentInfoDayTop();
+        pt1.setNemCode(String.valueOf(ids.get(0)));
+        ProEconEquipmentInfoDayTop pt2 = new ProEconEquipmentInfoDayTop();
+        pt2.setNemCode(String.valueOf(ids.get(1)));
+
+        Map<String, TurbineInfoDay> collect = turbineMonthList.stream().collect(Collectors.toMap(TurbineInfoDay::getTurbineId, Function.identity()));
+        List<ProBasicEquipment> wtls = CacheContext.wtls;
+        List<String> code = new ArrayList<>(Arrays.asList(null, null));
+        for (ProBasicEquipment wt : wtls) {
+            if (ids.get(0) != null && ids.get(0).toString().equals(wt.getNemCode())) {
+                code.set(0, wt.getId());
+                pt1.setWindturbineId(wt.getId());
+            }
+            if (ids.get(1) != null && ids.get(1).toString().equals(wt.getNemCode())) {
+                code.set(1, wt.getId());
+                pt2.setWindturbineId(wt.getId());
+            }
         }
-        int dayOfMonth = DateUtil.dayOfMonth(recordDate);
-        List<TurbineInfoDay> turls = turbineInfoDayService.getTurbineMonthList("NX_FGS_HA_FDC_STA", start.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), recordDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
+        List<TurbineInfoDay> turls = new ArrayList<>();
+        TurbineInfoDay t1 = collect.get(code.get(0));
+        TurbineInfoDay t2 = collect.get(code.get(1));
+        turls.add(t1);
+        turls.add(t2);
         List<TurbineInfoDay> turSorted = turls.stream().sorted(Comparator.comparing(TurbineInfoDay::getScore).reversed().thenComparing(TurbineInfoDay::getTurbineId)).collect(Collectors.toList());
-
         for (int i = 1; i < turSorted.size(); i++) {
             turSorted.get(i - 1).setEdfs((double) i);
         }
-
+        ptls.add(pt1);
+        ptls.add(pt2);
         Map<String, TurbineInfoDay> turMap = turls.stream().collect(Collectors.toMap(TurbineInfoDay::getTurbineId, Function.identity()));
-        list.stream().forEach(i -> {
+        ptls.stream().forEach(i -> {
             TurbineInfoDay tur = turMap.get(i.getWindturbineId());
             i.setNemCode(CacheContext.wtmap.get(i.getWindturbineId()).getAname());
             i.setDayfdl(NumberUtil.round(tur.getRfdl() / 1000, 2).doubleValue());
@@ -435,14 +575,14 @@ public class ProEconEquipmentInfoDayTopServiceImpl extends ServiceImpl<ProEconEq
             i.setDayxfqr(NumberUtil.round(tur.getXfqrfs(), 2).doubleValue());
             i.setDayjfpl(NumberUtil.round(tur.getJfpl(), 2).doubleValue());
             double rank = tur.getEdfs();
-            i.setDayRank((int)rank);
+            i.setDayRank((int) rank);
             i.setDayLevel(level(tur.getScore(), DateUtil.dayOfMonth(i.getRecordDate()) - 1));
             i.setDayjfpl(NumberUtil.round(tur.getJfpl() * 100, 2).doubleValue());
         });
-        resultMap.put("data", list);
+        resultMap.put("data", ptls);
 
 
-        list.stream().forEach(wtd -> {
+        ptls.stream().forEach(wtd -> {
             List<CompareVo> compareList = new ArrayList<>();
 
             for (int i = 0; i < 10; i++) {
@@ -501,5 +641,4 @@ public class ProEconEquipmentInfoDayTopServiceImpl extends ServiceImpl<ProEconEq
         return resultMap;
     }
 
-
 }

+ 5 - 0
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/singleanalysis/SingleAnalysisService.java

@@ -1115,6 +1115,11 @@ public class SingleAnalysisService {
 
 
     public Map<String, List<SingleAnalysisVo>> SingleAnalysisListByWtIdDetiml(String wtId, Date beginDate, Date endDate) {
+
+        if (DateUtil.dayOfMonth(beginDate) == 1) {
+            beginDate = DateUtil.offsetMonth(beginDate, -1);
+            endDate = DateUtil.offsetMonth(endDate, -1);
+        }
         Map<String, List<SingleAnalysisVo>> map = new HashMap<>();
         if (!StringUtils.notEmp(wtId) || !StringUtils.notEmp(beginDate) || !StringUtils.notEmp(endDate)) {
             map.put("ff", new ArrayList<>());