KwtLogisticsOrderMapper.xml 115 KB

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