KwfDriverMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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.KwfDriverMapper">
  4. <select id="statisticsAll" resultType="com.sckw.fleet.model.vo.KwfTableTopCount" parameterType="java.util.Map" >
  5. SELECT
  6. dr.`auth_status` value, count(0) total
  7. from kwf_driver dr
  8. left join kwf_driver_card drc on drc.driver_id = dr.id and drc.del_flag = 0
  9. left join kwf_driver_license drl on drl.driver_id = dr.id and drl.del_flag = 0
  10. left join kwf_driver_qualification drq on drq.driver_id = dr.id and drq.del_flag = 0
  11. where dr.del_flag = 0
  12. <if test="entId != null and entId != ''">
  13. and dr.ent_id = #{entId, jdbcType=VARCHAR}
  14. </if>
  15. <if test="name != null and name != ''">
  16. and dr.name = #{name, jdbcType=VARCHAR}
  17. </if>
  18. <if test="idcard != null and idcard != ''">
  19. and dr.idcard = #{idcard, jdbcType=VARCHAR}
  20. </if>
  21. <if test="phone != null and phone != ''">
  22. and dr.phone = #{phone, jdbcType=VARCHAR}
  23. </if>
  24. <if test="licenseType != null and licenseType != ''">
  25. and drl.type = #{licenseType, jdbcType=VARCHAR}
  26. </if>
  27. <if test="startTime != null and startTime != '' " >
  28. and DATE( dr.create_time) <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
  29. </if>
  30. <if test="endTime != null and endTime != '' " >
  31. and DATE( dr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
  32. </if>
  33. <if test="keywords != null and keywords != ''">
  34. and (
  35. dr.name like concat('%',#{keywords},'%')
  36. or dr.phone like concat('%',#{keywords},'%')
  37. )
  38. </if>
  39. GROUP BY dr.`auth_status`
  40. </select>
  41. <select id="statistics" resultType="com.sckw.fleet.model.vo.KwfTableTopCount" parameterType="java.util.Map" >
  42. SELECT
  43. dr.`auth_status` value, count(0) total
  44. from kwf_driver dr
  45. left join kwf_driver_ent dre on dre.driver_id = dr.id
  46. left join kwf_driver_card drc on drc.driver_id = dr.id and drc.del_flag = 0
  47. left join kwf_driver_license drl on drl.driver_id = dr.id and drl.del_flag = 0
  48. left join kwf_driver_qualification drq on drq.driver_id = dr.id and drq.del_flag = 0
  49. left join kwf_fleet_driver flr on flr.driver_id = dr.id and flr.del_flag = 0
  50. left join kwf_fleet fl on fl.id = flr.fleet_id and fl.del_flag = 0
  51. where dr.del_flag = 0 and dre.del_flag = 0
  52. <if test="entId != null and entId != ''">
  53. and dre.ent_id = #{entId, jdbcType=VARCHAR}
  54. </if>
  55. <if test="name != null and name != ''">
  56. and dr.name = #{name, jdbcType=VARCHAR}
  57. </if>
  58. <if test="idcard != null and idcard != ''">
  59. and dr.idcard = #{idcard, jdbcType=VARCHAR}
  60. </if>
  61. <if test="phone != null and phone != ''">
  62. and dr.phone = #{phone, jdbcType=VARCHAR}
  63. </if>
  64. <if test="licenseType != null and licenseType != ''">
  65. and drl.type = #{licenseType, 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="startTime != null and startTime != '' " >
  74. and DATE( dr.create_time) <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
  75. </if>
  76. <if test="endTime != null and endTime != '' " >
  77. and DATE( dr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
  78. </if>
  79. <if test="noReport != null and noReport != ''">
  80. and dr.id not in (
  81. select driver_id from kwf_truck_report where del_flag = 0 and ent_id = #{entId, jdbcType=VARCHAR}
  82. )
  83. </if>
  84. <if test="keywords != null and keywords != ''">
  85. and (
  86. dr.name like concat('%',#{keywords},'%')
  87. or dr.phone like concat('%',#{keywords},'%')
  88. )
  89. </if>
  90. GROUP BY dr.`auth_status`
  91. </select>
  92. <select id="findPageAll" resultType="com.sckw.fleet.model.vo.KwfDriverVo" parameterType="java.util.Map" >
  93. SELECT
  94. dr.id, dr.name, dr.phone, dr.idcard, dr.status, dr.auth_status authStatus, drc.expire_time idcardExpireTime,
  95. drc.address, drl.driver_no driverNo, drl.type licenseType, drl.expire_time licenseExpireTime,
  96. drl.grant_unit licenseGrantUnit,drq.quali_no qualiNo, dr.ent_id entId, dr.create_by createBy,
  97. dr.create_time createTime,dr.update_time updateTime, dr.remark
  98. from kwf_driver dr
  99. left join kwf_driver_card drc on drc.driver_id = dr.id and drc.del_flag = 0
  100. left join kwf_driver_license drl on drl.driver_id = dr.id and drl.del_flag = 0
  101. left join kwf_driver_qualification drq on drq.driver_id = dr.id and drq.del_flag = 0
  102. where dr.del_flag = 0
  103. <if test="entId != null and entId != ''">
  104. and dr.ent_id = #{entId, jdbcType=VARCHAR}
  105. </if>
  106. <if test="name != null and name != ''">
  107. and dr.name = #{name, jdbcType=VARCHAR}
  108. </if>
  109. <if test="idcard != null and idcard != ''">
  110. and dr.idcard = #{idcard, jdbcType=VARCHAR}
  111. </if>
  112. <if test="phone != null and phone != ''">
  113. and dr.phone = #{phone, jdbcType=VARCHAR}
  114. </if>
  115. <if test="licenseType != null and licenseType != ''">
  116. and drl.type = #{licenseType, jdbcType=VARCHAR}
  117. </if>
  118. <if test="status != null and status != ''">
  119. and dr.status = #{status, jdbcType=VARCHAR}
  120. </if>
  121. <if test="authStatus != null and authStatus != '' and authStatus != 0">
  122. and dr.auth_status = #{authStatus, jdbcType=VARCHAR}
  123. </if>
  124. <if test="startTime != null and startTime != '' " >
  125. and DATE( dr.create_time) <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
  126. </if>
  127. <if test="endTime != null and endTime != '' " >
  128. and DATE( dr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
  129. </if>
  130. <choose>
  131. <when test="ids != null and ids != '' and ids.size() > 0">
  132. and dr.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. dr.name like concat('%',#{keywords},'%')
  141. or dr.phone like concat('%',#{keywords},'%')
  142. )
  143. </if>
  144. ORDER BY dr.create_time desc
  145. </select>
  146. <select id="findPage" resultType="com.sckw.fleet.model.vo.KwfDriverVo" parameterType="java.util.Map" >
  147. SELECT
  148. dr.id, dr.name, dr.phone, dr.idcard, dr.status, dr.auth_status authStatus, drc.expire_time idcardExpireTime,
  149. drc.address, drl.driver_no driverNo, drl.type licenseType, drl.expire_time licenseExpireTime,
  150. drl.grant_unit licenseGrantUnit,drq.quali_no qualiNo, dr.ent_id entId, dr.create_by createBy,
  151. dr.create_time createTime,dr.update_time updateTime, dr.remark, fl.id fleetId, fl.name fleetName
  152. from kwf_driver dr
  153. left join kwf_driver_ent dre on dre.driver_id = dr.id
  154. left join kwf_driver_card drc on drc.driver_id = dr.id and drc.del_flag = 0
  155. left join kwf_driver_license drl on drl.driver_id = dr.id and drl.del_flag = 0
  156. left join kwf_driver_qualification drq on drq.driver_id = dr.id and drq.del_flag = 0
  157. left join kwf_fleet_driver flr on flr.driver_id = dr.id and flr.del_flag = 0
  158. left join kwf_fleet fl on fl.id = flr.fleet_id and fl.del_flag = 0
  159. where dr.del_flag = 0 and dre.del_flag = 0
  160. <if test="entId != null and entId != ''">
  161. and dre.ent_id = #{entId, jdbcType=VARCHAR}
  162. </if>
  163. <if test="name != null and name != ''">
  164. and dr.name = #{name, jdbcType=VARCHAR}
  165. </if>
  166. <if test="idcard != null and idcard != ''">
  167. and dr.idcard = #{idcard, jdbcType=VARCHAR}
  168. </if>
  169. <if test="phone != null and phone != ''">
  170. and dr.phone = #{phone, jdbcType=VARCHAR}
  171. </if>
  172. <if test="licenseType != null and licenseType != ''">
  173. and drl.type = #{licenseType, jdbcType=VARCHAR}
  174. </if>
  175. <if test="fleetId != null and fleetId != ''">
  176. and fl.id = #{fleetId, jdbcType=VARCHAR}
  177. </if>
  178. <if test="fleetName != null and fleetName != ''">
  179. and fl.name like concat('%',#{fleetName},'%')
  180. </if>
  181. <if test="status != null and status != ''">
  182. and dr.status = #{status, jdbcType=VARCHAR}
  183. </if>
  184. <if test="authStatus != null and authStatus != '' and authStatus != 0">
  185. and dr.auth_status = #{authStatus, jdbcType=VARCHAR}
  186. </if>
  187. <if test="startTime != null and startTime != '' " >
  188. and DATE( dr.create_time) <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
  189. </if>
  190. <if test="endTime != null and endTime != '' " >
  191. and DATE( dr.create_time ) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
  192. </if>
  193. <if test="noReport != null and noReport != ''">
  194. and dr.id not in (
  195. select driver_id from kwf_truck_report where del_flag = 0 and ent_id = #{entId, jdbcType=VARCHAR}
  196. )
  197. </if>
  198. <choose>
  199. <when test="ids != null and ids != '' and ids.size() > 0">
  200. and dr.id in
  201. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  202. #{id,jdbcType=BIGINT}
  203. </foreach>
  204. </when>
  205. </choose>
  206. <if test="keywords != null and keywords != ''">
  207. and (
  208. dr.name like concat('%',#{keywords},'%')
  209. or dr.phone like concat('%',#{keywords},'%')
  210. )
  211. </if>
  212. ORDER BY dr.create_time desc
  213. </select>
  214. <select id="findList" resultType="java.util.Map" parameterType="java.util.Map" >
  215. SELECT
  216. dr.id, name, phone, salt, password, idcard, total_complete totalComplete,
  217. total_take totalTake, total_weight totalWeight, dre.ent_id entId
  218. from kwf_driver dr
  219. left join kwf_driver_ent dre on dre.driver_id = dr.id
  220. where dr.del_flag = 0 and dre.del_flag = 0
  221. <if test="entId != null and entId != ''">
  222. and dre.ent_id = #{entId, jdbcType=VARCHAR}
  223. </if>
  224. <if test="name != null and name != ''">
  225. and dr.name like concat('%',#{name},'%')
  226. </if>
  227. <if test="wholeName != null and wholeName != ''">
  228. and dr.name = #{wholeName, jdbcType=VARCHAR}
  229. </if>
  230. <if test="idcard != null and idcard != ''">
  231. and dr.idcard = #{idcard, jdbcType=VARCHAR}
  232. </if>
  233. <if test="phone != null and phone != ''">
  234. and dr.phone = #{phone, jdbcType=VARCHAR}
  235. </if>
  236. <if test="status != null and status != ''">
  237. and dr.status = #{status, jdbcType=VARCHAR}
  238. </if>
  239. <if test="authStatus != null and authStatus != '' and authStatus != 0">
  240. and dr.auth_status = #{authStatus, jdbcType=VARCHAR}
  241. </if>
  242. <if test="noReport != null and noReport != ''">
  243. and dr.id not in (
  244. select driver_id from kwf_truck_report where del_flag = 0 and ent_id = #{entId, jdbcType=VARCHAR}
  245. )
  246. </if>
  247. <choose>
  248. <when test="ids != null and ids != '' and ids.size() > 0">
  249. and dr.id in
  250. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  251. #{id,jdbcType=BIGINT}
  252. </foreach>
  253. </when>
  254. </choose>
  255. <if test="keywords != null and keywords != ''">
  256. and (
  257. dr.name like concat('%',#{keyWords},'%')
  258. or dr.idcard like concat('%',#{keywords},'%')
  259. or dr.phone like concat('%',#{keywords},'%')
  260. )
  261. </if>
  262. ORDER BY dr.create_time desc
  263. </select>
  264. <select id="findDriver" resultType="com.sckw.fleet.model.KwfDriver" parameterType="java.util.Map" >
  265. SELECT
  266. id, ent_id entId, name, phone, salt, password, idcard, total_complete totalComplete,
  267. total_take totalTake, total_weight totalWeight, business_status businessStatus, remark, status
  268. from kwf_driver dr
  269. where dr.del_flag = 0
  270. <if test="entId != null and entId != ''">
  271. and ent_id = #{entId, jdbcType=VARCHAR}
  272. </if>
  273. <if test="name != null and name != ''">
  274. and name = #{name, jdbcType=VARCHAR}
  275. </if>
  276. <if test="idcard != null and idcard != ''">
  277. and idcard = #{idcard, jdbcType=VARCHAR}
  278. </if>
  279. <if test="phone != null and phone != ''">
  280. and phone = #{phone, jdbcType=VARCHAR}
  281. </if>
  282. <if test="status != null and status != ''">
  283. and status = #{status, jdbcType=VARCHAR}
  284. </if>
  285. <if test="authStatus != null and authStatus != '' and authStatus != 0">
  286. and dr.auth_status = #{authStatus, jdbcType=VARCHAR}
  287. </if>
  288. ORDER BY create_time desc
  289. </select>
  290. <select id="findEntDriver" resultType="com.sckw.fleet.model.KwfDriver" parameterType="com.sckw.fleet.model.KwfDriver" >
  291. SELECT
  292. dr.id, name, phone, salt, password, idcard, total_complete totalComplete,
  293. total_take totalTake, total_weight totalWeight, dre.ent_id entId
  294. from kwf_driver dr
  295. left join kwf_driver_ent dre on dre.driver_id = dr.id
  296. where dr.del_flag = 0 and dre.del_flag = 0
  297. and dre.ent_id = #{entId, jdbcType=VARCHAR}
  298. and dr.id = #{id, jdbcType=VARCHAR}
  299. </select>
  300. </mapper>