<?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.DeviceExtMapper"> 
 | 
  
 | 
  <!-- 管理页面查询 --> 
 | 
  <resultMap id="DeviceExtListVO" type="doumeemes.dao.ext.vo.DeviceExtListVO" 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="pmodel" javaType="doumeemes.dao.business.model.Procedures"> 
 | 
      <id column="PMODEL_ID" jdbcType="INTEGER" property="id"/> 
 | 
      <result column="PMODEL_DELETED" jdbcType="TINYINT" property="deleted"/> 
 | 
      <result column="PMODEL_CREATE_USER" jdbcType="INTEGER" property="createUser"/> 
 | 
      <result column="PMODEL_CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/> 
 | 
      <result column="PMODEL_UPDATE_USER" jdbcType="INTEGER" property="updateUser"/> 
 | 
      <result column="PMODEL_UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/> 
 | 
      <result column="PMODEL_REMARK" jdbcType="VARCHAR" property="remark"/> 
 | 
      <result column="PMODEL_ROOT_DEPART_ID" jdbcType="INTEGER" property="rootDepartId"/> 
 | 
      <result column="PMODEL_DEPART_ID" jdbcType="INTEGER" property="departId"/> 
 | 
      <result column="PMODEL_CODE" jdbcType="VARCHAR" property="code"/> 
 | 
      <result column="PMODEL_NAME" jdbcType="VARCHAR" property="name"/> 
 | 
      <result column="PMODEL_SORTNUM" jdbcType="INTEGER" property="sortnum"/> 
 | 
      <result column="PMODEL_ORG_ID" jdbcType="INTEGER" property="orgId"/> 
 | 
      <result column="PMODEL_USER_ID" jdbcType="INTEGER" property="userId"/> 
 | 
      <result column="PMODEL_PICKING_WAREHOUSE_ID" jdbcType="INTEGER" property="pickingWarehouseId"/> 
 | 
      <result column="PMODEL_PRODUCE_WAREHOUSE_ID" jdbcType="INTEGER" property="produceWarehouseId"/> 
 | 
      <result column="PMODEL_LEVEL" jdbcType="TINYINT" property="level"/> 
 | 
    </association> 
 | 
    <association property="gmodel" javaType="doumeemes.dao.business.model.Device"> 
 | 
      <id column="GMODEL_ID" jdbcType="INTEGER" property="id"/> 
 | 
      <result column="GMODEL_DELETED" jdbcType="TINYINT" property="deleted"/> 
 | 
      <result column="GMODEL_CREATE_USER" jdbcType="INTEGER" property="createUser"/> 
 | 
      <result column="GMODEL_CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/> 
 | 
      <result column="GMODEL_UPDATE_USER" jdbcType="INTEGER" property="updateUser"/> 
 | 
      <result column="GMODEL_UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/> 
 | 
      <result column="GMODEL_REMARK" jdbcType="VARCHAR" property="remark"/> 
 | 
      <result column="GMODEL_ROOT_DEPART_ID" jdbcType="INTEGER" property="rootDepartId"/> 
 | 
      <result column="GMODEL_DEPART_ID" jdbcType="INTEGER" property="departId"/> 
 | 
      <result column="GMODEL_PROCEDURE_ID" jdbcType="INTEGER" property="procedureId"/> 
 | 
      <result column="GMODEL_CODE" jdbcType="INTEGER" property="code"/> 
 | 
      <result column="GMODEL_TYPE" jdbcType="TINYINT" property="type"/> 
 | 
      <result column="GMODEL_NAME" jdbcType="VARCHAR" property="name"/> 
 | 
      <result column="GMODEL_MODEL" jdbcType="VARCHAR" property="model"/> 
 | 
      <result column="GMODEL_STATUS" jdbcType="TINYINT" property="status"/> 
 | 
      <result column="GMODEL_SUPPLIER" jdbcType="VARCHAR" property="supplier"/> 
 | 
      <result column="GMODEL_STATION_CODE" jdbcType="VARCHAR" property="stationCode"/> 
 | 
      <result column="GMODEL_GROUP_ID" jdbcType="INTEGER" property="groupId"/> 
 | 
      <result column="GMODEL_SERIAL_NUM" jdbcType="VARCHAR" property="serialNum"/> 
 | 
    </association> 
 | 
  
 | 
    <association property="wmodel" javaType="doumeemes.dao.business.model.Warehouse"> 
 | 
      <id column="WMODEL_ID" jdbcType="INTEGER" property="id"/> 
 | 
      <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="wwpmodel" javaType="doumeemes.dao.business.model.Warehouse"> 
 | 
      <id column="WWPMODEL_ID" jdbcType="INTEGER" property="id"/> 
 | 
      <result column="WWPMODEL_ROOT_DEPART_ID" jdbcType="INTEGER" property="rootDepartId"/> 
 | 
      <result column="WWPMODEL_DEPART_ID" jdbcType="INTEGER" property="departId"/> 
 | 
      <result column="WWPMODEL_PROCEDURE_ID" jdbcType="INTEGER" property="procedureId"/> 
 | 
      <result column="WWPMODEL_QRCODE" jdbcType="INTEGER" property="qrcode"/> 
 | 
      <result column="WWPMODEL_NAME" jdbcType="VARCHAR" property="name"/> 
 | 
      <result column="WWPMODEL_USE_LOCATION" jdbcType="TINYINT" property="useLocation"/> 
 | 
      <result column="WWPMODEL_STATUS" jdbcType="TINYINT" property="status"/> 
 | 
      <result column="WWPMODEL_ADDR" jdbcType="VARCHAR" property="addr"/> 
 | 
      <result column="WWPMODEL_MANAGER_ID" jdbcType="INTEGER" property="managerId"/> 
 | 
      <result column="WWPMODEL_TYPE" jdbcType="INTEGER" property="type"/> 
 | 
      <result column="WWPMODEL_CODE" jdbcType="VARCHAR" property="code"/> 
 | 
    </association> 
 | 
  
 | 
    <association property="wpmodel" javaType="doumeemes.dao.business.model.WarehouseLocation"> 
 | 
      <id column="WPMODEL_ID" jdbcType="INTEGER" property="id"/> 
 | 
      <result column="WPMODEL_ROOT_DEPART_ID" jdbcType="INTEGER" property="rootDepartId"/> 
 | 
      <result column="WPMODEL_WAREHOUSE_ID" jdbcType="INTEGER" property="warehouseId"/> 
 | 
      <result column="WPMODEL_UNION_NAME" jdbcType="VARCHAR" property="unionName"/> 
 | 
      <result column="WPMODEL_AREA" jdbcType="VARCHAR" property="area"/> 
 | 
      <result column="WPMODEL_SHELF" jdbcType="VARCHAR" property="shelf"/> 
 | 
      <result column="WPMODEL_CELL" jdbcType="VARCHAR" property="cell"/> 
 | 
      <result column="WPMODEL_QRCODE" jdbcType="INTEGER" property="qrcode"/> 
 | 
      <result column="WPMODEL_STATUS" jdbcType="TINYINT" property="status"/> 
 | 
    </association> 
 | 
  
 | 
  
 | 
    <association property="wfmodel" javaType="doumeemes.dao.business.model.WarehouseLocation"> 
 | 
      <id column="WFMODEL_ID" jdbcType="INTEGER" property="id"/> 
 | 
      <result column="WFMODEL_ROOT_DEPART_ID" jdbcType="INTEGER" property="rootDepartId"/> 
 | 
      <result column="WFMODEL_WAREHOUSE_ID" jdbcType="INTEGER" property="warehouseId"/> 
 | 
      <result column="WFMODEL_UNION_NAME" jdbcType="VARCHAR" property="unionName"/> 
 | 
      <result column="WFMODEL_AREA" jdbcType="VARCHAR" property="area"/> 
 | 
      <result column="WFMODEL_SHELF" jdbcType="VARCHAR" property="shelf"/> 
 | 
      <result column="WFMODEL_CELL" jdbcType="VARCHAR" property="cell"/> 
 | 
      <result column="WFMODEL_QRCODE" jdbcType="INTEGER" property="qrcode"/> 
 | 
      <result column="WFMODEL_STATUS" jdbcType="TINYINT" property="status"/> 
 | 
    </association> 
 | 
  </resultMap> 
 | 
  <select id="selectByModel" parameterType="doumeemes.dao.ext.dto.QueryDeviceExtDTO" resultMap="DeviceExtListVO"> 
 | 
    SELECT * 
 | 
    FROM `device` `a` 
 | 
    <where> 
 | 
      <if test="id != null"> 
 | 
        AND `a`.`ID` = #{id} 
 | 
      </if> 
 | 
      <if test="deleted != null"> 
 | 
        AND `a`.`DELETED` = #{deleted} 
 | 
      </if> 
 | 
      <if test="createUser != null"> 
 | 
        AND `a`.`CREATE_USER` = #{createUser} 
 | 
      </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="departId != null"> 
 | 
        AND `a`.`DEPART_ID` = #{departId} 
 | 
      </if> 
 | 
      <if test="departIds != null and departIds.size > 0"> 
 | 
        AND `a`.`DEPART_ID` IN 
 | 
        <foreach collection="departIds" open="(" close=")" separator="," item="id"> 
 | 
          #{id} 
 | 
        </foreach> 
 | 
      </if> 
 | 
      <if test="procedureId != null"> 
 | 
        AND `a`.`PROCEDURE_ID` = #{procedureId} 
 | 
      </if> 
 | 
      <if test="code != null"> 
 | 
        AND `a`.`CODE` = #{code} 
 | 
      </if> 
 | 
      <if test="type != null"> 
 | 
        AND `a`.`TYPE` = #{type} 
 | 
      </if> 
 | 
      <if test="name != null and name != ''"> 
 | 
        AND `a`.`NAME` like concat('%',#{name},'%') 
 | 
      </if> 
 | 
      <if test="model != null and model != ''"> 
 | 
        AND `a`.`MODEL` = #{model} 
 | 
      </if> 
 | 
      <if test="status != null"> 
 | 
        AND `a`.`STATUS` = #{status} 
 | 
      </if> 
 | 
      <if test="supplier != null and supplier != ''"> 
 | 
        AND `a`.`SUPPLIER` = #{supplier} 
 | 
      </if> 
 | 
      <if test="stationCode != null and stationCode != ''"> 
 | 
        AND `a`.`STATION_CODE` = #{stationCode} 
 | 
      </if> 
 | 
      <if test="groupId != null"> 
 | 
        AND `a`.`GROUP_ID` = #{groupId} 
 | 
      </if> 
 | 
      <if test="serialNum != null and serialNum != ''"> 
 | 
        AND `a`.`SERIAL_NUM` = #{serialNum} 
 | 
      </if> 
 | 
    limit 1 
 | 
    </where> 
 | 
  </select> 
 | 
  <select id="selectList" parameterType="doumeemes.dao.ext.dto.QueryDeviceExtDTO" resultMap="DeviceExtListVO"> 
 | 
    SELECT 
 | 
      `a`.`ID`, 
 | 
      `a`.`DELETED`, 
 | 
      `a`.`CREATE_USER`, 
 | 
      `a`.`CREATE_TIME`, 
 | 
      `a`.`UPDATE_USER`, 
 | 
      `a`.`UPDATE_TIME`, 
 | 
      `a`.`REMARK`, 
 | 
      `a`.`ROOT_DEPART_ID`, 
 | 
      `a`.`DEPART_ID`, 
 | 
      `a`.`PROCEDURE_ID`, 
 | 
      `a`.`CODE`, 
 | 
      `a`.`TYPE`, 
 | 
      `a`.`NAME`, 
 | 
      `a`.`MODEL`, 
 | 
      `a`.`STATUS`, 
 | 
      `a`.`SUPPLIER`, 
 | 
      `a`.`STATION_CODE`, 
 | 
      `a`.`GROUP_ID`, 
 | 
      `a`.`SERIAL_NUM`, 
 | 
    a.PRODUCE_WAREHOUSE_LOCATION_ID, 
 | 
    a.FINISH_WAREHOUSE_LOCATION_ID, 
 | 
      `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, 
 | 
      `pmodel`.`ID` AS PMODEL_ID, 
 | 
      `pmodel`.`DELETED` AS PMODEL_DELETED, 
 | 
      `pmodel`.`CREATE_USER` AS PMODEL_CREATE_USER, 
 | 
      `pmodel`.`CREATE_TIME` AS PMODEL_CREATE_TIME, 
 | 
      `pmodel`.`UPDATE_USER` AS PMODEL_UPDATE_USER, 
 | 
      `pmodel`.`UPDATE_TIME` AS PMODEL_UPDATE_TIME, 
 | 
      `pmodel`.`REMARK` AS PMODEL_REMARK, 
 | 
      `pmodel`.`ROOT_DEPART_ID` AS PMODEL_ROOT_DEPART_ID, 
 | 
      `pmodel`.`DEPART_ID` AS PMODEL_DEPART_ID, 
 | 
      `pmodel`.`CODE` AS PMODEL_CODE, 
 | 
      `pmodel`.`NAME` AS PMODEL_NAME, 
 | 
      `pmodel`.`SORTNUM` AS PMODEL_SORTNUM, 
 | 
      `pmodel`.`ORG_ID` AS PMODEL_ORG_ID, 
 | 
      `pmodel`.`USER_ID` AS PMODEL_USER_ID, 
 | 
      `pmodel`.`PICKING_WAREHOUSE_ID` AS PMODEL_PICKING_WAREHOUSE_ID, 
 | 
      `pmodel`.`PRODUCE_WAREHOUSE_ID` AS PMODEL_PRODUCE_WAREHOUSE_ID, 
 | 
      `pmodel`.`LEVEL` AS PMODEL_LEVEL, 
 | 
      `gmodel`.`ID` AS GMODEL_ID, 
 | 
      `gmodel`.`DELETED` AS GMODEL_DELETED, 
 | 
      `gmodel`.`CREATE_USER` AS GMODEL_CREATE_USER, 
 | 
      `gmodel`.`CREATE_TIME` AS GMODEL_CREATE_TIME, 
 | 
      `gmodel`.`UPDATE_USER` AS GMODEL_UPDATE_USER, 
 | 
      `gmodel`.`UPDATE_TIME` AS GMODEL_UPDATE_TIME, 
 | 
      `gmodel`.`REMARK` AS GMODEL_REMARK, 
 | 
      `gmodel`.`ROOT_DEPART_ID` AS GMODEL_ROOT_DEPART_ID, 
 | 
      `gmodel`.`DEPART_ID` AS GMODEL_DEPART_ID, 
 | 
      `gmodel`.`PROCEDURE_ID` AS GMODEL_PROCEDURE_ID, 
 | 
      `gmodel`.`CODE` AS GMODEL_CODE, 
 | 
      `gmodel`.`TYPE` AS GMODEL_TYPE, 
 | 
      `gmodel`.`NAME` AS GMODEL_NAME, 
 | 
      `gmodel`.`MODEL` AS GMODEL_MODEL, 
 | 
      `gmodel`.`STATUS` AS GMODEL_STATUS, 
 | 
      `gmodel`.`SUPPLIER` AS GMODEL_SUPPLIER, 
 | 
      `gmodel`.`STATION_CODE` AS GMODEL_STATION_CODE, 
 | 
      `gmodel`.`GROUP_ID` AS GMODEL_GROUP_ID, 
 | 
      `gmodel`.`SERIAL_NUM` AS GMODEL_SERIAL_NUM, 
 | 
  
 | 
    `wmodel`.`ID` AS WMODEL_ID, 
 | 
    `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, 
 | 
  
 | 
    `wwpmodel`.`ID` AS WWPMODEL_ID, 
 | 
    `wwpmodel`.`ROOT_DEPART_ID` AS WWPMODEL_ROOT_DEPART_ID, 
 | 
    `wwpmodel`.`DEPART_ID` AS WWPMODEL_DEPART_ID, 
 | 
    `wwpmodel`.`PROCEDURE_ID` AS WWPMODEL_PROCEDURE_ID, 
 | 
    `wwpmodel`.`QRCODE` AS WWPMODEL_QRCODE, 
 | 
    `wwpmodel`.`NAME` AS WWPMODEL_NAME, 
 | 
    `wwpmodel`.`USE_LOCATION` AS WWPMODEL_USE_LOCATION, 
 | 
    `wwpmodel`.`STATUS` AS WWPMODEL_STATUS, 
 | 
    `wwpmodel`.`ADDR` AS WWPMODEL_ADDR, 
 | 
    `wwpmodel`.`MANAGER_ID` AS WWPMODEL_MANAGER_ID, 
 | 
    `wwpmodel`.`TYPE` AS WWPMODEL_TYPE, 
 | 
    `wwpmodel`.`CODE` AS WWPMODEL_CODE, 
 | 
  
 | 
    `wpmodel`.`ID` as WPMODEL_ID, 
 | 
    `wpmodel`.`ROOT_DEPART_ID` as WPMODEL_ROOT_DEPART_ID, 
 | 
    `wpmodel`.`WAREHOUSE_ID` as WPMODEL_WAREHOUSE_ID, 
 | 
    `wpmodel`.`UNION_NAME` as WPMODEL_UNION_NAME, 
 | 
    `wpmodel`.`QRCODE` as WPMODEL_QRCODE, 
 | 
    `wpmodel`.`STATUS` as WPMODEL_STATUS, 
 | 
    `wpmodel`.`CODE` as WPMODEL_CODE, 
 | 
  
 | 
    `wfmodel`.`ID` as WFMODEL_ID, 
 | 
    `wfmodel`.`ROOT_DEPART_ID` as WFMODEL_ROOT_DEPART_ID, 
 | 
    `wfmodel`.`WAREHOUSE_ID` as WFMODEL_WAREHOUSE_ID, 
 | 
    `wfmodel`.`UNION_NAME` as WFMODEL_UNION_NAME, 
 | 
    `wfmodel`.`QRCODE` as WFMODEL_QRCODE, 
 | 
    `wfmodel`.`STATUS` as WFMODEL_STATUS, 
 | 
    `wfmodel`.`CODE` as WFMODEL_CODE 
 | 
    FROM `device` `a` 
 | 
    LEFT JOIN `department` `dmodel` ON a.DEPART_ID=dmodel.ID 
 | 
    LEFT JOIN `procedures` `pmodel` ON a.PROCEDURE_ID=pmodel.ID 
 | 
    LEFT JOIN `device` `gmodel` ON a.GROUP_ID=gmodel.ID 
 | 
  
 | 
    left join  `warehouse_location` `wpmodel` ON a.PRODUCE_WAREHOUSE_LOCATION_ID=wpmodel.ID 
 | 
    left join  `warehouse_location` `wfmodel` ON a.FINISH_WAREHOUSE_LOCATION_ID=wfmodel.ID 
 | 
    left join  `warehouse` `wwpmodel` ON wpmodel.WAREHOUSE_ID=wwpmodel.ID 
 | 
    left join  `warehouse` `wmodel` ON wfmodel.WAREHOUSE_ID=wmodel.ID 
 | 
    <where> 
 | 
      <if test="id != null"> 
 | 
        AND `a`.`ID` = #{id} 
 | 
      </if> 
 | 
      <if test="deleted != null"> 
 | 
        AND `a`.`DELETED` = #{deleted} 
 | 
      </if> 
 | 
      <if test="createUser != null"> 
 | 
        AND `a`.`CREATE_USER` = #{createUser} 
 | 
      </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="departId != null"> 
 | 
        AND `a`.`DEPART_ID` = #{departId} 
 | 
      </if> 
 | 
      <if test="departIds != null and departIds.size > 0"> 
 | 
        AND `a`.`DEPART_ID` IN 
 | 
        <foreach collection="departIds" open="(" close=")" separator="," item="id"> 
 | 
          #{id} 
 | 
        </foreach> 
 | 
      </if> 
 | 
      <if test="procedureId != null"> 
 | 
        AND `a`.`PROCEDURE_ID` = #{procedureId} 
 | 
      </if> 
 | 
      <if test="code != null and code != ''"> 
 | 
        AND `a`.`CODE` like concat('%',#{code},'%') 
 | 
      </if> 
 | 
      <if test="type != null"> 
 | 
        AND `a`.`TYPE` = #{type} 
 | 
      </if> 
 | 
      <if test="name != null and name != ''"> 
 | 
        AND `a`.`NAME` like concat('%',#{name},'%') 
 | 
      </if> 
 | 
      <if test="model != null and model != ''"> 
 | 
        AND `a`.`MODEL` = #{model} 
 | 
      </if> 
 | 
      <if test="status != null"> 
 | 
        AND `a`.`STATUS` = #{status} 
 | 
      </if> 
 | 
      <if test="supplier != null and supplier != ''"> 
 | 
        AND `a`.`SUPPLIER` = #{supplier} 
 | 
      </if> 
 | 
      <if test="stationCode != null and stationCode != ''"> 
 | 
        AND `a`.`STATION_CODE` = #{stationCode} 
 | 
      </if> 
 | 
      <if test="groupId != null"> 
 | 
        AND `a`.`GROUP_ID` = #{groupId} 
 | 
      </if> 
 | 
      <if test="serialNum != null and serialNum != ''"> 
 | 
        AND `a`.`SERIAL_NUM` = #{serialNum} 
 | 
      </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> 
 | 
      <if test="pmodelId != null"> 
 | 
        AND `pmodel`.`ID` = #{pmodelId} 
 | 
      </if> 
 | 
      <if test="pmodelDeleted != null"> 
 | 
        AND `pmodel`.`DELETED` = #{pmodelDeleted} 
 | 
      </if> 
 | 
      <if test="pmodelCreateUser != null"> 
 | 
        AND `pmodel`.`CREATE_USER` = #{pmodelCreateUser} 
 | 
      </if> 
 | 
      <if test="pmodelCreateTime != null"> 
 | 
        AND `pmodel`.`CREATE_TIME` = #{pmodelCreateTime} 
 | 
      </if> 
 | 
      <if test="pmodelUpdateUser != null"> 
 | 
        AND `pmodel`.`UPDATE_USER` = #{pmodelUpdateUser} 
 | 
      </if> 
 | 
      <if test="pmodelUpdateTime != null"> 
 | 
        AND `pmodel`.`UPDATE_TIME` = #{pmodelUpdateTime} 
 | 
      </if> 
 | 
      <if test="pmodelRemark != null and pmodelRemark != ''"> 
 | 
        AND `pmodel`.`REMARK` = #{pmodelRemark} 
 | 
      </if> 
 | 
      <if test="pmodelRootDepartId != null"> 
 | 
        AND `pmodel`.`ROOT_DEPART_ID` = #{pmodelRootDepartId} 
 | 
      </if> 
 | 
      <if test="pmodelDepartId != null"> 
 | 
        AND `pmodel`.`DEPART_ID` = #{pmodelDepartId} 
 | 
      </if> 
 | 
      <if test="pmodelCode != null and pmodelCode != ''"> 
 | 
        AND `pmodel`.`CODE` = #{pmodelCode} 
 | 
      </if> 
 | 
      <if test="pmodelName != null and pmodelName != ''"> 
 | 
        AND `pmodel`.`NAME` = #{pmodelName} 
 | 
      </if> 
 | 
      <if test="pmodelSortnum != null"> 
 | 
        AND `pmodel`.`SORTNUM` = #{pmodelSortnum} 
 | 
      </if> 
 | 
      <if test="pmodelOrgId != null"> 
 | 
        AND `pmodel`.`ORG_ID` = #{pmodelOrgId} 
 | 
      </if> 
 | 
      <if test="pmodelUserId != null"> 
 | 
        AND `pmodel`.`USER_ID` = #{pmodelUserId} 
 | 
      </if> 
 | 
      <if test="pmodelPickingWarehouseId != null"> 
 | 
        AND `pmodel`.`PICKING_WAREHOUSE_ID` = #{pmodelPickingWarehouseId} 
 | 
      </if> 
 | 
      <if test="pmodelProduceWarehouseId != null"> 
 | 
        AND `pmodel`.`PRODUCE_WAREHOUSE_ID` = #{pmodelProduceWarehouseId} 
 | 
      </if> 
 | 
      <if test="pmodelLevel != null"> 
 | 
        AND `pmodel`.`LEVEL` = #{pmodelLevel} 
 | 
      </if> 
 | 
      <if test="gmodelId != null"> 
 | 
        AND `gmodel`.`ID` = #{gmodelId} 
 | 
      </if> 
 | 
      <if test="gmodelDeleted != null"> 
 | 
        AND `gmodel`.`DELETED` = #{gmodelDeleted} 
 | 
      </if> 
 | 
      <if test="gmodelCreateUser != null"> 
 | 
        AND `gmodel`.`CREATE_USER` = #{gmodelCreateUser} 
 | 
      </if> 
 | 
      <if test="gmodelCreateTime != null"> 
 | 
        AND `gmodel`.`CREATE_TIME` = #{gmodelCreateTime} 
 | 
      </if> 
 | 
      <if test="gmodelUpdateUser != null"> 
 | 
        AND `gmodel`.`UPDATE_USER` = #{gmodelUpdateUser} 
 | 
      </if> 
 | 
      <if test="gmodelUpdateTime != null"> 
 | 
        AND `gmodel`.`UPDATE_TIME` = #{gmodelUpdateTime} 
 | 
      </if> 
 | 
      <if test="gmodelRemark != null and gmodelRemark != ''"> 
 | 
        AND `gmodel`.`REMARK` = #{gmodelRemark} 
 | 
      </if> 
 | 
      <if test="gmodelRootDepartId != null"> 
 | 
        AND `gmodel`.`ROOT_DEPART_ID` = #{gmodelRootDepartId} 
 | 
      </if> 
 | 
      <if test="gmodelDepartId != null"> 
 | 
        AND `gmodel`.`DEPART_ID` = #{gmodelDepartId} 
 | 
      </if> 
 | 
      <if test="gmodelProcedureId != null"> 
 | 
        AND `gmodel`.`PROCEDURE_ID` = #{gmodelProcedureId} 
 | 
      </if> 
 | 
      <if test="gmodelCode != null"> 
 | 
        AND `gmodel`.`CODE` = #{gmodelCode} 
 | 
      </if> 
 | 
      <if test="gmodelType != null"> 
 | 
        AND `gmodel`.`TYPE` = #{gmodelType} 
 | 
      </if> 
 | 
      <if test="gmodelName != null and gmodelName != ''"> 
 | 
        AND `gmodel`.`NAME` = #{gmodelName} 
 | 
      </if> 
 | 
      <if test="gmodelModel != null and gmodelModel != ''"> 
 | 
        AND `gmodel`.`MODEL` = #{gmodelModel} 
 | 
      </if> 
 | 
      <if test="gmodelStatus != null"> 
 | 
        AND `gmodel`.`STATUS` = #{gmodelStatus} 
 | 
      </if> 
 | 
      <if test="gmodelSupplier != null and gmodelSupplier != ''"> 
 | 
        AND `gmodel`.`SUPPLIER` = #{gmodelSupplier} 
 | 
      </if> 
 | 
      <if test="gmodelStationCode != null and gmodelStationCode != ''"> 
 | 
        AND `gmodel`.`STATION_CODE` = #{gmodelStationCode} 
 | 
      </if> 
 | 
      <if test="gmodelGroupId != null"> 
 | 
        AND `gmodel`.`GROUP_ID` = #{gmodelGroupId} 
 | 
      </if> 
 | 
      <if test="gmodelSerialNum != null and gmodelSerialNum != ''"> 
 | 
        AND `gmodel`.`SERIAL_NUM` = #{gmodelSerialNum} 
 | 
      </if> 
 | 
    </where> 
 | 
    order by  `a`.`ID` desc 
 | 
  </select> 
 | 
  
 | 
  
 | 
  <select id="getListByCondition" parameterType="doumeemes.dao.ext.dto.QueryDeviceExtDTO" resultMap="DeviceExtListVO"> 
 | 
    SELECT 
 | 
     `a`.`ID`, 
 | 
    `a`.`DELETED`, 
 | 
    `a`.`CREATE_USER`, 
 | 
    `a`.`CREATE_TIME`, 
 | 
    `a`.`UPDATE_USER`, 
 | 
    `a`.`UPDATE_TIME`, 
 | 
    `a`.`REMARK`, 
 | 
    `a`.`ROOT_DEPART_ID`, 
 | 
    `a`.`DEPART_ID`, 
 | 
    `a`.`PROCEDURE_ID`, 
 | 
    `a`.`CODE`, 
 | 
    `a`.`TYPE`, 
 | 
    `a`.`NAME`, 
 | 
    `a`.`MODEL`, 
 | 
    `a`.`STATUS`, 
 | 
    `a`.`SUPPLIER`, 
 | 
    `a`.`STATION_CODE`, 
 | 
    `a`.`GROUP_ID`, 
 | 
    `a`.`SERIAL_NUM`, 
 | 
    a.PRODUCE_WAREHOUSE_LOCATION_ID, 
 | 
    a.FINISH_WAREHOUSE_LOCATION_ID, 
 | 
    `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, 
 | 
    `pmodel`.`ID` AS PMODEL_ID, 
 | 
    `pmodel`.`DELETED` AS PMODEL_DELETED, 
 | 
    `pmodel`.`CREATE_USER` AS PMODEL_CREATE_USER, 
 | 
    `pmodel`.`CREATE_TIME` AS PMODEL_CREATE_TIME, 
 | 
    `pmodel`.`UPDATE_USER` AS PMODEL_UPDATE_USER, 
 | 
    `pmodel`.`UPDATE_TIME` AS PMODEL_UPDATE_TIME, 
 | 
    `pmodel`.`REMARK` AS PMODEL_REMARK, 
 | 
    `pmodel`.`ROOT_DEPART_ID` AS PMODEL_ROOT_DEPART_ID, 
 | 
    `pmodel`.`DEPART_ID` AS PMODEL_DEPART_ID, 
 | 
    `pmodel`.`CODE` AS PMODEL_CODE, 
 | 
    `pmodel`.`NAME` AS PMODEL_NAME, 
 | 
    `pmodel`.`SORTNUM` AS PMODEL_SORTNUM, 
 | 
    `pmodel`.`ORG_ID` AS PMODEL_ORG_ID, 
 | 
    `pmodel`.`USER_ID` AS PMODEL_USER_ID, 
 | 
    `pmodel`.`PICKING_WAREHOUSE_ID` AS PMODEL_PICKING_WAREHOUSE_ID, 
 | 
    `pmodel`.`PRODUCE_WAREHOUSE_ID` AS PMODEL_PRODUCE_WAREHOUSE_ID, 
 | 
    `pmodel`.`LEVEL` AS PMODEL_LEVEL, 
 | 
    `gmodel`.`ID` AS GMODEL_ID, 
 | 
    `gmodel`.`DELETED` AS GMODEL_DELETED, 
 | 
    `gmodel`.`CREATE_USER` AS GMODEL_CREATE_USER, 
 | 
    `gmodel`.`CREATE_TIME` AS GMODEL_CREATE_TIME, 
 | 
    `gmodel`.`UPDATE_USER` AS GMODEL_UPDATE_USER, 
 | 
    `gmodel`.`UPDATE_TIME` AS GMODEL_UPDATE_TIME, 
 | 
    `gmodel`.`REMARK` AS GMODEL_REMARK, 
 | 
    `gmodel`.`ROOT_DEPART_ID` AS GMODEL_ROOT_DEPART_ID, 
 | 
    `gmodel`.`DEPART_ID` AS GMODEL_DEPART_ID, 
 | 
    `gmodel`.`PROCEDURE_ID` AS GMODEL_PROCEDURE_ID, 
 | 
    `gmodel`.`CODE` AS GMODEL_CODE, 
 | 
    `gmodel`.`TYPE` AS GMODEL_TYPE, 
 | 
    `gmodel`.`NAME` AS GMODEL_NAME, 
 | 
    `gmodel`.`MODEL` AS GMODEL_MODEL, 
 | 
    `gmodel`.`STATUS` AS GMODEL_STATUS, 
 | 
    `gmodel`.`SUPPLIER` AS GMODEL_SUPPLIER, 
 | 
    `gmodel`.`STATION_CODE` AS GMODEL_STATION_CODE, 
 | 
    `gmodel`.`GROUP_ID` AS GMODEL_GROUP_ID, 
 | 
    `gmodel`.`SERIAL_NUM` AS GMODEL_SERIAL_NUM 
 | 
    FROM `device` `a` 
 | 
    LEFT JOIN `department` `dmodel` ON a.DEPART_ID=dmodel.ID 
 | 
    LEFT JOIN `procedures` `pmodel` ON a.PROCEDURE_ID=pmodel.ID 
 | 
    LEFT JOIN `device` `gmodel` ON a.GROUP_ID=gmodel.ID 
 | 
  /*  left join `user_device` udmodel on udmodel.DEVICE_ID=a.ID*/ 
 | 
    <where> 
 | 
      <if test="id != null"> 
 | 
        AND `a`.`ID` = #{id} 
 | 
      </if> 
 | 
      <if test="deleted != null"> 
 | 
        AND `a`.`DELETED` = #{deleted} 
 | 
      </if> 
 | 
      <if test="createUser != null"> 
 | 
        AND `a`.`CREATE_USER` = #{createUser} 
 | 
      </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="departId != null"> 
 | 
        AND `a`.`DEPART_ID` = #{departId} 
 | 
      </if> 
 | 
      <if test="procedureId != null"> 
 | 
        AND `a`.`PROCEDURE_ID` = #{procedureId} 
 | 
      </if> 
 | 
      <if test="code != null"> 
 | 
        AND `a`.`CODE` = #{code} 
 | 
      </if> 
 | 
      <if test="type != null"> 
 | 
        AND `a`.`TYPE` = #{type} 
 | 
      </if> 
 | 
      <if test="name != null and name != ''"> 
 | 
        AND `a`.`NAME` = #{name} 
 | 
      </if> 
 | 
      <if test="model != null and model != ''"> 
 | 
        AND `a`.`MODEL` = #{model} 
 | 
      </if> 
 | 
      <if test="status != null"> 
 | 
        AND `a`.`STATUS` = #{status} 
 | 
      </if> 
 | 
      <if test="supplier != null and supplier != ''"> 
 | 
        AND `a`.`SUPPLIER` = #{supplier} 
 | 
      </if> 
 | 
      <if test="stationCode != null and stationCode != ''"> 
 | 
        AND `a`.`STATION_CODE` = #{stationCode} 
 | 
      </if> 
 | 
      <if test="groupId != null"> 
 | 
        AND `a`.`GROUP_ID` = #{groupId} 
 | 
      </if> 
 | 
      <if test="serialNum != null and serialNum != ''"> 
 | 
        AND `a`.`SERIAL_NUM` = #{serialNum} 
 | 
      </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> 
 | 
      <if test="pmodelId != null"> 
 | 
        AND `pmodel`.`ID` = #{pmodelId} 
 | 
      </if> 
 | 
      <if test="pmodelDeleted != null"> 
 | 
        AND `pmodel`.`DELETED` = #{pmodelDeleted} 
 | 
      </if> 
 | 
      <if test="pmodelCreateUser != null"> 
 | 
        AND `pmodel`.`CREATE_USER` = #{pmodelCreateUser} 
 | 
      </if> 
 | 
      <if test="pmodelCreateTime != null"> 
 | 
        AND `pmodel`.`CREATE_TIME` = #{pmodelCreateTime} 
 | 
      </if> 
 | 
      <if test="pmodelUpdateUser != null"> 
 | 
        AND `pmodel`.`UPDATE_USER` = #{pmodelUpdateUser} 
 | 
      </if> 
 | 
      <if test="pmodelUpdateTime != null"> 
 | 
        AND `pmodel`.`UPDATE_TIME` = #{pmodelUpdateTime} 
 | 
      </if> 
 | 
      <if test="pmodelRemark != null and pmodelRemark != ''"> 
 | 
        AND `pmodel`.`REMARK` = #{pmodelRemark} 
 | 
      </if> 
 | 
      <if test="pmodelRootDepartId != null"> 
 | 
        AND `pmodel`.`ROOT_DEPART_ID` = #{pmodelRootDepartId} 
 | 
      </if> 
 | 
      <if test="pmodelDepartId != null"> 
 | 
        AND `pmodel`.`DEPART_ID` = #{pmodelDepartId} 
 | 
      </if> 
 | 
      <if test="pmodelCode != null and pmodelCode != ''"> 
 | 
        AND `pmodel`.`CODE` = #{pmodelCode} 
 | 
      </if> 
 | 
      <if test="pmodelName != null and pmodelName != ''"> 
 | 
        AND `pmodel`.`NAME` = #{pmodelName} 
 | 
      </if> 
 | 
      <if test="pmodelSortnum != null"> 
 | 
        AND `pmodel`.`SORTNUM` = #{pmodelSortnum} 
 | 
      </if> 
 | 
      <if test="pmodelOrgId != null"> 
 | 
        AND `pmodel`.`ORG_ID` = #{pmodelOrgId} 
 | 
      </if> 
 | 
      <if test="pmodelUserId != null"> 
 | 
        AND `pmodel`.`USER_ID` = #{pmodelUserId} 
 | 
      </if> 
 | 
      <if test="pmodelPickingWarehouseId != null"> 
 | 
        AND `pmodel`.`PICKING_WAREHOUSE_ID` = #{pmodelPickingWarehouseId} 
 | 
      </if> 
 | 
      <if test="pmodelProduceWarehouseId != null"> 
 | 
        AND `pmodel`.`PRODUCE_WAREHOUSE_ID` = #{pmodelProduceWarehouseId} 
 | 
      </if> 
 | 
      <if test="pmodelLevel != null"> 
 | 
        AND `pmodel`.`LEVEL` = #{pmodelLevel} 
 | 
      </if> 
 | 
      <if test="gmodelId != null"> 
 | 
        AND `gmodel`.`ID` = #{gmodelId} 
 | 
      </if> 
 | 
      <if test="gmodelDeleted != null"> 
 | 
        AND `gmodel`.`DELETED` = #{gmodelDeleted} 
 | 
      </if> 
 | 
      <if test="gmodelCreateUser != null"> 
 | 
        AND `gmodel`.`CREATE_USER` = #{gmodelCreateUser} 
 | 
      </if> 
 | 
      <if test="gmodelCreateTime != null"> 
 | 
        AND `gmodel`.`CREATE_TIME` = #{gmodelCreateTime} 
 | 
      </if> 
 | 
      <if test="gmodelUpdateUser != null"> 
 | 
        AND `gmodel`.`UPDATE_USER` = #{gmodelUpdateUser} 
 | 
      </if> 
 | 
      <if test="gmodelUpdateTime != null"> 
 | 
        AND `gmodel`.`UPDATE_TIME` = #{gmodelUpdateTime} 
 | 
      </if> 
 | 
      <if test="gmodelRemark != null and gmodelRemark != ''"> 
 | 
        AND `gmodel`.`REMARK` = #{gmodelRemark} 
 | 
      </if> 
 | 
      <if test="gmodelRootDepartId != null"> 
 | 
        AND `gmodel`.`ROOT_DEPART_ID` = #{gmodelRootDepartId} 
 | 
      </if> 
 | 
      <if test="gmodelDepartId != null"> 
 | 
        AND `gmodel`.`DEPART_ID` = #{gmodelDepartId} 
 | 
      </if> 
 | 
      <if test="gmodelProcedureId != null"> 
 | 
        AND `gmodel`.`PROCEDURE_ID` = #{gmodelProcedureId} 
 | 
      </if> 
 | 
      <if test="gmodelCode != null"> 
 | 
        AND `gmodel`.`CODE` = #{gmodelCode} 
 | 
      </if> 
 | 
      <if test="gmodelType != null"> 
 | 
        AND `gmodel`.`TYPE` = #{gmodelType} 
 | 
      </if> 
 | 
      <if test="gmodelName != null and gmodelName != ''"> 
 | 
        AND `gmodel`.`NAME` = #{gmodelName} 
 | 
      </if> 
 | 
      <if test="gmodelModel != null and gmodelModel != ''"> 
 | 
        AND `gmodel`.`MODEL` = #{gmodelModel} 
 | 
      </if> 
 | 
      <if test="gmodelStatus != null"> 
 | 
        AND `gmodel`.`STATUS` = #{gmodelStatus} 
 | 
      </if> 
 | 
      <if test="gmodelSupplier != null and gmodelSupplier != ''"> 
 | 
        AND `gmodel`.`SUPPLIER` = #{gmodelSupplier} 
 | 
      </if> 
 | 
      <if test="gmodelStationCode != null and gmodelStationCode != ''"> 
 | 
        AND `gmodel`.`STATION_CODE` = #{gmodelStationCode} 
 | 
      </if> 
 | 
      <if test="gmodelGroupId != null"> 
 | 
        AND `gmodel`.`GROUP_ID` = #{gmodelGroupId} 
 | 
      </if> 
 | 
      <if test="gmodelSerialNum != null and gmodelSerialNum != ''"> 
 | 
        AND `gmodel`.`SERIAL_NUM` = #{gmodelSerialNum} 
 | 
      </if> 
 | 
   <!--   <if test="departIds != null and departIds.size()>0"> 
 | 
        AND `pmodel`.`ORG_ID` 
 | 
        in <foreach collection="departIds" item="item" separator="," open="(" close=")">#{item}</foreach> 
 | 
      </if>--> 
 | 
  
 | 
        <if test="departIds != null and departIds.size()>0"> 
 | 
          AND  exists (select d.id from company_user d where   d.user_id =pmodel.`USER_ID`  and d.department_id 
 | 
          in <foreach collection="departIds" item="item" separator="," open="(" close=")">#{item}</foreach>) 
 | 
  
 | 
        </if> 
 | 
  
 | 
  
 | 
  <!--    <choose> 
 | 
        <when test="departIds != null and departIds.size()>0"> 
 | 
          AND ( `udmodel`.`CREATE_USER` = #{createUser} OR    `udmodel`.`USER_ID` = #{createUser} 
 | 
  
 | 
          or exists (select d.id from company_user d where  ( d.user_id =`udmodel`.`CREATE_USER` or d.user_id= udmodel.USER_ID) and d.department_id 
 | 
          in <foreach collection="departIds" item="item" separator="," open="(" close=")">#{item}</foreach>) 
 | 
          ) 
 | 
        </when> 
 | 
        <otherwise> 
 | 
          <if test="createUser != null "> 
 | 
            AND ( `udmodel`.`CREATE_USER` = #{createUser} OR    `udmodel`.`USER_ID` = #{createUser}) 
 | 
          </if> 
 | 
        </otherwise> 
 | 
      </choose>--> 
 | 
    </where> 
 | 
  
 | 
  </select> 
 | 
</mapper> 
 |