Explorar el Código

功率预测页面取值调整

wangb@gyee-china.com hace 1 año
padre
commit
cdd7dc93b8

+ 10 - 7
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/Electricity/Electricityservice.java

@@ -32,6 +32,9 @@ public class Electricityservice {
     private IProEconPowerstationInfoDay1Service proEconPowerstationInfoDay1Service;
 
     @Resource
+    private IProEconPowerstationInfoDay5Service proEconPowerstationInfoDay5Service;
+
+    @Resource
     private ProEconStationPowerServiceImpl powerService;
 
     @Resource
@@ -154,9 +157,9 @@ public class Electricityservice {
 
 
                             //实际电量
-                            List<ProEconPowerstationInfoDay1> sjdlls = proEconPowerstationInfoDay1Service.getmax(wpls.getId(),firstDayZeroHour);
+                            List<ProEconPowerstationInfoDay5> sjdlls = proEconPowerstationInfoDay5Service.getmax(wpls.getId(),firstDayZeroHour);
                             if (!sjdlls.isEmpty() && sjdlls !=null) {
-                                bysjdlhjsum += sjdlls.get(0).getYfdl().doubleValue();
+                                bysjdlhjsum += sjdlls.get(0).getYfdldb().doubleValue();
                             }
 
                             //短期预测准确率和日发电量预测
@@ -191,10 +194,10 @@ public class Electricityservice {
 
 
                         //添加当月占比
-                        vo.setDyzb(MathUtil.twoBit((bysjdlhjsum / 10000)/bnjhdlsum));
+                        vo.setDyzb(StringUtils.round(((bysjdlhjsum / 10000)/bnjhdlsum ) *100,0));
 
                         //添加全年占比
-                        vo.setQnzb(MathUtil.twoBit(((bysjdlhjsum / 10000) / yeardlsum)));
+                        vo.setQnzb(StringUtils.round(((bysjdlhjsum / 10000) / yeardlsum) *100,0));
 
                         //添加超短期准确率
                         vo.setDqzql(dqzqlsum);
@@ -228,8 +231,8 @@ public class Electricityservice {
 //                        PointData bnsjdlhj = edosUtil.getHistMatrix(nfdl, currentDate.getTime() / 1000);
 //                        bnsjdlhjsum += bnsjdlhj.getPointValueInDouble();
 
-                        List<ProEconPowerstationInfoDay1> sjdlls = proEconPowerstationInfoDay1Service.getmax(wpls.getId(),yearHour);
-                        bnsjdlhjsum +=  sjdlls.get(0).getNfdl().doubleValue();
+                        List<ProEconPowerstationInfoDay5> sjdlls = proEconPowerstationInfoDay5Service.getmax(wpls.getId(),yearHour);
+                        bnsjdlhjsum +=  sjdlls.get(0).getNfdldb().doubleValue();
 
                         Calendar calendar1 = Calendar.getInstance();
                         calendar1.set(Calendar.DAY_OF_YEAR, 1);
@@ -248,7 +251,7 @@ public class Electricityservice {
                         map.put("bnjhdlhj",MathUtil.twoBit(yeardlsum));
                         map.put("rfdlychj",rfdlychjsum);
                         map.put("bnsjdlhj",MathUtil.twoBit(bnsjdlhjsum / 10000));
-                        map.put("qnzbhj",MathUtil.twoBit((bnsjdlhjsum / 10000) /yeardlsum));
+                        map.put("qnzbhj",StringUtils.round(((bnsjdlhjsum / 10000) /yeardlsum) * 100,0));
                         map.put("dqzqlhj",dqzqlhjsum);
 
                     }

+ 42 - 36
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/analysis/AnalysisNewService.java

@@ -48,72 +48,78 @@ public class AnalysisNewService {
 
     @Resource
     private IProBasicProjectPlanService proBasicProjectPlanService;
+
     public void companys() throws Exception {
 
 
-        // 获取当前日期
+// 获取当前日期
         Date currentDate = new Date();
 
-        // 创建 Calendar 对象,并设置为当前日期
+// 创建 Calendar 对象,并设置为当前日期
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(currentDate);
 
-        // 将时间设为0点
+// 设置 beginDate 为8月31日0点
+        calendar.set(Calendar.MONTH, Calendar.AUGUST);
+        calendar.set(Calendar.DAY_OF_MONTH, 31);
         calendar.set(Calendar.HOUR_OF_DAY, 0);
         calendar.set(Calendar.MINUTE, 0);
         calendar.set(Calendar.SECOND, 0);
         calendar.set(Calendar.MILLISECOND, 0);
-
-        // 设置 beginDate 为前一天的0点
-        calendar.add(Calendar.DAY_OF_MONTH, -1);
         Date beginDate = calendar.getTime();
 
-        // 设置 endDate 为当天的0点
-        calendar.add(Calendar.DAY_OF_MONTH, 1);
+// 设置 endDate 为9月1日0点
+        calendar.set(Calendar.MONTH, Calendar.SEPTEMBER);
+        calendar.set(Calendar.DAY_OF_MONTH, 1);
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
         Date endDate = calendar.getTime();
 
+
         List<ProEconAnalysisSubtableBottom> stringList = new ArrayList<>();
         for (ProBasicPowerstation wp : CacheContext.wpls) {
+            if (wp.getId().equals("SXJ_KGDL_GJY_FDC_STA")) {
+                List<ProBasicMeterPoint> meterPoints = proBasicMeterPointService.getBaseMapper().selectList(null);
 
-            List<ProBasicMeterPoint> meterPoints = proBasicMeterPointService.getBaseMapper().selectList(null);
-
-            List<ProBasicMeterPoint> collect = meterPoints.stream().filter(i -> i.getWindpowerstationId().equals(wp.getId())).collect(Collectors.toList());
-            for (ProBasicMeterPoint po : collect) {
-                if (wp.getId().equals(po.getWindpowerstationId())) {
+                List<ProBasicMeterPoint> collect = meterPoints.stream().filter(i -> i.getWindpowerstationId().equals(wp.getId())).collect(Collectors.toList());
+                for (ProBasicMeterPoint po : collect) {
+                    if (wp.getId().equals(po.getWindpowerstationId())) {
 
-                    String point = po.getNemCode();
-                    String name = po.getName();
+                        String point = po.getNemCode();
+                        String name = po.getName();
 
-                    //获取当前测点倍率
-                    double magnification = po.getMagnification();
+                        //获取当前测点倍率
+                        double magnification = po.getMagnification();
 
-                    PointData begin = edosUtil.getSectionData(point, beginDate.getTime());
-                    PointData end = edosUtil.getSectionData(point, endDate.getTime());
+                        PointData begin = edosUtil.getSectionData(point, beginDate.getTime());
+                        PointData end = edosUtil.getSectionData(point, endDate.getTime());
 
-                    double temp1 =0.0;
-                    double temp2 =0.0;
+                        double temp1 = 0.0;
+                        double temp2 = 0.0;
 
-                    temp1 = begin.getPointValueInDouble();
-                    temp2 = end.getPointValueInDouble();
+                        temp1 = begin.getPointValueInDouble();
+                        temp2 = end.getPointValueInDouble();
 
 
-                    ProEconAnalysisSubtableBottom vo = new ProEconAnalysisSubtableBottom();
+                        ProEconAnalysisSubtableBottom vo = new ProEconAnalysisSubtableBottom();
 
-                    vo.setId(StringUtils.getUUID());
-                    vo.setRecordDate(beginDate);
-                    vo.setWpid(wp.getId());
-                    vo.setMeterId(begin.getPointName());
-                    vo.setMeterName(name);
-                    vo.setStopCode(temp2);
-                    vo.setStopCodeModify(temp2);
-                    vo.setDayValue((temp2 - temp1) * magnification);
-                    vo.setDayValueModify((temp2 - temp1) * magnification);
-                    stringList.add(vo);
-                    proEconAnalysisSubtableBottomService.batchAdd(stringList);
+                        vo.setId(StringUtils.getUUID());
+                        vo.setRecordDate(beginDate);
+                        vo.setWpid(wp.getId());
+                        vo.setMeterId(begin.getPointName());
+                        vo.setMeterName(name);
+                        vo.setStopCode(temp2);
+                        vo.setStopCodeModify(temp2);
+                        vo.setDayValue((temp2 - temp1) * magnification);
+                        vo.setDayValueModify((temp2 - temp1) * magnification);
+                        stringList.add(vo);
+                        proEconAnalysisSubtableBottomService.batchAdd(stringList);
+                    }
                 }
             }
         }
-
     }
 
 

+ 2 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/IProEconPowerstationInfoDay5Service.java

@@ -22,4 +22,6 @@ public interface IProEconPowerstationInfoDay5Service extends IService<ProEconPow
 
 
     List<ProEconPowerstationInfoDay5> getEconZhcydldb(String foreignKeyId, String staType, String dateType, Date date);
+
+    List<ProEconPowerstationInfoDay5> getmax(String foreignKeyId , Date date);
 }

+ 52 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/ProEconPowerstationInfoDay5ServiceImpl.java

@@ -94,5 +94,57 @@ public class ProEconPowerstationInfoDay5ServiceImpl extends ServiceImpl<ProEconP
         return list;
     }
 
+    @Override
+    public List<ProEconPowerstationInfoDay5> getmax(String foreignKeyId, Date date) {
+        QueryWrapper<ProEconPowerstationInfoDay5> qw = null;
+
+
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        int specifiedYear = calendar.get(Calendar.YEAR);
+        int specifiedMonth = calendar.get(Calendar.MONTH) +1;
+        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+        calendar.set(Calendar.HOUR_OF_DAY, 23);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+
+        Date endOfDayOfLastDayOfMonth = calendar.getTime();
 
+// 获取当前日期的年份和月份
+        int currentYear = Calendar.getInstance().get(Calendar.YEAR);
+        int currentMonth = Calendar.getInstance().get(Calendar.MONTH)+1;
+
+//// 获取指定日期的年份和月份
+//        int specifiedYear = calendar.get(Calendar.YEAR);
+//        int specifiedMonth = calendar.get(Calendar.MONTH);
+
+// 判断指定日期是否是当前月份
+        if (currentYear == specifiedYear && currentMonth == specifiedMonth) {
+            // 如果是当前月份,则将endOfDayOfLastDayOfMonth减去一天
+            Calendar calendar2 = Calendar.getInstance();  // 创建 Calendar 对象,表示当前时间
+            calendar2.add(Calendar.DAY_OF_MONTH, -1);  // 减去一天
+
+            // 设置时、分、秒为最后时刻
+            calendar2.set(Calendar.HOUR_OF_DAY, 23);
+            calendar2.set(Calendar.MINUTE, 59);
+            calendar2.set(Calendar.SECOND, 59);
+
+           endOfDayOfLastDayOfMonth = calendar2.getTime();  // 获取计算后的时间
+        }
+
+        //当前数据
+        List<ProEconPowerstationInfoDay5> currlist = new ArrayList<>();
+        if (null != date) {
+            qw = new QueryWrapper<>();
+            if (StringUtils.isNotEmpty(foreignKeyId)) {
+                qw.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, foreignKeyId);
+            }
+            qw.lambda().between(ProEconPowerstationInfoDay5::getRecordDate, DateUtils.getMonthFirst(date), endOfDayOfLastDayOfMonth);
+            qw.lambda().orderByDesc(ProEconPowerstationInfoDay5::getRecordDate);
+            qw.last("limit 1");
+            currlist = baseMapper.selectList(qw);
+
+        }
+        return currlist;
+    }
 }