gz_att/bonus-modules/bonus-system/src/main/resources/mapper/att/AttGroupMapper.xml

208 lines
9.1 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.att.dao.AttGroupDao">
<select id="selectAttGroupList" resultType="com.bonus.system.att.entity.AttGroupBean">
2025-02-18 09:30:42 +08:00
select ags.*, ag.id as groupId, ag.group_name, ag.att_type
from att_group ag
2024-12-02 11:13:48 +08:00
left join att_group_setting ags on ags.group_id = ag.id and ags.is_active = 1
where ag.is_active = 1
<if test="groupName != null and groupName != '' ">
and ag.group_name = #{groupName}
</if>
GROUP BY ag.id
</select>
<select id="selectOrgList" resultType="com.bonus.system.att.entity.AttGroupCheckOrgBean">
select org.id as orgId,
org.org_name as orgName,
su.user_id,
su.user_name,
IF(agpr.is_active is null, 0, 1) as isBind
from sys_organization org
left join sys_user_org suo on suo.org_id = org.id and org.is_active = 1
left join sys_user su on su.user_id = suo.user_id and su.is_active = 1
left join att_group_person_relation agpr on agpr.user_id = su.user_id and agpr.is_active = 1
where org.is_active = 1
GROUP BY org.id, su.user_id
</select>
<select id="selectAttGroupById" resultType="com.bonus.system.att.entity.AttGroupBean">
select ag.id as groupId, ag.*, ags.*
from att_group ag
left join att_group_setting ags on ags.group_id = ag.id and ags.is_active = 1
where ag.is_active = 1
and ag.id = #{groupId}
</select>
<select id="selectAttGroupUserById" resultType="com.bonus.system.att.entity.AttGroupCheckOrgBean">
2025-02-18 09:30:42 +08:00
select user_id AS userId
2024-12-02 11:13:48 +08:00
from att_group_person_relation
where group_id = #{groupId}
and is_active = 1
</select>
<select id="getAttGroupPersonIsBind" resultType="java.lang.String">
SELECT IFNULL((SELECT is_active
FROM att_group_person_relation
WHERE user_id = #{id}
AND is_active = 1), 0) as idBind
FROM DUAL
</select>
<select id="getAttGroupCheckPerson" resultType="com.bonus.system.basic.domain.SysTree">
2025-02-18 09:30:42 +08:00
select CONCAT('org', '|', id) AS id, org_name as name, CONCAT('org', '|', parent_id) AS parent_id,'' as userId, id as orgId,false AS isChecked
2024-12-02 11:13:48 +08:00
from sys_organization
where is_active = 1
union
2025-02-18 09:30:42 +08:00
select CONCAT('user', '|',su.user_id) as id,
2024-12-02 11:13:48 +08:00
user_name as name,
2025-02-18 09:30:42 +08:00
CONCAT('org', '|', suo.org_id ) as parnet_id,
2024-12-02 11:13:48 +08:00
su.user_id,
2025-02-18 09:30:42 +08:00
suo.org_id,
IF(agpr.user_id IS NULL,false,true) AS isChecked
2024-12-02 11:13:48 +08:00
from sys_user su
2025-02-18 09:30:42 +08:00
left join sys_user_org suo on suo.user_id = su.user_id and suo.is_active = 1
left join att_group_person_relation agpr on agpr.user_id = su.user_id and agpr.is_active = 1
2024-12-02 11:13:48 +08:00
where su.is_active = 1
2025-02-18 09:30:42 +08:00
<if test="groupId==null">
AND agpr.group_id IS NULL
</if>
<if test="groupId!=null">
AND (agpr.group_id = #{groupId} OR agpr.group_id IS NULL)
</if>
2024-12-02 11:13:48 +08:00
</select>
<select id="getUserByOrg" resultType="com.bonus.system.att.entity.AttGroupCheckOrgBean">
SELECT
su.user_id,
suo.org_id
FROM
sys_user su
LEFT JOIN sys_user_org suo ON suo.user_id = su.user_id
AND suo.is_active = 1
LEFT JOIN att_group_person_relation agpr ON agpr.user_id = su.user_id
<if test="groupId != null and groupId != ''">
and agpr.group_id != #{groupId}
</if>
AND agpr.is_active = 1
WHERE
su.is_active = 1
<if test="idList != null and idList.size() > 0">
AND suo.org_id IN
<foreach item="id" collection="idList" separator="," open="(" close=")" index="">
#{id}
</foreach>
</if>
-- AND agpr.user_id IS NULL
2024-12-02 11:13:48 +08:00
</select>
<delete id="deleteAttGroup">
update att_group
set is_active = 0
where id = #{groupId};
update att_group_setting
set is_active = 0
where group_id = #{groupId};
update att_group_person_relation
2025-01-20 13:41:32 +08:00
set is_active = 0,expiring_time = now()
2024-12-02 11:13:48 +08:00
where group_id = #{groupId};
</delete>
<delete id="deleteAttGroupRelationPerson">
update att_group_person_relation
set is_active = 0
where group_id = #{groupId};
</delete>
2025-01-20 13:41:32 +08:00
<delete id="deleteAttGroupPersonByUserId">
2025-01-23 19:03:25 +08:00
<foreach item="params" collection="list" separator=";">
2025-01-20 13:41:32 +08:00
update att_group_person_relation
set is_active = 0,expiring_time = now()
2025-01-23 19:03:25 +08:00
where user_id = #{params.userId}
2025-01-20 13:41:32 +08:00
</foreach>
</delete>
2024-12-02 11:13:48 +08:00
<insert id="insertAttGroup" useGeneratedKeys="true" keyColumn="id" keyProperty="groupId">
insert into att_group(group_name, att_type, create_user_id)
values (#{groupName}, #{attType}, #{createUserId});
</insert>
<insert id="insertAttGroupSetting">
insert into att_group_setting(group_id, att_day
<if test="toWorkTime != null and toWorkTime != ''">,to_work_time</if>
<if test="offWorkTime != null and offWorkTime != ''">,off_work_time</if>
<if test="breakStartTime != null and breakStartTime != ''">,break_start_time</if>
<if test="breakEndTime != null and breakEndTime != ''">,break_end_time</if>
<if test="attRange != null and attRange != ''">,att_range</if>
<if test="lateMinute != null ">,late_minute</if>
<if test="leaveMinute != null ">,leave_minute</if>
<if test="absenteeismLateMinute != null ">,absenteeism_late_minute</if>
<if test="absenteeismLeaveMinute != null ">,absenteeism_leave_minute</if>
<if test="entryAbnormalMinute != null ">,entry_abnormal_minute</if>
<if test="todayClockNum != null ">,today_clock_num</if>
<if test="attendanceDuration != null ">,attendance_duration</if>
<if test="isHaveHoliday!= null ">,is_have_holiday</if>
2024-12-02 11:13:48 +08:00
)values( #{groupId}, #{attDay}
<if test="toWorkTime != null and toWorkTime != ''">,#{toWorkTime}</if>
<if test="offWorkTime != null and offWorkTime != ''">,#{offWorkTime}</if>
<if test="breakStartTime != null and breakStartTime != ''">,#{breakStartTime}</if>
<if test="breakEndTime != null and breakEndTime != ''">,#{breakEndTime}</if>
<if test="attRange != null and attRange != ''">,#{attRange}</if>
<if test="lateMinute != null ">,#{lateMinute}</if>
<if test="leaveMinute != null ">,#{leaveMinute}</if>
<if test="absenteeismLateMinute != null ">,#{absenteeismLateMinute}</if>
<if test="absenteeismLeaveMinute != null ">,#{absenteeismLeaveMinute}</if>
<if test="entryAbnormalMinute != null ">,#{entryAbnormalMinute}</if>
<if test="todayClockNum != null ">,#{todayClockNum}</if>
<if test="attendanceDuration != null ">,#{attendanceDuration}</if>
<if test="isHaveHoliday != null ">,#{isHaveHoliday}</if>
2024-12-02 11:13:48 +08:00
)
</insert>
<insert id="insertAttGroupPerson">
2025-02-18 09:30:42 +08:00
insert into att_group_person_relation(group_id, user_id, effective_time)
2024-12-02 11:13:48 +08:00
values
<foreach item="params" collection="list" separator=",">
2025-02-18 09:30:42 +08:00
(#{params.groupId}, #{params.userId}, now())
2024-12-02 11:13:48 +08:00
</foreach>
</insert>
<update id="updateAttGroup">
update att_group
set group_name = #{groupName},
att_type = #{attType},
update_user_id = #{updateUserId}
where id = #{groupId}
</update>
<update id="updateAttGroupSetting">
update att_group_setting set att_day = #{attDay}
<if test="toWorkTime != null and toWorkTime != ''">,to_work_time = #{toWorkTime}</if>
<if test="offWorkTime != null and offWorkTime != ''">,off_work_time = #{offWorkTime}</if>
<if test="breakStartTime != null and breakStartTime != ''">,break_start_time = #{breakStartTime}</if>
<if test="breakEndTime != null and breakEndTime != ''">,break_end_time = #{breakEndTime}</if>
<if test="attRange != null and attRange != ''">,att_range = #{attRange}</if>
<if test="lateMinute != null ">,late_minute = #{lateMinute}</if>
<if test="leaveMinute != null ">,leave_minute = #{leaveMinute}</if>
<if test="absenteeismLateMinute != null ">,absenteeism_late_minute =
2024-12-02 11:13:48 +08:00
#{absenteeismLateMinute}
</if>
<if test="absenteeismLeaveMinute != null ">,absenteeism_leave_minute =
2024-12-02 11:13:48 +08:00
#{absenteeismLeaveMinute}
</if>
<if test="entryAbnormalMinute != null ">,entry_abnormal_minute =
2024-12-02 11:13:48 +08:00
#{entryAbnormalMinute}
</if>
<if test="todayClockNum != null ">,today_clock_num = #{todayClockNum}</if>
<if test="attendanceDuration != null ">,attendance_duration =
2024-12-02 11:13:48 +08:00
#{attendanceDuration}
</if>
<if test="isHaveHoliday != null ">,is_have_holiday =
#{isHaveHoliday}
</if>
2024-12-02 11:13:48 +08:00
where group_id = #{groupId}
</update>
</mapper>