| <?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="doumeemes.dao.ext.PlanImportExtMapper"> | 
|   | 
|   <!-- 管理页面查询 --> | 
|   <resultMap id="PlanImportExtListVO" type="doumeemes.dao.ext.vo.PlanImportExtListVO" autoMapping="true"> | 
|     <id column="ID" jdbcType="INTEGER" property="id"/> | 
|     <association property="dmodel" javaType="doumeemes.dao.business.model.Department"> | 
|       <id column="DMODEL_ID" jdbcType="INTEGER" property="id"/> | 
|       <result column="DMODEL_DELETED" jdbcType="TINYINT" property="deleted"/> | 
|       <result column="DMODEL_CREATE_USER" jdbcType="INTEGER" property="createUser"/> | 
|       <result column="DMODEL_CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/> | 
|       <result column="DMODEL_UPDATE_USER" jdbcType="INTEGER" property="updateUser"/> | 
|       <result column="DMODEL_UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/> | 
|       <result column="DMODEL_NAME" jdbcType="VARCHAR" property="name"/> | 
|       <result column="DMODEL_REMARK" jdbcType="VARCHAR" property="remark"/> | 
|       <result column="DMODEL_ROOT_ID" jdbcType="INTEGER" property="rootId"/> | 
|       <result column="DMODEL_PARENT_ID" jdbcType="INTEGER" property="parentId"/> | 
|       <result column="DMODEL_COMPANY_ID" jdbcType="INTEGER" property="companyId"/> | 
|       <result column="DMODEL_TYPE" jdbcType="TINYINT" property="type"/> | 
|       <result column="DMODEL_ERP_ID" jdbcType="VARCHAR" property="erpId"/> | 
|       <result column="DMODEL_STATUS" jdbcType="INTEGER" property="status"/> | 
|       <result column="DMODEL_VALID_TIME" jdbcType="TIMESTAMP" property="validTime"/> | 
|       <result column="DMODEL_INVALID_TIME" jdbcType="TIMESTAMP" property="invalidTime"/> | 
|     </association> | 
|   | 
|     <association property="umodel" javaType="doumeemes.dao.system.model.SystemUser"> | 
|       <id column="UMODEL_ID" jdbcType="INTEGER" property="id"/> | 
|       <result column="UMODEL_DELETED" jdbcType="TINYINT" property="deleted"/> | 
|       <result column="UMODEL_CREATE_USER" jdbcType="INTEGER" property="createUser"/> | 
|       <result column="UMODEL_CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/> | 
|       <result column="UMODEL_UPDATE_USER" jdbcType="INTEGER" property="updateUser"/> | 
|       <result column="UMODEL_UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/> | 
|       <result column="UMODEL_FIXED" jdbcType="TINYINT" property="fixed"/> | 
|       <result column="UMODEL_PASSWORD" jdbcType="VARCHAR" property="password"/> | 
|       <result column="UMODEL_SALT" jdbcType="VARCHAR" property="salt"/> | 
|       <result column="UMODEL_AVATAR" jdbcType="VARCHAR" property="avatar"/> | 
|       <result column="UMODEL_MOBILE" jdbcType="VARCHAR" property="mobile"/> | 
|       <result column="UMODEL_EMAIL" jdbcType="VARCHAR" property="email"/> | 
|       <result column="UMODEL_SEX" jdbcType="VARCHAR" property="sex"/> | 
|       <result column="UMODEL_BIRTHDAY" jdbcType="DATE" property="birthday"/> | 
|       <result column="UMODEL_EMP_NO" jdbcType="VARCHAR" property="empNo"/> | 
|       <result column="UMODEL_REALNAME" jdbcType="VARCHAR" property="realname"/> | 
|       <result column="UMODEL_USERNAME" jdbcType="VARCHAR" property="username"/> | 
|       <result column="UMODEL_SYSTEMID" jdbcType="VARCHAR" property="systemid"/> | 
|       <result column="UMODEL_INVALID_TIME" jdbcType="TIMESTAMP" property="invalidTime"/> | 
|       <result column="UMODEL_TYPE" jdbcType="INTEGER" property="type"/> | 
|     </association> | 
|   </resultMap> | 
|   <select id="selectList" parameterType="doumeemes.dao.ext.dto.QueryPlanImportExtDTO" resultMap="PlanImportExtListVO"> | 
|     SELECT | 
|       `planImport`.`ID`, | 
|       `planImport`.`DELETED`, | 
|       `planImport`.`CREATE_USER`, | 
|       `planImport`.`CREATE_TIME`, | 
|       `planImport`.`UPDATE_USER`, | 
|       `planImport`.`UPDATE_TIME`, | 
|       `planImport`.`REMARK`, | 
|       `planImport`.`ROOT_DEPART_ID`, | 
|       `planImport`.`DEPART_ID`, | 
|       `planImport`.`FILE_URL`, | 
|       `planImport`.`STATUS`, | 
|       `planImport`.`FILE_NAME`, | 
|       `dmodel`.`ID` AS DMODEL_ID, | 
|       `dmodel`.`DELETED` AS DMODEL_DELETED, | 
|       `dmodel`.`CREATE_USER` AS DMODEL_CREATE_USER, | 
|       `dmodel`.`CREATE_TIME` AS DMODEL_CREATE_TIME, | 
|       `dmodel`.`UPDATE_USER` AS DMODEL_UPDATE_USER, | 
|       `dmodel`.`UPDATE_TIME` AS DMODEL_UPDATE_TIME, | 
|       `dmodel`.`NAME` AS DMODEL_NAME, | 
|       `dmodel`.`REMARK` AS DMODEL_REMARK, | 
|       `dmodel`.`ROOT_ID` AS DMODEL_ROOT_ID, | 
|       `dmodel`.`PARENT_ID` AS DMODEL_PARENT_ID, | 
|       `dmodel`.`COMPANY_ID` AS DMODEL_COMPANY_ID, | 
|       `dmodel`.`TYPE` AS DMODEL_TYPE, | 
|       `dmodel`.`ERP_ID` AS DMODEL_ERP_ID, | 
|       `dmodel`.`STATUS` AS DMODEL_STATUS, | 
|       `dmodel`.`VALID_TIME` AS DMODEL_VALID_TIME, | 
|       `dmodel`.`INVALID_TIME` AS DMODEL_INVALID_TIME, | 
|     `umodel`.`REALNAME` AS UMODEL_REALNAME, | 
|     `umodel`.`USERNAME` AS UMODEL_USERNAME | 
|     FROM `plan_import` `planImport` | 
|     LEFT JOIN `department` `dmodel` ON planImport.DEPART_ID=dmodel.ID | 
|     LEFT JOIN `system_user` `umodel` ON planImport.CREATE_USER=umodel.ID | 
|     <where> | 
|       <if test="id != null"> | 
|         AND `planImport`.`ID` = #{id} | 
|       </if> | 
|       <if test="deleted != null"> | 
|         AND `planImport`.`DELETED` = #{deleted} | 
|       </if> | 
|      <!-- <if test="createUser != null"> | 
|         AND `planImport`.`CREATE_USER` = #{createUser} | 
|       </if>--> | 
|       <if test="createTime != null"> | 
|         AND `planImport`.`CREATE_TIME` = #{createTime} | 
|       </if> | 
|       <if test="updateUser != null"> | 
|         AND `planImport`.`UPDATE_USER` = #{updateUser} | 
|       </if> | 
|       <if test="updateTime != null"> | 
|         AND `planImport`.`UPDATE_TIME` = #{updateTime} | 
|       </if> | 
|       <if test="remark != null and remark != ''"> | 
|         AND `planImport`.`REMARK` = #{remark} | 
|       </if> | 
|       <if test="rootDepartId != null"> | 
|         AND `planImport`.`ROOT_DEPART_ID` = #{rootDepartId} | 
|       </if> | 
|       <if test="departId != null"> | 
|         AND `planImport`.`DEPART_ID` = #{departId} | 
|       </if> | 
|       <if test="fileUrl != null"> | 
|         AND `planImport`.`FILE_URL` = #{fileUrl} | 
|       </if> | 
|       <if test="status != null"> | 
|         AND `planImport`.`STATUS` = #{status} | 
|       </if> | 
|       <if test="fileName != null and fileName != ''"> | 
|         AND `planImport`.`FILE_NAME` = #{fileName} | 
|       </if> | 
|       <if test="dmodelId != null"> | 
|         AND `dmodel`.`ID` = #{dmodelId} | 
|       </if> | 
|       <if test="dmodelDeleted != null"> | 
|         AND `dmodel`.`DELETED` = #{dmodelDeleted} | 
|       </if> | 
|       <if test="dmodelCreateUser != null"> | 
|         AND `dmodel`.`CREATE_USER` = #{dmodelCreateUser} | 
|       </if> | 
|       <if test="dmodelCreateTime != null"> | 
|         AND `dmodel`.`CREATE_TIME` = #{dmodelCreateTime} | 
|       </if> | 
|       <if test="dmodelUpdateUser != null"> | 
|         AND `dmodel`.`UPDATE_USER` = #{dmodelUpdateUser} | 
|       </if> | 
|       <if test="dmodelUpdateTime != null"> | 
|         AND `dmodel`.`UPDATE_TIME` = #{dmodelUpdateTime} | 
|       </if> | 
|       <if test="dmodelName != null and dmodelName != ''"> | 
|         AND `dmodel`.`NAME` = #{dmodelName} | 
|       </if> | 
|       <if test="dmodelRemark != null and dmodelRemark != ''"> | 
|         AND `dmodel`.`REMARK` = #{dmodelRemark} | 
|       </if> | 
|       <if test="dmodelRootId != null"> | 
|         AND `dmodel`.`ROOT_ID` = #{dmodelRootId} | 
|       </if> | 
|       <if test="dmodelParentId != null"> | 
|         AND `dmodel`.`PARENT_ID` = #{dmodelParentId} | 
|       </if> | 
|       <if test="dmodelCompanyId != null"> | 
|         AND `dmodel`.`COMPANY_ID` = #{dmodelCompanyId} | 
|       </if> | 
|       <if test="dmodelType != null"> | 
|         AND `dmodel`.`TYPE` = #{dmodelType} | 
|       </if> | 
|       <if test="dmodelErpId != null and dmodelErpId != ''"> | 
|         AND `dmodel`.`ERP_ID` = #{dmodelErpId} | 
|       </if> | 
|       <if test="dmodelStatus != null"> | 
|         AND `dmodel`.`STATUS` = #{dmodelStatus} | 
|       </if> | 
|       <if test="dmodelValidTime != null"> | 
|         AND `dmodel`.`VALID_TIME` = #{dmodelValidTime} | 
|       </if> | 
|       <if test="dmodelInvalidTime != null"> | 
|         AND `dmodel`.`INVALID_TIME` = #{dmodelInvalidTime} | 
|       </if> | 
|   | 
|       <choose> | 
|       <when test="departIds != null and departIds.size()>0"> | 
|         AND (exists (select d.id from company_user d where d.user_id= `planImport`.`CREATE_USER` and d.department_id | 
|         in <foreach collection="departIds" item="item" separator="," open="(" close=")">#{item}</foreach>) | 
|         or `planImport`.`CREATE_USER` = #{createUser} | 
|         ) | 
|       </when> | 
|     <otherwise> | 
|       <if test="createUser != null"> | 
|         and   `planImport`.`CREATE_USER` = #{createUser} | 
|       </if> | 
|     </otherwise> | 
|       </choose> | 
|   | 
|   | 
|     </where> | 
| order by `planImport`.`CREATE_TIME` desc | 
|   </select> | 
| </mapper> |