KwtLogisticsOrderMapper.xml 114 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617
  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
  101. WHERE a.del_flag = '0'
  102. AND b.del_flag = '0'
  103. <if test="type != null and type != ''">
  104. AND c.unit_type = #{type}
  105. </if>
  106. AND a.t_order_id = #{id,jdbcType=VARCHAR}
  107. order by createTime desc
  108. </select>
  109. <select id="selectOrderListNotPageByIds" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
  110. SELECT a.id as lOrderId,
  111. a.l_order_no as lOrderNo,
  112. b.`status` as `status`,
  113. a.t_order_id as tOrderId,
  114. a.t_order_no as tOrderNo,
  115. a.payment as payment,
  116. a.amount,
  117. a.unit as unit,
  118. a.price,
  119. a.price_type as priceType,
  120. a.loss,
  121. a.loss_unit AS lossUnit,
  122. a.goods_price as goodsPrice,
  123. a.goods_price_unit as goodsPriceUnit,
  124. c.firm_name as companyName,
  125. c.contacts,
  126. c.phone,
  127. a.create_by as createBy,
  128. a.create_time as createTime
  129. FROM kwt_logistics_order a
  130. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
  131. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  132. WHERE a.del_flag = '0'
  133. AND b.del_flag = '0'
  134. <if test="type != null and type != ''">
  135. AND c.unit_type = #{type}
  136. </if>
  137. <if test="ids != null and ids.size() > 0">
  138. AND a.t_order_id in
  139. <foreach collection="ids" separator="," open="(" close=")" item="item">
  140. #{item}
  141. </foreach>
  142. </if>
  143. order by createTime desc
  144. </select>
  145. <select id="selectOrderListByTradeOrderIds" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
  146. SELECT a.id as lOrderId,
  147. a.l_order_no as lOrderNo,
  148. a.`status` as `status`,
  149. a.t_order_id as tOrderId,
  150. a.t_order_no as tOrderNo,
  151. a.payment as payment,
  152. a.amount,
  153. a.unit as unit,
  154. a.price,
  155. a.price_type as priceType,
  156. a.loss,
  157. a.loss_unit AS lossUnit,
  158. a.goods_price as goodsPrice,
  159. a.goods_price_unit as goodsPriceUnit,
  160. c.firm_name as companyName,
  161. c.contacts,
  162. c.phone,
  163. a.create_by as createBy,
  164. a.create_time as createTime
  165. FROM kwt_logistics_order a
  166. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  167. WHERE a.del_flag = '0'
  168. AND c.del_flag = '0'
  169. <if test="unitType != null and unitType != ''">
  170. AND c.unit_type = #{unitType}
  171. </if>
  172. <if test="tradeOrderIds != null and tradeOrderIds.size()>0">
  173. and a.t_order_id in
  174. <foreach collection="tradeOrderIds" item="item" separator="," open="(" close=")">
  175. #{item}
  176. </foreach>
  177. </if>
  178. order by tOrderId,createTime desc
  179. </select>
  180. <select id="selectOrderListByContractId" resultType="com.sckw.transport.model.vo.SckwLogisticsOrderVO">
  181. SELECT
  182. a.STATUS,
  183. a.id AS lOrderId,
  184. a.l_order_no AS lOrderNo,
  185. f.contract_no AS contractNo,
  186. d.id as checkId,
  187. d.ent_id as checkEntId,
  188. d.top_ent_id as checkTopEntId,
  189. d.firm_name AS checkFirmName,
  190. e.id as carrierId,
  191. e.ent_id as carrierEntId,
  192. e.top_ent_id as carrierTopEntId,
  193. e.firm_name AS carrierFirmName,
  194. g.goods_name AS goodsName,
  195. a.amount AS carryingCapacity,
  196. a.price AS price,
  197. b.city_name AS loadCityName,
  198. b.detail_address AS loadDetailAddress,
  199. a.payment AS payment,
  200. a.loss AS loss,
  201. a.loss_unit AS lossUnit,
  202. a.goods_price AS goodsPrice,
  203. a.goods_price_unit AS goodsPriceUnit,
  204. a.settlement_cycle AS settlementCycle,
  205. e.contacts AS carrierContacts,
  206. e.phone AS carrierPhone,
  207. d.contacts AS checkContacts,
  208. d.phone AS checkPhone,
  209. b.contacts AS loadContacts,
  210. b.phone AS loadPhone,
  211. c.contacts AS unloadContacts,
  212. c.phone AS unloadPhone,
  213. a.start_time AS startTime,
  214. a.end_time AS endTime,
  215. a.remark AS remark,
  216. a.create_by AS createBy,
  217. a.create_time AS createTime,
  218. f.contract_id AS contractId,
  219. a.amount AS amount,
  220. c.detail_address as unloadDetailAddress,
  221. a.billing_mode as billingMode
  222. FROM
  223. kwt_logistics_order a
  224. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  225. AND b.address_type = 1
  226. AND b.del_flag = 0
  227. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  228. AND c.address_type = 2
  229. AND c.del_flag = 0
  230. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  231. AND d.unit_type = 1
  232. AND d.del_flag = 0
  233. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  234. AND e.unit_type = 2
  235. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id
  236. AND g.del_flag = 0
  237. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id
  238. AND f.del_flag = 0
  239. <where>
  240. a.del_flag = 0
  241. <!-- <if test="type == 1">-->
  242. <!-- and (d.top_ent_id = #{entId} or d.ent_id = #{entId})-->
  243. <!-- </if>-->
  244. <!-- <if test="type == 2">-->
  245. <!-- and (e.top_ent_id = #{entId} or e.ent_id = #{entId})-->
  246. <!-- </if>-->
  247. <if test="contractIds != null and contractIds.size() > 0">
  248. and f.contract_id in
  249. <foreach collection="contractIds" item="item" separator="," open="(" close=")">
  250. #{item}
  251. </foreach>
  252. </if>
  253. </where>
  254. ORDER BY a.id DESC
  255. </select>
  256. <select id="selectOrderCount" resultType="java.lang.Long">
  257. SELECT count(a.id)
  258. FROM kwt_logistics_order a
  259. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
  260. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  261. WHERE a.del_flag = '0'
  262. AND b.del_flag = '0'
  263. AND a.t_order_id = #{id,jdbcType=VARCHAR}
  264. </select>
  265. <select id="selectLogisticOrderData" resultType="com.sckw.transport.api.model.vo.LogisticsOrderVO">
  266. SELECT
  267. DISTINCT a.id AS lOrderId,
  268. a.l_order_no AS lOrderNO,
  269. a.t_order_id AS tOrderId,
  270. a.t_order_no AS tOrderNO,
  271. a.payment AS payment,
  272. a.billing_mode AS billingMode,
  273. c.contract_id AS contractId,
  274. c.contract_no AS contractNo,
  275. c.contract_name AS contractName,
  276. b.goods_name AS goodsName,
  277. a.amount,
  278. a.remark as remark,
  279. a.unit ,
  280. a.ignore_amount AS ignoreAmount,
  281. a.price,
  282. a.price_type as priceType,
  283. a.goods_price AS goodsPrice,
  284. a.goods_price_unit AS goodsPriceUnit,
  285. a.loss,
  286. a.loss_unit AS lossUnit,
  287. a.tax_rate as taxRate,
  288. a.load_amount AS loadAmount,
  289. a.unload_amount AS unloadAmount,
  290. a.total_load_amount AS totalLoadAmount,
  291. a.total_unload_amount AS totalUnloadAmount,
  292. a.settlement_cycle as settlementCycle,
  293. a.start_time AS startTime,
  294. a.end_time AS endTime,
  295. a.create_time AS createTime,
  296. a.create_by AS createBy,
  297. a.update_by AS updateBy,
  298. a.update_time AS updateTime
  299. FROM
  300. kwt_logistics_order a
  301. LEFT JOIN kwt_logistics_order_goods b ON a.id = b.l_order_id and a.bind_status = '0'
  302. <!-- LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id-->
  303. LEFT JOIN kwt_logistics_order_contract c ON a.id = c.l_order_id
  304. <!-- 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-->
  305. <!-- 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-->
  306. LEFT JOIN kwt_logistics_order_unit g on a.id = g.l_order_id and g.unit_type= 1
  307. LEFT JOIN kwt_logistics_order_unit h on a.id = h.l_order_id and h.unit_type= 2
  308. <where>
  309. a.del_flag = 0 and a.bind_status = '0' <!--and d.unit_type = 1-->
  310. <if test="dictValue != null and dictValue != ''">
  311. AND a.payment = #{dictValue}
  312. </if>
  313. <if test="logisticsOrderParam.companyId !=null and logisticsOrderParam.companyId != ''">
  314. <!-- AND d.ent_id = #{logisticsOrderParam.companyId}-->
  315. AND g.ent_id = #{logisticsOrderParam.companyId}
  316. </if>
  317. <if test="ids !=null and ids.size() > 0 ">
  318. AND ( h.ent_id in
  319. <foreach collection="ids" open="(" close=")" separator="," item="item">
  320. #{item}
  321. </foreach>
  322. or h.top_ent_id in
  323. <foreach collection="ids" item="item" separator="," close=")" open="(">
  324. #{item}
  325. </foreach>
  326. )
  327. </if>
  328. <if test="logisticsOrderParam.taxRate != null and logisticsOrderParam.taxRate != ''">
  329. AND a.tax_rate = #{logisticsOrderParam.taxRate}
  330. </if>
  331. <if test="logisticsOrderParam.goodsName != null and logisticsOrderParam.goodsName != ''">
  332. AND b.goods_name LIKE concat('%',#{logisticsOrderParam.goodsName},'%')
  333. </if>
  334. <if test="logisticsOrderParam.startTime != null and logisticsOrderParam.startTime !=''">
  335. AND a.start_time &gt;= #{logisticsOrderParam.startTime}
  336. </if>
  337. <if test="logisticsOrderParam.endTime != null and logisticsOrderParam.endTime !=''">
  338. AND a.end_time &lt;= #{logisticsOrderParam.endTime}
  339. </if>
  340. <if test="orderStatusList != null and orderStatusList.size()>0">
  341. and a.status in
  342. <foreach collection="orderStatusList" separator="," open="(" close=")" item="item" >
  343. #{item,jdbcType=INTEGER}
  344. </foreach>
  345. </if>
  346. </where>
  347. ORDER BY a.create_time DESC
  348. <if test="logisticsOrderParam.page != null and logisticsOrderParam.pageSize != null ">
  349. limit #{logisticsOrderParam.page,jdbcType=INTEGER},#{logisticsOrderParam.pageSize,jdbcType=INTEGER}
  350. </if>
  351. </select>
  352. <select id="selectLogisticOrderCount" resultType="java.lang.Long">
  353. SELECT
  354. count(a.id)
  355. FROM
  356. kwt_logistics_order a
  357. LEFT JOIN kwt_logistics_order_goods b ON a.id = b.l_order_id
  358. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  359. LEFT JOIN kwt_logistics_order_unit h ON a.id = h.l_order_id
  360. LEFT JOIN kwt_logistics_order_contract c ON a.id=c.l_order_id
  361. <where>
  362. a.del_flag = 0 and d.unit_type = 1 and h.unit_type = 2 and a.bind_status='0'
  363. <if test="dictValue != null and dictValue != ''">
  364. AND a.payment = #{dictValue}
  365. </if>
  366. <if test="logisticsOrderParam.companyId !=null and logisticsOrderParam.companyId != ''">
  367. AND d.ent_id = #{logisticsOrderParam.companyId}
  368. </if>
  369. <if test="ids !=null and ids.size() > 0 ">
  370. AND ( h.ent_id in
  371. <foreach collection="ids" open="(" close=")" separator="," item="item">
  372. #{item}
  373. </foreach>
  374. or h.top_ent_id in
  375. <foreach collection="ids" item="item" separator="," close=")" open="(">
  376. #{item}
  377. </foreach>
  378. )
  379. </if>
  380. <if test="logisticsOrderParam.taxRate != null and logisticsOrderParam.taxRate != ''">
  381. AND a.tax_rate = #{logisticsOrderParam.taxRate}
  382. </if>
  383. <if test="logisticsOrderParam.goodsName != null and logisticsOrderParam.goodsName != ''">
  384. AND b.goods_name LIKE concat('%',#{logisticsOrderParam.goodsName},'%')
  385. </if>
  386. <if test="logisticsOrderParam.startTime != null and logisticsOrderParam.startTime !=''">
  387. AND a.start_time &gt;= #{logisticsOrderParam.startTime}
  388. </if>
  389. <if test="logisticsOrderParam.endTime != null and logisticsOrderParam.endTime !=''">
  390. AND a.end_time &lt;= #{logisticsOrderParam.endTime}
  391. </if>
  392. <if test="orderStatusList != null and orderStatusList.size()>0">
  393. and a.status in
  394. <foreach collection="orderStatusList" item="item" close=")" open="(" separator=",">
  395. #{item,jdbcType=INTEGER}
  396. </foreach>
  397. </if>
  398. </where>
  399. ORDER BY a.create_time DESC
  400. </select>
  401. <select id="getRejectReason" resultType="java.util.Map">
  402. SELECT a.id AS lOrderId,
  403. b.remark remark
  404. FROM kwt_logistics_order a
  405. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id
  406. WHERE a.del_flag = '0'
  407. AND b.del_flag = '0'
  408. and b.status = #{status}
  409. and a.id = #{id}
  410. </select>
  411. <select id="getSubcontractConsignment" resultType="com.sckw.transport.model.vo.SubcontractConsignmentVO">
  412. SELECT a.id,
  413. a.pid,
  414. a.`status` as status,
  415. a.l_order_no as consignOrderNo,
  416. c.firm_name as carrierContacts,
  417. d.goods_name as goodsName,
  418. a.amount as amount,
  419. a.price,
  420. a.price_type as priceType,
  421. e.detail_address as loadAddress,
  422. f.detail_address as unloadAddress,
  423. a.billing_mode as billingMode,
  424. a.loss,
  425. a.loss_unit as lossUnit,
  426. a.goods_price as goodsPrice,
  427. a.goods_price_unit as goodsPriceUnit,
  428. a.settlement_cycle as settlementCycle,
  429. c.contacts as carrierContacts,
  430. c.phone as carrierPhone,
  431. b.firm_name as consignCompany,
  432. b.contacts as consignContacts,
  433. b.phone as consignPhone,
  434. e.contacts as loadContacts,
  435. e.phone as loadContacts,
  436. f.contacts as unloadContacts,
  437. f.phone as unloadPhone,
  438. a.start_time as shipmentsDate,
  439. a.end_time as receiveGoodsDate,
  440. a.remark,
  441. a.create_by as createBy,
  442. a.create_time as createTime,
  443. g.contract_id as contractId
  444. FROM kwt_logistics_order a
  445. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  446. AND b.unit_type = 1
  447. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  448. AND c.unit_type = 2
  449. LEFT JOIN kwt_logistics_order_goods d ON a.id = d.l_order_id
  450. LEFT JOIN kwt_logistics_order_address e ON a.id = e.l_order_id
  451. AND e.address_type = 1
  452. LEFT JOIN kwt_logistics_order_address f ON a.id = f.l_order_id
  453. AND f.address_type = 2
  454. LEFT JOIN kwt_logistics_order_contract g ON a.id = g.l_order_id
  455. WHERE a.del_flag = 0
  456. AND b.del_flag = 0
  457. AND c.del_flag = 0
  458. AND e.del_flag = 0
  459. AND f.del_flag = 0
  460. and a.pid = #{lOrderId}
  461. ORDER BY a.create_time
  462. limit #{page}, #{pageSize}
  463. </select>
  464. <select id="getSubcontractConsignmentList" resultType="com.sckw.transport.model.vo.SubcontractConsignmentVO">
  465. SELECT a.id,
  466. a.pid,
  467. a.`status` as status,
  468. a.l_order_no as consignOrderNo,
  469. <!-- a.l_order_no as carrierOrderNo,-->
  470. c.firm_name as carrierCompany,
  471. d.goods_name as goodsName,
  472. a.amount as carryingCapacity,
  473. a.price,
  474. a.price_type as priceType,
  475. e.detail_address as loadAddress,
  476. f.detail_address as unloadAddress,
  477. a.billing_mode as billingMode,
  478. a.loss,
  479. a.tax_rate as taxRate,
  480. a.loss_unit as lossUnit,
  481. a.goods_price as goodsPrice,
  482. a.goods_price_unit as goodsPriceUnit,
  483. a.settlement_cycle as settlementCycle,
  484. c.contacts as carrierContacts,
  485. c.phone as carrierPhone,
  486. b.firm_name as consignCompany,
  487. b.contacts as consignContacts,
  488. b.phone as consignPhone,
  489. e.contacts as loadContacts,
  490. e.phone as loadPhone,
  491. f.contacts as unloadContacts,
  492. f.phone as unloadPhone,
  493. a.start_time as shipmentsDate,
  494. a.end_time as receiveGoodsDate,
  495. a.remark,
  496. a.create_by as createBy,
  497. a.create_time as createTime,
  498. g.contract_id as contractId,
  499. g.contract_no as contractNo,
  500. g.contract_name as contractName,
  501. g.signing_way as signing,
  502. e.city_name as loadCityName,
  503. f.city_name as unloadCityName,
  504. e.name as loadName,
  505. f.name as unloadName,
  506. a.type as orderSource
  507. FROM kwt_logistics_order a
  508. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  509. AND b.unit_type = 1
  510. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  511. AND c.unit_type = 2
  512. LEFT JOIN kwt_logistics_order_goods d ON a.id = d.l_order_id
  513. LEFT JOIN kwt_logistics_order_address e ON a.id = e.l_order_id
  514. AND e.address_type = 1
  515. LEFT JOIN kwt_logistics_order_address f ON a.id = f.l_order_id
  516. AND f.address_type = 2
  517. LEFT JOIN kwt_logistics_order_contract g ON a.id = g.l_order_id
  518. WHERE a.del_flag = 0
  519. AND b.del_flag = 0
  520. AND c.del_flag = 0
  521. AND e.del_flag = 0
  522. AND f.del_flag = 0
  523. <if test="lOrderIds != null and lOrderIds.size() > 0">
  524. and a.pid in
  525. <foreach collection="lOrderIds" item="item" close=")" open="(" separator=",">
  526. #{item,jdbcType=BIGINT}
  527. </foreach>
  528. </if>
  529. <!-- ORDER BY a.id desc-->
  530. ORDER BY a.create_time desc
  531. </select>
  532. <select id="getSubcontractConsignmentNotPage" resultType="com.sckw.transport.model.vo.SubcontractConsignmentVO">
  533. SELECT a.id,
  534. a.pid,
  535. a.`status` as status,
  536. a.l_order_no as consignOrderNo,
  537. <!-- a.l_order_no as carrierOrderNo,-->
  538. c.firm_name as carrierCompany,
  539. d.goods_name as goodsName,
  540. a.amount as carryingCapacity,
  541. a.price,
  542. a.price_type as priceType,
  543. e.detail_address as loadAddress,
  544. f.detail_address as unloadAddress,
  545. a.billing_mode as billingMode,
  546. a.loss,
  547. a.loss_unit as lossUnit,
  548. a.goods_price as goodsPrice,
  549. a.goods_price_unit as goodsPriceUnit,
  550. a.settlement_cycle as settlementCycle,
  551. c.contacts as carrierContacts,
  552. c.phone as carrierPhone,
  553. b.firm_name as consignCompany,
  554. b.contacts as consignContacts,
  555. b.phone as consignPhone,
  556. e.contacts as loadContacts,
  557. e.phone as loadPhone,
  558. f.contacts as unloadContacts,
  559. f.phone as unloadPhone,
  560. a.start_time as shipmentsDate,
  561. a.end_time as receiveGoodsDate,
  562. a.remark,
  563. a.create_by as createBy,
  564. a.create_time as createTime,
  565. g.contract_id as contractId,
  566. g.contract_no as contractNo,
  567. g.contract_name as contractName,
  568. g.signing_way as signing,
  569. e.city_name as loadCityName,
  570. f.city_name as unloadCityName
  571. FROM kwt_logistics_order a
  572. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  573. AND b.unit_type = 1
  574. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  575. AND c.unit_type = 2
  576. LEFT JOIN kwt_logistics_order_goods d ON a.id = d.l_order_id
  577. LEFT JOIN kwt_logistics_order_address e ON a.id = e.l_order_id
  578. AND e.address_type = 1
  579. LEFT JOIN kwt_logistics_order_address f ON a.id = f.l_order_id
  580. AND f.address_type = 2
  581. LEFT JOIN kwt_logistics_order_contract g ON a.id = g.l_order_id
  582. WHERE a.del_flag = 0
  583. AND b.del_flag = 0
  584. AND c.del_flag = 0
  585. AND e.del_flag = 0
  586. AND f.del_flag = 0
  587. and a.pid = #{lOrderId}
  588. ORDER BY a.create_time desc
  589. </select>
  590. <select id="countSubcontractConsignmentById" resultType="java.util.Map">
  591. SELECT COUNT(0) as total,
  592. a.id,
  593. a.pid,
  594. a.`status` as status,
  595. a.l_order_no as consignOrderNo,
  596. c.firm_name as carrierContacts,
  597. d.goods_name as goodsName,
  598. a.amount as amount,
  599. a.price,
  600. a.price_type as priceType,
  601. e.detail_address as loadAddress,
  602. f.detail_address as unloadAddress,
  603. a.billing_mode as billingMode,
  604. a.loss,
  605. a.loss_unit as lossUnit,
  606. a.goods_price as goodsPrice,
  607. a.goods_price_unit as goodsPriceUnit,
  608. a.settlement_cycle as settlementCycle,
  609. c.contacts as carrierContacts,
  610. c.phone as carrierPhone,
  611. b.firm_name as consignCompany,
  612. b.contacts as consignContacts,
  613. b.phone as consignPhone,
  614. e.contacts as loadContacts,
  615. e.phone as loadContacts,
  616. f.contacts as unloadContacts,
  617. f.phone as unloadPhone,
  618. a.start_time as shipmentsDate,
  619. a.end_time as receiveGoodsDate,
  620. a.remark,
  621. a.create_by as createBy,
  622. a.create_time as createTime,
  623. g.contract_id as contractId
  624. FROM kwt_logistics_order a
  625. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  626. AND b.unit_type = 1
  627. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  628. AND c.unit_type = 2
  629. LEFT JOIN kwt_logistics_order_goods d ON a.id = d.l_order_id
  630. LEFT JOIN kwt_logistics_order_address e ON a.id = e.l_order_id
  631. AND e.address_type = 1
  632. LEFT JOIN kwt_logistics_order_address f ON a.id = f.l_order_id
  633. AND f.address_type = 2
  634. LEFT JOIN kwt_logistics_order_contract g ON a.id = g.l_order_id
  635. WHERE a.del_flag = 0
  636. AND b.del_flag = 0
  637. AND c.del_flag = 0
  638. AND e.del_flag = 0
  639. AND f.del_flag = 0
  640. and a.pid = #{lOrderId}
  641. ORDER BY a.create_time
  642. </select>
  643. <select id="selectDriverListById" resultType="com.sckw.transport.model.vo.DriverListVo">
  644. SELECT COUNT( b.truck_no ) AS count,
  645. a.id AS lOrderId,
  646. a.l_order_no AS lOrderNo,
  647. b.driver_id AS driverId,
  648. b.id AS wOrderId,
  649. b.w_order_no AS wOrderNo,
  650. b.driver_name AS driverName,
  651. b.driver_phone AS driverPhone,
  652. b.driver_idcard AS driverIdCard,
  653. b.truck_no AS truckNo,
  654. b.status AS status
  655. FROM
  656. kwt_waybill_order b
  657. LEFT JOIN kwt_logistics_order a ON b.l_order_id = a.id
  658. <!-- SELECT a.id AS lOrderId,-->
  659. <!-- a.l_order_no AS lOrderNo,-->
  660. <!-- b.driver_id AS driverId,-->
  661. <!-- b.id AS wOrderId,-->
  662. <!-- b.w_order_no AS wOrderNo,-->
  663. <!-- b.driver_name AS driverName,-->
  664. <!-- b.driver_phone AS driverPhone,-->
  665. <!-- b.driver_idcard AS driverIdCard,-->
  666. <!-- b.truck_no AS truckNo-->
  667. <!-- ,-->
  668. <!-- COUNT( b.id ) AS count-->
  669. <!-- FROM-->
  670. <!-- kwt_waybill_order b,-->
  671. <!-- kwt_logistics_order a-->
  672. <where>
  673. a.id = b.l_order_id
  674. AND a.del_flag = 0
  675. AND b.del_flag = 0
  676. AND b.type = '1'
  677. AND b.status = 1
  678. <if test="driverParam.lOrderId != null and driverParam.lOrderId != ''">
  679. AND a.id =#{driverParam.lOrderId}
  680. </if>
  681. <if test="driverParam.driverName != null and driverParam.driverName != '' or ( driverParam.driverPhone != null and driverParam.driverPhone != '' ) or ( driverParam.truckNo != null and driverParam.truckNo != '' ) ">
  682. <!-- and (-->
  683. <if test="driverParam.driverName != null and driverParam.driverName != ''">
  684. and b.driver_name like concat('%',#{driverParam.driverName},'%')
  685. </if>
  686. <if test="driverParam.driverPhone != null and driverParam.driverPhone != ''">
  687. and b.driver_phone like concat('%',#{driverParam.driverPhone},'%')
  688. </if>
  689. <if test="driverParam.truckNo != null and driverParam.truckNo != ''">
  690. and b.truck_no like concat('%',#{driverParam.truckNo},'%')
  691. </if>
  692. <!-- )-->
  693. </if>
  694. GROUP BY
  695. b.truck_no
  696. <!-- a.l_order_no,-->
  697. </where>
  698. </select>
  699. <select id="selectLogisticOrderList" resultType="com.sckw.transport.api.model.dto.LogisticsOrderDTO">
  700. SELECT
  701. DISTINCT a.id AS lOrderId,
  702. a.l_order_no AS lOrderNO,
  703. a.t_order_id AS tOrderId,
  704. a.t_order_no AS tOrderNO,
  705. a.payment AS payment,
  706. a.billing_mode AS billingMode,
  707. c.contract_id AS contractId,
  708. b.goods_name AS goodsName,
  709. a.amount,
  710. a.remark as remark,
  711. a.unit ,
  712. a.ignore_amount AS ignoreAmount,
  713. a.price,
  714. a.price_type as priceType,
  715. a.goods_price AS goodsPrice,
  716. a.loss,
  717. a.loss_unit AS lossUnit,
  718. a.tax_rate as taxRate,
  719. a.load_amount AS loadAmount,
  720. a.unload_amount AS unloadAmount,
  721. a.total_load_amount AS totalLoadAmount,
  722. a.total_unload_amount AS totalUnloadAmount,
  723. a.settlement_cycle as settlementCycle,
  724. a.start_time AS startTime,
  725. a.end_time AS endTime,
  726. a.create_time AS createTime,
  727. a.create_by AS createBy,
  728. a.update_by AS updateBy,
  729. a.update_time AS updateTime
  730. FROM
  731. kwt_logistics_order a
  732. LEFT JOIN kwt_logistics_order_goods b ON a.id = b.l_order_id and a.bind_status = '0'
  733. <!-- LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id-->
  734. LEFT JOIN kwt_logistics_order_contract c ON a.id = c.l_order_id
  735. <where>
  736. <if test="ids != null and ids.size() > 0">
  737. and a.id in
  738. <foreach collection="ids" item="item" open="(" close=")" separator=",">
  739. #{item}
  740. </foreach>
  741. </if>
  742. </where>
  743. and a.status = #{status,jdbcType=INTEGER}
  744. ORDER BY a.create_time DESC
  745. </select>
  746. <select id="selectOrderFinishData" resultType="com.sckw.transport.model.vo.OrderFinishVO">
  747. SELECT b.amount as amount,COUNT(a.id) AS number,
  748. SUM(IFNULL(a.load_amount, 0)) as loadAmount,
  749. SUM(IFNULL(a.unload_amount, 0)) AS unloadAmount
  750. FROM kwt_waybill_order a
  751. LEFT JOIN kwt_logistics_order b ON b.id = a.l_order_id
  752. AND a.del_flag = 0
  753. AND b.del_flag = 0
  754. <where>
  755. <if test="orderId != null and orderId != ''">
  756. and b.id=#{orderId}
  757. </if>
  758. </where>
  759. </select>
  760. <select id="findLogisticsOrder" resultType="com.sckw.transport.model.KwtLogisticsOrder"
  761. parameterType="java.util.Map">
  762. select
  763. id, ent_id entId, t_order_id tOrderId, t_order_no tOrderNo, l_order_no lOrderNo, pid, pids,
  764. settlement_cycle settlementCycle, price, price_type priceType, billing_mode billingMode, type,
  765. amount, unit, loss, loss_unit lossUnit, goods_price goodsPrice, goods_price_unit goodsPriceUnit,
  766. start_time startTime, end_time endTime, subcontract_amount subcontractAmount, entrust_amount entrustAmount,
  767. unload_amount unloadAmount, load_amount loadAmount, ignore_amount ignoreAmount, deficit_amount deficitAmount,
  768. deficit_price deficitPrice, payment, tax_rate taxRate, remark, `status`, create_by createBy,
  769. total_load_amount totalLoadAmount, total_unload_amount totalUnloadAmount,
  770. create_time createTime, update_by updateBy, update_time updateTime
  771. from kwt_logistics_order
  772. where del_flag = 0
  773. <if test="id != null and id != ''">
  774. and id = #{id, jdbcType=BIGINT}
  775. </if>
  776. <if test="pid != null and pid != ''">
  777. and pid in (#{pid, jdbcType=VARCHAR})
  778. </if>
  779. <if test="status != null and status != ''">
  780. and status = #{status, jdbcType=INTEGER}
  781. </if>
  782. <if test="upperlOrderId != null and upperlOrderId != ''">
  783. and FIND_IN_SET(#{upperlOrderId, jdbcType=BIGINT}, pids)
  784. </if>
  785. <if test="belowlOrderId != null and belowlOrderId != ''">
  786. and FIND_IN_SET(id, #{belowlOrderId, jdbcType=VARCHAR})
  787. </if>
  788. <if test="ownOrderId != null and ownOrderId != ''">
  789. and id != #{ownOrderId, jdbcType=BIGINT}
  790. </if>
  791. <if test="allOrderId != null and allOrderId != ''">
  792. and (
  793. FIND_IN_SET(#{plOrderIds, jdbcType=BIGINT}, pids)
  794. or FIND_IN_SET(id, #{currentlOrderId, jdbcType=VARCHAR})
  795. )
  796. </if>
  797. <if test="checkEntId != null and checkEntId != ''">
  798. and id in (select l_order_id from kwt_logistics_order_unit where unit_type = 1 and top_ent_id = #{checkEntId, jdbcType=BIGINT})
  799. </if>
  800. </select>
  801. <select id="selectOrderCountByTorderId" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
  802. SELECT a.id as lOrderId,
  803. a.l_order_no as lOrderNo,
  804. b.`status` as `status`,
  805. a.t_order_id as tOrderId,
  806. a.t_order_no as tOrderNo,
  807. a.payment as payment,
  808. a.amount,
  809. a.price,
  810. a.loss,
  811. a.goods_price as goodsPrice,
  812. c.firm_name as comanyName,
  813. c.contacts,
  814. c.phone,
  815. a.create_by as createBy,
  816. a.create_time as createTime
  817. FROM kwt_logistics_order a
  818. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id
  819. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  820. WHERE a.del_flag = '0'
  821. AND b.del_flag = '0'
  822. AND a.t_order_id = #{id,jdbcType=VARCHAR}
  823. </select>
  824. <select id="getAddressList" resultType="java.lang.Integer">
  825. SELECT a.city_code
  826. FROM kwt_logistics_order_address a
  827. LEFT JOIN kwt_logistics_order b ON a.l_order_id = b.id
  828. where a.city_code is not null
  829. AND b.ent_id = #{entId}
  830. GROUP BY a.city_code
  831. </select>
  832. <select id="getAddressDetailListByEntId" resultType="com.sckw.transport.api.model.dto.AddressResDTO">
  833. </select>
  834. <select id="selectMaxLevel" resultType="java.lang.Integer">
  835. SELECT MAX(LEVEL)
  836. FROM kwt_logistics_order
  837. WHERE del_flag = 0
  838. AND FIND_IN_SET(#{id}, pids)
  839. </select>
  840. <select id="countAmountByTradeOrderId" resultType="java.util.Map">
  841. SELECT IFNULL(SUM(unload_amount), 0) AS unloadAmount,
  842. IFNULL(SUM(load_amount), 0) AS loadAmount,
  843. IFNULL(SUM(total_load_amount), 0) AS totalLoadAmount,
  844. IFNULL(SUM(total_unload_amount), 0) AS totalUnloadAmount
  845. FROM kwt_logistics_order
  846. WHERE del_flag = 0
  847. AND t_order_id = #{tOrderId}
  848. AND `status` IN (
  849. 8
  850. )
  851. </select>
  852. <select id="selectOrderListByIdsAndUnitType" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
  853. SELECT a.id as lOrderId,
  854. a.l_order_no as lOrderNo,
  855. b.`status` as `status`,
  856. a.t_order_id as tOrderId,
  857. a.t_order_no as tOrderNo,
  858. a.payment as payment,
  859. a.amount,
  860. a.price,
  861. a.loss,
  862. a.goods_price as goodsPrice,
  863. c.firm_name as companyName,
  864. c.contacts,
  865. c.phone,
  866. a.create_by as createBy,
  867. a.create_time as createTime
  868. FROM kwt_logistics_order a
  869. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
  870. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  871. WHERE a.del_flag = '0'
  872. AND b.del_flag = '0'
  873. AND a.t_order_id IN
  874. <foreach collection="ids" item="item" open="(" close=")" separator=",">
  875. #{item}
  876. </foreach>
  877. order by createTime desc
  878. </select>
  879. <select id="selectLoopOrderAndDriverListByOrderId" resultType="com.sckw.transport.model.vo.DriverListVo">
  880. SELECT a.id AS lOrderId,
  881. a.l_order_no AS lOrderNo,
  882. c.driver_id AS driverId,
  883. c.id AS circulateId,
  884. c.driver_name AS driverName,
  885. c.driver_phone AS driverPhone,
  886. c.driver_idcard AS driverIdCard,
  887. c.truck_no AS truckNo,
  888. c.truck_id AS truckId,
  889. c.total_take as count,
  890. c.status as status
  891. FROM
  892. kwt_logistics_order_circulate c,
  893. kwt_logistics_order a
  894. <where>
  895. a.id = c.l_order_id
  896. AND c.type = '2'
  897. AND c.`status` = '0'
  898. AND a.del_flag = 0
  899. AND c.del_flag = 0
  900. <if test="driverParam.lOrderId != null and driverParam.lOrderId != ''">
  901. AND a.id =#{driverParam.lOrderId}
  902. </if>
  903. <if test="driverParam.driverName != null and driverParam.driverName != '' or ( driverParam.driverPhone != null and driverParam.driverPhone != '' ) or ( driverParam.truckNo != null and driverParam.truckNo != '' )">
  904. <!-- and (-->
  905. <if test=" driverParam.driverName != null and driverParam.driverName != ''">
  906. and c.driver_name like concat('%',#{driverParam.driverName},'%')
  907. </if>
  908. <if test=" driverParam.driverPhone != null and driverParam.driverPhone != ''">
  909. and c.driver_phone like concat('%',#{driverParam.driverPhone},'%')
  910. </if>
  911. <if test=" driverParam.truckNo != null and driverParam.truckNo != ''">
  912. and c.truck_no like concat('%',#{driverParam.truckNo},'%')
  913. </if>
  914. <!-- )-->
  915. </if>
  916. </where>
  917. </select>
  918. <select id="selectLoopOrderAndDriverListByOrderIds" resultType="com.sckw.transport.model.vo.DriverListVo">
  919. SELECT
  920. c.id AS circulateId,
  921. c.driver_id AS driverId,
  922. b.id AS lOrderId,
  923. b.l_order_no AS lOrderNo,
  924. c.driver_name AS driverName,
  925. c.driver_phone AS driverPhone,
  926. c.driver_idcard AS driverIdCard,
  927. c.truck_no AS truckNo,
  928. c.truck_id AS truckId,
  929. c.total_take AS count
  930. FROM
  931. kwt_logistics_order_circulate c
  932. LEFT JOIN kwt_logistics_order b ON b.id = c.l_order_id
  933. WHERE
  934. b.del_flag = 0
  935. AND c.del_flag = 0
  936. AND c.STATUS = 0
  937. <if test="idsList != null and idsList.size() >0">
  938. AND b.id IN
  939. <foreach collection="idsList" item="item" open="(" close=")" separator=",">
  940. #{item}
  941. </foreach>
  942. </if>
  943. </select>
  944. <sql id="Query_Column_List">
  945. a.id AS lOrderId,
  946. a.l_order_no AS lOrderNo,
  947. a.t_order_id AS tOrderId,
  948. a.t_order_no AS tOrderNo,
  949. a.loss AS loss,
  950. a.loss_unit AS lossUnit,
  951. a.settlement_cycle AS accountsCycle,
  952. a.billing_mode AS billingMode,
  953. a.amount AS carryingCapacity,
  954. a.goods_price AS goodsPrice,
  955. a.goods_price_unit AS goodsPriceUnit,
  956. a.`status` AS status,
  957. a.settlement_cycle AS settlementCycle,
  958. a.price AS price,
  959. a.price_type AS priceType,
  960. a.type AS orderSource,
  961. a.unit AS unit,
  962. a.subcontract_amount AS subcontractAmount,
  963. a.entrust_amount AS entrustAmount,
  964. a.unload_amount AS unloadAmount,
  965. a.load_amount AS loadAmount,
  966. a.ignore_amount AS ignoreAmount,
  967. a.deficit_amount AS deficitAmount,
  968. a.deficit_price AS deficitPrice,
  969. a.total_load_amount AS totalLoadAmount,
  970. a.total_unload_amount AS totalUnloadAmount,
  971. a.payment AS payment,
  972. a.tax_rate AS taxRate,
  973. a.ent_id AS entId,
  974. a.create_by AS createBy,
  975. a.create_time AS createTime,
  976. a.update_by AS updateBy,
  977. a.update_time AS updateTime,
  978. a.start_time AS shipmentsDateTime,
  979. a.end_time AS receiveGoodsDateTime,
  980. a.remark AS remark,
  981. g.goods_id AS goodsId,
  982. g.goods_name AS goodsName,
  983. g.goods_type AS goodsType,
  984. f.contract_id AS contractId,
  985. f.contract_no AS contractNo,
  986. f.signing_way AS signing,
  987. d.ent_id AS consignCompanyId,
  988. d.top_ent_id AS consignTopEntId,
  989. d.firm_name AS consignCompany,
  990. d.contacts AS consignContacts,
  991. d.contacts_id AS consignContactsId,
  992. e.contacts_id AS carrierContactsId,
  993. d.phone AS consignPhone,
  994. e.ent_id AS carrierCompanyId,
  995. e.firm_name AS carrierCompany,
  996. e.top_ent_id AS carrierTopEntId,
  997. e.contacts AS carrierContacts,
  998. e.phone AS carrierPhone,
  999. b.`name` AS loadName,
  1000. b.address_type AS loadType,
  1001. b.city_name AS loadCityName,
  1002. b.city_code AS loadCityCode,
  1003. b.detail_address AS loadAddress,
  1004. b.contacts AS shipmentsContacts,
  1005. b.phone AS shipmentsPhone,
  1006. b.lat AS loadLat,
  1007. b.lng AS loadLng,
  1008. c.name AS unloadName,
  1009. c.address_type AS unloadType,
  1010. c.contacts AS receiveGoodsContacts,
  1011. c.phone AS receiveGoodsPhone,
  1012. c.city_name AS unloadCityName,
  1013. c.city_code AS unloadCityCode,
  1014. c.detail_address AS unloadAddress,
  1015. c.lat AS unloadLat,
  1016. c.lng AS unloadLng,
  1017. f.contract_name as contract
  1018. ,a.del_flag as delFlag
  1019. </sql>
  1020. <sql id="Query_Column_List_Accept_Carriage">
  1021. a.id AS lOrderId,
  1022. a.l_order_no AS lOrderNo,
  1023. a.t_order_id AS tOrderId,
  1024. a.t_order_no AS tOrderNo,
  1025. a.loss AS loss,
  1026. a.loss_unit AS lossUnit,
  1027. a.settlement_cycle AS accountsCycle,
  1028. a.billing_mode AS billingMode,
  1029. a.amount AS carryingCapacity,
  1030. a.goods_price AS goodsPrice,
  1031. a.goods_price_unit AS goodsPriceUnit,
  1032. a.`status` AS status,
  1033. a.settlement_cycle AS settlementCycle,
  1034. a.price AS price,
  1035. a.price_type AS priceType,
  1036. a.type AS orderSource,
  1037. a.unit AS unit,
  1038. a.subcontract_amount AS subcontractAmount,
  1039. a.entrust_amount AS entrustAmount,
  1040. a.unload_amount AS unloadAmount,
  1041. a.load_amount AS loadAmount,
  1042. a.ignore_amount AS ignoreAmount,
  1043. a.deficit_amount AS deficitAmount,
  1044. a.deficit_price AS deficitPrice,
  1045. a.total_load_amount AS totalLoadAmount,
  1046. a.total_unload_amount AS totalUnloadAmount,
  1047. a.payment AS payment,
  1048. a.tax_rate AS taxRate,
  1049. a.ent_id AS entId,
  1050. a.create_by AS createBy,
  1051. a.create_time AS createTime,
  1052. a.update_by AS updateBy,
  1053. a.update_time AS updateTime,
  1054. a.start_time AS shipmentsDateTime,
  1055. a.end_time AS receiveGoodsDateTime,
  1056. a.remark AS remark,
  1057. g.goods_id AS goodsId,
  1058. g.goods_name AS goodsName,
  1059. g.goods_type AS goodsType,
  1060. f.contract_id AS contractId,
  1061. f.contract_no AS contractNo,
  1062. f.signing_way AS signing,
  1063. d.ent_id AS consignCompanyId,
  1064. d.top_ent_id AS consignTopEntId,
  1065. d.firm_name AS consignCompany,
  1066. d.contacts AS consignContacts,
  1067. d.contacts_id AS consignContactsId,
  1068. e.contacts_id AS carrierContactsId,
  1069. d.phone AS consignPhone,
  1070. e.ent_id AS carrierCompanyId,
  1071. e.firm_name AS carrierCompany,
  1072. e.top_ent_id AS carrierTopEntId,
  1073. e.contacts AS carrierContacts,
  1074. e.phone AS carrierPhone,
  1075. b.`name` AS loadName,
  1076. b.address_type AS loadType,
  1077. b.city_name AS loadCityName,
  1078. b.city_code AS loadCityCode,
  1079. b.detail_address AS loadAddress,
  1080. b.contacts AS shipmentsContacts,
  1081. b.phone AS shipmentsPhone,
  1082. b.lat AS loadLat,
  1083. b.lng AS loadLng,
  1084. c.`name` AS unloadName,
  1085. c.address_type AS unloadType,
  1086. c.contacts AS receiveGoodsContacts,
  1087. c.phone AS receiveGoodsPhone,
  1088. c.city_name AS unloadCityName,
  1089. c.city_code AS unloadCityCode,
  1090. c.detail_address AS unloadAddress,
  1091. c.lat AS unloadLat,
  1092. c.lng AS unloadLng,
  1093. f.contract_name as contract
  1094. ,a.del_flag as delFlag,
  1095. case when a.ent_id = e.top_ent_id then 1 ELSE 2 end as createType
  1096. </sql>
  1097. <sql id="Query_Column_List_Cogsign">
  1098. a.id AS lOrderId,
  1099. a.l_order_no AS lOrderNo,
  1100. a.t_order_id AS tOrderId,
  1101. a.t_order_no AS tOrderNo,
  1102. a.loss AS loss,
  1103. a.loss_unit AS lossUnit,
  1104. a.settlement_cycle AS accountsCycle,
  1105. a.billing_mode AS billingMode,
  1106. a.amount AS carryingCapacity,
  1107. a.goods_price AS goodsPrice,
  1108. a.goods_price_unit AS goodsPriceUnit,
  1109. a.`status` AS status,
  1110. a.settlement_cycle AS settlementCycle,
  1111. a.price AS price,
  1112. a.price_type AS priceType,
  1113. a.type AS orderSource,
  1114. a.unit AS unit,
  1115. a.subcontract_amount AS subcontractAmount,
  1116. a.entrust_amount AS entrustAmount,
  1117. a.unload_amount AS unloadAmount,
  1118. a.load_amount AS loadAmount,
  1119. a.ignore_amount AS ignoreAmount,
  1120. a.deficit_amount AS deficitAmount,
  1121. a.deficit_price AS deficitPrice,
  1122. a.total_load_amount AS totalLoadAmount,
  1123. a.total_unload_amount AS totalUnloadAmount,
  1124. a.payment AS payment,
  1125. a.tax_rate AS taxRate,
  1126. a.ent_id AS entId,
  1127. a.create_by AS createBy,
  1128. a.create_time AS createTime,
  1129. a.update_by AS updateBy,
  1130. a.update_time AS updateTime,
  1131. a.start_time AS shipmentsDateTime,
  1132. a.end_time AS receiveGoodsDateTime,
  1133. a.remark AS remark,
  1134. g.goods_id AS goodsId,
  1135. g.goods_name AS goodsName,
  1136. g.goods_type AS goodsType,
  1137. f.contract_id AS contractId,
  1138. f.contract_no AS contractNo,
  1139. f.signing_way AS signing,
  1140. d.ent_id AS consignCompanyId,
  1141. d.top_ent_id AS consignTopEntId,
  1142. d.firm_name AS consignCompany,
  1143. d.contacts AS consignContacts,
  1144. d.contacts_id AS consignContactsId,
  1145. e.contacts_id AS carrierContactsId,
  1146. d.phone AS consignPhone,
  1147. e.ent_id AS carrierCompanyId,
  1148. e.firm_name AS carrierCompany,
  1149. e.top_ent_id AS carrierTopEntId,
  1150. e.contacts AS carrierContacts,
  1151. e.phone AS carrierPhone,
  1152. b.`name` AS loadName,
  1153. b.address_type AS loadType,
  1154. b.city_name AS loadCityName,
  1155. b.city_code AS loadCityCode,
  1156. b.detail_address AS loadAddress,
  1157. b.contacts AS shipmentsContacts,
  1158. b.phone AS shipmentsPhone,
  1159. b.lat AS loadLat,
  1160. b.lng AS loadLng,
  1161. c.`name` AS unloadName,
  1162. c.address_type AS unloadType,
  1163. c.contacts AS receiveGoodsContacts,
  1164. c.phone AS receiveGoodsPhone,
  1165. c.city_name AS unloadCityName,
  1166. c.city_code AS unloadCityCode,
  1167. c.detail_address AS unloadAddress,
  1168. c.lat AS unloadLat,
  1169. c.lng AS unloadLng,
  1170. f.contract_name as contract
  1171. ,a.del_flag as delFlag,
  1172. case when a.ent_id = d.top_ent_id then 1 ELSE 2 end as createType
  1173. </sql>
  1174. <sql id="New_Query_Column_List">
  1175. lOrderId,
  1176. lOrderNo,
  1177. tOrderId,
  1178. tOrderNo,
  1179. loss,
  1180. lossUnit,
  1181. accountsCycle,
  1182. billingMode,
  1183. carryingCapacity,
  1184. goodsPrice,
  1185. goodsPriceUnit,
  1186. STATUS,
  1187. settlementCycle,
  1188. price,
  1189. priceType,
  1190. orderSource,
  1191. unit,
  1192. subcontractAmount,
  1193. entrustAmount,
  1194. unloadAmount,
  1195. loadAmount,
  1196. ignoreAmount,
  1197. deficitAmount,
  1198. deficitPrice,
  1199. totalLoadAmount,
  1200. totalUnloadAmount,
  1201. payment,
  1202. taxRate,
  1203. entId,
  1204. createBy,
  1205. createTime,
  1206. updateBy,
  1207. updateTime,
  1208. shipmentsDateTime,
  1209. receiveGoodsDateTime,
  1210. remark,
  1211. goodsId,
  1212. goodsName,
  1213. goodsType,
  1214. contractId,
  1215. contractNo,
  1216. signing,
  1217. consignCompanyId,
  1218. consignTopEntId,
  1219. consignCompany,
  1220. consignContacts,
  1221. consignPhone,
  1222. carrierCompanyId,
  1223. carrierCompany,
  1224. carrierTopEntId,
  1225. carrierContacts,
  1226. carrierPhone,
  1227. loadName,
  1228. loadType,
  1229. loadCityName,
  1230. loadCityCode,
  1231. loadAddress,
  1232. shipmentsContacts,
  1233. shipmentsPhone,
  1234. loadLat,
  1235. loadLng,
  1236. unloadName,
  1237. unloadType,
  1238. receiveGoodsContacts,
  1239. receiveGoodsPhone,
  1240. unloadCityName,
  1241. unloadCityCode,
  1242. unloadAddress,
  1243. unloadLat,
  1244. unloadLng,
  1245. contract,
  1246. createType
  1247. </sql>
  1248. <select id="selectLogisticsOrderList" resultType="com.sckw.transport.model.vo.AcceptCarriageOrderVO">
  1249. SELECT
  1250. <include refid="Query_Column_List">
  1251. </include>
  1252. FROM
  1253. kwt_logistics_order a
  1254. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  1255. AND b.address_type = 1 AND b.del_flag = 0
  1256. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  1257. AND c.address_type = 2 AND c.del_flag = 0
  1258. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  1259. AND d.unit_type = 1 AND d.del_flag = 0
  1260. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  1261. AND e.unit_type = 2
  1262. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  1263. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  1264. <where>
  1265. a.del_flag = 0
  1266. <if test="type == 1">
  1267. <!-- and (d.top_ent_id = #{entId} or d.ent_id = #{entId})-->
  1268. AND ((
  1269. a.ent_id = #{entId}
  1270. <if test="userIds != null and userIds.size()>0">
  1271. AND a.create_by IN
  1272. <foreach collection="userIds" open="(" close=")" item="item" separator=",">
  1273. #{item}
  1274. </foreach>
  1275. </if>
  1276. )
  1277. OR (
  1278. d.top_ent_id = #{entId}
  1279. <if test="contactsIds != null and contactsIds.size()>0">
  1280. AND d.contacts_id IN
  1281. <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
  1282. #{item}
  1283. </foreach>
  1284. </if>
  1285. ))
  1286. </if>
  1287. <if test="type == 2">
  1288. <!-- and (e.top_ent_id = #{entId} or e.ent_id = #{entId})-->
  1289. AND ((
  1290. a.ent_id = #{entId}
  1291. <if test="userIds != null and userIds.size()>0">
  1292. AND a.create_by IN
  1293. <foreach collection="userIds" open="(" close=")" item="item" separator=",">
  1294. #{item}
  1295. </foreach>
  1296. </if>
  1297. )
  1298. OR (
  1299. e.top_ent_id = #{entId}
  1300. <if test="contactsIds != null and contactsIds.size()>0">
  1301. AND e.contacts_id IN
  1302. <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
  1303. #{item}
  1304. </foreach>
  1305. </if>
  1306. ))
  1307. </if>
  1308. <if test="query.keywords != null and query.keywords != ''">
  1309. and (
  1310. a.t_order_no like concat('%',#{query.keywords},'%')
  1311. or a.l_order_no like concat('%',#{query.keywords},'%')
  1312. or d.firm_name like concat('%',#{query.keywords},'%')
  1313. or e.firm_name like concat('%',#{query.keywords},'%')
  1314. or g.goods_name like concat('%',#{query.keywords},'%'))
  1315. </if>
  1316. <if test="orderList != null and orderList.size() > 0 ">
  1317. and a.status in
  1318. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  1319. #{status}
  1320. </foreach>
  1321. </if>
  1322. <if test="idsList != null and idsList.size()>0">
  1323. and a.id in
  1324. <foreach collection="idsList" close=")" open="(" separator="," item="item">
  1325. #{item}
  1326. </foreach>
  1327. </if>
  1328. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  1329. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  1330. </if>
  1331. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  1332. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  1333. </if>
  1334. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  1335. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  1336. </if>
  1337. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  1338. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  1339. </if>
  1340. <if test="query.createStartTime != null and query.createStartTime != '' ">
  1341. and a.create_time &gt;=#{query.createStartTime}
  1342. </if>
  1343. <if test="query.createEndTime != null and query.createEndTime != ''">
  1344. and a.create_time &lt;=#{query.createEndTime}
  1345. </if>
  1346. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  1347. and b.city_code = #{query.loadAddressCode}
  1348. </if>
  1349. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  1350. and c.city_code = #{query.unloadAddressCode}
  1351. </if>
  1352. <if test="query.billingMode != null and query.billingMode != ''">
  1353. and a.billing_mode =#{query.billingMode}
  1354. </if>
  1355. </where>
  1356. ORDER BY a.create_time DESC
  1357. <!-- ,a.create_time-->
  1358. </select>
  1359. <select id="selectManagementLogisticsOrderList" resultType="com.sckw.transport.model.vo.ManagementLogisticsOrderVO">
  1360. SELECT
  1361. <include refid="Query_Column_List">
  1362. </include>
  1363. FROM
  1364. kwt_logistics_order a
  1365. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  1366. AND b.address_type = 1 AND b.del_flag = 0
  1367. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  1368. AND c.address_type = 2 AND c.del_flag = 0
  1369. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  1370. AND d.unit_type = 1 AND d.del_flag = 0
  1371. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  1372. AND e.unit_type = 2
  1373. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  1374. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  1375. <where>
  1376. a.del_flag = 0
  1377. <if test="query.keywords != null and query.keywords != ''">
  1378. and (
  1379. a.t_order_no like concat('%',#{query.keywords},'%')
  1380. or a.l_order_no like concat('%',#{query.keywords},'%')
  1381. or d.firm_name like concat('%',#{query.keywords},'%')
  1382. or e.firm_name like concat('%',#{query.keywords},'%')
  1383. or g.goods_name like concat('%',#{query.keywords},'%'))
  1384. </if>
  1385. <if test="orderList != null and orderList.size() > 0 ">
  1386. and a.status in
  1387. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  1388. #{status}
  1389. </foreach>
  1390. </if>
  1391. <if test="idsList != null and idsList.size>0">
  1392. and a.id in
  1393. <foreach collection="idsList" item="item" separator="," open="(" close=")">
  1394. #{item}
  1395. </foreach>
  1396. </if>
  1397. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  1398. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  1399. </if>
  1400. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  1401. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  1402. </if>
  1403. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  1404. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  1405. </if>
  1406. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  1407. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  1408. </if>
  1409. <if test="query.createStartTime != null and query.createStartTime != '' ">
  1410. and a.create_time &gt;=#{query.createStartTime}
  1411. </if>
  1412. <if test="query.createEndTime != null and query.createEndTime != ''">
  1413. and a.create_time &lt;=#{query.createEndTime}
  1414. </if>
  1415. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  1416. and b.city_code = #{query.loadAddressCode}
  1417. </if>
  1418. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  1419. and c.city_code = #{query.unloadAddressCode}
  1420. </if>
  1421. <if test="query.billingMode != null and query.billingMode != ''">
  1422. and a.billing_mode =#{query.billingMode}
  1423. </if>
  1424. </where>
  1425. ORDER BY a.create_time DESC
  1426. <!-- ,a.create_time-->
  1427. </select>
  1428. <select id="countLogisticsOrderListByStatus" resultType="com.sckw.mongo.model.TableTops">
  1429. SELECT
  1430. a.`status` AS value ,
  1431. COUNT(a.`status`) AS total
  1432. FROM
  1433. kwt_logistics_order a
  1434. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  1435. AND b.address_type = 1 AND b.del_flag = 0
  1436. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  1437. AND c.address_type = 2 AND c.del_flag = 0
  1438. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  1439. AND d.unit_type = 1 AND d.del_flag = 0
  1440. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  1441. AND e.unit_type = 2
  1442. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  1443. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  1444. <where>
  1445. a.del_flag = 0
  1446. <if test="type == 1">
  1447. <!-- and (d.top_ent_id = #{entId} or d.ent_id = #{entId})-->
  1448. AND ((
  1449. a.ent_id = #{entId}
  1450. <if test="userIds != null and userIds.size()>0">
  1451. AND a.create_by IN
  1452. <foreach collection="userIds" open="(" close=")" item="item" separator=",">
  1453. #{item}
  1454. </foreach>
  1455. </if>
  1456. )
  1457. OR (
  1458. d.top_ent_id = #{entId}
  1459. <if test="contactsIds != null and contactsIds.size()>0">
  1460. AND d.contacts_id IN
  1461. <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
  1462. #{item}
  1463. </foreach>
  1464. </if>
  1465. ))
  1466. </if>
  1467. <if test="type == 2">
  1468. <!-- and (e.top_ent_id = #{entId} or e.ent_id = #{entId})-->
  1469. AND ((
  1470. a.ent_id = #{entId}
  1471. <if test="userIds != null and userIds.size()>0">
  1472. AND a.create_by IN
  1473. <foreach collection="userIds" open="(" close=")" item="item" separator=",">
  1474. #{item}
  1475. </foreach>
  1476. </if>
  1477. )
  1478. OR (
  1479. e.top_ent_id = #{entId}
  1480. <if test="contactsIds != null and contactsIds.size()>0">
  1481. AND e.contacts_id IN
  1482. <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
  1483. #{item}
  1484. </foreach>
  1485. </if>
  1486. ))
  1487. </if>
  1488. <if test="query.keywords != null and query.keywords != ''">
  1489. and (
  1490. a.t_order_no like concat('%',#{query.keywords},'%')
  1491. or a.l_order_no like concat('%',#{query.keywords},'%')
  1492. or d.firm_name like concat('%',#{query.keywords},'%')
  1493. or e.firm_name like concat('%',#{query.keywords},'%')
  1494. or g.goods_name like concat('%',#{query.keywords},'%'))
  1495. </if>
  1496. <if test="orderList != null and orderList.size() > 0 ">
  1497. and a.status in
  1498. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  1499. #{status}
  1500. </foreach>
  1501. </if>
  1502. <if test="idsList != null and idsList.size() > 0 ">
  1503. and a.id in
  1504. <foreach collection="idsList" item="item" open="(" close=")" separator=",">
  1505. #{item}
  1506. </foreach>
  1507. </if>
  1508. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  1509. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  1510. </if>
  1511. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  1512. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  1513. </if>
  1514. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  1515. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  1516. </if>
  1517. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  1518. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  1519. </if>
  1520. <if test="query.createStartTime != null and query.createStartTime != '' ">
  1521. and a.create_time &gt;=#{query.createStartTime}
  1522. </if>
  1523. <if test="query.createEndTime != null and query.createEndTime != ''">
  1524. and a.create_time &lt;=#{query.createEndTime}
  1525. </if>
  1526. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  1527. and b.city_code = #{query.loadAddressCode}
  1528. </if>
  1529. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  1530. and c.city_code = #{query.unloadAddressCode}
  1531. </if>
  1532. </where>
  1533. group by a.status
  1534. </select>
  1535. <select id="countManagementLogisticsOrderListByStatus" resultType="com.sckw.mongo.model.TableTops">
  1536. SELECT
  1537. a.`status` AS value ,
  1538. COUNT(a.`status`) AS total
  1539. FROM
  1540. kwt_logistics_order a
  1541. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  1542. AND b.address_type = 1 AND b.del_flag = 0
  1543. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  1544. AND c.address_type = 2 AND c.del_flag = 0
  1545. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  1546. AND d.unit_type = 1 AND d.del_flag = 0
  1547. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  1548. AND e.unit_type = 2
  1549. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  1550. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  1551. <where>
  1552. a.del_flag = 0
  1553. <if test="query.keywords != null and query.keywords != ''">
  1554. and (
  1555. a.t_order_no like concat('%',#{query.keywords},'%')
  1556. or a.l_order_no like concat('%',#{query.keywords},'%')
  1557. or d.firm_name like concat('%',#{query.keywords},'%')
  1558. or e.firm_name like concat('%',#{query.keywords},'%')
  1559. or g.goods_name like concat('%',#{query.keywords},'%'))
  1560. </if>
  1561. <if test="orderList != null and orderList.size() > 0 ">
  1562. and a.status in
  1563. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  1564. #{status}
  1565. </foreach>
  1566. </if>
  1567. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  1568. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  1569. </if>
  1570. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  1571. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  1572. </if>
  1573. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  1574. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  1575. </if>
  1576. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  1577. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  1578. </if>
  1579. <if test="query.createStartTime != null and query.createStartTime != '' ">
  1580. and a.create_time &gt;=#{query.createStartTime}
  1581. </if>
  1582. <if test="query.createEndTime != null and query.createEndTime != ''">
  1583. and a.create_time &lt;=#{query.createEndTime}
  1584. </if>
  1585. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  1586. and b.city_code = #{query.loadAddressCode}
  1587. </if>
  1588. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  1589. and c.city_code = #{query.unloadAddressCode}
  1590. </if>
  1591. <if test="query.billingMode != null and query.billingMode != ''">
  1592. and a.billing_mode =#{query.billingMode}
  1593. </if>
  1594. </where>
  1595. group by a.status
  1596. </select>
  1597. <select id="selectCountByLorderId" resultType="java.lang.Integer">
  1598. SELECT COUNT(id)
  1599. FROM kwt_waybill_order
  1600. WHERE del_flag = 0
  1601. and l_order_id = #{orderId}
  1602. <if test="orderStatusList != null and orderStatusList.size() > 0">
  1603. AND status IN
  1604. <foreach collection="orderStatusList" item="item" open="(" close=")" separator=",">
  1605. #{item}
  1606. </foreach>
  1607. </if>
  1608. </select>
  1609. <select id="getMaxOrderNoByDate" resultType="java.lang.String">
  1610. SELECT MAX(l_order_no)
  1611. FROM kwt_logistics_order
  1612. WHERE create_time &gt;= #{date};
  1613. </select>
  1614. <select id="checkLogisticsOrderIsFinishByEntId" resultType="java.lang.String">
  1615. SELECT
  1616. a.l_order_no
  1617. FROM
  1618. kwt_logistics_order a
  1619. INNER JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  1620. AND a.del_flag = 0
  1621. AND b.del_flag = 0
  1622. AND b.unit_type = 1
  1623. INNER JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  1624. AND a.del_flag = 0
  1625. AND c.del_flag = 0
  1626. AND c.unit_type = 2
  1627. <where>
  1628. <if test="consignEntId != null and consignEntId != ''">
  1629. and b.top_ent_id = #{consignEntId}
  1630. </if>
  1631. <if test="acceptCarriageEntId != null and acceptCarriageEntId != ''">
  1632. and c.top_ent_id = #{acceptCarriageEntId}
  1633. </if>
  1634. <if test="orderStatus != null and orderStatus.size() > 0">
  1635. and a.status in
  1636. <foreach collection="orderStatus" separator="," open="(" item="item" close=")">
  1637. #{item}
  1638. </foreach>
  1639. </if>
  1640. </where>
  1641. </select>
  1642. <select id="selectLogisticsOrderListExport"
  1643. resultType="com.sckw.transport.model.vo.execlVo.AcceptCarriageOrderExcelVo">
  1644. SELECT
  1645. <include refid="Query_Column_List">
  1646. </include>
  1647. FROM
  1648. kwt_logistics_order a
  1649. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  1650. AND b.address_type = 1 AND b.del_flag = 0
  1651. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  1652. AND c.address_type = 2 AND c.del_flag = 0
  1653. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  1654. AND d.unit_type = 1 AND d.del_flag = 0
  1655. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  1656. AND e.unit_type = 2
  1657. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  1658. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  1659. <where>
  1660. a.del_flag = 0
  1661. <if test="type == 1">
  1662. and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
  1663. </if>
  1664. <if test="type == 2">
  1665. and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
  1666. </if>
  1667. <if test="query.keywords != null and query.keywords != ''">
  1668. and (
  1669. a.t_order_no like concat('%',#{query.keywords},'%')
  1670. or a.l_order_no like concat('%',#{query.keywords},'%')
  1671. or d.firm_name like concat('%',#{query.keywords},'%')
  1672. or e.firm_name like concat('%',#{query.keywords},'%')
  1673. or g.goods_name like concat('%',#{query.keywords},'%'))
  1674. </if>
  1675. <if test="orderList != null and orderList.size() > 0 ">
  1676. and a.status in
  1677. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  1678. #{status}
  1679. </foreach>
  1680. </if>
  1681. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  1682. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  1683. </if>
  1684. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  1685. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  1686. </if>
  1687. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  1688. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  1689. </if>
  1690. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  1691. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  1692. </if>
  1693. <if test="query.createStartTime != null and query.createStartTime != '' ">
  1694. and a.create_time &gt;=#{query.createStartTime}
  1695. </if>
  1696. <if test="query.createEndTime != null and query.createEndTime != ''">
  1697. and a.create_time &lt;=#{query.createEndTime}
  1698. </if>
  1699. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  1700. and b.city_code = #{query.loadAddressCode}
  1701. </if>
  1702. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  1703. and c.city_code = #{query.unloadAddressCode}
  1704. </if>
  1705. <if test="query.billingMode != null and query.billingMode != ''">
  1706. and a.billing_mode =#{query.billingMode}
  1707. </if>
  1708. </where>
  1709. ORDER BY a.id DESC
  1710. <!-- ,a.create_time-->
  1711. </select>
  1712. <select id="selectConsignLogisticsOrderList" resultType="com.sckw.transport.model.vo.ConsignOrderVO">
  1713. SELECT
  1714. <include refid="Query_Column_List">
  1715. </include>
  1716. FROM
  1717. kwt_logistics_order a
  1718. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  1719. AND b.address_type = 1 AND b.del_flag = 0
  1720. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  1721. AND c.address_type = 2 AND c.del_flag = 0
  1722. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  1723. AND d.unit_type = 1 AND d.del_flag = 0
  1724. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  1725. AND e.unit_type = 2
  1726. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  1727. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  1728. <where>
  1729. a.del_flag = 0
  1730. <if test="type == 1">
  1731. <!-- and (d.top_ent_id = #{entId} or d.ent_id = #{entId})-->
  1732. AND ((
  1733. a.ent_id = #{entId}
  1734. <if test="userIds != null and userIds.size()>0">
  1735. AND a.create_by IN
  1736. <foreach collection="userIds" open="(" close=")" item="item" separator=",">
  1737. #{item}
  1738. </foreach>
  1739. </if>
  1740. )
  1741. OR (
  1742. d.top_ent_id = #{entId}
  1743. <if test="contactsIds != null and contactsIds.size()>0">
  1744. AND d.contacts_id IN
  1745. <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
  1746. #{item}
  1747. </foreach>
  1748. </if>
  1749. ))
  1750. </if>
  1751. <if test="type == 2">
  1752. <!-- and (e.top_ent_id = #{entId} or e.ent_id = #{entId})-->
  1753. AND ((
  1754. a.ent_id = #{entId}
  1755. <if test="userIds != null and userIds.size()>0">
  1756. AND a.create_by IN
  1757. <foreach collection="userIds" open="(" close=")" item="item" separator=",">
  1758. #{item}
  1759. </foreach>
  1760. </if>
  1761. )
  1762. OR (
  1763. e.top_ent_id = #{entId}
  1764. <if test="contactsIds != null and contactsIds.size()>0">
  1765. AND e.contacts_id IN
  1766. <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
  1767. #{item}
  1768. </foreach>
  1769. </if>
  1770. ))
  1771. </if>
  1772. <if test="query.keywords != null and query.keywords != ''">
  1773. and (
  1774. a.t_order_no like concat('%',#{query.keywords},'%')
  1775. or a.l_order_no like concat('%',#{query.keywords},'%')
  1776. or d.firm_name like concat('%',#{query.keywords},'%')
  1777. or e.firm_name like concat('%',#{query.keywords},'%')
  1778. or g.goods_name like concat('%',#{query.keywords},'%'))
  1779. </if>
  1780. <if test="orderList != null and orderList.size() > 0 ">
  1781. and a.status in
  1782. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  1783. #{status}
  1784. </foreach>
  1785. </if>
  1786. <if test="idsList != null and idsList.size() > 0 ">
  1787. and a.status in
  1788. <foreach collection="idsList" item="status" open="(" close=")" separator=",">
  1789. #{status}
  1790. </foreach>
  1791. </if>
  1792. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  1793. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  1794. </if>
  1795. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  1796. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  1797. </if>
  1798. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  1799. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  1800. </if>
  1801. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  1802. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  1803. </if>
  1804. <if test="query.createStartTime != null and query.createStartTime != '' ">
  1805. and a.create_time &gt;=#{query.createStartTime}
  1806. </if>
  1807. <if test="query.createEndTime != null and query.createEndTime != ''">
  1808. and a.create_time &lt;=#{query.createEndTime}
  1809. </if>
  1810. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  1811. and b.city_code = #{query.loadAddressCode}
  1812. </if>
  1813. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  1814. and c.city_code = #{query.unloadAddressCode}
  1815. </if>
  1816. <if test="query.billingMode != null and query.billingMode != ''">
  1817. and a.billing_mode =#{query.billingMode}
  1818. </if>
  1819. </where>
  1820. ORDER BY a.id DESC
  1821. <!-- ,a.create_time-->
  1822. </select>
  1823. <select id="statisticsWaybillSendCar" resultType="java.lang.Integer">
  1824. SELECT
  1825. COUNT(b.id)
  1826. FROM
  1827. kwt_waybill_order b
  1828. LEFT JOIN kwt_logistics_order a ON a.id = b.l_order_id
  1829. WHERE
  1830. a.del_flag = 0
  1831. AND b.del_flag = 0
  1832. <if test="ids != null and ids.size()>0">
  1833. and a.id in
  1834. <foreach collection="ids" open="(" close=")" separator="," item="item">
  1835. #{item}
  1836. </foreach>
  1837. </if>
  1838. <if test="orderList != null and orderList.size()>0">
  1839. and b.status in
  1840. <foreach collection="orderList" item="item" separator="," close=")" open="(">
  1841. #{item}
  1842. </foreach>
  1843. </if>
  1844. </select>
  1845. <select id="statisticsLogistics" resultType="java.lang.Long">
  1846. SELECT DISTINCT a.id
  1847. FROM kwt_logistics_order a
  1848. LEFT JOIN kwt_logistics_order_unit b ON b.l_order_id = a.id
  1849. WHERE a.del_flag = 0
  1850. AND b.del_flag = 0
  1851. <if test="topEntId != null and topEntId != ''">
  1852. AND (b.ent_id = #{topEntId} OR b.top_ent_id = #{topEntId})
  1853. </if>
  1854. </select>
  1855. <select id="statisticsLogisticsByTopEntIdAndOrderStatus" resultType="java.lang.Integer">
  1856. SELECT
  1857. count(DISTINCT a.id)
  1858. FROM
  1859. kwt_logistics_order a
  1860. LEFT JOIN kwt_logistics_order_unit b ON b.l_order_id = a.id
  1861. WHERE
  1862. a.del_flag = 0
  1863. AND b.del_flag = 0
  1864. <if test="topEntId != null and topEntId != ''">
  1865. AND ( b.ent_id = #{topEntId} OR b.top_ent_id = #{topEntId} )
  1866. </if>
  1867. AND b.unit_type=#{unitType}
  1868. And a.status in
  1869. <foreach collection="orderList" open="(" close=")" separator="," item="item">
  1870. #{item}
  1871. </foreach>
  1872. </select>
  1873. <select id="selectAcceptCarriageFinishOrder" resultType="com.sckw.transport.model.vo.StatisticsByOrderVO">
  1874. SELECT
  1875. IFNULL( SUM( t1.WaitingAmount ), 0 ) AS WaitingAmount ,
  1876. IFNULL( SUM( t1.amount ), 0 ) AS amount ,
  1877. IFNULL( SUM( t1.entrustAmount ), 0 ) AS entrustAmount ,
  1878. IFNULL( SUM( t1.subcontractAmount ), 0 ) AS subcontractAmount ,
  1879. IFNULL( SUM( t1.totalPrice ), 0 ) AS totalPrice
  1880. FROM
  1881. (
  1882. SELECT
  1883. ( a.amount - IFNULL(a.total_load_amount,0)) AS WaitingAmount,
  1884. a.amount,
  1885. a.entrust_amount AS entrustAmount,
  1886. a.subcontract_amount AS subcontractAmount,
  1887. a.price ,
  1888. a.amount * IFNULL(a.price,0) AS totalPrice
  1889. FROM
  1890. kwt_logistics_order a
  1891. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  1892. AND a.del_flag = 0
  1893. AND b.del_flag = 0
  1894. WHERE
  1895. b.unit_type = #{unitType}
  1896. <if test="topId != null and topId !=''">
  1897. and b.top_ent_id = #{topId}
  1898. </if>
  1899. <if test="statusList != null and statusList.size()>0">
  1900. and a.`status` IN
  1901. <foreach collection="statusList" item="item" separator="," open="(" close=")">
  1902. #{item}
  1903. </foreach>
  1904. </if>
  1905. <if test="dateStart != null and dateStart != ''">
  1906. and a.create_time &gt;= #{dateStart,jdbcType=TIMESTAMP}
  1907. </if>
  1908. <if test="dateEnd != null and dateEnd != ''">
  1909. and a.create_time &lt;= #{dateEnd,jdbcType=TIMESTAMP}
  1910. </if>
  1911. ) t1
  1912. </select>
  1913. <select id="selectStatisticsByOrder" resultType="com.sckw.transport.model.vo.StatisticsByOrderVO">
  1914. SELECT
  1915. IFNULL( SUM( t1.WaitingAmount ), 0 ) AS WaitingAmount ,
  1916. IFNULL( SUM( t1.amount ), 0 ) AS amount ,
  1917. IFNULL( SUM( t1.entrustAmount ), 0 ) AS entrustAmount ,
  1918. IFNULL( SUM( t1.subcontractAmount ), 0 ) AS subcontractAmount ,
  1919. IFNULL( SUM( t1.totalPrice ), 0 ) AS totalPrice
  1920. FROM
  1921. (
  1922. SELECT
  1923. ( a.amount - a.entrust_amount - a.subcontract_amount ) AS WaitingAmount,
  1924. a.amount,
  1925. a.entrust_amount AS entrustAmount,
  1926. a.subcontract_amount AS subcontractAmount,
  1927. a.price ,
  1928. a.amount * IFNULL(a.price,0) AS totalPrice
  1929. FROM
  1930. kwt_logistics_order a
  1931. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  1932. AND a.del_flag = 0
  1933. AND b.del_flag = 0
  1934. WHERE
  1935. b.unit_type = #{unitType}
  1936. <if test="topId != null and topId !=''">
  1937. and b.top_ent_id = #{topId}
  1938. </if>
  1939. <if test="statusList != null and statusList.size()>0">
  1940. and a.`status` IN
  1941. <foreach collection="statusList" item="item" separator="," open="(" close=")">
  1942. #{item}
  1943. </foreach>
  1944. </if>
  1945. <if test="dateStart != null and dateStart != ''">
  1946. and a.create_time &gt;= #{dateStart,jdbcType=TIMESTAMP}
  1947. </if>
  1948. <if test="dateEnd != null and dateEnd != ''">
  1949. and a.create_time &lt;= #{dateEnd,jdbcType=TIMESTAMP}
  1950. </if>
  1951. ) t1
  1952. </select>
  1953. <select id="selectAcceptCarriageAwaitFinishOrder" resultType="com.sckw.transport.model.vo.StatisticsByOrderVO">
  1954. SELECT
  1955. IFNULL( SUM( t1.WaitingAmount ), 0 ) AS WaitingAmount ,
  1956. IFNULL( SUM( t1.amount ), 0 ) AS amount ,
  1957. IFNULL( SUM( t1.entrustAmount ), 0 ) AS entrustAmount ,
  1958. IFNULL( SUM( t1.subcontractAmount ), 0 ) AS subcontractAmount ,
  1959. IFNULL( SUM( t1.totalPrice ), 0 ) AS totalPrice
  1960. FROM
  1961. (
  1962. SELECT
  1963. ( a.amount - a.entrust_amount - a.subcontract_amount) AS WaitingAmount,
  1964. a.amount,
  1965. a.entrust_amount AS entrustAmount,
  1966. a.subcontract_amount AS subcontractAmount,
  1967. a.price ,
  1968. a.amount * IFNULL(a.price,0) AS totalPrice
  1969. FROM
  1970. kwt_logistics_order a
  1971. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  1972. AND a.del_flag = 0
  1973. AND b.del_flag = 0
  1974. WHERE
  1975. b.unit_type = #{unitType}
  1976. <if test="topId != null and topId !=''">
  1977. and b.top_ent_id = #{topId}
  1978. </if>
  1979. <if test="statusList != null and statusList.size()>0">
  1980. and a.`status` IN
  1981. <foreach collection="statusList" item="item" separator="," open="(" close=")">
  1982. #{item}
  1983. </foreach>
  1984. </if>
  1985. <if test="dateStart != null and dateStart != ''">
  1986. and a.create_time &gt;= #{dateStart,jdbcType=TIMESTAMP}
  1987. </if>
  1988. <if test="dateEnd != null and dateEnd != ''">
  1989. and a.create_time &lt;= #{dateEnd,jdbcType=TIMESTAMP}
  1990. </if>
  1991. ) t1
  1992. </select>
  1993. <select id="workbenchLogisticsOrderStatisticsByMonth" resultType="com.sckw.transport.model.vo.LogisticsOrderStatisticsVO">
  1994. SELECT A.date_time as dateTime, COALESCE(B.num, 0) as num,IFNULL(B.typeOne,0) AS typeOne , IFNULL(B.typeTwo,0) AS typeTwo FROM
  1995. (
  1996. SELECT
  1997. DATE_FORMAT( DATE_ADD( #{dateStart}, INTERVAL ROW1 MONTH ), '%Y-%m' ) date_time
  1998. FROM
  1999. (
  2000. SELECT
  2001. @ROW := @ROW +1 as ROW1
  2002. FROM
  2003. (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t,
  2004. (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t2,
  2005. (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t3,
  2006. (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t4,
  2007. (SELECT @row:=-1) r
  2008. ) se
  2009. WHERE
  2010. DATE_FORMAT( date_add( #{dateStart}, INTERVAL ROW1 MONTH ), '%Y-%m' ) &lt;= DATE_FORMAT(
  2011. #{dateEnd},
  2012. '%Y-%m')
  2013. ) A
  2014. LEFT JOIN
  2015. (
  2016. SELECT DATE_FORMAT(a.create_time, '%Y-%m') date_time, COUNT(*) num,
  2017. CASE WHEN #{typeOne} = 1 THEN
  2018. sum( a.amount )
  2019. WHEN #{typeOne} = 2 THEN
  2020. sum(a.amount * IFNULL( a.price, 0 ))
  2021. ELSE 0 end AS typeOne,
  2022. CASE WHEN #{typeTwo} = 2 THEN
  2023. sum(a.amount * IFNULL( a.price, 0 ))
  2024. WHEN #{typeTwo} = 1 THEN
  2025. sum( a.amount )
  2026. ELSE 0 end AS typeTwo
  2027. FROM kwt_logistics_order a LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  2028. WHERE a.del_flag = 0 AND b.unit_type = #{type}
  2029. <if test="statusList != null and statusList.size() > 0">
  2030. and a.status in
  2031. <foreach collection="statusList" close=")" open="(" separator="," item="item">
  2032. #{item}
  2033. </foreach>
  2034. </if>
  2035. GROUP BY DATE_FORMAT(a.create_time, '%Y-%m')
  2036. ) B
  2037. ON A.date_time = B.date_time
  2038. </select>
  2039. <select id="workbenchLogisticsOrderStatisticsByDays"
  2040. resultType="com.sckw.transport.model.vo.LogisticsOrderStatisticsVO">
  2041. SELECT A.date as dateTime, COALESCE(B.num, 0) as num,IFNULL(B.typeOne,0) AS typeOne , IFNULL(B.typeTwo,0) AS typeTwo FROM
  2042. (
  2043. select date_add(#{dateStart}, interval row1 DAY) date from
  2044. (
  2045. SELECT @row := @row + 1 as row1 FROM
  2046. (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t,
  2047. (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t2,
  2048. (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t3,
  2049. (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t4,
  2050. (SELECT @row:=-1) r
  2051. ) se
  2052. where date_add(#{dateStart}, interval row1 DAY) &lt;= #{dateEnd}
  2053. ) A
  2054. LEFT JOIN
  2055. (
  2056. SELECT
  2057. COUNT(*) num,
  2058. CASE
  2059. WHEN #{typeOne} = 1 THEN
  2060. sum( a.amount )
  2061. WHEN #{typeOne} = 2 THEN
  2062. sum(a.amount * IFNULL( a.price, 0 ))
  2063. ELSE 0 end AS typeOne,
  2064. CASE
  2065. WHEN #{typeTwo} = 2 THEN
  2066. sum(a.amount * IFNULL( a.price, 0 ) )
  2067. WHEN #{typeTwo} = 1 THEN
  2068. sum( a.amount )
  2069. ELSE 0 end AS typeTwo,
  2070. DATE_FORMAT(a.create_time, '%Y-%m-%d') date_time
  2071. FROM kwt_logistics_order a LEFT JOIN kwt_logistics_order_unit b ON a.id =b.l_order_id
  2072. WHERE a.del_flag = 0 AND b.unit_type = b.unit_type = #{type}
  2073. <if test="statusList != null and statusList.size() > 0">
  2074. and a.status in
  2075. <foreach collection="statusList" close=")" open="(" separator="," item="item">
  2076. #{item}
  2077. </foreach>
  2078. </if>
  2079. GROUP BY DATE_FORMAT(a.create_time, '%Y-%m-%d')
  2080. ) B
  2081. ON A.date= B.date_time;
  2082. </select>
  2083. <select id="selectLogisticsOrderListByAcceptCarriage"
  2084. resultType="com.sckw.transport.model.vo.AcceptCarriageOrderVO">
  2085. SELECT <include refid="New_Query_Column_List"></include> FROM (
  2086. SELECT
  2087. <include refid="Query_Column_List_Accept_Carriage">
  2088. </include>
  2089. FROM
  2090. kwt_logistics_order a
  2091. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  2092. AND b.address_type = 1 AND b.del_flag = 0
  2093. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  2094. AND c.address_type = 2 AND c.del_flag = 0
  2095. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  2096. AND d.unit_type = 1 AND d.del_flag = 0
  2097. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  2098. AND e.unit_type = 2
  2099. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  2100. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  2101. <where>
  2102. a.del_flag = 0
  2103. <if test="query.keywords != null and query.keywords != ''">
  2104. and (
  2105. a.t_order_no like concat('%',#{query.keywords},'%')
  2106. or a.l_order_no like concat('%',#{query.keywords},'%')
  2107. or d.firm_name like concat('%',#{query.keywords},'%')
  2108. or e.firm_name like concat('%',#{query.keywords},'%')
  2109. or g.goods_name like concat('%',#{query.keywords},'%'))
  2110. </if>
  2111. <if test="orderList != null and orderList.size() > 0 ">
  2112. and a.status in
  2113. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  2114. #{status}
  2115. </foreach>
  2116. </if>
  2117. <if test="idsList != null and idsList.size()>0">
  2118. and a.id in
  2119. <foreach collection="idsList" close=")" open="(" separator="," item="item">
  2120. #{item}
  2121. </foreach>
  2122. </if>
  2123. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  2124. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  2125. </if>
  2126. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  2127. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  2128. </if>
  2129. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  2130. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  2131. </if>
  2132. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  2133. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  2134. </if>
  2135. <if test="query.createStartTime != null and query.createStartTime != '' ">
  2136. and a.create_time &gt;=#{query.createStartTime}
  2137. </if>
  2138. <if test="query.createEndTime != null and query.createEndTime != ''">
  2139. and a.create_time &lt;=#{query.createEndTime}
  2140. </if>
  2141. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  2142. and b.city_code = #{query.loadAddressCode}
  2143. </if>
  2144. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  2145. and c.city_code = #{query.unloadAddressCode}
  2146. </if>
  2147. <if test="query.billingMode != null and query.billingMode != ''">
  2148. and a.billing_mode =#{query.billingMode}
  2149. </if>
  2150. </where>
  2151. ORDER BY a.create_time DESC
  2152. ) tab
  2153. <where>
  2154. tab.delFlag = 0
  2155. AND ((
  2156. tab.createType = 1
  2157. and tab.entId = #{entId}
  2158. <if test="userIds != null and userIds.size()>0">
  2159. AND tab.createBy IN
  2160. <foreach collection="userIds" open="(" close=")" item="item" separator=",">
  2161. #{item}
  2162. </foreach>
  2163. </if>
  2164. )
  2165. OR (
  2166. tab.carrierTopEntId = #{entId}
  2167. <if test="contactsIds != null and contactsIds.size()>0">
  2168. AND tab.carrierContactsId IN
  2169. <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
  2170. #{item}
  2171. </foreach>
  2172. </if>
  2173. ))
  2174. </where>
  2175. </select>
  2176. <select id="selectLogisticsOrderListByConsign" resultType="com.sckw.transport.model.vo.AcceptCarriageOrderVO">
  2177. SELECT <include refid="New_Query_Column_List"></include> FROM (
  2178. SELECT
  2179. <include refid="Query_Column_List_Cogsign">
  2180. </include>
  2181. FROM
  2182. kwt_logistics_order a
  2183. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  2184. AND b.address_type = 1 AND b.del_flag = 0
  2185. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  2186. AND c.address_type = 2 AND c.del_flag = 0
  2187. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  2188. AND d.unit_type = 1 AND d.del_flag = 0
  2189. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  2190. AND e.unit_type = 2
  2191. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  2192. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  2193. <where>
  2194. a.del_flag = 0
  2195. <if test="query.keywords != null and query.keywords != ''">
  2196. and (
  2197. a.t_order_no like concat('%',#{query.keywords},'%')
  2198. or a.l_order_no like concat('%',#{query.keywords},'%')
  2199. or d.firm_name like concat('%',#{query.keywords},'%')
  2200. or e.firm_name like concat('%',#{query.keywords},'%')
  2201. or g.goods_name like concat('%',#{query.keywords},'%'))
  2202. </if>
  2203. <if test="orderList != null and orderList.size() > 0 ">
  2204. and a.status in
  2205. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  2206. #{status}
  2207. </foreach>
  2208. </if>
  2209. <if test="idsList != null and idsList.size()>0">
  2210. and a.id in
  2211. <foreach collection="idsList" close=")" open="(" separator="," item="item">
  2212. #{item}
  2213. </foreach>
  2214. </if>
  2215. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  2216. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  2217. </if>
  2218. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  2219. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  2220. </if>
  2221. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  2222. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  2223. </if>
  2224. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  2225. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  2226. </if>
  2227. <if test="query.createStartTime != null and query.createStartTime != '' ">
  2228. and a.create_time &gt;=#{query.createStartTime}
  2229. </if>
  2230. <if test="query.createEndTime != null and query.createEndTime != ''">
  2231. and a.create_time &lt;=#{query.createEndTime}
  2232. </if>
  2233. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  2234. and b.city_code = #{query.loadAddressCode}
  2235. </if>
  2236. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  2237. and c.city_code = #{query.unloadAddressCode}
  2238. </if>
  2239. <if test="query.billingMode != null and query.billingMode != ''">
  2240. and a.billing_mode =#{query.billingMode}
  2241. </if>
  2242. </where>
  2243. ORDER BY a.create_time DESC
  2244. ) tab
  2245. <where>
  2246. tab.delFlag = 0
  2247. AND ((
  2248. tab.createType = 1
  2249. and tab.entId = #{entId}
  2250. <if test="userIds != null and userIds.size()>0">
  2251. AND tab.createBy IN
  2252. <foreach collection="userIds" open="(" close=")" item="item" separator=",">
  2253. #{item}
  2254. </foreach>
  2255. </if>
  2256. )
  2257. OR (
  2258. tab.consignTopEntId = #{entId}
  2259. <if test="contactsIds != null and contactsIds.size()>0">
  2260. AND tab.consignContactsId IN
  2261. <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
  2262. #{item}
  2263. </foreach>
  2264. </if>
  2265. ))
  2266. </where>
  2267. ORDER BY tab.createTime DESC
  2268. </select>
  2269. <select id="countLogisticsOrderListByConsignStatus" resultType="com.sckw.mongo.model.TableTops">
  2270. select status AS value ,
  2271. COUNT(status) AS total FROM (
  2272. SELECT
  2273. <include refid="Query_Column_List_Cogsign">
  2274. </include>
  2275. FROM
  2276. kwt_logistics_order a
  2277. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  2278. AND b.address_type = 1 AND b.del_flag = 0
  2279. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  2280. AND c.address_type = 2 AND c.del_flag = 0
  2281. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  2282. AND d.unit_type = 1 AND d.del_flag = 0
  2283. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  2284. AND e.unit_type = 2
  2285. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  2286. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  2287. <where>
  2288. a.del_flag = 0
  2289. <if test="query.keywords != null and query.keywords != ''">
  2290. and (
  2291. a.t_order_no like concat('%',#{query.keywords},'%')
  2292. or a.l_order_no like concat('%',#{query.keywords},'%')
  2293. or d.firm_name like concat('%',#{query.keywords},'%')
  2294. or e.firm_name like concat('%',#{query.keywords},'%')
  2295. or g.goods_name like concat('%',#{query.keywords},'%'))
  2296. </if>
  2297. <if test="orderList != null and orderList.size() > 0 ">
  2298. and a.status in
  2299. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  2300. #{status}
  2301. </foreach>
  2302. </if>
  2303. <if test="idsList != null and idsList.size()>0">
  2304. and a.id in
  2305. <foreach collection="idsList" close=")" open="(" separator="," item="item">
  2306. #{item}
  2307. </foreach>
  2308. </if>
  2309. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  2310. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  2311. </if>
  2312. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  2313. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  2314. </if>
  2315. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  2316. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  2317. </if>
  2318. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  2319. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  2320. </if>
  2321. <if test="query.createStartTime != null and query.createStartTime != '' ">
  2322. and a.create_time &gt;=#{query.createStartTime}
  2323. </if>
  2324. <if test="query.createEndTime != null and query.createEndTime != ''">
  2325. and a.create_time &lt;=#{query.createEndTime}
  2326. </if>
  2327. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  2328. and b.city_code = #{query.loadAddressCode}
  2329. </if>
  2330. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  2331. and c.city_code = #{query.unloadAddressCode}
  2332. </if>
  2333. <if test="query.billingMode != null and query.billingMode != ''">
  2334. and a.billing_mode =#{query.billingMode}
  2335. </if>
  2336. </where>
  2337. ORDER BY a.create_time DESC
  2338. ) tab
  2339. <where>
  2340. tab.delFlag = 0
  2341. AND ((
  2342. tab.createType = 1
  2343. and tab.entId = #{entId}
  2344. <if test="userIds != null and userIds.size()>0">
  2345. AND tab.createBy IN
  2346. <foreach collection="userIds" open="(" close=")" item="item" separator=",">
  2347. #{item}
  2348. </foreach>
  2349. </if>
  2350. )
  2351. OR (
  2352. tab.consignTopEntId = #{entId}
  2353. <if test="contactsIds != null and contactsIds.size()>0">
  2354. AND tab.consignContactsId IN
  2355. <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
  2356. #{item}
  2357. </foreach>
  2358. </if>
  2359. ))
  2360. </where>
  2361. group by status
  2362. </select>
  2363. <select id="countLogisticsOrderListByAcceptCarriageStatus" resultType="com.sckw.mongo.model.TableTops">
  2364. SELECT status as value,
  2365. COUNT( status ) AS total FROM (
  2366. SELECT
  2367. <include refid="Query_Column_List_Accept_Carriage">
  2368. </include>
  2369. FROM
  2370. kwt_logistics_order a
  2371. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  2372. AND b.address_type = 1 AND b.del_flag = 0
  2373. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  2374. AND c.address_type = 2 AND c.del_flag = 0
  2375. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  2376. AND d.unit_type = 1 AND d.del_flag = 0
  2377. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  2378. AND e.unit_type = 2
  2379. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  2380. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  2381. <where>
  2382. a.del_flag = 0
  2383. <if test="query.keywords != null and query.keywords != ''">
  2384. and (
  2385. a.t_order_no like concat('%',#{query.keywords},'%')
  2386. or a.l_order_no like concat('%',#{query.keywords},'%')
  2387. or d.firm_name like concat('%',#{query.keywords},'%')
  2388. or e.firm_name like concat('%',#{query.keywords},'%')
  2389. or g.goods_name like concat('%',#{query.keywords},'%'))
  2390. </if>
  2391. <if test="orderList != null and orderList.size() > 0 ">
  2392. and a.status in
  2393. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  2394. #{status}
  2395. </foreach>
  2396. </if>
  2397. <if test="idsList != null and idsList.size()>0">
  2398. and a.id in
  2399. <foreach collection="idsList" close=")" open="(" separator="," item="item">
  2400. #{item}
  2401. </foreach>
  2402. </if>
  2403. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  2404. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  2405. </if>
  2406. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  2407. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  2408. </if>
  2409. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  2410. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  2411. </if>
  2412. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  2413. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  2414. </if>
  2415. <if test="query.createStartTime != null and query.createStartTime != '' ">
  2416. and a.create_time &gt;=#{query.createStartTime}
  2417. </if>
  2418. <if test="query.createEndTime != null and query.createEndTime != ''">
  2419. and a.create_time &lt;=#{query.createEndTime}
  2420. </if>
  2421. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  2422. and b.city_code = #{query.loadAddressCode}
  2423. </if>
  2424. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  2425. and c.city_code = #{query.unloadAddressCode}
  2426. </if>
  2427. <if test="query.billingMode != null and query.billingMode != ''">
  2428. and a.billing_mode =#{query.billingMode}
  2429. </if>
  2430. </where>
  2431. ORDER BY a.create_time DESC
  2432. ) tab
  2433. <where>
  2434. tab.delFlag = 0
  2435. AND ((
  2436. tab.createType = 1
  2437. and tab.entId = #{entId}
  2438. <if test="userIds != null and userIds.size()>0">
  2439. AND tab.createBy IN
  2440. <foreach collection="userIds" open="(" close=")" item="item" separator=",">
  2441. #{item}
  2442. </foreach>
  2443. </if>
  2444. )
  2445. OR (
  2446. tab.carrierTopEntId = #{entId}
  2447. <if test="contactsIds != null and contactsIds.size()>0">
  2448. AND tab.carrierContactsId IN
  2449. <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
  2450. #{item}
  2451. </foreach>
  2452. </if>
  2453. ))
  2454. </where>
  2455. group by status
  2456. </select>
  2457. <select id="selectConsignLogisticsOrderListByConsign" resultType="com.sckw.transport.model.vo.ConsignOrderVO">
  2458. SELECT <include refid="New_Query_Column_List"></include> FROM (
  2459. SELECT
  2460. <include refid="Query_Column_List_Cogsign">
  2461. </include>
  2462. FROM
  2463. kwt_logistics_order a
  2464. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  2465. AND b.address_type = 1 AND b.del_flag = 0
  2466. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  2467. AND c.address_type = 2 AND c.del_flag = 0
  2468. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  2469. AND d.unit_type = 1 AND d.del_flag = 0
  2470. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  2471. AND e.unit_type = 2
  2472. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  2473. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  2474. <where>
  2475. a.del_flag = 0
  2476. <if test="query.keywords != null and query.keywords != ''">
  2477. and (
  2478. a.t_order_no like concat('%',#{query.keywords},'%')
  2479. or a.l_order_no like concat('%',#{query.keywords},'%')
  2480. or d.firm_name like concat('%',#{query.keywords},'%')
  2481. or e.firm_name like concat('%',#{query.keywords},'%')
  2482. or g.goods_name like concat('%',#{query.keywords},'%'))
  2483. </if>
  2484. <if test="orderList != null and orderList.size() > 0 ">
  2485. and a.status in
  2486. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  2487. #{status}
  2488. </foreach>
  2489. </if>
  2490. <if test="idsList != null and idsList.size()>0">
  2491. and a.id in
  2492. <foreach collection="idsList" close=")" open="(" separator="," item="item">
  2493. #{item}
  2494. </foreach>
  2495. </if>
  2496. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  2497. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  2498. </if>
  2499. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  2500. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  2501. </if>
  2502. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  2503. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  2504. </if>
  2505. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  2506. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  2507. </if>
  2508. <if test="query.createStartTime != null and query.createStartTime != '' ">
  2509. and a.create_time &gt;=#{query.createStartTime}
  2510. </if>
  2511. <if test="query.createEndTime != null and query.createEndTime != ''">
  2512. and a.create_time &lt;=#{query.createEndTime}
  2513. </if>
  2514. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  2515. and b.city_code = #{query.loadAddressCode}
  2516. </if>
  2517. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  2518. and c.city_code = #{query.unloadAddressCode}
  2519. </if>
  2520. <if test="query.billingMode != null and query.billingMode != ''">
  2521. and a.billing_mode =#{query.billingMode}
  2522. </if>
  2523. </where>
  2524. ORDER BY a.create_time DESC
  2525. ) tab
  2526. <where>
  2527. tab.delFlag = 0
  2528. AND ((
  2529. tab.createType = 1
  2530. and tab.entId = #{entId}
  2531. <if test="userIds != null and userIds.size()>0">
  2532. AND tab.createBy IN
  2533. <foreach collection="userIds" open="(" close=")" item="item" separator=",">
  2534. #{item}
  2535. </foreach>
  2536. </if>
  2537. )
  2538. OR (
  2539. tab.consignTopEntId = #{entId}
  2540. <if test="contactsIds != null and contactsIds.size()>0">
  2541. AND tab.consignContactsId IN
  2542. <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
  2543. #{item}
  2544. </foreach>
  2545. </if>
  2546. ))
  2547. </where>
  2548. ORDER BY tab.createTime DESC
  2549. </select>
  2550. <select id="findLogisticsOrderCount" resultType="com.sckw.transport.model.vo.LogisticsCountVo" parameterType="java.util.Map">
  2551. SELECT
  2552. IFNULL(sum(load_amount), 0.0) loadAmount, IFNULL(sum(unload_amount), 0.0) unloadAmount,
  2553. IFNULL(sum(total_load_amount), 0.0) totalLoadAmount, IFNULL(sum(total_unload_amount), 0.0) totalUnloadAmount
  2554. from kwt_logistics_order where del_flag = 0
  2555. <if test="tOrderId != null and tOrderId != ''">
  2556. and t_order_id = #{tOrderId, jdbcType=BIGINT}
  2557. </if>
  2558. <if test="lOrderId != null and lOrderId != ''">
  2559. and id = #{lOrderId, jdbcType=BIGINT}
  2560. </if>
  2561. <if test="level != null and level != ''">
  2562. and pid is null
  2563. </if>
  2564. <if test="finishedStatus != null and finishedStatus != ''">
  2565. and status in (4, 5, 6)
  2566. </if>
  2567. <if test="status != null and status != ''">
  2568. and status = #{lOrderId, jdbcType=INTEGER}
  2569. </if>
  2570. <if test="upperlOrderId != null and upperlOrderId != ''">
  2571. and FIND_IN_SET(#{upperlOrderId, jdbcType=BIGINT}, pids)
  2572. </if>
  2573. <if test="belowlOrderId != null and belowlOrderId != ''">
  2574. and FIND_IN_SET(id, #{belowlOrderId, jdbcType=VARCHAR})
  2575. </if>
  2576. </select>
  2577. </mapper>