Sfoglia il codice sorgente

:sparkles: 内河低压分析月度报表计算范围以及逻辑调整

lag 1 anno fa
parent
commit
d19267f25d

+ 63 - 5
src/main/java/com/shcd/service/impl/SpStatementInlandLowServiceImpl.java

@@ -22,6 +22,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.stream.Collectors;
 import javax.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -348,17 +349,26 @@ public class SpStatementInlandLowServiceImpl extends
       throws ParseException {
     List<SpStatementInlandLow> spStatementInlandLowList = new ArrayList<>(
         currentMonthData.size());
-    for (ShorePowerConnRecordInfoVo currentMonth : currentMonthData) {
+    for (ShorePowerConnRecordInfoEnum areaEnum : ShorePowerConnRecordInfoEnum.values()) {
       SpStatementInlandLow spStatementInlandLow = new SpStatementInlandLow();
       spStatementInlandLow.setId(String.valueOf(snowflakeMakeConf.snowflakeId()));
+      spStatementInlandLow.setDistrict(areaEnum.getArea());
       spStatementInlandLow.setReportDate(
           DateUtils.stringToDate(currentDate, DateUtils.DATE_FORMAT_12));
-      spStatementInlandLow.setDistrict(
-          ShorePowerConnRecordInfoEnum.getByArea(Integer.parseInt(currentMonth.getArea()))
-              .getArea());
       spStatementInlandLow.setSort(
           AreaSortEnum.getByArea(spStatementInlandLow.getDistrict()).getSort());
       spStatementInlandLow.setType(2);
+      List<ShorePowerConnRecordInfoVo> areaCollectData = currentMonthData.stream()
+          .filter(
+              i -> ShorePowerConnRecordInfoEnum.getByArea(Integer.parseInt(i.getArea())).getArea()
+                  .equals(areaEnum.getArea())).collect(
+              Collectors.toList());
+      ShorePowerConnRecordInfoVo currentMonth;
+      if (!CollectionUtils.isEmpty(areaCollectData)) {
+        currentMonth = areaCollectData.get(0);
+      } else {
+        currentMonth = new ShorePowerConnRecordInfoVo();
+      }
       spStatementInlandLow.setBoatUseNumberMonth(currentMonth.getTotal());
       // 使用岸电小时在查询数据库时已经转换为小时计算
       spStatementInlandLow.setPowerConnHoursMonth(currentMonth.getDuration());
@@ -393,11 +403,59 @@ public class SpStatementInlandLowServiceImpl extends
                     .add(lastReportData.getElectricityUsageYearTotal())
                     .setScale(2, RoundingMode.HALF_UP));
           }
-
         }
       }
       spStatementInlandLowList.add(spStatementInlandLow);
     }
+//    for (ShorePowerConnRecordInfoVo currentMonth : currentMonthData) {
+//      SpStatementInlandLow spStatementInlandLow = new SpStatementInlandLow();
+//      spStatementInlandLow.setId(String.valueOf(snowflakeMakeConf.snowflakeId()));
+//      spStatementInlandLow.setReportDate(
+//          DateUtils.stringToDate(currentDate, DateUtils.DATE_FORMAT_12));
+//      spStatementInlandLow.setDistrict(
+//          ShorePowerConnRecordInfoEnum.getByArea(Integer.parseInt(currentMonth.getArea()))
+//              .getArea());
+//      spStatementInlandLow.setSort(
+//          AreaSortEnum.getByArea(spStatementInlandLow.getDistrict()).getSort());
+//      spStatementInlandLow.setType(2);
+//      spStatementInlandLow.setBoatUseNumberMonth(currentMonth.getTotal());
+//      // 使用岸电小时在查询数据库时已经转换为小时计算
+//      spStatementInlandLow.setPowerConnHoursMonth(currentMonth.getDuration());
+//      spStatementInlandLow.setElectricityUsageMonth(currentMonth.getElect());
+//      // 计算当年累计 以及 环比
+//      Calendar thisCalendar = Calendar.getInstance();
+//      thisCalendar.setTime(DateUtils.stringToDate(currentDate, DateUtils.DATE_FORMAT_12));
+//      if (thisCalendar.get(Calendar.MONTH) == Calendar.JANUARY) {
+//        spStatementInlandLow.setBoatUseNumberYearTotal(
+//            spStatementInlandLow.getBoatUseNumberMonth());
+//        spStatementInlandLow.setPowerConnHoursYearTotal(
+//            spStatementInlandLow.getPowerConnHoursMonth());
+//        spStatementInlandLow.setElectricityUsageYearTotal(
+//            spStatementInlandLow.getElectricityUsageMonth());
+//      } else {
+//        // 2月才开始计算环比
+//        for (SpStatementInlandLow lastReportData : lastReportDataList) {
+//          if (lastReportData.getDistrict().equals(spStatementInlandLow.getDistrict())) {
+//            spStatementInlandLow.setBoatUseNumberChain(
+//                getRate(spStatementInlandLow.getBoatUseNumberMonth(),
+//                    lastReportData.getBoatUseNumberMonth()));
+//            spStatementInlandLow.setBoatUseNumberYearTotal(
+//                spStatementInlandLow.getBoatUseNumberMonth()
+//                    .add(lastReportData.getBoatUseNumberYearTotal())
+//                    .setScale(2, RoundingMode.HALF_UP));
+//            spStatementInlandLow.setPowerConnHoursYearTotal(
+//                spStatementInlandLow.getPowerConnHoursMonth()
+//                    .add(lastReportData.getPowerConnHoursYearTotal())
+//                    .setScale(2, RoundingMode.HALF_UP));
+//            spStatementInlandLow.setElectricityUsageYearTotal(
+//                spStatementInlandLow.getElectricityUsageMonth()
+//                    .add(lastReportData.getElectricityUsageYearTotal())
+//                    .setScale(2, RoundingMode.HALF_UP));
+//          }
+//        }
+//      }
+//      spStatementInlandLowList.add(spStatementInlandLow);
+//    }
     return spStatementInlandLowList;
   }
 }

+ 3 - 3
src/main/java/com/shcd/vo/ShorePowerConnRecordInfoVo.java

@@ -7,7 +7,7 @@ import lombok.Data;
 public class ShorePowerConnRecordInfoVo {
 
   String area;
-  BigDecimal elect;
-  BigDecimal duration;
-  BigDecimal total;
+  BigDecimal elect = BigDecimal.ZERO;
+  BigDecimal duration = BigDecimal.ZERO;
+  BigDecimal total = BigDecimal.ZERO;
 }