KwfTruckReportMapper.xml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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.KwfTruckReportMapper">
  4. <select id="statistics" 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_report trr
  8. left join kwf_truck tr on tr.id = trr.truck_id
  9. left join kwf_driver dr on dr.id = trr.driver_id
  10. left join kwf_fleet_truck flt on flt.truck_id = tr.id and flt.ent_id = trr.ent_id and flt.del_flag = 0
  11. left join kwf_fleet fl on fl.id = flt.fleet_id and fl.ent_id = trr.ent_id and fl.del_flag = 0
  12. where trr.del_flag = 0 and tr.del_flag = 0 and dr.del_flag = 0
  13. <if test="entId != null and entId != ''">
  14. and trr.ent_id = #{entId, jdbcType=VARCHAR}
  15. </if>
  16. <if test="truckNo != null and truckNo != ''">
  17. and tr.truck_no = #{truckNo, jdbcType=VARCHAR}
  18. </if>
  19. <if test="truckType != null and truckType != ''">
  20. and tr.type = #{truckType, jdbcType=VARCHAR}
  21. </if>
  22. <if test="fleetId != null and fleetId != ''">
  23. and fl.id = #{fleetId, jdbcType=VARCHAR}
  24. </if>
  25. <if test="fleetName != null and fleetName != ''">
  26. and fl.name like concat('%',#{fleetName},'%')
  27. </if>
  28. <if test="status != null and status != ''">
  29. and tr.status = #{status, jdbcType=VARCHAR}
  30. </if>
  31. <if test="startTime != null and startTime != '' " >
  32. and DATE( trr.create_time) <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
  33. </if>
  34. <if test="endTime != null and endTime != '' " >
  35. and DATE( trr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
  36. </if>
  37. <if test="keywords != null and keywords != ''">
  38. and (
  39. tr.truck_no like concat('%',#{keywords},'%')
  40. or dr.name like concat('%',#{keywords},'%')
  41. or dr.phone like concat('%',#{keywords},'%')
  42. <choose>
  43. <when test="entIds != null and entIds != '' and entIds.size() > 0">
  44. or (
  45. trr.truck_id in (select id from kwf_truck where del_flag = 0 and ent_id in
  46. <foreach collection="entIds" item="id" open="(" close=")" separator=",">
  47. #{id,jdbcType=BIGINT}
  48. </foreach>
  49. )
  50. or
  51. trr.driver_id in (select id from kwf_driver where del_flag = 0 and ent_id in
  52. <foreach collection="entIds" item="id" open="(" close=")" separator=",">
  53. #{id,jdbcType=BIGINT}
  54. </foreach>
  55. )
  56. )
  57. </when>
  58. <when test="createBys != null and createBys != '' and createBys.size() > 0">
  59. or trr.create_by in
  60. <foreach collection="createBys" item="id" open="(" close=")" separator=",">
  61. #{id,jdbcType=BIGINT}
  62. </foreach>
  63. </when>
  64. </choose>
  65. )
  66. </if>
  67. GROUP BY tr.`auth_status`
  68. </select>
  69. <select id="findPage" resultType="com.sckw.fleet.model.vo.KwfTruckReportVo" parameterType="java.util.Map" >
  70. SELECT
  71. trr.id, trr.ent_id entId, trr.truck_id truckId, driver_id driverId, trr.remark, tr.status,
  72. trr.create_by createBy, trr.create_time createTime, trr.update_time updateTime, trr.remark,
  73. tr.truck_no truckNo, tr.actual_weight actualWeight, tr.business_status businessStatus,
  74. tr.auth_status truckAuthStatus, dr.`name` driverName, dr.phone driverPhone, dr.idcard driverIdcard,
  75. dr.ent_id driverEntId, dr.auth_status driverAuthStatus, tr.ent_id truckEntId, flt.fleet_id truckFleetId,
  76. fl.name truckFleetName, tr.type truckType, tr.color, tr.trailer_no trailerNo
  77. from kwf_truck_report trr
  78. left join kwf_truck tr on tr.id = trr.truck_id
  79. left join kwf_driver dr on dr.id = trr.driver_id
  80. left join kwf_fleet_truck flt on flt.truck_id = tr.id and flt.ent_id = trr.ent_id and flt.del_flag = 0
  81. left join kwf_fleet fl on fl.id = flt.fleet_id and fl.ent_id = trr.ent_id and fl.del_flag = 0
  82. where trr.del_flag = 0 and tr.del_flag = 0 and dr.del_flag = 0
  83. <if test="entId != null and entId != ''">
  84. and trr.ent_id = #{entId, jdbcType=VARCHAR}
  85. </if>
  86. <if test="truckNo != null and truckNo != ''">
  87. and tr.truck_no = #{truckNo, jdbcType=VARCHAR}
  88. </if>
  89. <if test="truckType != null and truckType != ''">
  90. and tr.type = #{truckType, jdbcType=VARCHAR}
  91. </if>
  92. <if test="fleetId != null and fleetId != ''">
  93. and fl.id = #{fleetId, jdbcType=VARCHAR}
  94. </if>
  95. <if test="fleetName != null and fleetName != ''">
  96. and fl.name like concat('%',#{fleetName},'%')
  97. </if>
  98. <if test="status != null and status != ''">
  99. and tr.status = #{status, jdbcType=VARCHAR}
  100. </if>
  101. <if test="truckAuthStatus != null and truckAuthStatus != '' and truckAuthStatus != 0">
  102. and tr.auth_status = #{truckAuthStatus, jdbcType=VARCHAR}
  103. </if>
  104. <if test="authStatus != null and authStatus != '' and authStatus != 0">
  105. and tr.auth_status = #{authStatus, jdbcType=VARCHAR}
  106. </if>
  107. <if test="startTime != null and startTime != '' " >
  108. and DATE( trr.create_time) <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
  109. </if>
  110. <if test="endTime != null and endTime != '' " >
  111. and DATE( trr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
  112. </if>
  113. <choose>
  114. <when test="ids != null and ids != '' and ids.size() > 0">
  115. and trr.id in
  116. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  117. #{id,jdbcType=BIGINT}
  118. </foreach>
  119. </when>
  120. </choose>
  121. <if test="keywords != null and keywords != ''">
  122. and (
  123. tr.truck_no like concat('%',#{keywords},'%')
  124. or dr.name like concat('%',#{keywords},'%')
  125. or dr.phone like concat('%',#{keywords},'%')
  126. <choose>
  127. <when test="entIds != null and entIds != '' and entIds.size() > 0">
  128. or (
  129. trr.truck_id in (select id from kwf_truck where del_flag = 0 and ent_id in
  130. <foreach collection="entIds" item="id" open="(" close=")" separator=",">
  131. #{id,jdbcType=BIGINT}
  132. </foreach>
  133. )
  134. or
  135. trr.driver_id in (select id from kwf_driver where del_flag = 0 and ent_id in
  136. <foreach collection="entIds" item="id" open="(" close=")" separator=",">
  137. #{id,jdbcType=BIGINT}
  138. </foreach>
  139. )
  140. )
  141. </when>
  142. <when test="createBys != null and createBys != '' and createBys.size() > 0">
  143. or trr.create_by in
  144. <foreach collection="createBys" item="id" open="(" close=")" separator=",">
  145. #{id,jdbcType=BIGINT}
  146. </foreach>
  147. </when>
  148. </choose>
  149. )
  150. </if>
  151. ORDER BY tr.create_time desc
  152. </select>
  153. <select id="findList" resultType="java.util.Map" parameterType="java.util.Map" >
  154. SELECT
  155. trr.id, trr.ent_id entId, trr.status, dr.id driverId, dr.name driverName, dr.phone driverPhone,
  156. dr.idcard driverIdcard, tr.id truckId, tr.truck_no truckNo, tr.type truckType, tr.energy_type truckEnergyType,
  157. tr.use_type truckUseType, tr.color truckColor, tr.trailer_no truckTrailerNo, tr.auth_status authStatus,
  158. tr.business_status businessStatus, tr.actual_weight actualWeight
  159. from kwf_truck_report trr
  160. left join kwf_truck tr on tr.id = trr.truck_id
  161. left join kwf_driver dr on dr.id = trr.driver_id
  162. where trr.del_flag = 0 and tr.del_flag = 0 and dr.del_flag = 0
  163. <if test="truckNos != null and truckNos != ''">
  164. and FIND_IN_SET(tr.truck_no, #{truckNos, jdbcType=VARCHAR})
  165. </if>
  166. <if test="entId != null and entId != ''">
  167. and trr.ent_id = #{entId, jdbcType=VARCHAR}
  168. </if>
  169. <if test="truckId != null and truckId != ''">
  170. and trr.truck_id = #{truckId, jdbcType=VARCHAR}
  171. </if>
  172. <if test="driverId != null and driverId != ''">
  173. and trr.driver_id = #{driverId, jdbcType=VARCHAR}
  174. </if>
  175. <if test="truckNo != null and truckNo != ''">
  176. and tr.truck_no = #{truckNo, jdbcType=VARCHAR}
  177. </if>
  178. <if test="businessStatus != null and businessStatus != ''">
  179. and tr.business_status = #{businessStatus, jdbcType=VARCHAR}
  180. </if>
  181. <if test="authStatus != null and authStatus != '' and authStatus != 0">
  182. and tr.auth_status = #{authStatus, jdbcType=VARCHAR}
  183. </if>
  184. <if test="status != null and status != ''">
  185. and trr.status = #{status, jdbcType=VARCHAR}
  186. </if>
  187. <if test="keywords != null and keywords != ''">
  188. and (
  189. tr.truck_no like concat('%',#{keywords},'%')
  190. or dr.name like concat('%',#{keywords},'%')
  191. or dr.phone like concat('%',#{keywords},'%')
  192. )
  193. </if>
  194. ORDER BY tr.create_time desc
  195. </select>
  196. </mapper>