KwtLogisticsOrderMapper.xml 127 KB

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