KwfTruckReportMapper.xml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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.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 = #{type, 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.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 = #{type, 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 != ''">
  79. and tr.auth_status = #{truckAuthStatus, jdbcType=VARCHAR}
  80. </if>
  81. <if test="startTime != null and startTime != '' " >
  82. and DATE( trr.create_time) <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
  83. </if>
  84. <if test="endTime != null and endTime != '' " >
  85. and DATE( trr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
  86. </if>
  87. <choose>
  88. <when test="ids != null">
  89. and trr.id in
  90. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  91. #{id,jdbcType=BIGINT}
  92. </foreach>
  93. </when>
  94. </choose>
  95. <if test="keywords != null and keywords != ''">
  96. and (
  97. tr.truck_no like concat('%',#{keywords},'%')
  98. or dr.name like concat('%',#{keywords},'%')
  99. or dr.phone like concat('%',#{keywords},'%')
  100. )
  101. </if>
  102. ORDER BY tr.create_time desc
  103. </select>
  104. <select id="findList" resultType="java.util.Map" parameterType="java.util.Map" >
  105. SELECT
  106. trr.id, trr.ent_id entId, trr.status, dr.id driverId, dr.name driverName, dr.phone driverPhone,
  107. dr.idcard driverIdcard, tr.id truckId, tr.truck_no truckNo, tr.type truckType, tr.energy_type truckEnergyType,
  108. tr.use_type truckUseType, tr.color truckColor, tr.trailer_no truckTrailerNo, tr.auth_status authStatus,
  109. tr.business_status businessStatus, tr.actual_weight actualWeight
  110. from kwf_truck_report trr
  111. left join kwf_truck tr on tr.id = trr.truck_id
  112. left join kwf_driver dr on dr.id = trr.driver_id
  113. where trr.del_flag = 0 and tr.del_flag = 0 and dr.del_flag = 0
  114. <if test="truckNos != null and truckNos != ''">
  115. and FIND_IN_SET(tr.truck_no, #{truckNos, jdbcType=VARCHAR})
  116. </if>
  117. <if test="entId != null and entId != ''">
  118. and trr.ent_id = #{entId, jdbcType=VARCHAR}
  119. </if>
  120. <if test="truckId != null and truckId != ''">
  121. and trr.truck_id = #{truckId, jdbcType=VARCHAR}
  122. </if>
  123. <if test="driverId != null and driverId != ''">
  124. and trr.driver_id = #{driverId, jdbcType=VARCHAR}
  125. </if>
  126. <if test="truckNo != null and truckNo != ''">
  127. and tr.truck_no = #{truckNo, jdbcType=VARCHAR}
  128. </if>
  129. <if test="businessStatus != null and businessStatus != ''">
  130. and tr.business_status = #{businessStatus, jdbcType=VARCHAR}
  131. </if>
  132. <if test="authStatus != null and status != ''">
  133. and tr.auth_status = #{authStatus, jdbcType=VARCHAR}
  134. </if>
  135. <if test="status != null and status != ''">
  136. and trr.status = #{status, jdbcType=VARCHAR}
  137. </if>
  138. <if test="keywords != null and keywords != ''">
  139. and (
  140. tr.truck_no like concat('%',#{keywords},'%')
  141. or dr.name like concat('%',#{keywords},'%')
  142. or dr.phone like concat('%',#{keywords},'%')
  143. )
  144. </if>
  145. ORDER BY tr.create_time desc
  146. </select>
  147. </mapper>