KwtLogisticsOrderMapper.xml 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.sckw.transport.dao.KwtLogisticsOrderMapper">
  4. <resultMap id="BaseResultMap" type="com.sckw.transport.model.KwtLogisticsOrder">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="ent_id" jdbcType="BIGINT" property="entId"/>
  7. <result column="type" jdbcType="BIGINT" property="type"/>
  8. <result column="t_order_id" jdbcType="BIGINT" property="tOrderId"/>
  9. <result column="t_order_no" jdbcType="VARCHAR" property="tOrderNo"/>
  10. <result column="l_order_no" jdbcType="VARCHAR" property="lOrderNo"/>
  11. <result column="pid" jdbcType="BIGINT" property="pid"/>
  12. <result column="pids" jdbcType="VARCHAR" property="pids"/>
  13. <result column="level" jdbcType="VARCHAR" property="level"/>
  14. <result column="bind_status" jdbcType="VARCHAR" property="bindStatus"/>
  15. <result column="total_load_amount" jdbcType="VARCHAR" property="totalLoadAmount"/>
  16. <result column="total_unload_amount" jdbcType="VARCHAR" property="totalUnloadAmount"/>
  17. <result column="settlement_cycle" jdbcType="BIGINT" property="settlementCycle"/>
  18. <result column="billing_mode" jdbcType="BIGINT" property="billingMode"/>
  19. <result column="price" jdbcType="DECIMAL" property="price"/>
  20. <result column="price_type" jdbcType="BIGINT" property="priceType"/>
  21. <result column="amount" jdbcType="DECIMAL" property="amount"/>
  22. <result column="unit" jdbcType="VARCHAR" property="unit"/>
  23. <result column="loss" jdbcType="DECIMAL" property="loss"/>
  24. <result column="loss_unit" jdbcType="VARCHAR" property="lossUnit"/>
  25. <result column="goods_price" jdbcType="DECIMAL" property="goodsPrice"/>
  26. <result column="goods_price_unit" jdbcType="VARCHAR" property="goodsPriceUnit"/>
  27. <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
  28. <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
  29. <result column="subcontract_amount" jdbcType="DECIMAL" property="subcontractAmount"/>
  30. <result column="entrust_amount" jdbcType="DECIMAL" property="entrustAmount"/>
  31. <result column="unload_amount" jdbcType="DECIMAL" property="unloadAmount"/>
  32. <result column="load_amount" jdbcType="DECIMAL" property="loadAmount"/>
  33. <result column="ignore_amount" jdbcType="DECIMAL" property="ignoreAmount"/>
  34. <result column="deficit_amount" jdbcType="DECIMAL" property="deficitAmount"/>
  35. <result column="deficit_price" jdbcType="DECIMAL" property="deficitPrice"/>
  36. <result column="payment" jdbcType="BIGINT" property="payment"/>
  37. <result column="tax_rate" jdbcType="DECIMAL" property="taxRate"/>
  38. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  39. <result column="status" jdbcType="INTEGER" property="status"/>
  40. <result column="create_by" jdbcType="BIGINT" property="createBy"/>
  41. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  42. <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
  43. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  44. <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
  45. </resultMap>
  46. <sql id="Base_Column_List">
  47. id
  48. , ent_id, t_order_id,type,level,bind_status,total_load_amount,total_unload_amount, t_order_no, l_order_no, pid,pids, settlement_cycle, price, price_type,billing_mode,
  49. amount, unit, loss, loss_unit, goods_price, goods_price_unit, start_time, end_time,
  50. subcontract_amount, entrust_amount, unload_amount, load_amount, ignore_amount, deficit_amount,
  51. deficit_price, payment, tax_rate, remark, `status`, create_by, create_time, update_by,
  52. update_time, del_flag
  53. </sql>
  54. <select id="selectOrderList" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
  55. SELECT a.id as lOrderId,
  56. a.l_order_no as lOrderNo,
  57. b.`status` as `status`,
  58. a.t_order_id as tOrderId,
  59. a.t_order_no as tOrderNo,
  60. a.payment as payment,
  61. a.amount,
  62. a.price,
  63. a.loss,
  64. a.goods_price as goodsPrice,
  65. c.firm_name as comanyName,
  66. c.contacts,
  67. c.phone,
  68. a.create_by as createBy,
  69. a.create_time as createTime
  70. FROM kwt_logistics_order a
  71. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
  72. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  73. WHERE a.del_flag = '0'
  74. AND b.del_flag = '0'
  75. AND a.t_order_id = #{id,jdbcType=VARCHAR} limit #{page}
  76. , #{pageSize}
  77. </select>
  78. <select id="selectOrderListNotPage" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
  79. SELECT a.id as lOrderId,
  80. a.l_order_no as lOrderNo,
  81. b.`status` as `status`,
  82. a.t_order_id as tOrderId,
  83. a.t_order_no as tOrderNo,
  84. a.payment as payment,
  85. a.amount,
  86. a.unit as unit,
  87. a.price,
  88. a.price_type as priceType,
  89. a.loss,
  90. a.loss_unit AS lossUnit,
  91. a.goods_price as goodsPrice,
  92. a.goods_price_unit as goodsPriceUnit,
  93. c.firm_name as companyName,
  94. c.contacts,
  95. c.phone,
  96. a.create_by as createBy,
  97. a.create_time as createTime
  98. FROM kwt_logistics_order a
  99. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
  100. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  101. WHERE a.del_flag = '0'
  102. AND b.del_flag = '0'
  103. AND a.t_order_id = #{id,jdbcType=VARCHAR}
  104. order by createTime desc
  105. </select>
  106. <select id="selectOrderListByContractId" resultType="com.sckw.transport.model.vo.SckwLogisticsOrderVO">
  107. SELECT
  108. a.STATUS,
  109. a.id AS lOrderId,
  110. a.l_order_no AS lOrderNo,
  111. f.contract_no AS contractNo,
  112. d.id as checkId,
  113. d.ent_id as checkEntId,
  114. d.top_ent_id as checkTopEntId,
  115. d.firm_name AS checkFirmName,
  116. e.id as carrierId,
  117. e.ent_id as carrierEntId,
  118. e.top_ent_id as carrierTopEntId,
  119. e.firm_name AS carrierFirmName,
  120. g.goods_name AS goodsName,
  121. a.amount AS carryingCapacity,
  122. a.price AS price,
  123. b.city_name AS loadCityName,
  124. b.detail_address AS loadDetailAddress,
  125. a.payment AS payment,
  126. a.loss AS loss,
  127. a.loss_unit AS lossUnit,
  128. a.goods_price AS goodsPrice,
  129. a.goods_price_unit AS goodsPriceUnit,
  130. a.settlement_cycle AS settlementCycle,
  131. e.contacts AS carrierContacts,
  132. e.phone AS carrierPhone,
  133. d.contacts AS checkContacts,
  134. d.phone AS checkPhone,
  135. b.contacts AS loadContacts,
  136. b.phone AS loadPhone,
  137. c.contacts AS unloadContacts,
  138. c.phone AS unloadPhone,
  139. a.start_time AS startTime,
  140. a.end_time AS endTime,
  141. a.remark AS remark,
  142. a.create_by AS createBy,
  143. a.create_time AS createTime,
  144. f.contract_id AS contractId,
  145. a.amount AS amount,
  146. c.detail_address as unloadDetailAddress
  147. FROM
  148. kwt_logistics_order a
  149. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  150. AND b.address_type = 1
  151. AND b.del_flag = 0
  152. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  153. AND c.address_type = 2
  154. AND c.del_flag = 0
  155. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  156. AND d.unit_type = 1
  157. AND d.del_flag = 0
  158. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  159. AND e.unit_type = 2
  160. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id
  161. AND g.del_flag = 0
  162. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id
  163. AND f.del_flag = 0
  164. <where>
  165. a.del_flag = 0
  166. <!-- <if test="type == 1">-->
  167. <!-- and (d.top_ent_id = #{entId} or d.ent_id = #{entId})-->
  168. <!-- </if>-->
  169. <!-- <if test="type == 2">-->
  170. <!-- and (e.top_ent_id = #{entId} or e.ent_id = #{entId})-->
  171. <!-- </if>-->
  172. <if test="contractIds != null and contractIds.size() > 0">
  173. and f.contract_id in
  174. <foreach collection="contractIds" item="item" separator="," open="(" close=")">
  175. #{item}
  176. </foreach>
  177. </if>
  178. </where>
  179. ORDER BY a.id DESC
  180. </select>
  181. <select id="selectOrderCount" resultType="java.lang.Long">
  182. SELECT count(a.id)
  183. FROM kwt_logistics_order a
  184. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
  185. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  186. WHERE a.del_flag = '0'
  187. AND b.del_flag = '0'
  188. AND a.t_order_id = #{id,jdbcType=VARCHAR}
  189. </select>
  190. <select id="selectLogisticOrderData" resultType="com.sckw.transport.api.model.vo.LogisticsOrderVO">
  191. SELECT
  192. DISTINCT a.id AS lOrderId,
  193. a.l_order_no AS lOrderNO,
  194. a.t_order_id AS tOrderId,
  195. a.t_order_no AS tOrderNO,
  196. a.payment AS payment,
  197. a.billing_mode AS billingMode,
  198. c.contract_id AS contractId,
  199. c.contract_no AS contractNo,
  200. c.contract_name AS contractName,
  201. b.goods_name AS goodsName,
  202. a.amount,
  203. a.remark as remark,
  204. a.unit ,
  205. a.ignore_amount AS ignoreAmount,
  206. a.price,
  207. a.price_type as priceType,
  208. a.goods_price AS goodsPrice,
  209. a.goods_price_unit AS goodsPriceUnit,
  210. a.loss,
  211. a.loss_unit AS lossUnit,
  212. a.tax_rate as taxRate,
  213. a.load_amount AS loadAmount,
  214. a.unload_amount AS unloadAmount,
  215. a.total_load_amount AS totalLoadAmount,
  216. a.total_unload_amount AS totalUnloadAmount,
  217. a.settlement_cycle as settlementCycle,
  218. a.start_time AS startTime,
  219. a.end_time AS endTime,
  220. a.create_time AS createTime,
  221. a.create_by AS createBy,
  222. a.update_by AS updateBy,
  223. a.update_time AS updateTime
  224. FROM
  225. kwt_logistics_order a
  226. LEFT JOIN kwt_logistics_order_goods b ON a.id = b.l_order_id and a.bind_status = '0'
  227. <!-- LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id-->
  228. LEFT JOIN kwt_logistics_order_contract c ON a.id = c.l_order_id
  229. <!-- 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-->
  230. <!-- 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-->
  231. LEFT JOIN kwt_logistics_order_unit g on a.id = g.l_order_id and g.unit_type= 1
  232. LEFT JOIN kwt_logistics_order_unit h on a.id = h.l_order_id and h.unit_type= 2
  233. <where>
  234. a.del_flag = 0 and a.bind_status = '0' <!--and d.unit_type = 1-->
  235. <if test="dictValue != null and dictValue != ''">
  236. AND a.payment = #{dictValue}
  237. </if>
  238. <if test="logisticsOrderParam.companyId !=null and logisticsOrderParam.companyId != ''">
  239. <!-- AND d.ent_id = #{logisticsOrderParam.companyId}-->
  240. AND g.ent_id = #{logisticsOrderParam.companyId}
  241. </if>
  242. <if test="ids !=null and ids.size() > 0 ">
  243. AND ( h.ent_id in
  244. <foreach collection="ids" open="(" close=")" separator="," item="item">
  245. #{item}
  246. </foreach>
  247. or h.top_ent_id in
  248. <foreach collection="ids" item="item" separator="," close=")" open="(">
  249. #{item}
  250. </foreach>
  251. )
  252. </if>
  253. <if test="logisticsOrderParam.taxRate != null and logisticsOrderParam.taxRate != ''">
  254. AND a.tax_rate = #{logisticsOrderParam.taxRate}
  255. </if>
  256. <if test="logisticsOrderParam.goodsName != null and logisticsOrderParam.goodsName != ''">
  257. AND b.goods_name LIKE concat('%',#{logisticsOrderParam.goodsName},'%')
  258. </if>
  259. <if test="logisticsOrderParam.startTime != null and logisticsOrderParam.startTime !=''">
  260. AND a.start_time &gt;= #{logisticsOrderParam.startTime}
  261. </if>
  262. <if test="logisticsOrderParam.endTime != null and logisticsOrderParam.endTime !=''">
  263. AND a.end_time &lt;= #{logisticsOrderParam.endTime}
  264. </if>
  265. </where>
  266. ORDER BY a.create_time DESC
  267. <if test="logisticsOrderParam.page != null and logisticsOrderParam.pageSize != null ">
  268. limit #{logisticsOrderParam.page,jdbcType=INTEGER},#{logisticsOrderParam.pageSize,jdbcType=INTEGER}
  269. </if>
  270. </select>
  271. <select id="selectLogisticOrderCount" resultType="java.lang.Long">
  272. SELECT
  273. count(a.id)
  274. FROM
  275. kwt_logistics_order a
  276. LEFT JOIN kwt_logistics_order_goods b ON a.id = b.l_order_id
  277. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  278. LEFT JOIN kwt_logistics_order_unit h ON a.id = h.l_order_id
  279. LEFT JOIN kwt_logistics_order_contract c ON a.id=c.l_order_id
  280. <where>
  281. a.del_flag = 0 and d.unit_type = 1 and h.unit_type = 2 and a.bind_status='0'
  282. <if test="dictValue != null and dictValue != ''">
  283. AND a.payment = #{dictValue}
  284. </if>
  285. <if test="logisticsOrderParam.companyId !=null and logisticsOrderParam.companyId != ''">
  286. AND d.ent_id = #{logisticsOrderParam.companyId}
  287. </if>
  288. <if test="ids !=null and ids.size() > 0 ">
  289. AND ( h.ent_id in
  290. <foreach collection="ids" open="(" close=")" separator="," item="item">
  291. #{item}
  292. </foreach>
  293. or h.top_ent_id in
  294. <foreach collection="ids" item="item" separator="," close=")" open="(">
  295. #{item}
  296. </foreach>
  297. )
  298. </if>
  299. <if test="logisticsOrderParam.taxRate != null and logisticsOrderParam.taxRate != ''">
  300. AND a.tax_rate = #{logisticsOrderParam.taxRate}
  301. </if>
  302. <if test="logisticsOrderParam.goodsName != null and logisticsOrderParam.goodsName != ''">
  303. AND b.goods_name LIKE concat('%',#{logisticsOrderParam.goodsName},'%')
  304. </if>
  305. <if test="logisticsOrderParam.startTime != null and logisticsOrderParam.startTime !=''">
  306. AND a.start_time &gt;= #{logisticsOrderParam.startTime}
  307. </if>
  308. <if test="logisticsOrderParam.endTime != null and logisticsOrderParam.endTime !=''">
  309. AND a.end_time &lt;= #{logisticsOrderParam.endTime}
  310. </if>
  311. </where>
  312. ORDER BY a.create_time DESC
  313. </select>
  314. <select id="getRejectReason" resultType="java.util.Map">
  315. SELECT a.id AS lOrderId,
  316. b.remark remark
  317. FROM kwt_logistics_order a
  318. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id
  319. WHERE a.del_flag = '0'
  320. AND b.del_flag = '0'
  321. and b.status = #{status}
  322. and a.id = #{id}
  323. </select>
  324. <select id="getSubcontractConsignment" resultType="com.sckw.transport.model.vo.SubcontractConsignmentVO">
  325. SELECT a.id,
  326. a.pid,
  327. a.`status` as status,
  328. a.l_order_no as consignOrderNo,
  329. c.firm_name as carrierContacts,
  330. d.goods_name as goodsName,
  331. a.amount as amount,
  332. a.price,
  333. a.price_type as priceType,
  334. e.detail_address as loadAddress,
  335. f.detail_address as unloadAddress,
  336. a.billing_mode as billingMode,
  337. a.loss,
  338. a.loss_unit as lossUnit,
  339. a.goods_price as goodsPrice,
  340. a.goods_price_unit as goodsPriceUnit,
  341. a.settlement_cycle as settlementCycle,
  342. c.contacts as carrierContacts,
  343. c.phone as carrierPhone,
  344. b.firm_name as consignCompany,
  345. b.contacts as consignContacts,
  346. b.phone as consignPhone,
  347. e.contacts as loadContacts,
  348. e.phone as loadContacts,
  349. f.contacts as unloadContacts,
  350. f.phone as unloadPhone,
  351. a.start_time as shipmentsDate,
  352. a.end_time as receiveGoodsDate,
  353. a.remark,
  354. a.create_by as createBy,
  355. a.create_time as createTime,
  356. g.contract_id as contractId
  357. FROM kwt_logistics_order a
  358. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  359. AND b.unit_type = 1
  360. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  361. AND c.unit_type = 2
  362. LEFT JOIN kwt_logistics_order_goods d ON a.id = d.l_order_id
  363. LEFT JOIN kwt_logistics_order_address e ON a.id = e.l_order_id
  364. AND e.address_type = 1
  365. LEFT JOIN kwt_logistics_order_address f ON a.id = f.l_order_id
  366. AND f.address_type = 2
  367. LEFT JOIN kwt_logistics_order_contract g ON a.id = g.l_order_id
  368. WHERE a.del_flag = 0
  369. AND b.del_flag = 0
  370. AND c.del_flag = 0
  371. AND e.del_flag = 0
  372. AND f.del_flag = 0
  373. and a.pid = #{lOrderId}
  374. ORDER BY a.create_time
  375. limit #{page}, #{pageSize}
  376. </select>
  377. <select id="getSubcontractConsignmentNotPage" resultType="com.sckw.transport.model.vo.SubcontractConsignmentVO">
  378. SELECT a.id,
  379. a.pid,
  380. a.`status` as status,
  381. a.l_order_no as consignOrderNo,
  382. <!-- a.l_order_no as carrierOrderNo,-->
  383. c.firm_name as carrierCompany,
  384. d.goods_name as goodsName,
  385. a.amount as carryingCapacity,
  386. a.price,
  387. a.price_type as priceType,
  388. e.detail_address as loadAddress,
  389. f.detail_address as unloadAddress,
  390. a.billing_mode as billingMode,
  391. a.loss,
  392. a.loss_unit as lossUnit,
  393. a.goods_price as goodsPrice,
  394. a.goods_price_unit as goodsPriceUnit,
  395. a.settlement_cycle as settlementCycle,
  396. c.contacts as carrierContacts,
  397. c.phone as carrierPhone,
  398. b.firm_name as consignCompany,
  399. b.contacts as consignContacts,
  400. b.phone as consignPhone,
  401. e.contacts as loadContacts,
  402. e.phone as loadPhone,
  403. f.contacts as unloadContacts,
  404. f.phone as unloadPhone,
  405. a.start_time as shipmentsDate,
  406. a.end_time as receiveGoodsDate,
  407. a.remark,
  408. a.create_by as createBy,
  409. a.create_time as createTime,
  410. g.contract_id as contractId,
  411. g.contract_no as contractNo,
  412. g.contract_name as contractName,
  413. g.signing_way as signing,
  414. e.city_name as loadCityName,
  415. f.city_name as unloadCityName
  416. FROM kwt_logistics_order a
  417. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  418. AND b.unit_type = 1
  419. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  420. AND c.unit_type = 2
  421. LEFT JOIN kwt_logistics_order_goods d ON a.id = d.l_order_id
  422. LEFT JOIN kwt_logistics_order_address e ON a.id = e.l_order_id
  423. AND e.address_type = 1
  424. LEFT JOIN kwt_logistics_order_address f ON a.id = f.l_order_id
  425. AND f.address_type = 2
  426. LEFT JOIN kwt_logistics_order_contract g ON a.id = g.l_order_id
  427. WHERE a.del_flag = 0
  428. AND b.del_flag = 0
  429. AND c.del_flag = 0
  430. AND e.del_flag = 0
  431. AND f.del_flag = 0
  432. and a.pid = #{lOrderId}
  433. ORDER BY a.create_time desc
  434. </select>
  435. <select id="countSubcontractConsignmentById" resultType="java.util.Map">
  436. SELECT COUNT(0) as total,
  437. a.id,
  438. a.pid,
  439. a.`status` as status,
  440. a.l_order_no as consignOrderNo,
  441. c.firm_name as carrierContacts,
  442. d.goods_name as goodsName,
  443. a.amount as amount,
  444. a.price,
  445. a.price_type as priceType,
  446. e.detail_address as loadAddress,
  447. f.detail_address as unloadAddress,
  448. a.billing_mode as billingMode,
  449. a.loss,
  450. a.loss_unit as lossUnit,
  451. a.goods_price as goodsPrice,
  452. a.goods_price_unit as goodsPriceUnit,
  453. a.settlement_cycle as settlementCycle,
  454. c.contacts as carrierContacts,
  455. c.phone as carrierPhone,
  456. b.firm_name as consignCompany,
  457. b.contacts as consignContacts,
  458. b.phone as consignPhone,
  459. e.contacts as loadContacts,
  460. e.phone as loadContacts,
  461. f.contacts as unloadContacts,
  462. f.phone as unloadPhone,
  463. a.start_time as shipmentsDate,
  464. a.end_time as receiveGoodsDate,
  465. a.remark,
  466. a.create_by as createBy,
  467. a.create_time as createTime,
  468. g.contract_id as contractId
  469. FROM kwt_logistics_order a
  470. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  471. AND b.unit_type = 1
  472. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  473. AND c.unit_type = 2
  474. LEFT JOIN kwt_logistics_order_goods d ON a.id = d.l_order_id
  475. LEFT JOIN kwt_logistics_order_address e ON a.id = e.l_order_id
  476. AND e.address_type = 1
  477. LEFT JOIN kwt_logistics_order_address f ON a.id = f.l_order_id
  478. AND f.address_type = 2
  479. LEFT JOIN kwt_logistics_order_contract g ON a.id = g.l_order_id
  480. WHERE a.del_flag = 0
  481. AND b.del_flag = 0
  482. AND c.del_flag = 0
  483. AND e.del_flag = 0
  484. AND f.del_flag = 0
  485. and a.pid = #{lOrderId}
  486. ORDER BY a.create_time
  487. </select>
  488. <select id="selectDriverListById" resultType="com.sckw.transport.model.vo.DriverListVo">
  489. SELECT COUNT( b.truck_no ) AS count,
  490. a.id AS lOrderId,
  491. a.l_order_no AS lOrderNo,
  492. b.driver_id AS driverId,
  493. b.id AS wOrderId,
  494. b.w_order_no AS wOrderNo,
  495. b.driver_name AS driverName,
  496. b.driver_phone AS driverPhone,
  497. b.driver_idcard AS driverIdCard,
  498. b.truck_no AS truckNo
  499. FROM
  500. kwt_waybill_order b
  501. LEFT JOIN kwt_logistics_order a ON b.l_order_id = a.id
  502. <!-- SELECT a.id AS lOrderId,-->
  503. <!-- a.l_order_no AS lOrderNo,-->
  504. <!-- b.driver_id AS driverId,-->
  505. <!-- b.id AS wOrderId,-->
  506. <!-- b.w_order_no AS wOrderNo,-->
  507. <!-- b.driver_name AS driverName,-->
  508. <!-- b.driver_phone AS driverPhone,-->
  509. <!-- b.driver_idcard AS driverIdCard,-->
  510. <!-- b.truck_no AS truckNo-->
  511. <!-- ,-->
  512. <!-- COUNT( b.id ) AS count-->
  513. <!-- FROM-->
  514. <!-- kwt_waybill_order b,-->
  515. <!-- kwt_logistics_order a-->
  516. <where>
  517. a.id = b.l_order_id
  518. AND a.del_flag = 0
  519. AND b.del_flag = 0
  520. AND b.type = '1'
  521. AND b.status = 1
  522. <if test="driverParam.lOrderId != null and driverParam.lOrderId != ''">
  523. AND a.id =#{driverParam.lOrderId}
  524. </if>
  525. <if test="driverParam.driverName != null and driverParam.driverName != '' or ( driverParam.driverPhone != null and driverParam.driverPhone != '' ) or ( driverParam.truckNo != null and driverParam.truckNo != '' ) ">
  526. and (
  527. <if test="driverParam.driverName != null and driverParam.driverName != ''">
  528. b.driver_name like concat('%',#{driverParam.driverName},'%')
  529. </if>
  530. <if test="driverParam.driverPhone != null and driverParam.driverPhone != ''">
  531. or b.driver_phone like concat('%',#{driverParam.driverPhone},'%')
  532. </if>
  533. <if test="driverParam.truckNo != null and driverParam.truckNo != ''">
  534. or b.truck_no like concat('%',#{driverParam.truckNo},'%')
  535. </if>
  536. )
  537. </if>
  538. GROUP BY
  539. b.truck_no
  540. <!-- a.l_order_no,-->
  541. </where>
  542. </select>
  543. <select id="selectLogisticOrderList" resultType="com.sckw.transport.api.model.dto.LogisticsOrderDTO">
  544. SELECT
  545. DISTINCT a.id AS lOrderId,
  546. a.l_order_no AS lOrderNO,
  547. a.t_order_id AS tOrderId,
  548. a.t_order_no AS tOrderNO,
  549. a.payment AS payment,
  550. a.billing_mode AS billingMode,
  551. c.contract_id AS contractId,
  552. b.goods_name AS goodsName,
  553. a.amount,
  554. a.remark as remark,
  555. a.unit ,
  556. a.ignore_amount AS ignoreAmount,
  557. a.price,
  558. a.price_type as priceType,
  559. a.goods_price AS goodsPrice,
  560. a.loss,
  561. a.loss_unit AS lossUnit,
  562. a.tax_rate as taxRate,
  563. a.load_amount AS loadAmount,
  564. a.unload_amount AS unloadAmount,
  565. a.total_load_amount AS totalLoadAmount,
  566. a.total_unload_amount AS totalUnloadAmount,
  567. a.settlement_cycle as settlementCycle,
  568. a.start_time AS startTime,
  569. a.end_time AS endTime,
  570. a.create_time AS createTime,
  571. a.create_by AS createBy,
  572. a.update_by AS updateBy,
  573. a.update_time AS updateTime
  574. FROM
  575. kwt_logistics_order a
  576. LEFT JOIN kwt_logistics_order_goods b ON a.id = b.l_order_id and a.bind_status = '0'
  577. <!-- LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id-->
  578. LEFT JOIN kwt_logistics_order_contract c ON a.id = c.l_order_id
  579. <where>
  580. <if test="ids != null and ids.size() > 0">
  581. and a.id in
  582. <foreach collection="ids" item="item" open="(" close=")" separator=",">
  583. #{item}
  584. </foreach>
  585. </if>
  586. </where>
  587. ORDER BY a.create_time DESC
  588. </select>
  589. <select id="selectOrderFinishData" resultType="com.sckw.transport.model.vo.OrderFinishVO">
  590. SELECT b.amount as amount,COUNT(a.id) AS number,
  591. SUM(IFNULL(a.load_amount, 0)) as loadAmount,
  592. SUM(IFNULL(a.unload_amount, 0)) AS unloadAmount
  593. FROM kwt_waybill_order a
  594. LEFT JOIN kwt_logistics_order b ON b.id = a.l_order_id
  595. AND a.del_flag = 0
  596. AND b.del_flag = 0
  597. <where>
  598. <if test="orderId != null and orderId != ''">
  599. and b.id=#{orderId}
  600. </if>
  601. </where>
  602. </select>
  603. <select id="findLogisticsOrder" resultType="com.sckw.transport.model.KwtLogisticsOrder"
  604. parameterType="java.util.Map">
  605. select
  606. id, ent_id entId, t_order_id tOrderId, t_order_no tOrderNo, l_order_no lOrderNo, pid, pids,
  607. settlement_cycle settlementCycle, price, price_type priceType, billing_mode billingMode,
  608. amount, unit, loss, loss_unit lossUnit, goods_price goodsPrice, goods_price_unit goodsPriceUnit,
  609. start_time startTime, end_time endTime, subcontract_amount subcontractAmount, entrust_amount entrustAmount,
  610. unload_amount unloadAmount, load_amount loadAmount, ignore_amount ignoreAmount, deficit_amount deficitAmount,
  611. deficit_price deficitPrice, payment, tax_rate taxRate, remark, `status`, create_by createBy,
  612. create_time createTime, update_by updateBy, update_time updateTime
  613. from kwt_logistics_order
  614. where del_flag = 0
  615. <if test="id != null and id != ''">
  616. and id = #{id, jdbcType=BIGINT}
  617. </if>
  618. <if test="upperlOrderId != null and upperlOrderId != ''">
  619. and FIND_IN_SET(#{upperlOrderId, jdbcType=BIGINT}, pids)
  620. and id != #{ownOrderId, jdbcType=BIGINT}
  621. </if>
  622. <if test="belowlOrderId != null and belowlOrderId != ''">
  623. and FIND_IN_SET(id, #{belowlOrderId, jdbcType=VARCHAR})
  624. and id != #{ownOrderId, jdbcType=BIGINT}
  625. </if>
  626. </select>
  627. <select id="selectOrderCountByTorderId" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
  628. SELECT a.id as lOrderId,
  629. a.l_order_no as lOrderNo,
  630. b.`status` as `status`,
  631. a.t_order_id as tOrderId,
  632. a.t_order_no as tOrderNo,
  633. a.payment as payment,
  634. a.amount,
  635. a.price,
  636. a.loss,
  637. a.goods_price as goodsPrice,
  638. c.firm_name as comanyName,
  639. c.contacts,
  640. c.phone,
  641. a.create_by as createBy,
  642. a.create_time as createTime
  643. FROM kwt_logistics_order a
  644. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id
  645. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  646. WHERE a.del_flag = '0'
  647. AND b.del_flag = '0'
  648. AND a.t_order_id = #{id,jdbcType=VARCHAR}
  649. </select>
  650. <select id="getAddressList" resultType="java.lang.Integer">
  651. SELECT a.city_code
  652. FROM kwt_logistics_order_address a
  653. LEFT JOIN kwt_logistics_order b ON a.l_order_id = b.id
  654. where a.city_code is not null
  655. AND b.ent_id = #{entId}
  656. GROUP BY a.city_code
  657. </select>
  658. <select id="getAddressDetailListByEntId" resultType="com.sckw.transport.api.model.dto.AddressResDTO">
  659. </select>
  660. <select id="selectMaxLevel" resultType="java.lang.Integer">
  661. SELECT MAX(LEVEL)
  662. FROM kwt_logistics_order
  663. WHERE del_flag = 0
  664. AND FIND_IN_SET(#{id}, pids)
  665. </select>
  666. <select id="countAmountByTradeOrderId" resultType="java.util.Map">
  667. SELECT IFNULL(SUM(unload_amount), 0) AS unloadAmount,
  668. IFNULL(SUM(load_amount), 0) AS loadAmount,
  669. IFNULL(SUM(total_load_amount), 0) AS totalLoadAmount,
  670. IFNULL(SUM(total_unload_amount), 0) AS totalUnloadAmount
  671. FROM kwt_logistics_order
  672. WHERE del_flag = 0
  673. AND t_order_id = #{tOrderId}
  674. AND `status` IN (
  675. 8
  676. )
  677. </select>
  678. <select id="selectOrderListByIdsAndUnitType" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
  679. SELECT a.id as lOrderId,
  680. a.l_order_no as lOrderNo,
  681. b.`status` as `status`,
  682. a.t_order_id as tOrderId,
  683. a.t_order_no as tOrderNo,
  684. a.payment as payment,
  685. a.amount,
  686. a.price,
  687. a.loss,
  688. a.goods_price as goodsPrice,
  689. c.firm_name as companyName,
  690. c.contacts,
  691. c.phone,
  692. a.create_by as createBy,
  693. a.create_time as createTime
  694. FROM kwt_logistics_order a
  695. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
  696. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  697. WHERE a.del_flag = '0'
  698. AND b.del_flag = '0'
  699. AND a.t_order_id IN
  700. <foreach collection="ids" item="item" open="(" close=")" separator=",">
  701. #{item}
  702. </foreach>
  703. order by createTime desc
  704. </select>
  705. <select id="selectLoopOrderAndDriverListByOrderId" resultType="com.sckw.transport.model.vo.DriverListVo">
  706. SELECT a.id AS lOrderId,
  707. a.l_order_no AS lOrderNo,
  708. c.driver_id AS driverId,
  709. c.id AS circulateId,
  710. c.driver_name AS driverName,
  711. c.driver_phone AS driverPhone,
  712. c.driver_idcard AS driverIdCard,
  713. c.truck_no AS truckNo,
  714. c.truck_id AS truckId,
  715. c.total_take as count
  716. FROM
  717. kwt_logistics_order_circulate c,
  718. kwt_logistics_order a
  719. <where>
  720. a.id = c.l_order_id
  721. AND c.type = '2'
  722. AND c.`status` = '0'
  723. AND a.del_flag = 0
  724. AND c.del_flag = 0
  725. <if test="driverParam.lOrderId != null and driverParam.lOrderId != ''">
  726. AND a.id =#{driverParam.lOrderId}
  727. </if>
  728. <if test="driverParam.driverName != null and driverParam.driverName != '' or ( driverParam.driverPhone != null and driverParam.driverPhone != '' ) or ( driverParam.truckNo != null and driverParam.truckNo != '' )">
  729. and (
  730. <if test=" driverParam.driverName != null and driverParam.driverName != ''">
  731. c.driver_name like concat('%',#{driverParam.driverName},'%')
  732. </if>
  733. <if test=" driverParam.driverPhone != null and driverParam.driverPhone != ''">
  734. or c.driver_phone like concat('%',#{driverParam.driverPhone},'%')
  735. </if>
  736. <if test=" driverParam.truckNo != null and driverParam.truckNo != ''">
  737. or c.truck_no like concat('%',#{driverParam.truckNo},'%')
  738. </if>
  739. )
  740. </if>
  741. </where>
  742. </select>
  743. <select id="selectLoopOrderAndDriverListByOrderIds" resultType="com.sckw.transport.model.vo.DriverListVo">
  744. SELECT
  745. c.id AS circulateId,
  746. c.driver_id AS driverId,
  747. b.id AS lOrderId,
  748. b.l_order_no AS lOrderNo,
  749. c.driver_name AS driverName,
  750. c.driver_phone AS driverPhone,
  751. c.driver_idcard AS driverIdCard,
  752. c.truck_no AS truckNo,
  753. c.truck_id AS truckId,
  754. c.total_take AS count
  755. FROM
  756. kwt_logistics_order_circulate c
  757. LEFT JOIN kwt_logistics_order b ON b.id = c.l_order_id
  758. WHERE
  759. b.del_flag = 0
  760. AND c.del_flag = 0
  761. AND c.STATUS = 0
  762. <if test="idsList != null and idsList.size() >0">
  763. AND b.id IN
  764. <foreach collection="idsList" item="item" open="(" close=")" separator=",">
  765. #{item}
  766. </foreach>
  767. </if>
  768. </select>
  769. <sql id="Query_Column_List">
  770. a.id AS lOrderId,
  771. a.l_order_no AS lOrderNo,
  772. a.t_order_id AS tOrderId,
  773. a.t_order_no AS tOrderNo,
  774. a.loss AS loss,
  775. a.loss_unit AS lossUnit,
  776. a.settlement_cycle AS accountsCycle,
  777. a.billing_mode AS billingMode,
  778. a.amount AS carryingCapacity,
  779. a.goods_price AS goodsPrice,
  780. a.goods_price_unit AS goodsPriceUnit,
  781. a.`status` AS `status`,
  782. a.settlement_cycle AS settlementCycle,
  783. a.price AS price,
  784. a.price_type AS priceType,
  785. a.type AS type,
  786. a.unit AS unit,
  787. a.subcontract_amount AS subcontractAmount,
  788. a.entrust_amount AS entrustAmount,
  789. a.unload_amount AS unloadAmount,
  790. a.load_amount AS loadAmount,
  791. a.ignore_amount AS ignoreAmount,
  792. a.deficit_amount AS deficitAmount,
  793. a.deficit_price AS deficitPrice,
  794. a.total_load_amount AS totalLoadAmount,
  795. a.total_unload_amount AS totalUnloadAmount,
  796. a.payment AS payment,
  797. a.tax_rate AS taxRate,
  798. a.ent_id AS entId,
  799. a.create_by AS createBy,
  800. a.create_time AS createTime,
  801. a.update_by AS updateBy,
  802. a.update_time AS updateTime,
  803. a.start_time AS shipmentsDateTime,
  804. a.end_time AS receiveGoodsDateTime,
  805. a.remark AS remark,
  806. g.goods_id AS goodsId,
  807. g.goods_name AS goodsName,
  808. g.goods_type AS goodsType,
  809. f.contract_id AS contractId,
  810. f.contract_no AS contractNo,
  811. f.signing_way AS signing,
  812. d.ent_id AS consignCompanyId,
  813. d.top_ent_id AS consignTopEntId,
  814. d.firm_name AS consignCompany,
  815. d.contacts AS consignContacts,
  816. d.phone AS consignPhone,
  817. e.ent_id AS carrierCompanyId,
  818. e.firm_name AS carrierCompany,
  819. e.top_ent_id AS carrierTopEntId,
  820. e.contacts AS carrierContacts,
  821. e.phone AS carrierPhone,
  822. b.`name` AS loadName,
  823. b.address_type AS loadType,
  824. b.city_name AS loadCityName,
  825. b.city_code AS loadCityCode,
  826. b.detail_address AS loadAddress,
  827. b.contacts AS shipmentsContacts,
  828. b.phone AS shipmentsPhone,
  829. b.lat AS loadLat,
  830. b.lng AS loadLng,
  831. c.address_type AS unloadType,
  832. c.contacts AS receiveGoodsContacts,
  833. c.phone AS receiveGoodsPhone,
  834. c.city_name AS unloadCityName,
  835. c.city_code AS unloadCityCode,
  836. c.detail_address AS unloadAddress,
  837. c.lat AS unloadLat,
  838. c.lng AS unloadLng,
  839. f.contract_name as contract
  840. <!-- ,-->
  841. <!-- a.del_flag,-->
  842. <!-- b.del_flag,-->
  843. <!-- c.del_flag,-->
  844. <!-- d.del_flag,-->
  845. <!-- e.del_flag,-->
  846. <!-- f.del_flag,-->
  847. <!-- g.del_flag-->
  848. </sql>
  849. <select id="selectLogisticsOrderList" resultType="com.sckw.transport.model.vo.AcceptCarriageOrderVO">
  850. SELECT
  851. <include refid="Query_Column_List">
  852. </include>
  853. FROM
  854. kwt_logistics_order a
  855. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  856. AND b.address_type = 1 AND b.del_flag = 0
  857. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  858. AND c.address_type = 2 AND c.del_flag = 0
  859. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  860. AND d.unit_type = 1 AND d.del_flag = 0
  861. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  862. AND e.unit_type = 2
  863. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  864. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  865. <where>
  866. a.del_flag = 0
  867. <if test="type == 1">
  868. and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
  869. <!-- AND (-->
  870. <!-- a.ent_id = #{entId}-->
  871. <!-- <if test="userIds != null and userIds.size()>0">-->
  872. <!-- AND a.create_by IN-->
  873. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  874. <!-- #{item}-->
  875. <!-- </foreach>-->
  876. <!-- </if>-->
  877. <!-- )-->
  878. <!-- OR (-->
  879. <!-- d.top_ent_id = #{entId}-->
  880. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  881. <!-- AND d.contacts_id IN-->
  882. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  883. <!-- #{item}-->
  884. <!-- </foreach>-->
  885. <!-- </if>-->
  886. <!-- )-->
  887. </if>
  888. <if test="type == 2">
  889. and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
  890. <!-- AND (-->
  891. <!-- a.ent_id = #{entId}-->
  892. <!-- <if test="userIds != null and userIds.size()>0">-->
  893. <!-- AND a.create_by IN-->
  894. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  895. <!-- #{item}-->
  896. <!-- </foreach>-->
  897. <!-- </if>-->
  898. <!-- )-->
  899. <!-- OR (-->
  900. <!-- d.top_ent_id = #{entId}-->
  901. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  902. <!-- AND d.contacts_id IN-->
  903. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  904. <!-- #{item}-->
  905. <!-- </foreach>-->
  906. <!-- </if>-->
  907. <!-- )-->
  908. </if>
  909. <if test="query.keywords != null and query.keywords != ''">
  910. and (
  911. a.t_order_no like concat('%',#{query.keywords},'%')
  912. or a.l_order_no like concat('%',#{query.keywords},'%')
  913. or d.firm_name like concat('%',#{query.keywords},'%')
  914. or e.firm_name like concat('%',#{query.keywords},'%')
  915. or g.goods_name like concat('%',#{query.keywords},'%'))
  916. </if>
  917. <if test="orderList != null and orderList.size() > 0 ">
  918. and a.status in
  919. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  920. #{status}
  921. </foreach>
  922. </if>
  923. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  924. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  925. </if>
  926. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  927. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  928. </if>
  929. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  930. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  931. </if>
  932. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  933. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  934. </if>
  935. <if test="query.createStartTime != null and query.createStartTime != '' ">
  936. and a.create_time &gt;=#{query.createStartTime}
  937. </if>
  938. <if test="query.createEndTime != null and query.createEndTime != ''">
  939. and a.create_time &lt;=#{query.createEndTime}
  940. </if>
  941. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  942. and b.city_code = #{query.loadAddressCode}
  943. </if>
  944. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  945. and c.city_code = #{query.unloadAddressCode}
  946. </if>
  947. <if test="query.billingMode != null and query.billingMode != ''">
  948. and a.billing_mode =#{query.billingMode}
  949. </if>
  950. </where>
  951. ORDER BY a.create_time DESC
  952. <!-- ,a.create_time-->
  953. </select>
  954. <select id="selectManagementLogisticsOrderList" resultType="com.sckw.transport.model.vo.ManagementLogsiticsOrderVO">
  955. SELECT
  956. <include refid="Query_Column_List">
  957. </include>
  958. FROM
  959. kwt_logistics_order a
  960. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  961. AND b.address_type = 1 AND b.del_flag = 0
  962. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  963. AND c.address_type = 2 AND c.del_flag = 0
  964. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  965. AND d.unit_type = 1 AND d.del_flag = 0
  966. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  967. AND e.unit_type = 2
  968. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  969. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  970. <where>
  971. a.del_flag = 0
  972. <!-- <if test="type == 1">-->
  973. <!-- and (d.top_ent_id = #{entId} or d.ent_id = #{entId})-->
  974. <!-- AND (-->
  975. <!-- a.ent_id = #{entId}-->
  976. <!-- <if test="userIds != null and userIds.size()>0">-->
  977. <!-- AND a.create_by IN-->
  978. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  979. <!-- #{item}-->
  980. <!-- </foreach>-->
  981. <!-- </if>-->
  982. <!-- )-->
  983. <!-- OR (-->
  984. <!-- d.top_ent_id = #{entId}-->
  985. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  986. <!-- AND d.contacts_id IN-->
  987. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  988. <!-- #{item}-->
  989. <!-- </foreach>-->
  990. <!-- </if>-->
  991. <!-- )-->
  992. <!-- </if>-->
  993. <!-- <if test="type == 2">-->
  994. <!-- and (e.top_ent_id = #{entId} or e.ent_id = #{entId})-->
  995. <!-- AND (-->
  996. <!-- a.ent_id = #{entId}-->
  997. <!-- <if test="userIds != null and userIds.size()>0">-->
  998. <!-- AND a.create_by IN-->
  999. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  1000. <!-- #{item}-->
  1001. <!-- </foreach>-->
  1002. <!-- </if>-->
  1003. <!-- )-->
  1004. <!-- OR (-->
  1005. <!-- d.top_ent_id = #{entId}-->
  1006. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  1007. <!-- AND d.contacts_id IN-->
  1008. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  1009. <!-- #{item}-->
  1010. <!-- </foreach>-->
  1011. <!-- </if>-->
  1012. <!-- )-->
  1013. <!-- </if>-->
  1014. <if test="query.keywords != null and query.keywords != ''">
  1015. and (
  1016. a.t_order_no like concat('%',#{query.keywords},'%')
  1017. or a.l_order_no like concat('%',#{query.keywords},'%')
  1018. or d.firm_name like concat('%',#{query.keywords},'%')
  1019. or e.firm_name like concat('%',#{query.keywords},'%')
  1020. or g.goods_name like concat('%',#{query.keywords},'%'))
  1021. </if>
  1022. <if test="orderList != null and orderList.size() > 0 ">
  1023. and a.status in
  1024. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  1025. #{status}
  1026. </foreach>
  1027. </if>
  1028. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  1029. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  1030. </if>
  1031. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  1032. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  1033. </if>
  1034. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  1035. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  1036. </if>
  1037. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  1038. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  1039. </if>
  1040. <if test="query.createStartTime != null and query.createStartTime != '' ">
  1041. and a.create_time &gt;=#{query.createStartTime}
  1042. </if>
  1043. <if test="query.createEndTime != null and query.createEndTime != ''">
  1044. and a.create_time &lt;=#{query.createEndTime}
  1045. </if>
  1046. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  1047. and b.city_code = #{query.loadAddressCode}
  1048. </if>
  1049. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  1050. and c.city_code = #{query.unloadAddressCode}
  1051. </if>
  1052. <if test="query.billingMode != null and query.billingMode != ''">
  1053. and a.billing_mode =#{query.billingMode}
  1054. </if>
  1055. </where>
  1056. ORDER BY a.create_time DESC
  1057. <!-- ,a.create_time-->
  1058. </select>
  1059. <select id="countLogisticsOrderListByStatus" resultType="com.sckw.mongo.model.TableTops">
  1060. SELECT
  1061. a.`status` AS value ,
  1062. COUNT(a.`status`) AS total
  1063. FROM
  1064. kwt_logistics_order a
  1065. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  1066. AND b.address_type = 1 AND b.del_flag = 0
  1067. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  1068. AND c.address_type = 2 AND c.del_flag = 0
  1069. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  1070. AND d.unit_type = 1 AND d.del_flag = 0
  1071. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  1072. AND e.unit_type = 2
  1073. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  1074. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  1075. <where>
  1076. a.del_flag = 0
  1077. <if test="type == 1">
  1078. and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
  1079. <!-- AND (-->
  1080. <!-- a.ent_id = #{entId}-->
  1081. <!-- <if test="userIds != null and userIds.size()>0">-->
  1082. <!-- AND a.create_by IN-->
  1083. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  1084. <!-- #{item}-->
  1085. <!-- </foreach>-->
  1086. <!-- </if>-->
  1087. <!-- )-->
  1088. <!-- OR (-->
  1089. <!-- d.top_ent_id = #{entId}-->
  1090. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  1091. <!-- AND d.contacts_id IN-->
  1092. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  1093. <!-- #{item}-->
  1094. <!-- </foreach>-->
  1095. <!-- </if>-->
  1096. <!-- )-->
  1097. </if>
  1098. <if test="type == 2">
  1099. and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
  1100. <!-- AND (-->
  1101. <!-- a.ent_id = #{entId}-->
  1102. <!-- <if test="userIds != null and userIds.size()>0">-->
  1103. <!-- AND a.create_by IN-->
  1104. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  1105. <!-- #{item}-->
  1106. <!-- </foreach>-->
  1107. <!-- </if>-->
  1108. <!-- )-->
  1109. <!-- OR (-->
  1110. <!-- d.top_ent_id = #{entId}-->
  1111. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  1112. <!-- AND d.contacts_id IN-->
  1113. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  1114. <!-- #{item}-->
  1115. <!-- </foreach>-->
  1116. <!-- </if>-->
  1117. <!-- )-->
  1118. </if>
  1119. <if test="query.keywords != null and query.keywords != ''">
  1120. and (
  1121. a.t_order_no like concat('%',#{query.keywords},'%')
  1122. or a.l_order_no like concat('%',#{query.keywords},'%')
  1123. or d.firm_name like concat('%',#{query.keywords},'%')
  1124. or e.firm_name like concat('%',#{query.keywords},'%')
  1125. or g.goods_name like concat('%',#{query.keywords},'%'))
  1126. </if>
  1127. <if test="orderList != null and orderList.size() > 0 ">
  1128. and a.status in
  1129. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  1130. #{status}
  1131. </foreach>
  1132. </if>
  1133. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  1134. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  1135. </if>
  1136. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  1137. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  1138. </if>
  1139. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  1140. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  1141. </if>
  1142. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  1143. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  1144. </if>
  1145. <if test="query.createStartTime != null and query.createStartTime != '' ">
  1146. and a.create_time &gt;=#{query.createStartTime}
  1147. </if>
  1148. <if test="query.createEndTime != null and query.createEndTime != ''">
  1149. and a.create_time &lt;=#{query.createEndTime}
  1150. </if>
  1151. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  1152. and b.city_code = #{query.loadAddressCode}
  1153. </if>
  1154. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  1155. and c.city_code = #{query.unloadAddressCode}
  1156. </if>
  1157. </where>
  1158. group by a.status
  1159. </select>
  1160. <select id="countManagementLogisticsOrderListByStatus" resultType="com.sckw.mongo.model.TableTops">
  1161. SELECT
  1162. a.`status` AS value ,
  1163. COUNT(a.`status`) AS total
  1164. FROM
  1165. kwt_logistics_order a
  1166. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  1167. AND b.address_type = 1 AND b.del_flag = 0
  1168. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  1169. AND c.address_type = 2 AND c.del_flag = 0
  1170. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  1171. AND d.unit_type = 1 AND d.del_flag = 0
  1172. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  1173. AND e.unit_type = 2
  1174. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  1175. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  1176. <where>
  1177. a.del_flag = 0
  1178. <!-- <if test="type == 1">-->
  1179. <!-- and (d.top_ent_id = #{entId} or d.ent_id = #{entId})-->
  1180. <!-- AND (-->
  1181. <!-- a.ent_id = #{entId}-->
  1182. <!-- <if test="userIds != null and userIds.size()>0">-->
  1183. <!-- AND a.create_by IN-->
  1184. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  1185. <!-- #{item}-->
  1186. <!-- </foreach>-->
  1187. <!-- </if>-->
  1188. <!-- )-->
  1189. <!-- OR (-->
  1190. <!-- d.top_ent_id = #{entId}-->
  1191. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  1192. <!-- AND d.contacts_id IN-->
  1193. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  1194. <!-- #{item}-->
  1195. <!-- </foreach>-->
  1196. <!-- </if>-->
  1197. <!-- )-->
  1198. <!-- </if>-->
  1199. <!-- <if test="type == 2">-->
  1200. <!-- and (e.top_ent_id = #{entId} or e.ent_id = #{entId})-->
  1201. <!-- AND (-->
  1202. <!-- a.ent_id = #{entId}-->
  1203. <!-- <if test="userIds != null and userIds.size()>0">-->
  1204. <!-- AND a.create_by IN-->
  1205. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  1206. <!-- #{item}-->
  1207. <!-- </foreach>-->
  1208. <!-- </if>-->
  1209. <!-- )-->
  1210. <!-- OR (-->
  1211. <!-- d.top_ent_id = #{entId}-->
  1212. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  1213. <!-- AND d.contacts_id IN-->
  1214. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  1215. <!-- #{item}-->
  1216. <!-- </foreach>-->
  1217. <!-- </if>-->
  1218. <!-- )-->
  1219. <!-- </if>-->
  1220. <if test="query.keywords != null and query.keywords != ''">
  1221. and (
  1222. a.t_order_no like concat('%',#{query.keywords},'%')
  1223. or a.l_order_no like concat('%',#{query.keywords},'%')
  1224. or d.firm_name like concat('%',#{query.keywords},'%')
  1225. or e.firm_name like concat('%',#{query.keywords},'%')
  1226. or g.goods_name like concat('%',#{query.keywords},'%'))
  1227. </if>
  1228. <if test="orderList != null and orderList.size() > 0 ">
  1229. and a.status in
  1230. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  1231. #{status}
  1232. </foreach>
  1233. </if>
  1234. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  1235. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  1236. </if>
  1237. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  1238. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  1239. </if>
  1240. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  1241. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  1242. </if>
  1243. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  1244. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  1245. </if>
  1246. <if test="query.createStartTime != null and query.createStartTime != '' ">
  1247. and a.create_time &gt;=#{query.createStartTime}
  1248. </if>
  1249. <if test="query.createEndTime != null and query.createEndTime != ''">
  1250. and a.create_time &lt;=#{query.createEndTime}
  1251. </if>
  1252. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  1253. and b.city_code = #{query.loadAddressCode}
  1254. </if>
  1255. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  1256. and c.city_code = #{query.unloadAddressCode}
  1257. </if>
  1258. </where>
  1259. group by a.status
  1260. </select>
  1261. <select id="selectCountByLorderId" resultType="java.lang.Integer">
  1262. SELECT COUNT(id)
  1263. FROM kwt_waybill_order
  1264. WHERE del_flag = 0
  1265. and l_order_id = #{orderId}
  1266. <if test="orderStatusList != null and orderStatusList.size() > 0">
  1267. AND status IN
  1268. <foreach collection="orderStatusList" item="item" open="(" close=")" separator=",">
  1269. #{item}
  1270. </foreach>
  1271. </if>
  1272. </select>
  1273. <select id="getMaxOrderNoByDate" resultType="java.lang.String">
  1274. SELECT MAX(l_order_no)
  1275. FROM kwt_logistics_order
  1276. WHERE create_time &gt;= #{date};
  1277. </select>
  1278. <select id="checkLogisticsOrderIsFinishByEntId" resultType="java.lang.String">
  1279. SELECT
  1280. a.l_order_no
  1281. FROM
  1282. kwt_logistics_order a
  1283. INNER JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  1284. AND a.del_flag = 0
  1285. AND b.del_flag = 0
  1286. AND b.unit_type = 1
  1287. INNER JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  1288. AND a.del_flag = 0
  1289. AND c.del_flag = 0
  1290. AND c.unit_type = 2
  1291. <where>
  1292. <if test="consignEntId != null and consignEntId != ''">
  1293. and b.top_ent_id = #{consignEntId}
  1294. </if>
  1295. <if test="acceptCarriageEntId != null and acceptCarriageEntId != ''">
  1296. and c.top_ent_id = #{acceptCarriageEntId}
  1297. </if>
  1298. <if test="orderStatus != null and orderStatus.size() > 0">
  1299. and a.status in
  1300. <foreach collection="orderStatus" separator="," open="(" item="item" close=")">
  1301. #{item}
  1302. </foreach>
  1303. </if>
  1304. </where>
  1305. </select>
  1306. <select id="selectLogisticsOrderListExport"
  1307. resultType="com.sckw.transport.model.vo.execlVo.AcceptCarriageOrderExcelVo">
  1308. SELECT
  1309. <include refid="Query_Column_List">
  1310. </include>
  1311. FROM
  1312. kwt_logistics_order a
  1313. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  1314. AND b.address_type = 1 AND b.del_flag = 0
  1315. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  1316. AND c.address_type = 2 AND c.del_flag = 0
  1317. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  1318. AND d.unit_type = 1 AND d.del_flag = 0
  1319. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  1320. AND e.unit_type = 2
  1321. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  1322. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  1323. <where>
  1324. a.del_flag = 0
  1325. <if test="type == 1">
  1326. and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
  1327. </if>
  1328. <if test="type == 2">
  1329. and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
  1330. </if>
  1331. <if test="query.keywords != null and query.keywords != ''">
  1332. and (
  1333. a.t_order_no like concat('%',#{query.keywords},'%')
  1334. or a.l_order_no like concat('%',#{query.keywords},'%')
  1335. or d.firm_name like concat('%',#{query.keywords},'%')
  1336. or e.firm_name like concat('%',#{query.keywords},'%')
  1337. or g.goods_name like concat('%',#{query.keywords},'%'))
  1338. </if>
  1339. <if test="orderList != null and orderList.size() > 0 ">
  1340. and a.status in
  1341. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  1342. #{status}
  1343. </foreach>
  1344. </if>
  1345. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  1346. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  1347. </if>
  1348. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  1349. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  1350. </if>
  1351. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  1352. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  1353. </if>
  1354. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  1355. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  1356. </if>
  1357. <if test="query.createStartTime != null and query.createStartTime != '' ">
  1358. and a.create_time &gt;=#{query.createStartTime}
  1359. </if>
  1360. <if test="query.createEndTime != null and query.createEndTime != ''">
  1361. and a.create_time &lt;=#{query.createEndTime}
  1362. </if>
  1363. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  1364. and b.city_code = #{query.loadAddressCode}
  1365. </if>
  1366. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  1367. and c.city_code = #{query.unloadAddressCode}
  1368. </if>
  1369. <if test="query.billingMode != null and query.billingMode != ''">
  1370. and a.billing_mode =#{query.billingMode}
  1371. </if>
  1372. </where>
  1373. ORDER BY a.id DESC
  1374. <!-- ,a.create_time-->
  1375. </select>
  1376. <select id="selectConsignLogisticsOrderList" resultType="com.sckw.transport.model.vo.ConsignOrderVO">
  1377. SELECT
  1378. <include refid="Query_Column_List">
  1379. </include>
  1380. FROM
  1381. kwt_logistics_order a
  1382. LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
  1383. AND b.address_type = 1 AND b.del_flag = 0
  1384. LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
  1385. AND c.address_type = 2 AND c.del_flag = 0
  1386. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  1387. AND d.unit_type = 1 AND d.del_flag = 0
  1388. LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
  1389. AND e.unit_type = 2
  1390. LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
  1391. LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
  1392. <where>
  1393. a.del_flag = 0
  1394. <if test="type == 1">
  1395. and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
  1396. <!-- AND (-->
  1397. <!-- a.ent_id = #{entId}-->
  1398. <!-- <if test="userIds != null and userIds.size()>0">-->
  1399. <!-- AND a.create_by IN-->
  1400. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  1401. <!-- #{item}-->
  1402. <!-- </foreach>-->
  1403. <!-- </if>-->
  1404. <!-- )-->
  1405. <!-- OR (-->
  1406. <!-- d.top_ent_id = #{entId}-->
  1407. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  1408. <!-- AND d.contacts_id IN-->
  1409. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  1410. <!-- #{item}-->
  1411. <!-- </foreach>-->
  1412. <!-- </if>-->
  1413. <!-- )-->
  1414. </if>
  1415. <if test="type == 2">
  1416. and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
  1417. <!-- AND (-->
  1418. <!-- a.ent_id = #{entId}-->
  1419. <!-- <if test="userIds != null and userIds.size()>0">-->
  1420. <!-- AND a.create_by IN-->
  1421. <!-- <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
  1422. <!-- #{item}-->
  1423. <!-- </foreach>-->
  1424. <!-- </if>-->
  1425. <!-- )-->
  1426. <!-- OR (-->
  1427. <!-- d.top_ent_id = #{entId}-->
  1428. <!-- <if test="contactsIds != null and contactsIds.size()>0">-->
  1429. <!-- AND d.contacts_id IN-->
  1430. <!-- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
  1431. <!-- #{item}-->
  1432. <!-- </foreach>-->
  1433. <!-- </if>-->
  1434. <!-- )-->
  1435. </if>
  1436. <if test="query.keywords != null and query.keywords != ''">
  1437. and (
  1438. a.t_order_no like concat('%',#{query.keywords},'%')
  1439. or a.l_order_no like concat('%',#{query.keywords},'%')
  1440. or d.firm_name like concat('%',#{query.keywords},'%')
  1441. or e.firm_name like concat('%',#{query.keywords},'%')
  1442. or g.goods_name like concat('%',#{query.keywords},'%'))
  1443. </if>
  1444. <if test="orderList != null and orderList.size() > 0 ">
  1445. and a.status in
  1446. <foreach collection="orderList" item="status" open="(" close=")" separator=",">
  1447. #{status}
  1448. </foreach>
  1449. </if>
  1450. <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
  1451. and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
  1452. </if>
  1453. <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
  1454. and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
  1455. </if>
  1456. <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
  1457. and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
  1458. </if>
  1459. <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
  1460. and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
  1461. </if>
  1462. <if test="query.createStartTime != null and query.createStartTime != '' ">
  1463. and a.create_time &gt;=#{query.createStartTime}
  1464. </if>
  1465. <if test="query.createEndTime != null and query.createEndTime != ''">
  1466. and a.create_time &lt;=#{query.createEndTime}
  1467. </if>
  1468. <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
  1469. and b.city_code = #{query.loadAddressCode}
  1470. </if>
  1471. <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
  1472. and c.city_code = #{query.unloadAddressCode}
  1473. </if>
  1474. <if test="query.billingMode != null and query.billingMode != ''">
  1475. and a.billing_mode =#{query.billingMode}
  1476. </if>
  1477. </where>
  1478. ORDER BY a.id DESC
  1479. <!-- ,a.create_time-->
  1480. </select>
  1481. <select id="statisticsWaybillSendCar" resultType="java.lang.Integer">
  1482. SELECT
  1483. COUNT(b.id)
  1484. FROM
  1485. kwt_waybill_order b
  1486. LEFT JOIN kwt_logistics_order a ON a.id = b.l_order_id
  1487. WHERE
  1488. a.del_flag = 0
  1489. AND b.del_flag = 0
  1490. <if test="ids != null and ids.size()>0">
  1491. and a.id in
  1492. <foreach collection="ids" open="(" close=")" separator="," item="item">
  1493. #{item}
  1494. </foreach>
  1495. </if>
  1496. <if test="orderList != null and orderList.size()>0">
  1497. and b.status in
  1498. <foreach collection="orderList" item="item" separator="," close=")" open="(">
  1499. #{item}
  1500. </foreach>
  1501. </if>
  1502. </select>
  1503. <select id="statisticsLogistics" resultType="java.lang.Long">
  1504. SELECT DISTINCT a.id
  1505. FROM kwt_logistics_order a
  1506. LEFT JOIN kwt_logistics_order_unit b ON b.l_order_id = a.id
  1507. WHERE a.del_flag = 0
  1508. AND b.del_flag = 0
  1509. AND (b.ent_id = #{topEntId} OR b.top_ent_id = #{topEntId})
  1510. </select>
  1511. <select id="statisticsLogisticsByTopEntIdAndOrderStatus" resultType="java.lang.Integer">
  1512. SELECT
  1513. count(DISTINCT a.id)
  1514. FROM
  1515. kwt_logistics_order a
  1516. LEFT JOIN kwt_logistics_order_unit b ON b.l_order_id = a.id
  1517. WHERE
  1518. a.del_flag = 0
  1519. AND b.del_flag = 0
  1520. AND ( b.ent_id = #{topEntId} OR b.top_ent_id = #{topEntId} )
  1521. And a.status in
  1522. <foreach collection="orderList" open="(" close=")" separator="," item="item">
  1523. #{item}
  1524. </foreach>
  1525. </select>
  1526. <select id="selectAcceptCarriageFinishOrder" resultType="com.sckw.transport.model.vo.StatisticsByOrderVO">
  1527. SELECT
  1528. IFNULL( SUM( t1.WaitingAmount ), 0 ) AS WaitingAmount ,
  1529. IFNULL( SUM( t1.amount ), 0 ) AS amount ,
  1530. IFNULL( SUM( t1.entrustAmount ), 0 ) AS entrustAmount ,
  1531. IFNULL( SUM( t1.subcontractAmount ), 0 ) AS subcontractAmount ,
  1532. IFNULL( SUM( t1.totalPrice ), 0 ) AS totalPrice
  1533. FROM
  1534. (
  1535. SELECT
  1536. ( a.amount - IFNULL(a.total_load_amount,0)) AS WaitingAmount,
  1537. a.amount,
  1538. a.entrust_amount AS entrustAmount,
  1539. a.subcontract_amount AS subcontractAmount,
  1540. a.price ,
  1541. a.amount * IFNULL(a.price,0) AS totalPrice
  1542. FROM
  1543. kwt_logistics_order a
  1544. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  1545. AND a.del_flag = 0
  1546. AND b.del_flag = 0
  1547. WHERE
  1548. b.unit_type = #{unitType}
  1549. <if test="topId != null and topId !=''">
  1550. and b.top_ent_id = #{topId}
  1551. </if>
  1552. <if test="statusList != null and statusList.size()>0">
  1553. and a.`status` IN
  1554. <foreach collection="statusList" item="item" separator="," open="(" close=")">
  1555. #{item}
  1556. </foreach>
  1557. </if>
  1558. <if test="dateStart != null and dateStart != ''">
  1559. and a.create_time &gt;= #{dateStart,jdbcType=TIMESTAMP}
  1560. </if>
  1561. <if test="dateEnd != null and dateEnd != ''">
  1562. and a.create_time &lt;= #{dateEnd,jdbcType=TIMESTAMP}
  1563. </if>
  1564. ) t1
  1565. </select>
  1566. <select id="selectStatisticsByOrder" resultType="com.sckw.transport.model.vo.StatisticsByOrderVO">
  1567. SELECT
  1568. IFNULL( SUM( t1.WaitingAmount ), 0 ) AS WaitingAmount ,
  1569. IFNULL( SUM( t1.amount ), 0 ) AS amount ,
  1570. IFNULL( SUM( t1.entrustAmount ), 0 ) AS entrustAmount ,
  1571. IFNULL( SUM( t1.subcontractAmount ), 0 ) AS subcontractAmount ,
  1572. IFNULL( SUM( t1.totalPrice ), 0 ) AS totalPrice
  1573. FROM
  1574. (
  1575. SELECT
  1576. ( a.amount - a.entrust_amount - a.subcontract_amount ) AS WaitingAmount,
  1577. a.amount,
  1578. a.entrust_amount AS entrustAmount,
  1579. a.subcontract_amount AS subcontractAmount,
  1580. a.price ,
  1581. a.amount * IFNULL(a.price,0) AS totalPrice
  1582. FROM
  1583. kwt_logistics_order a
  1584. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  1585. AND a.del_flag = 0
  1586. AND b.del_flag = 0
  1587. WHERE
  1588. b.unit_type = #{unitType}
  1589. <if test="topId != null and topId !=''">
  1590. and b.top_ent_id = #{topId}
  1591. </if>
  1592. <if test="statusList != null and statusList.size()>0">
  1593. and a.`status` IN
  1594. <foreach collection="statusList" item="item" separator="," open="(" close=")">
  1595. #{item}
  1596. </foreach>
  1597. </if>
  1598. <if test="dateStart != null and dateStart != ''">
  1599. and a.create_time &gt;= #{dateStart,jdbcType=TIMESTAMP}
  1600. </if>
  1601. <if test="dateEnd != null and dateEnd != ''">
  1602. and a.create_time &lt;= #{dateEnd,jdbcType=TIMESTAMP}
  1603. </if>
  1604. ) t1
  1605. </select>
  1606. <select id="selectAcceptCarriageAwaitFinishOrder" resultType="com.sckw.transport.model.vo.StatisticsByOrderVO">
  1607. SELECT
  1608. IFNULL( SUM( t1.WaitingAmount ), 0 ) AS WaitingAmount ,
  1609. IFNULL( SUM( t1.amount ), 0 ) AS amount ,
  1610. IFNULL( SUM( t1.entrustAmount ), 0 ) AS entrustAmount ,
  1611. IFNULL( SUM( t1.subcontractAmount ), 0 ) AS subcontractAmount ,
  1612. IFNULL( SUM( t1.totalPrice ), 0 ) AS totalPrice
  1613. FROM
  1614. (
  1615. SELECT
  1616. ( a.amount - a.entrust_amount - a.subcontract_amount) AS WaitingAmount,
  1617. a.amount,
  1618. a.entrust_amount AS entrustAmount,
  1619. a.subcontract_amount AS subcontractAmount,
  1620. a.price ,
  1621. a.amount * IFNULL(a.price,0) AS totalPrice
  1622. FROM
  1623. kwt_logistics_order a
  1624. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  1625. AND a.del_flag = 0
  1626. AND b.del_flag = 0
  1627. WHERE
  1628. b.unit_type = #{unitType}
  1629. <if test="topId != null and topId !=''">
  1630. and b.top_ent_id = #{topId}
  1631. </if>
  1632. <if test="statusList != null and statusList.size()>0">
  1633. and a.`status` IN
  1634. <foreach collection="statusList" item="item" separator="," open="(" close=")">
  1635. #{item}
  1636. </foreach>
  1637. </if>
  1638. <if test="dateStart != null and dateStart != ''">
  1639. and a.create_time &gt;= #{dateStart,jdbcType=TIMESTAMP}
  1640. </if>
  1641. <if test="dateEnd != null and dateEnd != ''">
  1642. and a.create_time &lt;= #{dateEnd,jdbcType=TIMESTAMP}
  1643. </if>
  1644. ) t1
  1645. </select>
  1646. <select id="workbenchLogisticsOrderStatisticsByMonth" resultType="com.sckw.transport.model.vo.LogisticsOrderStatisticsVO">
  1647. SELECT A.date_time as dateTime, COALESCE(B.num, 0) as num,IFNULL(B.totalAmount,0) AS totalAmount FROM
  1648. (
  1649. SELECT
  1650. DATE_FORMAT( DATE_ADD( #{dateStart}, INTERVAL ROW1 MONTH ), '%Y-%m' ) date_time
  1651. FROM
  1652. (
  1653. SELECT
  1654. @ROW := @ROW +1 as ROW1
  1655. FROM
  1656. (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t,
  1657. (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t2,
  1658. (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t3,
  1659. (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t4,
  1660. (SELECT @row:=-1) r
  1661. ) se
  1662. WHERE
  1663. DATE_FORMAT( date_add( #{dateStart}, INTERVAL ROW1 MONTH ), '%Y-%m' ) &lt;= DATE_FORMAT(
  1664. #{dateEnd},
  1665. '%Y-%m')
  1666. ) A
  1667. LEFT JOIN
  1668. (
  1669. SELECT DATE_FORMAT(a.create_time, '%Y-%m') date_time, COUNT(*) num,sum(a.amount) as totalAmount
  1670. FROM kwt_logistics_order a LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  1671. WHERE a.del_flag = 0 AND b.unit_type = #{type}
  1672. <if test="statusList != null and statusList.size() > 0">
  1673. and a.status in
  1674. <foreach collection="statusList" close=")" open="(" separator="," item="item">
  1675. #{item}
  1676. </foreach>
  1677. </if>
  1678. GROUP BY DATE_FORMAT(a.create_time, '%Y-%m')
  1679. ) B
  1680. ON A.date_time = B.date_time
  1681. </select>
  1682. <select id="workbenchLogisticsOrderStatisticsByDays"
  1683. resultType="com.sckw.transport.model.vo.LogisticsOrderStatisticsVO">
  1684. SELECT A.date as dateTime, COALESCE(B.num, 0) as num,IFNULL(B.totalAmount,0) AS totalAmount FROM
  1685. (
  1686. select date_add(#{dateStart}, interval row1 DAY) date from
  1687. (
  1688. SELECT @row := @row + 1 as row1 FROM
  1689. (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t,
  1690. (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t2,
  1691. (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t3,
  1692. (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t4,
  1693. (SELECT @row:=-1) r
  1694. ) se
  1695. where date_add(#{dateStart}, interval row1 DAY) &lt;= #{dateEnd}
  1696. ) A
  1697. LEFT JOIN
  1698. (
  1699. SELECT
  1700. <!-- <if test="type == 1">-->
  1701. <!-- COUNT(*) num,-->
  1702. <!-- </if>-->
  1703. <!-- <if test="type == 1">-->
  1704. <!-- sum(a.amount) as totalAmount ,-->
  1705. <!-- </if>-->
  1706. COUNT(*) num,
  1707. sum(a.amount) as totalAmount ,
  1708. DATE_FORMAT(a.create_time, '%Y-%m-%d') date_time
  1709. FROM kwt_logistics_order a LEFT JOIN kwt_logistics_order_unit b ON a.id =b.l_order_id
  1710. WHERE a.del_flag = 0 AND b.unit_type = b.unit_type = #{type}
  1711. <if test="statusList != null and statusList.size() > 0">
  1712. and a.status in
  1713. <foreach collection="statusList" close=")" open="(" separator="," item="item">
  1714. #{item}
  1715. </foreach>
  1716. </if>
  1717. GROUP BY DATE_FORMAT(a.create_time, '%Y-%m-%d')
  1718. ) B
  1719. ON A.date= B.date_time;
  1720. </select>
  1721. </mapper>