KwtLogisticsOrderMapper.xml 119 KB

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