Sfoglia il codice sorgente

岸电模板统计口径为endTime
统计计算出101编码为全部的数据

zoro 1 anno fa
parent
commit
e3fde9c55c

+ 10 - 3
src/main/java/com/shcd/mapper/SpStatementShipUsageMonthMapper.java

@@ -7,7 +7,7 @@ import com.shcd.vo.SpQuarterReportOriginVo;
 import com.shcd.vo.SpShipUsageMonthQuarterVo;
 import com.shcd.vo.SpStatementShipUsageDetail;
 import com.shcd.vo.SpStatementShipUsageMonthVo;
-import io.lettuce.core.dynamic.annotation.Param;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.Date;
 import java.util.List;
@@ -21,8 +21,8 @@ import java.util.List;
 public interface SpStatementShipUsageMonthMapper extends BaseMapper<SpStatementShipUsageMonth> {
 
   List<SpStatementShipUsageDetail> selectOriginDataMonth(
-      @Param("thisDate") Date thisDate, @Param("lastDate") Date lastDate,
-      @Param("lastCycleStart") Date lastCycleStart, @Param("lastCycleEnd") Date lastCycleEnd);
+          @Param("thisDate") Date thisDate, @Param("lastDate") Date lastDate,
+          @Param("lastCycleStart") Date lastCycleStart, @Param("lastCycleEnd") Date lastCycleEnd);
 
   SpStatementShipUsageMonthVo selectOriginDataYear(@Param("toDate") String thisDate);
 
@@ -69,6 +69,13 @@ public interface SpStatementShipUsageMonthMapper extends BaseMapper<SpStatementS
 
   SpShipUsageMonthQuarterVo selectThreeMonthsDataTotal(@Param("start") Date start,
       @Param("end") Date end);
+
+  List<SpStatementShipUsageDetail> selectNhAndWgMonth(@Param("thisDate") Date thisDate,
+                                                      @Param("lastDate") Date lastDate,
+                                                      @Param("lastCycleStart") Date lastCycleStart,
+                                                      @Param("lastCycleEnd") Date lastCycleEnd);
+
+    SpStatementShipUsageMonthVo selectNhAndWgLastMonthSum(@Param("thisMonth") Date thisDate);
 }
 
 

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

@@ -244,6 +244,27 @@ public class SpStatementShipUsageMonthServiceImpl extends
       wgq.setShorePowerCountYear(wgqYear.getShorePowerCount().add(wgqMonth.getShorePowerCount())
           .setScale(2, RoundingMode.HALF_UP));
       spStatementShipUsageMonths.add(wgq);
+      //有一个合计的用于上海市岸电使用指标完成情况统计表,对应的dataSource为101
+      //获取对应月的数据
+      List<SpStatementShipUsageDetail> nwSum = spStatementShipUsageMonthMapper.selectNhAndWgMonth(thisDate,lastDate,lastCycleStart,lastCycleEnd);
+      SpStatementShipUsageMonthVo realSum = makeOriginMonthData(nwSum);
+      //获取该月前一个月的合计数据
+      SpStatementShipUsageMonthVo nwSumLastSum = spStatementShipUsageMonthMapper.selectNhAndWgLastMonthSum(DateUtils.stringToDate(dateStrLast,"yyyy-MM"));
+      SpStatementShipUsageMonth nwSumSave = new SpStatementShipUsageMonth();
+      if (nwSumLastSum == null){
+        nwSumLastSum = new SpStatementShipUsageMonthVo();
+      }
+      nwSumSave.setId(snowflakeGenerator.next().toString());
+      nwSumSave.setReportDate(DateUtils.stringToDate(thisYear + "-" + thisMonth, "yyyy-MM"));
+      nwSumSave.setDataSource(101);
+      nwSumSave.setShipUsageMonth(realSum.getShipUsage());
+      nwSumSave.setShorePowerCountMonth(realSum.getShorePowerCount());
+      nwSumSave.setShorePowerTimeMonth(realSum.getShorePowerTime());
+      nwSumSave.setShipUsageYear(nwSumLastSum.getShipUsage().add(realSum.getShipUsage()).setScale(2,RoundingMode.HALF_UP));
+      nwSumSave.setShorePowerTimeYear(nwSumLastSum.getShorePowerTime().add(realSum.getShorePowerTime()).setScale(2,RoundingMode.HALF_UP));
+      nwSumSave.setShorePowerCountYear(nwSumLastSum.getShorePowerCount().add(realSum.getShorePowerCount()).setScale(2,RoundingMode.HALF_UP));
+      spStatementShipUsageMonths.add(nwSumSave);
+      //获取对应年的合计
       //计算内河平台数据
       //先获取本月的数据
       CompletableFuture<List<SpStatementShipUsageDetail>> futureInRiver = CompletableFuture.supplyAsync(

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

@@ -98,14 +98,14 @@
     AND PORT.AREA is not null
     and PORT.AREA != 1
     AND PORT.PORTID != '1146')
-    AND ((T.STARTTIME &lt;=
+    AND ((T.ENDTIME &lt;=
     TO_DATE(#{reportDateEnd}, 'yyyy-MM-dd HH24:mi:ss')
-    AND T.STARTTIME &gt;=
+    AND T.ENDTIME &gt;=
     TO_DATE(#{reportDateStart}, 'yyyy-MM-dd HH24:mi:ss'))
     <if
       test="lastReportDateEnd != '' and lastReportDateEnd != null and lastReportDateStart != '' and lastReportDateStart != null">
-      OR (T.STARTTIME &lt;= TO_DATE(#{lastReportDateEnd}, 'yyyy-MM-dd HH24:mi:ss') AND
-      T.STARTTIME &gt;=
+      OR (T.ENDTIME &lt;= TO_DATE(#{lastReportDateEnd}, 'yyyy-MM-dd HH24:mi:ss') AND
+      T.ENDTIME &gt;=
       TO_DATE(#{lastReportDateStart}, 'yyyy-MM-dd HH24:mi:ss') AND T.MODIFYTIME &lt;=
       TO_DATE(#{reportDateEnd}, 'yyyy-MM-dd HH24:mi:ss')
       AND T.MODIFYTIME &gt;=

+ 18 - 6
src/main/resources/mapper/SpStatementShipUsageMonthMapper.xml

@@ -19,7 +19,7 @@
     </delete>
     <select id="selectOriginDataMonth" 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})
+        where (ENDTIME between #{lastDate} and #{thisDate}) OR (ENDTIME between #{lastCycleStart} and #{lastCycleEnd} AND MODIFYTIME between #{lastDate} and #{thisDate})
     </select>
     <select id="selectGhDataMonth" resultType="com.shcd.vo.SpStatementShipUsageMonthVo">
         select decode(sum(SHORE_POWER_BOAT_USE_NUMBER),null,0,sum(SHORE_POWER_BOAT_USE_NUMBER)) shipUsage,decode(sum(POWER_CONN_HOURS),null,0,sum(POWER_CONN_HOURS)) shorePowerTime,decode(sum(ELECTRICITY_CONSUMPTION),null,0,sum(ELECTRICITY_CONSUMPTION)) shorePowerCount  from GHJG_PORT_MANAGE.SHORE_POWER_DEVICE_USAGE
@@ -58,9 +58,9 @@
       from GHJG_PORT_MANAGE.SHORE_POWER_CONN_RECORD_INFO i
              left join GHJG_PORT_MANAGE.SHORE_POWER_BERTH_INFO_NEW b on i.BERTHID = b.BERTHID
       where b.BERTHTYPE is not null
-        AND ((i.STARTTIME >= #{startDate}
-        AND i.STARTTIME &lt;= #{endDate})
-        OR (i.STARTTIME >= #{newStartDate} and i.STARTTIME &lt;= #{newStartEnd} AND
+        AND ((i.ENDTIME >= #{startDate}
+        AND i.ENDTIME &lt;= #{endDate})
+        OR (i.ENDTIME >= #{newStartDate} and i.ENDTIME &lt;= #{newStartEnd} AND
             i.MODIFYTIME >= #{startDate} and i.MODIFYTIME &lt;= #{endDate}))
     </select>
     <select id="selectQuarterBlBerth" resultType="com.shcd.vo.SpQuarterReportBlVo">
@@ -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 ((ENDTIME between #{lastDate} and #{thisDate}) OR (ENDTIME 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 ((ENDTIME between #{lastDate} and #{thisDate}) OR (ENDTIME 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
@@ -105,4 +105,16 @@
       where T.DATA_SOURCE = 99
       AND T.REPORT_DATE >= #{start} AND T.REPORT_DATE &lt;= #{end}
     </select>
+    <select id="selectNhAndWgMonth" resultType="com.shcd.vo.SpStatementShipUsageDetail">
+        select STARTTIME chargeStartDate, ENDTIME chargeEndDate, ELECT shorePowerCount
+        from GHJG_PORT_MANAGE.SHORE_POWER_CONN_RECORD_INFO
+        where CONNTYPE = '低压(标准化)'
+          and (ENDTIME > #{lastDate} and ENDTIME &lt; #{thisDate}
+                   or
+               (ENDTIME > #{lastCycleStart} and ENDTIME &lt; #{lastDate} and MODIFYTIME > #{lastCycleStart} and MODIFYTIME &lt; #{lastCycleEnd}))
+    </select>
+    <select id="selectNhAndWgLastMonthSum" resultType="com.shcd.vo.SpStatementShipUsageMonthVo">
+        select SHIP_USAGE_YEAR shipUsage, SHORE_POWER_TIME_YEAR shorePowerTime, SHORE_POWER_COUNT_YEAR shorePowerCount  from GHJG_PORT_MANAGE.SP_STATEMENT_SHIP_USAGE_MONTH
+        where trunc(REPORT_DATE) = trunc(#{thisMonth}) and DATA_SOURCE = 101
+    </select>
 </mapper>