154 lines
5.9 KiB
XML
154 lines
5.9 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.base.mapper.TbPeopleMapper">
|
|
|
|
<select id="queryByPage" resultType="com.bonus.base.domain.TbPeople">
|
|
select
|
|
tp.id as id, tp.team_id as teamId, tp.rel_name as relName, tp.rel_phone as relPhone, tp.id_card as idCard,
|
|
tp.post_code as postCode, tp.sex as sex, td.dev_name as devName, tt.rel_id as relId
|
|
from tb_people tp
|
|
left join tb_device td on tp.dev_id = td.id and td.del_flag = '0'
|
|
left join tb_team tt on tp.team_id = tt.id and tt.del_flag = '0'
|
|
where tp.del_flag = '0'
|
|
<if test="id != null">
|
|
and tp.team_id = #{id}
|
|
</if>
|
|
<if test="relName != null and relName != ''">
|
|
and tp.rel_name like concat('%',#{relName},'%')
|
|
</if>
|
|
<if test="sex != null">
|
|
and tp.sex = #{sex}
|
|
</if>
|
|
/**
|
|
* 班组长条件筛选,一个班组长只可带领一个组,班组员条件筛选,一个组员只可在一个班组
|
|
*/
|
|
<if test="isAll != null and isAll == 0">
|
|
and tp.team_id is null
|
|
</if>
|
|
<if test="isAll != null and isAll == 1">
|
|
ORDER BY CASE WHEN tp.id = tt.rel_id THEN 0 ELSE 1 END, tp.id
|
|
</if>
|
|
<if test="isAll == null">
|
|
ORDER BY tp.create_time DESC
|
|
</if>
|
|
</select>
|
|
|
|
<select id="queryById" resultType="com.bonus.base.domain.TbPeople">
|
|
select tp.id as id,
|
|
tp.team_id as teamId,
|
|
tp.rel_name as relName,
|
|
tp.rel_phone as relPhone,
|
|
tp.id_card as idCard,
|
|
tp.post_code as postCode,
|
|
tp.sex as sex
|
|
from tb_people tp
|
|
where tp.del_flag = '0' and tp.id = #{id}
|
|
</select>
|
|
|
|
<select id="queryByName" resultType="com.bonus.base.domain.TbPeople">
|
|
select tp.id as id,
|
|
tp.team_id as teamId,
|
|
tp.rel_name as relName,
|
|
tp.rel_phone as relPhone,
|
|
tp.id_card as idCard,
|
|
tp.post_code as postCode,
|
|
tp.sex as sex
|
|
from tb_people tp
|
|
where tp.del_flag = '0'
|
|
</select>
|
|
|
|
<insert id="insert">
|
|
INSERT INTO tb_people
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="teamId != null and teamId != ''">team_id,</if>
|
|
<if test="relName != null and relName != ''">rel_name,</if>
|
|
<if test="relPhone != null and relPhone != ''">rel_phone,</if>
|
|
<if test="idCard != null and idCard != ''">id_card,</if>
|
|
<if test="postCode != null">post_code,</if>
|
|
<if test="sex != null">sex,</if>
|
|
<if test="createUser != null">create_user,</if>
|
|
create_time,
|
|
del_flag
|
|
</trim>
|
|
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
|
<if test="teamId != null and teamId != ''">#{teamId},</if>
|
|
<if test="relName != null and relName != ''">#{relName},</if>
|
|
<if test="relPhone != null and relPhone != ''">#{relPhone},</if>
|
|
<if test="idCard != null and idCard != ''">#{idCard},</if>
|
|
<if test="postCode != null">#{postCode},</if>
|
|
<if test="sex != null">#{sex},</if>
|
|
<if test="createUser != null">#{createUser},</if>
|
|
NOW(),
|
|
0
|
|
</trim>
|
|
</insert>
|
|
|
|
<!--通过主键修改数据-->
|
|
<update id="update">
|
|
update tb_people
|
|
<set>
|
|
<if test="teamId != null">
|
|
team_id = #{teamId},
|
|
</if>
|
|
<if test="relName != null and relName != ''">
|
|
rel_name = #{relName},
|
|
</if>
|
|
<if test="relPhone != null and relPhone != ''">
|
|
rel_phone = #{relPhone},
|
|
</if>
|
|
<if test="idCard != null and idCard != ''">
|
|
id_card = #{idCard},
|
|
</if>
|
|
<if test="postCode != null and postCode != ''">
|
|
post_code = #{postCode},
|
|
</if>
|
|
<if test="sex != null">
|
|
sex = #{sex},
|
|
</if>
|
|
update_time = NOW(),
|
|
<if test="updateUser != null">
|
|
update_user = #{updateUser},
|
|
</if>
|
|
</set>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<update id="updateById">
|
|
update tb_people
|
|
set team_id = NULL
|
|
WHERE team_id = #{id}
|
|
</update>
|
|
|
|
<!--通过主键删除-->
|
|
<delete id="deleteById">
|
|
update tb_people set del_flag = '1' where id = #{id}
|
|
</delete>
|
|
|
|
<select id="queryPeoplePositionByProId" resultType="com.bonus.screen.vo.PeoplePositionVo">
|
|
SELECT
|
|
tp.id_card as idCard,
|
|
tp.rel_name as relName,
|
|
tp.dev_id as devId,
|
|
tp.team_id AS teamId,
|
|
tt.team_name as teamName,
|
|
tt.pro_id as proId,
|
|
project.pro_name as proName,
|
|
device.dev_code as devCode,
|
|
MAX(CASE WHEN tda.jc_name = '经度' THEN tda.jc_value END) AS lon,
|
|
MAX(CASE WHEN tda.jc_name = '纬度' THEN tda.jc_value END) AS lat
|
|
FROM
|
|
tb_people tp
|
|
LEFT JOIN tb_team tt ON tt.id = tp.team_id AND tt.del_flag = 0
|
|
LEFT JOIN tb_project project ON project.id = tt.pro_id AND project.del_flag = 0
|
|
LEFT JOIN tb_device device ON tp.dev_id = device.id AND device.del_flag = 0
|
|
LEFT JOIN tb_dev_attribute tda ON tda.dev_id = tp.dev_id AND tda.del_flag = 0
|
|
WHERE tp.del_flag = 0 AND project.id = #{proId}
|
|
GROUP BY tp.id
|
|
</select>
|
|
|
|
<select id="getUserById" resultType="com.bonus.system.api.domain.SysUser">
|
|
select user_id as userId, user_name as userName, password as password from sys_user where user_id = #{userId}
|
|
</select>
|
|
</mapper>
|
|
|