KwtLogisticsOrderMapper.xml 118 KB

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