KwfTruckMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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.fleet.dao.KwfTruckMapper">
  4. <select id="statisticsAll" resultType="com.sckw.fleet.model.vo.KwfTableTopCount" parameterType="java.util.Map" >
  5. SELECT
  6. tr.`auth_status` value, count(0) total
  7. from kwf_truck tr
  8. left join kwf_truck_license trl on trl.truck_id = tr.id and trl.del_flag = 0
  9. left join kwf_transport_license tranl on tranl.truck_id = tr.id and tranl.del_flag = 0
  10. where tr.del_flag = 0
  11. <if test="entId != null and entId != ''">
  12. and tr.ent_id = #{entId, jdbcType=VARCHAR}
  13. </if>
  14. <if test="truckNo != null and truckNo != ''">
  15. and tr.truck_no = #{truckNo, jdbcType=VARCHAR}
  16. </if>
  17. <if test="type != null and type != ''">
  18. and tr.type = #{type, jdbcType=VARCHAR}
  19. </if>
  20. <if test="energyType != null and energyType != ''">
  21. and tr.energy_type = #{energyType, jdbcType=VARCHAR}
  22. </if>
  23. <if test="useType != null and useType != ''">
  24. and tr.use_type = #{useType, jdbcType=VARCHAR}
  25. </if>
  26. <if test="status != null and status != ''">
  27. and tr.status = #{status, jdbcType=VARCHAR}
  28. </if>
  29. <if test="startTime != null and startTime != '' " >
  30. and DATE( tr.create_time) <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
  31. </if>
  32. <if test="endTime != null and endTime != '' " >
  33. and DATE( tr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
  34. </if>
  35. <if test="keywords != null and keywords != ''">
  36. and (
  37. tr.truck_no like concat('%',#{keywords},'%')
  38. )
  39. </if>
  40. GROUP BY tr.`auth_status`
  41. </select>
  42. <select id="statistics" resultType="com.sckw.fleet.model.vo.KwfTableTopCount" parameterType="java.util.Map" >
  43. SELECT
  44. tr.`auth_status` value, count(0) total
  45. from kwf_truck tr
  46. left join kwf_truck_ent tre on tre.truck_id = tr.id
  47. left join kwf_truck_license trl on trl.truck_id = tr.id and trl.del_flag = 0
  48. left join kwf_transport_license tranl on tranl.truck_id = tr.id and tranl.del_flag = 0
  49. left join kwf_fleet_truck flt on flt.truck_id = tr.id and flt.del_flag = 0
  50. left join kwf_fleet fl on fl.id = flt.fleet_id and fl.del_flag = 0
  51. where tr.del_flag = 0 and tre.del_flag = 0
  52. <if test="entId != null and entId != ''">
  53. and tre.ent_id = #{entId, jdbcType=VARCHAR}
  54. </if>
  55. <if test="truckNo != null and truckNo != ''">
  56. and tr.truck_no = #{truckNo, jdbcType=VARCHAR}
  57. </if>
  58. <if test="type != null and type != ''">
  59. and tr.type = #{type, jdbcType=VARCHAR}
  60. </if>
  61. <if test="energyType != null and energyType != ''">
  62. and tr.energy_type = #{energyType, jdbcType=VARCHAR}
  63. </if>
  64. <if test="useType != null and useType != ''">
  65. and tr.use_type = #{useType, jdbcType=VARCHAR}
  66. </if>
  67. <if test="fleetId != null and fleetId != ''">
  68. and fl.id = #{fleetId, jdbcType=VARCHAR}
  69. </if>
  70. <if test="fleetName != null and fleetName != ''">
  71. and fl.name like concat('%',#{fleetName},'%')
  72. </if>
  73. <if test="status != null and status != ''">
  74. and tr.status = #{status, jdbcType=VARCHAR}
  75. </if>
  76. <if test="startTime != null and startTime != '' " >
  77. and DATE( tr.create_time) <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
  78. </if>
  79. <if test="endTime != null and endTime != '' " >
  80. and DATE( tr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
  81. </if>
  82. <if test="keywords != null and keywords != ''">
  83. and (
  84. tr.truck_no like concat('%',#{keywords},'%')
  85. )
  86. </if>
  87. GROUP BY tr.`auth_status`
  88. </select>
  89. <select id="findPageAll" resultType="com.sckw.fleet.model.vo.KwfTruckVo" parameterType="java.util.Map" >
  90. SELECT
  91. tr.id, tr.ent_id entId, tr.truck_no truckNo, tr.type, tr.energy_type energyType, tr.use_type useType,
  92. tr.spec, tr.actual_weight actualWeight, tr.gross_weight grossWeight, tr.tare_weight tareWeight,
  93. tr.color, tr.eev, tr.trailer_no trailerNo, tr.total_complete totalComplete, tr.total_take totalTake,
  94. tr.total_weight totalWeight, tr.business_status businessStatus, tr.remark, tr.status, tr.auth_status authStatus,
  95. tr.create_by createBy, tr.create_time createTime, tr.update_by updateBy, tr.update_time updateTime,
  96. trl.owner, trl.vin, trl.reg_time regTime, trl.grant_time grantTime, trl.grant_unit grantUnit,
  97. trl.driving_no drivingNo, tranl.road_tran_no roadTranNo, tranl.firm_name tranFirmName,
  98. tranl.business_license_no businessLicenseNo
  99. from kwf_truck tr
  100. left join kwf_truck_license trl on trl.truck_id = tr.id and trl.del_flag = 0
  101. left join kwf_transport_license tranl on tranl.truck_id = tr.id and tranl.del_flag = 0
  102. where tr.del_flag = 0
  103. <if test="entId != null and entId != ''">
  104. and tr.ent_id = #{entId, jdbcType=VARCHAR}
  105. </if>
  106. <if test="truckNo != null and truckNo != ''">
  107. and tr.truck_no = #{truckNo, jdbcType=VARCHAR}
  108. </if>
  109. <if test="truckType != null and truckType != ''">
  110. and tr.type = #{type, jdbcType=VARCHAR}
  111. </if>
  112. <if test="energyType != null and energyType != ''">
  113. and tr.energy_type = #{energyType, jdbcType=VARCHAR}
  114. </if>
  115. <if test="useType != null and useType != ''">
  116. and tr.use_type = #{useType, jdbcType=VARCHAR}
  117. </if>
  118. <if test="status != null and status != ''">
  119. and tr.status = #{status, jdbcType=VARCHAR}
  120. </if>
  121. <if test="authStatus != null and status != ''">
  122. and tr.auth_status = #{authStatus, jdbcType=VARCHAR}
  123. </if>
  124. <if test="startTime != null and startTime != '' " >
  125. and DATE( tr.create_time) <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
  126. </if>
  127. <if test="endTime != null and endTime != '' " >
  128. and DATE( tr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
  129. </if>
  130. <choose>
  131. <when test="ids != null">
  132. and tr.id in
  133. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  134. #{id,jdbcType=BIGINT}
  135. </foreach>
  136. </when>
  137. </choose>
  138. <if test="keywords != null and keywords != ''">
  139. and (
  140. tr.truck_no like concat('%',#{keywords},'%')
  141. )
  142. </if>
  143. ORDER BY tr.create_time desc
  144. </select>
  145. <select id="findPage" resultType="com.sckw.fleet.model.vo.KwfTruckVo" parameterType="java.util.Map" >
  146. SELECT
  147. tr.id, tr.ent_id entId, tr.truck_no truckNo, tr.type, tr.energy_type energyType, tr.use_type useType,
  148. tr.spec, tr.actual_weight actualWeight, tr.gross_weight grossWeight, tr.tare_weight tareWeight,
  149. tr.color, tr.eev, tr.trailer_no trailerNo, tr.total_complete totalComplete, tr.total_take totalTake,
  150. tr.total_weight totalWeight, tr.business_status businessStatus, tr.remark, tr.status, tr.auth_status authStatus,
  151. tr.create_by createBy, tr.create_time createTime, tr.update_by updateBy, tr.update_time updateTime,
  152. trl.owner, trl.vin, trl.reg_time regTime, trl.grant_time grantTime, trl.grant_unit grantUnit,
  153. trl.driving_no drivingNo, tranl.road_tran_no roadTranNo, tranl.firm_name tranFirmName,
  154. tranl.business_license_no businessLicenseNo, fl.`name` fleetName
  155. from kwf_truck tr
  156. left join kwf_truck_ent tre on tre.truck_id = tr.id
  157. left join kwf_truck_license trl on trl.truck_id = tr.id and trl.del_flag = 0
  158. left join kwf_transport_license tranl on tranl.truck_id = tr.id and tranl.del_flag = 0
  159. left join kwf_fleet_truck flt on flt.truck_id = tr.id and flt.del_flag = 0
  160. left join kwf_fleet fl on fl.id = flt.fleet_id and fl.del_flag = 0
  161. where tr.del_flag = 0 and tre.del_flag = 0
  162. <if test="entId != null and entId != ''">
  163. and tre.ent_id = #{entId, jdbcType=VARCHAR}
  164. </if>
  165. <if test="truckNo != null and truckNo != ''">
  166. and tr.truck_no = #{truckNo, jdbcType=VARCHAR}
  167. </if>
  168. <if test="truckType != null and truckType != ''">
  169. and tr.type = #{type, jdbcType=VARCHAR}
  170. </if>
  171. <if test="energyType != null and energyType != ''">
  172. and tr.energy_type = #{energyType, jdbcType=VARCHAR}
  173. </if>
  174. <if test="useType != null and useType != ''">
  175. and tr.use_type = #{useType, jdbcType=VARCHAR}
  176. </if>
  177. <if test="fleetId != null and fleetId != ''">
  178. and fl.id = #{fleetId, jdbcType=VARCHAR}
  179. </if>
  180. <if test="fleetName != null and fleetName != ''">
  181. and fl.name like concat('%',#{fleetName},'%')
  182. </if>
  183. <if test="status != null and status != ''">
  184. and tr.status = #{status, jdbcType=VARCHAR}
  185. </if>
  186. <if test="authStatus != null and status != ''">
  187. and tr.auth_status = #{authStatus, jdbcType=VARCHAR}
  188. </if>
  189. <if test="startTime != null and startTime != '' " >
  190. and DATE( tr.create_time) <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
  191. </if>
  192. <if test="endTime != null and endTime != '' " >
  193. and DATE( tr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
  194. </if>
  195. <choose>
  196. <when test="ids != null">
  197. and tr.id in
  198. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  199. #{id,jdbcType=BIGINT}
  200. </foreach>
  201. </when>
  202. </choose>
  203. <if test="keywords != null and keywords != ''">
  204. and (
  205. tr.truck_no like concat('%',#{keywords},'%')
  206. )
  207. </if>
  208. ORDER BY tr.create_time desc
  209. </select>
  210. <select id="findList" resultType="java.util.Map" parameterType="java.util.Map" >
  211. SELECT
  212. tr.id, tre.ent_id entId, truck_no truckNo, type, energy_type energyType, use_type useType,
  213. spec, actual_weight actualWeight, gross_weight grossWeight, tare_weight tareWeight,
  214. color, eev, trailer_no trailerNo, total_complete totalComplete, total_take totalTake,
  215. total_weight totalWeight, business_status businessStatus, tr.remark, tr.status, tr.auth_status authStatus,
  216. tr.create_by createBy, tr.create_time createTime, tr.update_by updateBy, tr.update_time updateTime
  217. from kwf_truck tr
  218. left join kwf_truck_ent tre on tre.truck_id = tr.id
  219. where tr.del_flag = 0 and tre.del_flag = 0
  220. <if test="entId != null and entId != ''">
  221. and tre.ent_id = #{entId, jdbcType=VARCHAR}
  222. </if>
  223. <if test="truckNo != null and truckNo != ''">
  224. and tr.truck_no like concat('%',#{truckNo},'%')
  225. </if>
  226. <if test="wholeTruckNo != null and wholeTruckNo != ''">
  227. and tr.truck_no = #{wholeTruckNo, jdbcType=VARCHAR}
  228. </if>
  229. <if test="type != null and type != ''">
  230. and tr.type = #{type, jdbcType=VARCHAR}
  231. </if>
  232. <if test="energyType != null and energyType != ''">
  233. and tr.energy_type = #{energyType, jdbcType=VARCHAR}
  234. </if>
  235. <if test="useType != null and useType != ''">
  236. and tr.use_type = #{useType, jdbcType=VARCHAR}
  237. </if>
  238. <if test="status != null and status != ''">
  239. and tr.status = #{status, jdbcType=VARCHAR}
  240. </if>
  241. <if test="authStatus != null and status != ''">
  242. and tr.auth_status = #{authStatus, jdbcType=VARCHAR}
  243. </if>
  244. <if test="startTime != null and startTime != '' " >
  245. and DATE( tr.create_time) <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
  246. </if>
  247. <if test="endTime != null and endTime != '' " >
  248. and DATE( tr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
  249. </if>
  250. <choose>
  251. <when test="truckNos != null and truckNos != ''">
  252. and tr.truck_no in
  253. <foreach collection="truckNos" item="truckNo" open="(" close=")" separator=",">
  254. #{truckNo,jdbcType=VARCHAR}
  255. </foreach>
  256. </when>
  257. </choose>
  258. <if test="keywords != null and keywords != ''">
  259. and (
  260. tr.truck_no like concat('%',#{keywords},'%')
  261. )
  262. </if>
  263. ORDER BY tr.create_time desc
  264. </select>
  265. <select id="findTruck" resultType="com.sckw.fleet.model.KwfTruck" parameterType="java.util.Map" >
  266. SELECT
  267. id, ent_id entId, truck_no truckNo, type, energy_type energyType, use_type useType,
  268. spec, actual_weight actualWeight, gross_weight grossWeight, tare_weight tareWeight,
  269. color, eev, trailer_no trailerNo, total_complete totalComplete, total_take totalTake,
  270. total_weight totalWeight, business_status businessStatus, remark, status, auth_status authStatus
  271. from kwf_truck tr
  272. where del_flag = 0
  273. <if test="entId != null and entId != ''">
  274. and ent_id = #{entId, jdbcType=VARCHAR}
  275. </if>
  276. <if test="truckNo != null and truckNo != ''">
  277. and truck_no = #{truckNo, jdbcType=VARCHAR}
  278. </if>
  279. <if test="type != null and type != ''">
  280. and type = #{type, jdbcType=VARCHAR}
  281. </if>
  282. <if test="energyType != null and energyType != ''">
  283. and energy_type = #{energyType, jdbcType=VARCHAR}
  284. </if>
  285. <if test="useType != null and useType != ''">
  286. and use_type = #{useType, jdbcType=VARCHAR}
  287. </if>
  288. <if test="status != null and status != ''">
  289. and status = #{status, jdbcType=VARCHAR}
  290. </if>
  291. <if test="authStatus != null and status != ''">
  292. and auth_status = #{authStatus, jdbcType=VARCHAR}
  293. </if>
  294. ORDER BY create_time desc
  295. </select>
  296. <select id="findEntTruck" resultType="com.sckw.fleet.model.KwfTruck" parameterType="com.sckw.fleet.model.KwfTruck" >
  297. SELECT
  298. tr.id, tre.ent_id entId, truck_no truckNo, type, energy_type energyType, use_type useType,
  299. spec, actual_weight actualWeight, gross_weight grossWeight, tare_weight tareWeight,
  300. color, eev, trailer_no trailerNo, total_complete totalComplete, total_take totalTake,
  301. total_weight totalWeight, business_status businessStatus, tr.remark, tr.status,
  302. tr.create_by createBy, tr.create_time createTime, tr.update_by updateBy, tr.update_time updateTime
  303. from kwf_truck tr
  304. left join kwf_truck_ent tre on tre.truck_id = tr.id
  305. where tr.del_flag = 0 and tre.del_flag = 0
  306. and tre.ent_id = #{entId, jdbcType=VARCHAR}
  307. and tr.id = #{id, jdbcType=VARCHAR}
  308. </select>
  309. <select id="capacityStatistics" resultType="java.util.Map" >
  310. SELECT
  311. ent_id entId, count(1) capacityTotal, sum(auth_status) capacityAmount
  312. from kwf_truck
  313. where del_flag = 0
  314. <choose>
  315. <when test="entIds != null and entIds.size() > 0">
  316. and ent_id in
  317. <foreach collection="entIds" item="item" open="(" close=")" separator=",">
  318. #{item,jdbcType=BIGINT}
  319. </foreach>
  320. </when>
  321. </choose>
  322. GROUP BY ent_id
  323. HAVING 1=1
  324. <if test="capacityAmountMin != null and capacityAmountMin != ''">
  325. and capacityAmount <![CDATA[ >= ]]> #{capacityAmountMin, jdbcType=INTEGER}
  326. </if>
  327. <if test="capacityAmountMax != null and capacityAmountMax != ''">
  328. and capacityAmount <![CDATA[ <= ]]> #{capacityAmountMax, jdbcType=INTEGER}
  329. </if>
  330. </select>
  331. <select id="findTruckByEnt" resultType="com.sckw.fleet.model.vo.KwfTruckMonitorVo" >
  332. SELECT
  333. kt.truck_no, kt.business_status businessStatus, kte.ent_id entId
  334. from kwf_truck kt
  335. left join kwf_truck_ent kte on kte.truck_id = kt.id
  336. where kt.del_flag = 0 and kte.del_flag = 0
  337. and kte.ent_id = #{entId, jdbcType=BIGINT}
  338. <if test="truckNo != null and truckNo != ''">
  339. and kt.truck_no = #{truckNo, jdbcType=VARCHAR}
  340. </if>
  341. </select>
  342. <select id="findTruckByAll" resultType="com.sckw.fleet.model.vo.KwfTruckMonitorVo" >
  343. SELECT
  344. kt.truck_no, kt.business_status businessStatus, kt.ent_id entId
  345. from kwf_truck kt
  346. where kt.del_flag = 0
  347. <if test="truckNo != null and truckNo != ''">
  348. and kt.truck_no = #{truckNo, jdbcType=VARCHAR}
  349. </if>
  350. </select>
  351. </mapper>