KwfDriverMapper.xml 16 KB

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