Browse Source

修改因光伏当天算,导致的起码问题

xieshengjie 3 năm trước cách đây
mục cha
commit
764c33e0b9

+ 88 - 4
src/main/java/cn/gyee/tamplate/service/analysis/AnalysisNewService.java

@@ -208,7 +208,8 @@ public class AnalysisNewService {
                     analysissubtablebottom.setRecorddate(DateUtils.parseDate(day));
                     analysissubtablebottom.setStopcode(m.getNow());
                     analysissubtablebottom.setStopcodemodify(m.getNow());
-                    double dayvalue = DoubleUtils.GetResult(DoubleUtils.GetResult(m.getNow(),m.getDay(),"-"),meterMap.get(m.getMeterid()).getMagnification(),"*");
+                    double yestdayNow = getYestdayNow(day,m.getMeterid());
+                    double dayvalue = DoubleUtils.GetResult(DoubleUtils.GetResult(m.getNow(),yestdayNow,"-"),meterMap.get(m.getMeterid()).getMagnification(),"*");
                     analysissubtablebottom.setDayvalue(dayvalue);
                     analysissubtablebottom.setDayvaluemodify(dayvalue);
                     analysissubtablebottomService.save(analysissubtablebottom);
@@ -217,6 +218,65 @@ public class AnalysisNewService {
         }
     }
 
+
+    /**
+     * 计算单场电量
+     *
+     * @param beginDate
+     * @param endDate
+     */
+    public void saveAnalysisGfTableBottomone(String beginDate, String endDate,String wpid) {
+        Map<String, Meterpoint2> meterMap = CacheContext.meterMap;
+        List<String> days = getDays(beginDate, endDate);
+        for (String day : days) {
+//            Map<String, Object> deleteparam = new HashMap<>();
+//            deleteparam.put("recorddate", DateUtils.parseDate(day));
+//            analysissubtablebottomService.removeByMap(deleteparam);
+
+            QueryWrapper<Analysissubtablebottom> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("recorddate", DateUtils.parseDate(day)).like("wpid","GDC");
+            analysissubtablebottomService.remove(queryWrapper);
+
+            Map<String, Object> deleteparam = new HashMap<>();
+            Date selDate = DateUtils.parseDate(day);
+            deleteparam.put("recorddate", DateUtils.addDays(selDate,1));
+
+            List<Meterpointvalue> meterpointvalues = meterpointvalueService.listByMap(deleteparam);
+            List<Meterpointvalue> collect = meterpointvalues.stream().filter(i -> meterMap.get(i.getMeterid()) != null).filter(i -> meterMap.get(i.getMeterid()).getDescription() != null).collect(Collectors.toList());
+
+            Analysismain mainValues = getMainValues(day, wpid);
+            collect.stream().filter(i -> meterMap.get(i.getMeterid()).getWindpowerstationid().equals(wpid)).forEach(m -> {
+                Analysissubtablebottom analysissubtablebottom = new Analysissubtablebottom();
+                analysissubtablebottom.setTid(mainValues.getId());
+                analysissubtablebottom.setWpid(wpid);
+                analysissubtablebottom.setMeterid(m.getMeterid());
+                analysissubtablebottom.setMetername(meterMap.get(m.getMeterid()).getDescription());
+                analysissubtablebottom.setRecorddate(DateUtils.parseDate(day));
+                analysissubtablebottom.setStopcode(m.getNow());
+                analysissubtablebottom.setStopcodemodify(m.getNow());
+                double yestdayNow = getYestdayNow(day,m.getMeterid());
+                double dayvalue = DoubleUtils.GetResult(DoubleUtils.GetResult(m.getNow(),yestdayNow,"-"),meterMap.get(m.getMeterid()).getMagnification(),"*");
+                analysissubtablebottom.setDayvalue(dayvalue);
+                analysissubtablebottom.setDayvaluemodify(dayvalue);
+                analysissubtablebottomService.save(analysissubtablebottom);
+            });
+        }
+    }
+
+    /**
+     * 获取昨天的止码(针对光伏不过12点就计算,起码取昨天止码)
+     * @param day
+     * @return
+     */
+    private double getYestdayNow(String day,String meterid) {
+        QueryWrapper<Analysissubtablebottom> queryWrapper = new QueryWrapper<>();
+        Date yestday = DateUtils.getYestday(DateUtils.parseDate(day));
+        queryWrapper.eq("recorddate",yestday);
+        queryWrapper.eq("meterid",meterid);
+        Analysissubtablebottom one = analysissubtablebottomService.getOne(queryWrapper);
+        return null != one ? one.getStopcodemodify() :0.0;
+    }
+
     /**
      * 保存风电项目表
      *
@@ -538,10 +598,34 @@ public class AnalysisNewService {
                 can.setRecorddate(DateUtils.parseDate(day));
 
                 can.setFdl(generatingcapacity / 10000);
-                can.setSwdl(fcfdl != 0.0 ? (generatingcapacity / fcfdl * fcswfdl) / 10000 : 0.0);
-                can.setGwdl(fcfdl != 0.0 ? (generatingcapacity / fcfdl * fcgwfdl) / 10000 : 0.0);
-                can.setFdcydl(fcfdl != 0.0 ? (generatingcapacity / fcfdl * fczyb) / 10000 : 0.0);
+                if (project.getWindpowerstationid().equals("HZJ_GDC")){
+                    Double sfwyx = 0.0;
+                    Optional<Analysissubtablebottom> sfwyxFirst = currentDayBdz.stream().filter(i -> i.getMeterid().equals("SBQDJL.NX_GD_SBQF_DD_P1_L1_001_ZXYG109")).findFirst();
+                    if (sfwyxFirst.isPresent()){
+                        sfwyx = sfwyxFirst.get().getDayvaluemodify();
+                    }
+                    List<String> ffdls = wpmeterMap.get("SBQ_FDC").stream()
+                            .filter(i -> (
+                                    i.getProjectid().equals("SBQ04_GC") && i.getMetersort().equals("主") && i.getMetertype().equals("进线") && i.getDisplaytype().equals("正向有功")
+                            )).map(i -> i.getId()).collect(Collectors.toList());
+                    double ffdl = 0;
+                    for (String meterid : fdls) {
+                        ffdl += currentDay.stream().filter(i -> i.getMeterid().equals(meterid)).findFirst().isPresent() ? currentDay.stream().filter(i -> i.getMeterid().equals(meterid)).findFirst().get().getDayvaluemodify().doubleValue() : 0.0;
+                    }
+                    can.setSwdl(ffdl!=0.0?sfwyx*(generatingcapacity/ffdl)/10000:0.0);
+
 
+                    Double gwdls = 0.0;
+                    Optional<Analysissubtablebottom> gwdlFirst = currentDayBdz.stream().filter(i -> i.getMeterid().equals("HZJDJL.NX_GD_HZJG_DD_P1_L1_001_ZXYG001")).findFirst();
+                    if (sfwyxFirst.isPresent()){
+                        gwdls = sfwyxFirst.get().getDayvaluemodify();
+                    }
+                    can.setGwdl(gwdls/10000);
+                }else{
+                    can.setSwdl(fcfdl != 0.0 ? (generatingcapacity / fcfdl * fcswfdl) / 10000 : 0.0);
+                    can.setGwdl(fcfdl != 0.0 ? (generatingcapacity / fcfdl * fcgwfdl) / 10000 : 0.0);
+                }
+                can.setFdcydl(fcfdl != 0.0 ? (generatingcapacity / fcfdl * fczyb) / 10000 : 0.0);
                 QueryWrapper<Windpowerinfoday> queryWrapper = new QueryWrapper<>();
                 queryWrapper.eq("recorddate", DateUtils.parseDate(day));
                 queryWrapper.eq("foreignkeyid", project.getId());

+ 16 - 7
src/test/java/cn/gyee/tamplate/AnalysisTest.java

@@ -27,20 +27,29 @@ public class AnalysisTest {
     public void test3() throws  Exception{
 
 
-//       analysisNewService.savaAnalysisGfmain("2021-04-01", "2021-04-22");
-        analysisNewService.saveAnalysisGfTableBottom("2021-07-10", "2021-08-02");
-//        analysisNewService.savePvProject("2021-04-01", "2021-04-22");
-//        analysisNewService.savePvStation("2021-04-01", "2021-04-22");
+//       analysisNewService.savaAnalysisGfmain("2021-08-31", "2021-09-18");
+//        analysisNewService.saveAnalysisGfTableBottom("2021-08-31", "2021-09-18");
+        analysisNewService.savePvProject("2021-09-01", "2021-09-26");
+        analysisNewService.savePvStation("2021-09-01", "2021-09-26");
 
 
               //  analysisNewService.savaAnalysismain("2021-04-25", "2021-04-25");
-        analysisNewService.saveAnalysisTableBottom("2021-07-10", "2021-08-02");
-//        analysisNewService.saveWindProject("2021-04-26", "2021-04-26");
-//        analysisNewService.saveWindStation("2021-04-26", "2021-04-26");
+//        analysisNewService.saveAnalysisTableBottom("2021-08-31", "2021-09-21");
+//        analysisNewService.saveWindProject("2021-08-31", "2021-09-21");
+//        analysisNewService.saveWindStation("2021-08-31", "2021-09-21");
 //        analysisNewService.saveCompany("2021-04-26", "2021-04-26");
 
 
 
     }
 
+    /**
+     * 计算单场
+     * @throws Exception
+     */
+    @Test
+    public void test4() throws  Exception{
+        analysisNewService.saveAnalysisGfTableBottomone("2021-09-01", "2021-09-26","XH_GDC");
+    }
+
 }