KwtWaybillOrderMapper.xml 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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.KwtWaybillOrderMapper">
  4. <resultMap id="BaseResultMap" type="com.sckw.transport.model.KwtWaybillOrder">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="ent_id" jdbcType="BIGINT" property="entId"/>
  7. <result column="l_order_id" jdbcType="BIGINT" property="lOrderId"/>
  8. <result column="w_order_no" jdbcType="VARCHAR" property="wOrderNo"/>
  9. <result column="truck_no" jdbcType="VARCHAR" property="truckNo"/>
  10. <result column="type" jdbcType="VARCHAR" property="type"/>
  11. <result column="driver_id" jdbcType="BIGINT" property="driverId"/>
  12. <result column="driver_name" jdbcType="VARCHAR" property="driverName"/>
  13. <result column="driver_phone" jdbcType="VARCHAR" property="driverPhone"/>
  14. <result column="driver_idcard" jdbcType="VARCHAR" property="driverIdcard"/>
  15. <result column="entrust_amount" jdbcType="DECIMAL" property="entrustAmount"/>
  16. <result column="unload_amount" jdbcType="DECIMAL" property="unloadAmount"/>
  17. <result column="load_amount" jdbcType="DECIMAL" property="loadAmount"/>
  18. <result column="deficit_amount" jdbcType="DECIMAL" property="deficitAmount"/>
  19. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  20. <result column="status" jdbcType="INTEGER" property="status"/>
  21. <result column="create_by" jdbcType="BIGINT" property="createBy"/>
  22. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  23. <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
  24. <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
  25. <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
  26. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  27. <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
  28. </resultMap>
  29. <sql id="Base_Column_List">
  30. id
  31. , ent_id, l_order_id, w_order_no, truck_no, driver_id, entrust_amount, unload_amount,
  32. load_amount, deficit_amount, remark, `status`, create_by, create_time, update_by,
  33. update_time, del_flag,start_time,end_time
  34. </sql>
  35. <select id="selectWaybillOrderCarList" resultType="com.sckw.transport.model.dto.OrderCarDTO">
  36. SELECT a.id as wOrderId,
  37. a.w_order_no as wOrderNo,
  38. a.driver_id as driverId,
  39. a.driver_name as driverName,
  40. a.driver_phone as driverPhone,
  41. a.driver_idcard as driverCard,
  42. a.truck_no as truckNo,
  43. a.l_order_id as lOrderId,
  44. b.l_order_no as lOrderNo,
  45. b.t_order_id as tOrderId,
  46. b.t_order_no as tOrderNo
  47. FROM kwt_waybill_order a
  48. LEFT JOIN kwt_logistics_order b ON a.l_order_id = b.id
  49. WHERE a.del_flag = '0'
  50. and b.del_flag = '0'
  51. and b.t_order_id = #{id,jdbcType=VARCHAR} limit #{page}
  52. , #{pageSize}
  53. </select>
  54. <select id="selectWaybillOrderCarCount" resultType="java.lang.Long">
  55. SELECT count(a.id)
  56. FROM kwt_waybill_order a
  57. LEFT JOIN kwt_logistics_order b ON a.l_order_id = b.id
  58. WHERE a.del_flag = '0'
  59. and b.del_flag = '0'
  60. and b.t_order_id = #{id,jdbcType=VARCHAR}
  61. </select>
  62. <select id="selectDriverOrder" resultType="java.lang.Long">
  63. SELECT a.l_order_id as lOrderId
  64. FROM kwt_waybill_order a
  65. LEFT JOIN kwt_waybill_order_track b ON a.id = b.w_order_id
  66. AND a.del_flag = '0'
  67. AND b.del_flag = '0'
  68. AND a.type='0'
  69. <where>
  70. <if test="id != null and id !=''">
  71. a.driver_id = #{id,jdbcType=BIGINT}
  72. </if>
  73. <if test="status != null and status.size() > 0">
  74. AND a.`status` IN
  75. <foreach collection="status" item="item" open="(" close=")" separator=",">
  76. #{item}
  77. </foreach>
  78. </if>
  79. </where>
  80. group by lOrderId
  81. </select>
  82. <select id="getWaybillData" resultType="com.sckw.transport.model.vo.WaybillDetailVO">
  83. </select>
  84. <select id="selectWaybillRelate" resultType="com.sckw.transport.model.dto.WayBillDetailDTO">
  85. SELECT `order`.`id` AS `wOrderId`,
  86. `order`.`w_order_no` AS `wOrderNo`,
  87. `order`.`truck_no` AS `truckNo`,
  88. `order`.`entrust_amount` AS `entrustAmount`,
  89. `order`.`truck_id` AS `truckId`,
  90. `order`.`driver_id` AS `driverId`,
  91. `order`.`driver_name` AS `driverName`,
  92. `order`.`driver_phone` AS `driverPhone`,
  93. `order`.`driver_idcard` AS `driverIdcard`,
  94. `order`.`type`,
  95. `order`.`start_time` AS `startTime`,
  96. `order`.`end_time` AS `endTime`,
  97. `order`.`create_by` AS `createBy`,
  98. `logistics`.`id` AS `lOrderId`,
  99. `logistics`.`l_order_no` AS `lOrderNo`,
  100. `logistics`.`price_type` AS `priceType`,
  101. `goods`.`goods_name` AS goodsName
  102. FROM `kwt_waybill_order` `order`
  103. LEFT JOIN `kwt_logistics_order` `logistics` ON `logistics`.`id` = `order`.`l_order_id`
  104. LEFT JOIN `kwt_logistics_order_goods` `goods` ON `goods`.`l_order_id` = `order`.`l_order_id`
  105. WHERE `order`.`id` = #{id,jdbcType=BIGINT}
  106. </select>
  107. <select id="statistics" resultType="com.sckw.mongo.model.TableTops">
  108. SELECT count(a.id) AS total
  109. FROM kwt_waybill_order a
  110. LEFT JOIN kwt_waybill_order_track b ON a.id = b.w_order_id
  111. AND a.del_flag = '0'
  112. AND b.del_flag = '0'
  113. <where>
  114. <if test="id != null and id !=''">
  115. a.driver_id = #{id,jdbcType=BIGINT}
  116. </if>
  117. <if test="status != null and status.size() > 0">
  118. AND b.`status` IN
  119. <foreach collection="status" item="item" open="(" close=")" separator=",">
  120. #{item}
  121. </foreach>
  122. </if>
  123. </where>
  124. </select>
  125. <select id="selectDataByLorderId" resultType="int">
  126. SELECT
  127. COUNT(b.id)
  128. FROM
  129. kwt_waybill_order a
  130. LEFT JOIN kwt_logistics_order b ON a.l_order_id = b.id
  131. AND a.del_flag = 0
  132. AND b.del_flag = 0
  133. <where>
  134. <if test="id != null and id !=''">
  135. and b.id = #{id}
  136. </if>
  137. <if test="statusList != null and statusList.size() >0">
  138. AND a.`status` IN
  139. <foreach collection="statusList" item="item" open="(" close=")" separator=",">
  140. #{item}
  141. </foreach>
  142. </if>
  143. </where>
  144. </select>
  145. <select id="findWaybillOrderCount" resultType="com.sckw.transport.model.vo.WaybillCountVo" parameterType="java.util.Map">
  146. SELECT
  147. IFNULL(SUM(wo.entrust_amount), 0.0) entrustAmount, IFNULL(SUM(wo.load_amount), 0.0) loadAmount,
  148. IFNULL(SUM(wo.unload_amount), 0.0) unloadAmount, IFNULL(SUM(wo.deficit_amount), 0.0) deficitAmount,
  149. MIN(wot1.time) loadTime, MAX(wot2.time) unloadTime
  150. from kwt_waybill_order wo
  151. left join kwt_waybill_order_ticket wot1 on wot1.w_order_id = wo.id and wot1.type = 1 and wot1.del_flag = 0
  152. left join kwt_waybill_order_ticket wot2 on wot2.w_order_id = wo.id and wot2.type = 2 and wot2.del_flag = 0
  153. left join kwt_logistics_order lo on lo.id = wo.l_order_id
  154. where wo.del_flag = 0 and lo.del_flag = 0
  155. <if test="lOrderId != null and lOrderId != ''">
  156. and lo.id = #{lOrderId, jdbcType=BIGINT}
  157. </if>
  158. <if test="passStatus != null and passStatus != ''">
  159. and wo.status = 8
  160. </if>
  161. <if test="loadCountStatus != null and loadCountStatus != ''">
  162. and wo.status in (5, 6, 7, 8, 12)
  163. </if>
  164. <if test="unloadCountStatus != null and unloadCountStatus != ''">
  165. and wo.status in (7, 8, 12)
  166. </if>
  167. <if test="upperlOrderId != null and upperlOrderId != ''">
  168. and FIND_IN_SET(#{upperlOrderId, jdbcType=BIGINT}, pids)
  169. </if>
  170. <if test="belowlOrderId != null and belowlOrderId != ''">
  171. and FIND_IN_SET(id, #{belowlOrderId, jdbcType=VARCHAR})
  172. </if>
  173. </select>
  174. <select id="selectWaybillOrderCarListGroupByTruckNo" resultType="com.sckw.transport.model.dto.OrderCarDTO">
  175. SELECT
  176. a.truck_no AS truckNo,
  177. COUNT( a.truck_no ) AS count,
  178. a.driver_id AS driverId,
  179. a.driver_name AS driverName,
  180. a.driver_phone AS driverPhone,
  181. a.driver_idcard AS driverCard
  182. FROM
  183. `kwt_waybill_order` a
  184. LEFT JOIN kwt_logistics_order b ON a.l_order_id = b.id
  185. AND B.del_flag = 0
  186. AND b.del_flag = 0
  187. <where>
  188. <if test="id != null and id != ''">
  189. and a.l_order_id = #{id}
  190. </if>
  191. </where>
  192. GROUP BY
  193. a.truck_no
  194. limit #{page},#{pageSize}
  195. </select>
  196. </mapper>