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

212 lines
9.5 KiB
XML
Raw Normal View History

<?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.OrgChangeDao">
<select id="selectOrgChangeList" resultType="com.bonus.system.att.entity.OrgChangeBean">
SELECT
su.user_name,
so.org_name AS oldOrgName,
so2.org_name AS newOrgName,
oc.*
FROM
org_change oc
LEFT JOIN sys_user su ON oc.user_id = su.user_id
AND su.is_active = '1'
LEFT JOIN sys_organization so ON oc.old_org_id = so.id
AND so.is_active = '1'
LEFT JOIN sys_organization so2 ON oc.new_org_id = so2.id
AND so2.is_active = '1'
WHERE
oc.is_active = '1'
<if test="startTime != null and startTime != '' ">
and oc.create_time between #{startTime} and #{endTime}
</if>
<if test="isCheck != null and isCheck != '' ">
and oc.is_check = #{isCheck}
</if>
</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="selectOrgChangeById" resultType="com.bonus.system.att.entity.OrgChangeBean">
SELECT
su.user_name,
so.org_name AS oldOrgName,
so2.org_name AS newOrgName,
oc.*
FROM
org_change oc
LEFT JOIN sys_user su ON oc.user_id = su.user_id
AND su.is_active = '1'
LEFT JOIN sys_organization so ON oc.old_org_id = so.id
AND so.is_active = '1'
LEFT JOIN sys_organization so2 ON oc.new_org_id = so2.id
AND so2.is_active = '1'
WHERE
oc.is_active = '1'
and oc.id = #{id}
</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="insertOrgChange" useGeneratedKeys="true" keyColumn="id" keyProperty="groupId">
insert into org_change(user_id, old_org_id, new_org_id,is_change_att_group, change_effective_date, is_check
remark)
values (#{userId},#{oldOrgId},#{newOrgId},#{isChangeAttGroup},#{changeTime},#{createUserId},#{remark})
<if test="oldAttGroup != null and oldAttGroup != ''">,old_att_group</if>
<if test="newAttGroup != null and newAttGroup != ''">,new_att_group</if>
) values (#{userId},#{oldOrgId},#{newOrgId},#{isChangeAttGroup},#{changeEffectiveDate},#{isCheck}
<if test="oldAttGroup != null and oldAttGroup != ''">,#{oldAttGroup}</if>
<if test="newAttGroup != null and newAttGroup != ''">,#{newAttGroup}</if>
)
</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="updateOrgChange">
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>