KwfTruckReportMapper.xml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. )
  43. </if>
  44. GROUP BY tr.`auth_status`
  45. </select>
  46. <select id="findPage" resultType="com.sckw.fleet.model.vo.KwfTruckReportVo" parameterType="java.util.Map" >
  47. SELECT
  48. trr.id, trr.ent_id entId, trr.truck_id truckId, driver_id driverId, trr.remark, tr.status,
  49. trr.create_by createBy, trr.create_time createTime, trr.update_time updateTime, trr.remark,
  50. tr.truck_no truckNo, tr.actual_weight actualWeight, tr.business_status businessStatus,
  51. tr.auth_status truckAuthStatus, dr.`name` driverName, dr.phone driverPhone, dr.idcard driverIdcard,
  52. dr.ent_id driverEntId, dr.auth_status driverAuthStatus, tr.ent_id truckEntId, fl.name truckFleetName,
  53. tr.type truckType, tr.color, tr.trailer_no trailerNo
  54. from kwf_truck_report trr
  55. left join kwf_truck tr on tr.id = trr.truck_id
  56. left join kwf_driver dr on dr.id = trr.driver_id
  57. left join kwf_fleet_truck flt on flt.truck_id = tr.id and flt.ent_id = trr.ent_id and flt.del_flag = 0
  58. left join kwf_fleet fl on fl.id = flt.fleet_id and fl.ent_id = trr.ent_id and fl.del_flag = 0
  59. where trr.del_flag = 0 and tr.del_flag = 0 and dr.del_flag = 0
  60. <if test="entId != null and entId != ''">
  61. and trr.ent_id = #{entId, jdbcType=VARCHAR}
  62. </if>
  63. <if test="truckNo != null and truckNo != ''">
  64. and tr.truck_no = #{truckNo, jdbcType=VARCHAR}
  65. </if>
  66. <if test="truckType != null and truckType != ''">
  67. and tr.type = #{truckType, jdbcType=VARCHAR}
  68. </if>
  69. <if test="fleetId != null and fleetId != ''">
  70. and fl.id = #{fleetId, jdbcType=VARCHAR}
  71. </if>
  72. <if test="fleetName != null and fleetName != ''">
  73. and fl.name like concat('%',#{fleetName},'%')
  74. </if>
  75. <if test="status != null and status != ''">
  76. and tr.status = #{status, jdbcType=VARCHAR}
  77. </if>
  78. <if test="truckAuthStatus != null and truckAuthStatus != '' and truckAuthStatus != 0">
  79. and tr.auth_status = #{truckAuthStatus, jdbcType=VARCHAR}
  80. </if>
  81. <if test="authStatus != null and authStatus != '' and authStatus != 0">
  82. and tr.auth_status = #{authStatus, jdbcType=VARCHAR}
  83. </if>
  84. <if test="startTime != null and startTime != '' " >
  85. and DATE( trr.create_time) <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
  86. </if>
  87. <if test="endTime != null and endTime != '' " >
  88. and DATE( trr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
  89. </if>
  90. <choose>
  91. <when test="ids != null and ids != '' and ids.size() > 0">
  92. and trr.id in
  93. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  94. #{id,jdbcType=BIGINT}
  95. </foreach>
  96. </when>
  97. </choose>
  98. <if test="keywords != null and keywords != ''">
  99. and (
  100. tr.truck_no like concat('%',#{keywords},'%')
  101. or dr.name like concat('%',#{keywords},'%')
  102. or dr.phone like concat('%',#{keywords},'%')
  103. )
  104. </if>
  105. ORDER BY tr.create_time desc
  106. </select>
  107. <select id="findList" resultType="java.util.Map" parameterType="java.util.Map" >
  108. SELECT
  109. trr.id, trr.ent_id entId, trr.status, dr.id driverId, dr.name driverName, dr.phone driverPhone,
  110. dr.idcard driverIdcard, tr.id truckId, tr.truck_no truckNo, tr.type truckType, tr.energy_type truckEnergyType,
  111. tr.use_type truckUseType, tr.color truckColor, tr.trailer_no truckTrailerNo, tr.auth_status authStatus,
  112. tr.business_status businessStatus, tr.actual_weight actualWeight
  113. from kwf_truck_report trr
  114. left join kwf_truck tr on tr.id = trr.truck_id
  115. left join kwf_driver dr on dr.id = trr.driver_id
  116. where trr.del_flag = 0 and tr.del_flag = 0 and dr.del_flag = 0
  117. <if test="truckNos != null and truckNos != ''">
  118. and FIND_IN_SET(tr.truck_no, #{truckNos, jdbcType=VARCHAR})
  119. </if>
  120. <if test="entId != null and entId != ''">
  121. and trr.ent_id = #{entId, jdbcType=VARCHAR}
  122. </if>
  123. <if test="truckId != null and truckId != ''">
  124. and trr.truck_id = #{truckId, jdbcType=VARCHAR}
  125. </if>
  126. <if test="driverId != null and driverId != ''">
  127. and trr.driver_id = #{driverId, jdbcType=VARCHAR}
  128. </if>
  129. <if test="truckNo != null and truckNo != ''">
  130. and tr.truck_no = #{truckNo, jdbcType=VARCHAR}
  131. </if>
  132. <if test="businessStatus != null and businessStatus != ''">
  133. and tr.business_status = #{businessStatus, jdbcType=VARCHAR}
  134. </if>
  135. <if test="authStatus != null and authStatus != '' and authStatus != 0">
  136. and tr.auth_status = #{authStatus, jdbcType=VARCHAR}
  137. </if>
  138. <if test="status != null and status != ''">
  139. and trr.status = #{status, jdbcType=VARCHAR}
  140. </if>
  141. <if test="keywords != null and keywords != ''">
  142. and (
  143. tr.truck_no like concat('%',#{keywords},'%')
  144. or dr.name like concat('%',#{keywords},'%')
  145. or dr.phone like concat('%',#{keywords},'%')
  146. )
  147. </if>
  148. ORDER BY tr.create_time desc
  149. </select>
  150. </mapper>