| <?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.WarehouseLocationExtMapper"> | 
|   | 
|   <!-- 管理页面查询 --> | 
|   <resultMap id="WarehouseLocationExtListVO" type="doumeemes.dao.ext.vo.WarehouseLocationExtListVO" autoMapping="true"> | 
|     <id column="ID" jdbcType="INTEGER" property="id"/> | 
|     <association property="wmodel" javaType="doumeemes.dao.business.model.Warehouse"> | 
|       <id column="WMODEL_ID" jdbcType="INTEGER" property="id"/> | 
|       <result column="WMODEL_DELETED" jdbcType="TINYINT" property="deleted"/> | 
|       <result column="WMODEL_CREATE_USER" jdbcType="INTEGER" property="createUser"/> | 
|       <result column="WMODEL_CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/> | 
|       <result column="WMODEL_UPDATE_USER" jdbcType="INTEGER" property="updateUser"/> | 
|       <result column="WMODEL_UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/> | 
|       <result column="WMODEL_REMARK" jdbcType="VARCHAR" property="remark"/> | 
|       <result column="WMODEL_ROOT_DEPART_ID" jdbcType="INTEGER" property="rootDepartId"/> | 
|       <result column="WMODEL_DEPART_ID" jdbcType="INTEGER" property="departId"/> | 
|       <result column="WMODEL_PROCEDURE_ID" jdbcType="INTEGER" property="procedureId"/> | 
|       <result column="WMODEL_QRCODE" jdbcType="INTEGER" property="qrcode"/> | 
|       <result column="WMODEL_NAME" jdbcType="VARCHAR" property="name"/> | 
|       <result column="WMODEL_USE_LOCATION" jdbcType="TINYINT" property="useLocation"/> | 
|       <result column="WMODEL_STATUS" jdbcType="TINYINT" property="status"/> | 
|       <result column="WMODEL_ADDR" jdbcType="VARCHAR" property="addr"/> | 
|       <result column="WMODEL_MANAGER_ID" jdbcType="INTEGER" property="managerId"/> | 
|       <result column="WMODEL_TYPE" jdbcType="INTEGER" property="type"/> | 
|       <result column="WMODEL_CODE" jdbcType="VARCHAR" property="code"/> | 
|     </association> | 
|     <association property="tmodel" javaType="doumeemes.dao.system.model.SystemDictData"> | 
|       <id column="TMODEL_ID" jdbcType="INTEGER" property="id"/> | 
|       <result column="TMODEL_DELETED" jdbcType="TINYINT" property="deleted"/> | 
|       <result column="TMODEL_CREATE_USER" jdbcType="INTEGER" property="createUser"/> | 
|       <result column="TMODEL_CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/> | 
|       <result column="TMODEL_UPDATE_USER" jdbcType="INTEGER" property="updateUser"/> | 
|       <result column="TMODEL_UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/> | 
|       <result column="TMODEL_DICT_ID" jdbcType="INTEGER" property="dictId"/> | 
|       <result column="TMODEL_CODE" jdbcType="LONGVARCHAR" property="code"/> | 
|       <result column="TMODEL_LABEL" jdbcType="VARCHAR" property="label"/> | 
|       <result column="TMODEL_SORT" jdbcType="INTEGER" property="sort"/> | 
|       <result column="TMODEL_DISABLED" jdbcType="INTEGER" property="disabled"/> | 
|     </association> | 
|   </resultMap> | 
|   <select id="selectList" parameterType="doumeemes.dao.ext.dto.QueryWarehouseLocationExtDTO" resultMap="WarehouseLocationExtListVO"> | 
|     SELECT | 
|       `a`.`ID`, | 
|       `a`.`DELETED`, | 
|       `a`.`CREATE_USER`, | 
|       `a`.`CREATE_TIME`, | 
|       `a`.`UPDATE_USER`, | 
|       `a`.`UPDATE_TIME`, | 
|       `a`.`REMARK`, | 
|       `a`.`ROOT_DEPART_ID`, | 
|       `a`.`WAREHOUSE_ID`, | 
|       `a`.`UNION_NAME`, | 
|       `a`.`AREA`, | 
|       `a`.`SHELF`, | 
|       `a`.`CELL`, | 
|       `a`.`QRCODE`, | 
|       `a`.`STATUS`, | 
|       `a`.`CODE`, | 
|     a.SYSTEM_DIC_DATA_ID, | 
|       `wmodel`.`ID` AS WMODEL_ID, | 
|       `wmodel`.`DELETED` AS WMODEL_DELETED, | 
|       `wmodel`.`CREATE_USER` AS WMODEL_CREATE_USER, | 
|       `wmodel`.`CREATE_TIME` AS WMODEL_CREATE_TIME, | 
|       `wmodel`.`UPDATE_USER` AS WMODEL_UPDATE_USER, | 
|       `wmodel`.`UPDATE_TIME` AS WMODEL_UPDATE_TIME, | 
|       `wmodel`.`REMARK` AS WMODEL_REMARK, | 
|       `wmodel`.`ROOT_DEPART_ID` AS WMODEL_ROOT_DEPART_ID, | 
|       `wmodel`.`DEPART_ID` AS WMODEL_DEPART_ID, | 
|       `wmodel`.`PROCEDURE_ID` AS WMODEL_PROCEDURE_ID, | 
|       `wmodel`.`QRCODE` AS WMODEL_QRCODE, | 
|       `wmodel`.`NAME` AS WMODEL_NAME, | 
|       `wmodel`.`USE_LOCATION` AS WMODEL_USE_LOCATION, | 
|       `wmodel`.`STATUS` AS WMODEL_STATUS, | 
|       `wmodel`.`ADDR` AS WMODEL_ADDR, | 
|       `wmodel`.`MANAGER_ID` AS WMODEL_MANAGER_ID, | 
|       `wmodel`.`TYPE` AS WMODEL_TYPE, | 
|       `wmodel`.`CODE` AS WMODEL_CODE, | 
|     `tmodel`.`ID` AS TMODEL_ID, | 
|     `tmodel`.`DELETED` AS TMODEL_DELETED, | 
|     `tmodel`.`CREATE_USER` AS TMODEL_CREATE_USER, | 
|     `tmodel`.`CREATE_TIME` AS TMODEL_CREATE_TIME, | 
|     `tmodel`.`UPDATE_USER` AS TMODEL_UPDATE_USER, | 
|     `tmodel`.`UPDATE_TIME` AS TMODEL_UPDATE_TIME, | 
|     `tmodel`.`DICT_ID` AS TMODEL_DICT_ID, | 
|     `tmodel`.`CODE` AS TMODEL_CODE, | 
|     `tmodel`.`LABEL` AS TMODEL_LABEL, | 
|     `tmodel`.`SORT` AS TMODEL_SORT, | 
|     `tmodel`.`DISABLED` AS TMODEL_DISABLED | 
|     FROM `warehouse_location` `a` | 
|     RIGHT JOIN `warehouse` `wmodel` ON a.WAREHOUSE_ID=wmodel.ID | 
|     LEFT JOIN `system_dict_data` `tmodel` ON a.SYSTEM_DIC_DATA_ID=tmodel.ID | 
|     <where> | 
|       <if test="id != null"> | 
|         AND `a`.`ID` = #{id} | 
|       </if> | 
|       <if test="deleted != null"> | 
|         AND `a`.`DELETED` = #{deleted} | 
|       </if> | 
|   | 
|       <if test="createTime != null"> | 
|         AND `a`.`CREATE_TIME` = #{createTime} | 
|       </if> | 
|       <if test="updateUser != null"> | 
|         AND `a`.`UPDATE_USER` = #{updateUser} | 
|       </if> | 
|       <if test="updateTime != null"> | 
|         AND `a`.`UPDATE_TIME` = #{updateTime} | 
|       </if> | 
|       <if test="remark != null and remark != ''"> | 
|         AND `a`.`REMARK` = #{remark} | 
|       </if> | 
|       <if test="rootDepartId != null"> | 
|         AND `a`.`ROOT_DEPART_ID` = #{rootDepartId} | 
|       </if> | 
|       <if test="warehouseId != null"> | 
|         AND `a`.`WAREHOUSE_ID` = #{warehouseId} | 
|       </if> | 
|       <if test="unionName != null and unionName != ''"> | 
|         AND `a`.`UNION_NAME` = #{unionName} | 
|       </if> | 
|       <if test="area != null and area != ''"> | 
|         AND `a`.`AREA` = #{area} | 
|       </if> | 
|       <if test="shelf != null and shelf != ''"> | 
|         AND `a`.`SHELF` = #{shelf} | 
|       </if> | 
|       <if test="cell != null and cell != ''"> | 
|         AND `a`.`CELL` = #{cell} | 
|       </if> | 
|       <if test="qrcode != null"> | 
|         AND `a`.`QRCODE` = #{qrcode} | 
|       </if> | 
|       <if test="status != null"> | 
|         AND `a`.`STATUS` = #{status} | 
|       </if> | 
|       <if test="code != null and code != ''"> | 
|         AND `a`.`CODE` = #{code} | 
|       </if> | 
|       <if test="systemDicDataId != null "> | 
|         AND   a.SYSTEM_DIC_DATA_ID = #{systemDicDataId} | 
|       </if> | 
|       <if test="wmodelId != null"> | 
|         AND `wmodel`.`ID` = #{wmodelId} | 
|       </if> | 
|       <if test="wmodelDeleted != null"> | 
|         AND `wmodel`.`DELETED` = #{wmodelDeleted} | 
|       </if> | 
|       <if test="wmodelCreateUser != null"> | 
|         AND `wmodel`.`CREATE_USER` = #{wmodelCreateUser} | 
|       </if> | 
|       <if test="wmodelCreateTime != null"> | 
|         AND `wmodel`.`CREATE_TIME` = #{wmodelCreateTime} | 
|       </if> | 
|       <if test="wmodelUpdateUser != null"> | 
|         AND `wmodel`.`UPDATE_USER` = #{wmodelUpdateUser} | 
|       </if> | 
|       <if test="wmodelUpdateTime != null"> | 
|         AND `wmodel`.`UPDATE_TIME` = #{wmodelUpdateTime} | 
|       </if> | 
|       <if test="wmodelRemark != null and wmodelRemark != ''"> | 
|         AND `wmodel`.`REMARK` = #{wmodelRemark} | 
|       </if> | 
|       <if test="wmodelRootDepartId != null"> | 
|         AND `wmodel`.`ROOT_DEPART_ID` = #{wmodelRootDepartId} | 
|       </if> | 
|       <if test="wmodelDepartId != null"> | 
|         AND `wmodel`.`DEPART_ID` = #{wmodelDepartId} | 
|       </if> | 
|       <if test="wmodelProcedureId != null"> | 
|         AND `wmodel`.`PROCEDURE_ID` = #{wmodelProcedureId} | 
|       </if> | 
|       <if test="wmodelQrcode != null"> | 
|         AND `wmodel`.`QRCODE` = #{wmodelQrcode} | 
|       </if> | 
|       <if test="wmodelName != null and wmodelName != ''"> | 
|         AND `wmodel`.`NAME` = #{wmodelName} | 
|       </if> | 
|       <if test="wmodelUseLocation != null"> | 
|         AND `wmodel`.`USE_LOCATION` = #{wmodelUseLocation} | 
|       </if> | 
|       <if test="wmodelStatus != null"> | 
|         AND `wmodel`.`STATUS` = #{wmodelStatus} | 
|       </if> | 
|       <if test="wmodelAddr != null and wmodelAddr != ''"> | 
|         AND `wmodel`.`ADDR` = #{wmodelAddr} | 
|       </if> | 
|       <if test="wmodelManagerId != null"> | 
|         AND `wmodel`.`MANAGER_ID` = #{wmodelManagerId} | 
|       </if> | 
|       <if test="wmodelType != null"> | 
|         AND `wmodel`.`TYPE` = #{wmodelType} | 
|       </if> | 
|       <if test="wmodelCode != null and wmodelCode != ''"> | 
|         AND `wmodel`.`CODE` = #{wmodelCode} | 
|       </if> | 
|       <if test="tmodelId != null"> | 
|         AND `tmodel`.`ID` = #{tmodelId} | 
|       </if> | 
|       <if test="tmodelDeleted != null"> | 
|         AND `tmodel`.`DELETED` = #{tmodelDeleted} | 
|       </if> | 
|       <if test="tmodelCreateUser != null"> | 
|         AND `tmodel`.`CREATE_USER` = #{tmodelCreateUser} | 
|       </if> | 
|       <if test="tmodelCreateTime != null"> | 
|         AND `tmodel`.`CREATE_TIME` = #{tmodelCreateTime} | 
|       </if> | 
|       <if test="tmodelUpdateUser != null"> | 
|         AND `tmodel`.`UPDATE_USER` = #{tmodelUpdateUser} | 
|       </if> | 
|       <if test="tmodelUpdateTime != null"> | 
|         AND `tmodel`.`UPDATE_TIME` = #{tmodelUpdateTime} | 
|       </if> | 
|       <if test="tmodelDictId != null"> | 
|         AND `tmodel`.`DICT_ID` = #{tmodelDictId} | 
|       </if> | 
|       <if test="tmodelCode != null and tmodelCode != ''"> | 
|         AND `tmodel`.`CODE` = #{tmodelCode} | 
|       </if> | 
|       <if test="tmodelLabel != null and tmodelLabel != ''"> | 
|         AND `tmodel`.`LABEL` = #{tmodelLabel} | 
|       </if> | 
|       <if test="tmodelSort != null"> | 
|         AND `tmodel`.`SORT` = #{tmodelSort} | 
|       </if> | 
|       <if test="tmodelDisabled != null"> | 
|         AND `tmodel`.`DISABLED` = #{tmodelDisabled} | 
|       </if> | 
|   | 
|   | 
|   | 
|         <if test="departIds != null and departIds.size()>0"> | 
|           AND (`a`.`CREATE_USER`  = #{createUser} or wmodel.`MANAGER_ID` = #{createUser} or exists (select d.id from company_user d where   d.user_id =wmodel.`MANAGER_ID`   and d.department_id | 
|           in <foreach collection="departIds" item="item" separator="," open="(" close=")">#{item}</foreach>) | 
|           ) | 
|         </if> | 
|   | 
|           <if test="departIds != null and departIds.size()==0"> | 
|             AND ( wmodel.`MANAGER_ID` = #{createUser} or  a.`CREATE_USER`  = #{createUser}) | 
|           </if> | 
|   | 
|     </where> | 
|     order by `a`.`ID` desc | 
|   </select> | 
| </mapper> |