旭捷内部项目管理系统
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

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.gaotao.modules.contract.mapper.ContractMapper">
  4. <select id="findAll" resultType="com.gaotao.modules.contract.entity.ContractEntity">
  5. SELECT pc.*,
  6. c.customer_name AS customerName,
  7. pi.project_name AS projectName,
  8. (SELECT COUNT(1) FROM sys_oss o
  9. WHERE o.order_ref1 = CONVERT(NVARCHAR(50), pc.id)
  10. AND o.file_type = 'contract') AS attachmentCount
  11. FROM project_contract pc
  12. LEFT JOIN customer c ON pc.customer_id = c.id
  13. LEFT JOIN project_info pi ON pc.project_id = pi.id
  14. <where>
  15. <if test="query.contractNo != null and query.contractNo != ''">
  16. AND pc.contract_no like '' + #{query.contractNo} + ''
  17. </if>
  18. <if test="query.customerId != null">
  19. AND pc.customer_id = #{query.customerId}
  20. </if>
  21. <if test="query.projectId != null">
  22. AND pc.project_id = #{query.projectId}
  23. </if>
  24. <if test="query.partnerType != null and query.partnerType != ''">
  25. AND pc.partner_type = #{query.partnerType}
  26. </if>
  27. <if test="query.startDate != null and query.startDate != ''">
  28. AND pc.contract_date &gt;= #{query.startDate}
  29. </if>
  30. <if test="query.endDate != null and query.endDate != ''">
  31. AND pc.contract_date &lt; DATEADD(day, 1, #{query.endDate})
  32. </if>
  33. <if test="query.validEndDateStart != null and query.validEndDateStart != ''">
  34. AND pc.valid_end_date &gt;= #{query.validEndDateStart}
  35. </if>
  36. <if test="query.validEndDateEnd != null and query.validEndDateEnd != ''">
  37. AND pc.valid_end_date &lt; DATEADD(day, 1, #{query.validEndDateEnd})
  38. </if>
  39. <if test="query.archiveDateStart != null and query.archiveDateStart != ''">
  40. AND pc.archive_date &gt;= #{query.archiveDateStart}
  41. </if>
  42. <if test="query.archiveDateEnd != null and query.archiveDateEnd != ''">
  43. AND pc.archive_date &lt; DATEADD(day, 1, #{query.archiveDateEnd})
  44. </if>
  45. <if test="query.whetherArchive != null and query.whetherArchive != ''">
  46. AND ISNULL(pc.whether_archive, 'N') = #{query.whetherArchive}
  47. </if>
  48. </where>
  49. ORDER BY
  50. <choose>
  51. <when test="query.sidx == 'contractNo' and query.order == 'asc'">pc.contract_no ASC, pc.id DESC</when>
  52. <when test="query.sidx == 'contractNo' and query.order == 'desc'">pc.contract_no DESC, pc.id DESC</when>
  53. <when test="query.sidx == 'contractDate' and query.order == 'asc'">pc.contract_date ASC, pc.id DESC</when>
  54. <when test="query.sidx == 'contractDate' and query.order == 'desc'">pc.contract_date DESC, pc.id DESC</when>
  55. <otherwise>pc.id DESC</otherwise>
  56. </choose>
  57. </select>
  58. </mapper>