| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <?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.management.platform.mapper.ContractMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.management.platform.entity.Contract">
- <id column="id" property="id" />
- <result column="company_id" property="companyId" />
- <result column="creator_id" property="creatorId" />
- <result column="start_date" property="startDate" />
- <result column="end_date" property="endDate" />
- <result column="number" property="number" />
- <result column="project_id" property="projectId" />
- <result column="name" property="name" />
- <result column="amounts" property="amounts" />
- <result column="type_id" property="typeId" />
- <result column="checkerId" property="checkerId" />
- <result column="status" property="status" />
- <result column="indate" property="indate" />
- <result column="remarks" property="remarks" />
- <result column="payment" property="payment" />
- <result column="sec_type_id" property="secTypeId" />
- </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
- </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.id 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>
|