ContractMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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.management.platform.mapper.ContractMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.management.platform.entity.Contract">
  6. <id column="id" property="id" />
  7. <result column="company_id" property="companyId" />
  8. <result column="creator_id" property="creatorId" />
  9. <result column="start_date" property="startDate" />
  10. <result column="end_date" property="endDate" />
  11. <result column="number" property="number" />
  12. <result column="project_id" property="projectId" />
  13. <result column="name" property="name" />
  14. <result column="amounts" property="amounts" />
  15. <result column="type_id" property="typeId" />
  16. <result column="checkerId" property="checkerId" />
  17. <result column="status" property="status" />
  18. <result column="indate" property="indate" />
  19. <result column="remarks" property="remarks" />
  20. <result column="payment" property="payment" />
  21. <result column="sec_type_id" property="secTypeId" />
  22. </resultMap>
  23. <!-- 通用查询结果列 -->
  24. <sql id="Base_Column_List">
  25. id, company_id, creator_id, start_date, end_date, number, project_id, name, amounts, type_id, checkerId, status, indate, remarks, payment, sec_type_id
  26. </sql>
  27. <select id="selectContract" resultType="com.management.platform.entity.Contract">
  28. 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,
  29. contract.start_date as startDate,contract.end_date as endDate,contract_type_sec.sec_type_name,contract.sec_type_id,
  30. 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,
  31. contract.plate1,contract.plate2,contract.plate3,contract.plate4,contract.plate5
  32. from contract
  33. left join sys_dict on contract.type_id = sys_dict.id
  34. left join contract_type_sec on contract.sec_type_id = contract_type_sec.id
  35. 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
  36. left join user
  37. on contract.creator_id = user.id
  38. left join contract_custom cc on cc.contract_id=contract.id
  39. where contract.company_id = #{companyId}
  40. <if test="number!=null">
  41. and number like CONCAT('%', #{number}, '%')
  42. </if>
  43. <if test="name!=null">
  44. and contract.name like CONCAT('%', #{name}, '%')
  45. </if>
  46. <if test="typeName!=null">
  47. and sys_dict.name = #{typeName}
  48. </if>
  49. <if test="secTypeId!=null">
  50. and contract.sec_type_id = #{secTypeId}
  51. </if>
  52. <if test="status!=null">
  53. and status = #{status}
  54. </if>
  55. <if test="startDate!=null and endDate !=null">
  56. and indate between #{startDate} and #{endDate}
  57. </if>
  58. <if test="paymentStartDate != null and paymentEndDate != null">
  59. and cp.pay_date between #{paymentStartDate} and #{paymentEndDate}
  60. </if>
  61. <if test="finishStatus!=null">
  62. and cc.finish_status = #{finishStatus}
  63. </if>
  64. <if test="customerOrg!=null">
  65. and cc.customer_org like CONCAT('%', #{customerOrg}, '%')
  66. </if>
  67. order by contract.id desc
  68. <if test="pageStart!=null and pageSize!=null">
  69. limit #{pageStart},#{pageSize}
  70. </if>
  71. </select>
  72. <select id="selectContractCnt" resultType="java.lang.Long">
  73. select count(1) from contract
  74. left join contract_type
  75. on contract.type_id = contract_type.id
  76. 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
  77. left join user
  78. on contract.creator_id = user.id
  79. left join contract_custom cc on cc.contract_id=contract.id
  80. where contract.company_id = #{companyId}
  81. <if test="number!=null">
  82. and number like CONCAT('%', #{number}, '%')
  83. </if>
  84. <if test="name!=null">
  85. and contract.name like CONCAT('%', #{name}, '%')
  86. </if>
  87. <if test="typeName!=null">
  88. and contract_type.id = #{typeName}
  89. </if>
  90. <if test="secTypeId!=null">
  91. and contract.sec_type_id = #{secTypeId}
  92. </if>
  93. <if test="status!=null">
  94. and status = #{status}
  95. </if>
  96. <if test="startDate!=null and endDate !=null">
  97. and indate between #{startDate} and #{endDate}
  98. </if>
  99. <if test="paymentStartDate != null and paymentEndDate != null">
  100. and cp.pay_date between #{paymentStartDate} and #{paymentEndDate}
  101. </if>
  102. <if test="finishStatus!=null">
  103. and cc.finish_status = #{finishStatus}
  104. </if>
  105. <if test="customerOrg!=null">
  106. and cc.customer_org like CONCAT('%', #{customerOrg}, '%')
  107. </if>
  108. </select>
  109. </mapper>