You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
3.1 KiB
60 lines
3.1 KiB
<?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.gaotao.modules.contract.mapper.ContractMapper">
|
|
|
|
<select id="findAll" resultType="com.gaotao.modules.contract.entity.ContractEntity">
|
|
SELECT pc.*,
|
|
c.customer_name AS customerName,
|
|
pi.project_name AS projectName,
|
|
(SELECT COUNT(1) FROM sys_oss o
|
|
WHERE o.order_ref1 = CONVERT(NVARCHAR(50), pc.id)
|
|
AND o.file_type = 'contract') AS attachmentCount
|
|
FROM project_contract pc
|
|
LEFT JOIN customer c ON pc.customer_id = c.id
|
|
LEFT JOIN project_info pi ON pc.project_id = pi.id
|
|
<where>
|
|
<if test="query.contractNo != null and query.contractNo != ''">
|
|
AND pc.contract_no like '' + #{query.contractNo} + ''
|
|
</if>
|
|
<if test="query.customerId != null">
|
|
AND pc.customer_id = #{query.customerId}
|
|
</if>
|
|
<if test="query.projectId != null">
|
|
AND pc.project_id = #{query.projectId}
|
|
</if>
|
|
<if test="query.partnerType != null and query.partnerType != ''">
|
|
AND pc.partner_type = #{query.partnerType}
|
|
</if>
|
|
<if test="query.startDate != null and query.startDate != ''">
|
|
AND pc.contract_date >= #{query.startDate}
|
|
</if>
|
|
<if test="query.endDate != null and query.endDate != ''">
|
|
AND pc.contract_date < DATEADD(day, 1, #{query.endDate})
|
|
</if>
|
|
<if test="query.validEndDateStart != null and query.validEndDateStart != ''">
|
|
AND pc.valid_end_date >= #{query.validEndDateStart}
|
|
</if>
|
|
<if test="query.validEndDateEnd != null and query.validEndDateEnd != ''">
|
|
AND pc.valid_end_date < DATEADD(day, 1, #{query.validEndDateEnd})
|
|
</if>
|
|
<if test="query.archiveDateStart != null and query.archiveDateStart != ''">
|
|
AND pc.archive_date >= #{query.archiveDateStart}
|
|
</if>
|
|
<if test="query.archiveDateEnd != null and query.archiveDateEnd != ''">
|
|
AND pc.archive_date < DATEADD(day, 1, #{query.archiveDateEnd})
|
|
</if>
|
|
<if test="query.whetherArchive != null and query.whetherArchive != ''">
|
|
AND ISNULL(pc.whether_archive, 'N') = #{query.whetherArchive}
|
|
</if>
|
|
</where>
|
|
ORDER BY
|
|
<choose>
|
|
<when test="query.sidx == 'contractNo' and query.order == 'asc'">pc.contract_no ASC, pc.id DESC</when>
|
|
<when test="query.sidx == 'contractNo' and query.order == 'desc'">pc.contract_no DESC, pc.id DESC</when>
|
|
<when test="query.sidx == 'contractDate' and query.order == 'asc'">pc.contract_date ASC, pc.id DESC</when>
|
|
<when test="query.sidx == 'contractDate' and query.order == 'desc'">pc.contract_date DESC, pc.id DESC</when>
|
|
<otherwise>pc.id DESC</otherwise>
|
|
</choose>
|
|
</select>
|
|
|
|
</mapper>
|