dcs hace 1 año
padre
commit
24d9bda14e

+ 8 - 1
virgo.api/src/main/java/com/bosshand/virgo/api/controller/ContractController.java

@@ -67,13 +67,20 @@ public class ContractController {
         return Response.ok(result);
     }
 
-    @ApiOperation("更新")
+    @ApiOperation("更新合同")
     @RequestMapping(value = "/update", method = RequestMethod.PUT)
     public Response update(@RequestBody Contract contract) {
         contractService.update(contract);
         return Response.ok();
     }
 
+    @ApiOperation("更新合同和条款")
+    @RequestMapping(value = "/updateAll", method = RequestMethod.PUT)
+    public Response updateAll(@RequestBody Contract contract) {
+        contractService.updateAll(contract);
+        return Response.ok();
+    }
+
     @ApiOperation("删除")
     @RequestMapping(value = "/delete/{id}", method = RequestMethod.DELETE)
     public Response delete(@PathVariable long id) {

+ 4 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/dao/ClauseDao.java

@@ -10,6 +10,8 @@ public interface ClauseDao {
 
     int insert (Clause clause);
 
+    int batchInsert(List<Clause> clauseList);
+
     int update(Clause clause);
 
     int delete(long id);
@@ -17,4 +19,6 @@ public interface ClauseDao {
     List<Clause> getList(Clause clause);
 
     Clause get(long id);
+
+    int deleteContractId(long contractId);
 }

+ 110 - 6
virgo.api/src/main/java/com/bosshand/virgo/api/model/Contract.java

@@ -42,14 +42,49 @@ public class Contract {
     /**
      * 招商跟进人
      */
-    private String investmentPromotion;
+    private long investmentPromotion;
 
     /**
      * 运营跟进人
      */
-    private String operator;
+    private long operator;
+
+    /**
+     * 招商跟进人名称
+     */
+    private String investmentPromotionName;
+
+    /**
+     * 运营跟进人名称
+     */
+    private String operatorName;
 
     // 租客信息
+    /**
+     * 租客类型
+     */
+    private Integer tenantType;
+
+    /**
+     * 企业id
+     */
+    private long merchantId;
+
+    /**
+     * 企业名称
+     */
+    private String merchantName;
+
+    /**
+     * 客户id
+     */
+    private long clientId;
+
+    /**
+     * 客户名称
+     */
+    private String clientName;
+
     /**
      * 租客
      */
@@ -134,6 +169,11 @@ public class Contract {
      */
     private String data;
 
+    /**
+     * 服务条款列表
+     */
+    private List<Clause> clauseList;
+
     public long getId() {
         return id;
     }
@@ -182,22 +222,78 @@ public class Contract {
         this.roleName = roleName;
     }
 
-    public String getInvestmentPromotion() {
+    public long getInvestmentPromotion() {
         return investmentPromotion;
     }
 
-    public void setInvestmentPromotion(String investmentPromotion) {
+    public void setInvestmentPromotion(long investmentPromotion) {
         this.investmentPromotion = investmentPromotion;
     }
 
-    public String getOperator() {
+    public long getOperator() {
         return operator;
     }
 
-    public void setOperator(String operator) {
+    public void setOperator(long operator) {
         this.operator = operator;
     }
 
+    public String getInvestmentPromotionName() {
+        return investmentPromotionName;
+    }
+
+    public void setInvestmentPromotionName(String investmentPromotionName) {
+        this.investmentPromotionName = investmentPromotionName;
+    }
+
+    public String getOperatorName() {
+        return operatorName;
+    }
+
+    public void setOperatorName(String operatorName) {
+        this.operatorName = operatorName;
+    }
+
+    public Integer getTenantType() {
+        return tenantType;
+    }
+
+    public void setTenantType(Integer tenantType) {
+        this.tenantType = tenantType;
+    }
+
+    public long getMerchantId() {
+        return merchantId;
+    }
+
+    public void setMerchantId(long merchantId) {
+        this.merchantId = merchantId;
+    }
+
+    public String getMerchantName() {
+        return merchantName;
+    }
+
+    public void setMerchantName(String merchantName) {
+        this.merchantName = merchantName;
+    }
+
+    public long getClientId() {
+        return clientId;
+    }
+
+    public void setClientId(long clientId) {
+        this.clientId = clientId;
+    }
+
+    public String getClientName() {
+        return clientName;
+    }
+
+    public void setClientName(String clientName) {
+        this.clientName = clientName;
+    }
+
     public String getTenant() {
         return tenant;
     }
@@ -333,4 +429,12 @@ public class Contract {
     public void setData(String data) {
         this.data = data;
     }
+
+    public List<Clause> getClauseList() {
+        return clauseList;
+    }
+
+    public void setClauseList(List<Clause> clauseList) {
+        this.clauseList = clauseList;
+    }
 }

+ 26 - 5
virgo.api/src/main/java/com/bosshand/virgo/api/service/ContractService.java

@@ -1,6 +1,8 @@
 package com.bosshand.virgo.api.service;
 
+import com.bosshand.virgo.api.dao.ClauseDao;
 import com.bosshand.virgo.api.dao.ContractDao;
+import com.bosshand.virgo.api.model.Clause;
 import com.bosshand.virgo.api.model.Contract;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -13,16 +15,34 @@ public class ContractService {
     @Autowired
     private ContractDao contractDao;
 
-    public int insert (Contract contract){
-        return contractDao.insert(contract);
+    @Autowired
+    private ClauseDao clauseDao;
+
+    private void batchInsertClause(long contractId, List<Clause> clauseList) {
+        if (clauseList.size() > 0) {
+            clauseList.forEach(ls -> ls.setContractId(contractId));
+            clauseDao.batchInsert(clauseList);
+        }
+    }
+
+    public void insert(Contract contract) {
+        contractDao.insert(contract);
+        batchInsertClause(contract.getId(), contract.getClauseList());
     }
 
-    public int update(Contract contract){
+    public void updateAll(Contract contract) {
+        this.update(contract);
+        clauseDao.deleteContractId(contract.getId());
+        batchInsertClause(contract.getId(), contract.getClauseList());
+    }
+
+    public int update(Contract contract) {
         return contractDao.update(contract);
     }
 
-    public int delete(long id){
-        return contractDao.delete(id);
+    public void delete(long id) {
+        contractDao.delete(id);
+        clauseDao.deleteContractId(id);
     }
 
     public List<Contract> getList(Contract contract){
@@ -42,4 +62,5 @@ public class ContractService {
         return contractDao.getLimit(contract, currIndex, pageSize);
     }
 
+
 }

+ 15 - 0
virgo.api/src/main/resources/mapper/ClauseMapper.xml

@@ -41,10 +41,25 @@
                 #{incrementalEarnestMoney}, #{preferentialType}, #{preferentialStartTime}, #{preferentialEndTime}, #{preferentialRemark}, #{preferentialRentFreeWay}, #{data})
     </insert>
 
+    <insert id="batchInsert">
+        INSERT INTO clause(`contractId`, `type`, `rentWay`, `startTime`, `endTime`, `unitPrice`, `payTime`, `chargingType`, `unnaturalMonthChargingWay`,
+                           `yearDays`, `payCycle`, `leaseTermWay`, `earnestMoneyType`, `earnestMoney`, `currencyType`, `incrementalTime`, `incrementalUnitPrice`,
+                           `incrementalEarnestMoney`, `preferentialType`, `preferentialStartTime`, `preferentialEndTime`, `preferentialRemark`, `preferentialRentFreeWay`, `data`) VALUES
+        <foreach collection="clauseList" index="" item="item" separator=",">
+               (#{item.contractId}, #{item.type}, #{item.rentWay}, #{item.startTime}, #{item.endTime}, #{item.unitPrice}, #{item.payTime}, #{item.chargingType}, #{item.unnaturalMonthChargingWay},
+                #{item.yearDays}, #{item.payCycle}, #{item.leaseTermWay}, #{item.earnestMoneyType}, #{item.earnestMoney}, #{item.currencyType}, #{item.incrementalTime}, #{item.incrementalUnitPrice},
+                #{item.incrementalEarnestMoney}, #{item.preferentialType}, #{item.preferentialStartTime}, #{item.preferentialEndTime}, #{item.preferentialRemark}, #{item.preferentialRentFreeWay}, #{item.data})
+        </foreach>
+    </insert>
+
     <delete id="delete">
         DELETE from clause where id=#{id}
     </delete>
 
+    <delete id="deleteContractId">
+        DELETE from clause where contractId=#{contractId}
+    </delete>
+
     <update id="update" parameterType="com.bosshand.virgo.api.model.Clause">
         UPDATE clause
         <trim prefix="set" suffixOverrides=",">

+ 113 - 12
virgo.api/src/main/resources/mapper/ContractMapper.xml

@@ -13,6 +13,13 @@
         <result column="roleName" property="roleName"/>
         <result column="investmentPromotion" property="investmentPromotion"/>
         <result column="operator" property="operator"/>
+        <result column="investmentPromotionName" property="investmentPromotionName"/>
+        <result column="operatorName" property="operatorName"/>
+        <result column="tenantType" property="tenantType"/>
+        <result column="merchantId" property="merchantId"/>
+        <result column="merchantName" property="merchantName"/>
+        <result column="clientId" property="clientId"/>
+        <result column="clientName" property="clientName"/>
         <result column="tenant" property="tenant"/>
         <result column="industry" property="industry"/>
         <result column="corporation" property="corporation"/>
@@ -31,11 +38,48 @@
         <result column="data" property="data"/>
     </resultMap>
 
+    <resultMap type="com.bosshand.virgo.api.model.Contract" id="result">
+        <id column="id" property="id"/>
+        <result column="createDate" property="createDate"/>
+        <result column="organizationId" property="organizationId"/>
+        <result column="organizationName" property="organizationName"/>
+        <result column="roleId" property="roleId"/>
+        <result column="roleName" property="roleName"/>
+        <result column="investmentPromotion" property="investmentPromotion"/>
+        <result column="operator" property="operator"/>
+        <result column="investmentPromotionName" property="investmentPromotionName"/>
+        <result column="operatorName" property="operatorName"/>
+        <result column="tenantType" property="tenantType"/>
+        <result column="merchantId" property="merchantId"/>
+        <result column="merchantName" property="merchantName"/>
+        <result column="clientId" property="clientId"/>
+        <result column="clientName" property="clientName"/>
+        <result column="tenant" property="tenant"/>
+        <result column="industry" property="industry"/>
+        <result column="corporation" property="corporation"/>
+        <result column="signatory" property="signatory"/>
+        <result column="tenantContactPerson" property="tenantContactPerson"/>
+        <result column="signingDate" property="signingDate"/>
+        <result column="startDate" property="startDate"/>
+        <result column="endDate" property="endDate"/>
+        <result column="lateFeesStartingDays" property="lateFeesStartingDays"/>
+        <result column="lateFeesProportion" property="lateFeesProportion"/>
+        <result column="lateFeesCeiling" property="lateFeesCeiling"/>
+        <result column="tagIds" property="tagIds"/>
+        <result column="projectItemTargetRoomIds" property="projectItemTargetRoomIds"/>
+        <result column="attachment" property="attachment"/>
+        <result column="documentId" property="documentId"/>
+        <result column="data" property="data"/>
+        <collection property="clauseList" ofType="com.bosshand.virgo.api.model.Clause" resultMap="com.bosshand.virgo.api.dao.ClauseDao.clauseResult" columnPrefix="clause_"/>
+    </resultMap>
+
+
+
     <insert id="insert" parameterType="com.bosshand.virgo.api.model.Contract" useGeneratedKeys="true" keyProperty="id">
-        INSERT INTO contract(`createDate`, `organizationId`, `organizationName`, `roleId`, `roleName`, `investmentPromotion`, `operator`,
+        INSERT INTO contract(`createDate`, `organizationId`, `organizationName`, `roleId`, `roleName`, `investmentPromotion`, `operator`, `investmentPromotionName`, `operatorName`,`tenantType`, `merchantId`, `merchantName`, `clientId`, `clientName`
                              `tenant`, `industry`, `corporation`, `signatory`, `tenantContactPerson`, `signingDate`, `startDate`, `endDate`,
                              `lateFeesStartingDays`, `lateFeesProportion`, `lateFeesCeiling`, `tagIds`, `projectItemTargetRoomIds`, `attachment`, `documentId`, `data`)
-        VALUES (now(), #{organizationId}, #{organizationName}, #{roleId}, #{roleName}, #{investmentPromotion}, #{operator}, #{tenant},
+        VALUES (now(), #{organizationId}, #{organizationName}, #{roleId}, #{roleName}, #{investmentPromotion}, #{operator}, #{investmentPromotionName}, #{operatorName}, #{tenantType}, #{merchantId}, #{merchantName}, #{clientId}, #{clientName}, #{tenant},
                 #{industry}, #{corporation}, #{signatory}, #{tenantContactPerson}, #{signingDate}, #{startDate}, #{endDate}, #{lateFeesStartingDays},
                 #{lateFeesProportion}, #{lateFeesCeiling}, #{tagIds}, #{projectItemTargetRoomIds}, #{attachment}, #{documentId}, #{data})
     </insert>
@@ -50,8 +94,15 @@
             <if test="organizationId!=0">organizationId=#{organizationId},</if>
             <if test="organizationName!=null">organizationName=#{organizationName},</if>
             <if test="roleId!=0">roleId=#{roleId},</if>
-            <if test="investmentPromotion!=null">investmentPromotion=#{investmentPromotion},</if>
-            <if test="operator!=null">operator=#{operator},</if>
+            <if test="investmentPromotion!=0">investmentPromotion=#{investmentPromotion},</if>
+            <if test="operator!=0">operator=#{operator},</if>
+            <if test="investmentPromotionName!=null">investmentPromotionName=#{investmentPromotionName},</if>
+            <if test="operatorName!=null">operatorName=#{operatorName},</if>
+            <if test="tenantType!=null">tenantType=#{tenantType},</if>
+            <if test="merchantId!=0">merchantId=#{merchantId},</if>
+            <if test="merchantName!=null">merchantName=#{merchantName},</if>
+            <if test="clientId!=0">clientId=#{clientId},</if>
+            <if test="clientName!=null">clientName=#{clientName},</if>
             <if test="tenant!=null">tenant=#{tenant},</if>
             <if test="industry!=null">industry=#{industry},</if>
             <if test="corporation!=null">corporation=#{corporation},</if>
@@ -72,8 +123,37 @@
         WHERE id=#{id}
     </update>
 
-    <select id="get" resultMap="contractResult">
-        SELECT * FROM contract where id = #{id}
+    <select id="get" resultMap="result">
+        SELECT
+        c.*,
+        cl.id as clause_id,
+        cl.contractId as clause_contractId,
+        cl.type as clause_type,
+        cl.rentWay as clause_rentWay,
+        cl.startTime as clause_startTime,
+        cl.endTime as clause_endTime,
+        cl.unitPrice as clause_unitPrice,
+        cl.payTime as clause_payTime,
+        cl.chargingType as clause_chargingType,
+        cl.unnaturalMonthChargingWay as clause_unnaturalMonthChargingWay,
+        cl.yearDays as clause_yearDays,
+        cl.payCycle as clause_payCycle,
+        cl.leaseTermWay as clause_leaseTermWay,
+        cl.earnestMoneyType as clause_earnestMoneyType,
+        cl.earnestMoney as clause_earnestMoney,
+        cl.currencyType as clause_currencyType,
+        cl.incrementalTime as clause_incrementalTime,
+        cl.incrementalUnitPrice as clause_incrementalUnitPrice,
+        cl.incrementalEarnestMoney as clause_incrementalEarnestMoney,
+        cl.preferentialType as clause_preferentialType,
+        cl.preferentialStartTime as clause_preferentialStartTime,
+        cl.preferentialEndTime as clause_preferentialEndTime,
+        cl.preferentialRemark as clause_preferentialRemark,
+        cl.preferentialRentFreeWay as clause_preferentialRentFreeWay,
+        cl.data as clause_data
+        FROM contract c
+        LEFT JOIN clause cl ON c.id = cl.contractId
+        where c.id = #{id}
     </select>
 
     <select id="getList" resultMap="contractResult">
@@ -82,8 +162,15 @@
             <if test="organizationId!=0">and organizationId=#{organizationId}</if>
             <if test="organizationName!=null">and organizationName=#{organizationName}</if>
             <if test="roleId!=0">and roleId=#{roleId}</if>
-            <if test="investmentPromotion!=null">and investmentPromotion=#{investmentPromotion}</if>
-            <if test="operator!=null">and operator=#{operator}</if>
+            <if test="investmentPromotion!=0">and investmentPromotion=#{investmentPromotion}</if>
+            <if test="operator!=0">and operator=#{operator}</if>
+            <if test="investmentPromotionName!=null">investmentPromotionName=#{investmentPromotionName},</if>
+            <if test="operatorName!=null">operatorName=#{operatorName},</if>
+            <if test="tenantType!=null">and tenantType=#{tenantType}</if>
+            <if test="merchantId!=0">and merchantId=#{merchantId}</if>
+            <if test="merchantName!=null">and merchantName=#{merchantName}</if>
+            <if test="clientId!=0">and clientId=#{clientId}</if>
+            <if test="clientName!=null">and clientName=#{clientName}</if>
             <if test="tenant!=null">and tenant=#{tenant}</if>
             <if test="industry!=null">and industry=#{industry}</if>
             <if test="corporation!=null">and corporation=#{corporation}</if>
@@ -113,8 +200,15 @@
             <if test="organizationId!=0">and organizationId=#{organizationId}</if>
             <if test="organizationName!=null">and organizationName=#{organizationName}</if>
             <if test="roleId!=0">and roleId=#{roleId}</if>
-            <if test="investmentPromotion!=null">and investmentPromotion=#{investmentPromotion}</if>
-            <if test="operator!=null">and operator=#{operator}</if>
+            <if test="investmentPromotion!=0">and investmentPromotion=#{investmentPromotion}</if>
+            <if test="operator!=0">and operator=#{operator}</if>
+            <if test="investmentPromotionName!=null">investmentPromotionName=#{investmentPromotionName},</if>
+            <if test="operatorName!=null">operatorName=#{operatorName},</if>
+            <if test="tenantType!=null">and tenantType=#{tenantType}</if>
+            <if test="merchantId!=0">and merchantId=#{merchantId}</if>
+            <if test="merchantName!=null">and merchantName=#{merchantName}</if>
+            <if test="clientId!=0">and clientId=#{clientId}</if>
+            <if test="clientName!=null">and clientName=#{clientName}</if>
             <if test="tenant!=null">and tenant=#{tenant}</if>
             <if test="industry!=null">and industry=#{industry}</if>
             <if test="corporation!=null">and corporation=#{corporation}</if>
@@ -144,8 +238,15 @@
             <if test="p.organizationId!=0">and organizationId=#{p.organizationId}</if>
             <if test="p.organizationName!=null">and organizationName=#{p.organizationName}</if>
             <if test="p.roleId!=0">and roleId=#{p.roleId}</if>
-            <if test="p.investmentPromotion!=null">and investmentPromotion=#{p.investmentPromotion}</if>
-            <if test="p.operator!=null">and operator=#{p.operator}</if>
+            <if test="p.investmentPromotion!=0">and investmentPromotion=#{p.investmentPromotion}</if>
+            <if test="p.operator!=0">and operator=#{p.operator}</if>
+            <if test="p.investmentPromotionName!=null">investmentPromotionName=#{p.investmentPromotionName},</if>
+            <if test="p.operatorName!=null">operatorName=#{p.operatorName},</if>
+            <if test="p.tenantType!=null">and tenantType=#{p.tenantType}</if>
+            <if test="p.merchantId!=0">and merchantId=#{p.merchantId}</if>
+            <if test="p.merchantName!=null">and merchantName=#{p.merchantName}</if>
+            <if test="p.clientId!=0">and clientId=#{p.clientId}</if>
+            <if test="p.clientName!=null">and clientName=#{p.clientName}</if>
             <if test="p.tenant!=null">and tenant=#{p.tenant}</if>
             <if test="p.industry!=null">and industry=#{p.industry}</if>
             <if test="p.corporation!=null">and corporation=#{p.corporation}</if>