310 lines
12 KiB
XML
310 lines
12 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.zhwl.base.mapper.ZdyBaseEmployeeMapper">
|
|
|
|
<resultMap type="ZdyBaseEmployee" id="ZdyBaseEmployeeResult">
|
|
<result property="id" column="id"/>
|
|
<result property="companyId" column="company_id"/>
|
|
<result property="name" column="name"/>
|
|
<result property="phone" column="phone"/>
|
|
<result property="idCard" column="id_card"/>
|
|
<result property="cardNo" column="card_no"/>
|
|
<result property="cardId" column="card_id"/>
|
|
<result property="sex" column="sex"/>
|
|
<result property="duty" column="duty"/>
|
|
<result property="employeeStatus" column="employee_status"/>
|
|
<result property="delFlag" column="del_flag"/>
|
|
<result property="createTime" column="create_time"/>
|
|
<result property="createBy" column="create_by"/>
|
|
<result property="updateTime" column="update_time"/>
|
|
<result property="updateBy" column="update_by"/>
|
|
<result property="remark" column="remark"/>
|
|
<result property="companyName" column="company_name"/>
|
|
<result property="deptId" column="dept_id"/>
|
|
</resultMap>
|
|
|
|
<resultMap type="ZdyEmployeeCardGraph" id="ZdyEmployeeCardGraphResult">
|
|
<result property="dataTime" column="data_time"/>
|
|
<result property="cardNo" column="card_no"/>
|
|
<result property="deviceName" column="device_name"/>
|
|
<result property="employeeName" column="name"/>
|
|
<result property="employeePhone" column="phone"/>
|
|
<result property="employeeId" column="employee_id"/>
|
|
<result property="openDoor" column="open_door"/>
|
|
<result property="serial" column="serial"/>
|
|
</resultMap>
|
|
|
|
<sql id="selectZdyBaseEmployeeVo">
|
|
select be.id,
|
|
be.company_id,
|
|
be.name,
|
|
be.phone,
|
|
be.id_card,
|
|
be.card_no,
|
|
be.card_id,
|
|
be.sex,
|
|
be.duty,
|
|
be.employee_status,
|
|
be.del_flag,
|
|
be.create_time,
|
|
be.create_by,
|
|
be.update_time,
|
|
be.update_by,
|
|
be.remark,
|
|
bc.company_name,
|
|
be.dept_id
|
|
from zdy_base_employee be
|
|
left join zdy_base_company bc on be.company_id = bc.id
|
|
</sql>
|
|
|
|
<sql id = "whereZdyEmployeeCardGraph">
|
|
<if test="cardNo != null and cardNo != ''">
|
|
and l.card_no = #{cardNo}
|
|
</if>
|
|
<if test="openDoor != null">
|
|
and l.open_door = #{openDoor}
|
|
</if>
|
|
<if test="deviceName != null and deviceName != ''">
|
|
and g.device_name like concat('%', #{deviceName}, '%')
|
|
</if>
|
|
<if test="employeeName != null and employeeName != ''">
|
|
and be.name like concat('%', #{employeeName}, '%')
|
|
</if>
|
|
<if test="employeePhone != null and employeePhone != ''">
|
|
and be.phone = #{employeePhone}
|
|
</if>
|
|
<if test="params.beginDataTime != null and params.beginDataTime != '' and params.endDataTime != null and params.endDataTime != ''">
|
|
and l.create_time between #{params.beginDataTime} and #{params.endDataTime}
|
|
</if>
|
|
</sql>
|
|
|
|
<sql id = "whereInZdyEmployeeCardGraph">
|
|
<if test="cardNo != null and cardNo != ''">
|
|
and l.card_no = #{cardNo}
|
|
</if>
|
|
<if test="openDoor != null">
|
|
and l.open_door = #{openDoor}
|
|
</if>
|
|
<if test="deviceName != null and deviceName != ''">
|
|
and l.serial in (select serial_no from zdy_device_gate where device_name like concat('%', #{deviceName}, '%') )
|
|
</if>
|
|
<if test="employeeName != null and employeeName != ''">
|
|
and be.name like concat('%', #{employeeName}, '%')
|
|
</if>
|
|
<if test="employeePhone != null and employeePhone != ''">
|
|
and be.phone = #{employeePhone}
|
|
</if>
|
|
<if test="params.beginDataTime != null and params.beginDataTime != '' and params.endDataTime != null and params.endDataTime != ''">
|
|
and l.create_time between #{params.beginDataTime} and #{params.endDataTime}
|
|
</if>
|
|
</sql>
|
|
|
|
<select id="selectZdyBaseEmployeeList" parameterType="ZdyBaseEmployee" resultMap="ZdyBaseEmployeeResult">
|
|
<include refid="selectZdyBaseEmployeeVo"/>
|
|
left join sys_dept d on d.dept_id = be.dept_id
|
|
<where>
|
|
be.del_flag = 0
|
|
<if test="companyId != null ">
|
|
and be.company_id = #{companyId}
|
|
</if>
|
|
<if test="name != null and name != ''">
|
|
and be.name like concat('%', #{name}, '%')
|
|
</if>
|
|
<if test="phone != null and phone != ''">
|
|
and be.phone = #{phone}
|
|
</if>
|
|
<if test="idCard != null and idCard != ''">
|
|
and be.id_card = #{idCard}
|
|
</if>
|
|
<if test="cardNo != null and cardNo != ''">
|
|
and be.card_no = #{cardNo}
|
|
</if>
|
|
<if test="cardId != null ">
|
|
and be.card_id = #{cardId}
|
|
</if>
|
|
<if test="sex != null and sex != ''">
|
|
and be.sex = #{sex}
|
|
</if>
|
|
<if test="duty != null and duty != ''">
|
|
and be.duty = #{duty}
|
|
</if>
|
|
<if test="employeeStatus != null ">
|
|
and be.employee_status = #{employeeStatus}
|
|
</if>
|
|
${params.dataScope}
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectZdyBaseEmployeeById" parameterType="Long"
|
|
resultMap="ZdyBaseEmployeeResult">
|
|
<include refid="selectZdyBaseEmployeeVo"/>
|
|
where be.id = #{id}
|
|
</select>
|
|
|
|
<insert id="insertZdyBaseEmployee" parameterType="ZdyBaseEmployee" useGeneratedKeys="true"
|
|
keyProperty="id">
|
|
insert into zdy_base_employee
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="companyId != null">company_id,
|
|
</if>
|
|
<if test="name != null">name,
|
|
</if>
|
|
<if test="phone != null">phone,
|
|
</if>
|
|
<if test="idCard != null">id_card,
|
|
</if>
|
|
<if test="cardNo != null">card_no,
|
|
</if>
|
|
<if test="cardId != null">card_id,
|
|
</if>
|
|
<if test="sex != null">sex,
|
|
</if>
|
|
<if test="duty != null">duty,
|
|
</if>
|
|
<if test="employeeStatus != null">employee_status,
|
|
</if>
|
|
<if test="delFlag != null">del_flag,
|
|
</if>
|
|
<if test="createTime != null">create_time,
|
|
</if>
|
|
<if test="createBy != null">create_by,
|
|
</if>
|
|
<if test="updateTime != null">update_time,
|
|
</if>
|
|
<if test="updateBy != null">update_by,
|
|
</if>
|
|
<if test="remark != null">remark,
|
|
</if>
|
|
<if test="deptId != null">dept_id,
|
|
</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="companyId != null">#{companyId},
|
|
</if>
|
|
<if test="name != null">#{name},
|
|
</if>
|
|
<if test="phone != null">#{phone},
|
|
</if>
|
|
<if test="idCard != null">#{idCard},
|
|
</if>
|
|
<if test="cardNo != null">#{cardNo},
|
|
</if>
|
|
<if test="cardId != null">#{cardId},
|
|
</if>
|
|
<if test="sex != null">#{sex},
|
|
</if>
|
|
<if test="duty != null">#{duty},
|
|
</if>
|
|
<if test="employeeStatus != null">#{employeeStatus},
|
|
</if>
|
|
<if test="delFlag != null">#{delFlag},
|
|
</if>
|
|
<if test="createTime != null">#{createTime},
|
|
</if>
|
|
<if test="createBy != null">#{createBy},
|
|
</if>
|
|
<if test="updateTime != null">#{updateTime},
|
|
</if>
|
|
<if test="updateBy != null">#{updateBy},
|
|
</if>
|
|
<if test="remark != null">#{remark},
|
|
</if>
|
|
<if test="deptId != null">#{deptId},
|
|
</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateZdyBaseEmployee" parameterType="ZdyBaseEmployee">
|
|
update zdy_base_employee
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="companyId != null">company_id =
|
|
#{companyId},
|
|
</if>
|
|
<if test="name != null">name =
|
|
#{name},
|
|
</if>
|
|
<if test="phone != null">phone =
|
|
#{phone},
|
|
</if>
|
|
<if test="idCard != null">id_card =
|
|
#{idCard},
|
|
</if>
|
|
<if test="cardNo != null">card_no =
|
|
#{cardNo},
|
|
</if>
|
|
<if test="cardId != null">card_id =
|
|
#{cardId},
|
|
</if>
|
|
<if test="sex != null">sex =
|
|
#{sex},
|
|
</if>
|
|
<if test="duty != null">duty =
|
|
#{duty},
|
|
</if>
|
|
<if test="employeeStatus != null">employee_status =
|
|
#{employeeStatus},
|
|
</if>
|
|
<if test="delFlag != null">del_flag =
|
|
#{delFlag},
|
|
</if>
|
|
<if test="createTime != null">create_time =
|
|
#{createTime},
|
|
</if>
|
|
<if test="createBy != null">create_by =
|
|
#{createBy},
|
|
</if>
|
|
<if test="updateTime != null">update_time =
|
|
#{updateTime},
|
|
</if>
|
|
<if test="updateBy != null">update_by =
|
|
#{updateBy},
|
|
</if>
|
|
<if test="remark != null">remark =
|
|
#{remark},
|
|
</if>
|
|
<if test="deptId != null">dept_id =
|
|
#{deptId},
|
|
</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteZdyBaseEmployeeById" parameterType="Long">
|
|
delete
|
|
from zdy_base_employee
|
|
where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteZdyBaseEmployeeByIds" parameterType="String">
|
|
delete from zdy_base_employee where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
<select id="selectEmployeeByIdCardAndPhone" resultMap="ZdyBaseEmployeeResult">
|
|
<include refid="selectZdyBaseEmployeeVo"/>
|
|
where be.id_card = #{idCard} and be.phone = #{phone} and be.del_flag = 0 limit 1
|
|
</select>
|
|
<select id="selectZdyBaseEmployeeByCardNo" parameterType="String"
|
|
resultMap="ZdyBaseEmployeeResult">
|
|
<include refid="selectZdyBaseEmployeeVo"/>
|
|
where be.card_no = #{cardNo} and del_flag = 0 limit 1
|
|
</select>
|
|
|
|
<select id="selectZdyEmployeeCardGraphList" resultMap="ZdyEmployeeCardGraphResult">
|
|
SELECT
|
|
l.create_time AS data_time, l.serial, l.card_no, l.open_door, g.device_name, be.name, be.phone, l.employee_id
|
|
FROM zdy_device_gate_card_log l
|
|
LEFT JOIN zdy_base_employee be ON be.id = l.employee_id
|
|
LEFT JOIN zdy_device_gate g ON g.serial_no = l.serial
|
|
left join sys_dept d on d.dept_id = be.dept_id
|
|
WHERE l.type = '0' and l.employee_id is not null and be.id is not null and g.del_flag != 1
|
|
<include refid="whereZdyEmployeeCardGraph"/>
|
|
${params.dataScope}
|
|
order by l.id desc
|
|
</select>
|
|
|
|
</mapper>
|