gs_sub_evaluate/src/main/resources/mappers/evaluate/TeamGroupMapper.xml

102 lines
4.0 KiB
XML
Raw Normal View History

2025-06-30 15:59:55 +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.gs.sub.evaluate.evaluate.dao.TeamGroupDao">
<insert id="addTeamType">
insert into team_group_type(team_group_id,team_type) values(#{id},#{teamType})
</insert>
<insert id="addTeamGroupPerson">
insert into team_person(team_id,name,id_card,phone,sex,work_type,face_url,is_team_leader)
values
(#{id},#{name},#{idCard},#{phone},#{sex},#{workTypeId},#{faceUrl},#{isTeamLeader})
</insert>
<update id="updaTeteamType">
update team_group_type set team_type = #{teamType} where team_group_id = #{id}
</update>
<update id="updaTeteamGroup">
update pm_org_info set name = #{teamGroupName} where id = #{id}
</update>
<update id="updateTeamPerson">
update team_person set name = #{name},id_card = #{idCard},phone = #{phone},sex = #{sex},work_type = #{workType},face_url = #{faceUrl}
where id = #{id}
</update>
<delete id="delTeamGroup">
delete from pm_org_info where id = #{id}
</delete>
<delete id="delTeamGroupType">
delete from team_group_type where team_group_id = #{id}
</delete>
<delete id="delTeamPerson">
delete from team_person where id = #{id}
</delete>
<select id="getTeamGroupList" resultType="com.bonus.gs.sub.evaluate.evaluate.beans.TeamGroupBean">
SELECT
poi2.NAME subContractor,
poi3.NAME project,
poi.NAME teamGroupName,
poi.id as id,
poi.status as status,
CONCAT( poi.user_name, '/', poi.user_phone ) teamLeader,
td.id as teamTypeId,
td.val teamType,
count( tp.team_id ) teamPersonNum
FROM
pm_org_info poi
LEFT JOIN pm_org_info poi2 ON poi.parent_id = poi2.id
LEFT JOIN pm_org_info poi3 ON poi2.parent_id = poi3.id
left join team_group_type tgt on poi.id = tgt.team_group_id
left join t_dict td on tgt.team_type = td.id
left join team_person tp on poi.id = tp.team_id
WHERE
poi.`level` = 5
AND poi.`status` IN (1,2)
<if test="keyWord != null and keyWord != ''">
AND (
poi2.NAME like concat('%',#{keyWord},'%') or
poi3.NAME like concat('%',#{keyWord},'%') or
poi.NAME like concat('%',#{keyWord},'%')
)
</if>
<if test="status != null ">
and poi.status = #{status}
</if>
group by poi.id
</select>
<select id="selectTeteamType" resultType="java.lang.Integer">
select count(1) from team_group_type where team_group_id = #{id}
</select>
<select id="getTeamGroupPerson" resultType="com.bonus.gs.sub.evaluate.evaluate.beans.TeamGroupBean">
SELECT tp.id,
tp.name,
tp.id_card as idCard,
tp.phone,
case when tp.sex = 1 then '男' else '女' end as sex,
tp.work_type workTypeId,
td.val as workType,
tp.face_url as faceUrl,
case when tp.is_team_leader = 0 then '是' else '否' end as isTeamLeader
FROM
team_person tp
left join t_dict td on tp.work_type = td.id
WHERE
tp.team_id = #{id}
<if test="name != null and name != ''">
and tp.name like concat('%',#{name},'%')
</if>
<if test="sex != null and sex != ''">
and tp.sex = #{sex}
</if>
</select>
<select id="getUserNumByIdCard" resultType="java.lang.Integer">
select count(1) from team_person where id_card = #{idCard}
</select>
<select id="getUserNumByPhone" resultType="java.lang.Integer">
select count(1) from team_person where phone = #{phone}
</select>
<select id="isTeamLeader" resultType="java.lang.Integer">
select is_team_leader from team_person where id = #{id}
</select>
</mapper>