183 lines
8.3 KiB
XML
183 lines
8.3 KiB
XML
|
|
<?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">
|
||
|
|
select ags.*, ag.id as groupId, ag.group_name, ag.att_type from att_group ag
|
||
|
|
left join att_group_setting ags on ags.group_id = ag.id and ags.is_active = 1
|
||
|
|
left join att_group_person_relation agpr on agpr.group_id = ag.id and agpr.is_active = 1
|
||
|
|
where ag.is_active = 1
|
||
|
|
<if test="groupName != null and groupName != '' ">
|
||
|
|
and ag.group_name = #{groupName}
|
||
|
|
</if>
|
||
|
|
<if test="orgId != null and orgId != '' ">
|
||
|
|
and agpr.org_id = #{orgId}
|
||
|
|
</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">
|
||
|
|
select *
|
||
|
|
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">
|
||
|
|
select id, org_name as name, parent_id, false as disabled, '' as userId, id as orgId
|
||
|
|
from sys_organization
|
||
|
|
where is_active = 1
|
||
|
|
union
|
||
|
|
select CONCAT(su.user_id, '|', suo.org_id) as id,
|
||
|
|
user_name as name,
|
||
|
|
suo.org_id as parnet_id,
|
||
|
|
if(agpr.is_active is null, false, true) as disabled,
|
||
|
|
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 and agpr.is_active = 1
|
||
|
|
where su.is_active = 1
|
||
|
|
</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
|
||
|
|
</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
|
||
|
|
set is_active = 0
|
||
|
|
where group_id = #{groupId};
|
||
|
|
</delete>
|
||
|
|
|
||
|
|
<delete id="deleteAttGroupRelationPerson">
|
||
|
|
update att_group_person_relation
|
||
|
|
set is_active = 0
|
||
|
|
where group_id = #{groupId};
|
||
|
|
</delete>
|
||
|
|
|
||
|
|
<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="lateMinute != null and lateMinute != ''">,late_minute</if>
|
||
|
|
<if test="leaveMinute != null and leaveMinute != ''">,leave_minute</if>
|
||
|
|
<if test="absenteeismLateMinute != null and absenteeismLateMinute != ''">,absenteeism_late_minute</if>
|
||
|
|
<if test="absenteeismLeaveMinute != null and absenteeismLeaveMinute != ''">,absenteeism_leave_minute</if>
|
||
|
|
<if test="entryAbnormalMinute != null and entryAbnormalMinute != ''">,entry_abnormal_minute</if>
|
||
|
|
<if test="todayClockNum != null and todayClockNum != ''">,today_clock_num</if>
|
||
|
|
<if test="attendanceDuration != null and attendanceDuration != ''">,attendance_duration</if>
|
||
|
|
)values( #{groupId}, #{attDay}
|
||
|
|
<if test="toWorkTime != null and toWorkTime != ''">,#{toWorkTime}</if>
|
||
|
|
<if test="offWorkTime != null and offWorkTime != ''">,#{offWorkTime}</if>
|
||
|
|
<if test="lateMinute != null and lateMinute != ''">,#{lateMinute}</if>
|
||
|
|
<if test="leaveMinute != null and leaveMinute != ''">,#{leaveMinute}</if>
|
||
|
|
<if test="absenteeismLateMinute != null and absenteeismLateMinute != ''">,#{absenteeismLateMinute}</if>
|
||
|
|
<if test="absenteeismLeaveMinute != null and absenteeismLeaveMinute != ''">,#{absenteeismLeaveMinute}</if>
|
||
|
|
<if test="entryAbnormalMinute != null and entryAbnormalMinute != ''">,#{entryAbnormalMinute}</if>
|
||
|
|
<if test="todayClockNum != null and todayClockNum != ''">,#{todayClockNum}</if>
|
||
|
|
<if test="attendanceDuration != null and attendanceDuration != ''">,#{attendanceDuration}</if>
|
||
|
|
)
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<insert id="insertAttGroupPerson">
|
||
|
|
insert into att_group_person_relation(group_id, org_id, user_id)
|
||
|
|
values
|
||
|
|
<foreach item="params" collection="list" separator=",">
|
||
|
|
(#{params.groupId}, #{params.orgId}, #{params.userId})
|
||
|
|
</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="lateMinute != null and lateMinute != ''">,late_minute = #{lateMinute}</if>
|
||
|
|
<if test="leaveMinute != null and leaveMinute != ''">,leave_minute = #{leaveMinute}</if>
|
||
|
|
<if test="absenteeismLateMinute != null and absenteeismLateMinute != ''">,absenteeism_late_minute =
|
||
|
|
#{absenteeismLateMinute}
|
||
|
|
</if>
|
||
|
|
<if test="absenteeismLeaveMinute != null and absenteeismLeaveMinute != ''">,absenteeism_leave_minute =
|
||
|
|
#{absenteeismLeaveMinute}
|
||
|
|
</if>
|
||
|
|
<if test="entryAbnormalMinute != null and entryAbnormalMinute != ''">,entry_abnormal_minute =
|
||
|
|
#{entryAbnormalMinute}
|
||
|
|
</if>
|
||
|
|
<if test="todayClockNum != null and todayClockNum != ''">,today_clock_num = #{todayClockNum}</if>
|
||
|
|
<if test="attendanceDuration != null and attendanceDuration != ''">,attendance_duration =
|
||
|
|
#{attendanceDuration}
|
||
|
|
</if>
|
||
|
|
where group_id = #{groupId}
|
||
|
|
</update>
|
||
|
|
</mapper>
|