Browse Source

系统效率修改

wangb@gyee-china.com 1 year ago
parent
commit
73f5451e01

+ 2 - 1
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/PVSystemEfficiencyCalculator/PVSystemEfficiencyCalculatorController.java

@@ -40,7 +40,8 @@ public class PVSystemEfficiencyCalculatorController {
 
 
 //        Map<String, Object> resultList = new LinkedHashMap<>();
 //        Map<String, Object> resultList = new LinkedHashMap<>();
 
 
-        qncalculator.planvalue();
+//        qncalculator.planvalue();
+        calculator.planvalue();
 //        if (null != resultList) {
 //        if (null != resultList) {
 //            return AjaxResult.successData(200, resultList);
 //            return AjaxResult.successData(200, resultList);
 //        } else {
 //        } else {

+ 24 - 20
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/Comprehensive/PVSystemEfficiencyCalculator.java

@@ -42,6 +42,7 @@ public class PVSystemEfficiencyCalculator {
 
 
     @Resource
     @Resource
     private IEdosUtil edosUtil;
     private IEdosUtil edosUtil;
+
     public void planvalue() throws Exception {
     public void planvalue() throws Exception {
 
 
         String year = "2023";
         String year = "2023";
@@ -163,7 +164,7 @@ public class PVSystemEfficiencyCalculator {
             firstDayZeroHour = initialFirstDayZeroHour;
             firstDayZeroHour = initialFirstDayZeroHour;
         }
         }
 
 
-        //计算期次级别
+//        计算期次级别
         int ts2 = 1; // 设置为本年一月一号0点
         int ts2 = 1; // 设置为本年一月一号0点
 
 
         Calendar calendar2 = Calendar.getInstance();
         Calendar calendar2 = Calendar.getInstance();
@@ -387,14 +388,14 @@ public class PVSystemEfficiencyCalculator {
         Calendar calFirstDayZeroHour4 = Calendar.getInstance();
         Calendar calFirstDayZeroHour4 = Calendar.getInstance();
         calFirstDayZeroHour4.setTime(firstDayZeroHour4);
         calFirstDayZeroHour4.setTime(firstDayZeroHour4);
         int calFirstMonth4 = calFirstDayZeroHour4.get(Calendar.MONTH) + 1;
         int calFirstMonth4 = calFirstDayZeroHour4.get(Calendar.MONTH) + 1;
-
+        Date date = null;
+        List<ProEconSystemEfficiencyEquipment> stringList = new ArrayList<>();
         for (ProBasicEquipment wt : wtlsG) {
         for (ProBasicEquipment wt : wtlsG) {
 
 
             List<ProEconEquipmentmodel> collect = CacheContext.equipmentmodels.stream().filter(w -> wt.getModelId().equals(w.getId())).collect(Collectors.toList());
             List<ProEconEquipmentmodel> collect = CacheContext.equipmentmodels.stream().filter(w -> wt.getModelId().equals(w.getId())).collect(Collectors.toList());
 
 
 //            for (int i = 0; i < currentMonth; i++) {
 //            for (int i = 0; i < currentMonth; i++) {
-            Date date = null;
+
-            List<ProEconSystemEfficiencyEquipment> stringList = new ArrayList<>();
 
 
             if (calFirstMonth4 == currentMonth && dqnf == currentyear) {
             if (calFirstMonth4 == currentMonth && dqnf == currentyear) {
                 Calendar calendar5 = Calendar.getInstance();
                 Calendar calendar5 = Calendar.getInstance();
@@ -430,24 +431,24 @@ public class PVSystemEfficiencyCalculator {
 
 
 
 
             ProEconSystemEfficiencyEquipment power = new ProEconSystemEfficiencyEquipment();
             ProEconSystemEfficiencyEquipment power = new ProEconSystemEfficiencyEquipment();
-            power.setId(StringUtils.getUUID());
-            power.setForeignKeyId(wt.getNemCode());
-            power.setStationId(wt.getWindpowerstationId());
-            power.setProjectId(wt.getProjectId());
-            power.setLineId(wt.getLineId());
-            power.setEquipmentId(wt.getId());
-            power.setLocation("wt");
-            power.setDataDate(date);
-            power.setPowerGeneration(actualPowerOutputKilowattHours);
-            power.setLlfdlmax(expectedPowerOutputKilowattHours);
-            power.setRzqd(solarRadiationWattsPerSquareMeter);
-            power.setEfficiency(pr);
-            power.setOrderNum(wt.getOrderNum());
-            stringList.add(power);
             if (date != null) {
             if (date != null) {
-                efficiencyEquipmentService.batchAdd(stringList);
+                power.setId(StringUtils.getUUID());
+                power.setForeignKeyId(wt.getNemCode());
+                power.setStationId(wt.getWindpowerstationId());
+                power.setProjectId(wt.getProjectId());
+                power.setLineId(wt.getLineId());
+                power.setEquipmentId(wt.getId());
+                power.setLocation("wt");
+                power.setDataDate(date);
+                power.setPowerGeneration(actualPowerOutputKilowattHours);
+                power.setLlfdlmax(expectedPowerOutputKilowattHours);
+                power.setRzqd(solarRadiationWattsPerSquareMeter);
+                power.setEfficiency(pr);
+                power.setOrderNum(wt.getOrderNum());
+                stringList.add(power);
             }
             }
 
 
+
 //
 //
 //            firstDayZeroHour4 = DateUtils.addMonths(firstDayZeroHour4, 1);
 //            firstDayZeroHour4 = DateUtils.addMonths(firstDayZeroHour4, 1);
 //            calFirstDayZeroHour4.setTime(firstDayZeroHour4);
 //            calFirstDayZeroHour4.setTime(firstDayZeroHour4);
@@ -458,9 +459,12 @@ public class PVSystemEfficiencyCalculator {
 //            firstDayZeroHour4 = initialFirstDayZeroHour4;
 //            firstDayZeroHour4 = initialFirstDayZeroHour4;
         }
         }
 
 
+        efficiencyEquipmentService.batchAdd(stringList);
+
 
 
     }
     }
-        // 计算预期发电量的方法
+
+    // 计算预期发电量的方法
     public static double calculateExpectedPowerOutput(double solarRadiationWattsPerSquareMeter, double moduleCapacityKilowatts, double ts) {
     public static double calculateExpectedPowerOutput(double solarRadiationWattsPerSquareMeter, double moduleCapacityKilowatts, double ts) {
         double hoursOfDaylight = 12.0; // 假设日照时间为12小时
         double hoursOfDaylight = 12.0; // 假设日照时间为12小时
         //辐照度*容量
         //辐照度*容量

+ 76 - 44
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/ProEconSystemEfficiencyEquipmentServiceImpl.java

@@ -3,7 +3,9 @@ package com.gyee.runeconomy.service.auto.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gyee.common.model.StringUtils;
 import com.gyee.common.model.StringUtils;
+import com.gyee.runeconomy.init.CacheContext;
 import com.gyee.runeconomy.mapper.auto.ProEconSystemEfficiencyEquipmentMapper;
 import com.gyee.runeconomy.mapper.auto.ProEconSystemEfficiencyEquipmentMapper;
+import com.gyee.runeconomy.model.auto.ProBasicEquipment;
 import com.gyee.runeconomy.model.auto.ProEconSystemEfficiencyEquipment;
 import com.gyee.runeconomy.model.auto.ProEconSystemEfficiencyEquipment;
 import com.gyee.runeconomy.service.auto.IProEconSystemEfficiencyEquipmentService;
 import com.gyee.runeconomy.service.auto.IProEconSystemEfficiencyEquipmentService;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -13,6 +15,7 @@ import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.Date;
 import java.util.List;
 import java.util.List;
+import java.util.stream.Collectors;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -50,36 +53,35 @@ public class ProEconSystemEfficiencyEquipmentServiceImpl extends ServiceImpl<Pro
 
 
     @Override
     @Override
     public List<ProEconSystemEfficiencyEquipment> getbq(String foreignKeyId, Date date) {
     public List<ProEconSystemEfficiencyEquipment> getbq(String foreignKeyId, Date date) {
-        QueryWrapper<ProEconSystemEfficiencyEquipment> qw = null;
-        // 当前数据
         List<ProEconSystemEfficiencyEquipment> currlist = new ArrayList<>();
         List<ProEconSystemEfficiencyEquipment> currlist = new ArrayList<>();
-        if (null != date) {
+        if (date != null) {
-            qw = new QueryWrapper<>();
+            List<ProBasicEquipment> collect = CacheContext.wtls.stream()
-            if (StringUtils.isNotEmpty(foreignKeyId)) {
+                    .filter(wt -> foreignKeyId.equals(wt.getWindpowerstationId()))
-                qw.lambda().eq(ProEconSystemEfficiencyEquipment::getStationId, foreignKeyId);
+                    .collect(Collectors.toList());
+            for (ProBasicEquipment wt : collect) {
+                QueryWrapper<ProEconSystemEfficiencyEquipment> qw = new QueryWrapper<>();
+                if (StringUtils.isNotEmpty(wt.getId())) {
+                    qw.lambda().eq(ProEconSystemEfficiencyEquipment::getEquipmentId, wt.getId());
+                }
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+                String dateString = sdf.format(date);
+                qw.lambda().apply("to_char(data_date, 'YYYY-MM') = '" + dateString + "'");
+                qw.lambda().orderByDesc(ProEconSystemEfficiencyEquipment::getDataDate).last("LIMIT 1");
+                List<ProEconSystemEfficiencyEquipment> selectedList = baseMapper.selectList(qw);
+                currlist.addAll(selectedList);
             }
             }
-            // 获取传入日期的年月
-            String yearMonth = new SimpleDateFormat("yyyy-MM").format(date);
-            // 设置日期为固定的一天(如1日)
-            String fixedDate = yearMonth + "-01";
-            qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone >= to_timestamp('" + fixedDate + "', 'YYYY-MM-DD')");
-            qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone < to_timestamp('" + fixedDate + "', 'YYYY-MM-DD') + interval '1 month'");
-            qw.lambda().orderByAsc(ProEconSystemEfficiencyEquipment::getOrderNum);
-            currlist = baseMapper.selectList(qw);
         }
         }
         return currlist;
         return currlist;
     }
     }
 
 
     @Override
     @Override
     public List<ProEconSystemEfficiencyEquipment> gethb(String foreignKeyId, Date date) {
     public List<ProEconSystemEfficiencyEquipment> gethb(String foreignKeyId, Date date) {
-        QueryWrapper<ProEconSystemEfficiencyEquipment> qw = null;
+
-        // 当前数据
         List<ProEconSystemEfficiencyEquipment> currlist = new ArrayList<>();
         List<ProEconSystemEfficiencyEquipment> currlist = new ArrayList<>();
-        if (null != date) {
+        if (date != null) {
-            qw = new QueryWrapper<>();
+            List<ProBasicEquipment> collect = CacheContext.wtls.stream()
-            if (StringUtils.isNotEmpty(foreignKeyId)) {
+                    .filter(wt -> foreignKeyId.equals(wt.getWindpowerstationId()))
-                qw.lambda().eq(ProEconSystemEfficiencyEquipment::getStationId, foreignKeyId);
+                    .collect(Collectors.toList());
-            }
 
 
             // 将日期减去一个月
             // 将日期减去一个月
             Calendar cal = Calendar.getInstance();
             Calendar cal = Calendar.getInstance();
@@ -87,15 +89,18 @@ public class ProEconSystemEfficiencyEquipmentServiceImpl extends ServiceImpl<Pro
             cal.add(Calendar.MONTH, -1);
             cal.add(Calendar.MONTH, -1);
             Date previousMonth = cal.getTime();
             Date previousMonth = cal.getTime();
 
 
-            // 获取传入日期的年月
+            for (ProBasicEquipment wt : collect) {
-            String yearMonth = new SimpleDateFormat("yyyy-MM").format(previousMonth);
+                QueryWrapper<ProEconSystemEfficiencyEquipment> qw = new QueryWrapper<>();
-
+                if (StringUtils.isNotEmpty(wt.getId())) {
-            // 设置日期为固定的一天(如1日)
+                    qw.lambda().eq(ProEconSystemEfficiencyEquipment::getEquipmentId, wt.getId());
-            String fixedDate = yearMonth + "-01";
+                }
-            qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone >= to_timestamp('" + fixedDate + "', 'YYYY-MM-DD')");
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
-            qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone < to_timestamp('" + fixedDate + "', 'YYYY-MM-DD') + interval '1 month'");
+                String dateString = sdf.format(previousMonth);
-            qw.lambda().orderByAsc(ProEconSystemEfficiencyEquipment::getOrderNum);
+                qw.lambda().apply("to_char(data_date, 'YYYY-MM') = '" + dateString + "'");
-            currlist = baseMapper.selectList(qw);
+                qw.lambda().orderByDesc(ProEconSystemEfficiencyEquipment::getDataDate).last("LIMIT 1");
+                List<ProEconSystemEfficiencyEquipment> selectedList = baseMapper.selectList(qw);
+                currlist.addAll(selectedList);
+            }
         }
         }
         return currlist;
         return currlist;
     }
     }
@@ -103,27 +108,54 @@ public class ProEconSystemEfficiencyEquipmentServiceImpl extends ServiceImpl<Pro
 
 
     @Override
     @Override
     public List<ProEconSystemEfficiencyEquipment> gettb(String foreignKeyId, Date date) {
     public List<ProEconSystemEfficiencyEquipment> gettb(String foreignKeyId, Date date) {
-        QueryWrapper<ProEconSystemEfficiencyEquipment> qw = null;
+//        QueryWrapper<ProEconSystemEfficiencyEquipment> qw = null;
-        // 当前数据
+//        // 当前数据
+//        List<ProEconSystemEfficiencyEquipment> currlist = new ArrayList<>();
+//        if (null != date) {
+//            Calendar cal = Calendar.getInstance();
+//            cal.setTime(date);
+//            cal.add(Calendar.YEAR, -1);
+//            Date oneYearAgo = cal.getTime();
+//
+//            qw = new QueryWrapper<>();
+//            if (StringUtils.isNotEmpty(foreignKeyId)) {
+//                qw.lambda().eq(ProEconSystemEfficiencyEquipment::getStationId, foreignKeyId);
+//            }
+//            // 获取传入日期的年月
+//            String yearMonth = new SimpleDateFormat("yyyy-MM").format(oneYearAgo);
+//            // 设置日期为固定的一天(如1日)
+//            String fixedDate = yearMonth + "-01";
+//            qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone >= to_timestamp('" + fixedDate + "', 'YYYY-MM-DD')");
+//            qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone < to_timestamp('" + fixedDate + "', 'YYYY-MM-DD') + interval '1 month'");
+//            qw.lambda().orderByAsc(ProEconSystemEfficiencyEquipment::getOrderNum);
+//            currlist = baseMapper.selectList(qw);
+//        }
+//        return currlist;
+
         List<ProEconSystemEfficiencyEquipment> currlist = new ArrayList<>();
         List<ProEconSystemEfficiencyEquipment> currlist = new ArrayList<>();
-        if (null != date) {
+        if (date != null) {
+            List<ProBasicEquipment> collect = CacheContext.wtls.stream()
+                    .filter(wt -> foreignKeyId.equals(wt.getWindpowerstationId()))
+                    .collect(Collectors.toList());
+
+            // 将日期减去一个月
             Calendar cal = Calendar.getInstance();
             Calendar cal = Calendar.getInstance();
             cal.setTime(date);
             cal.setTime(date);
             cal.add(Calendar.YEAR, -1);
             cal.add(Calendar.YEAR, -1);
             Date oneYearAgo = cal.getTime();
             Date oneYearAgo = cal.getTime();
 
 
-            qw = new QueryWrapper<>();
+            for (ProBasicEquipment wt : collect) {
-            if (StringUtils.isNotEmpty(foreignKeyId)) {
+                QueryWrapper<ProEconSystemEfficiencyEquipment> qw = new QueryWrapper<>();
-                qw.lambda().eq(ProEconSystemEfficiencyEquipment::getStationId, foreignKeyId);
+                if (StringUtils.isNotEmpty(wt.getId())) {
+                    qw.lambda().eq(ProEconSystemEfficiencyEquipment::getEquipmentId, wt.getId());
+                }
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+                String dateString = sdf.format(oneYearAgo);
+                qw.lambda().apply("to_char(data_date, 'YYYY-MM') = '" + dateString + "'");
+                qw.lambda().orderByDesc(ProEconSystemEfficiencyEquipment::getDataDate).last("LIMIT 1");
+                List<ProEconSystemEfficiencyEquipment> selectedList = baseMapper.selectList(qw);
+                currlist.addAll(selectedList);
             }
             }
-            // 获取传入日期的年月
-            String yearMonth = new SimpleDateFormat("yyyy-MM").format(oneYearAgo);
-            // 设置日期为固定的一天(如1日)
-            String fixedDate = yearMonth + "-01";
-            qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone >= to_timestamp('" + fixedDate + "', 'YYYY-MM-DD')");
-            qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone < to_timestamp('" + fixedDate + "', 'YYYY-MM-DD') + interval '1 month'");
-            qw.lambda().orderByAsc(ProEconSystemEfficiencyEquipment::getOrderNum);
-            currlist = baseMapper.selectList(qw);
         }
         }
         return currlist;
         return currlist;
     }
     }