KwtWaybillOrderV1Mapper.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  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.sckw.transport.dao.KwtWaybillOrderV1Mapper">
  4. <select id="statistics" resultType="com.sckw.core.model.vo.TableTop"
  5. parameterType="com.sckw.transport.model.dto.WaybillOrderQueryDto">
  6. SELECT
  7. wo.status 'value',
  8. count(1) total
  9. from kwt_waybill_order wo
  10. where wo.del_flag = 0
  11. <if test="entId != null and entId != ''">
  12. and wo.ent_id = #{entId, jdbcType=VARCHAR}
  13. </if>
  14. <if test="userIds != null and userIds.size() > 0">
  15. and wo.create_by IN
  16. <foreach collection="userIds" open="(" close=")" item="item" separator=",">
  17. #{item}
  18. </foreach>
  19. </if>
  20. <if test="(loadCityCode != null and loadCityCode != '') or (unloadCityCode != null and unloadCityCode != '')">
  21. and wo.id in (
  22. SELECT DISTINCT w_order_id from kwt_waybill_order_address where del_flag = 0
  23. <if test="loadCityCode != null and loadCityCode != ''">
  24. and address_type = 1
  25. and left(city_code, #{loadCityCodeLevel, jdbcType=INTEGER}) = left( #{loadCityCode, jdbcType=INTEGER}, #{loadCityCodeLevel, jdbcType=INTEGER} )
  26. </if>
  27. <if test="unloadCityCode != null and unloadCityCode != ''">
  28. and address_type = 2
  29. and left(city_code, #{loadCityCodeLevel, jdbcType=INTEGER}) = left( #{unloadCityCode, jdbcType=INTEGER}, #{loadCityCodeLevel, jdbcType=INTEGER} )
  30. </if>
  31. )
  32. </if>
  33. <if test="(startLoadTime != null and startLoadTime != '') or (endLoadTime != null and endLoadTime != '')
  34. or (startUnloadTime != null and startUnloadTime != '') or (endUnloadTime != null and endUnloadTime != '')">
  35. and wo.id in (
  36. SELECT DISTINCT w_order_id from kwt_waybill_order_subtask where del_flag = 0
  37. <if test="startLoadTime != null and startLoadTime != ''">
  38. and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
  39. </if>
  40. <if test="endLoadTime != null and endLoadTime != ''">
  41. and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
  42. </if>
  43. <if test="startUnloadTime != null and startUnloadTime != ''">
  44. and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
  45. </if>
  46. <if test="endUnloadTime != null and endUnloadTime != ''">
  47. and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
  48. </if>
  49. )
  50. </if>
  51. <if test="startSendCarTime != null and startSendCarTime != '' " >
  52. and DATE( wo.create_time) <![CDATA[ >= ]]> #{startSendCarTime,jdbcType=TIMESTAMP}
  53. </if>
  54. <if test="startSendCarTime != null and startSendCarTime != '' " >
  55. and DATE( wo.create_time ) <![CDATA[ <= ]]> #{endSendCarTime,jdbcType=TIMESTAMP}
  56. </if>
  57. <if test="keywords != null and keywords != ''">
  58. and (
  59. wo.w_order_no like concat('%',#{keywords},'%')
  60. or wo.truck_no like concat('%',#{keywords},'%')
  61. or wo.driver_name like concat('%',#{keywords},'%')
  62. )
  63. </if>
  64. GROUP BY wo.status
  65. </select>
  66. <select id="findListPage" resultType="com.sckw.transport.model.vo.WaybillOrderSelectVo"
  67. parameterType="com.sckw.transport.model.dto.WaybillOrderQueryDto">
  68. SELECT
  69. wo.id wOrderId, wo.ent_id entId, wo.w_order_no wOrderNo, wo.type, wo.truck_no truckNo, wo.driver_name driverName,
  70. wo.driver_phone driverPhone, wo.type, wo.create_time sendCarTime, wo.create_by createBy, wo.create_time createTime,
  71. wo.update_time updateTime, wo.status
  72. from kwt_waybill_order wo
  73. where wo.del_flag = 0
  74. <if test="lOrderId != null and lOrderId != ''">
  75. and exists(select 1 from kwt_waybill_order_subtask wos where wo.id = wos.w_order_id and wos.l_order_id = #{lOrderId})
  76. </if>
  77. <if test="lOrderId == null or lOrderId == ''">
  78. <if test="entId != null and entId != ''">
  79. and wo.ent_id = #{entId, jdbcType=VARCHAR}
  80. </if>
  81. <if test="userIds != null and userIds.size() > 0">
  82. and wo.create_by IN
  83. <foreach collection="userIds" open="(" close=")" item="item" separator=",">
  84. #{item}
  85. </foreach>
  86. </if>
  87. <if test="entIds != null and entIds.size() > 0">
  88. and wo.ent_id IN
  89. <foreach collection="entIds" open="(" close=")" item="item" separator=",">
  90. #{item}
  91. </foreach>
  92. </if>
  93. </if>
  94. <if test="queryWstatus != null and queryWstatus != ''">
  95. AND wo.status in
  96. <foreach collection="queryWstatus.split(',')" item="item" open="(" close=")" separator=",">
  97. #{item}
  98. </foreach>
  99. </if>
  100. <if test="(loadCityCode != null and loadCityCode != '') or (unloadCityCode != null and unloadCityCode != '')">
  101. and wo.id in (
  102. SELECT DISTINCT w_order_id from kwt_waybill_order_address where del_flag = 0
  103. <if test="loadCityCode != null and loadCityCode != ''">
  104. and address_type = 1
  105. and left(city_code, #{loadCityCodeLevel, jdbcType=INTEGER}) = left( #{loadCityCode, jdbcType=INTEGER}, #{loadCityCodeLevel, jdbcType=INTEGER} )
  106. </if>
  107. <if test="unloadCityCode != null and unloadCityCode != ''">
  108. and address_type = 2
  109. and left(city_code, #{unloadCityCodeLevel, jdbcType=INTEGER}) = left( #{unloadCityCode, jdbcType=INTEGER}, #{unloadCityCodeLevel, jdbcType=INTEGER} )
  110. </if>
  111. )
  112. </if>
  113. <if test="(startLoadTime != null and startLoadTime != '') or (endLoadTime != null and endLoadTime != '')
  114. or (startUnloadTime != null and startUnloadTime != '') or (endUnloadTime != null and endUnloadTime != '')">
  115. and wo.id in (
  116. SELECT DISTINCT w_order_id from kwt_waybill_order_subtask where del_flag = 0
  117. <if test="startLoadTime != null and startLoadTime != ''">
  118. and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
  119. </if>
  120. <if test="endLoadTime != null and endLoadTime != ''">
  121. and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
  122. </if>
  123. <if test="startUnloadTime != null and startUnloadTime != ''">
  124. and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
  125. </if>
  126. <if test="endUnloadTime != null and endUnloadTime != ''">
  127. and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
  128. </if>
  129. )
  130. </if>
  131. <if test="startSendCarTime != null and startSendCarTime != '' " >
  132. and DATE( wo.create_time) <![CDATA[ >= ]]> #{startSendCarTime,jdbcType=TIMESTAMP}
  133. </if>
  134. <if test="endSendCarTime != null and endSendCarTime != '' " >
  135. and DATE( wo.create_time ) <![CDATA[ <= ]]> #{endSendCarTime,jdbcType=TIMESTAMP}
  136. </if>
  137. <if test="keywords != null and keywords != ''">
  138. and (
  139. wo.w_order_no like concat('%',#{keywords},'%')
  140. or wo.truck_no like concat('%',#{keywords},'%')
  141. or wo.driver_name like concat('%',#{keywords},'%')
  142. )
  143. </if>
  144. order by wo.update_time desc
  145. </select>
  146. <select id="findCapacityListPage" resultType="com.sckw.transport.model.vo.WaybillOrderSelectVo"
  147. parameterType="com.sckw.transport.model.dto.WaybillSubtaskOrderQueryDto">
  148. SELECT
  149. wo.driver_id driverId, wo.driver_name driverName, wo.driver_phone driverPhone, wo.driver_idcard driverIdcard,
  150. wo.truck_id truckId, wo.truck_no truckNo, count(1) count
  151. from kwt_waybill_order wo
  152. left join kwt_waybill_order_subtask wos on wos.w_order_id = wo.id
  153. WHERE wo.del_flag = 0 and wos.del_flag = 0
  154. <if test="ids != null and ids != ''">
  155. AND wos.l_order_id IN
  156. <foreach collection="ids.split(',')" item="item" open="(" close=")" separator=",">
  157. #{item}
  158. </foreach>
  159. </if>
  160. </select>
  161. <select id="findStatisticsCountByDriver" resultType="java.util.Map">
  162. SELECT
  163. count(case when wo.status = 101 then 1 end) waitTotal,
  164. count(case when wo.status = 201 then 1 end) departureTotal,
  165. count(case when wo.status in (203, 301, 302, 401, 402) then 1 end) executeTotal,
  166. count(case when wo.status in (501, 502, 503, 504, 103, 202) then 1 end) endTotal
  167. from kwt_waybill_order wo
  168. where wo.del_flag = 0
  169. and wo.driver_id = #{driverId, jdbcType=BIGINT}
  170. <if test="specialEntIds != null and specialEntIds.size() > 0">
  171. and wo.ent_id in
  172. <foreach collection="specialEntIds" item="item" open="(" close=")" separator=",">
  173. #{item,jdbcType=BIGINT}
  174. </foreach>
  175. </if>
  176. </select>
  177. <select id="findWaybillOrderSubtask" resultType="com.sckw.transport.model.vo.WaybillOrderSubtaskVo" parameterType="java.util.Map">
  178. SELECT
  179. wo.id, wo.id wOrderId, wo.ent_id entId, wo.w_order_no wOrderNo, wo.truck_no truckNo, wo.driver_name driverName, wo.driver_phone driverPhone,
  180. wo.driver_idcard driverIdcard, wo.type, wo.create_time sendCarTime, wo.create_time createTime, wo.update_time updateTime, wo.status, wos.unit,
  181. wos.load_amount loadAmount, wos.unload_amount unloadAmount, wos.load_time loadTime, wos.unload_time unloadTime, wos.entrust_amount entrustAmount,
  182. wos.deficit_amount deficitAmount, wos.deficit_price deficitPrice, wos.id wSubtaskId
  183. from kwt_waybill_order wo
  184. left join kwt_waybill_order_subtask wos on wos.w_order_id = wo.id
  185. where wo.del_flag = 0 and wos.del_flag = 0
  186. <if test="entId != null and entId != ''">
  187. and wo.ent_id = #{entId, jdbcType=BIGINT}
  188. </if>
  189. <if test="lOrderId != null and lOrderId != ''">
  190. and wos.l_order_id = #{lOrderId, jdbcType=BIGINT}
  191. </if>
  192. <if test="specialEntIds != null and specialEntIds.size() > 0">
  193. and wo.ent_id in
  194. <foreach collection="specialEntIds" item="item" open="(" close=")" separator=",">
  195. #{item,jdbcType=BIGINT}
  196. </foreach>
  197. </if>
  198. <if test="driverId != null and driverId != ''">
  199. and wo.driver_id = #{driverId, jdbcType=BIGINT}
  200. </if>
  201. <if test="busAppStatus != null and busAppStatus != ''">
  202. and wos.status = #{busAppStatus}
  203. </if>
  204. <if test="busStatus != null and busStatus == 1">
  205. and wo.status = 101
  206. </if>
  207. <if test="busStatus != null and busStatus == 2">
  208. and wo.status = 201
  209. </if>
  210. <if test="busStatus != null and busStatus == 3">
  211. and wo.status in (203, 301, 302, 401, 402)
  212. </if>
  213. <if test="busStatus != null and busStatus == 4">
  214. and wo.status in (103, 202, 501, 502, 503, 504)
  215. </if>
  216. <if test="month != null and month != ''">
  217. and LEFT(wo.create_time, 7) = #{month, jdbcType=TIMESTAMP}
  218. </if>
  219. <if test="startTime != null and startTime != ''">
  220. and LEFT(wo.create_time, 10) <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
  221. </if>
  222. <if test="endTime != null and endTime != ''">
  223. and LEFT(wo.create_time, 10) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
  224. </if>
  225. <if test="busStatus != null and busStatus == 2">
  226. ORDER BY wos.load_time
  227. </if>
  228. <if test="busStatus != null and busStatus == 4">
  229. ORDER BY CASE WHEN wo.status = 503 THEN wo.status * -1 ELSE wo.status END ASC, wo.update_time desc
  230. </if>
  231. </select>
  232. <select id="findCountByDriverOrTruck" resultType="com.sckw.transport.model.vo.WaybillCountVo">
  233. SELECT
  234. count(case when wo.status = 502 then 1 end) totalComplete,
  235. count(case when wo.status not in (101, 102, 103, 202) then 1 end) totalTake,
  236. count(case when wo.status in (203, 301, 302, 401, 402) then 1 end) totalExecute
  237. from kwt_waybill_order wo
  238. left join kwt_waybill_order_subtask wos on wos.w_order_id = wo.id
  239. where wo.del_flag = 0 and wos.del_flag = 0
  240. <if test="driverId != null and driverId != ''">
  241. and wo.driver_id = #{driverId, jdbcType=BIGINT}
  242. </if>
  243. <if test="truckId != null and truckId != ''">
  244. and wo.truck_id = #{truckId, jdbcType=BIGINT}
  245. </if>
  246. </select>
  247. <select id="findCountByLOrderId" resultType="com.sckw.transport.model.vo.WaybillCountVo">
  248. SELECT
  249. count(case when wo.status = 502 then 1 end) totalComplete
  250. from kwt_waybill_order wo
  251. left join kwt_waybill_order_subtask wos on wos.w_order_id = wo.id
  252. where wo.del_flag = 0 and wos.del_flag = 0
  253. <if test="lOrderId != null and lOrderId != ''">
  254. and wos.l_order_id = #{lOrderId, jdbcType=BIGINT}
  255. </if>
  256. </select>
  257. <select id="findAmountByDriverOrTruck" resultType="com.sckw.transport.model.vo.WaybillCountVo">
  258. SELECT
  259. IFNULL(SUM(wos.load_amount), 0.0) loadAmount
  260. from kwt_waybill_order_subtask wos
  261. left join kwt_waybill_order wo on wos.w_order_id = wo.id
  262. where wo.del_flag = 0 and wos.del_flag = 0
  263. <if test="driverId != null and driverId != ''">
  264. and wo.driver_id = #{driverId, jdbcType=BIGINT}
  265. </if>
  266. <if test="truckId != null and truckId != ''">
  267. and wo.truck_id = #{truckId, jdbcType=BIGINT}
  268. </if>
  269. </select>
  270. <select id="findUnfinishedByTruck" resultType="com.sckw.transport.model.vo.WaybillCountVo">
  271. SELECT count(1) totalExecute from kwt_waybill_order wo
  272. where wo.del_flag = 0
  273. and wo.status in (101, 201, 203, 301, 302, 401, 402)
  274. <if test="type != null and type != ''">
  275. and wo.type = #{type, jdbcType=INTEGER}
  276. </if>
  277. <if test="truckId != null and truckId != ''">
  278. and wo.truck_id = #{truckId, jdbcType=BIGINT}
  279. </if>
  280. </select>
  281. <select id="findTicketCountByAddress" resultType="com.sckw.transport.model.vo.WaybillCountVo">
  282. SELECT
  283. IFNULL(sum(wot.amount), 0.0) amount,
  284. MIN(wot.operate_time) loadTime,
  285. MAX(wot.operate_time) unloadTime
  286. from kwt_waybill_order_ticket wot
  287. left join kwt_waybill_order_address woa on woa.id = wot.w_address_id
  288. left join kwt_logistics_order_address loa on loa.id = woa.l_address_id
  289. left join kwt_logistics_order lo on lo.id = loa.l_order_id
  290. left join kwt_waybill_order wo on wo.id = wot.w_order_id
  291. where wot.del_flag = 0
  292. <if test="passStatus != null and passStatus != ''">
  293. and wo.status = 502
  294. </if>
  295. <if test="wOrderId != null and wOrderId != ''">
  296. and wot.w_order_id = #{wOrderId, jdbcType=BIGINT}
  297. </if>
  298. <if test="type != null and type != ''">
  299. and wot.type = #{type, jdbcType=VARCHAR}
  300. </if>
  301. <if test="unit != null and unit != ''">
  302. and wot.unit = #{unit, jdbcType=VARCHAR}
  303. </if>
  304. <if test="lAddressId != null and lAddressId != ''">
  305. and loa.id = #{lAddressId, jdbcType=BIGINT}
  306. </if>
  307. <if test="lOrderId != null and lOrderId != ''">
  308. and lo.id = #{lOrderId, jdbcType=BIGINT}
  309. </if>
  310. <if test="upperlOrderId != null and upperlOrderId != ''">
  311. and FIND_IN_SET(#{upperlOrderId, jdbcType=BIGINT}, lo.pids)
  312. </if>
  313. </select>
  314. <select id="selectWaybillOrderCarPage" parameterType="java.util.Map" resultType="com.sckw.transport.model.dto.OrderCarDTO">
  315. SELECT
  316. kwo.id as wOrderId,
  317. kwo.w_order_no as wOrderNo,
  318. kwo.driver_id as driverId,
  319. kwo.driver_name as driverName,
  320. kwo.driver_phone as driverPhone,
  321. kwo.driver_idcard as driverCard,
  322. kwo.truck_no as truckNo,
  323. kwo.status as status,
  324. kwos.l_order_id as lOrderId,
  325. klo.l_order_no as lOrderNo,
  326. klo.t_order_id as tOrderId,
  327. klo.t_order_no as tOrderNo
  328. FROM kwt_waybill_order kwo
  329. left join kwt_waybill_order_subtask kwos on kwos.w_order_id = kwo.id
  330. LEFT JOIN kwt_logistics_order klo ON kwos.l_order_id = klo.id
  331. WHERE kwo.del_flag = 0 and kwos.del_flag = 0 and klo.del_flag = 0
  332. <if test="tOrderIds != null and tOrderIds.size() > 0">
  333. and klo.t_order_id in
  334. <foreach collection="tOrderIds" item="item" close=")" open="(" separator=",">
  335. #{item,jdbcType=BIGINT}
  336. </foreach>
  337. </if>
  338. </select>
  339. <select id="findWaybillOrder" resultType="com.sckw.transport.model.KwtWaybillOrderV1" parameterType="java.util.Map">
  340. SELECT
  341. kwo.id, kwo.id wOrderId, kwo.w_order_no worderNo, kwo.type, kwo.ent_id carrierEntId, kwo.truck_id truckId, kwo.truck_no truckNo, kwo.status,
  342. kwo.create_time createTime, kwo.driver_id driverId, kwo.driver_name driverName, kwo.driver_phone driverPhone, kwo.ent_id entId
  343. FROM kwt_waybill_order kwo
  344. where kwo.del_flag = 0
  345. <if test="driverId != null and driverId != ''">
  346. and kwo.driver_id = #{driverId, jdbcType=BIGINT}
  347. </if>
  348. <if test="truckNo != null and truckNo != ''">
  349. and kwo.truck_no = #{truckNo, jdbcType=VARCHAR}
  350. </if>
  351. <if test="status != null and status != ''">
  352. and kwo.status = #{status, jdbcType=INTEGER}
  353. </if>
  354. <if test="busStatus != null and busStatus == 2">
  355. and kwo.status = 201
  356. </if>
  357. <if test="busStatus != null and busStatus == 3">
  358. and kwo.status in (203, 301, 302, 401, 402)
  359. </if>
  360. <if test="busStatus != null and busStatus == 4">
  361. and kwo.status in (102, 103, 202, 501, 502, 503, 504)
  362. </if>
  363. <if test="lOrderId != null and lOrderId != ''">
  364. and kwo.id in (SELECT w_order_id from kwt_waybill_order_subtask where del_flag = 0 and l_order_id = #{lOrderId, jdbcType=BIGINT} ))
  365. </if>
  366. <choose>
  367. <when test="lOrderIds != null and lOrderIds != '' and lOrderIds.size() > 0">
  368. and kwo.id in (
  369. SELECT w_order_id from kwt_waybill_order_subtask where del_flag = 0 and l_order_id in
  370. <foreach collection="lOrderIds" item="lOrderId" open="(" close=")" separator=",">
  371. #{lOrderId,jdbcType=BIGINT}
  372. </foreach>
  373. )
  374. </when>
  375. </choose>
  376. </select>
  377. <select id="findWaybillOrderCount" resultType="com.sckw.transport.model.vo.WaybillCountVo">
  378. SELECT
  379. count(case when c.status = 8 then 1 end) totalComplete,
  380. count(case when c.status not in (1, 9, 10, 11) then 1 end) totalTake,
  381. count(case when c.status in (3, 4, 5, 6) then 1 end) totalExecute,
  382. count(DISTINCT case when lo.status in (0, 1, 2, 3) then lo.id end) totalUnfinished,
  383. IFNULL(SUM(c.entrust_amount), 0.0) entrustAmount, IFNULL(SUM(c.load_amount), 0.0) loadAmount,
  384. IFNULL(SUM(c.unload_amount), 0.0) unloadAmount, IFNULL(SUM(c.deficit_amount), 0.0) deficitAmount,
  385. MIN(wot1.operate_time) loadTime, MAX(wot2.operate_time) unloadTime
  386. from kwt_waybill_order wo
  387. left join kwt_waybill_order_subtask c on wo.id = c.w_order_id
  388. left join kwt_waybill_order_ticket wot1 on wot1.w_order_id = wo.id and wot1.type = 1 and c.unit = wot1.unit and wot1.type = 1 and wot1.del_flag = 0
  389. left join kwt_waybill_order_ticket wot2 on wot2.w_order_id = wo.id and wot2.type = 2 and c.unit = wot2.unit and wot1.type = 2 and wot2.del_flag = 0
  390. left join kwt_logistics_order lo on lo.id = c.l_order_id
  391. where c.del_flag = 0 and lo.del_flag = 0
  392. <if test="driverId != null and driverId != ''">
  393. and wo.driver_id = #{driverId, jdbcType=BIGINT}
  394. </if>
  395. <if test="truckId != null and truckId != ''">
  396. and wo.truck_id = #{truckId, jdbcType=BIGINT}
  397. </if>
  398. <if test="passStatus != null and passStatus != ''">
  399. and c.status = 8
  400. </if>
  401. <if test="loadCountStatus != null and loadCountStatus != ''">
  402. and c.status in (5, 6, 7, 8, 12, 13)
  403. </if>
  404. <if test="unloadCountStatus != null and unloadCountStatus != ''">
  405. and c.status in (7, 8, 12, 13)
  406. </if>
  407. <if test="tOrderId != null and tOrderId != ''">
  408. and lo.t_order_id = #{tOrderId, jdbcType=BIGINT}
  409. </if>
  410. <if test="lOrderId != null and lOrderId != ''">
  411. and lo.id = #{lOrderId, jdbcType=BIGINT}
  412. </if>
  413. <if test="logisticsStatus != null and logisticsStatus != ''">
  414. and lo.status = #{logisticsStatus, jdbcType=INTEGER}
  415. </if>
  416. <if test="upperlOrderId != null and upperlOrderId != ''">
  417. and FIND_IN_SET(#{upperlOrderId, jdbcType=BIGINT}, lo.pids)
  418. </if>
  419. <if test="belowlOrderId != null and belowlOrderId != ''">
  420. and FIND_IN_SET(lo.id, #{belowlOrderId, jdbcType=VARCHAR})
  421. </if>
  422. <if test="ownOrderId != null and ownOrderId != ''">
  423. and lo.id != #{ownOrderId, jdbcType=BIGINT}
  424. </if>
  425. </select>
  426. <select id="selectDataByLorderId" resultType="java.lang.Integer">
  427. SELECT COUNT(b.id)
  428. FROM kwt_waybill_order_subtask k
  429. left join kwt_waybill_order a on k.w_order_id = a.id and a.del_flag = 0 and k.del_flag = 0
  430. LEFT JOIN kwt_logistics_order b ON k.l_order_id = b.id AND a.del_flag = 0 AND b.del_flag = 0
  431. <where>
  432. <if test="id != null and id !=''">
  433. and b.id = #{id}
  434. </if>
  435. <if test="statusList != null and statusList.size() >0">
  436. AND a.`status` IN
  437. <foreach collection="statusList" item="item" open="(" close=")" separator=",">
  438. #{item}
  439. </foreach>
  440. </if>
  441. </where>
  442. </select>
  443. <select id="selectDataByLorderIds" resultType="java.lang.Integer">
  444. SELECT COUNT(b.id)
  445. FROM kwt_waybill_order_subtask k
  446. left join kwt_waybill_order a on k.w_order_id = a.id and a.del_flag = 0 and k.del_flag = 0
  447. LEFT JOIN kwt_logistics_order b ON k.l_order_id = b.id AND a.del_flag = 0 AND b.del_flag = 0
  448. <where>
  449. <if test="list != null and list.size() > 0">
  450. and b.id in <foreach collection="list" item="item" open="(" close=")" separator=","> #{item}</foreach>
  451. </if>
  452. <if test="status != null">
  453. AND a.`status`= #{status}
  454. </if>
  455. </where>
  456. </select>
  457. </mapper>