123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.management.platform.mapper.LeaveSheetMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.management.platform.entity.LeaveSheet">
- <id column="id" property="id" />
- <result column="company_id" property="companyId" />
- <result column="owner_id" property="ownerId" />
- <result column="owner_name" property="ownerName" />
- <result column="start_date" property="startDate" />
- <result column="end_date" property="endDate" />
- <result column="leave_type" property="leaveType" />
- <result column="status" property="status" />
- <result column="remark" property="remark" />
- <result column="operator_id" property="operatorId" />
- <result column="time_hours" property="timeHours" />
- <result column="time_days" property="timeDays" />
- <result column="indate" property="indate" />
- <result column="time_type" property="timeType" />
- <result column="tel" property="tel" />
- <result column="auditor_id" property="auditorId" />
- <result column="auditor_name" property="auditorName" />
- <result column="auditor_type" property="auditorType" />
- <result column="procinst_id" property="procinstId" />
- <result column="gmt_finished" property="gmtFinished" />
- <result column="cur_audit_setting_id" property="curAuditSettingId" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- 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
- </sql>
- <select id="summaryData" resultMap="BaseResultMap">
- select owner_id, owner_name, sum(time_hours) as time_hours, sum(time_days) as time_days from leave_sheet
- where start_date >= #{startDate} and end_date <= #{endDate}
- <if test="keyword != null and keyword != ''">
- and owner_name like '%${keyword}%'
- </if>
- and company_id = #{companyId}
- and status = 0
- group by owner_id
- </select>
- <!-- 查询审核中的请假单信息 -->
- <select id="selectApprovalList" resultType="com.management.platform.entity.LeaveSheet">
- select * from leave_sheet
- where procinst_id is not NULL AND procinst_id is not null and status = 1 and DATEDIFF(NOW(),indate) < 30
- </select>
- <!-- 查询某段时间内的请假列表 -->
- <select id="selectLeave" resultType="com.management.platform.entity.LeaveSheet">
- select * from leave_sheet
- where company_id = #{companyId} and leave_sheet.status=0
- and leave_sheet.start_date <=#{endDate} and leave_sheet.end_date >=#{startDate}
- </select>
- <!-- 查询某段时间内全部请假的人员信息 -->
- <select id="selectLeaveAll" resultType="map">
- 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
- from leave_sheet
- left join user
- on user.id = leave_sheet.owner_id
- where user.company_id = #{companyId} and leave_sheet.status=0
- and leave_sheet.start_date <=#{endDate} and leave_sheet.end_date >=#{startDate}
- <if test="branchDepartment!=null and branchDepartment.size()>0">
- and user.department_id in
- <foreach collection="branchDepartment" open="(" close=")" item="item" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and user.department_id in
- <foreach collection="deptIds" open="(" item="item" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="getCompanyUserRestTimeHours" resultType="com.management.platform.entity.vo.UserRestTimeVO">
- select tmp1.id as userId,tmp1.name as userName,ifnull(tmp2.restTimeHour,0) restTimeHour
- from
- (
- select id,name
- from user
- <where>
- company_id = #{companyId} and is_active = 1
- <if test="userId != null and userId !='' ">
- and id = #{userId}
- </if>
- </where>
- )tmp1
- left join (
- select owner_id userId,ifnull(sum(time_hours),0) as restTimeHour
- from leave_sheet
- where
- company_id = #{companyId}
- and leave_type = 6
- and status not in (2,3)
- group by owner_id
- ) tmp2 on tmp1.id = tmp2.userId
- </select>
- </mapper>
|