<?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="cn.com.countrygarden.bi.main.dao.personnel.PersonnelAssessmentemporaryMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.com.countrygarden.bi.main.model.personnel.PersonnelAssessmentemporary">
                                    <id column="id" property="id" />
                                                <result column="user_id" property="userId" />
                                                <result column="user_name" property="userName" />
                                                <result column="identity" property="identity" />
                                                <result column="grade_id" property="gradeId" />
                                                <result column="name" property="name" />
                                                <result column="tel" property="tel" />
                                                <result column="addition_time" property="additionTime" />
                                                <result column="created_date" property="createdDate" />
                                                <result column="created_by" property="createdBy" />
                                                <result column="updated_date" property="updatedDate" />
                                                <result column="updated_by" property="updatedBy" />
      </resultMap>
       <sql id="sqlcoue">      
          <if test="userquyu!=null">
          and 
          (<foreach collection="userquyu" item="userquyu"
						index="index" separator="or">
		     (t.Four_tissue like concat('%',#{userquyu},'%') or doc.PK_ORG  like concat('%',#{userquyu},'%'))
		    </foreach>)
		         <!-- <if test="rolesMap.identitys!=null">
		                   or ps.identity in
					<foreach collection="rolesMap.identitys" item="identitys"
						index="index" open="(" close=")" separator=",">
						#{identitys}
					</foreach>
		          </if> -->
						
		</if> 		
		 <if test="rolesMap.identitys!=null">
					and ps.identity in
					<foreach collection="rolesMap.identitys" item="identitys"
						index="index" open="(" close=")" separator=",">
						#{identitys}
					</foreach>
			</if>   
     
     </sql>
     
      
      <delete id="delcreatedby" parameterType="java.lang.String">
             delete from personnel_assessmentemporary where created_by=#{createdBy};
                                  
      </delete>
      
      <select id="listemporaryper" resultType="cn.com.countrygarden.bi.main.model.personnel.PersonnelAssessmentemporary" parameterType="java.lang.String">
             <!-- select distinct user_id as userId,user_name as userName from personnel_assessmentemporary -->
             select distinct ps.user_id as userId,ps.user_name as userName from personnel_assessmentemporary ps
             left join  performance_app.bd_psndoc doc on ps.user_id=doc.`CODE`
             left join  (select distinct Four_tissue,pk_org from performance_app.bd_type) t on t.pk_org=doc.PK_ORG 
             <where>
             <include refid="sqlcoue"/> 
              <if test="search != null and search != ''">
                   and ( ps.user_name like concat('%', #{search}, '%') or ps.user_id = #{search} )
              </if> 
              
               <!-- rolesMap.role!=null没有相应的角色 -->
		<if test=" rolesMap.role!=null">
			and ps.user_id=-1
		</if>
		
		<!-- rolesMap.gj_admin！=null管理员，有所有权限 -->
		<!-- <if test="rolesMap.gj_admin==null and rolesMap.role==null">
			rolesMap.gj_Area！=null区域管理员，只能查看登录账号区域的下的数据
			<if test="rolesMap.gj_Area!=null">
				and doc.code = #{rolesMap.gj_Area}
				 <if test="rolesMap.identitys!=null">
					or pg.identity in
					<foreach collection="rolesMap.identitys" item="identitys"
						index="index" open="(" close=")" separator=",">
						#{identitys}
					</foreach>
			</if>

			 <if test="rolesMap.gj_Area==null">
				<if test="rolesMap.identitys!=null">
					and pg.identity in
					<foreach collection="rolesMap.identitys" item="identitys"
						index="index" open="(" close=")" separator=",">
						#{identitys}
					</foreach>
				</if>
			</if> 
			
		</if>  -->
     </where> 
      </select>
      
      <select id="getlist" resultType="cn.com.countrygarden.bi.main.model.personnel.PersonnelAssessmentemporary" parameterType="java.lang.String">
             select id as id,user_id as userId,user_name as userName,identity as identity,grade_id as gradeId,`name` as name,
             tel as tel,created_date as createdDate,created_by as createdBy from personnel_assessmentemporary
             where 1=1    
             
              <if test="search != null and search != ''">
                  and user_id = #{search}
              </if>
      
          <!-- rolesMap.role!=null没有相应的角色 -->
		<if test=" rolesMap.role!=null">
			and id=-1
		</if>
		<!-- rolesMap.gj_admin！=null管理员，有所有权限 -->
		<!-- <if test="rolesMap.gj_admin==null and rolesMap.role==null">
			rolesMap.gj_Area！=null区域管理员，只能查看登录账号区域的下的数据
			<if test="rolesMap.gj_Area!=null">
				and doc.code = #{rolesMap.gj_Area}
				 <if test="rolesMap.identitys!=null">
					or pg.identity in
					<foreach collection="rolesMap.identitys" item="identitys"
						index="index" open="(" close=")" separator=",">
						#{identitys}
					</foreach>
			</if>

			 <if test="rolesMap.gj_Area==null">
				<if test="rolesMap.identitys!=null">
					and pg.identity in
					<foreach collection="rolesMap.identitys" item="identitys"
						index="index" open="(" close=")" separator=",">
						#{identitys}
					</foreach>
				</if>
			</if> 
			
		</if>  -->
      </select>


</mapper>