KwtLogisticsOrderMapper.xml 140 KB

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