KwtLogisticsOrderMapper.xml 114 KB

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