KwtLogisticsOrderMapper.xml 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669
  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.KwtLogisticsOrderMapper">
  4. <resultMap id="BaseResultMap" type="com.sckw.transport.model.KwtLogisticsOrder">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="ent_id" jdbcType="BIGINT" property="entId"/>
  7. <result column="type" jdbcType="BIGINT" property="type"/>
  8. <result column="t_order_id" jdbcType="BIGINT" property="tOrderId"/>
  9. <result column="t_order_no" jdbcType="VARCHAR" property="tOrderNo"/>
  10. <result column="l_order_no" jdbcType="VARCHAR" property="lOrderNo"/>
  11. <result column="pid" jdbcType="BIGINT" property="pid"/>
  12. <result column="pids" jdbcType="VARCHAR" property="pids"/>
  13. <result column="level" jdbcType="VARCHAR" property="level"/>
  14. <result column="bind_status" jdbcType="VARCHAR" property="bindStatus"/>
  15. <result column="total_load_amount" jdbcType="VARCHAR" property="totalLoadAmount"/>
  16. <result column="total_unload_amount" jdbcType="VARCHAR" property="totalUnloadAmount"/>
  17. <result column="settlement_cycle" jdbcType="BIGINT" property="settlementCycle"/>
  18. <result column="billing_mode" jdbcType="BIGINT" property="billingMode"/>
  19. <result column="price" jdbcType="DECIMAL" property="price"/>
  20. <result column="price_type" jdbcType="BIGINT" property="priceType"/>
  21. <result column="amount" jdbcType="DECIMAL" property="amount"/>
  22. <result column="unit" jdbcType="VARCHAR" property="unit"/>
  23. <result column="loss" jdbcType="DECIMAL" property="loss"/>
  24. <result column="loss_unit" jdbcType="VARCHAR" property="lossUnit"/>
  25. <result column="goods_price" jdbcType="DECIMAL" property="goodsPrice"/>
  26. <result column="goods_price_unit" jdbcType="VARCHAR" property="goodsPriceUnit"/>
  27. <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
  28. <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
  29. <result column="subcontract_amount" jdbcType="DECIMAL" property="subcontractAmount"/>
  30. <result column="entrust_amount" jdbcType="DECIMAL" property="entrustAmount"/>
  31. <result column="unload_amount" jdbcType="DECIMAL" property="unloadAmount"/>
  32. <result column="load_amount" jdbcType="DECIMAL" property="loadAmount"/>
  33. <result column="ignore_amount" jdbcType="DECIMAL" property="ignoreAmount"/>
  34. <result column="deficit_amount" jdbcType="DECIMAL" property="deficitAmount"/>
  35. <result column="deficit_price" jdbcType="DECIMAL" property="deficitPrice"/>
  36. <result column="payment" jdbcType="BIGINT" property="payment"/>
  37. <result column="tax_rate" jdbcType="DECIMAL" property="taxRate"/>
  38. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  39. <result column="status" jdbcType="INTEGER" property="status"/>
  40. <result column="create_by" jdbcType="BIGINT" property="createBy"/>
  41. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  42. <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
  43. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  44. <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
  45. </resultMap>
  46. <sql id="Base_Column_List">
  47. id
  48. , ent_id, t_order_id,type,level,bind_status,total_load_amount,total_unload_amount, t_order_no, l_order_no, pid,pids, settlement_cycle, price, price_type,billing_mode,
  49. amount, unit, loss, loss_unit, goods_price, goods_price_unit, start_time, end_time,
  50. subcontract_amount, entrust_amount, unload_amount, load_amount, ignore_amount, deficit_amount,
  51. deficit_price, payment, tax_rate, remark, `status`, create_by, create_time, update_by,
  52. update_time, del_flag
  53. </sql>
  54. <select id="selectOrderList" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
  55. SELECT a.id as lOrderId,
  56. a.l_order_no as lOrderNo,
  57. b.`status` as `status`,
  58. a.t_order_id as tOrderId,
  59. a.t_order_no as tOrderNo,
  60. a.payment as payment,
  61. a.amount,
  62. a.price,
  63. a.loss,
  64. a.goods_price as goodsPrice,
  65. c.firm_name as comanyName,
  66. c.contacts,
  67. c.phone,
  68. a.create_by as createBy,
  69. a.create_time as createTime
  70. FROM kwt_logistics_order a
  71. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
  72. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  73. WHERE a.del_flag = '0'
  74. AND b.del_flag = '0'
  75. AND a.t_order_id = #{id,jdbcType=VARCHAR} limit #{page}
  76. , #{pageSize}
  77. </select>
  78. <select id="selectOrderListNotPage" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
  79. SELECT a.id as lOrderId,
  80. a.l_order_no as lOrderNo,
  81. b.`status` as `status`,
  82. a.t_order_id as tOrderId,
  83. a.t_order_no as tOrderNo,
  84. a.payment as payment,
  85. a.amount,
  86. a.unit as unit,
  87. a.price,
  88. a.price_type as priceType,
  89. a.loss,
  90. a.loss_unit AS lossUnit,
  91. a.goods_price as goodsPrice,
  92. a.goods_price_unit as goodsPriceUnit,
  93. c.firm_name as companyName,
  94. c.contacts,
  95. c.phone,
  96. a.create_by as createBy,
  97. a.create_time as createTime
  98. FROM kwt_logistics_order a
  99. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
  100. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  101. WHERE a.del_flag = '0'
  102. AND b.del_flag = '0'
  103. AND a.t_order_id = #{id,jdbcType=VARCHAR}
  104. order by createTime desc
  105. </select>
  106. <select id="selectOrderListByContractId" resultType="com.sckw.transport.model.vo.SckwLogisticsOrderVO">
  107. SELECT
  108. a.STATUS,
  109. a.id AS lOrderId,
  110. a.l_order_no AS lOrderNo,
  111. f.contract_no AS contractNo,
  112. d.id as checkId,
  113. d.ent_id as checkEntId,
  114. d.top_ent_id as checkTopEntId,
  115. d.firm_name AS checkFirmName,
  116. e.id as carrierId,
  117. e.ent_id as carrierEntId,
  118. e.top_ent_id as carrierTopEntId,
  119. e.firm_name AS carrierFirmName,
  120. g.goods_name AS goodsName,
  121. a.amount AS carryingCapacity,
  122. a.price AS price,
  123. b.city_name AS loadCityName,
  124. b.detail_address AS loadDetailAddress,
  125. a.payment AS payment,
  126. a.loss AS loss,
  127. a.loss_unit AS lossUnit,
  128. a.goods_price AS goodsPrice,
  129. a.goods_price_unit AS goodsPriceUnit,
  130. a.settlement_cycle AS settlementCycle,
  131. e.contacts AS carrierContacts,
  132. e.phone AS carrierPhone,
  133. d.contacts AS checkContacts,
  134. d.phone AS checkPhone,
  135. b.contacts AS loadContacts,
  136. b.phone AS loadPhone,
  137. c.contacts AS unloadContacts,
  138. c.phone AS unloadPhone,
  139. a.start_time AS startTime,
  140. a.end_time AS endTime,
  141. a.remark AS remark,
  142. a.create_by AS createBy,
  143. a.create_time AS createTime,
  144. f.contract_id AS contractId,
  145. a.amount AS amount,
  146. c.detail_address as unloadDetailAddress
  147. FROM
  148. kwt_logistics_order a
  149. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  150. AND b.address_type = 1
  151. AND b.del_flag = 0
  152. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  153. AND c.address_type = 2
  154. AND c.del_flag = 0
  155. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  156. AND d.unit_type = 1
  157. AND d.del_flag = 0
  158. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  159. AND e.unit_type = 2
  160. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id
  161. AND g.del_flag = 0
  162. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id
  163. AND f.del_flag = 0
  164. <where>
  165. a.del_flag = 0
  166. <!-- <if test="type == 1">-->
  167. <!-- and (d.top_ent_id = #{entId} or d.ent_id = #{entId})-->
  168. <!-- </if>-->
  169. <!-- <if test="type == 2">-->
  170. <!-- and (e.top_ent_id = #{entId} or e.ent_id = #{entId})-->
  171. <!-- </if>-->
  172. <if test="contractIds != null and contractIds.size() > 0">
  173. and f.contract_id in
  174. <foreach collection="contractIds" item="item" separator="," open="(" close=")">
  175. #{item}
  176. </foreach>
  177. </if>
  178. </where>
  179. ORDER BY a.id DESC
  180. </select>
  181. <select id="selectOrderCount" resultType="java.lang.Long">
  182. SELECT count(a.id)
  183. FROM kwt_logistics_order a
  184. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
  185. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  186. WHERE a.del_flag = '0'
  187. AND b.del_flag = '0'
  188. AND a.t_order_id = #{id,jdbcType=VARCHAR}
  189. </select>
  190. <select id="selectLogisticOrderData" resultType="com.sckw.transport.api.model.vo.LogisticsOrderVO">
  191. SELECT
  192. DISTINCT a.id AS lOrderId,
  193. a.l_order_no AS lOrderNO,
  194. a.t_order_id AS tOrderId,
  195. a.t_order_no AS tOrderNO,
  196. a.payment AS payment,
  197. a.billing_mode AS billingMode,
  198. c.contract_id AS contractId,
  199. c.contract_no AS contractNo,
  200. c.contract_name AS contractName,
  201. b.goods_name AS goodsName,
  202. a.amount,
  203. a.remark as remark,
  204. a.unit ,
  205. a.ignore_amount AS ignoreAmount,
  206. a.price,
  207. a.price_type as priceType,
  208. a.goods_price AS goodsPrice,
  209. a.goods_price_unit AS goodsPriceUnit,
  210. a.loss,
  211. a.loss_unit AS lossUnit,
  212. a.tax_rate as taxRate,
  213. a.load_amount AS loadAmount,
  214. a.unload_amount AS unloadAmount,
  215. a.settlement_cycle as settlementCycle,
  216. a.start_time AS startTime,
  217. a.end_time AS endTime,
  218. a.create_time AS createTime,
  219. a.create_by AS createBy,
  220. a.update_by AS updateBy,
  221. a.update_time AS updateTime
  222. FROM
  223. kwt_logistics_order a
  224. LEFT JOIN kwt_logistics_order_goods b ON a.id = b.l_order_id and a.bind_status = '0'
  225. <!-- LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id-->
  226. LEFT JOIN kwt_logistics_order_contract c ON a.id = c.l_order_id
  227. <!-- LEFT JOIN ( SELECT l_order_id FROM kwt_logistics_order_unit WHERE unit_type = 1 AND ent_id = #{entId} ) g ON a.id = g.l_order_id-->
  228. <!-- LEFT JOIN ( SELECT ent_id FROM kwt_logistics_order_unit WHERE unit_type = 1 AND ent_id = #{entId} ) g ON a.id = g.l_order_id-->
  229. LEFT JOIN kwt_logistics_order_unit g on a.id = g.l_order_id and g.unit_type= 1
  230. LEFT JOIN kwt_logistics_order_unit h on a.id = h.l_order_id and h.unit_type= 2
  231. <where>
  232. a.del_flag = 0 and a.bind_status = '0' <!--and d.unit_type = 1-->
  233. <if test="dictValue != null and dictValue != ''">
  234. AND a.payment = #{dictValue}
  235. </if>
  236. <if test="logisticsOrderParam.companyId !=null and logisticsOrderParam.companyId != ''">
  237. <!-- AND d.ent_id = #{logisticsOrderParam.companyId}-->
  238. AND g.ent_id = #{logisticsOrderParam.companyId}
  239. </if>
  240. <if test="ids !=null and ids.size() > 0 ">
  241. AND ( h.ent_id in
  242. <foreach collection="ids" open="(" close=")" separator="," item="item">
  243. #{item}
  244. </foreach>
  245. or h.top_ent_id in
  246. <foreach collection="ids" item="item" separator="," close=")" open="(">
  247. #{item}
  248. </foreach>
  249. )
  250. </if>
  251. <if test="logisticsOrderParam.taxRate != null and logisticsOrderParam.taxRate != ''">
  252. AND a.tax_rate = #{logisticsOrderParam.taxRate}
  253. </if>
  254. <if test="logisticsOrderParam.goodsName != null and logisticsOrderParam.goodsName != ''">
  255. AND b.goods_name LIKE concat('%',#{logisticsOrderParam.goodsName},'%')
  256. </if>
  257. <if test="logisticsOrderParam.startTime != null and logisticsOrderParam.startTime !=''">
  258. AND a.start_time &gt;= #{logisticsOrderParam.startTime}
  259. </if>
  260. <if test="logisticsOrderParam.endTime != null and logisticsOrderParam.endTime !=''">
  261. AND a.end_time &lt;= #{logisticsOrderParam.endTime}
  262. </if>
  263. </where>
  264. ORDER BY a.create_time DESC
  265. <if test="logisticsOrderParam.page != null and logisticsOrderParam.pageSize != null ">
  266. limit #{logisticsOrderParam.page,jdbcType=INTEGER},#{logisticsOrderParam.pageSize,jdbcType=INTEGER}
  267. </if>
  268. </select>
  269. <select id="selectLogisticOrderCount" resultType="java.lang.Long">
  270. SELECT
  271. count(a.id)
  272. FROM
  273. kwt_logistics_order a
  274. LEFT JOIN kwt_logistics_order_goods b ON a.id = b.l_order_id
  275. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  276. LEFT JOIN kwt_logistics_order_unit h ON a.id = h.l_order_id
  277. LEFT JOIN kwt_logistics_order_contract c ON a.id=c.l_order_id
  278. <where>
  279. a.del_flag = 0 and d.unit_type = 1 and h.unit_type = 2 and a.bind_status='0'
  280. <if test="dictValue != null and dictValue != ''">
  281. AND a.payment = #{dictValue}
  282. </if>
  283. <if test="logisticsOrderParam.companyId !=null and logisticsOrderParam.companyId != ''">
  284. AND d.ent_id = #{logisticsOrderParam.companyId}
  285. </if>
  286. <if test="ids !=null and ids.size() > 0 ">
  287. AND ( h.ent_id in
  288. <foreach collection="ids" open="(" close=")" separator="," item="item">
  289. #{item}
  290. </foreach>
  291. or h.top_ent_id in
  292. <foreach collection="ids" item="item" separator="," close=")" open="(">
  293. #{item}
  294. </foreach>
  295. )
  296. </if>
  297. <if test="logisticsOrderParam.taxRate != null and logisticsOrderParam.taxRate != ''">
  298. AND a.tax_rate = #{logisticsOrderParam.taxRate}
  299. </if>
  300. <if test="logisticsOrderParam.goodsName != null and logisticsOrderParam.goodsName != ''">
  301. AND b.goods_name LIKE concat('%',#{logisticsOrderParam.goodsName},'%')
  302. </if>
  303. <if test="logisticsOrderParam.startTime != null and logisticsOrderParam.startTime !=''">
  304. AND a.start_time &gt;= #{logisticsOrderParam.startTime}
  305. </if>
  306. <if test="logisticsOrderParam.endTime != null and logisticsOrderParam.endTime !=''">
  307. AND a.end_time &lt;= #{logisticsOrderParam.endTime}
  308. </if>
  309. </where>
  310. ORDER BY a.create_time DESC
  311. </select>
  312. <select id="getRejectReason" resultType="java.util.Map">
  313. SELECT a.id AS lOrderId,
  314. b.remark remark
  315. FROM kwt_logistics_order a
  316. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id
  317. WHERE a.del_flag = '0'
  318. AND b.del_flag = '0'
  319. and b.status = #{status}
  320. and a.id = #{id}
  321. </select>
  322. <select id="getSubcontractConsignment" resultType="com.sckw.transport.model.vo.SubcontractConsignmentVO">
  323. SELECT a.id,
  324. a.pid,
  325. a.`status` as status,
  326. a.l_order_no as consignOrderNo,
  327. c.firm_name as carrierContacts,
  328. d.goods_name as goodsName,
  329. a.amount as amount,
  330. a.price,
  331. a.price_type as priceType,
  332. e.detail_address as loadAddress,
  333. f.detail_address as unloadAddress,
  334. a.billing_mode as billingMode,
  335. a.loss,
  336. a.loss_unit as lossUnit,
  337. a.goods_price as goodsPrice,
  338. a.goods_price_unit as goodsPriceUnit,
  339. a.settlement_cycle as settlementCycle,
  340. c.contacts as carrierContacts,
  341. c.phone as carrierPhone,
  342. b.firm_name as consignCompany,
  343. b.contacts as consignContacts,
  344. b.phone as consignPhone,
  345. e.contacts as loadContacts,
  346. e.phone as loadContacts,
  347. f.contacts as unloadContacts,
  348. f.phone as unloadPhone,
  349. a.start_time as shipmentsDate,
  350. a.end_time as receiveGoodsDate,
  351. a.remark,
  352. a.create_by as createBy,
  353. a.create_time as createTime,
  354. g.contract_id as contractId
  355. FROM kwt_logistics_order a
  356. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  357. AND b.unit_type = 1
  358. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  359. AND c.unit_type = 2
  360. LEFT JOIN kwt_logistics_order_goods d ON a.id = d.l_order_id
  361. LEFT JOIN kwt_logistics_order_address e ON a.id = e.l_order_id
  362. AND e.address_type = 1
  363. LEFT JOIN kwt_logistics_order_address f ON a.id = f.l_order_id
  364. AND f.address_type = 2
  365. LEFT JOIN kwt_logistics_order_contract g ON a.id = g.l_order_id
  366. WHERE a.del_flag = 0
  367. AND b.del_flag = 0
  368. AND c.del_flag = 0
  369. AND e.del_flag = 0
  370. AND f.del_flag = 0
  371. and a.pid = #{lOrderId}
  372. ORDER BY a.create_time
  373. limit #{page}, #{pageSize}
  374. </select>
  375. <select id="getSubcontractConsignmentNotPage" resultType="com.sckw.transport.model.vo.SubcontractConsignmentVO">
  376. SELECT a.id,
  377. a.pid,
  378. a.`status` as status,
  379. a.l_order_no as consignOrderNo,
  380. <!-- a.l_order_no as carrierOrderNo,-->
  381. c.firm_name as carrierCompany,
  382. d.goods_name as goodsName,
  383. a.amount as carryingCapacity,
  384. a.price,
  385. a.price_type as priceType,
  386. e.detail_address as loadAddress,
  387. f.detail_address as unloadAddress,
  388. a.billing_mode as billingMode,
  389. a.loss,
  390. a.loss_unit as lossUnit,
  391. a.goods_price as goodsPrice,
  392. a.goods_price_unit as goodsPriceUnit,
  393. a.settlement_cycle as settlementCycle,
  394. c.contacts as carrierContacts,
  395. c.phone as carrierPhone,
  396. b.firm_name as consignCompany,
  397. b.contacts as consignContacts,
  398. b.phone as consignPhone,
  399. e.contacts as loadContacts,
  400. e.phone as loadPhone,
  401. f.contacts as unloadContacts,
  402. f.phone as unloadPhone,
  403. a.start_time as shipmentsDate,
  404. a.end_time as receiveGoodsDate,
  405. a.remark,
  406. a.create_by as createBy,
  407. a.create_time as createTime,
  408. g.contract_id as contractId,
  409. g.contract_no as contractNo,
  410. g.contract_name as contractName,
  411. g.signing_way as signing,
  412. e.city_name as loadCityName,
  413. f.city_name as unloadCityName
  414. FROM kwt_logistics_order a
  415. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  416. AND b.unit_type = 1
  417. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  418. AND c.unit_type = 2
  419. LEFT JOIN kwt_logistics_order_goods d ON a.id = d.l_order_id
  420. LEFT JOIN kwt_logistics_order_address e ON a.id = e.l_order_id
  421. AND e.address_type = 1
  422. LEFT JOIN kwt_logistics_order_address f ON a.id = f.l_order_id
  423. AND f.address_type = 2
  424. LEFT JOIN kwt_logistics_order_contract g ON a.id = g.l_order_id
  425. WHERE a.del_flag = 0
  426. AND b.del_flag = 0
  427. AND c.del_flag = 0
  428. AND e.del_flag = 0
  429. AND f.del_flag = 0
  430. and a.pid = #{lOrderId}
  431. ORDER BY a.create_time desc
  432. </select>
  433. <select id="countSubcontractConsignmentById" resultType="java.util.Map">
  434. SELECT COUNT(0) as total,
  435. a.id,
  436. a.pid,
  437. a.`status` as status,
  438. a.l_order_no as consignOrderNo,
  439. c.firm_name as carrierContacts,
  440. d.goods_name as goodsName,
  441. a.amount as amount,
  442. a.price,
  443. a.price_type as priceType,
  444. e.detail_address as loadAddress,
  445. f.detail_address as unloadAddress,
  446. a.billing_mode as billingMode,
  447. a.loss,
  448. a.loss_unit as lossUnit,
  449. a.goods_price as goodsPrice,
  450. a.goods_price_unit as goodsPriceUnit,
  451. a.settlement_cycle as settlementCycle,
  452. c.contacts as carrierContacts,
  453. c.phone as carrierPhone,
  454. b.firm_name as consignCompany,
  455. b.contacts as consignContacts,
  456. b.phone as consignPhone,
  457. e.contacts as loadContacts,
  458. e.phone as loadContacts,
  459. f.contacts as unloadContacts,
  460. f.phone as unloadPhone,
  461. a.start_time as shipmentsDate,
  462. a.end_time as receiveGoodsDate,
  463. a.remark,
  464. a.create_by as createBy,
  465. a.create_time as createTime,
  466. g.contract_id as contractId
  467. FROM kwt_logistics_order a
  468. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  469. AND b.unit_type = 1
  470. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  471. AND c.unit_type = 2
  472. LEFT JOIN kwt_logistics_order_goods d ON a.id = d.l_order_id
  473. LEFT JOIN kwt_logistics_order_address e ON a.id = e.l_order_id
  474. AND e.address_type = 1
  475. LEFT JOIN kwt_logistics_order_address f ON a.id = f.l_order_id
  476. AND f.address_type = 2
  477. LEFT JOIN kwt_logistics_order_contract g ON a.id = g.l_order_id
  478. WHERE a.del_flag = 0
  479. AND b.del_flag = 0
  480. AND c.del_flag = 0
  481. AND e.del_flag = 0
  482. AND f.del_flag = 0
  483. and a.pid = #{lOrderId}
  484. ORDER BY a.create_time
  485. </select>
  486. <select id="selectDriverListById" resultType="com.sckw.transport.model.vo.DriverListVo">
  487. SELECT COUNT( b.truck_no ) AS count,
  488. a.id AS lOrderId,
  489. a.l_order_no AS lOrderNo,
  490. b.driver_id AS driverId,
  491. b.id AS wOrderId,
  492. b.w_order_no AS wOrderNo,
  493. b.driver_name AS driverName,
  494. b.driver_phone AS driverPhone,
  495. b.driver_idcard AS driverIdCard,
  496. b.truck_no AS truckNo
  497. FROM
  498. kwt_waybill_order b
  499. LEFT JOIN kwt_logistics_order a ON b.l_order_id = a.id
  500. <!-- SELECT a.id AS lOrderId,-->
  501. <!-- a.l_order_no AS lOrderNo,-->
  502. <!-- b.driver_id AS driverId,-->
  503. <!-- b.id AS wOrderId,-->
  504. <!-- b.w_order_no AS wOrderNo,-->
  505. <!-- b.driver_name AS driverName,-->
  506. <!-- b.driver_phone AS driverPhone,-->
  507. <!-- b.driver_idcard AS driverIdCard,-->
  508. <!-- b.truck_no AS truckNo-->
  509. <!-- ,-->
  510. <!-- COUNT( b.id ) AS count-->
  511. <!-- FROM-->
  512. <!-- kwt_waybill_order b,-->
  513. <!-- kwt_logistics_order a-->
  514. <where>
  515. a.id = b.l_order_id
  516. AND a.del_flag = 0
  517. AND b.del_flag = 0
  518. AND b.type = '1'
  519. AND b.status = 1
  520. <if test="driverParam.lOrderId != null and driverParam.lOrderId != ''">
  521. AND a.id =#{driverParam.lOrderId}
  522. </if>
  523. <if test="driverParam.driverName != null and driverParam.driverName != '' or ( driverParam.driverPhone != null and driverParam.driverPhone != '' ) or ( driverParam.truckNo != null and driverParam.truckNo != '' ) ">
  524. and (
  525. <if test="driverParam.driverName != null and driverParam.driverName != ''">
  526. b.driver_name like concat('%',#{driverParam.driverName},'%')
  527. </if>
  528. <if test="driverParam.driverPhone != null and driverParam.driverPhone != ''">
  529. or b.driver_phone like concat('%',#{driverParam.driverPhone},'%')
  530. </if>
  531. <if test="driverParam.truckNo != null and driverParam.truckNo != ''">
  532. or b.truck_no like concat('%',#{driverParam.truckNo},'%')
  533. </if>
  534. )
  535. </if>
  536. GROUP BY
  537. b.truck_no
  538. <!-- a.l_order_no,-->
  539. </where>
  540. </select>
  541. <select id="selectLogisticOrderList" resultType="com.sckw.transport.api.model.dto.LogisticsOrderDTO">
  542. SELECT
  543. DISTINCT a.id AS lOrderId,
  544. a.l_order_no AS lOrderNO,
  545. a.t_order_id AS tOrderId,
  546. a.t_order_no AS tOrderNO,
  547. a.payment AS payment,
  548. a.billing_mode AS billingMode,
  549. c.contract_id AS contractId,
  550. b.goods_name AS goodsName,
  551. a.amount,
  552. a.remark as remark,
  553. a.unit ,
  554. a.ignore_amount AS ignoreAmount,
  555. a.price,
  556. a.price_type as priceType,
  557. a.goods_price AS goodsPrice,
  558. a.loss,
  559. a.loss_unit AS lossUnit,
  560. a.tax_rate as taxRate,
  561. a.load_amount AS loadAmount,
  562. a.unload_amount AS unloadAmount,
  563. a.settlement_cycle as settlementCycle,
  564. a.start_time AS startTime,
  565. a.end_time AS endTime,
  566. a.create_time AS createTime,
  567. a.create_by AS createBy,
  568. a.update_by AS updateBy,
  569. a.update_time AS updateTime
  570. FROM
  571. kwt_logistics_order a
  572. LEFT JOIN kwt_logistics_order_goods b ON a.id = b.l_order_id and a.bind_status = '0'
  573. <!-- LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id-->
  574. LEFT JOIN kwt_logistics_order_contract c ON a.id = c.l_order_id
  575. <where>
  576. <if test="ids != null and ids.size() > 0">
  577. and a.id in
  578. <foreach collection="ids" item="item" open="(" close=")" separator=",">
  579. #{item}
  580. </foreach>
  581. </if>
  582. </where>
  583. ORDER BY a.create_time DESC
  584. </select>
  585. <select id="selectOrderFinishData" resultType="com.sckw.transport.model.vo.OrderFinishVO">
  586. SELECT b.amount as amount,COUNT(a.id) AS number,
  587. SUM(IFNULL(a.load_amount, 0)) as loadAmount,
  588. SUM(IFNULL(a.unload_amount, 0)) AS unloadAmount
  589. FROM kwt_waybill_order a
  590. LEFT JOIN kwt_logistics_order b ON b.id = a.l_order_id
  591. AND a.del_flag = 0
  592. AND b.del_flag = 0
  593. <where>
  594. <if test="orderId != null and orderId != ''">
  595. and b.id=#{orderId}
  596. </if>
  597. </where>
  598. </select>
  599. <select id="findLogisticsOrder" resultType="com.sckw.transport.model.KwtLogisticsOrder"
  600. parameterType="java.util.Map">
  601. select
  602. id, ent_id entId, t_order_id tOrderId, t_order_no tOrderNo, l_order_no lOrderNo, pid, pids,
  603. settlement_cycle settlementCycle, price, price_type priceType, billing_mode billingMode,
  604. amount, unit, loss, loss_unit lossUnit, goods_price goodsPrice, goods_price_unit goodsPriceUnit,
  605. start_time startTime, end_time endTime, subcontract_amount subcontractAmount, entrust_amount entrustAmount,
  606. unload_amount unloadAmount, load_amount loadAmount, ignore_amount ignoreAmount, deficit_amount deficitAmount,
  607. deficit_price deficitPrice, payment, tax_rate taxRate, remark, `status`, create_by createBy,
  608. create_time createTime, update_by updateBy, update_time updateTime
  609. from kwt_logistics_order
  610. where del_flag = 0
  611. <if test="id != null and id != ''">
  612. and id = #{id, jdbcType=BIGINT}
  613. </if>
  614. <if test="upperlOrderId != null and upperlOrderId != ''">
  615. and FIND_IN_SET(#{upperlOrderId, jdbcType=BIGINT}, pids)
  616. and id != #{ownOrderId, jdbcType=BIGINT}
  617. </if>
  618. <if test="belowlOrderId != null and belowlOrderId != ''">
  619. and FIND_IN_SET(id, #{belowlOrderId, jdbcType=VARCHAR})
  620. and id != #{ownOrderId, jdbcType=BIGINT}
  621. </if>
  622. </select>
  623. <select id="selectOrderCountByTorderId" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
  624. SELECT a.id as lOrderId,
  625. a.l_order_no as lOrderNo,
  626. b.`status` as `status`,
  627. a.t_order_id as tOrderId,
  628. a.t_order_no as tOrderNo,
  629. a.payment as payment,
  630. a.amount,
  631. a.price,
  632. a.loss,
  633. a.goods_price as goodsPrice,
  634. c.firm_name as comanyName,
  635. c.contacts,
  636. c.phone,
  637. a.create_by as createBy,
  638. a.create_time as createTime
  639. FROM kwt_logistics_order a
  640. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id
  641. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  642. WHERE a.del_flag = '0'
  643. AND b.del_flag = '0'
  644. AND a.t_order_id = #{id,jdbcType=VARCHAR}
  645. </select>
  646. <select id="getAddressList" resultType="java.lang.Integer">
  647. SELECT a.city_code
  648. FROM kwt_logistics_order_address a
  649. LEFT JOIN kwt_logistics_order b ON a.l_order_id = b.id
  650. where a.city_code is not null
  651. AND b.ent_id = #{entId}
  652. GROUP BY a.city_code
  653. </select>
  654. <select id="getAddressDetailListByEntId" resultType="com.sckw.transport.api.model.dto.AddressResDTO">
  655. </select>
  656. <select id="selectMaxLevel" resultType="java.lang.Integer">
  657. SELECT MAX(LEVEL)
  658. FROM kwt_logistics_order
  659. WHERE del_flag = 0
  660. AND FIND_IN_SET(#{id}, pids)
  661. </select>
  662. <select id="countAmountByTradeOrderId" resultType="java.util.Map">
  663. SELECT IFNULL(SUM(unload_amount), 0) AS unloadAmount,
  664. IFNULL(SUM(load_amount), 0) AS loadAmount,
  665. IFNULL(SUM(total_load_amount), 0) AS totalLoadAmount,
  666. IFNULL(SUM(total_unload_amount), 0) AS totalUnloadAmount
  667. FROM kwt_logistics_order
  668. WHERE del_flag = 0
  669. AND t_order_id = #{tOrderId}
  670. AND `status` IN (
  671. 8
  672. )
  673. </select>
  674. <select id="selectOrderListByIdsAndUnitType" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
  675. SELECT a.id as lOrderId,
  676. a.l_order_no as lOrderNo,
  677. b.`status` as `status`,
  678. a.t_order_id as tOrderId,
  679. a.t_order_no as tOrderNo,
  680. a.payment as payment,
  681. a.amount,
  682. a.price,
  683. a.loss,
  684. a.goods_price as goodsPrice,
  685. c.firm_name as companyName,
  686. c.contacts,
  687. c.phone,
  688. a.create_by as createBy,
  689. a.create_time as createTime
  690. FROM kwt_logistics_order a
  691. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
  692. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  693. WHERE a.del_flag = '0'
  694. AND b.del_flag = '0'
  695. AND a.t_order_id IN
  696. <foreach collection="ids" item="item" open="(" close=")" separator=",">
  697. #{item}
  698. </foreach>
  699. order by createTime desc
  700. </select>
  701. <select id="selectLoopOrderAndDriverListByOrderId" resultType="com.sckw.transport.model.vo.DriverListVo">
  702. SELECT a.id AS lOrderId,
  703. a.l_order_no AS lOrderNo,
  704. c.driver_id AS driverId,
  705. c.id AS circulateId,
  706. c.driver_name AS driverName,
  707. c.driver_phone AS driverPhone,
  708. c.driver_idcard AS driverIdCard,
  709. c.truck_no AS truckNo,
  710. c.truck_id AS truckId,
  711. c.total_take as count
  712. FROM
  713. kwt_logistics_order_circulate c,
  714. kwt_logistics_order a
  715. <where>
  716. a.id = c.l_order_id
  717. AND c.type = '2'
  718. AND c.`status` = '0'
  719. AND a.del_flag = 0
  720. AND c.del_flag = 0
  721. <if test="driverParam.lOrderId != null and driverParam.lOrderId != ''">
  722. AND a.id =#{driverParam.lOrderId}
  723. </if>
  724. <if test="driverParam.driverName != null and driverParam.driverName != '' or ( driverParam.driverPhone != null and driverParam.driverPhone != '' ) or ( driverParam.truckNo != null and driverParam.truckNo != '' )">
  725. and (
  726. <if test=" driverParam.driverName != null and driverParam.driverName != ''">
  727. c.driver_name like concat('%',#{driverParam.driverName},'%')
  728. </if>
  729. <if test=" driverParam.driverPhone != null and driverParam.driverPhone != ''">
  730. or c.driver_phone like concat('%',#{driverParam.driverPhone},'%')
  731. </if>
  732. <if test=" driverParam.truckNo != null and driverParam.truckNo != ''">
  733. or c.truck_no like concat('%',#{driverParam.truckNo},'%')
  734. </if>
  735. )
  736. </if>
  737. </where>
  738. </select>
  739. <select id="selectLoopOrderAndDriverListByOrderIds" resultType="com.sckw.transport.model.vo.DriverListVo">
  740. SELECT
  741. c.id AS circulateId,
  742. c.driver_id AS driverId,
  743. b.id AS lOrderId,
  744. b.l_order_no AS lOrderNo,
  745. c.driver_name AS driverName,
  746. c.driver_phone AS driverPhone,
  747. c.driver_idcard AS driverIdCard,
  748. c.truck_no AS truckNo,
  749. c.truck_id AS truckId,
  750. c.total_take AS count
  751. FROM
  752. kwt_logistics_order_circulate c
  753. LEFT JOIN kwt_logistics_order b ON b.id = c.l_order_id
  754. WHERE
  755. b.del_flag = 0
  756. AND c.del_flag = 0
  757. AND c.STATUS = 0
  758. <if test="idsList != null and idsList.size() >0">
  759. AND b.id IN
  760. <foreach collection="idsList" item="item" open="(" close=")" separator=",">
  761. #{item}
  762. </foreach>
  763. </if>
  764. </select>
  765. <sql id="Query_Column_List">
  766. a.id AS lOrderId,
  767. a.l_order_no AS lOrderNo,
  768. a.t_order_id AS tOrderId,
  769. a.t_order_no AS tOrderNo,
  770. a.loss AS loss,
  771. a.loss_unit AS lossUnit,
  772. a.settlement_cycle AS accountsCycle,
  773. a.billing_mode AS billingMode,
  774. a.amount AS carryingCapacity,
  775. a.goods_price AS goodsPrice,
  776. a.goods_price_unit AS goodsPriceUnit,
  777. a.`status` AS `status`,
  778. a.settlement_cycle AS settlementCycle,
  779. a.price AS price,
  780. a.price_type AS priceType,
  781. a.type AS type,
  782. a.unit AS unit,
  783. a.subcontract_amount AS subcontractAmount,
  784. a.entrust_amount AS entrustAmount,
  785. a.unload_amount AS unloadAmount,
  786. a.load_amount AS loadAmount,
  787. a.ignore_amount AS ignoreAmount,
  788. a.deficit_amount AS deficitAmount,
  789. a.deficit_price AS deficitPrice,
  790. a.total_load_amount AS totalLoadAmount,
  791. a.total_unload_amount AS totalUnloadAmount,
  792. a.payment AS payment,
  793. a.tax_rate AS taxRate,
  794. a.ent_id AS entId,
  795. a.create_by AS createBy,
  796. a.create_time AS createTime,
  797. a.update_by AS updateBy,
  798. a.update_time AS updateTime,
  799. a.start_time AS shipmentsDateTime,
  800. a.end_time AS receiveGoodsDateTime,
  801. a.remark AS remark,
  802. g.goods_id AS goodsId,
  803. g.goods_name AS goodsName,
  804. g.goods_type AS goodsType,
  805. f.contract_id AS contractId,
  806. f.contract_no AS contractNo,
  807. f.signing_way AS signing,
  808. d.ent_id AS consignCompanyId,
  809. d.top_ent_id AS consignTopEntId,
  810. d.firm_name AS consignCompany,
  811. d.contacts AS consignContacts,
  812. d.phone AS consignPhone,
  813. e.ent_id AS carrierCompanyId,
  814. e.firm_name AS carrierCompany,
  815. e.top_ent_id AS carrierTopEntId,
  816. e.contacts AS carrierContacts,
  817. e.phone AS carrierPhone,
  818. b.`name` AS loadName,
  819. b.address_type AS loadType,
  820. b.city_name AS loadCityName,
  821. b.city_code AS loadCityCode,
  822. b.detail_address AS loadAddress,
  823. b.contacts AS shipmentsContacts,
  824. b.phone AS shipmentsPhone,
  825. b.lat AS loadLat,
  826. b.lng AS loadLng,
  827. c.address_type AS unloadType,
  828. c.contacts AS receiveGoodsContacts,
  829. c.phone AS receiveGoodsPhone,
  830. c.city_name AS unloadCityName,
  831. c.city_code AS unloadCityCode,
  832. c.detail_address AS unloadAddress,
  833. c.lat AS unloadLat,
  834. c.lng AS unloadLng,
  835. f.contract_name as contract
  836. <!-- ,-->
  837. <!-- a.del_flag,-->
  838. <!-- b.del_flag,-->
  839. <!-- c.del_flag,-->
  840. <!-- d.del_flag,-->
  841. <!-- e.del_flag,-->
  842. <!-- f.del_flag,-->
  843. <!-- g.del_flag-->
  844. </sql>
  845. <select id="selectLogisticsOrderList" resultType="com.sckw.transport.model.vo.AcceptCarriageOrderVO">
  846. SELECT
  847. <include refid="Query_Column_List">
  848. </include>
  849. FROM
  850. kwt_logistics_order a
  851. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  852. AND b.address_type = 1 AND b.del_flag = 0
  853. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  854. AND c.address_type = 2 AND c.del_flag = 0
  855. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  856. AND d.unit_type = 1 AND d.del_flag = 0
  857. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  858. AND e.unit_type = 2
  859. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  860. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  861. <where>
  862. a.del_flag = 0
  863. <if test="type == 1">
  864. and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
  865. <!-- AND (-->
  866. <!-- a.ent_id = #{entId}-->
  867. <!-- <if test="userIds != null and userIds.size()>0">-->
  868. <!-- AND a.create_by IN-->
  869. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  870. <!-- #{item}-->
  871. <!-- </foreach>-->
  872. <!-- </if>-->
  873. <!-- )-->
  874. <!-- OR (-->
  875. <!-- d.top_ent_id = #{entId}-->
  876. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  877. <!-- AND d.contacts_id IN-->
  878. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  879. <!-- #{item}-->
  880. <!-- </foreach>-->
  881. <!-- </if>-->
  882. <!-- )-->
  883. </if>
  884. <if test="type == 2">
  885. and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
  886. <!-- AND (-->
  887. <!-- a.ent_id = #{entId}-->
  888. <!-- <if test="userIds != null and userIds.size()>0">-->
  889. <!-- AND a.create_by IN-->
  890. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  891. <!-- #{item}-->
  892. <!-- </foreach>-->
  893. <!-- </if>-->
  894. <!-- )-->
  895. <!-- OR (-->
  896. <!-- d.top_ent_id = #{entId}-->
  897. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  898. <!-- AND d.contacts_id IN-->
  899. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  900. <!-- #{item}-->
  901. <!-- </foreach>-->
  902. <!-- </if>-->
  903. <!-- )-->
  904. </if>
  905. <if test="query.keywords != null and query.keywords != ''">
  906. and (
  907. a.t_order_no like concat('%',#{query.keywords},'%')
  908. or a.l_order_no like concat('%',#{query.keywords},'%')
  909. or d.firm_name like concat('%',#{query.keywords},'%')
  910. or e.firm_name like concat('%',#{query.keywords},'%')
  911. or g.goods_name like concat('%',#{query.keywords},'%'))
  912. </if>
  913. <if test="orderList != null and orderList.size() > 0 ">
  914. and a.status in
  915. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  916. #{status}
  917. </foreach>
  918. </if>
  919. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  920. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  921. </if>
  922. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  923. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  924. </if>
  925. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  926. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  927. </if>
  928. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  929. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  930. </if>
  931. <if test="query.createStartTime != null and query.createStartTime != '' ">
  932. and a.create_time &gt;=#{query.createStartTime}
  933. </if>
  934. <if test="query.createEndTime != null and query.createEndTime != ''">
  935. and a.create_time &lt;=#{query.createEndTime}
  936. </if>
  937. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  938. and b.city_code = #{query.loadAddressCode}
  939. </if>
  940. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  941. and c.city_code = #{query.unloadAddressCode}
  942. </if>
  943. <if test="query.billingMode != null and query.billingMode != ''">
  944. and a.billing_mode =#{query.billingMode}
  945. </if>
  946. </where>
  947. ORDER BY a.create_time DESC
  948. <!-- ,a.create_time-->
  949. </select>
  950. <select id="selectManagementLogisticsOrderList" resultType="com.sckw.transport.model.vo.ManagementLogsiticsOrderVO">
  951. SELECT
  952. <include refid="Query_Column_List">
  953. </include>
  954. FROM
  955. kwt_logistics_order a
  956. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  957. AND b.address_type = 1 AND b.del_flag = 0
  958. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  959. AND c.address_type = 2 AND c.del_flag = 0
  960. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  961. AND d.unit_type = 1 AND d.del_flag = 0
  962. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  963. AND e.unit_type = 2
  964. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  965. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  966. <where>
  967. a.del_flag = 0
  968. <if test="type == 1">
  969. and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
  970. <!-- AND (-->
  971. <!-- a.ent_id = #{entId}-->
  972. <!-- <if test="userIds != null and userIds.size()>0">-->
  973. <!-- AND a.create_by IN-->
  974. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  975. <!-- #{item}-->
  976. <!-- </foreach>-->
  977. <!-- </if>-->
  978. <!-- )-->
  979. <!-- OR (-->
  980. <!-- d.top_ent_id = #{entId}-->
  981. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  982. <!-- AND d.contacts_id IN-->
  983. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  984. <!-- #{item}-->
  985. <!-- </foreach>-->
  986. <!-- </if>-->
  987. <!-- )-->
  988. </if>
  989. <if test="type == 2">
  990. and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
  991. <!-- AND (-->
  992. <!-- a.ent_id = #{entId}-->
  993. <!-- <if test="userIds != null and userIds.size()>0">-->
  994. <!-- AND a.create_by IN-->
  995. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  996. <!-- #{item}-->
  997. <!-- </foreach>-->
  998. <!-- </if>-->
  999. <!-- )-->
  1000. <!-- OR (-->
  1001. <!-- d.top_ent_id = #{entId}-->
  1002. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  1003. <!-- AND d.contacts_id IN-->
  1004. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  1005. <!-- #{item}-->
  1006. <!-- </foreach>-->
  1007. <!-- </if>-->
  1008. <!-- )-->
  1009. </if>
  1010. <if test="query.keywords != null and query.keywords != ''">
  1011. and (
  1012. a.t_order_no like concat('%',#{query.keywords},'%')
  1013. or a.l_order_no like concat('%',#{query.keywords},'%')
  1014. or d.firm_name like concat('%',#{query.keywords},'%')
  1015. or e.firm_name like concat('%',#{query.keywords},'%')
  1016. or g.goods_name like concat('%',#{query.keywords},'%'))
  1017. </if>
  1018. <if test="orderList != null and orderList.size() > 0 ">
  1019. and a.status in
  1020. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  1021. #{status}
  1022. </foreach>
  1023. </if>
  1024. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  1025. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  1026. </if>
  1027. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  1028. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  1029. </if>
  1030. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  1031. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  1032. </if>
  1033. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  1034. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  1035. </if>
  1036. <if test="query.createStartTime != null and query.createStartTime != '' ">
  1037. and a.create_time &gt;=#{query.createStartTime}
  1038. </if>
  1039. <if test="query.createEndTime != null and query.createEndTime != ''">
  1040. and a.create_time &lt;=#{query.createEndTime}
  1041. </if>
  1042. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  1043. and b.city_code = #{query.loadAddressCode}
  1044. </if>
  1045. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  1046. and c.city_code = #{query.unloadAddressCode}
  1047. </if>
  1048. <if test="query.billingMode != null and query.billingMode != ''">
  1049. and a.billing_mode =#{query.billingMode}
  1050. </if>
  1051. </where>
  1052. ORDER BY a.create_time DESC
  1053. <!-- ,a.create_time-->
  1054. </select>
  1055. <select id="countLogisticsOrderListByStatus" resultType="com.sckw.mongo.model.TableTops">
  1056. SELECT
  1057. a.`status` AS value ,
  1058. COUNT(a.`status`) AS total
  1059. FROM
  1060. kwt_logistics_order a
  1061. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  1062. AND b.address_type = 1 AND b.del_flag = 0
  1063. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  1064. AND c.address_type = 2 AND c.del_flag = 0
  1065. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  1066. AND d.unit_type = 1 AND d.del_flag = 0
  1067. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  1068. AND e.unit_type = 2
  1069. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  1070. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  1071. <where>
  1072. a.del_flag = 0
  1073. <if test="type == 1">
  1074. and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
  1075. <!-- AND (-->
  1076. <!-- a.ent_id = #{entId}-->
  1077. <!-- <if test="userIds != null and userIds.size()>0">-->
  1078. <!-- AND a.create_by IN-->
  1079. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  1080. <!-- #{item}-->
  1081. <!-- </foreach>-->
  1082. <!-- </if>-->
  1083. <!-- )-->
  1084. <!-- OR (-->
  1085. <!-- d.top_ent_id = #{entId}-->
  1086. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  1087. <!-- AND d.contacts_id IN-->
  1088. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  1089. <!-- #{item}-->
  1090. <!-- </foreach>-->
  1091. <!-- </if>-->
  1092. <!-- )-->
  1093. </if>
  1094. <if test="type == 2">
  1095. and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
  1096. <!-- AND (-->
  1097. <!-- a.ent_id = #{entId}-->
  1098. <!-- <if test="userIds != null and userIds.size()>0">-->
  1099. <!-- AND a.create_by IN-->
  1100. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  1101. <!-- #{item}-->
  1102. <!-- </foreach>-->
  1103. <!-- </if>-->
  1104. <!-- )-->
  1105. <!-- OR (-->
  1106. <!-- d.top_ent_id = #{entId}-->
  1107. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  1108. <!-- AND d.contacts_id IN-->
  1109. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  1110. <!-- #{item}-->
  1111. <!-- </foreach>-->
  1112. <!-- </if>-->
  1113. <!-- )-->
  1114. </if>
  1115. <if test="query.keywords != null and query.keywords != ''">
  1116. and (
  1117. a.t_order_no like concat('%',#{query.keywords},'%')
  1118. or a.l_order_no like concat('%',#{query.keywords},'%')
  1119. or d.firm_name like concat('%',#{query.keywords},'%')
  1120. or e.firm_name like concat('%',#{query.keywords},'%')
  1121. or g.goods_name like concat('%',#{query.keywords},'%'))
  1122. </if>
  1123. <if test="orderList != null and orderList.size() > 0 ">
  1124. and a.status in
  1125. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  1126. #{status}
  1127. </foreach>
  1128. </if>
  1129. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  1130. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  1131. </if>
  1132. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  1133. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  1134. </if>
  1135. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  1136. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  1137. </if>
  1138. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  1139. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  1140. </if>
  1141. <if test="query.createStartTime != null and query.createStartTime != '' ">
  1142. and a.create_time &gt;=#{query.createStartTime}
  1143. </if>
  1144. <if test="query.createEndTime != null and query.createEndTime != ''">
  1145. and a.create_time &lt;=#{query.createEndTime}
  1146. </if>
  1147. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  1148. and b.city_code = #{query.loadAddressCode}
  1149. </if>
  1150. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  1151. and c.city_code = #{query.unloadAddressCode}
  1152. </if>
  1153. </where>
  1154. group by a.status
  1155. </select>
  1156. <select id="countManagementLogisticsOrderListByStatus" resultType="com.sckw.mongo.model.TableTops">
  1157. SELECT
  1158. a.`status` AS value ,
  1159. COUNT(a.`status`) AS total
  1160. FROM
  1161. kwt_logistics_order a
  1162. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  1163. AND b.address_type = 1 AND b.del_flag = 0
  1164. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  1165. AND c.address_type = 2 AND c.del_flag = 0
  1166. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  1167. AND d.unit_type = 1 AND d.del_flag = 0
  1168. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  1169. AND e.unit_type = 2
  1170. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  1171. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  1172. <where>
  1173. a.del_flag = 0
  1174. <if test="type == 1">
  1175. and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
  1176. <!-- AND (-->
  1177. <!-- a.ent_id = #{entId}-->
  1178. <!-- <if test="userIds != null and userIds.size()>0">-->
  1179. <!-- AND a.create_by IN-->
  1180. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  1181. <!-- #{item}-->
  1182. <!-- </foreach>-->
  1183. <!-- </if>-->
  1184. <!-- )-->
  1185. <!-- OR (-->
  1186. <!-- d.top_ent_id = #{entId}-->
  1187. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  1188. <!-- AND d.contacts_id IN-->
  1189. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  1190. <!-- #{item}-->
  1191. <!-- </foreach>-->
  1192. <!-- </if>-->
  1193. <!-- )-->
  1194. </if>
  1195. <if test="type == 2">
  1196. and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
  1197. <!-- AND (-->
  1198. <!-- a.ent_id = #{entId}-->
  1199. <!-- <if test="userIds != null and userIds.size()>0">-->
  1200. <!-- AND a.create_by IN-->
  1201. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  1202. <!-- #{item}-->
  1203. <!-- </foreach>-->
  1204. <!-- </if>-->
  1205. <!-- )-->
  1206. <!-- OR (-->
  1207. <!-- d.top_ent_id = #{entId}-->
  1208. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  1209. <!-- AND d.contacts_id IN-->
  1210. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  1211. <!-- #{item}-->
  1212. <!-- </foreach>-->
  1213. <!-- </if>-->
  1214. <!-- )-->
  1215. </if>
  1216. <if test="query.keywords != null and query.keywords != ''">
  1217. and (
  1218. a.t_order_no like concat('%',#{query.keywords},'%')
  1219. or a.l_order_no like concat('%',#{query.keywords},'%')
  1220. or d.firm_name like concat('%',#{query.keywords},'%')
  1221. or e.firm_name like concat('%',#{query.keywords},'%')
  1222. or g.goods_name like concat('%',#{query.keywords},'%'))
  1223. </if>
  1224. <if test="orderList != null and orderList.size() > 0 ">
  1225. and a.status in
  1226. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  1227. #{status}
  1228. </foreach>
  1229. </if>
  1230. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  1231. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  1232. </if>
  1233. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  1234. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  1235. </if>
  1236. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  1237. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  1238. </if>
  1239. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  1240. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  1241. </if>
  1242. <if test="query.createStartTime != null and query.createStartTime != '' ">
  1243. and a.create_time &gt;=#{query.createStartTime}
  1244. </if>
  1245. <if test="query.createEndTime != null and query.createEndTime != ''">
  1246. and a.create_time &lt;=#{query.createEndTime}
  1247. </if>
  1248. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  1249. and b.city_code = #{query.loadAddressCode}
  1250. </if>
  1251. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  1252. and c.city_code = #{query.unloadAddressCode}
  1253. </if>
  1254. </where>
  1255. group by a.status
  1256. </select>
  1257. <select id="selectCountByLorderId" resultType="java.lang.Integer">
  1258. SELECT COUNT(id)
  1259. FROM kwt_waybill_order
  1260. WHERE del_flag = 0
  1261. and l_order_id = #{orderId}
  1262. <if test="orderStatusList != null and orderStatusList.size() > 0">
  1263. AND status IN
  1264. <foreach collection="orderStatusList" item="item" open="(" close=")" separator=",">
  1265. #{item}
  1266. </foreach>
  1267. </if>
  1268. </select>
  1269. <select id="getMaxOrderNoByDate" resultType="java.lang.String">
  1270. SELECT MAX(l_order_no)
  1271. FROM kwt_logistics_order
  1272. WHERE create_time &gt;= #{date};
  1273. </select>
  1274. <select id="checkLogisticsOrderIsFinishByEntId" resultType="java.lang.String">
  1275. SELECT
  1276. a.l_order_no
  1277. FROM
  1278. kwt_logistics_order a
  1279. INNER JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  1280. AND a.del_flag = 0
  1281. AND b.del_flag = 0
  1282. AND b.unit_type = 1
  1283. INNER JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  1284. AND a.del_flag = 0
  1285. AND c.del_flag = 0
  1286. AND c.unit_type = 2
  1287. <where>
  1288. <if test="consignEntId != null and consignEntId != ''">
  1289. and b.top_ent_id = #{consignEntId}
  1290. </if>
  1291. <if test="acceptCarriageEntId != null and acceptCarriageEntId != ''">
  1292. and c.top_ent_id = #{acceptCarriageEntId}
  1293. </if>
  1294. <if test="orderStatus != null and orderStatus.size() > 0">
  1295. and a.status in
  1296. <foreach collection="orderStatus" separator="," open="(" item="item" close=")">
  1297. #{item}
  1298. </foreach>
  1299. </if>
  1300. </where>
  1301. </select>
  1302. <select id="selectLogisticsOrderListExport"
  1303. resultType="com.sckw.transport.model.vo.execlVo.AcceptCarriageOrderExcelVo">
  1304. SELECT
  1305. <include refid="Query_Column_List">
  1306. </include>
  1307. FROM
  1308. kwt_logistics_order a
  1309. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  1310. AND b.address_type = 1 AND b.del_flag = 0
  1311. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  1312. AND c.address_type = 2 AND c.del_flag = 0
  1313. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  1314. AND d.unit_type = 1 AND d.del_flag = 0
  1315. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  1316. AND e.unit_type = 2
  1317. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  1318. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  1319. <where>
  1320. a.del_flag = 0
  1321. <if test="type == 1">
  1322. and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
  1323. </if>
  1324. <if test="type == 2">
  1325. and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
  1326. </if>
  1327. <if test="query.keywords != null and query.keywords != ''">
  1328. and (
  1329. a.t_order_no like concat('%',#{query.keywords},'%')
  1330. or a.l_order_no like concat('%',#{query.keywords},'%')
  1331. or d.firm_name like concat('%',#{query.keywords},'%')
  1332. or e.firm_name like concat('%',#{query.keywords},'%')
  1333. or g.goods_name like concat('%',#{query.keywords},'%'))
  1334. </if>
  1335. <if test="orderList != null and orderList.size() > 0 ">
  1336. and a.status in
  1337. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  1338. #{status}
  1339. </foreach>
  1340. </if>
  1341. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  1342. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  1343. </if>
  1344. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  1345. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  1346. </if>
  1347. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  1348. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  1349. </if>
  1350. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  1351. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  1352. </if>
  1353. <if test="query.createStartTime != null and query.createStartTime != '' ">
  1354. and a.create_time &gt;=#{query.createStartTime}
  1355. </if>
  1356. <if test="query.createEndTime != null and query.createEndTime != ''">
  1357. and a.create_time &lt;=#{query.createEndTime}
  1358. </if>
  1359. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  1360. and b.city_code = #{query.loadAddressCode}
  1361. </if>
  1362. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  1363. and c.city_code = #{query.unloadAddressCode}
  1364. </if>
  1365. <if test="query.billingMode != null and query.billingMode != ''">
  1366. and a.billing_mode =#{query.billingMode}
  1367. </if>
  1368. </where>
  1369. ORDER BY a.id DESC
  1370. <!-- ,a.create_time-->
  1371. </select>
  1372. <select id="selectConsignLogisticsOrderList" resultType="com.sckw.transport.model.vo.ConsignOrderVO">
  1373. SELECT
  1374. <include refid="Query_Column_List">
  1375. </include>
  1376. FROM
  1377. kwt_logistics_order a
  1378. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  1379. AND b.address_type = 1 AND b.del_flag = 0
  1380. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  1381. AND c.address_type = 2 AND c.del_flag = 0
  1382. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  1383. AND d.unit_type = 1 AND d.del_flag = 0
  1384. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  1385. AND e.unit_type = 2
  1386. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  1387. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  1388. <where>
  1389. a.del_flag = 0
  1390. <if test="type == 1">
  1391. and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
  1392. <!-- AND (-->
  1393. <!-- a.ent_id = #{entId}-->
  1394. <!-- <if test="userIds != null and userIds.size()>0">-->
  1395. <!-- AND a.create_by IN-->
  1396. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  1397. <!-- #{item}-->
  1398. <!-- </foreach>-->
  1399. <!-- </if>-->
  1400. <!-- )-->
  1401. <!-- OR (-->
  1402. <!-- d.top_ent_id = #{entId}-->
  1403. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  1404. <!-- AND d.contacts_id IN-->
  1405. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  1406. <!-- #{item}-->
  1407. <!-- </foreach>-->
  1408. <!-- </if>-->
  1409. <!-- )-->
  1410. </if>
  1411. <if test="type == 2">
  1412. and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
  1413. <!-- AND (-->
  1414. <!-- a.ent_id = #{entId}-->
  1415. <!-- <if test="userIds != null and userIds.size()>0">-->
  1416. <!-- AND a.create_by IN-->
  1417. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  1418. <!-- #{item}-->
  1419. <!-- </foreach>-->
  1420. <!-- </if>-->
  1421. <!-- )-->
  1422. <!-- OR (-->
  1423. <!-- d.top_ent_id = #{entId}-->
  1424. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  1425. <!-- AND d.contacts_id IN-->
  1426. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  1427. <!-- #{item}-->
  1428. <!-- </foreach>-->
  1429. <!-- </if>-->
  1430. <!-- )-->
  1431. </if>
  1432. <if test="query.keywords != null and query.keywords != ''">
  1433. and (
  1434. a.t_order_no like concat('%',#{query.keywords},'%')
  1435. or a.l_order_no like concat('%',#{query.keywords},'%')
  1436. or d.firm_name like concat('%',#{query.keywords},'%')
  1437. or e.firm_name like concat('%',#{query.keywords},'%')
  1438. or g.goods_name like concat('%',#{query.keywords},'%'))
  1439. </if>
  1440. <if test="orderList != null and orderList.size() > 0 ">
  1441. and a.status in
  1442. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  1443. #{status}
  1444. </foreach>
  1445. </if>
  1446. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  1447. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  1448. </if>
  1449. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  1450. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  1451. </if>
  1452. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  1453. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  1454. </if>
  1455. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  1456. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  1457. </if>
  1458. <if test="query.createStartTime != null and query.createStartTime != '' ">
  1459. and a.create_time &gt;=#{query.createStartTime}
  1460. </if>
  1461. <if test="query.createEndTime != null and query.createEndTime != ''">
  1462. and a.create_time &lt;=#{query.createEndTime}
  1463. </if>
  1464. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  1465. and b.city_code = #{query.loadAddressCode}
  1466. </if>
  1467. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  1468. and c.city_code = #{query.unloadAddressCode}
  1469. </if>
  1470. <if test="query.billingMode != null and query.billingMode != ''">
  1471. and a.billing_mode =#{query.billingMode}
  1472. </if>
  1473. </where>
  1474. ORDER BY a.id DESC
  1475. <!-- ,a.create_time-->
  1476. </select>
  1477. <select id="statisticsWaybillSendCar" resultType="java.lang.Integer">
  1478. SELECT
  1479. COUNT(b.id)
  1480. FROM
  1481. kwt_waybill_order b
  1482. LEFT JOIN kwt_logistics_order a ON a.id = b.l_order_id
  1483. WHERE
  1484. a.del_flag = 0
  1485. AND b.del_flag = 0
  1486. <if test="ids != null and ids.size()>0">
  1487. and a.id in
  1488. <foreach collection="ids" open="(" close=")" separator="," item="item">
  1489. #{item}
  1490. </foreach>
  1491. </if>
  1492. <if test="orderList != null and orderList.size()>0">
  1493. and b.status in
  1494. <foreach collection="orderList" item="item" separator="," close=")" open="(">
  1495. #{item}
  1496. </foreach>
  1497. </if>
  1498. </select>
  1499. <select id="statisticsLogistics" resultType="java.lang.Long">
  1500. SELECT DISTINCT a.id
  1501. FROM kwt_logistics_order a
  1502. LEFT JOIN kwt_logistics_order_unit b ON b.l_order_id = a.id
  1503. WHERE a.del_flag = 0
  1504. AND b.del_flag = 0
  1505. AND (b.ent_id = #{topEntId} OR b.top_ent_id = #{topEntId})
  1506. </select>
  1507. <select id="statisticsLogisticsByTopEntIdAndOrderStatus" resultType="java.lang.Integer">
  1508. SELECT
  1509. count(DISTINCT a.id)
  1510. FROM
  1511. kwt_logistics_order a
  1512. LEFT JOIN kwt_logistics_order_unit b ON b.l_order_id = a.id
  1513. WHERE
  1514. a.del_flag = 0
  1515. AND b.del_flag = 0
  1516. AND ( b.ent_id = #{topEntId} OR b.top_ent_id = #{topEntId} )
  1517. And a.status in
  1518. <foreach collection="orderList" open="(" close=")" separator="," item="item">
  1519. #{item}
  1520. </foreach>
  1521. </select>
  1522. <select id="selectAcceptCarriageFinishOrder" resultType="com.sckw.transport.model.vo.StatisticsByOrderVO">
  1523. SELECT
  1524. IFNULL( SUM( t1.WaitingAmount ), 0 ) AS WaitingAmount ,
  1525. IFNULL( SUM( t1.amount ), 0 ) AS amount ,
  1526. IFNULL( SUM( t1.entrustAmount ), 0 ) AS entrustAmount ,
  1527. IFNULL( SUM( t1.subcontractAmount ), 0 ) AS subcontractAmount ,
  1528. IFNULL( SUM( t1.totalPrice ), 0 ) AS totalPrice
  1529. FROM
  1530. (
  1531. SELECT
  1532. ( a.amount - IFNULL(a.total_load_amount,0)) AS WaitingAmount,
  1533. a.amount,
  1534. a.entrust_amount AS entrustAmount,
  1535. a.subcontract_amount AS subcontractAmount,
  1536. a.price ,
  1537. a.amount * IFNULL(a.price,0) AS totalPrice
  1538. FROM
  1539. kwt_logistics_order a
  1540. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  1541. AND a.del_flag = 0
  1542. AND b.del_flag = 0
  1543. WHERE
  1544. b.unit_type = #{unitType}
  1545. <if test="topId != null and topId !=''">
  1546. and b.top_ent_id = #{topId}
  1547. </if>
  1548. <if test="statusList != null and statusList.size()>0">
  1549. and a.`status` IN
  1550. <foreach collection="statusList" item="item" separator="," open="(" close=")">
  1551. #{item}
  1552. </foreach>
  1553. </if>
  1554. <if test="dateStart != null and dateStart != ''">
  1555. and a.create_time &gt;= #{dateStart,jdbcType=TIMESTAMP}
  1556. </if>
  1557. <if test="dateEnd != null and dateEnd != ''">
  1558. and a.create_time &lt;= #{dateEnd,jdbcType=TIMESTAMP}
  1559. </if>
  1560. ) t1
  1561. </select>
  1562. <select id="selectStatisticsByOrder" resultType="com.sckw.transport.model.vo.StatisticsByOrderVO">
  1563. SELECT
  1564. IFNULL( SUM( t1.WaitingAmount ), 0 ) AS WaitingAmount ,
  1565. IFNULL( SUM( t1.amount ), 0 ) AS amount ,
  1566. IFNULL( SUM( t1.entrustAmount ), 0 ) AS entrustAmount ,
  1567. IFNULL( SUM( t1.subcontractAmount ), 0 ) AS subcontractAmount ,
  1568. IFNULL( SUM( t1.totalPrice ), 0 ) AS totalPrice
  1569. FROM
  1570. (
  1571. SELECT
  1572. ( a.amount - a.entrust_amount - a.subcontract_amount ) AS WaitingAmount,
  1573. a.amount,
  1574. a.entrust_amount AS entrustAmount,
  1575. a.subcontract_amount AS subcontractAmount,
  1576. a.price ,
  1577. a.amount * IFNULL(a.price,0) AS totalPrice
  1578. FROM
  1579. kwt_logistics_order a
  1580. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  1581. AND a.del_flag = 0
  1582. AND b.del_flag = 0
  1583. WHERE
  1584. b.unit_type = #{unitType}
  1585. <if test="topId != null and topId !=''">
  1586. and b.top_ent_id = #{topId}
  1587. </if>
  1588. <if test="statusList != null and statusList.size()>0">
  1589. and a.`status` IN
  1590. <foreach collection="statusList" item="item" separator="," open="(" close=")">
  1591. #{item}
  1592. </foreach>
  1593. </if>
  1594. <if test="dateStart != null and dateStart != ''">
  1595. and a.create_time &gt;= #{dateStart,jdbcType=TIMESTAMP}
  1596. </if>
  1597. <if test="dateEnd != null and dateEnd != ''">
  1598. and a.create_time &lt;= #{dateEnd,jdbcType=TIMESTAMP}
  1599. </if>
  1600. ) t1
  1601. </select>
  1602. <select id="selectAcceptCarriageAwaitFinishOrder" resultType="com.sckw.transport.model.vo.StatisticsByOrderVO">
  1603. SELECT
  1604. IFNULL( SUM( t1.WaitingAmount ), 0 ) AS WaitingAmount ,
  1605. IFNULL( SUM( t1.amount ), 0 ) AS amount ,
  1606. IFNULL( SUM( t1.entrustAmount ), 0 ) AS entrustAmount ,
  1607. IFNULL( SUM( t1.subcontractAmount ), 0 ) AS subcontractAmount ,
  1608. IFNULL( SUM( t1.totalPrice ), 0 ) AS totalPrice
  1609. FROM
  1610. (
  1611. SELECT
  1612. ( a.amount - a.entrust_amount - a.subcontract_amount) AS WaitingAmount,
  1613. a.amount,
  1614. a.entrust_amount AS entrustAmount,
  1615. a.subcontract_amount AS subcontractAmount,
  1616. a.price ,
  1617. a.amount * IFNULL(a.price,0) AS totalPrice
  1618. FROM
  1619. kwt_logistics_order a
  1620. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  1621. AND a.del_flag = 0
  1622. AND b.del_flag = 0
  1623. WHERE
  1624. b.unit_type = #{unitType}
  1625. <if test="topId != null and topId !=''">
  1626. and b.top_ent_id = #{topId}
  1627. </if>
  1628. <if test="statusList != null and statusList.size()>0">
  1629. and a.`status` IN
  1630. <foreach collection="statusList" item="item" separator="," open="(" close=")">
  1631. #{item}
  1632. </foreach>
  1633. </if>
  1634. <if test="dateStart != null and dateStart != ''">
  1635. and a.create_time &gt;= #{dateStart,jdbcType=TIMESTAMP}
  1636. </if>
  1637. <if test="dateEnd != null and dateEnd != ''">
  1638. and a.create_time &lt;= #{dateEnd,jdbcType=TIMESTAMP}
  1639. </if>
  1640. ) t1
  1641. </select>
  1642. </mapper>