KwtLogisticsOrderMapper.xml 83 KB

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