Quellcode durchsuchen

[chg]增加续签合同存上一个合同编号逻辑

别傲 vor 5 Jahren
Ursprung
Commit
7a49279c57

+ 2 - 2
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/controller/ContractController.java

@@ -46,9 +46,9 @@ public class ContractController {
 
 
     /**
-     * @param contracts 新增合同数据项
+     * @param contracts 新增/续签合同数据项
      * @return 1.成功, 0.失败, 消息描述
-     * @description 新增合同
+     * @description 新增/续签合同
      * @date 2019/12/7 3:31 PM
      */
     @PostMapping("add")

+ 5 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/dao/entity/Contracts.java

@@ -107,4 +107,9 @@ public class Contracts implements Serializable {
      * 备注
      */
     private String remarks;
+
+    /**
+     * 上一个合同编号
+     */
+    private Long previousId;
 }

+ 4 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/dao/entity/model/ContractResponse.java

@@ -57,4 +57,8 @@ public class ContractResponse {
      * 合同状态
      */
     private String contractStatus;
+    /**
+     * 上一个合同编号
+     */
+    private String previousId;
 }

+ 5 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/service/ContractService.java

@@ -9,11 +9,13 @@ import cn.com.ty.lift.business.contract.dao.mapper.ContractsMapper;
 import cn.com.ty.lift.business.framework.util.MessageUtils;
 import cn.com.ty.lift.common.constants.ApiConstants;
 import cn.com.xwy.boot.web.dto.RestResponse;
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -70,7 +72,9 @@ public class ContractService {
      */
     public RestResponse add(Contracts contracts) {
         if (contracts.getNextId() == null) {
-            //TODO 按日期自动生成合同编号
+            //按当前日期时间戳自动生成合同编号
+            String contractId = DateUtil.format(new Date(), "yyyyMMddHHmmssSSS");
+            contracts.setNextId(Long.parseLong(contractId));
         }
         int result = contractsMapper.insert(contracts);
         if (result > 0) {

+ 4 - 2
lift-business-service/src/main/resources/mapper/contract/ContractsMapper.xml

@@ -21,17 +21,19 @@
         <result column="accessory_url" property="accessoryUrl" jdbcType="LONGVARCHAR" />
         <result column="end_reason" property="endReason" jdbcType="LONGVARCHAR" />
         <result column="remarks" property="remarks" jdbcType="LONGVARCHAR" />
+        <result column="previous_id" property="previousId" jdbcType="BIGINT" />
     </resultMap>
 
     <sql id="Base_Column_List" >
 		id, project_id, mt_company_id, code, source, pay_mode, lift_num, moneys, type, status,
-		given_date, given_user, star_date, end_date, create_date, next_id, accessory_url, end_reason, remarks
+		given_date, given_user, star_date, end_date, create_date, next_id, previous_id, accessory_url, end_reason, remarks
 	</sql>
 
     <!-- 根据项目、合同号、合同类型、合同状态查询合同管理列表-->
     <select id="findByCondition" resultType="cn.com.ty.lift.business.contract.dao.entity.model.ContractResponse" parameterType="cn.com.ty.lift.business.contract.dao.entity.model.ContractRequest" >
         SELECT
-        id            as contractId,
+        next_id       as contractId,
+        previous_id   as previousId,
         source        as source,
         type          as type,
         star_date     as starDate,