Ver código fonte

修改计量表场站数据统计

shilin 1 ano atrás
pai
commit
1706bbc34a

+ 183 - 58
realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindPowerInfo5Service.java

@@ -38,11 +38,7 @@ public class WindPowerInfo5Service {
         QueryWrapper<ProEconPowerstationInfoDay5> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("record_date",DateUtils.truncate(recordDate)).eq("location",Location.cp.getValue());
         List<ProEconPowerstationInfoDay5> wpinfodayls = proEconPowerstationInfoDay5Service.list(queryWrapper);
-//                .stream()
-//                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
-////                        && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
-//                        && i.getLocation().equals(Location.cp.getValue()))
-//                .collect(Collectors.toList());
+
         if (!wpinfodayls.isEmpty()) {
 
             Map<String, Map<String, List<ProEconPowerstationInfoDay5>>> rgmap = new HashMap<>();
@@ -386,19 +382,22 @@ public class WindPowerInfo5Service {
                 pewp.setLocation(Location.wp.getValue());
 
 //                //昨日的统计结果
-//                List<ProEconPowerstationInfoDay5> pepid1ls =new ArrayList<>();
-//                Calendar cl=Calendar.getInstance();
-//                cl.setTime(recordDate);
-//                if(cl.get(Calendar.DAY_OF_MONTH)!=1)
-//
-//                {
-//                    pepid1ls = proEconPowerstationInfoDay5Service.list().stream()
-//                            .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0
-//                                    && i.getWindpowerstationId().equals(wp.getId())
-//                                    && i.getLocation().equals(Location.wp.getValue()))
-//                            .collect(Collectors.toList());
-//                }
-                extracted(recordDate, pointmap, pewp);
+                List<ProEconPowerstationInfoDay5> pepid1ls =new ArrayList<>();
+                Calendar cl=Calendar.getInstance();
+                cl.setTime(recordDate);
+                cl.add(Calendar.DAY_OF_MONTH,-1);
+                pepid1ls = proEconPowerstationInfoDay5Service.list().stream()
+                        .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0
+                                && i.getWindpowerstationId().equals(wp.getId())
+                                && i.getLocation().equals(Location.wp.getValue()))
+                        .collect(Collectors.toList());
+
+                ProEconPowerstationInfoDay5 lastday5=null;
+                if(!pepid1ls.isEmpty())
+                {
+                    lastday5=pepid1ls.get(0);
+                }
+                extracted(recordDate, pointmap, pewp,lastday5);
 //*******************************************年信息统计*********************************************************/
 //                wpinfodayls.add(pewp);
                 dayls.add(pewp);
@@ -472,19 +471,22 @@ public class WindPowerInfo5Service {
                 pewp.setRecordDate(DateUtils.truncate(recordDate));
 
                 //昨日的统计结果
-//                List<ProEconPowerstationInfoDay5> pepid1ls =new ArrayList<>();
-//                Calendar cl=Calendar.getInstance();
-//                cl.setTime(recordDate);
-//                if(cl.get(Calendar.DAY_OF_MONTH)!=1)
-//
-//                {
-//                    pepid1ls = proEconPowerstationInfoDay5Service.list().stream()
-//                            .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0
-//                                    && i.getProjectId().equals(pj.getId())
-//                                    && i.getLocation().equals(Location.pj.getValue()))
-//                            .collect(Collectors.toList());
-//                }
-                extracted(recordDate, pointmap, pewp);
+                List<ProEconPowerstationInfoDay5> pepid1ls =new ArrayList<>();
+                Calendar cl=Calendar.getInstance();
+                cl.setTime(recordDate);
+                cl.add(Calendar.DAY_OF_MONTH,-1);
+                pepid1ls = proEconPowerstationInfoDay5Service.list().stream()
+                        .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0
+                                && i.getProjectId().equals(pj.getId())
+                                && i.getLocation().equals(Location.pj.getValue()))
+                        .collect(Collectors.toList());
+                ProEconPowerstationInfoDay5 lastday5=null;
+                if(!pepid1ls.isEmpty())
+                {
+                    lastday5=pepid1ls.get(0);
+                }
+                extracted(recordDate, pointmap, pewp,lastday5);
+
 
 
                 dayls.add(pewp);
@@ -563,19 +565,23 @@ public class WindPowerInfo5Service {
                 pewp.setRecordDate(DateUtils.truncate(recordDate));
 
                 //昨日的统计结果
-//                List<ProEconPowerstationInfoDay5> pepid1ls =new ArrayList<>();
-//                Calendar cl=Calendar.getInstance();
-//                cl.setTime(recordDate);
-//                if(cl.get(Calendar.DAY_OF_MONTH)!=1)
-//
-//                {
-//                    pepid1ls = proEconPowerstationInfoDay5Service.list().stream()
-//                            .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0
-//                                    && i.getLineId().equals(ln.getId())
-//                                    && i.getLocation().equals(Location.ln.getValue()))
-//                            .collect(Collectors.toList());
-//                }
-                extracted(recordDate, pointmap, pewp);
+
+                List<ProEconPowerstationInfoDay5> pepid1ls =new ArrayList<>();
+                Calendar cl=Calendar.getInstance();
+                cl.setTime(recordDate);
+                cl.add(Calendar.DAY_OF_MONTH,-1);
+                pepid1ls = proEconPowerstationInfoDay5Service.list().stream()
+                        .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0
+                                && i.getLineId().equals(ln.getId())
+                                && i.getLocation().equals(Location.ln.getValue()))
+                        .collect(Collectors.toList());
+                ProEconPowerstationInfoDay5 lastday5=null;
+                if(!pepid1ls.isEmpty())
+                {
+                    lastday5=pepid1ls.get(0);
+                }
+
+                extracted(recordDate, pointmap, pewp,lastday5);
 
                 dayls.add(pewp);
                 // proEconPowerstationInfoDay5Service.save(pewp);
@@ -603,7 +609,7 @@ public class WindPowerInfo5Service {
 //        proEconPowerstationInfoDay5Service.saveBatch(dayls);
     }
 
-    private void extracted(Date recordDate, Map<String, ProBasicPowerstationPoint> pointmap, ProEconPowerstationInfoDay5 pewp) throws Exception {
+    private void extracted(Date recordDate, Map<String, ProBasicPowerstationPoint> pointmap, ProEconPowerstationInfoDay5 pewp,ProEconPowerstationInfoDay5 lastday5 ) throws Exception {
         //*******************************************日信息统计*********************************************************/
 
         double rfdlsyz = 0.0;
@@ -677,10 +683,25 @@ public class WindPowerInfo5Service {
         double yswdlsyz = 0.0;
         double ygwgwdlsyz = 0.0;
         double ynwgwdlsyz = 0.0;
+        double ycydl = 0.0;
+
+
         if (pointmap.containsKey(ContantXk.YFDLSYZ)) {
             ProBasicPowerstationPoint point = pointmap.get(ContantXk.YFDLSYZ);
             PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
-            if (StringUtils.notEmp(pointValue)) {
+//            if (StringUtils.notEmp(pointValue)) {
+//                //月发电量(升压站)
+//                yfdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
+//                pewp.setYfdldb(yfdlsyz);
+//
+//            }
+
+            if (StringUtils.notEmp(lastday5)) {
+                //月发电量(升压站)
+                yfdlsyz = StringUtils.round(lastday5.getYfdldb()+lastday5.getRfdldb(), 2);
+                pewp.setYfdldb(yfdlsyz);
+
+            }else   if (StringUtils.notEmp(pointValue)) {
                 //月发电量(升压站)
                 yfdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
                 pewp.setYfdldb(yfdlsyz);
@@ -691,18 +712,40 @@ public class WindPowerInfo5Service {
         if (pointmap.containsKey(ContantXk.YSWDL)) {
             ProBasicPowerstationPoint point = pointmap.get(ContantXk.YSWDL);
             PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
-            if (StringUtils.notEmp(pointValue)) {
+//            if (StringUtils.notEmp(pointValue)) {
+//                //月上网电量
+//                yswdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
+//                pewp.setYswdldb(yswdlsyz);
+//
+//            }
+            if (StringUtils.notEmp(lastday5)) {
                 //月上网电量
-                yswdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
+                yswdlsyz = StringUtils.round(lastday5.getYswdldb()+lastday5.getRswdldb(), 2);
                 pewp.setYswdldb(yswdlsyz);
 
+            }else if (StringUtils.notEmp(pointValue)) {
+                //月上网电量
+                yswdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
+                pewp.setYswdldb(yswdlsyz);
             }
         }
 
         if (pointmap.containsKey(ContantXk.YGWGWDL)) {
             ProBasicPowerstationPoint point = pointmap.get(ContantXk.YGWGWDL);
             PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
-            if (StringUtils.notEmp(pointValue)) {
+//            if (StringUtils.notEmp(pointValue)) {
+//                //月工网购网电量
+//                ygwgwdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
+//                pewp.setYgwgwdldb(ygwgwdlsyz);
+//
+//            }
+
+            if (StringUtils.notEmp(lastday5)) {
+                //月工网购网电量
+                ygwgwdlsyz = StringUtils.round(lastday5.getYgwgwdldb()+lastday5.getRgwgwdldb(), 2);
+                pewp.setYgwgwdldb(ygwgwdlsyz);
+
+            }else if (StringUtils.notEmp(pointValue)) {
                 //月工网购网电量
                 ygwgwdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
                 pewp.setYgwgwdldb(ygwgwdlsyz);
@@ -713,7 +756,19 @@ public class WindPowerInfo5Service {
         if (pointmap.containsKey(ContantXk.YNWGWDL)) {
             ProBasicPowerstationPoint point = pointmap.get(ContantXk.YNWGWDL);
             PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
-            if (StringUtils.notEmp(pointValue)) {
+
+//            if (StringUtils.notEmp(pointValue)) {
+//                //月农网购网电量
+//                ynwgwdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
+//                pewp.setYnwgwdldb(ynwgwdlsyz);
+//
+//            }
+            if (StringUtils.notEmp(lastday5)) {
+                //月农网购网电量
+                ynwgwdlsyz = StringUtils.round(lastday5.getYnwgwdldb()+lastday5.getRnwgwdldb(), 2);
+                pewp.setYnwgwdldb(ynwgwdlsyz);
+
+            }else if (StringUtils.notEmp(pointValue)) {
                 //月农网购网电量
                 ynwgwdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
                 pewp.setYnwgwdldb(ynwgwdlsyz);
@@ -728,9 +783,21 @@ public class WindPowerInfo5Service {
         if (pointmap.containsKey(ContantXk.YCYDL)) {
             ProBasicPowerstationPoint point = pointmap.get(ContantXk.YCYDL);
             PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
-            if (StringUtils.notEmp(pointValue)) {
+//            if (StringUtils.notEmp(pointValue)) {
+//                //月厂用电量
+//                ycydl=StringUtils.round(pointValue.getPointValueInDouble(), 2);
+//                pewp.setYfdcydldb(ycydl);
+//
+//            }
+            if (StringUtils.notEmp(lastday5)) {
                 //月厂用电量
-                pewp.setYfdcydldb(StringUtils.round(pointValue.getPointValueInDouble(), 2));
+                ycydl=StringUtils.round(lastday5.getYfdcydldb()+lastday5.getRfdcydldb(), 2);
+                pewp.setYfdcydldb(ycydl);
+
+            }else  if (StringUtils.notEmp(pointValue)) {
+                //月厂用电量
+                ycydl=StringUtils.round(pointValue.getPointValueInDouble(), 2);
+                pewp.setYfdcydldb(ycydl);
 
             }
         }
@@ -743,10 +810,24 @@ public class WindPowerInfo5Service {
         double nswdlsyz = 0.0;
         double ngwgwdlsyz = 0.0;
         double nnwgwdlsyz = 0.0;
+        double ncydl = 0.0;
         if (pointmap.containsKey(ContantXk.NFDLSYZ)) {
             ProBasicPowerstationPoint point = pointmap.get(ContantXk.NFDLSYZ);
             PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
-            if (StringUtils.notEmp(pointValue)) {
+//
+//            if (StringUtils.notEmp(pointValue)) {
+//                //年发电量(升压站)
+//                nfdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
+//                pewp.setNfdldb(nfdlsyz);
+//
+//            }
+
+            if (StringUtils.notEmp(lastday5)) {
+                //年发电量(升压站)
+                nfdlsyz = StringUtils.round(lastday5.getNfdldb()+lastday5.getRfdldb(), 2);
+                pewp.setNfdldb(nfdlsyz);
+
+            }else  if (StringUtils.notEmp(pointValue)) {
                 //年发电量(升压站)
                 nfdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
                 pewp.setNfdldb(nfdlsyz);
@@ -757,7 +838,18 @@ public class WindPowerInfo5Service {
         if (pointmap.containsKey(ContantXk.NSWDL)) {
             ProBasicPowerstationPoint point = pointmap.get(ContantXk.NSWDL);
             PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
-            if (StringUtils.notEmp(pointValue)) {
+//            if (StringUtils.notEmp(pointValue)) {
+//                //年上网电量
+//                nswdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
+//                pewp.setNswdldb(nswdlsyz);
+//
+//            }
+            if (StringUtils.notEmp(lastday5)) {
+                //年上网电量
+                nswdlsyz = StringUtils.round(lastday5.getNswdldb()+lastday5.getRswdldb(), 2);
+                pewp.setNswdldb(nswdlsyz);
+
+            }else  if (StringUtils.notEmp(pointValue)) {
                 //年上网电量
                 nswdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
                 pewp.setNswdldb(nswdlsyz);
@@ -768,7 +860,18 @@ public class WindPowerInfo5Service {
         if (pointmap.containsKey(ContantXk.NGWGWDL)) {
             ProBasicPowerstationPoint point = pointmap.get(ContantXk.NGWGWDL);
             PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
-            if (StringUtils.notEmp(pointValue)) {
+//            if (StringUtils.notEmp(pointValue)) {
+//                //年工网购网电量
+//                ngwgwdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
+//                pewp.setNgwgwdldb(ngwgwdlsyz);
+//
+//            }
+            if (StringUtils.notEmp(lastday5)) {
+                //年工网购网电量
+                ngwgwdlsyz = StringUtils.round(lastday5.getNgwgwdldb()+lastday5.getRgwgwdldb(), 2);
+                pewp.setNgwgwdldb(ngwgwdlsyz);
+
+            }else  if (StringUtils.notEmp(pointValue)) {
                 //年工网购网电量
                 ngwgwdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
                 pewp.setNgwgwdldb(ngwgwdlsyz);
@@ -779,7 +882,18 @@ public class WindPowerInfo5Service {
         if (pointmap.containsKey(ContantXk.NNWGWDL)) {
             ProBasicPowerstationPoint point = pointmap.get(ContantXk.NNWGWDL);
             PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
-            if (StringUtils.notEmp(pointValue)) {
+//            if (StringUtils.notEmp(pointValue)) {
+//                //年农网购网电量
+//                nnwgwdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
+//                pewp.setNnwgwdldb(nnwgwdlsyz);
+//
+//            }
+            if (StringUtils.notEmp(lastday5)) {
+                //年农网购网电量
+                nnwgwdlsyz = StringUtils.round(lastday5.getNnwgwdldb()+lastday5.getRnwgwdldb(), 2);
+                pewp.setNnwgwdldb(nnwgwdlsyz);
+
+            }else  if (StringUtils.notEmp(pointValue)) {
                 //年农网购网电量
                 nnwgwdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
                 pewp.setNnwgwdldb(nnwgwdlsyz);
@@ -794,9 +908,20 @@ public class WindPowerInfo5Service {
         if (pointmap.containsKey(ContantXk.NCYDL)) {
             ProBasicPowerstationPoint point = pointmap.get(ContantXk.NCYDL);
             PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
-            if (StringUtils.notEmp(pointValue)) {
+//            if (StringUtils.notEmp(pointValue)) {
+//                //年厂用电量
+//                pewp.setNfdcydldb(StringUtils.round(pointValue.getPointValueInDouble(), 2));
+//
+//            }
+            if (StringUtils.notEmp(lastday5)) {
+                //年厂用电量
+                ncydl =StringUtils.round(lastday5.getNfdcydldb()+lastday5.getRfdcydldb(), 2);
+                pewp.setNfdcydldb(ncydl);
+
+            }else   if (StringUtils.notEmp(pointValue)) {
                 //年厂用电量
-                pewp.setNfdcydldb(StringUtils.round(pointValue.getPointValueInDouble(), 2));
+                ncydl =StringUtils.round(pointValue.getPointValueInDouble(), 2);
+                pewp.setNfdcydldb(ncydl);
 
             }
         }