KwtLogisticsOrderMapper.xml 119 KB

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