KwcContractLogisticsMapper.xml 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.sckw.contract.dao.KwcContractLogisticsMapper">
  6. <select id="queryList" resultType="com.sckw.contract.model.dto.res.QueryListResDto">
  7. select a.amount,
  8. a.charging,
  9. a.name contractName,
  10. a.contract_no,
  11. c.create_by initiateBy,
  12. c.create_time initiateTime,
  13. a.create_time,
  14. a.start_time,
  15. a.end_time,
  16. a.id,
  17. a.remark,
  18. a.signing_way,
  19. d.create_time signTime,
  20. a.status,
  21. b.unit_type,
  22. b.ent_id,
  23. b.firm_name entName,
  24. e.ent_id targetEntId,
  25. e.firm_name targetEntName,
  26. a.performed_amount performedAmount,
  27. a.contract_pid contractPid,
  28. f.name contractPname
  29. from kwc_contract_logistics a
  30. left join kwc_contract_logistics_unit b on a.id = b.contract_id
  31. and b.unit_type = #{entType}
  32. and case when a.status != 3 then b.ent_id in
  33. <foreach collection="allEnt" separator="," open="(" close=")" item="item">
  34. #{item}
  35. </foreach>
  36. else 1 = 1
  37. end
  38. and b.del_flag = 0
  39. left join kwc_contract_logistics_track c on a.id = c.contract_id and c.del_flag = 0 and c.type = 1
  40. left join kwc_contract_logistics_track d on a.id = d.contract_id and d.del_flag = 0 and d.type = 0
  41. left join kwc_contract_logistics_unit e on a.id = e.contract_id and e.unit_type != #{entType} and e.del_flag = 0
  42. left join kwc_contract_logistics f on f.id = a.contract_pid
  43. where a.del_flag = 0
  44. and case when a.status = 3 then a.ent_id = #{entId} and #{entType} = 3
  45. else (b.ent_id in
  46. <foreach collection="allEnt" separator="," open="(" close=")" item="item">
  47. #{item}
  48. </foreach>
  49. and b.id is not null)
  50. end
  51. <if test="startTime != null">
  52. and a.create_time >= #{startTime}
  53. </if>
  54. <if test="endTime != null">
  55. and a.create_time &lt;= #{endTime}
  56. </if>
  57. <if test="status != null">
  58. and a.status = #{status}
  59. </if>
  60. <if test="charging != null">
  61. and a.charging = #{charging}
  62. </if>
  63. <if test="signingWay != null">
  64. and a.signing_way = #{signingWay}
  65. </if>
  66. <if test="keywords != null and keywords != ''">
  67. and (b.firm_name like concat('%', #{keywords}, '%') or
  68. e.firm_name like concat('%', #{keywords}, '%') or
  69. b.phone like concat('%', #{keywords}, '%') or
  70. b.sign_phone like concat('%', #{keywords}, '%') or
  71. a.contract_no like concat('%', #{keywords}, '%') or
  72. a.name like concat('%', #{keywords}, '%')
  73. <if test="initiateList != null and initiateList.size() > 0">
  74. or a.create_by in
  75. <foreach collection="initiateList" item="item" open="(" close=")" separator=",">
  76. #{item}
  77. </foreach>
  78. </if>
  79. )
  80. </if>
  81. <if test="idList != null and idList.size() > 0">
  82. and a.id in
  83. <foreach collection="idList" open="(" close=")" separator="," item="item">
  84. #{item}
  85. </foreach>
  86. </if>
  87. <if test="targetEntId != null">
  88. and e.ent_id = #{targetEntId}
  89. </if>
  90. order by a.create_time desc
  91. </select>
  92. <select id="queryLogisticsList" resultType="com.sckw.contract.model.dto.res.QueryListResDto">
  93. select a.amount,
  94. a.charging,
  95. a.name contractName,
  96. a.contract_no,
  97. c.create_by initiateBy,
  98. c.create_time initiateTime,
  99. a.create_time,
  100. a.start_time,
  101. a.end_time,
  102. a.id,
  103. a.remark,
  104. a.signing_way,
  105. d.create_time signTime,
  106. a.status,
  107. b.unit_type,
  108. b.ent_id checkedEntId,
  109. b.firm_name checkedEntName,
  110. e.ent_id carrierEntId,
  111. e.firm_name carrierEntName,
  112. a.performed_amount performedAmount,
  113. a.contract_pid contractPid,
  114. f.name contractPname
  115. from kwc_contract_logistics a
  116. left join kwc_contract_logistics_unit b on a.id = b.contract_id and b.del_flag = 0 and b.unit_type = 3
  117. left join kwc_contract_logistics_unit e on a.id = e.contract_id and e.del_flag = 0 and e.unit_type = 4
  118. left join kwc_contract_logistics_track c on a.id = c.contract_id and c.del_flag = 0 and c.type = 1
  119. left join kwc_contract_logistics_track d on a.id = d.contract_id and d.del_flag = 0 and d.type = 0
  120. left join kwc_contract_logistics f on f.id = a.contract_pid
  121. where a.del_flag = 0
  122. and a.status != 3
  123. <if test="authEntIdList != null and authEntIdList.size() != 0">
  124. and a.ent_id in
  125. <foreach collection="authEntIdList" separator="," close=")" open="(" item="item">
  126. #{item}
  127. </foreach>
  128. </if>
  129. <if test="reqVo.startTime != null">
  130. and a.create_time >= #{reqVo.startTime}
  131. </if>
  132. <if test="reqVo.endTime != null">
  133. and a.create_time &lt;= #{reqVo.endTime}
  134. </if>
  135. <if test="reqVo.status != null">
  136. and a.status = #{reqVo.status}
  137. </if>
  138. <if test="reqVo.signingWay != null">
  139. and a.signing_way = #{reqVo.signingWay}
  140. </if>
  141. <if test="reqVo.charging != null">
  142. and a.charging = #{reqVo.charging}
  143. </if>
  144. <if test="reqVo.keywords != null and reqVo.keywords != ''">
  145. and (b.firm_name like concat('%', #{reqVo.keywords}, '%') or
  146. e.firm_name like concat('%', #{reqVo.keywords}, '%') or
  147. b.contacts like concat('%', #{reqVo.keywords}, '%') or
  148. e.contacts like concat('%', #{reqVo.keywords}, '%') or
  149. a.contract_no like concat('%', #{reqVo.keywords}, '%') or
  150. a.name like concat('%', #{reqVo.keywords}, '%'))
  151. </if>
  152. <if test="reqVo.idList != null and reqVo.idList.size() > 0">
  153. and a.id in
  154. <foreach collection="reqVo.idList" open="(" close=")" separator="," item="item">
  155. #{item}
  156. </foreach>
  157. </if>
  158. order by a.create_time desc
  159. </select>
  160. <select id="checkContractIsSole" resultType="java.lang.String">
  161. SELECT
  162. DISTINCT CONCAT(a.contract_no,b.ent_id,c.ent_id) as isSole
  163. FROM
  164. kwc_contract_logistics a
  165. LEFT JOIN kwc_contract_logistics_unit b ON a.id = b.contract_id
  166. LEFT JOIN kwc_contract_logistics_unit c ON a.id = c.contract_id
  167. WHERE
  168. a.del_flag = 0
  169. AND b.unit_type = 4
  170. AND c.unit_type = 3
  171. </select>
  172. <select id="selectIsSole" resultType="com.sckw.contract.model.entity.KwcContractLogistics">
  173. SELECT
  174. a.*
  175. FROM
  176. kwc_contract_logistics a
  177. LEFT JOIN kwc_contract_logistics_unit b ON a.id = b.contract_id
  178. LEFT JOIN kwc_contract_logistics_unit c ON a.id = c.contract_id
  179. WHERE
  180. a.del_flag = 0
  181. AND b.unit_type = 4
  182. AND c.unit_type = 3
  183. and b.ent_id =#{acceptId}
  184. and c.ent_id =#{consignId}
  185. and a.contract_no=#{contractNo}
  186. </select>
  187. <select id="count" resultType="java.lang.Long">
  188. SELECT count(1)
  189. FROM kwc_contract_logistics a
  190. LEFT JOIN kwc_contract_logistics_unit b ON a.id = b.contract_id and b.del_flag = 0 and b.unit_type = 3
  191. <where>
  192. a.del_flag = 0
  193. and a.status = 1
  194. and a.ent_id != #{entId}
  195. <if test="ids != null and ids.size() != 0">
  196. and a.ent_id in
  197. <foreach collection="ids" open="(" close=")" separator="," item="item">
  198. #{item}
  199. </foreach>
  200. </if>
  201. </where>
  202. </select>
  203. <select id="logisticsList" resultType="com.sckw.contract.api.model.vo.ContractVo">
  204. SELECT d.firm_name, a.name, a.status, a.create_time, a.amount
  205. FROM kwc_contract_logistics a
  206. LEFT JOIN kwc_contract_logistics_unit b ON a.id = b.contract_id and b.del_flag = 0 and b.unit_type = 3
  207. LEFT JOIN kwc_contract_logistics_unit d ON a.id = d.contract_id and d.del_flag = 0 and d.unit_type = 4
  208. <where>
  209. a.del_flag = 0
  210. and a.status = 1
  211. and a.ent_id != #{entId}
  212. <if test="ids != null and ids.size() != 0">
  213. and a.ent_id in
  214. <foreach collection="ids" open="(" close=")" separator="," item="item">
  215. #{item}
  216. </foreach>
  217. </if>
  218. order by a.create_time desc
  219. <if test="all != null and all">
  220. limit 10
  221. </if>
  222. </where>
  223. </select>
  224. <select id="selectSignCount" resultType="java.lang.Long">
  225. SELECT count(distinct a.id)
  226. FROM kwc_contract_logistics a
  227. LEFT JOIN kwc_contract_logistics_unit b ON a.id = b.contract_id and b.del_flag = 0 and b.unit_type = 3
  228. LEFT JOIN kwc_contract_logistics_unit d ON a.id = d.contract_id and d.del_flag = 0 and d.unit_type = 4
  229. <where>
  230. a.del_flag = 0
  231. and a.status = 1
  232. and (d.ent_id = #{entId} or b.ent_id = #{entId})
  233. </where>
  234. </select>
  235. </mapper>