TruckMapper.xml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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.aoyang.tms.mapper.TruckMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.aoyang.tms.entity.Truck">
  6. <id column="truck_id" property="truckId" />
  7. <result column="trade_type" property="tradeType" />
  8. <result column="org_id" property="orgId" />
  9. <result column="org_name" property="orgName" />
  10. <result column="org_short_name" property="orgShortName" />
  11. <result column="truck_name" property="truckName" />
  12. <result column="car_number" property="carNumber" />
  13. <result column="engine_number" property="engineNumber" />
  14. <result column="purchase_date" property="purchaseDate" />
  15. <result column="color" property="color" />
  16. <result column="dead_weight" property="deadWeight" />
  17. <result column="capacity" property="capacity" />
  18. <result column="manufacturer" property="manufacturer" />
  19. <result column="status" property="status" />
  20. <result column="bind_status" property="bindStatus" />
  21. <result column="tms_status" property="tmsStatus" />
  22. <result column="dept_name" property="deptName" />
  23. <result column="dept_id" property="deptId" />
  24. <result column="creater" property="creater" />
  25. <result column="create_date" property="createDate" />
  26. <result column="updater" property="updater" />
  27. <result column="update_date" property="updateDate" />
  28. <result column="frame_number" property="frameNumber" />
  29. <result column="trailer_number" property="trailerNumber" />
  30. <result column="creater_name" property="createrName" />
  31. <result column="updater_name" property="updaterName" />
  32. <result column="linked" property="linked" />
  33. <result column="auto_account" property="autoAccount" />
  34. <result column="type_name" property="typeName" />
  35. <result column="owner" property="owner" />
  36. <result column="address" property="address" />
  37. <result column="use_nature" property="useNature" />
  38. <result column="vehicle_id_code" property="vehicleIdCode" />
  39. <result column="register_date" property="registerDate" />
  40. <result column="issue_date" property="issueDate" />
  41. <result column="file_no" property="fileNo" />
  42. <result column="energy_type" property="energyType" />
  43. <result column="face_url" property="faceUrl" />
  44. <result column="back_url" property="backUrl" />
  45. <result column="auth_status" property="authStatus" />
  46. <result column="auth_date" property="authDate" />
  47. <result column="level" property="level" />
  48. <result column="com_status" property="comStatus" />
  49. <result column="com_contract_status" property="comContractStatus" />
  50. </resultMap>
  51. <!-- 通用查询结果列 -->
  52. <sql id="Base_Column_List">
  53. truck_id, trade_type, org_id, org_name, org_short_name, truck_name, car_number, engine_number, purchase_date, color, dead_weight, capacity, manufacturer, status, bind_status, tms_status, dept_name, dept_id, creater, create_date, updater, update_date, frame_number, trailer_number, creater_name, updater_name, linked, auto_account, type_name, owner, address, use_nature, vehicle_id_code, register_date, issue_date, file_no, energy_type, face_url, back_url, auth_status, auth_date, level, com_status, com_contract_status
  54. </sql>
  55. <!-- 查询实时调度车辆列表 -->
  56. <select id="listTmsManageTruck" resultType="com.aoyang.tms.controller.vo.TruckOrderManageVO">
  57. SELECT * FROM (
  58. SELECT
  59. truck.truck_id as truckId, truck.tms_status as tmsStatus, truck.org_id as orgId, truck.org_name as orgName, truck.org_short_name as orgShortName,
  60. truck.car_number as carNumber, truck.trailer_number as trailerNumber, truck.dept_id as deptId, truck.dept_name as deptName,
  61. two.id as orderId, two.order_status as orderStatus, two.order_no as orderNo, two.type, two.spot_id as spotId, two.spot_name as spotName,
  62. two.shipper_id as shipperId, two.shipper_name as shipperName, two.update_date as updateDate, two.create_date as createDate, two.queue_no as queueNo, wc.id as cycleId,
  63. case when wc.jing_weight > 0 then 1 else 0 end as weightFlag, two.spot_id
  64. FROM
  65. truck
  66. left join (
  67. select * from tms_work_order wo where 40 > wo.order_status
  68. <if test="param!=null and param.loadCount == 1">
  69. and wo.type = 1 and wo.order_status in (10, 20, 30)
  70. </if>
  71. <if test="param!=null and param.loadGotoSpot == 1">
  72. and wo.type = 1 and wo.order_status = 10
  73. </if>
  74. <if test="param!=null and param.loadWait == 1">
  75. and wo.type = 1 and wo.order_status = 20
  76. </if>
  77. <if test="param!=null and param.loadSubmit == 1">
  78. and wo.type = 1 and wo.order_status = 30
  79. </if>
  80. <if test="param!=null and param.unloadCount == 1">
  81. and wo.type = 2 and wo.order_status in (10, 20, 30)
  82. </if>
  83. <if test="param!=null and param.unloadGotoSpot == 1">
  84. and wo.type = 2 and wo.order_status = 10
  85. </if>
  86. <if test="param!=null and param.unloadWait == 1">
  87. and wo.type = 2 and wo.order_status = 20
  88. </if>
  89. <if test="param!=null and param.unloadSubmit == 1">
  90. and wo.type = 2 and wo.order_status = 30
  91. </if>
  92. <if test="param!=null and param.emptyUnAllocated == 1">
  93. and wo.type = 1
  94. </if>
  95. <if test="param!=null and param.heavyUnAllocated == 1">
  96. and wo.type = 2
  97. </if>
  98. order by order_status desc, plan_reach_time asc
  99. ) two on truck.truck_id = two.truck_id
  100. left join tms_work_cycle wc on truck.truck_id = wc.truck_id and wc.status = 1
  101. where truck.org_id = #{param.orgId}
  102. <if test="param!=null and param.deptId!=null">
  103. and truck.dept_id = #{param.deptId}
  104. </if>
  105. <if test="param!=null and param.carNumber!=null and param.carNumber!=''">
  106. and (truck.car_number like concat('%',#{param.carNumber},'%') or
  107. truck.trailer_number like concat('%',#{param.carNumber},'%'))
  108. </if>
  109. <if test="param!=null and param.shipperId!=null">
  110. and two.shipper_id = #{param.shipperId}
  111. </if>
  112. <if test="param!=null and param.surplusCount == 1">
  113. and (two.id is null or two.order_status = 0)
  114. </if>
  115. <if test="param!=null and param.unExecuted == 1">
  116. and two.order_status = 0
  117. </if>
  118. <if test="param!=null and param.unAllocated == 1">
  119. and two.id is null
  120. </if>
  121. <if test="param.loadCount == 1 or param.loadWait == 1 or param.loadGotoSpot == 1 or param.loadSubmit == 1 or
  122. param.unloadCount == 1 or param.unloadGotoSpot == 1 or param.unloadWait == 1 or param.unloadSubmit == 1">
  123. and two.id is not null
  124. </if>
  125. <if test="param!=null and param.emptyUnAllocated == 1">
  126. and (wc.jing_weight = 0 or wc.jing_weight is null) and two.id is null
  127. </if>
  128. <if test="param!=null and param.heavyUnAllocated == 1">
  129. and wc.jing_weight > 0 and two.id is null
  130. </if>
  131. group by truck.truck_id
  132. ) tbl
  133. <where>
  134. <if test="param != null and param.spotId != null">
  135. and wc.jing_weight > 0 and two.id is null
  136. ORDER BY tbl.queueNo is null, tbl.queueNo asc
  137. </if>
  138. </where>
  139. </select>
  140. <!-- 查询未派单车辆 -->
  141. <select id="listUnAllocatedTruck" resultType="com.aoyang.tms.entity.Truck">
  142. SELECT
  143. <include refid="Base_Column_List"/>
  144. FROM
  145. truck left join tms_work_order wo on truck.truck_id = wo.truck_id and 40 > wo.order_status
  146. WHERE truck.org_id = #{orgId} and wo.id is null
  147. </select>
  148. <!-- 查询未执行派单车辆 -->
  149. <select id="getUnExecutedOrderTruckCount" resultType="java.lang.Integer">
  150. SELECT count(1)
  151. FROM ( select id from truck left join tms_work_order wo on truck.truck_id = wo.truck_id and wo.order_status = 0
  152. WHERE truck.org_id = #{orgId} and wo.id is not null
  153. group by truck.truck_id ) tbl
  154. </select>
  155. <!-- 查询未派单车辆 -->
  156. <select id="getUnAllocatedTruckCount" resultType="java.lang.Integer">
  157. SELECT count(1)
  158. FROM
  159. truck left join tms_work_order wo on truck.truck_id = wo.truck_id and 40 > wo.order_status
  160. WHERE truck.org_id = #{orgId} and wo.id is null
  161. </select>
  162. <!-- 查询未派指定类型运单车车辆 -->
  163. <select id="getUnAllocatedOrderCount" resultType="java.lang.Integer">
  164. SELECT count(1)
  165. FROM
  166. truck
  167. left join tms_work_order wo on truck.truck_id = wo.truck_id and 40 > wo.order_status
  168. <if test="orderType != null and orderType == 1">
  169. and wo.type = #{orderType}
  170. </if>
  171. <if test="orderType != null and orderType == 2">
  172. and wo.type = #{orderType}
  173. </if>
  174. left join tms_work_cycle wc on truck.truck_id = wc.truck_id and wc.status = 1
  175. WHERE truck.org_id = #{orgId} and wo.id is null
  176. <if test="orderType != null and orderType == 1">
  177. and ( wc.jing_weight = 0 or wc.jing_weight is null )
  178. </if>
  179. <if test="orderType != null and orderType == 2">
  180. and wc.jing_weight > 0
  181. </if>
  182. </select>
  183. </mapper>