Browse Source

岸电报表生成逻辑梳理,增加备注内容

sbj 3 weeks ago
parent
commit
f2af84c7d8

+ 1 - 1
src/main/java/com/shcd/entity/SpStatementShipUsageMonth.java

@@ -54,7 +54,7 @@ public class SpStatementShipUsageMonth implements Serializable {
     private BigDecimal shorePowerCountYear;
 
     /**
-     * 0 市级平台原始数据,10港航部门报送数据, 20线下报送数据 99报送交通委数据,100及以后为其他类型数据
+     * 0 市级平台原始数据,1内河平台数据,2为外港平台数据,10港航部门报送数据即内河非标数据, 20线下报送数据(外港非标数据) 99报送交通委数据,100及以后为其他类型数据
      */
     @TableField(value = "DATA_SOURCE")
     private Integer dataSource;

+ 20 - 1
src/main/java/com/shcd/scheduling/ShorePowerReportGenerateScheduler.java

@@ -102,6 +102,10 @@ public class ShorePowerReportGenerateScheduler {
     }
   }
 
+  /**
+   * 获取当前年月
+   * @return
+   */
   private static String getShorePowerDate() {
     String date = null;
     LocalDate now = LocalDate.now();
@@ -109,25 +113,40 @@ public class ShorePowerReportGenerateScheduler {
     return date;
   }
 
+  /**
+   * 获取下个月年月
+   * @return
+   */
   private static String getShorePowerNextMonthDate() {
     String date = null;
     date = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDate.now().plusMonths(1));
     return date;
   }
 
+  /**
+   * 获取上个月年月
+   * @return
+   */
   private static String getShorePowerLastMonthDate() {
     String date = null;
     date = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDate.now().plusMonths(-1));
     return date;
   }
 
-
+  /**
+   * 获取上上个月年月
+   * @return
+   */
   private static String getShorePowerLast2MonthDate() {
     String date = null;
     date = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDate.now().plusMonths(-2));
     return date;
   }
 
+  /**
+   * 获取上上上个月年月
+   * @return
+   */
   private static String getShorePowerLast3MonthDate() {
     String date = null;
     date = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDate.now().plusMonths(-3));

+ 6 - 0
src/main/java/com/shcd/service/impl/SpStatementInlandLowServiceImpl.java

@@ -102,6 +102,7 @@ public class SpStatementInlandLowServiceImpl extends
   @Override
   public void makeReport1(String currentMonthDate, String lastMonthDate) {
     try {
+      // 查询当前年月的内河非标岸电设备使用情况
       List<ShorePowerDeviceUsage> originList = this.getOriginDataFromPage(
           currentMonthDate);
       log.info("统计当月原始数据为:{}", JSONObject.toJSONString(originList));
@@ -118,8 +119,10 @@ public class SpStatementInlandLowServiceImpl extends
       // 计算合计
       executeTotal(spStatementInlandLowList, lastMonthDate);
       log.info("最终存储的内河低压分析表1为:{}", JSONObject.toJSONString(spStatementInlandLowList));
+      // 查询本月报表数据
       List<SpStatementInlandLow> currentList = this.selectCurrentMonthReport1Count(
           spStatementInlandLowList.get(0).getReportDate());
+      // 有数据情况下先删除后插入
       if (!CollectionUtils.isEmpty(currentList)) {
         this.deleteAllCurrentMonthReport1(
             spStatementInlandLowList.get(0).getReportDate());
@@ -167,8 +170,10 @@ public class SpStatementInlandLowServiceImpl extends
           lastReportDataList, currentDate);
       // 计算合计
       executeTotal2(spStatementInlandLowList, lastMonthDate);
+      // 查询当月是否有数据
       List<SpStatementInlandLow> currentList = this.selectCurrentMonthReport2Count(
           spStatementInlandLowList.get(0).getReportDate());
+      // 有数据先删除,后插入
       if (!CollectionUtils.isEmpty(currentList)) {
         this.deleteAllCurrentMonthReport2(
             spStatementInlandLowList.get(0).getReportDate());
@@ -211,6 +216,7 @@ public class SpStatementInlandLowServiceImpl extends
       // 计算当年累计 以及 环比
       Calendar thisCalendar = Calendar.getInstance();
       thisCalendar.setTime(thisMonthData.getReportDate());
+      // 判断是否为1月份
       if (thisCalendar.get(Calendar.MONTH) == Calendar.JANUARY) {
         spStatementInlandLow.setBoatUseNumberYearTotal(
             spStatementInlandLow.getBoatUseNumberMonth());

+ 1 - 1
src/main/java/com/shcd/service/impl/SpStatementQuarterReportServiceImpl.java

@@ -126,7 +126,7 @@ public class SpStatementQuarterReportServiceImpl extends
           CompletableFuture.supplyAsync(
               () -> spStatementShipUsageMonthMapper.selectQuarterOrigin(startDate, endDate,
                   newStartDate, newEndDate));
-      //手动数据
+      //线下手动上报数据
       CompletableFuture<List<SpQuarterReportBlVo>> future2 = CompletableFuture.supplyAsync(
           () -> spStatementShipUsageMonthMapper.selectQuarterBlBerth(startDate, endDate));
       CompletableFuture.allOf(future1, future2).join();

+ 21 - 1
src/main/java/com/shcd/service/impl/SpStatementShipUsageMonthServiceImpl.java

@@ -120,8 +120,10 @@ public class SpStatementShipUsageMonthServiceImpl extends
       CompletableFuture<List<SpStatementShipUsageDetail>> future1 = CompletableFuture.supplyAsync(
           () -> spStatementShipUsageMonthMapper.selectOriginDataMonth(thisDate, lastDate,
               lastCycleStart, lastCycleEnd));
+      // 查询当月内河非标岸电设备使用情况
       CompletableFuture<SpStatementShipUsageMonthVo> future2 = CompletableFuture.supplyAsync(
           () -> spStatementShipUsageMonthMapper.selectGhDataMonth(toDate));
+      // 泊位本月使用情况
       CompletableFuture<SpStatementShipUsageMonthVo> future5 = CompletableFuture.supplyAsync(
           () -> spStatementShipUsageMonthMapper.selectOriginSelfDataMonth(thisDate, lastDate));
       CompletableFuture.allOf(future1, future2, future5).join();
@@ -137,8 +139,11 @@ public class SpStatementShipUsageMonthServiceImpl extends
       List<SpStatementShipUsageDetail> otherList = spStatementShipUsageDetails.stream()
           .filter(x -> !"低压(标准化)".equals(x.getConnectType())).collect(
               Collectors.toList());
+      // 求和 低压(标准化)
       SpStatementShipUsageMonthVo nhdybzhListMonth = makeOriginMonthDataV2d1(nhdybzhList);
+      // 求和 非低压(标准化)(高压和低压大容量)
       SpStatementShipUsageMonthVo otherListMonth = makeOriginMonthData(otherList);
+
       originMonth.setShipUsage(nhdybzhListMonth.getShipUsage().add(otherListMonth.getShipUsage()));
       originMonth.setShorePowerTime(
           nhdybzhListMonth.getShorePowerTime().add(otherListMonth.getShorePowerTime()));
@@ -147,9 +152,10 @@ public class SpStatementShipUsageMonthServiceImpl extends
 
       SpStatementShipUsageMonthVo ghMonth = future2.get();
       SpStatementShipUsageMonthVo originSelfMonth = future5.get();
-      //除本月之前合计的
+      // 查询市级平台 除本月之前当年累计
       CompletableFuture<SpStatementShipUsageMonthVo> future3 = CompletableFuture.supplyAsync(
           () -> spStatementShipUsageMonthMapper.selectOriginDataYear(dateStrLast));
+      // 查询港航部门报送数据即内河非标数据 除本月之前当年累计
       CompletableFuture<SpStatementShipUsageMonthVo> future4 = CompletableFuture.supplyAsync(
           () -> spStatementShipUsageMonthMapper.selectGhDataYear(dateStrLast));
       //企业自维护的在中间表中没有额外计算即可
@@ -838,6 +844,13 @@ public class SpStatementShipUsageMonthServiceImpl extends
     return spStatementShipUsageMonthVo;
   }
 
+  /**
+   * 低压标准化
+   *  受电时间使用连电平台推送 duration字段值,注意单位是分钟要除以60转换成小时
+   *  用电量使用连电平台推送 elect字段值
+   * @param spStatementShipUsageDetails
+   * @return
+   */
   private SpStatementShipUsageMonthVo makeOriginMonthDataV2d1(
       List<SpStatementShipUsageDetail> spStatementShipUsageDetails) {
     SpStatementShipUsageMonthVo spStatementShipUsageMonthVo = new SpStatementShipUsageMonthVo();
@@ -857,6 +870,13 @@ public class SpStatementShipUsageMonthServiceImpl extends
     return spStatementShipUsageMonthVo;
   }
 
+  /**
+   * 高压和低压大容量
+   *  受电时间需要自己计算:使用连电平台推送ENDTIME-STARTTIME,注意要转换为小时
+   *  用电量使用连电平台推送 elect字段值
+   * @param spStatementShipUsageDetails
+   * @return
+   */
   private SpStatementShipUsageMonthVo makeOriginMonthData(
       List<SpStatementShipUsageDetail> spStatementShipUsageDetails) {
     SpStatementShipUsageMonthVo spStatementShipUsageMonthVo = new SpStatementShipUsageMonthVo();

+ 1 - 0
src/test/java/test.java

@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test;
 
 import java.util.Calendar;
 import java.util.HashMap;
+import java.util.Map;
 
 public class test {