Sfoglia il codice sorgente

Merge branch 'shorepower' of http://47.101.207.123:3000/gh_department/ScheduleWork into shorepower

zoro 10 mesi fa
parent
commit
4181a7101b

+ 194 - 0
src/main/java/com/shcd/entity/SpStatementContainer.java

@@ -0,0 +1,194 @@
+package com.shcd.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * 靠泊集装箱码头船舶表
+ *
+ * @TableName SP_STATEMENT_CONTAINER
+ */
+@TableName(value = "GHJG_PORT_MANAGE.SP_STATEMENT_CONTAINER")
+@Data
+public class SpStatementContainer implements Serializable {
+
+  /**
+   *
+   */
+  @TableField(value = "ID")
+  private String id;
+
+  /**
+   *
+   */
+  @TableField(value = "REPORT_DATE")
+  private String reportDate;
+
+  /**
+   *
+   */
+  @TableField(value = "SHIP_USAGE")
+  private BigDecimal shipUsage = BigDecimal.ZERO;
+
+  /**
+   *
+   */
+  @TableField(value = "SHIP_USAGE_TON")
+  private BigDecimal shipUsageTon = BigDecimal.ZERO;
+
+  /**
+   *
+   */
+  @TableField(value = "CHARGE_TIME")
+  private BigDecimal chargeTime;
+
+  /**
+   *
+   */
+  @TableField(value = "CHARGE_TIME_TON")
+  private BigDecimal chargeTimeTon = BigDecimal.ZERO;
+
+  /**
+   *
+   */
+  @TableField(value = "ELECT_USAGE")
+  private BigDecimal electUsage = BigDecimal.ZERO;
+
+  /**
+   *
+   */
+  @TableField(value = "ELECT_USAGE_TON")
+  private BigDecimal electUsageTon = BigDecimal.ZERO;
+
+  /**
+   *
+   */
+  @TableField(value = "CREATE_TIME")
+  private Date createTime;
+
+  /**
+   *
+   */
+  @TableField(value = "SUM_SHIP_USAGE_NUM")
+  private BigDecimal sumShipUsageNum = BigDecimal.ZERO;
+
+  /**
+   *
+   */
+  @TableField(value = "SUM_SHIP_USAGE_TON")
+  private BigDecimal sumShipUsageTon = BigDecimal.ZERO;
+
+  /**
+   *
+   */
+  @TableField(value = "SUM_CHARGE_TIME")
+  private BigDecimal sumChargeTime = BigDecimal.ZERO;
+
+  /**
+   *
+   */
+  @TableField(value = "SUM_ELECT_USE")
+  private BigDecimal sumElectUse = BigDecimal.ZERO;
+
+  /**
+   *
+   */
+  @TableField(value = "SUM_ELECT_USE_TON")
+  private BigDecimal sumElectUseTon = BigDecimal.ZERO;
+
+  @TableField(exist = false)
+  private static final long serialVersionUID = 1L;
+
+  @Override
+  public boolean equals(Object that) {
+    if (this == that) {
+      return true;
+    }
+    if (that == null) {
+      return false;
+    }
+    if (getClass() != that.getClass()) {
+      return false;
+    }
+    SpStatementContainer other = (SpStatementContainer) that;
+    return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+        && (this.getReportDate() == null ? other.getReportDate() == null
+        : this.getReportDate().equals(other.getReportDate()))
+        && (this.getShipUsage() == null ? other.getShipUsage() == null
+        : this.getShipUsage().equals(other.getShipUsage()))
+        && (this.getShipUsageTon() == null ? other.getShipUsageTon() == null
+        : this.getShipUsageTon().equals(other.getShipUsageTon()))
+        && (this.getChargeTime() == null ? other.getChargeTime() == null
+        : this.getChargeTime().equals(other.getChargeTime()))
+        && (this.getChargeTimeTon() == null ? other.getChargeTimeTon() == null
+        : this.getChargeTimeTon().equals(other.getChargeTimeTon()))
+        && (this.getElectUsage() == null ? other.getElectUsage() == null
+        : this.getElectUsage().equals(other.getElectUsage()))
+        && (this.getElectUsageTon() == null ? other.getElectUsageTon() == null
+        : this.getElectUsageTon().equals(other.getElectUsageTon()))
+        && (this.getCreateTime() == null ? other.getCreateTime() == null
+        : this.getCreateTime().equals(other.getCreateTime()))
+        && (this.getSumShipUsageNum() == null ? other.getSumShipUsageNum() == null
+        : this.getSumShipUsageNum().equals(other.getSumShipUsageNum()))
+        && (this.getSumShipUsageTon() == null ? other.getSumShipUsageTon() == null
+        : this.getSumShipUsageTon().equals(other.getSumShipUsageTon()))
+        && (this.getSumChargeTime() == null ? other.getSumChargeTime() == null
+        : this.getSumChargeTime().equals(other.getSumChargeTime()))
+        && (this.getSumElectUse() == null ? other.getSumElectUse() == null
+        : this.getSumElectUse().equals(other.getSumElectUse()))
+        && (this.getSumElectUseTon() == null ? other.getSumElectUseTon() == null
+        : this.getSumElectUseTon().equals(other.getSumElectUseTon()));
+  }
+
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+    result = prime * result + ((getReportDate() == null) ? 0 : getReportDate().hashCode());
+    result = prime * result + ((getShipUsage() == null) ? 0 : getShipUsage().hashCode());
+    result = prime * result + ((getShipUsageTon() == null) ? 0 : getShipUsageTon().hashCode());
+    result = prime * result + ((getChargeTime() == null) ? 0 : getChargeTime().hashCode());
+    result = prime * result + ((getChargeTimeTon() == null) ? 0 : getChargeTimeTon().hashCode());
+    result = prime * result + ((getElectUsage() == null) ? 0 : getElectUsage().hashCode());
+    result = prime * result + ((getElectUsageTon() == null) ? 0 : getElectUsageTon().hashCode());
+    result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
+    result =
+        prime * result + ((getSumShipUsageNum() == null) ? 0 : getSumShipUsageNum().hashCode());
+    result =
+        prime * result + ((getSumShipUsageTon() == null) ? 0 : getSumShipUsageTon().hashCode());
+    result = prime * result + ((getSumChargeTime() == null) ? 0 : getSumChargeTime().hashCode());
+    result = prime * result + ((getSumElectUse() == null) ? 0 : getSumElectUse().hashCode());
+    result = prime * result + ((getSumElectUseTon() == null) ? 0 : getSumElectUseTon().hashCode());
+    return result;
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder();
+    sb.append(getClass().getSimpleName());
+    sb.append(" [");
+    sb.append("Hash = ").append(hashCode());
+    sb.append(", id=").append(id);
+    sb.append(", reportDate=").append(reportDate);
+    sb.append(", shipUsage=").append(shipUsage);
+    sb.append(", shipUsageTon=").append(shipUsageTon);
+    sb.append(", chargeTime=").append(chargeTime);
+    sb.append(", chargeTimeTon=").append(chargeTimeTon);
+    sb.append(", electUsage=").append(electUsage);
+    sb.append(", electUsageTon=").append(electUsageTon);
+    sb.append(", createTime=").append(createTime);
+    sb.append(", sumShipUsageNum=").append(sumShipUsageNum);
+    sb.append(", sumShipUsageTon=").append(sumShipUsageTon);
+    sb.append(", sumChargeTime=").append(sumChargeTime);
+    sb.append(", sumElectUse=").append(sumElectUse);
+    sb.append(", sumElectUseTon=").append(sumElectUseTon);
+    sb.append(", serialVersionUID=").append(serialVersionUID);
+    sb.append("]");
+    return sb.toString();
+  }
+}

+ 18 - 0
src/main/java/com/shcd/mapper/SpStatementContainerMapper.java

@@ -0,0 +1,18 @@
+package com.shcd.mapper;
+
+import com.shcd.entity.SpStatementContainer;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author 14390
+* @description 针对表【SP_STATEMENT_CONTAINER(靠泊集装箱码头船舶表)】的数据库操作Mapper
+* @createDate 2024-05-23 14:29:35
+* @Entity com.shcd.entity.SpStatementContainer
+*/
+public interface SpStatementContainerMapper extends BaseMapper<SpStatementContainer> {
+
+}
+
+
+
+

+ 14 - 0
src/main/java/com/shcd/service/SpStatementContainerService.java

@@ -0,0 +1,14 @@
+package com.shcd.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.shcd.entity.SpStatementContainer;
+
+/**
+* @author 14390
+* @description 针对表【SP_STATEMENT_CONTAINER(靠泊集装箱码头船舶表)】的数据库操作Service
+* @createDate 2024-05-23 14:29:35
+*/
+public interface SpStatementContainerService extends IService<SpStatementContainer> {
+
+}

+ 23 - 0
src/main/java/com/shcd/service/impl/SpStatementContainerServiceImpl.java

@@ -0,0 +1,23 @@
+package com.shcd.service.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.shcd.entity.SpStatementContainer;
+import com.shcd.service.SpStatementContainerService;
+import com.shcd.mapper.SpStatementContainerMapper;
+import org.springframework.stereotype.Service;
+
+/**
+* @author 14390
+* @description 针对表【SP_STATEMENT_CONTAINER(靠泊集装箱码头船舶表)】的数据库操作Service实现
+* @createDate 2024-05-23 14:29:35
+*/
+@Service
+public class SpStatementContainerServiceImpl extends ServiceImpl<SpStatementContainerMapper, SpStatementContainer>
+    implements SpStatementContainerService{
+
+}
+
+
+
+

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

@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.shanghaigeography.Util.DateUtils;
 import com.shanghaigeography.Util.SnowflakeConfig;
+import com.shcd.entity.SpStatementContainer;
 import com.shcd.entity.SpStatementQuarterReport;
 import com.shcd.enums.ShorePowerQuarterDataType;
+import com.shcd.mapper.SpStatementContainerMapper;
 import com.shcd.mapper.SpStatementShipUsageMonthMapper;
 import com.shcd.service.SpStatementQuarterReportService;
 import com.shcd.mapper.SpStatementQuarterReportMapper;
@@ -18,9 +20,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
-import java.math.BigInteger;
 import java.math.RoundingMode;
-import java.text.ParseException;
 import java.util.*;
 import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
@@ -39,6 +39,9 @@ public class SpStatementQuarterReportServiceImpl extends
   @Resource
   private SpStatementShipUsageMonthMapper spStatementShipUsageMonthMapper;
 
+  @Resource
+  private SpStatementContainerMapper containerMapper;
+
   @Autowired
   private SnowflakeConfig snowflakeConfig;
   private final String dateEnd = "-25 00:00:00";
@@ -216,6 +219,7 @@ public class SpStatementQuarterReportServiceImpl extends
             resultMapBl.get(dataType.getDataType()));
         spStatementQuarterReports.add(spStatementQuarterReport);
       }
+      saveCurrentMonthContainerDataToDB(spStatementQuarterReports, currentDate);
       //过滤出额外的总和,合并明细的时候会增加一个总和的数据,但是都是0
       SpStatementQuarterReport reportSum = spStatementQuarterReports.stream()
           .filter(i -> i.getDataType().equals(ShorePowerQuarterDataType.SUM.getDataType()))
@@ -370,6 +374,43 @@ public class SpStatementQuarterReportServiceImpl extends
     }
   }
 
+  private void saveCurrentMonthContainerDataToDB(
+      List<SpStatementQuarterReport> spStatementQuarterReports,
+      String currentDate) {
+    SpStatementQuarterReport currentMonthContainerData = spStatementQuarterReports.stream()
+        .filter(
+            x -> ShorePowerQuarterDataType.CONTAINER_BERTH.getDataType().equals(x.getDataType()))
+        .collect(
+            Collectors.toList()).get(0);
+    int thisMonth = Integer.parseInt(currentDate.split("-")[1]);
+    int thisYear = Integer.parseInt(currentDate.split("-")[0]);
+    // 先删后插 避免数据重复
+    containerMapper.delete(Wrappers.<SpStatementContainer>lambdaQuery()
+        .eq(SpStatementContainer::getReportDate,
+            thisYear + "_" + (thisMonth < 10 ? "0" + thisMonth : thisMonth)));
+    SpStatementContainer sameTimeLastYear = containerMapper.selectOne(
+        Wrappers.<SpStatementContainer>lambdaQuery()
+            .eq(SpStatementContainer::getReportDate,
+                thisYear - 1 + "_" + (thisMonth < 10 ? "0" + thisMonth : thisMonth)));
+    SpStatementContainer containerSingleData = new SpStatementContainer();
+    containerSingleData.setId(snowflakeConfig.snowflakeStringId());
+    containerSingleData.setReportDate(currentDate);
+    containerSingleData.setShipUsage(currentMonthContainerData.getShipUsageQuarter());
+    containerSingleData.setChargeTime(currentMonthContainerData.getChargeTimeQuarter());
+    containerSingleData.setElectUsage(currentMonthContainerData.getElectUseQuarter());
+    if (!Objects.isNull(sameTimeLastYear)) {
+      containerSingleData.setShipUsageTon(
+        containerSingleData.getShipUsage().subtract(sameTimeLastYear.getShipUsage())
+            .multiply(BigDecimal.valueOf(100))
+            .divide(sameTimeLastYear.getShipUsage(), 2, RoundingMode.HALF_UP));
+    containerSingleData.setElectUsageTon(
+        containerSingleData.getElectUsage().subtract(sameTimeLastYear.getElectUsage())
+            .multiply(BigDecimal.valueOf(100))
+            .divide(sameTimeLastYear.getElectUsage(), 2, RoundingMode.HALF_UP));
+    }
+    containerMapper.insert(containerSingleData);
+  }
+
   private void calculateQuarterReportDetailBlMonth(
       SpStatementQuarterReport spStatementQuarterReport,
       List<SpQuarterReportBlVo> spQuarterReportBlVos) {

+ 31 - 0
src/main/resources/mapper/SpStatementContainerMapper.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.shcd.mapper.SpStatementContainerMapper">
+
+    <resultMap id="BaseResultMap" type="com.shcd.entity.SpStatementContainer">
+            <result property="id" column="ID" jdbcType="VARCHAR"/>
+            <result property="reportDate" column="REPORT_DATE" jdbcType="VARCHAR"/>
+            <result property="shipUsage" column="SHIP_USAGE" jdbcType="DECIMAL"/>
+            <result property="shipUsageTon" column="SHIP_USAGE_TON" jdbcType="DECIMAL"/>
+            <result property="chargeTime" column="CHARGE_TIME" jdbcType="DECIMAL"/>
+            <result property="chargeTimeTon" column="CHARGE_TIME_TON" jdbcType="DECIMAL"/>
+            <result property="electUsage" column="ELECT_USAGE" jdbcType="DECIMAL"/>
+            <result property="electUsageTon" column="ELECT_USAGE_TON" jdbcType="DECIMAL"/>
+            <result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/>
+            <result property="sumShipUsageNum" column="SUM_SHIP_USAGE_NUM" jdbcType="DECIMAL"/>
+            <result property="sumShipUsageTon" column="SUM_SHIP_USAGE_TON" jdbcType="DECIMAL"/>
+            <result property="sumChargeTime" column="SUM_CHARGE_TIME" jdbcType="DECIMAL"/>
+            <result property="sumElectUse" column="SUM_ELECT_USE" jdbcType="DECIMAL"/>
+            <result property="sumElectUseTon" column="SUM_ELECT_USE_TON" jdbcType="DECIMAL"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        ID,REPORT_DATE,SHIP_USAGE,
+        SHIP_USAGE_TON,CHARGE_TIME,CHARGE_TIME_TON,
+        ELECT_USAGE,ELECT_USAGE_TON,CREATE_TIME,
+        SUM_SHIP_USAGE_NUM,SUM_SHIP_USAGE_TON,SUM_CHARGE_TIME,
+        SUM_ELECT_USE,SUM_ELECT_USE_TON
+    </sql>
+</mapper>