KwtLogisticsOrderMapper.xml 115 KB

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