ah_jjzhgd_service/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/TeamManageMapper.xml

136 lines
6.2 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" >
2024-03-20 13:36:22 +08:00
<mapper namespace="com.securitycontrol.background.mapper.TeamManageMapper">
2024-03-21 13:28:01 +08:00
<!--新增/修改班组-->
<insert id="addOrUpdateTeam">
<if test="type == 1">
INSERT INTO tb_work_team
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="teamId != null and teamId != ''">team_id,</if>
<if test="teamName != null and teamName != ''">team_name,</if>
<if test="teamLeader != null and teamLeader != ''">team_leader,</if>
<if test="bidCode != null and bidCode!=''">bid_code,</if>
<if test="teamLeaderPhone != null and teamLeaderPhone!=''">team_leader_phone,</if>
<if test="idNumber != null and idNumber!=''">id_number,</if>
<if test="status != null and status!=''">status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="teamId != null and teamId != ''">#{teamId},</if>
<if test="teamName != null and teamName != ''">#{teamName},</if>
<if test="teamLeader != null and teamLeader != ''">#{teamLeader},</if>
<if test="bidCode != null and bidCode!=''">#{bidCode},</if>
<if test="teamLeaderPhone != null and teamLeaderPhone!=''">#{teamLeaderPhone},</if>
<if test="idNumber != null and idNumber!=''">#{idNumber},</if>
<if test="status != null and status!=''">#{status},</if>
</trim>
</if>
<if test="type == 2">
UPDATE tb_work_team
<set>
<if test="teamName != null and teamName != ''">team_name = #{teamName},</if>
<if test="teamLeader != null and teamLeader != ''">team_leader = #{teamLeader},</if>
<if test="bidCode != null and bidCode != ''">bid_code = #{bidCode},</if>
<if test="teamLeaderPhone != null and teamLeaderPhone != ''">team_leader_phone = #{teamLeaderPhone},</if>
<if test="idNumber != null and idNumber != ''">id_number = #{idNumber},</if>
<if test="status != null and status != ''">status = #{status},</if>
</set>
WHERE team_id = #{teamId}
</if>
</insert>
2024-03-22 11:14:47 +08:00
<!--添加班组人员-->
<insert id="addTeamUser">
<if test="type == 1">
UPDATE t_team_people SET team_id = #{teamId} WHERE user_id = #{userId}
</if>
<if test="type == 2">
UPDATE t_team_people SET team_id = NULL WHERE user_id = #{userId}
</if>
</insert>
<!--移出班组人员-->
<update id="removeTeamUser">
UPDATE t_team_people SET team_id = NULL WHERE user_id = #{id}
</update>
2024-03-21 13:28:01 +08:00
<!--删除班组-->
<delete id="delTeam">
DELETE FROM tb_work_team WHERE team_id = #{id}
</delete>
<!--获取班组列表-->
2024-03-20 13:36:22 +08:00
<select id="getTeamLists" resultType="com.securitycontrol.entity.background.vo.TeamManageVo">
SELECT
2024-03-21 13:28:01 +08:00
twt.team_id AS teamId,
twt.team_name as teamName,
twt.team_leader as teamleader,
twt.team_leader_phone as teamleaderphone,
tp.pro_name AS proName,
twt.team_num as teamNum,
2024-04-18 09:48:42 +08:00
CASE twt.status WHEN '1' THEN '施工' WHEN '2' THEN '暂停' WHEN '3' THEN '完工' ELSE '完工' END AS status,
2024-03-21 13:28:01 +08:00
twt.bid_code AS bidCode
FROM tb_work_team twt
LEFT JOIN tb_project tp on twt.bid_code = tp.bid_code
<where>
2024-03-21 14:03:44 +08:00
<if test="teamName !=null and teamName!=''">
AND INSTR(twt.team_name,#{teamName}) > 0
</if>
<if test="teamLeader !=null and teamLeader!=''">
AND INSTR(twt.team_leader,#{teamLeader}) > 0
</if>
</where>
</select>
2024-03-21 13:28:01 +08:00
<!--班组是否存在-->
<select id="isTeamExist" resultType="java.util.Map">
<if test="teamId == null or teamId == ''">
SELECT team_id AS id,id_number AS value FROM tb_work_team
</if>
<if test="teamId != null and teamId != ''">
SELECT team_id AS id,id_number AS value FROM tb_work_team WHERE team_id != #{teamId}
</if>
</select>
<!--班组详情-->
<select id="getTeamDetailById" resultType="com.securitycontrol.entity.background.vo.TeamManageVo">
SELECT
twt.team_id AS teamId,
twt.team_name as teamname,
twt.team_leader as teamleader,
twt.team_leader_phone as teamleaderphone,
twt.status,
twt.bid_code AS bidCode,
twt.id_number AS idNumber
FROM tb_work_team twt
WHERE team_id = #{id}
</select>
<!--班组是否存在班组人员-->
<select id="isPeopleByTeam" resultType="java.lang.Integer">
2024-04-24 14:49:42 +08:00
SELECT COUNT(*) FROM t_team_people WHERE team_id = #{id} AND del_falge = '0'
2024-03-21 13:28:01 +08:00
</select>
2024-03-22 11:14:47 +08:00
<!--班组人员数量-->
<select id="getTeamUserNum" resultType="java.lang.Integer">
2024-04-24 14:49:42 +08:00
SELECT COUNT(*) FROM t_team_people WHERE team_id = #{teamId} AND del_falge = '0'
2024-03-22 11:14:47 +08:00
</select>
<!--获取班组人员列表-->
<select id="getTeamUserLists" resultType="com.securitycontrol.entity.background.vo.HumanManageVo">
SELECT
ttp.user_id AS userId,
ttp.user_name AS userName,
2024-04-24 14:49:42 +08:00
sd.dict_name AS userType,
ttp.sex,
ttp.id_number AS idNumber
2024-03-22 11:14:47 +08:00
FROM t_team_people ttp
LEFT JOIN sys_dict sd ON ttp.user_type = sd.dict_code
<where>
ttp.team_id = #{id}
<if test="userName!=null and userName !=''">
AND INSTR(ttp.user_name,#{userName}) > 0
</if>
2024-04-24 14:49:42 +08:00
AND ttp.del_falge = '0'
2024-03-22 11:14:47 +08:00
</where>
</select>
<!--获取班组组员和未加入班组人员-->
<select id="getTeamUserAndNoBandingUser" resultType="java.util.Map">
2024-04-24 14:49:42 +08:00
SELECT user_id AS id,user_name AS userName,'1' AS type FROM t_team_people WHERE team_id = #{id} AND del_falge = '0'
2024-03-22 11:14:47 +08:00
UNION ALL
2024-04-24 14:49:42 +08:00
SELECT user_id AS id,user_name AS userName,'2' AS type FROM t_team_people WHERE team_id IS NULL OR team_id = '' AND (del_falge = '0')
2024-03-22 11:14:47 +08:00
</select>
</mapper>