Browse Source

:sparkles: 长江经济带报表计算调整

lag 1 year ago
parent
commit
255a05d96b

+ 8 - 8
src/main/java/com/shcd/mapper/SpStatementShipUsageMonthMapper.java

@@ -21,8 +21,8 @@ import java.util.List;
 public interface SpStatementShipUsageMonthMapper extends BaseMapper<SpStatementShipUsageMonth> {
 
   List<SpStatementShipUsageDetail> selectOriginDataMonth(
-      @Param("lastCycleStart") Date lastCycleStart, @Param("lastCycleEnd") Date lastCycleEnd,
-      @Param("thisDate") Date thisDate, @Param("lastDate") Date lastDate);
+      @Param("thisDate") Date thisDate, @Param("lastDate") Date lastDate,
+      @Param("lastCycleStart") Date lastCycleStart, @Param("lastCycleEnd") Date lastCycleEnd);
 
   SpStatementShipUsageMonthVo selectOriginDataYear(@Param("toDate") String thisDate);
 
@@ -50,18 +50,18 @@ public interface SpStatementShipUsageMonthMapper extends BaseMapper<SpStatementS
   List<SpQuarterReportBlVo> selectQuarterBlBerth(@Param("startDate") Date startDate,
       @Param("endDate") Date endDate);
 
-  List<SpStatementShipUsageDetail> selectWgqMonth(@Param("lastCycleStart") Date lastCycleStart,
-      @Param("lastCycleEnd") Date lastCycleEnd, @Param("thisDate") Date thisDate,
-      @Param("lastDate") Date lastDate);
+  List<SpStatementShipUsageDetail> selectWgqMonth(@Param("thisDate") Date thisDate,
+      @Param("lastDate") Date lastDate, @Param("lastCycleStart") Date lastCycleStart,
+      @Param("lastCycleEnd") Date lastCycleEnd);
 
   SpStatementShipUsageMonthVo selectWgqYear(@Param("toDate") String dateStrLast);
 
   SpStatementShipUsageMonthVo getInRiverDataBeforeThisMonth(@Param("toDate") String dateStrLast);
 
   List<SpStatementShipUsageDetail> getInRiverDataThisMonth(
-      @Param("lastCycleStart") Date lastCycleStart,
-      @Param("lastCycleEnd") Date lastCycleEnd, @Param("thisDate") Date thisDate,
-      @Param("lastDate") Date lastDate);
+      @Param("thisDate") Date thisDate,
+      @Param("lastDate") Date lastDate, @Param("lastCycleStart") Date lastCycleStart,
+      @Param("lastCycleEnd") Date lastCycleEnd);
 
   SpStatementShipUsageMonthVo getInRiverDataSelfThisMonth(Date thisDate, Date lastDate);
 

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

@@ -179,6 +179,7 @@ public class SpStatementInlandLowServiceImpl extends
       log.info("最终存储的内河低压分析表2为:{}", JSONObject.toJSONString(spStatementInlandLowList));
       super.saveBatch(spStatementInlandLowList);
     } catch (Exception e) {
+      e.printStackTrace();
       log.error("内河低压分析表 表2 中间表生成逻辑出错....原因:{}", e.getMessage());
     }
   }

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

@@ -66,7 +66,7 @@ public class SpStatementShipUsageMonthServiceImpl extends
       lastCycleMonth = 11;
     } else if (thisMonth == 2) {
       lastMonth = thisMonth - 1;
-      lastYear = thisYear - 1;
+      lastYear = thisYear;
       lastCycleYear = thisYear - 1;
       lastCycleMonth = 12;
     } else {
@@ -111,12 +111,12 @@ public class SpStatementShipUsageMonthServiceImpl extends
       CompletableFuture<SpStatementShipUsageMonthVo> future4 = CompletableFuture.supplyAsync(
           () -> spStatementShipUsageMonthMapper.selectGhDataYear(dateStrLast));
       //企业自维护的在中间表中没有额外计算即可
-      CompletableFuture<SpStatementShipUsageMonthVo> future6 = CompletableFuture.supplyAsync(
-          () -> spStatementShipUsageMonthMapper.selectOriginSelfDataYear(yearCountBegin, thisDate));
-      CompletableFuture.allOf(future3, future4, future6).join();
+//      CompletableFuture<SpStatementShipUsageMonthVo> future6 = CompletableFuture.supplyAsync(
+//          () -> spStatementShipUsageMonthMapper.selectOriginSelfDataYear(yearCountBegin, thisDate));
+      CompletableFuture.allOf(future3, future4).join();
       SpStatementShipUsageMonthVo originYear = future3.get();
       SpStatementShipUsageMonthVo ghYear = future4.get();
-      SpStatementShipUsageMonthVo originSelfYear = future6.get();
+      //SpStatementShipUsageMonthVo originSelfYear = future6.get();
       if (ghMonth == null) {
         ghMonth = new SpStatementShipUsageMonthVo();
       }
@@ -129,28 +129,28 @@ public class SpStatementShipUsageMonthServiceImpl extends
       if (originSelfMonth == null) {
         originSelfMonth = new SpStatementShipUsageMonthVo();
       }
-      if (originSelfYear == null) {
-        originSelfYear = new SpStatementShipUsageMonthVo();
-      }
+//      if (originSelfYear == null) {
+//        originSelfYear = new SpStatementShipUsageMonthVo();
+//      }
       ArrayList<SpStatementShipUsageMonth> spStatementShipUsageMonths = new ArrayList<>();
       SpStatementShipUsageMonth origin = new SpStatementShipUsageMonth();
       origin.setId(snowflakeGenerator.next().toString());
       origin.setShipUsageMonth(originMonth.getShipUsage().add(originSelfMonth.getShipUsage())
           .setScale(2, RoundingMode.HALF_UP));
-      origin.setShipUsageYear(originYear.getShipUsage().add(originMonth.getShipUsage())
-          .add(originSelfYear.getShipUsage()).setScale(2, RoundingMode.HALF_UP));
+      origin.setShipUsageYear(originYear.getShipUsage().add(originMonth.getShipUsage()).add(originSelfMonth.getShipUsage())
+          .setScale(2, RoundingMode.HALF_UP));
       origin.setShorePowerTimeMonth(
           originMonth.getShorePowerTime().add(originSelfMonth.getShorePowerTime())
               .setScale(2, RoundingMode.HALF_UP));
       origin.setShorePowerTimeYear(
-          originYear.getShorePowerTime().add(originMonth.getShorePowerTime())
-              .add(originSelfYear.getShorePowerTime()).setScale(2, RoundingMode.HALF_UP));
+          originYear.getShorePowerTime().add(originMonth.getShorePowerTime()).add(originSelfMonth.getShorePowerTime())
+              .setScale(2, RoundingMode.HALF_UP));
       origin.setShorePowerCountMonth(
           originMonth.getShorePowerCount().add(originSelfMonth.getShorePowerCount())
               .setScale(2, RoundingMode.HALF_UP));
       origin.setShorePowerCountYear(
-          originYear.getShorePowerCount().add(originMonth.getShorePowerCount())
-              .add(originSelfYear.getShorePowerCount()).setScale(2, RoundingMode.HALF_UP));
+          originYear.getShorePowerCount().add(originMonth.getShorePowerCount()).add(originSelfMonth.getShorePowerCount())
+              .setScale(2, RoundingMode.HALF_UP));
       origin.setReportDate(DateUtils.stringToDate(thisYear + "-" + thisMonth, "yyyy-MM"));
       origin.setDataSource(0);
       spStatementShipUsageMonths.add(origin);
@@ -496,10 +496,10 @@ public class SpStatementShipUsageMonthServiceImpl extends
       //查询去年同期数据
       SpStatementSg sameTimeLastYear = spStatementSgService.getOne(
           Wrappers.<SpStatementSg>lambdaQuery().eq(SpStatementSg::getReportDate,
-              lastYear + "-" + (thisMonth < 10 ? "0" + thisMonth : thisMonth)));
+              thisYear - 1 + "-" + (thisMonth < 10 ? "0" + thisMonth : thisMonth)));
       //获取去年最后一个月
       SpStatementSg last = spStatementSgService.getOne(
-          Wrappers.<SpStatementSg>lambdaQuery().eq(SpStatementSg::getReportDate, lastYear + "-12"));
+          Wrappers.<SpStatementSg>lambdaQuery().eq(SpStatementSg::getReportDate, thisYear -1 + "-12"));
       SpStatementSg spStatementSg = new SpStatementSg();
       spStatementSg.setId(snowflakeGenerator.next().toString());
       spStatementSg.setReportDate(DateUtils.dateToString(toDate, "yyyy-MM"));

+ 4 - 3
src/main/resources/mapper/SpStatementInlandLowMapper.xml

@@ -94,11 +94,11 @@
     FROM GHJG_PORT_MANAGE.SHORE_POWER_CONN_RECORD_INFO T
     LEFT JOIN GHJG_PORT_MANAGE.SHORE_POWER_PORT_INFO_NEW PORT
     ON PORT.PORTID = T.PORTID
-    WHERE T.CONNTYPE = '低压(标准化)'
+    WHERE (T.CONNTYPE = '低压(标准化)'
     AND PORT.AREA is not null
     and PORT.AREA != 1
-    AND PORT.PORTID != '1146'
-    AND (T.STARTTIME &lt;=
+    AND PORT.PORTID != '1146')
+    AND ((T.STARTTIME &lt;=
     TO_DATE(#{reportDateEnd}, 'yyyy-MM-dd HH24:mi:ss')
     AND T.STARTTIME &gt;=
     TO_DATE(#{reportDateStart}, 'yyyy-MM-dd HH24:mi:ss'))
@@ -111,6 +111,7 @@
       AND T.MODIFYTIME &gt;=
       TO_DATE(#{reportDateStart}, 'yyyy-MM-dd HH24:mi:ss'))
     </if>
+    )
     GROUP BY PORT.AREA
   </select>
 

+ 2 - 2
src/main/resources/mapper/SpStatementShipUsageMonthMapper.xml

@@ -73,7 +73,7 @@
     </select>
     <select id="selectWgqMonth" resultType="com.shcd.vo.SpStatementShipUsageDetail">
         select STARTTIME chargeStartDate, ENDTIME chargeEndDate ,ELECT shorePowerCount  from GHJG_PORT_MANAGE.SHORE_POWER_CONN_RECORD_INFO
-        where (STARTTIME between #{lastDate} and #{thisDate}) OR (STARTTIME between #{lastCycleStart} and #{lastCycleEnd} AND MODIFYTIME between #{lastDate} and #{thisDate}) and ENTERPRISESNAME in ('上海外高桥发电有限责任公司','上海外高桥第二发电有限责任公司','上海外高桥第三发电有限责任公司')
+        where ((STARTTIME between #{lastDate} and #{thisDate}) OR (STARTTIME between #{lastCycleStart} and #{lastCycleEnd} AND MODIFYTIME between #{lastDate} and #{thisDate})) and ENTERPRISESNAME in ('上海外高桥发电有限责任公司','上海外高桥第二发电有限责任公司','上海外高桥第三发电有限责任公司')
     </select>
     <select id="selectWgqYear" resultType="com.shcd.vo.SpStatementShipUsageMonthVo">
         select SHIP_USAGE_YEAR shipUsage, SHORE_POWER_COUNT_YEAR shorePowerCount,SHORE_POWER_TIME_YEAR shorePowerTime
@@ -83,7 +83,7 @@
     <select id="getInRiverDataThisMonth" resultType="com.shcd.vo.SpStatementShipUsageDetail">
         select STARTTIME chargeStartDate, ENDTIME chargeEndDate ,ELECT shorePowerCount  from GHJG_PORT_MANAGE.SHORE_POWER_CONN_RECORD_INFO i
         left join GHJG_PORT_MANAGE.SHORE_POWER_PORT_INFO_NEW b on B.PORTID = i.PORTID
-        where (STARTTIME between #{lastDate} and #{thisDate}) OR (STARTTIME between #{lastCycleStart} and #{lastCycleEnd} AND MODIFYTIME between #{lastDate} and #{thisDate}) and CONNTYPE = '低压(标准化)' and area >= 2 AND b.AREA &lt;= 12
+        where ((STARTTIME between #{lastDate} and #{thisDate}) OR (STARTTIME between #{lastCycleStart} and #{lastCycleEnd} AND MODIFYTIME between #{lastDate} and #{thisDate})) and (CONNTYPE = '低压(标准化)' and area >= 2 AND b.AREA &lt;= 12)
     </select>
     <select id="getInRiverDataSelfThisMonth" resultType="com.shcd.vo.SpStatementShipUsageMonthVo">
         select  sum(USE_COUNT) shipUsage, sum(ELE_TIME) shorePowerCount, sum(USE_ELECTRICITY) shorePowerTime from GHJG_PORT_MANAGE.Shore_Power_Blberthmonthuse b