KwtLogisticsOrderMapper.xml 138 KB

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