lj-zhgd-ht/bonus-modules/bonus-bracelet/src/main/resources/mapper/bracelet/PersonMgeMapper.xml

121 lines
4.7 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.bracelet.mapper.PersonMgeMapper">
<!--新增人员-->
<insert id="addPerson" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tb_people
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">name,</if>
<if test="sex != null">sex,</if>
<if test="idCard != null and idCard != ''">id_card,</if>
<if test="phone != null and phone!=''">phone,</if>
<if test="aqmCode != null and aqmCode!=''">aqm_code,</if>
<if test="mjCode != null and mjCode!=''">mj_code,</if>
create_time,
create_user,
update_time,
update_user,
del_flag,
id
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if>
<if test="sex != null">#{sex},</if>
<if test="idCard != null and idCard != ''">#{idCard},</if>
<if test="phone != null and phone!=''">#{phone},</if>
<if test="aqmCode != null and aqmCode!=''">#{aqmCode},</if>
<if test="mjCode != null and mjCode!=''">#{mjCode},</if>
#{createTime},
#{createUser},
#{updateTime},
#{updateUser},
0,
null
</trim>
</insert>
<!--修改人员-->
<update id="editPerson">
UPDATE tb_people SET name = #{name},sex = #{sex},id_card = #{idCard},phone = #{phone},aqm_code = #{aqmCode},mj_code = #{mjCode},update_time = #{updateTime},update_user = #{updateUser} WHERE id = #{id}
</update>
<!--删除人员-->
<update id="delPerson">
UPDATE tb_people SET del_flag = 1 WHERE id = #{id}
</update>
<!--人员身份证号是否存在-->
<select id="personIsExist" resultType="java.util.Map">
<if test="id == null">
SELECT id,id_card AS value,phone FROM tb_people WHERE del_flag = 0
</if>
<if test="id != null">
SELECT id,id_card AS value,phone FROM tb_people WHERE id != #{id} AND del_flag = 0
</if>
</select>
<!--人员详情-->
<select id="getPersonInfo" resultType="com.bonus.common.entity.bracelet.vo.PersonVo">
SELECT tp.id,
tp.name,
tp.sex,
tp.id_card AS idCard,
tp.phone,
tp.aqm_code AS aqmCode,
tp.mj_code AS mjCode,
sfs.file_path AS filePath,
sfs.id AS fileId
FROM tb_people tp
LEFT JOIN sys_file_source sfs ON tp.id = sfs.source_id AND sfs.source_type = #{sourceType} AND sfs.del_flag = 0
WHERE tp.id = #{id} AND tp.del_flag = 0
</select>
<!--查询人员列表-->
<select id="getPersonLists" resultType="com.bonus.common.entity.bracelet.vo.PersonVo">
SELECT tp.id,
tp.name,
tp.sex,
tp.id_card AS idCard,
tp.phone,
tp.aqm_code AS aqmCode,
tp.mj_code AS mjCode,
sfs.file_path AS filePath,
sfs.id AS fileId
FROM tb_people tp
LEFT JOIN sys_file_source sfs ON tp.id = sfs.source_id AND sfs.source_type = #{sourceType} AND sfs.del_flag = 0
WHERE tp.del_flag = 0
<if test="name != null and name!=''">
AND INSTR(name,#{name}) > 0
</if>
<if test="sex != null">
AND tp.sex = #{sex}
</if>
<if test="roleCode == 'administrators'">
</if>
<if test="roleCode == 'depart'">
</if>
<if test="roleCode == 'team'">
</if>
ORDER BY tp.create_time
</select>
<!--验证安全帽编号是否重复、马甲编号是否重复-->
<select id="codeIsExist" resultType="java.lang.Integer">
<if test="type == 1">
<if test="id == null">
SELECT COUNT(*) FROM tb_people WHERE aqm_code = #{params.aqmCode} AND del_flag = 0
</if>
<if test="id != null">
SELECT COUNT(*) FROM tb_people WHERE id != #{params.id} AND aqm_code = #{params.aqmCode} AND del_flag = 0
</if>
</if>
<if test="type == 2">
<if test="id == null">
SELECT COUNT(*) FROM tb_people WHERE mj_code = #{params.mjCode} AND del_flag = 0
</if>
<if test="id != null">
SELECT COUNT(*) FROM tb_people WHERE mj_code = #{params.mjCode} AND id != #{params.id} AND del_flag = 0
</if>
</if>
</select>
</mapper>