<?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.cloud.user.dao.BbEmployeeDao" >
|
|
<sql id="table"> bb_person_base </sql>
|
<sql id="temp_person_table"> bb_person_temporary </sql> <!--wp 添加-->
|
|
<resultMap id="beanMap" type="Map">
|
<id column="id" property="id" /> <!--id-->
|
<result column="orgId" property="orgId"/> <!--组织架构Id-->
|
<result column="officeId" property="officeId"/> <!--部门Id-->
|
<result column="no" property="no"/> <!--工卡、学生校徽等卡片编号-->
|
<result column="cardId" property="cardId"/> <!--身份证号-->
|
<result column="userId" property="userId"/> <!--用户id-->
|
<result column="userName" property="userName"/> <!--用户名冗余-->
|
<result column="name" property="name"/> <!--姓名-->
|
<result column="gender" property="gender"/> <!--性别-->
|
<result column="mnemonicCode" property="mnemonicCode"/> <!--助记码-->
|
<result column="nation" property="nation"/> <!--民族-->
|
<result column="phone" property="phone"/> <!--电话-->
|
<result column="type" property="type"/> <!--人员类型(学生、职工、校外)-->
|
<result column="registerAddress" property="registerAddress"/> <!--注册地址-->
|
<result column="distributionIds" property="distributionIds"/> <!--分布节点IDs-->
|
<result column="distributionNames" property="distributionNames"/> <!--分布节点Names-->
|
<result column="photos" property="photos"/> <!--人员照片(格式-->
|
<result column="faceIds" property="faceIds"/> <!--人脸Id(格式-->
|
<result column="createBy" property="createBy"/> <!--创建者-->
|
<result column="createTime" property="createTime"/> <!--创建时间-->
|
<result column="updateBy" property="updateBy"/> <!--更新者-->
|
<result column="updateTime" property="updateTime"/> <!--更新时间-->
|
<result column="remarks" property="remarks"/> <!--备注信息-->
|
<result column="delFlag" property="delFlag"/> <!--逻辑删除标记(0-->
|
<result column="rev_json1" property="revJson1"/> <!--预留json格式字段1-->
|
<result column="officeName" property="officeName"/> <!--部门Name-->
|
</resultMap>
|
|
<!--学生Map集合-->
|
<resultMap id="stuMap" type="com.cloud.model.sys.BbEmployee">
|
<id column="id" property="id" /> <!--id-->
|
<result column="orgId" property="orgId"/> <!--组织架构Id-->
|
<result column="officeId" property="officeId"/> <!--部门Id-->
|
<result column="no" property="no"/> <!--工卡、学生校徽等卡片编号-->
|
<result column="name" property="name"/> <!--姓名-->
|
<result column="gender" property="gender"/> <!--性别-->
|
<result column="photos" property="photos"/> <!--人员照片(格式-->
|
<result column="remarks" property="remarks"/>
|
</resultMap>
|
|
<insert id="add" parameterType="com.cloud.model.sys.BbEmployee" useGeneratedKeys="true" keyProperty="id">
|
insert into <include refid="table" />
|
(
|
id , <!--id-->
|
orgId , <!--组织架构Id-->
|
officeId , <!--部门Id-->
|
no , <!--工卡、学生校徽等卡片编号-->
|
cardId , <!--身份证号-->
|
userId , <!--用户id-->
|
userName , <!--用户名冗余-->
|
name , <!--姓名-->
|
mnemonicCode , <!--助记码-->
|
gender , <!--性别-->
|
nation , <!--民族-->
|
phone , <!--电话-->
|
type , <!--人员类型(学生、职工、校外)-->
|
compactType , <!--教师合同类型-->
|
registerAddress , <!--注册地址-->
|
distributionIds , <!--分布节点IDs-->
|
distributionNames , <!--分布节点Names-->
|
photos , <!--人员照片(格式-->
|
faceIds , <!--人脸Id(格式-->
|
createBy , <!--创建者-->
|
createTime , <!--创建时间-->
|
updateBy , <!--更新者-->
|
updateTime , <!--更新时间-->
|
remarks , <!--备注信息-->
|
delFlag , <!--逻辑删除标记(0-->
|
rev_json1 <!--预留json格式字段1-->
|
)
|
values
|
(
|
#{id} , <!--id-->
|
#{orgId} , <!--组织架构Id-->
|
#{officeId} , <!--部门Id-->
|
#{no,jdbcType=VARCHAR} ,<!--工卡、学生校徽等卡片编号-->
|
#{cardId} , <!--身份证号-->
|
#{userId} , <!--用户id-->
|
#{userName} , <!--用户名冗余-->
|
#{name} , <!--姓名-->
|
#{mnemonicCode} , <!--助记码-->
|
#{gender} , <!--性别-->
|
#{nation} , <!--民族-->
|
#{phone} , <!--电话-->
|
#{type} , <!--人员类型(学生、职工、校外)-->
|
#{compactType,jdbcType=VARCHAR} ,<!--教师合同类型-->
|
#{registerAddress} , <!--注册地址-->
|
#{distributionIds} , <!--分布节点IDs-->
|
#{distributionNames}, <!--分布节点Names-->
|
#{photos} , <!--人员照片(格式-->
|
#{faceIds} , <!--人脸Id(格式-->
|
#{createBy} , <!--创建者-->
|
#{createTime} , <!--创建时间-->
|
#{updateBy} , <!--更新者-->
|
#{updateTime} , <!--更新时间-->
|
#{remarks} , <!--备注信息-->
|
#{delFlag} , <!--逻辑删除标记(0-->
|
#{revJson1} <!--预留json格式字段1-->
|
)
|
</insert>
|
|
<insert id="addVisitor" parameterType="com.cloud.model.sys.BbEmployee" keyProperty="id" useGeneratedKeys="true">
|
insert into <include refid="table" />
|
(
|
id , <!--id-->
|
orgId , <!--组织架构Id-->
|
officeId , <!--部门Id-->
|
cardId , <!--身份证号-->
|
name , <!--姓名-->
|
mnemonicCode , <!--助记码-->
|
gender , <!--性别-->
|
nation , <!--民族-->
|
phone , <!--电话-->
|
type , <!--人员类型(学生、职工、校外)-->
|
registerAddress , <!--注册地址-->
|
distributionIds , <!--分布节点IDs-->
|
distributionNames , <!--分布节点Names-->
|
photos , <!--人员照片(格式-->
|
faceIds , <!--人脸Id(格式-->
|
createBy , <!--创建者-->
|
createTime , <!--创建时间-->
|
updateBy , <!--更新者-->
|
updateTime , <!--更新时间-->
|
remarks , <!--备注信息-->
|
delFlag , <!--逻辑删除标记(0-->
|
rev_json1 <!--预留json格式字段1-->
|
)
|
values
|
(
|
#{id} , <!--id-->
|
#{orgId} , <!--组织架构Id-->
|
#{officeId} , <!--部门Id-->
|
#{cardId} , <!--身份证号-->
|
#{name} , <!--姓名-->
|
#{mnemonicCode} , <!--助记码-->
|
#{gender} , <!--性别-->
|
#{nation} , <!--民族-->
|
#{phone} , <!--电话-->
|
#{type} , <!--人员类型(学生、职工、校外)-->
|
#{registerAddress} , <!--注册地址-->
|
#{distributionIds} , <!--分布节点IDs-->
|
#{distributionNames}, <!--分布节点Names-->
|
#{photos} , <!--人员照片(格式-->
|
#{faceIds} , <!--人脸Id(格式-->
|
#{createBy} , <!--创建者-->
|
#{createTime} , <!--创建时间-->
|
#{updateBy} , <!--更新者-->
|
#{updateTime} , <!--更新时间-->
|
#{remarks} , <!--备注信息-->
|
#{delFlag} , <!--逻辑删除标记(0-->
|
#{revJson1} <!--预留json格式字段1-->
|
)
|
</insert>
|
|
|
|
<update id="update" parameterType="com.cloud.model.sys.BbEmployee">
|
update
|
<include refid="table" />
|
set
|
id = #{id} , <!--id-->
|
orgId = #{orgId} , <!--组织架构Id-->
|
officeId = #{officeId} , <!--部门Id-->
|
no = #{no} ,<!--工卡、学生校徽等卡片编号-->
|
cardId = #{cardId} , <!--身份证号-->
|
userId = #{userId} , <!--用户id-->
|
userName = #{userName} , <!--用户名-->
|
name = #{name} , <!--姓名-->
|
gender = #{gender} , <!--性别-->
|
nation = #{nation} , <!--民族-->
|
phone = #{phone} , <!--电话-->
|
type = #{type} , <!--人员类型(学生、职工、校外)-->
|
registerAddress = #{registerAddress} , <!--注册地址-->
|
distributionIds = #{distributionIds} , <!--分布节点ID-->
|
distributionNames = #{distributionNames}, <!--分布节点Name-->
|
photos = #{photos} , <!--人员照片(格式-->
|
faceIds = #{faceIds} , <!--人脸Id(格式-->
|
createBy = #{createBy} , <!--创建者-->
|
createTime = #{createTime} , <!--创建时间-->
|
updateBy = #{updateBy} , <!--更新者-->
|
updateTime = now() , <!--更新时间-->
|
remarks = #{remarks} , <!--备注信息-->
|
delFlag = #{delFlag} , <!--逻辑删除标记(0-->
|
rev_json1 = #{revJson1} <!--预留json格式字段1-->
|
|
<where>
|
<if test="orgId != null and orgId != ''">
|
and orgId = #{orgId}
|
</if>
|
<if test="id != null and id != ''">
|
and id = #{id}
|
</if>
|
</where>
|
</update>
|
|
<update id="deleteById" parameterType="java.util.Map">
|
update
|
<include refid="table" />
|
set
|
delFlag = '1',
|
updateTime = NOW()
|
<where>
|
<if test="orgId != null and orgId != ''">
|
and orgId = #{orgId}
|
</if>
|
<if test="id != null and id != ''">
|
and id = #{id}
|
</if>
|
</where>
|
</update>
|
|
<update id="deleteByIdFromTemp" parameterType="java.util.Map">
|
update
|
bb_person_temporary
|
set
|
delFlag = '1',
|
updateTime = NOW()
|
<where>
|
id = #{id}
|
</where>
|
</update>
|
|
|
<update id="deleteByIds" parameterType="java.util.Map">
|
update
|
<include refid="table" />
|
set
|
delFlag = '1'
|
<where>
|
<if test="orgId != null and orgId != ''">
|
and orgId = #{orgId}
|
</if>
|
<if test="ids != null and ids != ''">
|
and id in (${ids})
|
</if>
|
</where>
|
</update>
|
|
<update id="updateByPhone1" parameterType="com.cloud.model.sys.BbEmployee">
|
update
|
<include refid="table" />
|
set
|
orgId = #{orgId} , <!--组织架构Id-->
|
officeId = #{officeId} , <!--部门Id-->
|
no = #{no} ,<!--工卡、学生校徽等卡片编号-->
|
cardId = #{cardId} , <!--身份证号-->
|
userId = #{userId} , <!--用户id-->
|
userName = #{userName} , <!--用户Name-->
|
name = #{name} , <!--姓名-->
|
gender = #{gender} , <!--性别-->
|
nation = #{nation} , <!--民族-->
|
type = #{type} , <!--人员类型(学生、职工、校外)-->
|
compactType = #{compactType} ,<!--教师合同类型-->
|
registerAddress = #{registerAddress} , <!--注册地址-->
|
distributionIds = #{distributionIds} , <!--分布节点ID-->
|
distributionNames = #{distributionNames}, <!--分布节点Name-->
|
photos = #{photos} , <!--人员照片(格式-->
|
faceIds = #{faceIds} , <!--人脸Id(格式-->
|
createBy = #{createBy} , <!--创建者-->
|
createTime = #{createTime} , <!--创建时间-->
|
updateBy = #{updateBy} , <!--更新者-->
|
updateTime = #{updateTime} , <!--更新时间-->
|
remarks = #{remarks} , <!--备注信息-->
|
delFlag = #{delFlag} , <!--逻辑删除标记(0-->
|
rev_json1 = #{revJson1} <!--预留json格式字段1-->
|
|
<where>
|
<if test="orgId != null and orgId != ''">
|
and orgId = #{orgId}
|
</if>
|
<if test="phone != null and phone != ''">
|
and phone = #{phone}
|
</if>
|
</where>
|
</update>
|
|
<update id="updateByPhone" parameterType="com.cloud.model.sys.BbEmployee">
|
update bb_employee
|
<set>
|
<if test="orgId != null">
|
orgId = #{orgId,jdbcType=INTEGER},
|
</if>
|
<if test="no != null">
|
no = #{no,jdbcType=VARCHAR},
|
</if>
|
<if test="officeId != null">
|
officeId = #{officeId,jdbcType=INTEGER},
|
</if>
|
<if test="cardId != null">
|
cardId = #{cardId,jdbcType=VARCHAR},
|
</if>
|
<if test="userId != null">
|
userId = #{userId,jdbcType=INTEGER},
|
</if>
|
<if test="userName != null">
|
userName = #{userName,jdbcType=VARCHAR},
|
</if>
|
<if test="name != null">
|
name = #{name,jdbcType=VARCHAR},
|
</if>
|
<if test="mnemonicCode != null">
|
mnemonicCode = #{mnemonicCode,jdbcType=VARCHAR},
|
</if>
|
<if test="gender != null">
|
gender = #{gender,jdbcType=VARCHAR},
|
</if>
|
<if test="nation != null">
|
nation = #{nation,jdbcType=VARCHAR},
|
</if>
|
<if test="type != null">
|
type = #{type,jdbcType=VARCHAR},
|
</if>
|
<if test="compactType != null">
|
compactType = #{compactType,jdbcType=VARCHAR},
|
</if>
|
<if test="registerAddress != null">
|
registerAddress = #{registerAddress,jdbcType=VARCHAR},
|
</if>
|
<if test="distributionIds != null">
|
distributionIds = #{distributionIds,jdbcType=VARCHAR},
|
</if>
|
<if test="distributionNames != null">
|
distributionNames = #{distributionNames,jdbcType=VARCHAR},
|
</if>
|
|
photos = #{photos,jdbcType=VARCHAR},
|
|
|
faceIds = #{faceIds,jdbcType=VARCHAR},
|
|
<if test="createBy != null">
|
createBy = #{createBy,jdbcType=VARCHAR},
|
</if>
|
<if test="createTime != null">
|
createTime = #{createTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="updateBy != null">
|
updateBy = #{updateBy,jdbcType=VARCHAR},
|
</if>
|
<if test="updateTime != null">
|
updateTime = #{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="remarks != null">
|
remarks = #{remarks,jdbcType=VARCHAR},
|
</if>
|
<if test="delFlag != null">
|
delFlag = #{delFlag,jdbcType=VARCHAR},
|
</if>
|
<if test="revJson1 != null">
|
rev_json1 = #{revJson1,jdbcType=CHAR},
|
</if>
|
</set>
|
<where>
|
<if test="orgId != null and orgId != ''">
|
and orgId = #{orgId}
|
</if>
|
<if test="phone != null and phone != ''">
|
and phone = #{phone}
|
</if>
|
</where>
|
</update>
|
|
|
<!--人员修改判空-->
|
<update id="updateBbEmpId" parameterType="com.cloud.model.sys.BbEmployee">
|
update bb_person_base
|
<set>
|
<if test="no != null">
|
no = #{no,jdbcType=VARCHAR},
|
</if>
|
<if test="officeId != null">
|
officeId = #{officeId,jdbcType=INTEGER},
|
</if>
|
<if test="cardId != null">
|
cardId = #{cardId,jdbcType=VARCHAR},
|
</if>
|
<if test="userId != null">
|
userId = #{userId,jdbcType=INTEGER},
|
</if>
|
<if test="userName != null">
|
userName = #{userName,jdbcType=VARCHAR},
|
</if>
|
<if test="name != null">
|
name = #{name,jdbcType=VARCHAR},
|
</if>
|
<if test="phone != null">
|
phone = #{phone,jdbcType=VARCHAR},
|
</if>
|
<if test="mnemonicCode != null">
|
mnemonicCode = #{mnemonicCode,jdbcType=VARCHAR},
|
</if>
|
<if test="gender != null">
|
gender = #{gender,jdbcType=VARCHAR},
|
</if>
|
<if test="nation != null">
|
nation = #{nation,jdbcType=VARCHAR},
|
</if>
|
<if test="type != null">
|
type = #{type,jdbcType=VARCHAR},
|
</if>
|
|
<if test="registerAddress != null">
|
registerAddress = #{registerAddress,jdbcType=VARCHAR},
|
</if>
|
<if test="distributionIds != null">
|
distributionIds = #{distributionIds,jdbcType=VARCHAR},
|
</if>
|
<if test="distributionNames != null">
|
distributionNames = #{distributionNames,jdbcType=VARCHAR},
|
</if>
|
<if test="photos != null">
|
photos = #{photos,jdbcType=VARCHAR},
|
</if>
|
<if test="faceIds != null">
|
faceIds = #{faceIds,jdbcType=VARCHAR},
|
</if>
|
<if test="createBy != null">
|
createBy = #{createBy,jdbcType=VARCHAR},
|
</if>
|
<if test="createTime != null">
|
createTime = #{createTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="updateBy != null">
|
updateBy = #{updateBy,jdbcType=VARCHAR},
|
</if>
|
<if test="updateTime != null">
|
updateTime = #{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="remarks != null">
|
remarks = #{remarks,jdbcType=VARCHAR},
|
</if>
|
<if test="delFlag != null">
|
delFlag = #{delFlag,jdbcType=VARCHAR},
|
</if>
|
<if test="revJson1 != null">
|
rev_json1 = #{revJson1,jdbcType=CHAR},
|
</if>
|
</set>
|
<where>
|
id = #{id}
|
</where>
|
</update>
|
|
<sql id="base_column_list">
|
id , <!--id-->
|
orgId , <!--组织架构Id-->
|
officeId , <!--部门Id-->
|
no , <!--工卡、学生校徽等卡片编号-->
|
cardId , <!--身份证号-->
|
userId , <!--用户ID-->
|
userName , <!--用户名-->
|
name , <!--姓名-->
|
gender , <!--性别-->
|
nation , <!--民族-->
|
phone , <!--电话-->
|
type , <!--人员类型(学生、职工、校外)-->
|
registerAddress , <!--注册地址-->
|
distributionIds , <!--分布节点ids-->
|
distributionNames , <!--分布节点Names-->
|
photos , <!--人员照片(格式-->
|
faceIds , <!--人脸Id(格式-->
|
createBy , <!--创建者-->
|
createTime , <!--创建时间-->
|
updateBy , <!--更新者-->
|
updateTime , <!--更新时间-->
|
remarks , <!--备注信息-->
|
delFlag , <!--逻辑删除标记(0-->
|
rev_json1 <!--预留json格式字段1-->
|
</sql>
|
|
<select id="findById" resultType="com.cloud.model.sys.BbEmployee">
|
select p.*,f.feature
|
from
|
<include refid="table" /> p inner join bb_face f
|
on p.faceIds = f.resourceId
|
<where>
|
p.delFlag = '0'
|
<if test="orgId != null and orgId != ''">
|
and p.orgId = #{orgId}
|
</if>
|
<if test="id != null and id != ''">
|
and p.id = #{id}
|
</if>
|
</where>
|
</select>
|
|
<select id="findByIdFromTemp" resultType="com.cloud.model.sys.BbEmployee">
|
select p.*,f.feature
|
from
|
bb_person_temporary p inner join bb_face f
|
on p.faceIds = f.resourceId
|
<where>
|
and p.id = #{id} and p.delFlag = '0'
|
</where>
|
</select>
|
<!--除临时库以外的编辑回显方法-->
|
<select id="anyThingToUpdate" resultType="Map">
|
select p.*,o.name as orgName,o.parentJson
|
from
|
<include refid="table" /> p left join sys_organization o on p.officeId = o.id
|
<where>
|
p.delFlag="0"
|
and p.id = #{id}
|
</where>
|
</select>
|
|
<select id="selectPersonDetailById" resultType="java.util.Map">
|
select b.id id,b.name name,b.photos photos,b.gender gender,b.cardId cardId,b.phone phone,b.`no` no,b.type type,o.name orgName,b.delFlag delFlag
|
from
|
<include refid="table" /> b
|
left join sys_organization o
|
on b.officeId = o.id where
|
<if test="personId != null and personId != ''">
|
b.id = #{personId}
|
</if>
|
<if test=" delFlag == null or !delFlag">
|
and b.delFlag != '1'
|
</if>
|
ORDER BY b.updateTime DESC
|
LIMIT 1
|
</select>
|
|
<!--在临时库中查人,返回map-->
|
<select id="tempToUpdate" resultType="Map">
|
select p.*
|
from
|
bb_person_temporary p
|
<where>
|
p.delFlag="0"
|
and p.id = #{id}
|
</where>
|
</select>
|
|
<select id="isRepeatIdCard" resultType="Integer">
|
select count(*)
|
from
|
<include refid="table" />
|
<where>
|
cardId = #{cardId}
|
<if test=" id!=null and id!='' ">
|
and id!=#{id}
|
</if>
|
and delFlag = 0
|
|
</where>
|
</select>
|
|
<select id="findByPersonIds" resultType="com.cloud.user.model.PadPersonInfo">
|
select p.id personId,p.name name,p.cardId idcard,p.photos personPic,f.feature byteFeature,
|
p.phone phone,p.photos photos,p.orgId orgId,p.officeId officeId,p.no no,p.gender gender,p.nation nation,
|
p.registerAddress registerAddress,p.distributionIds distributionIds
|
from
|
(SELECT *
|
from <include refid="table" /> union /* where delFlag = 0*/
|
select *
|
from <include refid="temp_person_table"/>
|
) p
|
left join bb_face f on p.faceIds = f.resourceId
|
where
|
<foreach collection="personIds" index="index" item="perId" separator="or" close=")" open="(" >
|
p.id = #{perId,jdbcType=VARCHAR}
|
</foreach>
|
<if test="personLike != null and personLike != ''" >
|
and ( p.name like CONCAT("%",#{personLike,jdbcType=VARCHAR},"%") or
|
p.cardId like CONCAT("%",#{personLike,jdbcType=VARCHAR},"%") )
|
</if>
|
ORDER BY p.delFlag limit 1
|
</select>
|
|
<select id="findAllMergePerson" resultType="com.cloud.user.model.MergePersonView">
|
select p.id personId,p.name name,p.cardId idcard,p.photos personPic,mf.mergeFrom
|
FROM merge_from mf
|
inner JOIN <include refid="table" /> p on mf.personId = p.id and p.delFlag = '0'
|
WHERE mf.delFlag = '0'
|
</select>
|
|
<select id="queryUpdatingPersonCount" resultType="Integer">
|
select count(id)
|
FROM merge_from
|
WHERE delFlag = '0'
|
</select>
|
|
<update id="deleteMergePerson" parameterType="String" >
|
UPDATE merge_from
|
SET delFlag = '1'
|
WHERE personId = #{personId,jdbcType=VARCHAR}
|
</update>
|
|
<update id="updateBbPersonBaseForCluInfo" >
|
update <include refid="table" />
|
set distributionIds =
|
CASE WHEN distributionIds is NULL or distributionIds = '' THEN
|
CONCAT(""
|
<foreach collection="cluInfos" item="cluInfo1" open="," separator="," close=")">
|
#{cluInfo1,jdbcType=VARCHAR}
|
</foreach>
|
ELSE
|
CONCAT(distributionIds
|
<foreach collection="cluInfos" item="cluInfo2" open="," separator="," close=")">
|
IF(distributionIds LIKE CONCAT('%',#{cluInfo2,jdbcType=VARCHAR},'%'),'',#{cluInfo2,jdbcType=VARCHAR})
|
</foreach>
|
END
|
WHERE id = #{personId,jdbcType=VARCHAR}
|
</update>
|
|
<sql id="where">
|
<where>
|
1=1
|
<if test=" phone!=null and phone!='' ">
|
and phone=#{phone}
|
</if>
|
<if test=" orgId!=null ">
|
and orgId=#{orgId}
|
</if>
|
<if test="type != null and type != ''">
|
and type = #{type}
|
</if>
|
<if test="name != null and name != ''">
|
and name = #{name}
|
</if>
|
and delFlag = 0
|
<if test="start != null and start != '' and length != null and length != ''">
|
LIMIT #{start}, #{length}
|
</if>
|
</where>
|
</sql>
|
|
<select id="count1" resultType="int">
|
select count(*) from <include refid="table" /> t
|
<where>
|
1=1
|
<if test="orgIds != null">
|
and officeId in <foreach collection="orgIds" item="officeId" open="(" separator="," close=")">
|
#{officeId}
|
</foreach>
|
</if>
|
<if test=" phone!=null and phone!='' ">
|
and phone=#{phone}
|
</if>
|
<if test="type != null and type != ''">
|
and type = #{type}
|
</if>
|
<if test="name != null and name != ''">
|
and name like '%${name}%'
|
</if>
|
<if test="orgId != null and orgId != null">
|
and orgId = #{orgId}
|
</if>
|
and delFlag = 0
|
</where>
|
</select>
|
|
<select id="findData1" resultType="com.cloud.model.sys.BbEmployee" parameterType="map">
|
select * from <include refid="table" /> t
|
<where>
|
1=1
|
<if test="orgIds != null">
|
and officeId in <foreach collection="orgIds" item="officeId" open="(" separator="," close=")">
|
#{officeId}
|
</foreach>
|
</if>
|
<if test=" phone!=null and phone!='' ">
|
and phone=#{phone}
|
</if>
|
<if test="type != null and type != ''">
|
and type = #{type}
|
</if>
|
<if test="name != null and name != ''">
|
and name like '%${name}%'
|
</if>
|
and delFlag = 0
|
<if test="orgId != null and orgId != null">
|
and orgId = #{orgId}
|
</if>
|
<if test="start != null and length != null">
|
LIMIT #{start}, #{length}
|
</if>
|
</where>
|
</select>
|
|
<select id="count" resultType="int">
|
select count(*) from <include refid="table" /> t
|
<where> 1=1 and officeId in (
|
SELECT id FROM sys_organization WHERE parentIds LIKE CONCAT("%,",#{id},",%")
|
<if test="orgIds != null" >
|
<foreach collection="orgIds" index="index" item="orgId" close=")" open="and(" separator="or" >
|
parentIds LIKE CONCAT("%,",#{orgId},",%")
|
</foreach>
|
</if>
|
)
|
<if test=" phone!=null and phone!='' ">
|
and t.phone=#{phone}
|
</if>
|
<if test="type != null and type != ''">
|
and t.type = #{type}
|
</if>
|
<if test="groupInformation != null and groupInformation != ''">
|
and (t.name like concat('%', #{groupInformation}, '%') or cardId like concat('%', #{groupInformation}, '%') or no like concat('%', #{groupInformation}, '%'))
|
</if>
|
<if test="distributionIds != null ">
|
and
|
<foreach collection="distributionIds" index="index" item="distributionId" separator="or" open="(" close=")">
|
distributionIds like concat('%', #{distributionId}, '%')
|
</foreach>
|
</if>
|
<if test="name != null and name != ''">
|
and t.name like '%${name}%'
|
</if>
|
<if test="orgId != null and orgId != null">
|
and t.orgId = #{orgId}
|
</if>
|
/*wp 添加 是否查询已上除*/
|
<if test="delFlag == null or !delFlag ">
|
and t.delFlag = 0
|
</if>
|
</where>
|
</select>
|
|
<select id="countTemp" resultType="int">
|
select count(*) from bb_person_temporary t
|
<where> 1=1
|
<if test=" phone!=null and phone!='' ">
|
and phone=#{phone}
|
</if>
|
<if test="type != null and type != ''">
|
and type = #{type}
|
</if>
|
<if test="groupInformation != null and groupInformation != ''">
|
and (t.name like concat('%', #{groupInformation}, '%') or cardId like concat('%', #{groupInformation}, '%') or no like concat('%', #{groupInformation}, '%'))
|
</if>
|
<if test="distributionIds != null ">
|
and
|
<foreach collection="distributionIds" index="index" item="distributionId" separator="or" open="(" close=")">
|
distributionIds like concat('%', #{distributionId}, '%')
|
</foreach>
|
</if>
|
<if test="name != null and name != ''">
|
and name like '%${name}%'
|
</if>
|
<if test="orgId != null and orgId != null">
|
and orgId = #{orgId}
|
</if>
|
and t.delFlag = 0
|
</where>
|
</select>
|
|
<select id="findData" resultType="com.cloud.model.sys.BbEmployee" parameterType="map">
|
select t.*,concat(IFNULL(parnetOrg.name,"")," ",o.name) officeName,d.lable typeName from <include refid="table" /> t
|
left JOIN sys_organization o on t.officeId = o.id
|
left JOIN sys_organization parnetOrg on o.parentId = parnetOrg.id
|
left join sys_dict d on t.type = d.value and d.orgId = t.orgId and d.type = 'PEO_TYPE' and d.delFlag= 0
|
<where> 1=1 and t.officeId in (
|
SELECT id FROM sys_organization WHERE parentIds LIKE CONCAT("%,",#{id},",%")
|
<if test="orgIds != null" >
|
<foreach collection="orgIds" index="index" item="orgId" close=")" open="and(" separator="or" >
|
parentIds LIKE CONCAT("%,",#{orgId},",%")
|
</foreach>
|
</if>
|
)
|
<!--<if test=" phone!=null and phone!='' ">
|
and t.phone=#{phone} wp 问过 panlei 此处可不用
|
</if>-->
|
<if test="type != null and type != ''">
|
and t.type = #{type}
|
</if>
|
<if test="groupInformation != null and groupInformation != ''">
|
and (t.name like concat('%', #{groupInformation}, '%') or cardId like concat('%', #{groupInformation}, '%')
|
or no like concat('%', #{groupInformation}, '%') )
|
</if>
|
<if test="distributionIds != null ">
|
and
|
<foreach collection="distributionIds" index="index" item="distributionId" separator="or" open="(" close=")">
|
t.distributionIds like concat('%', #{distributionId}, '%')
|
</foreach>
|
</if>
|
/*wp 添加 是否查询已上除*/
|
<if test="delFlag == null or !delFlag ">
|
and t.delFlag = 0
|
</if>
|
<if test="orgId != null and orgId != ''">
|
and t.orgId = #{orgId}
|
</if>
|
ORDER BY IFNULL(t.updateTime,t.createTime) DESC
|
<if test="start != null and length != null">
|
LIMIT #{start}, #{length}
|
</if>
|
|
</where>
|
</select>
|
|
|
<select id="findDataFromBase" resultType="com.cloud.model.sys.BbEmployee" parameterType="map">
|
select t.*,concat(IFNULL(parentOrg.name,"")," ",o.name) officeName,d.lable typeName from <include refid="table" /> t
|
left JOIN sys_organization o on t.officeId = o.id
|
left JOIN sys_organization parentOrg on o.parentId = parentOrg.id
|
left join sys_dict d on t.type = d.value and d.orgId = t.orgId and d.type = 'PEO_TYPE' and d.delFlag= 0
|
<where>
|
/*wp 添加 是否查询已上除*/
|
<if test="delFlag != null and delFlag">
|
1=1
|
</if>
|
<if test="delFlag == null or !delFlag ">
|
t.delFlag = 0
|
</if>
|
<if test=" phone!=null and phone!='' ">
|
and t.phone=#{phone}
|
</if>
|
<if test="type != null and type != ''">
|
and t.type = #{type}
|
</if>
|
<if test="groupInformation != null and groupInformation != ''">
|
and (t.name like concat('%', #{groupInformation}, '%') or t.cardId like concat('%', #{groupInformation}, '%')
|
or t.no like concat('%', #{groupInformation}, '%')
|
or t.phone like concat('%', #{groupInformation}, '%') or o.name like concat('%', #{groupInformation}, '%'))
|
</if>
|
<if test="distributionIds != null ">
|
and
|
<foreach collection="distributionIds" index="index" item="distributionId" separator="or" open="(" close=")">
|
t.distributionIds like concat('%', #{distributionId}, '%')
|
</foreach>
|
</if>
|
<if test="name != null and name != ''">
|
and t.name like '%${name}%'
|
</if>
|
ORDER BY IFNULL(t.updateTime,t.createTime) DESC
|
<if test="start != null and length != null">
|
LIMIT #{start}, #{length}
|
</if>
|
</where>
|
</select>
|
|
<select id="countBase" resultType="int" parameterType="map">
|
select count(*) from <include refid="table" /> t
|
left JOIN sys_organization o on t.officeId = o.id
|
<where>
|
/*wp 添加 是否查询已上除*/
|
<if test="delFlag != null and delFlag">
|
1=1
|
</if>
|
<if test="delFlag == null or !delFlag ">
|
t.delFlag = 0
|
</if>
|
<if test=" phone!=null and phone!='' ">
|
and t.phone=#{phone}
|
</if>
|
<if test="type != null and type != ''">
|
and t.type = #{type}
|
</if>
|
<if test="groupInformation != null and groupInformation != ''">
|
and (t.name like concat('%', #{groupInformation}, '%') or t.cardId like concat('%', #{groupInformation}, '%') or t.no like concat('%', #{groupInformation}, '%')
|
or t.phone like concat('%', #{groupInformation}, '%') or o.name like concat('%', #{groupInformation}, '%'))
|
</if>
|
<if test="distributionIds != null ">
|
and
|
<foreach collection="distributionIds" index="index" item="distributionId" separator="or" open="(" close=")">
|
t.distributionIds like concat('%', #{distributionId}, '%')
|
</foreach>
|
</if>
|
<if test="name != null and name != ''">
|
and t.name like '%${name}%'
|
</if>
|
</where>
|
</select>
|
|
<select id="findDataFromTemp" resultType="com.cloud.model.sys.BbEmployee" parameterType="map">
|
select t.* from bb_person_temporary t
|
<where> 1=1
|
<if test=" phone!=null and phone!='' ">
|
and phone=#{phone}
|
</if>
|
<if test="type != null and type != ''">
|
and type = #{type}
|
</if>
|
<if test="groupInformation != null and groupInformation != ''">
|
and (t.name like concat('%', #{groupInformation}, '%') or cardId like concat('%', #{groupInformation}, '%') or no like concat('%', #{groupInformation}, '%'))
|
</if>
|
<if test="distributionIds != null ">
|
and
|
<foreach collection="distributionIds" index="index" item="distributionId" separator="or" open="(" close=")">
|
distributionIds like concat('%', #{distributionId}, '%')
|
</foreach>
|
</if>
|
<if test="name != null and name != ''">
|
and name like '%${name}%'
|
</if>
|
and t.delFlag = 0
|
ORDER BY IFNULL(t.updateTime,t.createTime) DESC
|
<if test="start != null and length != null">
|
LIMIT #{start}, #{length}
|
</if>
|
</where>
|
</select>
|
|
<select id="findOrgEmployeeByTypeCount" parameterType="java.util.Map" resultType="int">
|
SELECT count(emp.id) FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id
|
WHERE emp.delFlag = 0 and org.parentIds LIKE '%${parentIds}%' AND emp.type = #{type}
|
<if test="name != null and name != ''">
|
and emp.name like '%${name}%'
|
</if>
|
</select>
|
|
<select id="findOrgEmployeeByTypeData" parameterType="java.util.Map" resultType="com.cloud.model.sys.BbEmployee">
|
SELECT emp.id,emp.name,emp.photos FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id
|
WHERE emp.delFlag = 0 AND org.parentIds LIKE '%${parentIds}%' AND emp.type = #{type}
|
<if test="name != null and name != ''">
|
and emp.name like '%${name}%'
|
</if>
|
<if test="start != null and length != null and length != ''" >
|
LIMIT #{start}, #{length}
|
</if>
|
</select>
|
|
<select id="findOrgEmpIds" parameterType="java.util.Map" resultType="int">
|
SELECT emp.id FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id AND org.delFlag = 0
|
AND org.parentIds LIKE '%${parentIds}%' AND emp.type = #{type}
|
</select>
|
|
<select id="findOrgEmpMap" parameterType="java.util.Map" resultType="map">
|
SELECT emp.orgId,emp.id,emp.photos,emp.`name`,emp.compactType,emp.type,emp.phone,emp.createTime FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id
|
AND emp.delFlag = 0
|
AND org.parentIds LIKE '%${parentIds}%'
|
<if test="orgId != null and orgId != ''">
|
AND emp.orgId = #{orgId}
|
</if>
|
<if test="type != null and type != ''">
|
AND emp.type = #{type}
|
</if>
|
<if test="compactType != null and compactType != ''">
|
AND emp.compactType = #{compactType}
|
</if>
|
<if test="searchName != null and searchName != ''">
|
AND emp.name like '%${searchName}%'
|
</if>
|
<if test="start != null and start != '' and length != null and length != ''">
|
limit ${start},${length}
|
</if>
|
</select>
|
|
<select id="findOrgEmpMap1" parameterType="java.util.Map" resultType="map">
|
SELECT emp.orgId,emp.id,emp.photos,emp.`name`,emp.gender,emp.cardId,emp.compactType,emp.type,emp.phone,emp.createTime FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id
|
WHERE emp.delFlag = 0
|
AND org.parentIds LIKE CONCAT((select parentIds from sys_organization where id = #{id}),"%")
|
<if test="orgId != null and orgId != ''">
|
AND emp.orgId = #{orgId}
|
</if>
|
<if test="type != null and type != ''">
|
AND emp.type = #{type}
|
</if>
|
<if test="compactType != null and compactType != ''">
|
AND emp.compactType = #{compactType}
|
</if>
|
<if test="searchName != null and searchName != ''">
|
AND emp.name like '%${searchName}%'
|
</if>
|
<if test="start != null and start != '' and length != null and length != ''">
|
limit ${start},${length}
|
</if>
|
</select>
|
|
<select id="findOrgEmpMapCount" resultType="int">
|
SELECT COUNT(emp.id) FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id
|
AND emp.delFlag = 0
|
AND org.parentIds LIKE '%${parentIds}%'
|
<if test="orgId != null and orgId != ''">
|
AND emp.orgId = #{orgId}
|
</if>
|
<if test="type != null and type != ''">
|
AND emp.type = #{type}
|
</if>
|
<if test="compactType != null and compactType != ''">
|
AND emp.compactType = #{compactType}
|
</if>
|
<if test="searchName != null and searchName != ''">
|
AND emp.name like '%${searchName}%'
|
</if>
|
</select>
|
|
<select id="findInfoByEmployeeId" parameterType="java.util.Map" resultType="map">
|
SELECT
|
a.id,
|
a.photos,
|
a.`name`,
|
b.relation,
|
c.photos as parent_photos,
|
c.`name` as parent_name
|
FROM
|
bb_employee a
|
LEFT JOIN bb_employee_relation b ON a.id = b.employeeId
|
LEFT JOIN bb_employee c ON c.id = b.relationoId
|
<where>
|
a.delFlag = #{delFlag}
|
<if test="orgId != null">
|
and a.orgId = #{orgId}
|
</if>
|
<if test="id != null">
|
and a.id = #{id}
|
</if>
|
</where>
|
LIMIT 1
|
</select>
|
|
<select id="findStudentAndTeachers" parameterType="java.util.Map" resultMap="beanMap">
|
SELECT
|
a.id,
|
a.orgId,
|
a.officeId,
|
a.cardId,
|
a.`name`,
|
a.gender,
|
a.nation,
|
a.phone,
|
a.type,
|
a.registerAddress,
|
a.distributionIds,
|
a.distributionNames,
|
a.photos,
|
a.faceIds,
|
a.createBy,
|
a.createTime,
|
a.updateBy,
|
a.updateTime,
|
a.remarks,
|
a.delFlag,
|
a.rev_json1
|
FROM
|
bb_employee a
|
LEFT JOIN sys_organization b on a.orgId = b.orgId
|
<where>
|
1=1
|
<if test="orgId != null">
|
and a.orgId = #{orgId}
|
and b.orgId = #{orgId}
|
</if>
|
<if test="classId != null and classId != ''">
|
and a.officeId = #{classId}
|
and a.officeId = b.id
|
</if>
|
<if test="gradeId != null and gradeId != ''">
|
and b.parentIds like '%,${gradeId},%'
|
a.officeId = b.id
|
</if>
|
and (a.type='学生' or a.type='教师')
|
<if test="type != null and type != ''">
|
and a.type = #{type}
|
</if>
|
and a.delFlag='0'
|
</where>
|
</select>
|
|
<!--根据家长ID查询学生信息-->
|
<select id="findStuByEmpId" parameterType="java.util.Map" resultMap="stuMap">
|
SELECT be.id,be.orgId,be.officeId,be.name,be.gender,be.nation,be.photos,ber.relation as remarks from bb_employee be
|
LEFT JOIN bb_employee_relation ber on be.id = ber.employeeId where be.delFlag = 0
|
<if test="orgId != null and orgId != ''">
|
and be.orgId = #{orgId}
|
</if>
|
and (ber.relation = '家长' or ber.relation = '父亲' or ber.relation = '母亲')
|
and ber.relationoId = #{empId}
|
and be.delFlag = 0
|
</select>
|
|
<!--教师模糊查询根据拼音-->
|
<select id="findTeacherByPin" parameterType="java.util.Map" resultMap="beanMap">
|
select be.id,be.name,be.photos,so.name as remarks from bb_employee be INNER JOIN sys_organization so
|
on be.officeId = so.id where be.delFlag=0
|
<if test="orgId != null and orgId != ''">
|
and be.orgId = #{orgId}
|
</if>
|
<if test="namecode != null and namecode != ''">
|
and be.mnemonicCode like '${namecode}%'
|
</if>
|
and be.type = '教师'
|
</select>
|
<!--教师模糊查询根据拼音-->
|
<select id="findOfficeNameById" parameterType="java.util.Map" resultType="map">
|
SELECT a.id, b.`name` from bb_employee a LEFT JOIN sys_organization b on a.officeId = b.id where
|
a.delFlag = 0
|
<if test="orgId != null">
|
and a.orgId = #{orgId}
|
</if>
|
<if test="id != null">
|
and a.id like #{id}
|
</if>
|
</select>
|
|
<select id="isExistEmp" resultMap="beanMap">
|
SELECT id,faceIds from bb_employee where delFlag = 0
|
<if test="orgId != null">
|
and orgId = #{orgId}
|
</if>
|
and phone = #{phone}
|
limit 0,1
|
</select>
|
|
<select id="isExistEmployee" resultType="com.cloud.model.sys.BbEmployee">
|
SELECT * from bb_employee where delFlag = 0
|
<if test="orgId != null">
|
and orgId = #{orgId}
|
</if>
|
and phone = #{phone}
|
limit 0,1
|
</select>
|
|
<select id="findOrgTeaMap" parameterType="java.util.Map" resultType="map">
|
SELECT emp.id,emp.name,emp.compactType FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id
|
AND emp.delFlag = 0 AND org.parentIds LIKE '%${parentIds}%' AND emp.type = #{type}
|
<if test="orgId != null and orgId != ''">
|
AND emp.orgId = #{orgId}
|
</if>
|
<if test="compactType != null and compactType != ''">
|
AND emp.compactType = #{compactType}
|
</if>
|
</select>
|
|
<!--根据id查询人员详细信息-->
|
<select id="findEmpById" resultType="com.cloud.model.sys.BbEmployee" parameterType="map">
|
select * from bb_person_base WHERE delFlag = '0' and id = #{id}
|
<if test="orgId = null and orgId != ''">
|
and orgId = #{orgId}
|
</if>
|
<if test="signDate!=null and signDate!=''">
|
and DATE_FORMAT(createTime,'%Y-%m-%d') <= #{signDate} and #{signDate} <= DATE_FORMAT(now(),'%Y-%m-%d')
|
</if>
|
</select>
|
|
<!--获取访客被访人数-->
|
<select id="findOrgEmpInVisitCount" resultType="java.lang.Integer">
|
SELECT count(emp.id) FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id
|
WHERE emp.delFlag = 0 and org.parentIds LIKE CONCAT((select parentIds from sys_organization where delFlag = '0' and id = #{id}),"%")
|
AND emp.type != #{type}
|
<if test="name != null and name != ''">
|
and emp.name like '%${name}%'
|
</if>
|
</select>
|
|
<!--获取访客被访人-->
|
<select id="findOrgEmpInVisitData" resultType="com.cloud.model.sys.BbEmployee">
|
SELECT emp.id,emp.name,emp.type,emp.photos FROM bb_employee emp INNER JOIN sys_organization org ON emp.officeId = org.id
|
WHERE emp.delFlag = 0 AND org.parentIds LIKE CONCAT((select parentIds from sys_organization where delFlag = '0' and id = #{id}),"%")
|
AND emp.type != #{type}
|
<if test="name != null and name != ''">
|
and emp.name like '%${name}%'
|
</if>
|
<if test="start != null and length != null and length != ''" >
|
LIMIT #{start}, #{length}
|
</if>
|
</select>
|
|
<select id="findDataByOfficeId" resultType="com.cloud.model.sys.BbEmployee">
|
select a.*
|
from <include refid="table" /> a
|
LEFT JOIN sys_organization b on a.officeId = b.id
|
where b.parentIds like CONCAT("%,",#{id},",%")
|
and a.delFlag = 0
|
and b.delFlag = 0
|
</select>
|
|
<update id="updateOfficeId" parameterType="map">
|
update bb_employee
|
<set>
|
|
<if test="updateOfficeId != null">
|
officeId = #{updateOfficeId,jdbcType=CHAR},
|
</if>
|
<if test="updateOrgId != null">
|
orgId = #{updateOrgId,jdbcType=CHAR},
|
</if>
|
<if test="orgNamesJson != null">
|
orgNamesJson = #{orgNamesJson,jdbcType=CHAR},
|
</if>
|
</set>
|
<where>
|
<if test="officeId != null and officeId != ''">
|
and officeId in (
|
SELECT id
|
from sys_organization
|
where parentIds LIKE CONCAT("%,",#{officeId},",%") and delFlag=0
|
)
|
</if>
|
<if test="employeeIds != null and employeeIds != ''">
|
and id in (${employeeIds})
|
</if>
|
<if test="orgId != null and orgId != ''">
|
and orgId = #{orgId}
|
</if>
|
</where>
|
</update>
|
</mapper>
|