LeaveSheetMapper.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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.management.platform.mapper.LeaveSheetMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.management.platform.entity.LeaveSheet">
  6. <id column="id" property="id" />
  7. <result column="company_id" property="companyId" />
  8. <result column="owner_id" property="ownerId" />
  9. <result column="owner_name" property="ownerName" />
  10. <result column="start_date" property="startDate" />
  11. <result column="end_date" property="endDate" />
  12. <result column="leave_type" property="leaveType" />
  13. <result column="status" property="status" />
  14. <result column="remark" property="remark" />
  15. <result column="operator_id" property="operatorId" />
  16. <result column="time_hours" property="timeHours" />
  17. <result column="time_days" property="timeDays" />
  18. <result column="indate" property="indate" />
  19. <result column="time_type" property="timeType" />
  20. <result column="tel" property="tel" />
  21. <result column="auditor_id" property="auditorId" />
  22. <result column="auditor_name" property="auditorName" />
  23. <result column="auditor_type" property="auditorType" />
  24. <result column="procinst_id" property="procinstId" />
  25. <result column="gmt_finished" property="gmtFinished" />
  26. <result column="cur_audit_setting_id" property="curAuditSettingId" />
  27. </resultMap>
  28. <!-- 通用查询结果列 -->
  29. <sql id="Base_Column_List">
  30. id, company_id, owner_id, owner_name, start_date, end_date, leave_type, status, remark, operator_id, time_hours, time_days, indate, time_type, tel, auditor_id, auditor_name, auditor_type, procinst_id, gmt_finished, cur_audit_setting_id
  31. </sql>
  32. <insert id="batchInsert">
  33. insert into leave_sheet(company_id, owner_id, owner_name,start_date, end_date, leave_type, status, remark
  34. , operator_id, time_hours, time_days, indate, time_type, tel, procinst_id) VALUES
  35. <foreach collection="resList" separator="," item="res">
  36. (#{res.companyId},#{res.ownerId},#{res.ownerName},#{res.startDate},#{res.endDate}
  37. ,#{res.leaveType},#{res.status},#{res.remark},#{res.operatorId},#{res.timeHours},#{res.timeDays}
  38. ,#{res.indate},#{res.timeType},#{res.tel},#{res.procinstId})
  39. </foreach>
  40. </insert>
  41. <select id="summaryData" resultMap="BaseResultMap">
  42. select owner_id, owner_name, sum(time_hours) as time_hours, sum(time_days) as time_days from leave_sheet
  43. where start_date &gt;= #{startDate} and end_date &lt;= #{endDate}
  44. <if test="keyword != null and keyword != ''">
  45. and owner_name like '%${keyword}%'
  46. </if>
  47. and company_id = #{companyId}
  48. and status = 0
  49. group by owner_id
  50. </select>
  51. <!-- 查询审核中的请假单信息 -->
  52. <select id="selectApprovalList" resultType="com.management.platform.entity.LeaveSheet">
  53. select * from leave_sheet
  54. where procinst_id is not NULL AND procinst_id is not null and status = 1 and DATEDIFF(NOW(),indate) &lt; 30
  55. </select>
  56. <!-- 查询某段时间内的请假列表 -->
  57. <select id="selectLeave" resultType="com.management.platform.entity.LeaveSheet">
  58. select * from leave_sheet
  59. where company_id = #{companyId} and leave_sheet.status=0
  60. and leave_sheet.start_date &lt;=#{endDate} and leave_sheet.end_date &gt;=#{startDate}
  61. </select>
  62. <!-- 查询某段时间内全部请假的人员信息 -->
  63. <select id="selectLeaveAll" resultType="map">
  64. select leave_sheet.start_date as startDate,leave_sheet.end_date as endDate,leave_sheet.time_hours as hours,user.id as id,user.department_id as departmentId,user.corpwx_userid as userId,user.job_number as jobNumber,user.name as name
  65. from leave_sheet
  66. left join user
  67. on user.id = leave_sheet.owner_id
  68. where user.company_id = #{companyId} and leave_sheet.status=0
  69. and leave_sheet.start_date &lt;=#{endDate} and leave_sheet.end_date &gt;=#{startDate}
  70. <if test="branchDepartment!=null and branchDepartment.size()>0">
  71. and user.department_id in
  72. <foreach collection="branchDepartment" open="(" close=")" item="item" separator=",">
  73. #{item}
  74. </foreach>
  75. </if>
  76. <if test="deptIds!=null and deptIds.size()>0">
  77. and user.department_id in
  78. <foreach collection="deptIds" open="(" item="item" separator="," close=")">
  79. #{item}
  80. </foreach>
  81. </if>
  82. </select>
  83. <select id="getCompanyUserRestTimeHours" resultType="com.management.platform.entity.vo.UserRestTimeVO">
  84. select tmp1.id as userId,tmp1.name as userName,ifnull(tmp2.restTimeHour,0) restTimeHour
  85. from
  86. (
  87. select id,name
  88. from user
  89. <where>
  90. company_id = #{companyId} and is_active = 1
  91. <if test="userId != null and userId !='' ">
  92. and id = #{userId}
  93. </if>
  94. </where>
  95. )tmp1
  96. left join (
  97. select owner_id userId,ifnull(sum(time_hours),0) as restTimeHour
  98. from leave_sheet
  99. where
  100. company_id = #{companyId}
  101. and leave_type = 6
  102. and status not in (2,3)
  103. group by owner_id
  104. ) tmp2 on tmp1.id = tmp2.userId
  105. </select>
  106. <select id="getExistIds" resultType="java.lang.String">
  107. select procinst_id
  108. from leave_sheet
  109. where procinst_id in <foreach collection="procinstIds" item="procinstId" separator="," open="(" close=")">#{procinstId}</foreach>
  110. </select>
  111. </mapper>