StudentLeaveMapper.xml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.xjrsoft.module.student.mapper.StudentLeaveMapper">
  6. <select id="getLeaveCount" resultType="java.lang.Long">
  7. SELECT COUNT(*) as count FROM student_leave t1
  8. INNER JOIN xjr_user t2 ON t1.student_user_id = t2.id
  9. INNER JOIN base_student_school_roll t3 ON t3.user_id = t2.id
  10. WHERE t1.status = 1 AND t2.delete_mark = 0
  11. AND (
  12. (start_date BETWEEN DATE_FORMAT(#{startTime}, '%Y-%m-%d') and DATE_FORMAT(#{endTime}, '%Y-%m-%d'))
  13. OR (end_date BETWEEN DATE_FORMAT(#{startTime}, '%Y-%m-%d') and DATE_FORMAT(#{endTime}, '%Y-%m-%d'))
  14. OR (start_date > DATE_FORMAT(#{startTime}, '%Y-%m-%d') and DATE_FORMAT(#{endTime}, '%Y-%m-%d') > end_date)
  15. OR (DATE_FORMAT(#{startTime}, '%Y-%m-%d') > start_date and end_date > DATE_FORMAT(#{endTime}, '%Y-%m-%d'))
  16. )
  17. <if test="dto.gradeId != null">
  18. and t3.grade_id = #{dto.gradeId}
  19. </if>
  20. <if test="dto.classId != null">
  21. and t3.class_id = #{dto.classId}
  22. </if>
  23. </select>
  24. <select id="getClassLeaveCount" resultType="com.xjrsoft.module.outint.vo.IdCountVo">
  25. SELECT t1.class_id as id, COUNT(*) as count FROM student_leave t1
  26. INNER JOIN xjr_user t2 ON t1.student_user_id = t2.id
  27. WHERE t1.status = 1 AND t2.delete_mark = 0
  28. AND (
  29. (start_date BETWEEN DATE_FORMAT(#{startTime}, '%Y-%m-%d') and DATE_FORMAT(#{endTime}, '%Y-%m-%d'))
  30. OR (end_date BETWEEN DATE_FORMAT(#{startTime}, '%Y-%m-%d') and DATE_FORMAT(#{endTime}, '%Y-%m-%d'))
  31. OR (start_date > DATE_FORMAT(#{startTime}, '%Y-%m-%d') and DATE_FORMAT(#{endTime}, '%Y-%m-%d') > end_date)
  32. OR (DATE_FORMAT(#{startTime}, '%Y-%m-%d') > start_date and end_date > DATE_FORMAT(#{endTime}, '%Y-%m-%d'))
  33. ) group by t1.class_id
  34. </select>
  35. <select id="getLeaveList" resultType="com.xjrsoft.module.student.entity.StudentLeave">
  36. SELECT t1.* FROM student_leave t1
  37. INNER JOIN xjr_user t2 ON t1.student_user_id = t2.id
  38. WHERE t1.status = 1 AND t2.delete_mark = 0
  39. AND (
  40. (start_date BETWEEN DATE_FORMAT(#{startTime}, '%Y-%m-%d') and DATE_FORMAT(#{endTime}, '%Y-%m-%d'))
  41. OR (end_date BETWEEN DATE_FORMAT(#{startTime}, '%Y-%m-%d') and DATE_FORMAT(#{endTime}, '%Y-%m-%d'))
  42. OR (start_date > DATE_FORMAT(#{startTime}, '%Y-%m-%d') and DATE_FORMAT(#{endTime}, '%Y-%m-%d') > end_date)
  43. OR (DATE_FORMAT(#{startTime}, '%Y-%m-%d') > start_date and end_date > DATE_FORMAT(#{endTime}, '%Y-%m-%d'))
  44. )
  45. </select>
  46. </mapper>