KwtLogisticsOrderMapper.xml 115 KB

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