Browse Source

完善电度日报:23零点-22零点=22的日报

hfxc226 2 years ago
parent
commit
ea6e72c2ae

+ 8 - 8
platform-service/src/main/java/com/platform/service/big/impl/BigScreenSbInfoServiceImpl.java

@@ -288,14 +288,14 @@ public class BigScreenSbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, Sb
                 jsonObject.put("lines", lineArray);
                 jSONArray.add(jsonObject);
             }
-        } else {// 月:统计每天的:需要当天0点减去前天0点的
+        } else {// 月:统计每天的:需要当天0点减去前天0点的:注意23号0点减去22号0点,是22号的
             LocalDate localDate = LocalDate.of(record.getYear(), record.getMonth(), 1);
             int days = localDate.lengthOfMonth();
 
-            // 找到前天晚上0点的
+            // 找到下个月1号晚上0点的,用来计算这个月最后一天的耗电量
             RemoteDegreeLogDTO lastDay = BeanConverterUtil.copyObjectProperties(record, RemoteDegreeLogDTO.class);
             Calendar calendar = Calendar.getInstance();
-            calendar.set(lastDay.getYear(), lastDay.getMonth() - 2, 1);
+            calendar.set(lastDay.getYear(), lastDay.getMonth(), 1);
             lastDay.setYear(calendar.get(Calendar.YEAR));
             lastDay.setMonth(calendar.get(Calendar.MONTH) + 1);
             lastDay.setDay(calendar.getActualMaximum(Calendar.DATE));
@@ -318,18 +318,18 @@ public class BigScreenSbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, Sb
                             if (degreeLog.getDay().equals(i)) {
                                 if (degreeLog.getType().equals(1)) {
                                     positiveTotal = positiveTotal.add(new BigDecimal(degreeLog.getResult()));
-                                    // 找到上个时间
-                                    if(i == 0){// 从上个月最后一天找
+                                    // 找到下个月时间
+                                    if(i == days){// 从下个月第一天找
                                         Optional<RemoteDegreeLogVO> lastR = lastList.stream().filter(item -> item.getPositionNum().equals(degreeLog.getPositionNum())).findFirst();
                                         if(lastR.isPresent()){
                                             log.info("1: " + degreeLog.getDay() + "," + degreeLog.getDay() + ","+ degreeLog.getDay() + ","+ lastR.get().getDay());
                                             positiveTotal = positiveTotal.subtract(new BigDecimal(lastR.get().getResult()));
                                         }
-                                    }else{// 从天时间找,减去昨天的数据
-                                        Optional<RemoteDegreeLogVO> lastR = list.stream().filter(item -> item.getPositionNum().equals(degreeLog.getPositionNum()) && item.getDay().equals(degreeLog.getDay()-1)).findFirst();
+                                    }else{// 从天时间找,减去昨天的数据
+                                        Optional<RemoteDegreeLogVO> lastR = list.stream().filter(item -> item.getPositionNum().equals(degreeLog.getPositionNum()) && item.getDay().equals(degreeLog.getDay()+1)).findFirst();
                                         if(lastR.isPresent()){
                                             log.info("2: " + degreeLog.getDay() + "," + lastR.get().getDay());
-                                            positiveTotal = positiveTotal.subtract(new BigDecimal(lastR.get().getResult()));
+                                            positiveTotal = new BigDecimal(lastR.get().getResult()).subtract(positiveTotal);
                                         }
                                     }
                                 }