<?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.tofly.gpsboot.mapper.plan.PdasignhisMapper">

    <resultMap id="pdasignhisMap" type="com.tofly.pojo.plan.Pdasignhis">
        <id property="id" column="ID"/>
        <result property="signUser" column="SIGN_USER"/>
        <result property="pdaid" column="PDAID"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="signAddress" column="SIGN_ADDRESS"/>
        <result property="signType" column="SIGN_TYPE"/>
        <result property="lng" column="LNG"/>
        <result property="lat" column="LAT"/>
        <result property="section" column="SECTION"/>
        <result property="note" column="NOTE"/>
        <result property="flag" column="FLAG"/>
        <result property="signTime" column="SIGN_TIME"/>
        <association property="signUserName" column="SIGN_USER" select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName"/>
        <association property="deptName" column="SIGN_USER" select="getDeptName"/>
    </resultMap>

    <select id="getUserIdList" resultType="long">
        select ID
        from TF_SMPN_USER_X
        <if test="deptIds != null and deptIds != ''">
            where DEPARTMENT_ID in
                <foreach item="deptId" collection="deptIds.split(',')" open="(" separator="," close=")">
                    #{deptId}
                </foreach>
        </if>
    </select>

    <select id="getDeptName" resultType="string">
        select b.NAME
        from TF_SMPN_USER_X a
            left join TF_SMPN_DEPARTMENT_X b on b.ID = a.DEPARTMENT_ID
        where a.ID = #{signUser}
    </select>


</mapper>
