KwtLogisticsOrderMapper.xml 137 KB

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