<?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.sundot.airport.system.mapper.SysUserMapper">

    <resultMap type="SysUser" id="SysUserResult">
        <id property="userId" column="user_id"/>
        <result property="deptId" column="dept_id"/>
        <result property="userName" column="user_name"/>
        <result property="nickName" column="nick_name"/>
        <result property="email" column="email"/>
        <result property="phonenumber" column="phonenumber"/>
        <result property="sex" column="sex"/>
        <result property="avatar" column="avatar"/>
        <result property="password" column="password"/>
        <result property="status" column="status"/>
        <result property="delFlag" column="del_flag"/>
        <result property="loginIp" column="login_ip"/>
        <result property="loginDate" column="login_date"/>
        <result property="pwdUpdateDate" column="pwd_update_date"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
        <result property="cardNumber" column="card_number"/>
        <result property="politicalStatus" column="political_status"/>
        <result property="trainingComplianceStatus" column="training_compliance_status"/>
        <result property="qualificationLevel" column="qualification_level"/>
        <result property="administrativeStatus" column="administrative_status"/>
        <result property="physicalHealthStatus" column="physical_health_status"/>
        <result property="emergencyContactName" column="emergency_contact_name"/>
        <result property="emergencyContactPhone" column="emergency_contact_phone"/>
        <result property="emergencyContactRelationship" column="emergency_contact_relationship"/>
        <result property="zodiac" column="zodiac"/>
        <result property="constellation" column="constellation"/>
        <result property="blooGroup" column="blood_group"/>
        <result property="characterCharacteristics" column="character_characteristics"/>
        <result property="workingStyle" column="working_style"/>
        <result property="teamCooperation" column="team_cooperation"/>
        <result property="selfAssessmentPersonalityTrait" column="self_assessment_personality_trait"/>
        <result property="selfAssessmentCapabilityPerformance" column="self_assessment_capability_performance"/>
        <result property="selfAssessmentInterpersonalInteraction" column="self_assessment_interpersonal_interaction"/>
        <result property="selfAssessmentGrowthPotential" column="self_assessment_growth_potential"/>
        <result property="colleagueCommentsPersonalityTrait" column="colleague_comments_personality_trait"/>
        <result property="colleagueCommentsCapabilityPerformance" column="colleague_comments_capability_performance"/>
        <result property="colleagueCommentsInterpersonalInteraction"
                column="colleague_comments_interpersonal_interaction"/>
        <result property="colleagueCommentsGrowthPotential" column="colleague_comments_growth_potential"/>
        <result property="superiorEvaluationPersonalityTrait" column="superior_evaluation_personality_trait"/>
        <result property="superiorEvaluationCapabilityPerformance" column="superior_evaluation_capability_performance"/>
        <result property="superiorEvaluationInterpersonalInteraction"
                column="superior_evaluation_interpersonal_interaction"/>
        <result property="superiorEvaluationGrowthPotential" column="superior_evaluation_growth_potential"/>
        <result property="subordinateEvaluationPersonalityTrait" column="subordinate_evaluation_personality_trait"/>
        <result property="subordinateEvaluationCapabilityPerformance"
                column="subordinate_evaluation_capability_performance"/>
        <result property="subordinateEvaluationInterpersonalInteraction"
                column="subordinate_evaluation_interpersonal_interaction"/>
        <result property="subordinateEvaluationGrowthPotential" column="subordinate_evaluation_growth_potential"/>
        <result property="schooling" column="schooling"/>
        <result property="politicalReviewSituation" column="political_review_situation"/>
        <result property="startWorkingDate" column="start_working_date"/>
        <result property="securityCheckStartDate" column="security_check_start_date"/>
        <result property="entryDate" column="entry_date"/>
        <result property="xrayOperatorStarttime" column="xray_operator_starttime"/>
        <result property="professional" column="professional"/>
        <result property="nativePlace" column="native_place"/>
        <result property="nation" column="nation"/>
        <result property="securityInspectionPosition" column="security_inspection_position"/>
        <result property="workRewardsNumber" column="work_rewards_number"/>
        <result property="workPenaltiesNumber" column="work_penalties_number"/>
        <association property="dept" javaType="SysDept" resultMap="deptResult"/>
        <collection property="roles" javaType="java.util.List" resultMap="RoleResult"/>
    </resultMap>

    <resultMap id="deptResult" type="SysDept">
        <id property="deptId" column="dept_id"/>
        <result property="parentId" column="parent_id"/>
        <result property="deptName" column="dept_name"/>
        <result property="ancestors" column="ancestors"/>
        <result property="orderNum" column="order_num"/>
        <result property="leader" column="leader"/>
        <result property="status" column="dept_status"/>
        <result property="deptType" column="dept_type"/>
        <result property="deptTypeDesc" column="dept_type_desc"/>
    </resultMap>

    <resultMap id="RoleResult" type="SysRole">
        <id property="roleId" column="role_id"/>
        <result property="roleName" column="role_name"/>
        <result property="roleKey" column="role_key"/>
        <result property="roleSort" column="role_sort"/>
        <result property="dataScope" column="data_scope"/>
        <result property="status" column="role_status"/>
    </resultMap>

    <sql id="selectUserVo">
        select u.user_id,
               u.dept_id,
               u.user_name,
               u.nick_name,
               u.email,
               u.avatar,
               u.phonenumber,
               u.password,
               u.sex,
               u.status,
               u.del_flag,
               u.login_ip,
               u.login_date,
               u.pwd_update_date,
               u.create_by,
               u.create_time,
               u.remark,
               u.card_number,
               u.political_status,
               u.training_compliance_status,
               u.qualification_level,
               u.administrative_status,
               u.physical_health_status,
               u.emergency_contact_name,
               u.emergency_contact_phone,
               u.emergency_contact_relationship,
               u.zodiac,
               u.constellation,
               u.blood_group,
               u.character_characteristics,
               u.working_style,
               u.team_cooperation,
               u.self_assessment_personality_trait,
               u.self_assessment_capability_performance,
               u.self_assessment_interpersonal_interaction,
               u.self_assessment_growth_potential,
               u.colleague_comments_personality_trait,
               u.colleague_comments_capability_performance,
               u.colleague_comments_interpersonal_interaction,
               u.colleague_comments_growth_potential,
               u.superior_evaluation_personality_trait,
               u.superior_evaluation_capability_performance,
               u.superior_evaluation_interpersonal_interaction,
               u.superior_evaluation_growth_potential,
               u.subordinate_evaluation_personality_trait,
               u.subordinate_evaluation_capability_performance,
               u.subordinate_evaluation_interpersonal_interaction,
               u.subordinate_evaluation_growth_potential,
               u.schooling,
               u.political_review_situation,
               u.start_working_date,
               u.security_check_start_date,
               u.entry_date,
               u.xray_operator_starttime,
               u.professional,
               u.native_place,
               u.nation,
               u.security_inspection_position,
               u.work_rewards_number,
               u.work_penalties_number,
               d.dept_id,
               d.parent_id,
               d.ancestors,
               d.dept_name,
               d.order_num,
               d.leader,
               d.status as dept_status,
               d.dept_type,
               d.dept_type_desc,
               r.role_id,
               r.role_name,
               r.role_key,
               r.role_sort,
               r.data_scope,
               r.status as role_status
        from sys_user u
                 left join sys_dept d on u.dept_id = d.dept_id
                 left join sys_user_role ur on u.user_id = ur.user_id
                 left join sys_role r on r.role_id = ur.role_id
    </sql>

    <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
        select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
        u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
        u.card_number, u.political_status, u.training_compliance_status,
        u.qualification_level, u.administrative_status, u.physical_health_status,
        u.emergency_contact_name, u.emergency_contact_phone, u.emergency_contact_relationship,
        u.zodiac, u.constellation, u.blood_group,
        u.character_characteristics, u.working_style, u.team_cooperation,
        u.self_assessment_personality_trait, u.self_assessment_capability_performance,
        u.self_assessment_interpersonal_interaction,u.self_assessment_growth_potential,
        u.colleague_comments_personality_trait, u.colleague_comments_capability_performance,
        u.colleague_comments_interpersonal_interaction,u.colleague_comments_growth_potential,
        u.superior_evaluation_personality_trait, u.superior_evaluation_capability_performance,
        u.superior_evaluation_interpersonal_interaction,u.superior_evaluation_growth_potential,
        u.subordinate_evaluation_personality_trait, u.subordinate_evaluation_capability_performance,
        u.subordinate_evaluation_interpersonal_interaction,u.subordinate_evaluation_growth_potential,
        u.schooling,u.political_review_situation,u.start_working_date,
        u.security_check_start_date,u.entry_date,u.xray_operator_starttime,
        u.professional,u.native_place,u.nation,
        u.security_inspection_position,u.work_rewards_number,u.work_penalties_number,
        d.dept_name, d.leader from sys_user u
        left join sys_dept d on u.dept_id = d.dept_id
        where u.del_flag = '0'
        <if test="userId != null and userId != 0">
            AND u.user_id = #{userId}
        </if>
        <if test="userName != null and userName != ''">
            AND u.user_name like concat('%', #{userName}, '%')
        </if>
        <if test="nickName != null and nickName != ''">
            AND u.nick_name like concat('%', #{nickName}, '%')
        </if>
        <if test="status != null and status != ''">
            AND u.status = #{status}
        </if>
        <if test="phonenumber != null and phonenumber != ''">
            AND u.phonenumber like concat('%', #{phonenumber}, '%')
        </if>
        <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
            AND date_format(u.create_time,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
        </if>
        <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
            AND date_format(u.create_time,'%Y%m%d') &lt;= date_format(#{params.endTime},'%Y%m%d')
        </if>
        <if test="deptId != null and deptId != 0">
            AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
            ancestors) ))
        </if>
        <!-- 角色查询 -->
        <if test="roleId != null and roleId != 0">
            AND u.user_id IN (SELECT user_id FROM sys_user_role WHERE role_id= #{roleId})
        </if>
        <!-- 角色名称模糊查询 -->
        <if test="roleName != null and roleName != ''">
            AND u.user_id IN (SELECT user_id FROM sys_user_role sur INNER JOIN sys_role sr ON sur.role_id = sr.role_id
            WHERE sr.role_name like concat('%', #{roleName}, '%'))
        </if>
        <if test="cardNumber != null and cardNumber != ''">
            AND u.card_number like concat('%', #{cardNumber}, '%')
        </if>
        <if test="politicalStatus != null and politicalStatus != ''">
            AND u.political_status = #{politicalStatus}
        </if>
        <if test="trainingComplianceStatus != null and trainingComplianceStatus != ''">
            AND u.training_compliance_status = #{trainingComplianceStatus}
        </if>
        <if test="qualificationLevel != null and qualificationLevel != ''">
            AND u.qualification_level = #{qualificationLevel}
        </if>
        <if test="administrativeStatus != null and administrativeStatus != ''">
            AND u.administrative_status like concat('%', #{administrativeStatus}, '%')
        </if>
        <if test="physicalHealthStatus != null and physicalHealthStatus != ''">
            AND u.physical_health_status like concat('%', #{physicalHealthStatus}, '%')
        </if>
        <if test="emergencyContactName != null and emergencyContactName != ''">
            AND u.emergency_contact_name like concat('%', #{emergencyContactName}, '%')
        </if>
        <if test="emergencyContactPhone != null and emergencyContactPhone != ''">
            AND u.emergency_contact_phone like concat('%', #{emergencyContactPhone}, '%')
        </if>
        <if test="emergencyContactRelationship != null and emergencyContactRelationship != ''">
            AND u.emergency_contact_relationship = #{emergencyContactRelationship}
        </if>
        <if test="zodiac != null and zodiac != ''">
            AND u.zodiac = #{zodiac}
        </if>
        <if test="constellation != null and constellation != ''">
            AND u.constellation = #{constellation}
        </if>
        <if test="blooGroup != null and blooGroup != ''">
            AND u.blood_group = #{blooGroup}
        </if>
        <if test="characterCharacteristics != null and characterCharacteristics != ''">
            AND u.character_characteristics = #{characterCharacteristics}
        </if>
        <if test="workingStyle != null and workingStyle != ''">
            AND u.working_style = #{workingStyle}
        </if>
        <if test="teamCooperation != null and teamCooperation != ''">
            AND u.team_cooperation = #{teamCooperation}
        </if>
        <if test="selfAssessmentPersonalityTrait != null and selfAssessmentPersonalityTrait != ''">
            AND u.self_assessment_personality_trait = #{selfAssessmentPersonalityTrait}
        </if>
        <if test="selfAssessmentCapabilityPerformance != null and selfAssessmentCapabilityPerformance != ''">
            AND u.self_assessment_capability_performance = #{selfAssessmentCapabilityPerformance}
        </if>
        <if test="selfAssessmentInterpersonalInteraction != null and selfAssessmentInterpersonalInteraction != ''">
            AND u.self_assessment_interpersonal_interaction = #{selfAssessmentInterpersonalInteraction}
        </if>
        <if test="selfAssessmentGrowthPotential != null and selfAssessmentGrowthPotential != ''">
            AND u.self_assessment_growth_potential = #{selfAssessmentGrowthPotential}
        </if>
        <if test="colleagueCommentsPersonalityTrait != null and colleagueCommentsPersonalityTrait != ''">
            AND u.colleague_comments_personality_trait = #{colleagueCommentsPersonalityTrait}
        </if>
        <if test="colleagueCommentsCapabilityPerformance != null and colleagueCommentsCapabilityPerformance != ''">
            AND u.colleague_comments_capability_performance = #{colleagueCommentsCapabilityPerformance}
        </if>
        <if test="colleagueCommentsInterpersonalInteraction != null and colleagueCommentsInterpersonalInteraction != ''">
            AND u.colleague_comments_interpersonal_interaction = #{colleagueCommentsInterpersonalInteraction}
        </if>
        <if test="colleagueCommentsGrowthPotential != null and colleagueCommentsGrowthPotential != ''">
            AND u.colleague_comments_growth_potential = #{colleagueCommentsGrowthPotential}
        </if>
        <if test="superiorEvaluationPersonalityTrait != null and superiorEvaluationPersonalityTrait != ''">
            AND u.superior_evaluation_personality_trait = #{superiorEvaluationPersonalityTrait}
        </if>
        <if test="superiorEvaluationCapabilityPerformance != null and superiorEvaluationCapabilityPerformance != ''">
            AND u.superior_evaluation_capability_performance = #{superiorEvaluationCapabilityPerformance}
        </if>
        <if test="superiorEvaluationInterpersonalInteraction != null and superiorEvaluationInterpersonalInteraction != ''">
            AND u.superior_evaluation_interpersonal_interaction = #{superiorEvaluationInterpersonalInteraction}
        </if>
        <if test="superiorEvaluationGrowthPotential != null and superiorEvaluationGrowthPotential != ''">
            AND u.superior_evaluation_growth_potential = #{superiorEvaluationGrowthPotential}
        </if>
        <if test="subordinateEvaluationPersonalityTrait != null and subordinateEvaluationPersonalityTrait != ''">
            AND u.subordinate_evaluation_personality_trait = #{subordinateEvaluationPersonalityTrait}
        </if>
        <if test="subordinateEvaluationCapabilityPerformance != null and subordinateEvaluationCapabilityPerformance != ''">
            AND u.subordinate_evaluation_capability_performance = #{subordinateEvaluationCapabilityPerformance}
        </if>
        <if test="subordinateEvaluationInterpersonalInteraction != null and subordinateEvaluationInterpersonalInteraction != ''">
            AND u.subordinate_evaluation_interpersonal_interaction = #{subordinateEvaluationInterpersonalInteraction}
        </if>
        <if test="subordinateEvaluationGrowthPotential != null and subordinateEvaluationGrowthPotential != ''">
            AND u.subordinate_evaluation_growth_potential = #{subordinateEvaluationGrowthPotential}
        </if>
        <if test="schooling != null and schooling != ''">
            AND u.schooling= #{schooling}
        </if>
        <if test="politicalReviewSituation != null and politicalReviewSituation != ''">
            AND u.political_review_situation= #{politicalReviewSituation}
        </if>
        <if test="startWorkingDate != null">
            AND u.start_working_date= #{startWorkingDate}
        </if>
        <if test="securityCheckStartDate != null">
            AND u.security_check_start_date= #{securityCheckStartDate}
        </if>
        <if test="securityInspectionPosition != null and securityInspectionPosition != ''">
            AND u.security_inspection_position= #{securityInspectionPosition}
        </if>
        <if test="workRewardsNumber != null ">
            AND u.work_rewards_number= #{workRewardsNumber}
        </if>
        <if test="workPenaltiesNumber != null">
            AND u.work_penalties_number= #{workPenaltiesNumber}
        </if>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>

    <select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
        select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
        from sys_user u
        left join sys_dept d on u.dept_id = d.dept_id
        left join sys_user_role ur on u.user_id = ur.user_id
        left join sys_role r on r.role_id = ur.role_id
        where u.del_flag = '0' and r.role_id = #{roleId}
        <if test="userName != null and userName != ''">
            AND u.user_name like concat('%', #{userName}, '%')
        </if>
        <if test="phonenumber != null and phonenumber != ''">
            AND u.phonenumber like concat('%', #{phonenumber}, '%')
        </if>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>

    <select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
        select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
        from sys_user u
        left join sys_dept d on u.dept_id = d.dept_id
        left join sys_user_role ur on u.user_id = ur.user_id
        left join sys_role r on r.role_id = ur.role_id
        where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
        and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and
        ur.role_id = #{roleId})
        <if test="userName != null and userName != ''">
            AND u.user_name like concat('%', #{userName}, '%')
        </if>
        <if test="phonenumber != null and phonenumber != ''">
            AND u.phonenumber like concat('%', #{phonenumber}, '%')
        </if>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>

    <select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
        <include refid="selectUserVo"/>
        where u.user_name = #{userName} and u.del_flag = '0'
    </select>

    <select id="selectUserByPhonenumber" parameterType="String" resultMap="SysUserResult">
        <include refid="selectUserVo"/>
        where u.phonenumber = #{phonenumber} and u.del_flag = '0'
    </select>

    <select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
        <include refid="selectUserVo"/>
        where u.user_id = #{userId}
    </select>

    <select id="selectUsersByRoleName" parameterType="String" resultMap="SysUserResult">
        <include refid="selectUserVo"/>
        where u.del_flag = '0' and u.status = '0'
        and exists (
        select 1 from sys_user_role sur
        left join sys_role sr on sur.role_id = sr.role_id
        where sur.user_id = u.user_id
        and sr.role_name = #{roleName}
        and sr.del_flag = '0'
        and sr.status = '0'
        )
    </select>

    <select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
        select user_id, user_name
        from sys_user
        where user_name = #{userName}
          and del_flag = '0' limit 1
    </select>

    <select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
        select user_id, phonenumber
        from sys_user
        where phonenumber = #{phonenumber}
          and del_flag = '0' limit 1
    </select>

    <select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
        select user_id, email
        from sys_user
        where email = #{email}
          and del_flag = '0' limit 1
    </select>

    <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
        insert into sys_user(
        <if test="userId != null and userId != 0">user_id,</if>
        <if test="deptId != null and deptId != 0">dept_id,</if>
        <if test="userName != null and userName != ''">user_name,</if>
        <if test="nickName != null and nickName != ''">nick_name,</if>
        <if test="email != null and email != ''">email,</if>
        <if test="avatar != null and avatar != ''">avatar,</if>
        <if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
        <if test="sex != null and sex != ''">sex,</if>
        <if test="password != null and password != ''">password,</if>
        <if test="status != null and status != ''">status,</if>
        <if test="pwdUpdateDate != null">pwd_update_date,</if>
        <if test="createBy != null and createBy != ''">create_by,</if>
        <if test="remark != null and remark != ''">remark,</if>
        <if test="cardNumber != null and cardNumber != ''">card_number,</if>
        <if test="politicalStatus != null and politicalStatus != ''">political_status,</if>
        <if test="trainingComplianceStatus != null and trainingComplianceStatus != ''">training_compliance_status,</if>
        <if test="qualificationLevel != null and qualificationLevel != ''">qualification_level,</if>
        <if test="administrativeStatus != null and administrativeStatus != ''">administrative_status,</if>
        <if test="physicalHealthStatus != null and physicalHealthStatus != ''">physical_health_status,</if>
        <if test="emergencyContactName != null and emergencyContactName != ''">emergency_contact_name,</if>
        <if test="emergencyContactPhone != null and emergencyContactPhone != ''">emergency_contact_phone,</if>
        <if test="emergencyContactRelationship != null and emergencyContactRelationship != ''">
            emergency_contact_relationship,
        </if>
        <if test="zodiac != null and zodiac != ''">
            zodiac,
        </if>
        <if test="constellation != null and constellation != ''">
            constellation,
        </if>
        <if test="blooGroup != null and blooGroup != ''">
            blood_group,
        </if>
        <if test="characterCharacteristics != null and characterCharacteristics != ''">
            character_characteristics,
        </if>
        <if test="workingStyle != null and workingStyle != ''">
            working_style,
        </if>
        <if test="teamCooperation != null and teamCooperation != ''">
            team_cooperation,
        </if>
        <if test="selfAssessmentPersonalityTrait != null and selfAssessmentPersonalityTrait != ''">
            self_assessment_personality_trait,
        </if>
        <if test="selfAssessmentCapabilityPerformance != null and selfAssessmentCapabilityPerformance != ''">
            self_assessment_capability_performance,
        </if>
        <if test="selfAssessmentInterpersonalInteraction != null and selfAssessmentInterpersonalInteraction != ''">
            self_assessment_interpersonal_interaction,
        </if>
        <if test="selfAssessmentGrowthPotential != null and selfAssessmentGrowthPotential != ''">
            self_assessment_growth_potential,
        </if>
        <if test="colleagueCommentsPersonalityTrait != null and colleagueCommentsPersonalityTrait != ''">
            colleague_comments_personality_trait,
        </if>
        <if test="colleagueCommentsCapabilityPerformance != null and colleagueCommentsCapabilityPerformance != ''">
            colleague_comments_capability_performance,
        </if>
        <if test="colleagueCommentsInterpersonalInteraction != null and colleagueCommentsInterpersonalInteraction != ''">
            colleague_comments_interpersonal_interaction,
        </if>
        <if test="colleagueCommentsGrowthPotential != null and colleagueCommentsGrowthPotential != ''">
            colleague_comments_growth_potential,
        </if>
        <if test="superiorEvaluationPersonalityTrait != null and superiorEvaluationPersonalityTrait != ''">
            superior_evaluation_personality_trait,
        </if>
        <if test="superiorEvaluationCapabilityPerformance != null and superiorEvaluationCapabilityPerformance != ''">
            superior_evaluation_capability_performance,
        </if>
        <if test="superiorEvaluationInterpersonalInteraction != null and superiorEvaluationInterpersonalInteraction != ''">
            superior_evaluation_interpersonal_interaction,
        </if>
        <if test="superiorEvaluationGrowthPotential != null and superiorEvaluationGrowthPotential != ''">
            superior_evaluation_growth_potential,
        </if>
        <if test="subordinateEvaluationPersonalityTrait != null and subordinateEvaluationPersonalityTrait != ''">
            subordinate_evaluation_personality_trait,
        </if>
        <if test="subordinateEvaluationCapabilityPerformance != null and subordinateEvaluationCapabilityPerformance != ''">
            subordinate_evaluation_capability_performance,
        </if>
        <if test="subordinateEvaluationInterpersonalInteraction != null and subordinateEvaluationInterpersonalInteraction != ''">
            subordinate_evaluation_interpersonal_interaction,
        </if>
        <if test="subordinateEvaluationGrowthPotential != null and subordinateEvaluationGrowthPotential != ''">
            subordinate_evaluation_growth_potential,
        </if>
        <if test="schooling != null and schooling != ''">
            schooling,
        </if>
        <if test="politicalReviewSituation != null and politicalReviewSituation != ''">
            political_review_situation,
        </if>
        <if test="startWorkingDate != null">
            start_working_date,
        </if>
        <if test="securityCheckStartDate != null">
            security_check_start_date,
        </if>
        <if test="entryDate != null">
            entry_date,
        </if>
        <if test="xrayOperatorStarttime != null">
            xray_operator_starttime,
        </if>
        <if test="professional != null and professional != ''">
            professional,
        </if>
        <if test="nativePlace != null and nativePlace != ''">
            native_place,
        </if>
        <if test="nation != null and nation != ''">
            nation,
        </if>
        <if test="securityInspectionPosition != null and securityInspectionPosition != ''">
            security_inspection_position,
        </if>
        <if test="workRewardsNumber != null ">
            work_rewards_number,
        </if>
        <if test="workPenaltiesNumber != null">
            work_penalties_number,
        </if>
        create_time
        )values(
        <if test="userId != null and userId != ''">#{userId},</if>
        <if test="deptId != null and deptId != ''">#{deptId},</if>
        <if test="userName != null and userName != ''">#{userName},</if>
        <if test="nickName != null and nickName != ''">#{nickName},</if>
        <if test="email != null and email != ''">#{email},</if>
        <if test="avatar != null and avatar != ''">#{avatar},</if>
        <if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
        <if test="sex != null and sex != ''">#{sex},</if>
        <if test="password != null and password != ''">#{password},</if>
        <if test="status != null and status != ''">#{status},</if>
        <if test="pwdUpdateDate != null">#{pwdUpdateDate},</if>
        <if test="createBy != null and createBy != ''">#{createBy},</if>
        <if test="remark != null and remark != ''">#{remark},</if>
        <if test="cardNumber != null and cardNumber != ''">#{cardNumber},</if>
        <if test="politicalStatus != null and politicalStatus != ''">#{politicalStatus},</if>
        <if test="trainingComplianceStatus != null and trainingComplianceStatus != ''">#{trainingComplianceStatus},</if>
        <if test="qualificationLevel != null and qualificationLevel != ''">#{qualificationLevel},</if>
        <if test="administrativeStatus != null and administrativeStatus != ''">#{administrativeStatus},</if>
        <if test="physicalHealthStatus != null and physicalHealthStatus != ''">#{physicalHealthStatus},</if>
        <if test="emergencyContactName != null and emergencyContactName != ''">#{emergencyContactName},</if>
        <if test="emergencyContactPhone != null and emergencyContactPhone != ''">#{emergencyContactPhone},</if>
        <if test="emergencyContactRelationship != null and emergencyContactRelationship != ''">
            #{emergencyContactRelationship},
        </if>
        <if test="zodiac != null and zodiac != ''">
            #{zodiac},
        </if>
        <if test="constellation != null and constellation != ''">
            #{constellation},
        </if>
        <if test="blooGroup != null and blooGroup != ''">
            #{blooGroup},
        </if>
        <if test="characterCharacteristics != null and characterCharacteristics != ''">
            #{characterCharacteristics},
        </if>
        <if test="workingStyle != null and workingStyle != ''">
            #{workingStyle},
        </if>
        <if test="teamCooperation != null and teamCooperation != ''">
            #{teamCooperation},
        </if>
        <if test="selfAssessmentPersonalityTrait != null and selfAssessmentPersonalityTrait != ''">
            #{selfAssessmentPersonalityTrait},
        </if>
        <if test="selfAssessmentCapabilityPerformance != null and selfAssessmentCapabilityPerformance != ''">
            #{selfAssessmentCapabilityPerformance},
        </if>
        <if test="selfAssessmentInterpersonalInteraction != null and selfAssessmentInterpersonalInteraction != ''">
            #{selfAssessmentInterpersonalInteraction},
        </if>
        <if test="selfAssessmentGrowthPotential != null and selfAssessmentGrowthPotential != ''">
            #{selfAssessmentGrowthPotential},
        </if>
        <if test="colleagueCommentsPersonalityTrait != null and colleagueCommentsPersonalityTrait != ''">
            #{colleagueCommentsPersonalityTrait},
        </if>
        <if test="colleagueCommentsCapabilityPerformance != null and colleagueCommentsCapabilityPerformance != ''">
            #{colleagueCommentsCapabilityPerformance},
        </if>
        <if test="colleagueCommentsInterpersonalInteraction != null and colleagueCommentsInterpersonalInteraction != ''">
            #{colleagueCommentsInterpersonalInteraction},
        </if>
        <if test="colleagueCommentsGrowthPotential != null and colleagueCommentsGrowthPotential != ''">
            #{colleagueCommentsGrowthPotential},
        </if>
        <if test="superiorEvaluationPersonalityTrait != null and superiorEvaluationPersonalityTrait != ''">
            #{superiorEvaluationPersonalityTrait},
        </if>
        <if test="superiorEvaluationCapabilityPerformance != null and superiorEvaluationCapabilityPerformance != ''">
            #{superiorEvaluationCapabilityPerformance},
        </if>
        <if test="superiorEvaluationInterpersonalInteraction != null and superiorEvaluationInterpersonalInteraction != ''">
            #{superiorEvaluationInterpersonalInteraction},
        </if>
        <if test="superiorEvaluationGrowthPotential != null and superiorEvaluationGrowthPotential != ''">
            #{superiorEvaluationGrowthPotential},
        </if>
        <if test="subordinateEvaluationPersonalityTrait != null and subordinateEvaluationPersonalityTrait != ''">
            #{subordinateEvaluationPersonalityTrait},
        </if>
        <if test="subordinateEvaluationCapabilityPerformance != null and subordinateEvaluationCapabilityPerformance != ''">
            #{subordinateEvaluationCapabilityPerformance},
        </if>
        <if test="subordinateEvaluationInterpersonalInteraction != null and subordinateEvaluationInterpersonalInteraction != ''">
            #{subordinateEvaluationInterpersonalInteraction},
        </if>
        <if test="subordinateEvaluationGrowthPotential != null and subordinateEvaluationGrowthPotential != ''">
            #{subordinateEvaluationGrowthPotential},
        </if>
        <if test="schooling != null and schooling != ''">
            #{schooling},
        </if>
        <if test="politicalReviewSituation != null and politicalReviewSituation != ''">
            #{politicalReviewSituation},
        </if>
        <if test="startWorkingDate != null">
            #{startWorkingDate},
        </if>
        <if test="securityCheckStartDate != null">
            #{securityCheckStartDate},
        </if>
        <if test="entryDate != null">
            #{entryDate},
        </if>
        <if test="xrayOperatorStarttime != null">
            #{xrayOperatorStarttime},
        </if>
        <if test="professional != null and professional != ''">
            #{professional},
        </if>
        <if test="nativePlace != null and nativePlace != ''">
            #{nativePlace},
        </if>
        <if test="nation != null and nation != ''">
            #{nation},
        </if>
        <if test="securityInspectionPosition != null and securityInspectionPosition != ''">
            #{securityInspectionPosition},
        </if>
        <if test="workRewardsNumber != null ">
            #{workRewardsNumber},
        </if>
        <if test="workPenaltiesNumber != null">
            #{workPenaltiesNumber},
        </if>
        sysdate()
        )
    </insert>

    <update id="updateUser" parameterType="SysUser">
        update sys_user
        <set>
            <if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
            <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
            <if test="email != null ">email = #{email},</if>
            <if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
            <if test="sex != null and sex != ''">sex = #{sex},</if>
            <if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
            <if test="password != null and password != ''">password = #{password},</if>
            <if test="status != null and status != ''">status = #{status},</if>
            <if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
            <if test="loginDate != null">login_date = #{loginDate},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="cardNumber != null">card_number = #{cardNumber},</if>
            <if test="politicalStatus != null">political_status = #{politicalStatus},</if>
            <if test="trainingComplianceStatus != null">training_compliance_status = #{trainingComplianceStatus},</if>
            <if test="qualificationLevel != null">qualification_level = #{qualificationLevel},</if>
            <if test="administrativeStatus != null">administrative_status = #{administrativeStatus},</if>
            <if test="physicalHealthStatus != null">physical_health_status = #{physicalHealthStatus},</if>
            <if test="emergencyContactName != null">emergency_contact_name = #{emergencyContactName},</if>
            <if test="emergencyContactPhone != null">emergency_contact_phone = #{emergencyContactPhone},</if>
            <if test="emergencyContactRelationship != null">emergency_contact_relationship =
                #{emergencyContactRelationship},
            </if>
            <if test="zodiac != null">
                zodiac = #{zodiac},
            </if>
            <if test="constellation != null">
                constellation = #{constellation},
            </if>
            <if test="blooGroup != null">
                blood_group = #{blooGroup},
            </if>
            <if test="characterCharacteristics != null">
                character_characteristics = #{characterCharacteristics},
            </if>
            <if test="workingStyle != null">
                working_style = #{workingStyle},
            </if>
            <if test="teamCooperation != null">
                team_cooperation = #{teamCooperation},
            </if>
            <if test="selfAssessmentPersonalityTrait != null">
                self_assessment_personality_trait = #{selfAssessmentPersonalityTrait},
            </if>
            <if test="selfAssessmentCapabilityPerformance != null">
                self_assessment_capability_performance = #{selfAssessmentCapabilityPerformance},
            </if>
            <if test="selfAssessmentInterpersonalInteraction != null">
                self_assessment_interpersonal_interaction = #{selfAssessmentInterpersonalInteraction},
            </if>
            <if test="selfAssessmentGrowthPotential != null">
                self_assessment_growth_potential = #{selfAssessmentGrowthPotential},
            </if>
            <if test="colleagueCommentsPersonalityTrait != null">
                colleague_comments_personality_trait = #{colleagueCommentsPersonalityTrait},
            </if>
            <if test="colleagueCommentsCapabilityPerformance != null">
                colleague_comments_capability_performance = #{colleagueCommentsCapabilityPerformance},
            </if>
            <if test="colleagueCommentsInterpersonalInteraction != null">
                colleague_comments_interpersonal_interaction = #{colleagueCommentsInterpersonalInteraction},
            </if>
            <if test="colleagueCommentsGrowthPotential != null">
                colleague_comments_growth_potential = #{colleagueCommentsGrowthPotential},
            </if>
            <if test="superiorEvaluationPersonalityTrait != null">
                superior_evaluation_personality_trait = #{superiorEvaluationPersonalityTrait},
            </if>
            <if test="superiorEvaluationCapabilityPerformance != null">
                superior_evaluation_capability_performance = #{superiorEvaluationCapabilityPerformance},
            </if>
            <if test="superiorEvaluationInterpersonalInteraction != null">
                superior_evaluation_interpersonal_interaction = #{superiorEvaluationInterpersonalInteraction},
            </if>
            <if test="superiorEvaluationGrowthPotential != null">
                superior_evaluation_growth_potential = #{superiorEvaluationGrowthPotential},
            </if>
            <if test="subordinateEvaluationPersonalityTrait != null">
                subordinate_evaluation_personality_trait = #{subordinateEvaluationPersonalityTrait},
            </if>
            <if test="subordinateEvaluationCapabilityPerformance != null">
                subordinate_evaluation_capability_performance = #{subordinateEvaluationCapabilityPerformance},
            </if>
            <if test="subordinateEvaluationInterpersonalInteraction != null">
                subordinate_evaluation_interpersonal_interaction = #{subordinateEvaluationInterpersonalInteraction},
            </if>
            <if test="subordinateEvaluationGrowthPotential != null">
                subordinate_evaluation_growth_potential = #{subordinateEvaluationGrowthPotential},
            </if>
            <if test="schooling != null and schooling != ''">
                schooling = #{schooling},
            </if>
            <if test="politicalReviewSituation != null and politicalReviewSituation!='' ">
                political_review_situation = #{politicalReviewSituation},
            </if>
            <if test="startWorkingDate != null  ">
                start_working_date = #{startWorkingDate},
            </if>
            <if test="securityCheckStartDate != null ">
                security_check_start_date = #{securityCheckStartDate},
            </if>
            <if test="entryDate != null">
                entry_date = #{entryDate},
            </if>
            <if test="xrayOperatorStarttime != null">
                xray_operator_starttime = #{xrayOperatorStarttime},
            </if>
            <if test="professional != null and professional != ''">
                professional = #{professional},
            </if>
            <if test="nativePlace != null and nativePlace != ''">
                native_place = #{nativePlace},
            </if>
            <if test="nation != null and nation != ''">
                nation = #{nation},
            </if>
            <if test="securityInspectionPosition != null and securityInspectionPosition!='' ">
                security_inspection_position = #{securityInspectionPosition},
            </if>
            <if test="workRewardsNumber != null ">
                work_rewards_number = #{workRewardsNumber},
            </if>
            <if test="workPenaltiesNumber != null ">
                work_penalties_number = #{workPenaltiesNumber},
            </if>
            update_time = sysdate()
        </set>
        where user_id = #{userId}
    </update>

    <update id="updateUserStatus" parameterType="SysUser">
        update sys_user
        set status = #{status}
        where user_id = #{userId}
    </update>

    <update id="updateUserAvatar" parameterType="SysUser">
        update sys_user
        set avatar = #{avatar}
        where user_id = #{userId}
    </update>

    <update id="resetUserPwd" parameterType="SysUser">
        update sys_user
        set pwd_update_date = sysdate(),
            password        = #{password}
        where user_id = #{userId}
    </update>

    <delete id="deleteUserById" parameterType="Long">
        update sys_user
        set del_flag = '2'
        where user_id = #{userId}
    </delete>

    <delete id="deleteUserByIds" parameterType="Long">
        update sys_user set del_flag = '2' where user_id in
        <foreach collection="array" item="userId" open="(" separator="," close=")">
            #{userId}
        </foreach>
    </delete>

    <select id="selectUsersByRoleKey" parameterType="String" resultMap="SysUserResult">
        select distinct u.user_id,
                        u.dept_id,
                        u.user_name,
                        u.nick_name,
                        u.email,
                        u.avatar,
                        u.phonenumber,
                        u.password,
                        u.sex,
                        u.status,
                        u.del_flag,
                        u.login_ip,
                        u.login_date,
                        u.pwd_update_date,
                        u.create_by,
                        u.create_time,
                        u.remark,
                        u.card_number,
                        u.political_status,
                        u.training_compliance_status,
                        u.qualification_level,
                        u.administrative_status,
                        u.physical_health_status,
                        u.emergency_contact_name,
                        u.emergency_contact_phone,
                        u.emergency_contact_relationship,
                        d.dept_id,
                        d.parent_id,
                        d.ancestors,
                        d.dept_name,
                        d.order_num,
                        d.leader,
                        d.status as dept_status
        from sys_user u
                 left join sys_dept d on u.dept_id = d.dept_id
                 left join sys_user_role ur on u.user_id = ur.user_id
                 left join sys_role r on ur.role_id = r.role_id
        where u.del_flag = '0'
          and u.status = '0'
          and r.status = '0'
          and r.role_key = #{roleKey}
    </select>

    <select id="selectUsersByDeptId" parameterType="Long" resultMap="SysUserResult">
        select u.user_id,
               u.dept_id,
               u.user_name,
               u.nick_name,
               u.email,
               u.avatar,
               u.phonenumber,
               u.password,
               u.sex,
               u.status,
               u.del_flag,
               u.login_ip,
               u.login_date,
               u.pwd_update_date,
               u.create_by,
               u.create_time,
               u.remark,
               u.card_number,
               u.political_status,
               u.training_compliance_status,
               u.qualification_level,
               u.administrative_status,
               u.physical_health_status,
               u.emergency_contact_name,
               u.emergency_contact_phone,
               u.emergency_contact_relationship,
               d.dept_id,
               d.parent_id,
               d.ancestors,
               d.dept_name,
               d.order_num,
               d.leader,
               d.status as dept_status
        from sys_user u
                 left join sys_dept d on u.dept_id = d.dept_id
        where u.del_flag = '0'
          and u.status = '0'
          and u.dept_id = #{deptId}
    </select>

    <select id="selectAttendanceTeamLeaderId" resultType="Long">
        select *
        from sys_user u
        left join sys_dept d on u.dept_id = d.dept_id
        left join sys_user_role sur on sur.user_id =u.user_id
        left join sys_role sr on sr.role_id =sur.role_id
        where u.del_flag = '0' and u.status = '0'
        and sr.del_flag ='0' and sr.status ='0'
        and sr.role_key ='banzuzhang'
        <if test="collect != null and collect.size() > 0">
            AND u.dept_id IN
            <foreach collection="collect" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
    </select>

    <select id="selectBzzAndAjy" resultType="Long">
        select distinct su.user_id
        from sys_user su
                 inner join sys_user_role sur on sur.user_id = su.user_id
                 inner join sys_role sr on sr.role_id = sur.role_id
        where su.del_flag = '0'
          and su.status = '0'
          and sr.del_flag = '0'
          and sr.status = '0'
          and sr.role_key in ('banzuzhang', 'SecurityCheck')
    </select>

    <select id="selectUserListByRoleKey" resultMap="SysUserResult">
        select distinct su.user_id,
        su.user_name,
        su.nick_name
        from sys_user su
        inner join sys_user_role sur on sur.user_id = su.user_id
        inner join sys_role sr on sr.role_id = sur.role_id
        where 1 = 1
        and su.del_flag = '0'
        and su.status = '0'
        and sr.del_flag = '0'
        and sr.status = '0'
        and sr.role_key in
        <foreach collection="list" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>

    <select id="selectUserByDeptId" resultMap="SysUserResult">
        <include refid="selectUserVo"/>
        where (u.dept_id = #{deptId} OR u.dept_id IN (
        SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors)))
        and u.del_flag = '0'
    </select>

    <select id="selectByUserIdList" resultMap="SysUserResult">
        <include refid="selectUserVo"/>
        where u.del_flag = '0'
        and u.user_id in
        <foreach collection="list" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>

    <select id="selectUserAll" resultMap="SysUserResult">
        <include refid="selectUserVo"/>
        where u.del_flag = '0'
    </select>


    <select id="selectUserListByRoleKeyAndDeptId" resultMap="SysUserResult">
        select distinct su.user_id,
        su.user_name,
        su.nick_name,
        su.dept_id,
        d.dept_id,
        d.parent_id,
        d.ancestors,
        d.dept_name,
        d.order_num,
        d.leader,
        d.status as dept_status,
        d.dept_type,
        d.dept_type_desc
        from sys_user su
        left join sys_dept d on su.dept_id = d.dept_id
        inner join sys_user_role sur on sur.user_id = su.user_id
        inner join sys_role sr on sr.role_id = sur.role_id
        where 1 = 1
        and su.del_flag = '0'
        and su.status = '0'
        and sr.del_flag = '0'
        and sr.status = '0'
        and (su.dept_id = #{deptId} OR d.parent_id = #{deptId} OR d.ancestors like concat('%,', #{deptId}, ',%') OR
        d.ancestors like concat(#{deptId}, ',%') OR d.ancestors like concat('%,', #{deptId}))
        and sr.role_key in
        <foreach collection="list" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>

    <select id="selectUserByDeptIdAndRoleKeyList" resultMap="SysUserResult">
        <include refid="selectUserVo"/>
        where (u.dept_id = #{deptId} OR u.dept_id IN (
        SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors)))
        and u.del_flag = '0'
        and r.role_key in
        <foreach collection="list" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>

    <select id="selectUserListByDeptIdAndRoleKeyListAndUserName" resultMap="SysUserResult">
        <include refid="selectUserVo"/>
        where (u.dept_id = #{deptId} OR u.dept_id IN (
        SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors)))
        and u.del_flag = '0'
        <if test="list != null and list.size() > 0">
            and r.role_key in
            <foreach collection="list" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="nickName != null and nickName != ''">
            and u.nick_name like concat('%', #{nickName}, '%')
        </if>
    </select>

    <select id="homePageUserInfo" resultType="com.sundot.airport.common.core.domain.LargeScreenHomePageUserInfoSqlDto">
        select su.user_id      userId,
               su.user_name    userName,
               su.nick_name    nickName,
               sd_bz.dept_id   teamId,
               sd_bz.dept_name teamName,
               sd_ks.dept_id   departmentId,
               sd_ks.dept_name departmentName,
               sd_dd.dept_id   brigadeId,
               sd_dd.dept_name brigadeName,
               sd_zj.dept_id   stationId,
               sd_zj.dept_name stationName
        from sys_user su
                 inner join sys_user_role sur on sur.user_id = su.user_id
                 inner join sys_role sr on sr.role_id = sur.role_id
                 inner join sys_dept sd_bz on sd_bz.dept_id = su.dept_id
                 inner join sys_dept sd_ks on sd_ks.dept_id = sd_bz.parent_id
                 inner join sys_dept sd_dd on sd_dd.dept_id = sd_ks.parent_id
                 inner join sys_dept sd_zj on sd_zj.dept_id = sd_dd.parent_id
        where 1 = 1
          and sr.role_key in ('banzuzhang', 'SecurityCheck')
    </select>

    <select id="homePageUserInfoByBrigadeId"
            resultType="com.sundot.airport.common.core.domain.LargeScreenHomePageUserInfoSqlDto">
        select su.user_id      userId,
               su.user_name    userName,
               su.nick_name    nickName,
               sd_bz.dept_id   teamId,
               sd_bz.dept_name teamName,
               sd_ks.dept_id   departmentId,
               sd_ks.dept_name departmentName,
               sd_dd.dept_id   brigadeId,
               sd_dd.dept_name brigadeName,
               sd_zj.dept_id   stationId,
               sd_zj.dept_name stationName
        from sys_user su
                 inner join sys_user_role sur on sur.user_id = su.user_id
                 inner join sys_role sr on sr.role_id = sur.role_id
                 inner join sys_dept sd_bz on sd_bz.dept_id = su.dept_id
                 inner join sys_dept sd_ks on sd_ks.dept_id = sd_bz.parent_id
                 inner join sys_dept sd_dd on sd_dd.dept_id = sd_ks.parent_id
                 inner join sys_dept sd_zj on sd_zj.dept_id = sd_dd.parent_id
        where 1 = 1
          and sr.role_key in ('banzuzhang', 'SecurityCheck')
          and sd_dd.dept_id = #{brigadeId}
    </select>

    <select id="homePageUserInfoByDepartmentId"
            resultType="com.sundot.airport.common.core.domain.LargeScreenHomePageUserInfoSqlDto">
        select su.user_id      userId,
               su.user_name    userName,
               su.nick_name    nickName,
               sd_bz.dept_id   teamId,
               sd_bz.dept_name teamName,
               sd_ks.dept_id   departmentId,
               sd_ks.dept_name departmentName,
               sd_dd.dept_id   brigadeId,
               sd_dd.dept_name brigadeName,
               sd_zj.dept_id   stationId,
               sd_zj.dept_name stationName
        from sys_user su
                 inner join sys_user_role sur on sur.user_id = su.user_id
                 inner join sys_role sr on sr.role_id = sur.role_id
                 inner join sys_dept sd_bz on sd_bz.dept_id = su.dept_id
                 inner join sys_dept sd_ks on sd_ks.dept_id = sd_bz.parent_id
                 inner join sys_dept sd_dd on sd_dd.dept_id = sd_ks.parent_id
                 inner join sys_dept sd_zj on sd_zj.dept_id = sd_dd.parent_id
        where 1 = 1
          and sr.role_key in ('banzuzhang', 'SecurityCheck')
          and sd_ks.dept_id = #{departmentId}
    </select>
</mapper>