Browse Source

内河低压分析月度报表,修复1月份环比计算问题

sbj 1 month ago
parent
commit
229518183a

+ 2 - 2
src/main/java/com/shcd/scheduling/ShorePowerReportGenerateScheduler.java

@@ -89,7 +89,7 @@ public class ShorePowerReportGenerateScheduler {
     try {
       spStatementInlandLowService.makeReport1(getShorePowerDate(), getShorePowerLastMonthDate());
     } catch (Exception e) {
-      log.error("内河低压分析表-市级平台自动上传数据出错....原因:{}", e.getMessage());
+      log.error("内河低压分析表-各区上报出错....原因:{}", e.getMessage());
     }
   }
 
@@ -98,7 +98,7 @@ public class ShorePowerReportGenerateScheduler {
       spStatementInlandLowService.makeReport2(getShorePowerDate(), getShorePowerLastMonthDate(),
           getShorePowerLast2MonthDate(), getShorePowerLast3MonthDate());
     } catch (Exception e) {
-      log.error("内河低压分析表-各区上报出错....原因:{}", e.getMessage());
+      log.error("内河低压分析表-市级平台自动上传数据出错....原因:{}", e.getMessage());
     }
   }
 

+ 24 - 14
src/main/java/com/shcd/service/impl/SpStatementInlandLowServiceImpl.java

@@ -118,7 +118,7 @@ public class SpStatementInlandLowServiceImpl extends
       // 计算各区
       executeEveryDistrict(originList, lastReportDataList, spStatementInlandLowList, currentMonthDate);
       // 计算合计
-      executeTotal(spStatementInlandLowList, lastMonthDate);
+      executeTotal(spStatementInlandLowList, currentMonthDate, lastMonthDate);
       log.info("最终存储的内河低压分析表1为:{}", JSONObject.toJSONString(spStatementInlandLowList));
       // 查询本月报表数据
       List<SpStatementInlandLow> currentList = this.selectCurrentMonthReport1Count(
@@ -170,7 +170,7 @@ public class SpStatementInlandLowServiceImpl extends
       List<SpStatementInlandLow> spStatementInlandLowList = executeEveryDistrict2(currentMonthData,
           lastReportDataList, currentDate);
       // 计算合计
-      executeTotal2(spStatementInlandLowList, lastMonthDate);
+      executeTotal2(spStatementInlandLowList, currentDate, lastMonthDate);
       // 查询当月是否有数据
       List<SpStatementInlandLow> currentList = this.selectCurrentMonthReport2Count(
           spStatementInlandLowList.get(0).getReportDate());
@@ -279,7 +279,7 @@ public class SpStatementInlandLowServiceImpl extends
   }
 
   private void executeTotal(List<SpStatementInlandLow> spStatementInlandLowList,
-      String lastMonthDate) {
+      String currentMonthDate, String lastMonthDate) {
     // 计算合计
     SpStatementInlandLow spStatementInlandLow = new SpStatementInlandLow();
     spStatementInlandLow.setId(String.valueOf(snowflakeMakeConf.snowflakeStringId()));
@@ -316,16 +316,21 @@ public class SpStatementInlandLowServiceImpl extends
         || lastMonthReportData.getBoatUseNumberMonth().equals(BigDecimal.ZERO)) {
       spStatementInlandLow.setBoatUseNumberChain(null);
     } else {
-      BigDecimal rate = (spStatementInlandLow.getBoatUseNumberMonth()
-          .subtract(lastMonthReportData.getBoatUseNumberMonth())).multiply(
-              BigDecimal.valueOf(100))
-          .divide(lastMonthReportData.getBoatUseNumberMonth(), 2, RoundingMode.HALF_UP);
-      spStatementInlandLow.setBoatUseNumberChain(rate);
+      String[] strings = currentMonthDate.split("-");
+      if(strings.length == 2 && Integer.valueOf(strings[1]) != 1) {
+        BigDecimal rate = (spStatementInlandLow.getBoatUseNumberMonth()
+            .subtract(lastMonthReportData.getBoatUseNumberMonth())).multiply(
+                BigDecimal.valueOf(100))
+            .divide(lastMonthReportData.getBoatUseNumberMonth(), 2, RoundingMode.HALF_UP);
+        spStatementInlandLow.setBoatUseNumberChain(rate);
+      }else{
+        spStatementInlandLow.setBoatUseNumberChain(null);
+      }
     }
     spStatementInlandLowList.add(spStatementInlandLow);
   }
 
-  private void executeTotal2(List<SpStatementInlandLow> spStatementInlandLowList,
+  private void executeTotal2(List<SpStatementInlandLow> spStatementInlandLowList, String currentDate,
       String lastMonthDate) {
     SpStatementInlandLow spStatementInlandLow = new SpStatementInlandLow();
     spStatementInlandLow.setId(String.valueOf(snowflakeMakeConf.snowflakeStringId()));
@@ -362,11 +367,16 @@ public class SpStatementInlandLowServiceImpl extends
         || lastMonthReportData.getBoatUseNumberMonth().equals(BigDecimal.ZERO)) {
       spStatementInlandLow.setBoatUseNumberChain(null);
     } else {
-      BigDecimal rate = (spStatementInlandLow.getBoatUseNumberMonth()
-          .subtract(lastMonthReportData.getBoatUseNumberMonth())).multiply(
-              BigDecimal.valueOf(100))
-          .divide(lastMonthReportData.getBoatUseNumberMonth(), 2, RoundingMode.HALF_UP);
-      spStatementInlandLow.setBoatUseNumberChain(rate);
+      String[] strings = currentDate.split("-");
+      if(strings.length == 2 && Integer.valueOf(strings[1]) != 1) {
+        BigDecimal rate = (spStatementInlandLow.getBoatUseNumberMonth()
+            .subtract(lastMonthReportData.getBoatUseNumberMonth())).multiply(
+                BigDecimal.valueOf(100))
+            .divide(lastMonthReportData.getBoatUseNumberMonth(), 2, RoundingMode.HALF_UP);
+        spStatementInlandLow.setBoatUseNumberChain(rate);
+      }else{
+        spStatementInlandLow.setBoatUseNumberChain(null);
+      }
     }
     spStatementInlandLowList.add(spStatementInlandLow);
   }