|
@@ -20,16 +20,93 @@
|
|
|
<result column="remarks" property="remarks" />
|
|
|
<result column="payment" property="payment" />
|
|
|
<result column="sec_type_id" property="secTypeId" />
|
|
|
- <result column="plate1" property="plate1" />
|
|
|
- <result column="plate2" property="plate2" />
|
|
|
- <result column="plate3" property="plate3" />
|
|
|
- <result column="plate4" property="plate4" />
|
|
|
- <result column="plate5" property="plate5" />
|
|
|
</resultMap>
|
|
|
|
|
|
<!-- 通用查询结果列 -->
|
|
|
<sql id="Base_Column_List">
|
|
|
- id, company_id, creator_id, start_date, end_date, number, project_id, name, amounts, type_id, checkerId, status, indate, remarks, payment, sec_type_id, plate1, plate2, plate3, plate4, plate5
|
|
|
+ id, company_id, creator_id, start_date, end_date, number, project_id, name, amounts, type_id, checkerId, status, indate, remarks, payment, sec_type_id
|
|
|
</sql>
|
|
|
+ <select id="selectContract" resultType="com.management.platform.entity.Contract">
|
|
|
+ select contract.id,contract.company_id,contract.creator_id,contract.number,contract.name,contract.amounts,contract.type_id,sys_dict.name typeName,contract.status,contract.indate,contract.remarks,
|
|
|
+ contract.start_date as startDate,contract.end_date as endDate,contract_type_sec.sec_type_name,contract.sec_type_id,
|
|
|
+ user.name as creatorName,user.corpwx_userid as creatorWxCorpId, contract.project_id, contract.payment, cp.pay_date AS next_payment_date, cp.amount AS next_payment_amount,
|
|
|
+ contract.plate1,contract.plate2,contract.plate3,contract.plate4,contract.plate5
|
|
|
+ from contract
|
|
|
+ left join sys_dict on contract.type_id = sys_dict.id
|
|
|
+ left join contract_type_sec on contract.sec_type_id = contract_type_sec.id
|
|
|
+ LEFT JOIN (SELECT contract_id, pay_date, amount FROM contract_payment WHERE is_payed = 0 GROUP BY contract_id) cp ON cp.contract_id=contract.id
|
|
|
+ left join user
|
|
|
+ on contract.creator_id = user.id
|
|
|
+ left join contract_custom cc on cc.contract_id=contract.id
|
|
|
+ where contract.company_id = #{companyId}
|
|
|
+ <if test="number!=null">
|
|
|
+ and number like CONCAT('%', #{number}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="name!=null">
|
|
|
+ and contract.name like CONCAT('%', #{name}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="typeName!=null">
|
|
|
+ and sys_dict.name = #{typeName}
|
|
|
+ </if>
|
|
|
+ <if test="secTypeId!=null">
|
|
|
+ and contract.sec_type_id = #{secTypeId}
|
|
|
+ </if>
|
|
|
+ <if test="status!=null">
|
|
|
+ and status = #{status}
|
|
|
+ </if>
|
|
|
+ <if test="startDate!=null and endDate !=null">
|
|
|
+ and indate between #{startDate} and #{endDate}
|
|
|
+ </if>
|
|
|
+ <if test="paymentStartDate != null and paymentEndDate != null">
|
|
|
+ and cp.pay_date between #{paymentStartDate} and #{paymentEndDate}
|
|
|
+ </if>
|
|
|
+ <if test="finishStatus!=null">
|
|
|
+ and cc.finish_status = #{finishStatus}
|
|
|
+ </if>
|
|
|
+ <if test="customerOrg!=null">
|
|
|
+ and cc.customer_org like CONCAT('%', #{customerOrg}, '%')
|
|
|
+ </if>
|
|
|
+ order by contract.number desc
|
|
|
+ <if test="pageStart!=null and pageSize!=null">
|
|
|
+ limit #{pageStart},#{pageSize}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
|
|
|
+ <select id="selectContractCnt" resultType="java.lang.Long">
|
|
|
+ select count(1) from contract
|
|
|
+ left join contract_type
|
|
|
+ on contract.type_id = contract_type.id
|
|
|
+ LEFT JOIN (SELECT contract_id, pay_date, amount FROM contract_payment WHERE is_payed = 0 GROUP BY contract_id) cp ON cp.contract_id=contract.id
|
|
|
+ left join user
|
|
|
+ on contract.creator_id = user.id
|
|
|
+ left join contract_custom cc on cc.contract_id=contract.id
|
|
|
+ where contract.company_id = #{companyId}
|
|
|
+ <if test="number!=null">
|
|
|
+ and number like CONCAT('%', #{number}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="name!=null">
|
|
|
+ and contract.name like CONCAT('%', #{name}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="typeName!=null">
|
|
|
+ and contract_type.id = #{typeName}
|
|
|
+ </if>
|
|
|
+ <if test="secTypeId!=null">
|
|
|
+ and contract.sec_type_id = #{secTypeId}
|
|
|
+ </if>
|
|
|
+ <if test="status!=null">
|
|
|
+ and status = #{status}
|
|
|
+ </if>
|
|
|
+ <if test="startDate!=null and endDate !=null">
|
|
|
+ and indate between #{startDate} and #{endDate}
|
|
|
+ </if>
|
|
|
+ <if test="paymentStartDate != null and paymentEndDate != null">
|
|
|
+ and cp.pay_date between #{paymentStartDate} and #{paymentEndDate}
|
|
|
+ </if>
|
|
|
+ <if test="finishStatus!=null">
|
|
|
+ and cc.finish_status = #{finishStatus}
|
|
|
+ </if>
|
|
|
+ <if test="customerOrg!=null">
|
|
|
+ and cc.customer_org like CONCAT('%', #{customerOrg}, '%')
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
</mapper>
|