KwtLogisticsOrderMapper.xml 134 KB

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