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

128 lines
4.9 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,
2024-12-04 17:14:58 +08:00
ag.group_name AS oldAttGroupName,
ag2.group_name AS newAttGroupName,
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'
2024-12-04 16:27:28 +08:00
LEFT JOIN att_group ag ON oc.old_att_group = ag.id
AND ag.is_active = '1'
LEFT JOIN att_group ag2 ON oc.new_att_group = ag2.id
AND ag2.is_active = '1'
WHERE
oc.is_active = '1'
<if test="userId != null and userId != '' ">
and oc.user_id = #{userId}
</if>
2024-12-05 10:46:34 +08:00
<if test="userName != null and userName != '' ">
and locate(#{userName},su.user_name)
</if>
<if test="startTime != null and startTime != '' ">
and oc.create_time between #{startTime} and #{endTime}
</if>
<if test="isCheck != null and isCheck != '' ">
<if test="isCheck == '-1'">
and oc.is_check in (0,1,2)
</if>
<if test="isCheck != '-1'">
and oc.is_check = #{isCheck}
</if>
</if>
order by oc.is_check ASC
</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,
2024-12-04 17:14:58 +08:00
ag.group_name AS oldAttGroupName,
ag2.group_name AS newAttGroupName,
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'
2024-12-04 16:36:15 +08:00
LEFT JOIN att_group ag ON oc.old_att_group = ag.id
AND ag.is_active = '1'
LEFT JOIN att_group ag2 ON oc.new_att_group = ag2.id
AND ag2.is_active = '1'
WHERE
oc.is_active = '1'
and oc.id = #{id}
</select>
<select id="getAttGroupList" resultType="com.bonus.system.api.domain.MapVo">
SELECT
id,
group_name AS `name`
FROM
att_group
WHERE
is_active = '1'
</select>
<delete id="deleteAttGroup">
update org_change
set is_active = 0
where id = #{id}
</delete>
<insert id="insertOrgChange">
2024-12-02 21:28:40 +08:00
insert into org_change(user_id, old_org_id, new_org_id,is_change_att_group, change_effective_date, is_check,remark
<if test="oldAttGroup != null and oldAttGroup != ''">,old_att_group</if>
<if test="newAttGroup != null and newAttGroup != ''">,new_att_group</if>
)
2024-12-02 21:28:40 +08:00
values (#{userId},#{oldOrgId},#{newOrgId},#{isChangeAttGroup},#{changeEffectiveDate},#{isCheck},#{remark}
<if test="oldAttGroup != null and oldAttGroup != ''">,#{oldAttGroup}</if>
<if test="newAttGroup != null and newAttGroup != ''">,#{newAttGroup}</if>
)
</insert>
<update id="updateOrgChange">
update org_change set user_id = #{userId}, old_org_id = #{oldOrgId}, new_org_id = #{newOrgId},
is_change_att_group = #{isChangeAttGroup}, change_effective_date = #{changeEffectiveDate},
is_check = #{isCheck}, remark = #{remark}
<if test="oldAttGroup != null and oldAttGroup != ''">,old_att_group = #{oldAttGroup}</if>
<if test="newAttGroup != null and newAttGroup != ''">,new_att_group = #{newAttGroup}</if>
where id = #{id}
</update>
<update id="orgChangeCheck">
update org_change
<set>
<if test="checkUserId != 0L">
check_opinion = #{checkOpinion},
check_user_id = #{checkUserId},
check_time = #{checkTime},
</if>
is_check = #{isCheck}
</set>
where id = #{id}
</update>
2024-12-04 18:31:58 +08:00
<update id="updateOrgByUserId">
update sys_user_org set org_id = #{newOrgId} where user_id = #{userId} and org_id = #{oldOrgId}
</update>
<update id="updateAttGroupByUserId">
update att_group_person_relation set group_id = #{newAttGroup},org_id = #{newOrgId} where user_id = #{userId} and group_id = #{oldAttGroup}
</update>
</mapper>