gz_att/bonus-modules/bonus-system/src/main/resources/mapper/holiday/HolidayMapper.xml

220 lines
7.5 KiB
XML
Raw Normal View History

2024-12-02 11:13:48 +08:00
<?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.bonus.system.holiday.dao.HolidayDao">
<insert id="insertHoliday" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
2024-12-02 11:13:48 +08:00
INSERT INTO leave_apply(user_id,user_name,org_id,org_name,leave_type,leave_reason,
leave_start_date,
<if test="leaveStartInterval != null">
leave_start_interval,
</if>
leave_end_date,
2025-01-07 01:47:43 +08:00
<if test="leaveEndInterval != null">
leave_end_interval,
</if>
2024-12-02 11:13:48 +08:00
leave_duration,examine_status,source,create_user_id,is_agree, location, host_user_id, remark,type)
VALUES(#{userId},#{userName},#{orgId},#{orgName},#{leaveType},#{leaveReason},
#{leaveStartDate},
<if test="leaveStartInterval != null">
#{leaveStartInterval},
</if>
#{leaveEndDate},
<if test="leaveEndInterval != null">
#{leaveEndInterval},
</if>
#{leaveDuration},#{examineStatus},#{source},#{createUserId}, #{isAgree}, #{location}, #{hostUserId}, #{remark}, #{type})
2024-12-02 11:13:48 +08:00
</insert>
<update id="updateHoliday">
UPDATE leave_apply
<set>
<if test="userId != null and userId != ''">
user_id = #{userId},
</if>
<if test="userName != null and userName != ''">
user_name = #{userName},
</if>
<if test="orgId != null and orgId != ''">
org_id = #{orgId},
</if>
<if test="orgName != null and orgName != ''">
org_name = #{orgName},
</if>
leave_reason = #{leaveReason},
leave_start_date = #{leaveStartDate},
leave_start_interval = #{leaveStartInterval},
leave_end_date = #{leaveEndDate},
leave_end_interval = #{leaveEndInterval},
leave_duration = #{leaveDuration},
examine_status = #{examineStatus},
update_user_id = #{updateUserId},
is_agree = #{isAgree},
location = #{location},
host_user_id = #{hostUserId},
remark = #{remark}
</set>
where id = #{id}
</update>
<update id="changeHolidayStatus">
update leave_apply
<set>
<if test="updateUserId != 0L">
examine_opinion = #{examineOpinion},
examine_user_id = #{examineUserId},
examine_time = #{examineTime},
</if>
<if test="examineUserId != 0L">
update_user_id = #{updateUserId},
</if>
examine_status = #{examineStatus}
</set>
where id = #{id}
</update>
<delete id="deleteHolidayById">
update leave_apply SET is_active = '0' WHERE id = #{id}
</delete>
<select id="getHolidayList" resultType="com.bonus.system.holiday.entity.HolidayBean" parameterType="com.bonus.system.holiday.entity.HolidayBean">
2024-12-02 11:13:48 +08:00
SELECT
DISTINCT
2024-12-20 15:08:28 +08:00
la.id,
la.user_id,
la.user_name,
la.org_id,
la.org_name,
la.create_time,
la.leave_type,
la.leave_reason,
la.leave_start_date,
la.leave_start_interval,
la.leave_end_date,
la.leave_end_interval,
la.leave_duration,
la.examine_status
2024-12-02 11:13:48 +08:00
FROM
2024-12-20 15:08:28 +08:00
leave_apply la
LEFT JOIN sys_user_org suo on suo.user_id=la.user_id and suo.is_active=1
2024-12-02 11:13:48 +08:00
WHERE
la.is_active = '1'
2024-12-02 11:13:48 +08:00
<if test="bean.leaveDate != null and bean.leaveDate != '' ">
2024-12-20 15:08:28 +08:00
and locate(#{bean.leaveDate},la.create_time)
2024-12-02 11:13:48 +08:00
</if>
<if test="bean.examineStatus != null and bean.examineStatus != '' ">
2024-12-20 15:08:28 +08:00
and la.examine_status = #{bean.examineStatus}
2024-12-02 11:13:48 +08:00
</if>
<if test="bean.leaveType != null and bean.leaveType != '' ">
2024-12-20 15:08:28 +08:00
and locate(#{bean.leaveType},la.leave_type)
2024-12-02 11:13:48 +08:00
</if>
<if test="bean.type != null and bean.type != '' ">
2024-12-20 15:08:28 +08:00
and locate(#{bean.type},la.type)
2024-12-02 11:13:48 +08:00
</if>
<if test="bean.orgName != null and bean.orgName != '' ">
2024-12-20 15:08:28 +08:00
and locate(#{bean.orgName},la.org_name)
2024-12-02 11:13:48 +08:00
</if>
<if test="bean.userName != null and bean.userName != '' ">
2024-12-20 15:08:28 +08:00
and locate(#{bean.userName},la.user_name)
2024-12-02 11:13:48 +08:00
</if>
<if test="bean.userId != null and bean.userId != '' ">
2024-12-20 15:08:28 +08:00
and (la.user_id = #{bean.userId} or la.create_user_id = #{bean.userId} )
2024-12-02 11:13:48 +08:00
</if>
<if test="bean.userIds != null and bean.userIds != '' ">
and la.user_id != #{bean.userIds}
</if>
<if test="bean.roleType =='2' || bean.roleType == 2 ">
2024-12-20 15:08:28 +08:00
and suo.org_id in (
<foreach collection="bean.OrgListId" item="item" separator=",">
2024-12-02 11:13:48 +08:00
#{item}
</foreach>
)
</if>
<if test='bean.orgList != null and bean.orgList.size() > 0'>
and suo.org_id in (
<foreach collection="bean.orgList" item="item" separator=",">
#{item}
</foreach>
)
</if>
2024-12-20 15:08:28 +08:00
ORDER BY la.update_time DESC
2024-12-02 11:13:48 +08:00
</select>
<select id="selectHolidayById" resultType="com.bonus.system.holiday.entity.HolidayBean">
SELECT
id,
user_id,
user_name,
org_id,
org_name,
create_time,
leave_type,
leave_reason,
leave_start_date,
leave_start_interval,
leave_end_date,
leave_end_interval,
leave_duration,
examine_status,
examine_opinion,
is_agree, location, host_user_id, remark
FROM
leave_apply
WHERE
id = #{id}
</select>
<select id="getLeaveType" resultType="java.util.Map">
</select>
<select id="getOrgList" resultType="com.bonus.system.holiday.entity.HolidayKeyBean">
SELECT
`id`,
org_name as `name`
FROM
sys_organization
WHERE
is_active = '1'
</select>
<select id="getPersonList" resultType="com.bonus.system.holiday.entity.HolidayKeyBean">
SELECT
user_id as `id`,
user_name as `name`
FROM
sys_user
WHERE
is_active = '1'
</select>
<select id="getLeaveTypeList" resultType="com.bonus.system.holiday.entity.HolidayKeyBean">
SELECT
dict_code as `id`,
dict_label as `name`
FROM
sys_dict_data
WHERE
dict_type = 'att_status' and dict_code > 47
</select>
<select id="getUserIdById" resultType="java.lang.Long">
SELECT
user_id
FROM
leave_apply
WHERE
id = #{id}
</select>
<select id="getHolidayData" resultType="com.bonus.system.holiday.entity.HolidayImportBean">
SELECT
user_name,leave_start_date,leave_end_date
FROM
leave_apply
WHERE leave_end_date > #{previousMonthDate}
</select>
2025-01-10 13:36:27 +08:00
<select id="getHolidayDataByType" resultType="java.lang.String">
SELECT date
FROM sys_holiday
WHERE date between #{startDate} and #{endDate} and type = 1
</select>
2024-12-02 11:13:48 +08:00
</mapper>