<?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.AppliancesExtMapper"> 
 | 
  
 | 
  <!-- 管理页面查询 --> 
 | 
  <resultMap id="AppliancesExtListVO" type="doumeemes.dao.ext.vo.AppliancesExtListVO" 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="wmodel" javaType="doumeemes.dao.business.model.Workorder"> 
 | 
      <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_PLAN_ID" jdbcType="INTEGER" property="planId"/> 
 | 
      <result column="WMODEL_FACTORY_ID" jdbcType="INTEGER" property="factoryId"/> 
 | 
      <result column="WMODEL_PROCEDURE_ID" jdbcType="INTEGER" property="procedureId"/> 
 | 
      <result column="WMODEL_CODE" jdbcType="VARCHAR" property="code"/> 
 | 
      <result column="WMODEL_ORIGIN_WORKORDER_ID" jdbcType="INTEGER" property="originWorkorderId"/> 
 | 
      <result column="WMODEL_TYPE_ID" jdbcType="INTEGER" property="typeId"/> 
 | 
      <result column="WMODEL_ORIGIN_ID" jdbcType="INTEGER" property="originId"/> 
 | 
      <result column="WMODEL_PLAN_DATE" jdbcType="TIMESTAMP" property="planDate"/> 
 | 
      <result column="WMODEL_PLAN_NUM" jdbcType="INTEGER" property="planNum"/> 
 | 
      <result column="WMODEL_MATERIAL_ID" jdbcType="INTEGER" property="materialId"/> 
 | 
      <result column="WMODEL_UNIT_ID" jdbcType="INTEGER" property="unitId"/> 
 | 
      <result column="WMODEL_BATCH" jdbcType="VARCHAR" property="batch"/> 
 | 
      <result column="WMODEL_PRO_USER_ID" jdbcType="INTEGER" property="proUserId"/> 
 | 
      <result column="WMODEL_PRO_GROUP_ID" jdbcType="INTEGER" property="proGroupId"/> 
 | 
      <result column="WMODEL_QUALIFIED_NUM" jdbcType="INTEGER" property="qualifiedNum"/> 
 | 
      <result column="WMODEL_UNQUALIFIED_NUM" jdbcType="INTEGER" property="unqualifiedNum"/> 
 | 
      <result column="WMODEL_CHECK_USER_ID" jdbcType="INTEGER" property="checkUserId"/> 
 | 
      <result column="WMODEL_STATUS" jdbcType="TINYINT" property="status"/> 
 | 
      <result column="WMODEL_LAST_DEAL_DATE" jdbcType="TIMESTAMP" property="lastDealDate"/> 
 | 
      <result column="WMODEL_LAST_DEAL_INFO" jdbcType="VARCHAR" property="lastDealInfo"/> 
 | 
      <result column="WMODEL_URGENT" jdbcType="TINYINT" property="urgent"/> 
 | 
    </association> 
 | 
    <association property="mmodel" javaType="doumeemes.dao.business.model.Material"> 
 | 
      <id column="MMODEL_ID" jdbcType="INTEGER" property="id"/> 
 | 
      <result column="MMODEL_DELETED" jdbcType="TINYINT" property="deleted"/> 
 | 
      <result column="MMODEL_CREATE_USER" jdbcType="INTEGER" property="createUser"/> 
 | 
      <result column="MMODEL_CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/> 
 | 
      <result column="MMODEL_UPDATE_USER" jdbcType="INTEGER" property="updateUser"/> 
 | 
      <result column="MMODEL_UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/> 
 | 
      <result column="MMODEL_REMARK" jdbcType="VARCHAR" property="remark"/> 
 | 
      <result column="MMODEL_ROOT_DEPART_ID" jdbcType="INTEGER" property="rootDepartId"/> 
 | 
      <result column="MMODEL_NAME" jdbcType="VARCHAR" property="name"/> 
 | 
      <result column="MMODEL_CODE" jdbcType="VARCHAR" property="code"/> 
 | 
      <result column="MMODEL_ATTR" jdbcType="VARCHAR" property="attr"/> 
 | 
      <result column="MMODEL_UNION_NAME" jdbcType="VARCHAR" property="unionName"/> 
 | 
      <result column="MMODEL_UNIT_ID" jdbcType="INTEGER" property="unitId"/> 
 | 
      <result column="MMODEL_CATE_UNION_ID" jdbcType="INTEGER" property="cateUnionId"/> 
 | 
      <result column="MMODEL_FORMATION" jdbcType="TINYINT" property="formation"/> 
 | 
      <result column="MMODEL_QRCODE_ID" jdbcType="VARCHAR" property="qrcodeId"/> 
 | 
      <result column="MMODEL_STATUS" jdbcType="TINYINT" property="status"/> 
 | 
      <result column="MMODEL_VALID_TIME" jdbcType="TIMESTAMP" property="validTime"/> 
 | 
      <result column="MMODEL_INVALID_TIME" jdbcType="TIMESTAMP" property="invalidTime"/> 
 | 
      <result column="MMODEL_CHECK_WAY" jdbcType="TINYINT" property="checkWay"/> 
 | 
      <result column="MMODEL_QUALITY_REQUIRE" jdbcType="VARCHAR" property="qualityRequire"/> 
 | 
      <result column="MMODEL_CHECK_NOTE" jdbcType="VARCHAR" property="checkNote"/> 
 | 
    </association> 
 | 
    <association property="mdmodel" javaType="doumeemes.dao.business.model.MaterialDistribute"> 
 | 
      <id column="MDMODEL_ID" jdbcType="INTEGER" property="id"/> 
 | 
      <result column="MDMODEL_DELETED" jdbcType="TINYINT" property="deleted"/> 
 | 
      <result column="MDMODEL_CREATE_USER" jdbcType="INTEGER" property="createUser"/> 
 | 
      <result column="MDMODEL_CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/> 
 | 
      <result column="MDMODEL_UPDATE_USER" jdbcType="INTEGER" property="updateUser"/> 
 | 
      <result column="MDMODEL_UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/> 
 | 
      <result column="MDMODEL_REMARK" jdbcType="VARCHAR" property="remark"/> 
 | 
      <result column="MDMODEL_ROOT_DEPART_ID" jdbcType="INTEGER" property="rootDepartId"/> 
 | 
      <result column="MDMODEL_ATTR" jdbcType="VARCHAR" property="attr"/> 
 | 
      <result column="MDMODEL_UNION_NAME" jdbcType="VARCHAR" property="unionName"/> 
 | 
      <result column="MDMODEL_UNIT_ID" jdbcType="INTEGER" property="unitId"/> 
 | 
      <result column="MDMODEL_CATE_UNION_ID" jdbcType="INTEGER" property="cateUnionId"/> 
 | 
      <result column="MDMODEL_FORMATION" jdbcType="INTEGER" property="formation"/> 
 | 
      <result column="MDMODEL_STATUS" jdbcType="INTEGER" property="status"/> 
 | 
      <result column="MDMODEL_VALID_TIME" jdbcType="TIMESTAMP" property="validTime"/> 
 | 
      <result column="MDMODEL_INVALID_TIME" jdbcType="TIMESTAMP" property="invalidTime"/> 
 | 
      <result column="MDMODEL_CHECK_WAY" jdbcType="INTEGER" property="checkWay"/> 
 | 
    </association> 
 | 
    <association property="whmodel" javaType="doumeemes.dao.business.model.Warehouse"> 
 | 
      <id column="WHMODEL_ID" jdbcType="INTEGER" property="id"/> 
 | 
      <result column="WHMODEL_DELETED" jdbcType="TINYINT" property="deleted"/> 
 | 
      <result column="WHMODEL_CREATE_USER" jdbcType="INTEGER" property="createUser"/> 
 | 
      <result column="WHMODEL_CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/> 
 | 
      <result column="WHMODEL_UPDATE_USER" jdbcType="INTEGER" property="updateUser"/> 
 | 
      <result column="WHMODEL_UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/> 
 | 
      <result column="WHMODEL_REMARK" jdbcType="VARCHAR" property="remark"/> 
 | 
      <result column="WHMODEL_ROOT_DEPART_ID" jdbcType="INTEGER" property="rootDepartId"/> 
 | 
      <result column="WHMODEL_DEPART_ID" jdbcType="INTEGER" property="departId"/> 
 | 
      <result column="WHMODEL_PROCEDURE_ID" jdbcType="INTEGER" property="procedureId"/> 
 | 
      <result column="WHMODEL_QRCODE" jdbcType="INTEGER" property="qrcode"/> 
 | 
      <result column="WHMODEL_NAME" jdbcType="VARCHAR" property="name"/> 
 | 
      <result column="WHMODEL_USE_LOCATION" jdbcType="TINYINT" property="useLocation"/> 
 | 
      <result column="WHMODEL_STATUS" jdbcType="TINYINT" property="status"/> 
 | 
      <result column="WHMODEL_ADDR" jdbcType="VARCHAR" property="addr"/> 
 | 
    </association> 
 | 
    <association property="lmodel" javaType="doumeemes.dao.business.model.WarehouseLocation"> 
 | 
      <id column="LMODEL_ID" jdbcType="INTEGER" property="id"/> 
 | 
      <result column="LMODEL_DELETED" jdbcType="TINYINT" property="deleted"/> 
 | 
      <result column="LMODEL_CREATE_USER" jdbcType="INTEGER" property="createUser"/> 
 | 
      <result column="LMODEL_CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/> 
 | 
      <result column="LMODEL_UPDATE_USER" jdbcType="INTEGER" property="updateUser"/> 
 | 
      <result column="LMODEL_UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/> 
 | 
      <result column="LMODEL_REMARK" jdbcType="VARCHAR" property="remark"/> 
 | 
      <result column="LMODEL_ROOT_DEPART_ID" jdbcType="INTEGER" property="rootDepartId"/> 
 | 
      <result column="LMODEL_WAREHOUSE_ID" jdbcType="INTEGER" property="warehouseId"/> 
 | 
      <result column="LMODEL_UNION_NAME" jdbcType="VARCHAR" property="unionName"/> 
 | 
      <result column="LMODEL_AREA" jdbcType="VARCHAR" property="area"/> 
 | 
      <result column="LMODEL_SHELF" jdbcType="VARCHAR" property="shelf"/> 
 | 
      <result column="LMODEL_CELL" jdbcType="VARCHAR" property="cell"/> 
 | 
      <result column="LMODEL_QRCODE" jdbcType="INTEGER" property="qrcode"/> 
 | 
      <result column="LMODEL_STATUS" jdbcType="TINYINT" property="status"/> 
 | 
    </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="cumodel" javaType="doumeemes.dao.business.model.CategoryUnion"> 
 | 
      <id column="CUMODEL_ID" jdbcType="INTEGER" property="id"/> 
 | 
      <result column="CUMODEL_DELETED" jdbcType="TINYINT" property="deleted"/> 
 | 
      <result column="CUMODEL_CREATE_USER" jdbcType="INTEGER" property="createUser"/> 
 | 
      <result column="CUMODEL_CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/> 
 | 
      <result column="CUMODEL_UPDATE_USER" jdbcType="INTEGER" property="updateUser"/> 
 | 
      <result column="CUMODEL_UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/> 
 | 
      <result column="CUMODEL_REMARK" jdbcType="VARCHAR" property="remark"/> 
 | 
      <result column="CUMODEL_ROOT_DEPART_ID" jdbcType="INTEGER" property="rootDepartId"/> 
 | 
      <result column="CUMODEL_CATE_BIG_ID" jdbcType="INTEGER" property="cateBigId"/> 
 | 
      <result column="CUMODEL_CATE_MIDDLE_ID" jdbcType="INTEGER" property="cateMiddleId"/> 
 | 
      <result column="CUMODEL_CATE_SMALL_ID" jdbcType="INTEGER" property="cateSmallId"/> 
 | 
    </association> 
 | 
  </resultMap> 
 | 
  <select id="selectList" parameterType="doumeemes.dao.ext.dto.QueryAppliancesExtDTO" resultMap="AppliancesExtListVO"> 
 | 
    SELECT 
 | 
      `a`.*, 
 | 
      u.name as umodelName, 
 | 
      u.ATTRIBUTE_DATA as umodelData, 
 | 
      `mdmodel`.`UNIT_ID` AS MDMODEL_UNIT_ID, 
 | 
      `mdmodel`.`ID` AS MDMODEL_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, 
 | 
      `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`.`PLAN_ID` AS WMODEL_PLAN_ID, 
 | 
      `wmodel`.`FACTORY_ID` AS WMODEL_FACTORY_ID, 
 | 
      `wmodel`.`PROCEDURE_ID` AS WMODEL_PROCEDURE_ID, 
 | 
      `wmodel`.`CODE` AS WMODEL_CODE, 
 | 
      `wmodel`.`ORIGIN_WORKORDER_ID` AS WMODEL_ORIGIN_WORKORDER_ID, 
 | 
      `wmodel`.`TYPE_ID` AS WMODEL_TYPE_ID, 
 | 
      `wmodel`.`ORIGIN_ID` AS WMODEL_ORIGIN_ID, 
 | 
      `wmodel`.`PLAN_DATE` AS WMODEL_PLAN_DATE, 
 | 
      `wmodel`.`PLAN_NUM` AS WMODEL_PLAN_NUM, 
 | 
      `wmodel`.`MATERIAL_ID` AS WMODEL_MATERIAL_ID, 
 | 
      `wmodel`.`UNIT_ID` AS WMODEL_UNIT_ID, 
 | 
      `wmodel`.`BATCH` AS WMODEL_BATCH, 
 | 
      `wmodel`.`PRO_USER_ID` AS WMODEL_PRO_USER_ID, 
 | 
      `wmodel`.`PRO_GROUP_ID` AS WMODEL_PRO_GROUP_ID, 
 | 
      `wmodel`.`QUALIFIED_NUM` AS WMODEL_QUALIFIED_NUM, 
 | 
      `wmodel`.`UNQUALIFIED_NUM` AS WMODEL_UNQUALIFIED_NUM, 
 | 
      `wmodel`.`CHECK_USER_ID` AS WMODEL_CHECK_USER_ID, 
 | 
      `wmodel`.`STATUS` AS WMODEL_STATUS, 
 | 
      `wmodel`.`LAST_DEAL_DATE` AS WMODEL_LAST_DEAL_DATE, 
 | 
      `wmodel`.`LAST_DEAL_INFO` AS WMODEL_LAST_DEAL_INFO, 
 | 
      `wmodel`.`URGENT` AS WMODEL_URGENT, 
 | 
      `whmodel`.`ID` AS WHMODEL_ID, 
 | 
      `whmodel`.`DELETED` AS WHMODEL_DELETED, 
 | 
      `whmodel`.`CREATE_USER` AS WHMODEL_CREATE_USER, 
 | 
      `whmodel`.`CREATE_TIME` AS WHMODEL_CREATE_TIME, 
 | 
      `whmodel`.`UPDATE_USER` AS WHMODEL_UPDATE_USER, 
 | 
      `whmodel`.`UPDATE_TIME` AS WHMODEL_UPDATE_TIME, 
 | 
      `whmodel`.`REMARK` AS WHMODEL_REMARK, 
 | 
      `whmodel`.`ROOT_DEPART_ID` AS WHMODEL_ROOT_DEPART_ID, 
 | 
      `whmodel`.`DEPART_ID` AS WHMODEL_DEPART_ID, 
 | 
      `whmodel`.`PROCEDURE_ID` AS WHMODEL_PROCEDURE_ID, 
 | 
      `whmodel`.`QRCODE` AS WHMODEL_QRCODE, 
 | 
      `whmodel`.`NAME` AS WHMODEL_NAME, 
 | 
      `whmodel`.`USE_LOCATION` AS WHMODEL_USE_LOCATION, 
 | 
      `whmodel`.`STATUS` AS WHMODEL_STATUS, 
 | 
      `whmodel`.`ADDR` AS WHMODEL_ADDR, 
 | 
      `lmodel`.`ID` AS LMODEL_ID, 
 | 
      `lmodel`.`DELETED` AS LMODEL_DELETED, 
 | 
      `lmodel`.`CREATE_USER` AS LMODEL_CREATE_USER, 
 | 
      `lmodel`.`CREATE_TIME` AS LMODEL_CREATE_TIME, 
 | 
      `lmodel`.`UPDATE_USER` AS LMODEL_UPDATE_USER, 
 | 
      `lmodel`.`UPDATE_TIME` AS LMODEL_UPDATE_TIME, 
 | 
      `lmodel`.`REMARK` AS LMODEL_REMARK, 
 | 
      `lmodel`.`ROOT_DEPART_ID` AS LMODEL_ROOT_DEPART_ID, 
 | 
      `lmodel`.`WAREHOUSE_ID` AS LMODEL_WAREHOUSE_ID, 
 | 
      `lmodel`.`UNION_NAME` AS LMODEL_UNION_NAME, 
 | 
      `lmodel`.`AREA` AS LMODEL_AREA, 
 | 
      `lmodel`.`SHELF` AS LMODEL_SHELF, 
 | 
      `lmodel`.`CELL` AS LMODEL_CELL, 
 | 
      `lmodel`.`QRCODE` AS LMODEL_QRCODE, 
 | 
      `lmodel`.`STATUS` AS LMODEL_STATUS, 
 | 
      `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, 
 | 
      (select st.batch from w_stock st where st.`LOCATION_ID`=a.`LOCATION_ID` and st.deleted=0 and st. `MATERIAL_ID` =a. `MATERIAL_ID` limit 1) as proBatch, 
 | 
    `cumodel`.`ID` AS CUMODEL_ID, 
 | 
    `cumodel`.`DELETED` AS CUMODEL_DELETED, 
 | 
    `cumodel`.`CREATE_USER` AS CUMODEL_CREATE_USER, 
 | 
    `cumodel`.`CREATE_TIME` AS CUMODEL_CREATE_TIME, 
 | 
    `cumodel`.`UPDATE_USER` AS CUMODEL_UPDATE_USER, 
 | 
    `cumodel`.`UPDATE_TIME` AS CUMODEL_UPDATE_TIME, 
 | 
    `cumodel`.`REMARK` AS CUMODEL_REMARK, 
 | 
    `cumodel`.`ROOT_DEPART_ID` AS CUMODEL_ROOT_DEPART_ID, 
 | 
    `cumodel`.`CATE_BIG_ID` AS CUMODEL_CATE_BIG_ID, 
 | 
    `cumodel`.`CATE_MIDDLE_ID` AS CUMODEL_CATE_MIDDLE_ID, 
 | 
    `cumodel`.`CATE_SMALL_ID` AS CUMODEL_CATE_SMALL_ID, 
 | 
    mmodel.code as materialCode, 
 | 
    mmodel.name as materialName, 
 | 
  <!--  cmodel1.name as cmodel1BigName, cmodel2.name as cmodel1MiddleName, cmodel3.name as cmodel1SmallName,--> 
 | 
    `smodel`.code as SMODEL_CODE 
 | 
    FROM `appliances` `a` 
 | 
    LEFT JOIN `department` `dmodel` ON a.DEPART_ID=dmodel.ID 
 | 
    LEFT JOIN `workorder` `wmodel` ON a.WORKORDER_ID=wmodel.ID 
 | 
    LEFT JOIN `material_distribute` `mdmodel` ON a.MATERIAL_ID=mdmodel.ID 
 | 
    LEFT JOIN `unit` `u` ON mdmodel.UNIT_ID=u.ID 
 | 
    LEFT JOIN `material` `mmodel` ON mdmodel.MATERIAL_ID=mmodel.ID 
 | 
    LEFT JOIN `warehouse` `whmodel` ON a.WAREHOUSE_ID=whmodel.ID 
 | 
    LEFT JOIN `warehouse_location` `lmodel` ON a.LOCATION_ID=lmodel.ID 
 | 
    LEFT JOIN `procedures` `pmodel` ON a.PROCEDURE_ID=pmodel.ID 
 | 
    LEFT JOIN `system_dict_data` `smodel` ON a.TYPE=smodel.ID 
 | 
    LEFT JOIN `category_union` `cumodel` ON a.`CATEGORY_ID`=cumodel.ID 
 | 
  <!--  LEFT JOIN `category` `cmodel1` ON cumodel.CATE_BIG_ID=cmodel1.ID 
 | 
    LEFT JOIN `category` `cmodel2` ON cumodel.`CATE_MIDDLE_ID`=cmodel2.ID 
 | 
    LEFT JOIN `category` `cmodel3` ON cumodel.`CATE_SMALL_ID`=cmodel3.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="serialNum != null and serialNum != ''"> 
 | 
        AND `a`.`SERIAL_NUM` = #{serialNum} 
 | 
      </if> 
 | 
      <if test="brcode != null"> 
 | 
        AND `a`.`BRCODE` = #{brcode} 
 | 
      </if> 
 | 
      <if test="validTime != null"> 
 | 
        AND `a`.`VALID_TIME` = #{validTime} 
 | 
      </if> 
 | 
      <if test="type != null"> 
 | 
        AND `a`.`TYPE` = #{type} 
 | 
      </if> 
 | 
      <if test="status != null"> 
 | 
        AND `a`.`STATUS` = #{status} 
 | 
      </if> 
 | 
      <if test="workorderId != null"> 
 | 
        AND `a`.`WORKORDER_ID` = #{workorderId} 
 | 
      </if> 
 | 
      <if test="backorderId != null"> 
 | 
        AND `a`.`BACKORDER_ID` = #{backorderId} 
 | 
      </if> 
 | 
      <if test="materialId != null and materialId != ''"> 
 | 
        AND `a`.`MATERIAL_ID` = #{materialId} 
 | 
      </if> 
 | 
      <if test="num != null"> 
 | 
        AND `a`.`NUM` = #{num} 
 | 
      </if> 
 | 
      <if test="code != null and code != ''"> 
 | 
        AND `a`.`CODE` = #{code} 
 | 
      </if> 
 | 
      <if test="positionType != null"> 
 | 
        AND `a`.`POSITION_TYPE` = #{positionType} 
 | 
      </if> 
 | 
      <if test="warehouseId != null"> 
 | 
        AND `a`.`WAREHOUSE_ID` = #{warehouseId} 
 | 
      </if> 
 | 
      <if test="locationId != null"> 
 | 
        AND `a`.`LOCATION_ID` = #{locationId} 
 | 
      </if> 
 | 
      <if test="procedureId != null"> 
 | 
        AND `a`.`PROCEDURE_ID` = #{procedureId} 
 | 
      </if> 
 | 
      <if test="curObjType != null"> 
 | 
        AND `a`.`CUR_OBJ_TYPE` = #{curObjType} 
 | 
      </if> 
 | 
      <if test="curObjId != null"> 
 | 
        AND `a`.`CUR_OBJ_ID` = #{curObjId} 
 | 
      </if> 
 | 
  
 | 
      <if test="qualityType != null"> 
 | 
        AND a.QUALITY_TYPE = #{qualityType} 
 | 
      </if> 
 | 
      <if test="batch != null"> 
 | 
        AND a.BATCH = #{batch} 
 | 
      </if> 
 | 
      <if test="saleorderId != null"> 
 | 
        AND a.SALEORDER_ID = #{saleorderId} 
 | 
      </if> 
 | 
      <if test="backProcedureId != null"> 
 | 
        AND a.BACK_PROCEDURE_ID= #{backProcedureId} 
 | 
      </if> 
 | 
      <if test="nextProcedureId != null"> 
 | 
        AND a.NEXT_PROCEDURE_ID, = #{nextProcedureId} 
 | 
      </if> 
 | 
      <if test="relobjType != null"> 
 | 
        AND a.RELOBJ_TYPE = #{relobjType} 
 | 
      </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="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="wmodelPlanId != null"> 
 | 
        AND `wmodel`.`PLAN_ID` = #{wmodelPlanId} 
 | 
      </if> 
 | 
      <if test="wmodelFactoryId != null"> 
 | 
        AND `wmodel`.`FACTORY_ID` = #{wmodelFactoryId} 
 | 
      </if> 
 | 
      <if test="wmodelProcedureId != null"> 
 | 
        AND `wmodel`.`PROCEDURE_ID` = #{wmodelProcedureId} 
 | 
      </if> 
 | 
      <if test="wmodelCode != null and wmodelCode != ''"> 
 | 
        AND `wmodel`.`CODE` = #{wmodelCode} 
 | 
      </if> 
 | 
      <if test="wmodelOriginWorkorderId != null"> 
 | 
        AND `wmodel`.`ORIGIN_WORKORDER_ID` = #{wmodelOriginWorkorderId} 
 | 
      </if> 
 | 
      <if test="wmodelTypeId != null"> 
 | 
        AND `wmodel`.`TYPE_ID` = #{wmodelTypeId} 
 | 
      </if> 
 | 
      <if test="wmodelOriginId != null"> 
 | 
        AND `wmodel`.`ORIGIN_ID` = #{wmodelOriginId} 
 | 
      </if> 
 | 
      <if test="wmodelPlanDate != null"> 
 | 
        AND `wmodel`.`PLAN_DATE` = #{wmodelPlanDate} 
 | 
      </if> 
 | 
      <if test="wmodelPlanNum != null"> 
 | 
        AND `wmodel`.`PLAN_NUM` = #{wmodelPlanNum} 
 | 
      </if> 
 | 
      <if test="wmodelMaterialId != null"> 
 | 
        AND `wmodel`.`MATERIAL_ID` = #{wmodelMaterialId} 
 | 
      </if> 
 | 
      <if test="wmodelUnitId != null"> 
 | 
        AND `wmodel`.`UNIT_ID` = #{wmodelUnitId} 
 | 
      </if> 
 | 
      <if test="wmodelBatch != null and wmodelBatch != ''"> 
 | 
        AND `wmodel`.`BATCH` = #{wmodelBatch} 
 | 
      </if> 
 | 
      <if test="wmodelProUserId != null"> 
 | 
        AND `wmodel`.`PRO_USER_ID` = #{wmodelProUserId} 
 | 
      </if> 
 | 
      <if test="wmodelProGroupId != null"> 
 | 
        AND `wmodel`.`PRO_GROUP_ID` = #{wmodelProGroupId} 
 | 
      </if> 
 | 
      <if test="wmodelQualifiedNum != null"> 
 | 
        AND `wmodel`.`QUALIFIED_NUM` = #{wmodelQualifiedNum} 
 | 
      </if> 
 | 
      <if test="wmodelUnqualifiedNum != null"> 
 | 
        AND `wmodel`.`UNQUALIFIED_NUM` = #{wmodelUnqualifiedNum} 
 | 
      </if> 
 | 
      <if test="wmodelCheckUserId != null"> 
 | 
        AND `wmodel`.`CHECK_USER_ID` = #{wmodelCheckUserId} 
 | 
      </if> 
 | 
      <if test="wmodelStatus != null"> 
 | 
        AND `wmodel`.`STATUS` = #{wmodelStatus} 
 | 
      </if> 
 | 
      <if test="wmodelLastDealDate != null"> 
 | 
        AND `wmodel`.`LAST_DEAL_DATE` = #{wmodelLastDealDate} 
 | 
      </if> 
 | 
      <if test="wmodelLastDealInfo != null and wmodelLastDealInfo != ''"> 
 | 
        AND `wmodel`.`LAST_DEAL_INFO` = #{wmodelLastDealInfo} 
 | 
      </if> 
 | 
      <if test="wmodelUrgent != null"> 
 | 
        AND `wmodel`.`URGENT` = #{wmodelUrgent} 
 | 
      </if> 
 | 
      <if test="whmodelId != null"> 
 | 
        AND `whmodel`.`ID` = #{whmodelId} 
 | 
      </if> 
 | 
      <if test="whmodelDeleted != null"> 
 | 
        AND `whmodel`.`DELETED` = #{whmodelDeleted} 
 | 
      </if> 
 | 
      <if test="whmodelCreateUser != null"> 
 | 
        AND `whmodel`.`CREATE_USER` = #{whmodelCreateUser} 
 | 
      </if> 
 | 
      <if test="whmodelCreateTime != null"> 
 | 
        AND `whmodel`.`CREATE_TIME` = #{whmodelCreateTime} 
 | 
      </if> 
 | 
      <if test="whmodelUpdateUser != null"> 
 | 
        AND `whmodel`.`UPDATE_USER` = #{whmodelUpdateUser} 
 | 
      </if> 
 | 
      <if test="whmodelUpdateTime != null"> 
 | 
        AND `whmodel`.`UPDATE_TIME` = #{whmodelUpdateTime} 
 | 
      </if> 
 | 
      <if test="whmodelRemark != null and whmodelRemark != ''"> 
 | 
        AND `whmodel`.`REMARK` = #{whmodelRemark} 
 | 
      </if> 
 | 
      <if test="whmodelRootDepartId != null"> 
 | 
        AND `whmodel`.`ROOT_DEPART_ID` = #{whmodelRootDepartId} 
 | 
      </if> 
 | 
      <if test="whmodelDepartId != null"> 
 | 
        AND `whmodel`.`DEPART_ID` = #{whmodelDepartId} 
 | 
      </if> 
 | 
      <if test="whmodelProcedureId != null"> 
 | 
        AND `whmodel`.`PROCEDURE_ID` = #{whmodelProcedureId} 
 | 
      </if> 
 | 
      <if test="whmodelQrcode != null"> 
 | 
        AND `whmodel`.`QRCODE` = #{whmodelQrcode} 
 | 
      </if> 
 | 
      <if test="whmodelName != null and whmodelName != ''"> 
 | 
        AND `whmodel`.`NAME` = #{whmodelName} 
 | 
      </if> 
 | 
      <if test="whmodelUseLocation != null"> 
 | 
        AND `whmodel`.`USE_LOCATION` = #{whmodelUseLocation} 
 | 
      </if> 
 | 
      <if test="whmodelStatus != null"> 
 | 
        AND `whmodel`.`STATUS` = #{whmodelStatus} 
 | 
      </if> 
 | 
      <if test="whmodelAddr != null and whmodelAddr != ''"> 
 | 
        AND `whmodel`.`ADDR` = #{whmodelAddr} 
 | 
      </if> 
 | 
      <if test="lmodelId != null"> 
 | 
        AND `lmodel`.`ID` = #{lmodelId} 
 | 
      </if> 
 | 
      <if test="lmodelDeleted != null"> 
 | 
        AND `lmodel`.`DELETED` = #{lmodelDeleted} 
 | 
      </if> 
 | 
      <if test="lmodelCreateUser != null"> 
 | 
        AND `lmodel`.`CREATE_USER` = #{lmodelCreateUser} 
 | 
      </if> 
 | 
      <if test="lmodelCreateTime != null"> 
 | 
        AND `lmodel`.`CREATE_TIME` = #{lmodelCreateTime} 
 | 
      </if> 
 | 
      <if test="lmodelUpdateUser != null"> 
 | 
        AND `lmodel`.`UPDATE_USER` = #{lmodelUpdateUser} 
 | 
      </if> 
 | 
      <if test="lmodelUpdateTime != null"> 
 | 
        AND `lmodel`.`UPDATE_TIME` = #{lmodelUpdateTime} 
 | 
      </if> 
 | 
      <if test="lmodelRemark != null and lmodelRemark != ''"> 
 | 
        AND `lmodel`.`REMARK` = #{lmodelRemark} 
 | 
      </if> 
 | 
      <if test="lmodelRootDepartId != null"> 
 | 
        AND `lmodel`.`ROOT_DEPART_ID` = #{lmodelRootDepartId} 
 | 
      </if> 
 | 
      <if test="lmodelWarehouseId != null"> 
 | 
        AND `lmodel`.`WAREHOUSE_ID` = #{lmodelWarehouseId} 
 | 
      </if> 
 | 
      <if test="lmodelUnionName != null and lmodelUnionName != ''"> 
 | 
        AND `lmodel`.`UNION_NAME` = #{lmodelUnionName} 
 | 
      </if> 
 | 
      <if test="lmodelArea != null and lmodelArea != ''"> 
 | 
        AND `lmodel`.`AREA` = #{lmodelArea} 
 | 
      </if> 
 | 
      <if test="lmodelShelf != null and lmodelShelf != ''"> 
 | 
        AND `lmodel`.`SHELF` = #{lmodelShelf} 
 | 
      </if> 
 | 
      <if test="lmodelCell != null and lmodelCell != ''"> 
 | 
        AND `lmodel`.`CELL` = #{lmodelCell} 
 | 
      </if> 
 | 
      <if test="lmodelQrcode != null"> 
 | 
        AND `lmodel`.`QRCODE` = #{lmodelQrcode} 
 | 
      </if> 
 | 
      <if test="lmodelStatus != null"> 
 | 
        AND `lmodel`.`STATUS` = #{lmodelStatus} 
 | 
      </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="statusname != null and statusname!=''"> 
 | 
        AND   locate(a.status,#{statusname}) 
 | 
      </if> 
 | 
      <if test="smodelLabel != null and smodelLabel!=''"> 
 | 
        AND `smodel`.label = #{smodelLabel} 
 | 
      </if> 
 | 
      <if test="recordList != null and recordList.size()>0"> 
 | 
        AND `a`.`id` in <foreach collection="recordList" open="(" close=")" item="item" separator=",">#{item.applianceId}</foreach> 
 | 
      </if> 
 | 
    </where> 
 | 
  </select> 
 | 
  
 | 
  
 | 
  
 | 
  <select id="findMaxSerial" parameterType="doumeemes.dao.ext.dto.QueryAppliancesExtDTO" resultMap="AppliancesExtListVO"> 
 | 
    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`, 
 | 
    MAX(CAST(`a`.`SERIAL_NUM` AS SIGNED))   as SERIAL_NUM 
 | 
    FROM `appliances` `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="serialNum != null and serialNum != ''"> 
 | 
        AND `a`.`SERIAL_NUM` = #{serialNum} 
 | 
      </if> 
 | 
      <if test="brcode != null"> 
 | 
        AND `a`.`BRCODE` = #{brcode} 
 | 
      </if> 
 | 
      <if test="validTime != null"> 
 | 
        AND `a`.`VALID_TIME` = #{validTime} 
 | 
      </if> 
 | 
      <if test="type != null"> 
 | 
        AND `a`.`TYPE` = #{type} 
 | 
      </if> 
 | 
  
 | 
      <if test="categoryId != null"> 
 | 
        AND `a`.`CATEGORY_ID` = #{categoryId} 
 | 
      </if> 
 | 
      <if test="status != null"> 
 | 
        AND `a`.`STATUS` = #{status} 
 | 
      </if> 
 | 
      <if test="workorderId != null"> 
 | 
        AND `a`.`WORKORDER_ID` = #{workorderId} 
 | 
      </if> 
 | 
      <if test="materialId != null and materialId != ''"> 
 | 
        AND `a`.`MATERIAL_ID` = #{materialId} 
 | 
      </if> 
 | 
      <if test="num != null"> 
 | 
        AND `a`.`NUM` = #{num} 
 | 
      </if> 
 | 
      <if test="code != null and code != ''"> 
 | 
        AND `a`.`CODE` = #{code} 
 | 
      </if> 
 | 
      <if test="positionType != null"> 
 | 
        AND `a`.`POSITION_TYPE` = #{positionType} 
 | 
      </if> 
 | 
      <if test="warehouseId != null"> 
 | 
        AND `a`.`WAREHOUSE_ID` = #{warehouseId} 
 | 
      </if> 
 | 
      <if test="locationId != null"> 
 | 
        AND `a`.`LOCATION_ID` = #{locationId} 
 | 
      </if> 
 | 
      <if test="procedureId != null"> 
 | 
        AND `a`.`PROCEDURE_ID` = #{procedureId} 
 | 
      </if> 
 | 
      <if test="curObjType != null"> 
 | 
        AND `a`.`CUR_OBJ_TYPE` = #{curObjType} 
 | 
      </if> 
 | 
      <if test="curObjId != null"> 
 | 
        AND `a`.`CUR_OBJ_ID` = #{curObjId} 
 | 
      </if> 
 | 
    </where> 
 | 
  </select> 
 | 
  
 | 
  <select id="selectListByCondition" parameterType="doumeemes.dao.ext.dto.QueryAppliancesExtDTO" resultType="doumeemes.dao.ext.vo.AppliancesExtListVO"> 
 | 
    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`.`SERIAL_NUM`, 
 | 
    `a`.`BRCODE`, 
 | 
    `a`.`VALID_TIME`, 
 | 
    `a`.`TYPE`, 
 | 
    `a`.`STATUS`, 
 | 
    `a`.`WORKORDER_ID`, 
 | 
    `a`.`MATERIAL_ID`, 
 | 
    `a`.`NUM`, 
 | 
    `a`.`CODE`, 
 | 
    `a`.`POSITION_TYPE`, 
 | 
    `a`.`WAREHOUSE_ID`, 
 | 
    `a`.`LOCATION_ID`, 
 | 
    `a`.`PROCEDURE_ID`, 
 | 
    `a`.`CUR_OBJ_TYPE`, 
 | 
    `a`.`CUR_OBJ_ID`, 
 | 
    a.CATEGORY_ID, 
 | 
    a.QUALITY_TYPE ,a.BATCH,a.SALEORDER_ID,a.BACKORDER_ID,a.BACK_PROCEDURE_ID,a.NEXT_PROCEDURE_ID,a.RELOBJ_TYPE, 
 | 
    `mmodel`.`NAME` AS MMODEL_NAME, 
 | 
    `mmodel`.`CODE` AS MMODEL_CODE, 
 | 
    `whmodel`.`NAME` AS WHMODEL_NAME, 
 | 
    wmodel.code as WMODEL_CODE, 
 | 
    `lmodel`.`UNION_NAME` AS LMODEL_UNION_NAME, 
 | 
    `pmodel`.`NAME` AS PMODEL_NAME, 
 | 
    `pmodel`.`ORG_ID` AS PMODEL_ORG_ID, 
 | 
    `smodel`.code as SMODEL_CODE, 
 | 
    `smodel`.label as SMODEL_LABEL, 
 | 
    vmodel.STATION_CODE as VMODEL_STATION_CODE, 
 | 
 <!--   cmodel1.name as cmodel1BigName, cmodel2.name as cmodel1MiddleName, cmodel3.name as cmodel1SmallName,--> 
 | 
    `cumodel`.`CATE_BIG_ID` AS CUMODEL_CATE_BIG_ID, 
 | 
    `cumodel`.`CATE_MIDDLE_ID` AS CUMODEL_CATE_MIDDLE_ID, 
 | 
    `cumodel`.`CATE_SMALL_ID` AS CUMODEL_CATE_SMALL_ID, 
 | 
    `umodel`.`NAME` AS UMODEL_NAME, 
 | 
    umodel.ATTRIBUTE_DATA as umodelData, 
 | 
    `fxpmodel`.`NAME` AS FXPMODEL_NAME, 
 | 
    `xypmodel`.`NAME` AS XYPMODEL_NAME, 
 | 
    salemodel.code as SALEMODEL_CODE, 
 | 
    cmodel.name as CMODEL_NAME, 
 | 
    `dmodel`.`ID` AS DMODEL_ID, 
 | 
    `dpmodel`.`NAME` AS DPMODEL_NAME, 
 | 
    mdmodel.unit_id as unitId, 
 | 
    case when a.RELOBJ_TYPE = 0 then wmodel.code  when a.RELOBJ_TYPE = 1 then acmodel.code else '' end zjcode 
 | 
  
 | 
    FROM `appliances` `a` 
 | 
    LEFT JOIN `department` `dmodel` ON a.DEPART_ID=dmodel.ID 
 | 
    LEFT JOIN `workorder` `wmodel` ON a.WORKORDER_ID=wmodel.ID 
 | 
    left join device vmodel on vmodel.id=wmodel.PRO_GROUP_ID 
 | 
    LEFT JOIN `material_distribute` `mdmodel` ON a.MATERIAL_ID=mdmodel.ID 
 | 
    LEFT JOIN `material` `mmodel` ON mdmodel.MATERIAL_ID=mmodel.ID 
 | 
    LEFT JOIN `unit` `umodel` ON mmodel.UNIT_ID=umodel.ID 
 | 
    LEFT JOIN `warehouse` `whmodel` ON a.WAREHOUSE_ID=whmodel.ID 
 | 
    LEFT JOIN `warehouse_location` `lmodel` ON a.LOCATION_ID=lmodel.ID 
 | 
    LEFT JOIN `procedures` `pmodel` ON a.PROCEDURE_ID=pmodel.ID 
 | 
    LEFT JOIN `department` `dpmodel` ON dpmodel.id=pmodel.ORG_ID 
 | 
    LEFT JOIN `system_dict_data` `smodel` ON a.TYPE=smodel.ID 
 | 
    LEFT JOIN `category_union` `cumodel` ON a.`CATEGORY_ID`=cumodel.ID 
 | 
    LEFT JOIN `procedures` `fxpmodel` ON a.BACK_PROCEDURE_ID=fxpmodel.ID 
 | 
    LEFT JOIN `procedures` `xypmodel` ON a.NEXT_PROCEDURE_ID=xypmodel.ID 
 | 
  
 | 
    LEFT JOIN `salesorder` `salemodel` ON a.SALEORDER_ID=salemodel.ID 
 | 
    LEFT JOIN `customer_distribute` `cdmodel` ON salemodel.CUSTOMER_ID=cdmodel.ID 
 | 
    LEFT JOIN `customer` `cmodel` ON cdmodel.CUSTOMER_ID=cmodel.ID 
 | 
    LEFT JOIN `appliance_change` `acmodel` ON a.WORKORDER_ID=acmodel.ID 
 | 
  
 | 
  
 | 
  
 | 
    <!--   LEFT JOIN `category` `cmodel1` ON cumodel.CATE_BIG_ID=cmodel1.ID 
 | 
      LEFT JOIN `category` `cmodel2` ON cumodel.`CATE_MIDDLE_ID`=cmodel2.ID 
 | 
      LEFT JOIN `category` `cmodel3` ON cumodel.`CATE_SMALL_ID`=cmodel3.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="categoryId != null"> 
 | 
        AND a.`CATEGORY_ID` = #{categoryId} 
 | 
      </if> 
 | 
      <if test="serialNum != null and serialNum != ''"> 
 | 
        AND `a`.`SERIAL_NUM` = #{serialNum} 
 | 
      </if> 
 | 
      <if test="brcode != null"> 
 | 
        AND `a`.`BRCODE` = #{brcode} 
 | 
      </if> 
 | 
      <if test="validTime != null"> 
 | 
        AND `a`.`VALID_TIME` = #{validTime} 
 | 
      </if> 
 | 
      <if test="type != null"> 
 | 
        AND `a`.`TYPE` = #{type} 
 | 
      </if> 
 | 
      <if test="status != null"> 
 | 
        AND `a`.`STATUS` = #{status} 
 | 
      </if> 
 | 
      <if test="workorderId != null"> 
 | 
        AND `a`.`WORKORDER_ID` = #{workorderId} 
 | 
      </if> 
 | 
      <if test="materialId != null and materialId != ''"> 
 | 
        AND `a`.`MATERIAL_ID` = #{materialId} 
 | 
      </if> 
 | 
      <if test="num != null"> 
 | 
        AND `a`.`NUM` = #{num} 
 | 
      </if> 
 | 
      <if test="code != null and code != ''"> 
 | 
        AND `a`.`CODE` like CONCAT('%', #{code},'%') 
 | 
      </if> 
 | 
      <if test="positionType != null"> 
 | 
        AND `a`.`POSITION_TYPE` = #{positionType} 
 | 
      </if> 
 | 
      <if test="warehouseId != null"> 
 | 
        AND `a`.`WAREHOUSE_ID` = #{warehouseId} 
 | 
      </if> 
 | 
      <if test="locationId != null"> 
 | 
        AND `a`.`LOCATION_ID` = #{locationId} 
 | 
      </if> 
 | 
      <if test="procedureId != null"> 
 | 
        AND `a`.`PROCEDURE_ID` = #{procedureId} 
 | 
      </if> 
 | 
      <if test="curObjType != null"> 
 | 
        AND `a`.`CUR_OBJ_TYPE` = #{curObjType} 
 | 
      </if> 
 | 
      <if test="curObjId != null"> 
 | 
        AND `a`.`CUR_OBJ_ID` = #{curObjId} 
 | 
      </if> 
 | 
      <if test="qualityType != null"> 
 | 
        AND a.QUALITY_TYPE = #{qualityType} 
 | 
      </if> 
 | 
      <if test="batch != null and batch!=''"> 
 | 
        AND a.BATCH = #{batch} 
 | 
      </if> 
 | 
      <if test="backorderId != null"> 
 | 
        AND a.BACKORDER_ID = #{backorderId} 
 | 
      </if> 
 | 
      <if test="saleorderId != null"> 
 | 
        AND a.SALEORDER_ID = #{saleorderId} 
 | 
      </if> 
 | 
      <if test="backProcedureId != null"> 
 | 
        AND a.BACK_PROCEDURE_ID= #{backProcedureId} 
 | 
      </if> 
 | 
      <if test="nextProcedureId != null"> 
 | 
        AND a.NEXT_PROCEDURE_ID, = #{nextProcedureId} 
 | 
      </if> 
 | 
      <if test="relobjType != null"> 
 | 
        AND a.RELOBJ_TYPE = #{relobjType} 
 | 
      </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="mmodelName != null and mmodelName != ''"> 
 | 
        AND (`mmodel`.`NAME` like concat('%', #{mmodelName},'%') or   `mmodel`.`CODE` = #{mmodelName}) 
 | 
      </if> 
 | 
  
 | 
      <if test="statusname != null and statusname!=''"> 
 | 
        AND   locate(a.status,#{statusname}) 
 | 
      </if> 
 | 
      <if test="smodelLabel != null and smodelLabel!=''"> 
 | 
        AND   locate(smodel.label,#{smodelLabel}) 
 | 
      </if> 
 | 
      <if test="wmodelCode != null and wmodelCode!=''"> 
 | 
        AND `wmodel`.code = #{wmodelCode} 
 | 
      </if> 
 | 
  
 | 
    </where> 
 | 
    order by `a`.`ID` desc 
 | 
  </select> 
 | 
  
 | 
  
 | 
  <select id="scanDetailForOut" resultType="doumeemes.dao.ext.bean.OutScanBean"> 
 | 
    select  a.id,a.num ,a.CODE as scanCode, d.id as materialId,d1.code as materialCode ,d1.name as materialName , b.id as warehouseId , 
 | 
            b.name as warehouseName , c.id as locationId , c.UNION_NAME as locationName , a.batch , f.id as unitId, 
 | 
            f.name as unitName , a.type , 
 | 
            p.name as procedureName, 
 | 
            a.procedure_id as procedureId, 
 | 
            a.quality_type as qualityType 
 | 
        FROM     appliances a 
 | 
      LEFT JOIN warehouse b ON a.WAREHOUSE_ID = b.id 
 | 
      LEFT JOIN warehouse_location c ON a.LOCATION_ID = c.id 
 | 
      LEFT JOIN material_distribute d ON a.MATERIAL_ID = d.id 
 | 
      LEFT JOIN material d1 ON d.MATERIAL_ID = d1.id 
 | 
      LEFT JOIN workorder w on a.WORKORDER_ID = w.id 
 | 
      LEFT JOIN w_stock e ON e.LOCATION_ID = a.LOCATION_ID 
 | 
      AND e.DELETED = 0 
 | 
      AND e.MATERIAL_ID = a.MATERIAL_ID and e.BATCH = a.BATCH 
 | 
        and e.QUALITY_TYPE =a.QUALITY_TYPE 
 | 
        and e.PROCEDURE_ID =a.PROCEDURE_ID 
 | 
      LEFT JOIN unit f ON d.UNIT_ID = f.id 
 | 
      LEFT JOIN procedures p ON a.PROCEDURE_ID=p.ID 
 | 
    where a.code = #{code} 
 | 
      and a.brCode = #{brCode} 
 | 
      and a.DEPART_ID = #{rootDepartId} 
 | 
      and a.num > 0 
 | 
        limit 1 
 | 
  </select> 
 | 
  
 | 
  
 | 
  <select id="getMaterialByLocationId" resultType="doumeemes.dao.ext.bean.AppliancesMaterialBean"> 
 | 
    select m.code as materialCode ,m.name as materialName , md.id as materialId 
 | 
        from appliances a 
 | 
        inner join material_distribute md on a.MATERIAL_ID = md.id 
 | 
        inner join material m on m.id = md.MATERIAL_ID   where 1 = 1 and a.material_id is not null 
 | 
    <if test="locationIds != null and locationIds != ''"> 
 | 
        and find_in_set( a.LOCATION_ID , #{locationIds} ) 
 | 
    </if> 
 | 
    group by m.code , m.name, m.id 
 | 
  </select> 
 | 
  
 | 
  
 | 
  <select id="getTypeNumByLocationId" resultType="doumeemes.dao.ext.bean.AppliancesBoxNumBean"> 
 | 
    select count(1) as boxNum , ifnull(sum(a.NUM),0) as num ,s.Code as typeDetail from appliances a 
 | 
      inner join system_dict_data s on a.TYPE = s.id 
 | 
    where 1 = 1 
 | 
    <if test="label != null and label != ''"> 
 | 
      and s.LABEL = #{label} 
 | 
    </if> 
 | 
    <if test="locationIds != null and locationIds != ''"> 
 | 
      and find_in_set( a.LOCATION_ID , #{locationIds} ) 
 | 
    </if> 
 | 
    <if test="materialId != null and materialId != ''"> 
 | 
      and  md.id = #{materialId} 
 | 
    </if> 
 | 
    <if test="inIds != null and inIds != ''"> 
 | 
      and  not exists ( select 1  from w_outbound_record r inner join appliances ap 
 | 
      on r.APPLIANCES_ID = ap.ID 
 | 
      where 1 = 1 and  FIND_IN_SET(r.OUTBOUND_ID,#{inIds}) 
 | 
      and ap.id  = a.id  ) 
 | 
    </if> 
 | 
      limit 1 
 | 
  </select> 
 | 
  
 | 
  
 | 
  <select id="getTypeNumByInIds" resultType="doumeemes.dao.ext.bean.AppliancesBoxNumBean"> 
 | 
    select count(1) as boxNum , ifnull(sum(a.NUM),0) as num ,s.Code as typeDetail from appliances a 
 | 
    inner join system_dict_data s on a.TYPE = s.id 
 | 
    where 1 = 1 
 | 
    <if test="label != null and label != ''"> 
 | 
      and s.LABEL = #{label} 
 | 
    </if> 
 | 
    <if test="locationIds != null and locationIds != ''"> 
 | 
      and find_in_set( a.LOCATION_ID , #{locationIds} ) 
 | 
    </if> 
 | 
    <if test="materialId != null and materialId != ''"> 
 | 
      and  md.id = #{materialId} 
 | 
    </if> 
 | 
    <if test="inIds != null and inIds != ''"> 
 | 
      and   exists ( select 1  from w_outbound_record r inner join appliances ap 
 | 
      on r.APPLIANCES_ID = ap.ID 
 | 
      where 1 = 1 and  FIND_IN_SET(r.OUTBOUND_ID,#{inIds}) 
 | 
      and ap.id  = a.id  ) 
 | 
    </if> 
 | 
    limit 1 
 | 
  </select> 
 | 
  
 | 
  
 | 
  
 | 
  <select id="getTypeNumUnitByLocationId" resultType="doumeemes.dao.ext.bean.AppliancesBoxNumBean"> 
 | 
    select count(1) as boxNum , ifnull(sum(a.NUM),0) as num ,s.Code as typeDetail , u.name as unitName 
 | 
    from appliances a 
 | 
    inner join system_dict_data s on a.TYPE = s.id 
 | 
    left join material_distribute md on a.MATERIAL_ID = md.ID 
 | 
    left join unit u on md.UNIT_ID = u.id 
 | 
    where 1 = 1 
 | 
    <if test="label != null and label != ''"> 
 | 
      and s.LABEL = #{label} 
 | 
    </if> 
 | 
    <if test="locationIds != null and locationIds != ''"> 
 | 
      and find_in_set( a.LOCATION_ID , #{locationIds} ) 
 | 
    </if> 
 | 
    <if test="materialId != null and materialId != ''"> 
 | 
      and  md.id = #{materialId} 
 | 
    </if> 
 | 
    <if test="inIds != null and inIds != ''"> 
 | 
      and  not exists ( select 1  from w_outbound_record r inner join appliances ap 
 | 
      on r.APPLIANCES_ID = ap.ID 
 | 
      where 1 = 1 and  FIND_IN_SET(r.OUTBOUND_ID,#{inIds}) 
 | 
      and ap.id  = a.id  ) 
 | 
    </if> 
 | 
    limit 1 
 | 
  </select> 
 | 
  
 | 
  
 | 
  <select id="getNumByInIds" resultType="doumeemes.dao.ext.bean.AppliancesBoxNumBean"> 
 | 
    select count(1) as boxNum,ifnull(sum(ap.NUM),0) as num 
 | 
    from w_outbound_record r inner join appliances ap on r.APPLIANCES_ID = ap.ID 
 | 
    where 1 = 1 
 | 
    <if test="inIds != null and inIds != ''"> 
 | 
      and  FIND_IN_SET(r.OUTBOUND_ID,#{inIds}) 
 | 
    </if> 
 | 
    <if test="inIds == null or inIds == ''"> 
 | 
      and  1 = 2 
 | 
    </if> 
 | 
    limit 1 
 | 
  </select> 
 | 
  
 | 
  
 | 
  <select id="getMaterialByInIdLocationIds" resultType="doumeemes.dao.ext.bean.AppliancesMaterialBean"> 
 | 
    SELECT 
 | 
      m.code as materialCode , m.name  as materialName , md.id as materialId 
 | 
    FROM 
 | 
      w_outbound_record w 
 | 
        INNER JOIN appliances a ON w.APPLIANCES_ID = a.id 
 | 
        INNER JOIN material_distribute md ON a.MATERIAL_ID = md.id 
 | 
        INNER JOIN material m ON md.MATERIAL_ID = m.id 
 | 
    where  1 = 1 
 | 
      <if test="id != null "> 
 | 
        and   w.OUTBOUND_ID = #{id} 
 | 
      </if> 
 | 
      <if test="locationIds != null and locationIds != '' "> 
 | 
        and  find_in_set( a.LOCATION_ID , #{locationIds}) 
 | 
      </if> 
 | 
      GROUP BY m.code , m.name , md.id 
 | 
  </select> 
 | 
  
 | 
  <select id="getMaterialByInIdLocationIdsNew" resultType="doumeemes.dao.ext.bean.AppliancesMaterialBean"> 
 | 
    SELECT 
 | 
    m.code as materialCode , m.name  as materialName , md.id as materialId 
 | 
    FROM 
 | 
    w_outbound_record w 
 | 
    INNER JOIN appliances a ON w.APPLIANCES_ID = a.id 
 | 
    INNER JOIN material_distribute md ON a.MATERIAL_ID = md.id 
 | 
    INNER JOIN material m ON md.MATERIAL_ID = m.id 
 | 
    where  1 = 1 
 | 
    <if test="id != null "> 
 | 
      and   w.OUTBOUND_ID = #{id} 
 | 
    </if> 
 | 
  
 | 
    <if test="locationIds != null"> 
 | 
      AND a.LOCATION_ID in 
 | 
      <foreach collection="locationIds" item="id" separator="," open="(" close=")"> 
 | 
        #{id} 
 | 
      </foreach> 
 | 
    </if> 
 | 
  
 | 
    GROUP BY m.code , m.name , md.id 
 | 
  </select> 
 | 
  
 | 
  
 | 
  
 | 
  <select id="getMaterialNumTypeByInIdLocationIds" resultType="doumeemes.dao.ext.bean.AppliancesBoxNumBean"> 
 | 
    SELECT 
 | 
     count(1) as boxNum , ifnull(sum(a.NUM),0) as num ,s.Code as typeDetail, u.name as unitName 
 | 
    FROM 
 | 
    w_outbound_record w 
 | 
    INNER JOIN appliances a ON w.APPLIANCES_ID = a.id 
 | 
    INNER JOIN material_distribute md ON a.MATERIAL_ID = md.id 
 | 
    INNER JOIN material m ON md.MATERIAL_ID = m.id 
 | 
    INNER JOIN unit u ON m.UNIT_ID = u.ID 
 | 
    inner join system_dict_data s on a.TYPE = s.id 
 | 
    where  1 = 1 
 | 
    <if test="id != null "> 
 | 
      and   w.OUTBOUND_ID = #{id} 
 | 
    </if> 
 | 
    <if test="locationIds != null and locationIds != '' "> 
 | 
      and  find_in_set( a.LOCATION_ID , #{locationIds}) 
 | 
    </if> 
 | 
    <if test="label != null and label != ''"> 
 | 
      and s.LABEL = #{label} 
 | 
    </if> 
 | 
    <if test="materialId != null and materialId != ''"> 
 | 
      and  md.id = #{materialId} 
 | 
    </if> 
 | 
  </select> 
 | 
  
 | 
  
 | 
  <select id="getMaterialNumTypeByInIdLocationIdsNew" resultType="doumeemes.dao.ext.bean.AppliancesBoxNumBean"> 
 | 
    SELECT 
 | 
    count(1) as boxNum , 
 | 
           ifnull(sum(a.NUM),0) as num ,p.name as procedureName , 
 | 
           w.QUALITY_TYPE as qualityType, 
 | 
           u.name as unitName , w.batch 
 | 
    FROM 
 | 
    w_outbound_record w 
 | 
    INNER JOIN appliances a ON w.APPLIANCES_ID = a.id 
 | 
    INNER JOIN material_distribute md ON a.MATERIAL_ID = md.id 
 | 
    INNER JOIN material m ON md.MATERIAL_ID = m.id 
 | 
    INNER JOIN unit u ON m.UNIT_ID = u.ID 
 | 
    LEFT JOIN procedures p on w.PROCEDURE_ID = p.id 
 | 
    where  1 = 1 
 | 
    <if test="id != null "> 
 | 
      and   w.OUTBOUND_ID = #{id} 
 | 
    </if> 
 | 
    <if test="locationIds != null"> 
 | 
      AND a.LOCATION_ID in 
 | 
      <foreach collection="locationIds" item="id" separator="," open="(" close=")"> 
 | 
        #{id} 
 | 
      </foreach> 
 | 
    </if> 
 | 
    <if test="type != null "> 
 | 
      and w.QUALITY_TYPE = #{type } 
 | 
    </if> 
 | 
    <if test="materialId != null and materialId != ''"> 
 | 
      and  md.id = #{materialId} 
 | 
    </if> 
 | 
  </select> 
 | 
  
 | 
  <select id="getDataToWTransfer" resultType="doumeemes.dao.ext.bean.AppliancesFroWTransferBean"> 
 | 
    select  a.LOCATION_ID outLocationId, a.WAREHOUSE_ID as outWarehouseId , 
 | 
            a.MATERIAL_ID as materialId  , m.UNIT_ID as unitId   , 
 | 
            ( select p.PICKING_WAREHOUSE_ID  from procedures p where p.id = #{proceduresId} ) as inWarehouseId , 
 | 
            1 as optType , ifnull(sum(a.num),0) as outNum , a.PROCEDURE_ID as procedureId , a.QUALITY_TYPE as qualityType , a.batch 
 | 
    from appliances a inner join system_dict_data s on a.TYPE = s.id 
 | 
                      inner join material_distribute md on a.MATERIAL_ID = md.id 
 | 
                      inner join material m on md.MATERIAL_ID = m.id 
 | 
    where 1 = 1 
 | 
      and FIND_IN_SET(a.LOCATION_ID,#{produceLocationIds}) 
 | 
      and not exists( 
 | 
            select 1  from w_outbound_record r inner join appliances ap 
 | 
                                                          on r.APPLIANCES_ID = ap.ID 
 | 
            where 1 = 1 and  FIND_IN_SET(r.OUTBOUND_ID,#{inIds}) 
 | 
              and ap.id  = a.id 
 | 
      ) 
 | 
    group by a.LOCATION_ID, a.WAREHOUSE_ID , a.MATERIAL_ID, m.UNIT_ID , a.PROCEDURE_ID , a.QUALITY_TYPE , a.batch 
 | 
    UNION ALL 
 | 
    select  a.LOCATION_ID outLocationId, a.WAREHOUSE_ID as outWarehouseId , 
 | 
            a.MATERIAL_ID as materialId  , m.UNIT_ID as unitId  , 
 | 
            ( select  p.PRODUCE_WAREHOUSE_ID   from procedures p where p.id = #{proceduresId} ) as inWarehouseId, 
 | 
            2 as optType  , ifnull(sum(a.num),0) as outNum , a.PROCEDURE_ID as procedureId , a.QUALITY_TYPE as qualityType , a.batch 
 | 
    from appliances a inner join system_dict_data s on a.TYPE = s.id 
 | 
                      inner join material_distribute md on a.MATERIAL_ID = md.id 
 | 
                      inner join material m on md.MATERIAL_ID = m.id 
 | 
    where 1 = 1 
 | 
      and s.LABEL = #{qualified} 
 | 
      and FIND_IN_SET(a.LOCATION_ID,#{finishLocationIds}) 
 | 
    group by a.LOCATION_ID, a.WAREHOUSE_ID , a.MATERIAL_ID, m.UNIT_ID , a.PROCEDURE_ID , a.QUALITY_TYPE , a.batch 
 | 
    UNION ALL 
 | 
    select  a.LOCATION_ID outLocationId, a.WAREHOUSE_ID as outWarehouseId , 
 | 
            a.MATERIAL_ID as materialId  , m.UNIT_ID as unitId  , 
 | 
            ( select  p.BAD_WAREHOUSE_ID    from procedures p where p.id = #{proceduresId} ) as inWarehouseId , 
 | 
            3 as optType  , ifnull(sum(a.num),0) as outNum , a.PROCEDURE_ID as procedureId , a.QUALITY_TYPE as qualityType , a.batch 
 | 
    from appliances a inner join system_dict_data s on a.TYPE = s.id 
 | 
                      inner join material_distribute md on a.MATERIAL_ID = md.id 
 | 
                      inner join material m on md.MATERIAL_ID = m.id 
 | 
    where 1 = 1 
 | 
      and s.LABEL = #{rejects} 
 | 
      and FIND_IN_SET(a.LOCATION_ID,#{finishLocationIds}) 
 | 
    group by a.LOCATION_ID, a.WAREHOUSE_ID , a.MATERIAL_ID, m.UNIT_ID , a.PROCEDURE_ID , a.QUALITY_TYPE , a.batch 
 | 
    UNION ALL 
 | 
    select  a.LOCATION_ID outLocationId, a.WAREHOUSE_ID as outWarehouseId , 
 | 
            a.MATERIAL_ID as materialId  , m.UNIT_ID as unitId  , 
 | 
            ( select  p.TOBESCRAPPED_WAREHOUSE_ID  from procedures p where p.id = #{proceduresId} ) as inWarehouseId , 
 | 
            4 as optType  , ifnull(sum(a.num),0) as outNum , a.PROCEDURE_ID as procedureId , a.QUALITY_TYPE as qualityType , a.batch 
 | 
    from appliances a inner join system_dict_data s on a.TYPE = s.id 
 | 
                      inner join material_distribute md on a.MATERIAL_ID = md.id 
 | 
                      inner join material m on md.MATERIAL_ID = m.id 
 | 
    where 1 = 1 
 | 
      and s.LABEL = #{scrap} 
 | 
      and FIND_IN_SET(a.LOCATION_ID,#{finishLocationIds}) 
 | 
    group by a.LOCATION_ID, a.WAREHOUSE_ID , a.MATERIAL_ID, m.UNIT_ID , a.PROCEDURE_ID , a.QUALITY_TYPE , a.batch 
 | 
  </select> 
 | 
  
 | 
  
 | 
  <select id="getDataToWTransferNew" resultType="doumeemes.dao.ext.bean.AppliancesFroWTransferBean"> 
 | 
    select  a.LOCATION_ID outLocationId, a.WAREHOUSE_ID as outWarehouseId , 
 | 
            a.MATERIAL_ID as materialId  , m.UNIT_ID as unitId   , 
 | 
            ( select p.PRODUCE_WAREHOUSE_ID  from procedures p where p.id = #{proceduresId} ) as inWarehouseId , 
 | 
            ( select p.BAD_WAREHOUSE_ID  from procedures p where p.id = #{proceduresId} ) as inBadWarehouseId , 
 | 
            ( select p.TOBESCRAPPED_WAREHOUSE_ID  from procedures p where p.id = #{proceduresId} ) as inScrapWarehouseId , 
 | 
            1 as optType , ifnull(sum(a.num),0) as outNum , a.PROCEDURE_ID as procedureId , a.QUALITY_TYPE as qualityType , a.batch 
 | 
    from appliances a inner join system_dict_data s on a.TYPE = s.id 
 | 
                      inner join material_distribute md on a.MATERIAL_ID = md.id 
 | 
                      inner join material m on md.MATERIAL_ID = m.id 
 | 
    where 1 = 1 
 | 
      and FIND_IN_SET(a.LOCATION_ID,#{allLocationIds}) 
 | 
      and not exists( 
 | 
            select 1  from w_outbound_record r inner join appliances ap 
 | 
                                                          on r.APPLIANCES_ID = ap.ID 
 | 
            where 1 = 1 and  FIND_IN_SET(r.OUTBOUND_ID,#{inIds}) 
 | 
              and ap.id  = a.id 
 | 
      ) 
 | 
  
 | 
      and not exists ( 
 | 
  
 | 
        select 1 from workorder wo inner join workorder_record wr on wo.id = wr.WORKORDER_ID where wo.status in ( 0 , 1 , 2 , 3 ) 
 | 
  
 | 
        and wr.TYPE = 0 and wr.APPLIANCES_ID = a.id 
 | 
  
 | 
      ) 
 | 
  
 | 
    group by a.LOCATION_ID, a.WAREHOUSE_ID , a.MATERIAL_ID, m.UNIT_ID ,  a.PROCEDURE_ID , a.QUALITY_TYPE , a.batch 
 | 
  </select> 
 | 
  
 | 
  
 | 
  <select id="getWarehouseIdByLocationId" resultType="doumeemes.dao.ext.bean.AppliancesBoxNumBean"> 
 | 
    select 
 | 
    from appliances a 
 | 
    where 1 = 1 
 | 
    <if test="locationIds != null and locationIds != ''"> 
 | 
      and find_in_set( a.LOCATION_ID , #{locationIds} ) 
 | 
    </if> 
 | 
    <if test="inIds != null and inIds != ''"> 
 | 
      and  not exists ( select 1  from w_outbound_record r inner join appliances ap 
 | 
      on r.APPLIANCES_ID = ap.ID 
 | 
      where 1 = 1 and  FIND_IN_SET(r.OUTBOUND_ID,#{inIds}) 
 | 
      and ap.id  = a.id  ) 
 | 
    </if> 
 | 
  </select> 
 | 
  
 | 
  
 | 
  <update id="editById" parameterType="doumeemes.dao.business.model.Appliances"> 
 | 
    update appliances 
 | 
    <set> 
 | 
        `status` = #{status}, 
 | 
      WORKORDER_ID =#{workorderId}, 
 | 
      MATERIAL_ID=#{materialId}, 
 | 
      num=#{num}, 
 | 
      POSITION_TYPE =#{positionType}, 
 | 
      WAREHOUSE_ID=#{warehouseId}, 
 | 
      LOCATION_ID =#{locationId}, 
 | 
      PROCEDURE_ID =#{procedureId}, 
 | 
      NEXT_PROCEDURE_ID =#{nextProcedureId}, 
 | 
      CUR_OBJ_ID=#{curObjId}, 
 | 
      CUR_OBJ_TYPE   =#{curObjType}, 
 | 
      batch   =#{batch}, 
 | 
      QUALITY_TYPE  =#{qualityType}, 
 | 
      BACKORDER_ID  =#{backorderId}, 
 | 
      SALEORDER_ID =#{saleorderId}, 
 | 
      BACK_PROCEDURE_ID  =#{backProcedureId}, 
 | 
      RELOBJ_TYPE  =#{relobjType} 
 | 
    </set> 
 | 
    where   `id` = #{id} 
 | 
  </update> 
 | 
  
 | 
  <select id="reserveMaterialBeanList" resultType="doumeemes.dao.ext.bean.ReserveMaterialBean"> 
 | 
    SELECT 
 | 
    count(1) as boxNum , 
 | 
    ifnull(sum(a.NUM),0) as num ,p.name as procedureName , 
 | 
    w.QUALITY_TYPE as qualityType, 
 | 
    u.name as unitName , w.batch , 
 | 
    m.code materialCode, m.name as materialName 
 | 
    FROM 
 | 
    w_outbound_record w 
 | 
    INNER JOIN appliances a ON w.APPLIANCES_ID = a.id 
 | 
    INNER JOIN material_distribute md ON a.MATERIAL_ID = md.id 
 | 
    INNER JOIN material m ON md.MATERIAL_ID = m.id 
 | 
    INNER JOIN unit u ON m.UNIT_ID = u.ID 
 | 
    LEFT JOIN procedures p on w.PROCEDURE_ID = p.id 
 | 
    where  1 = 1 
 | 
    <if test="id != null "> 
 | 
      and   w.OUTBOUND_ID = #{id} 
 | 
    </if> 
 | 
    <if test="locationIds != null"> 
 | 
      AND a.LOCATION_ID in 
 | 
      <foreach collection="locationIds" item="id" separator="," open="(" close=")"> 
 | 
        #{id} 
 | 
      </foreach> 
 | 
    </if> 
 | 
    group by p.name , w.QUALITY_TYPE , u.name ,  w.batch ,m.code  ,m.name 
 | 
  </select> 
 | 
  
 | 
  
 | 
  <select id="findListPageForManual" parameterType="doumeemes.dao.ext.dto.QueryAppliancesByManualDTO" resultMap="AppliancesExtListVO"> 
 | 
    SELECT 
 | 
    `a`.*, 
 | 
    u.name as umodelName, 
 | 
    u.ATTRIBUTE_DATA as umodelData, 
 | 
    `mdmodel`.`UNIT_ID` AS MDMODEL_UNIT_ID, 
 | 
    `mdmodel`.`ID` AS MDMODEL_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, 
 | 
    `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`.`PLAN_ID` AS WMODEL_PLAN_ID, 
 | 
    `wmodel`.`FACTORY_ID` AS WMODEL_FACTORY_ID, 
 | 
    `wmodel`.`PROCEDURE_ID` AS WMODEL_PROCEDURE_ID, 
 | 
    `wmodel`.`CODE` AS WMODEL_CODE, 
 | 
    `wmodel`.`ORIGIN_WORKORDER_ID` AS WMODEL_ORIGIN_WORKORDER_ID, 
 | 
    `wmodel`.`TYPE_ID` AS WMODEL_TYPE_ID, 
 | 
    `wmodel`.`ORIGIN_ID` AS WMODEL_ORIGIN_ID, 
 | 
    `wmodel`.`PLAN_DATE` AS WMODEL_PLAN_DATE, 
 | 
    `wmodel`.`PLAN_NUM` AS WMODEL_PLAN_NUM, 
 | 
    `wmodel`.`MATERIAL_ID` AS WMODEL_MATERIAL_ID, 
 | 
    `wmodel`.`UNIT_ID` AS WMODEL_UNIT_ID, 
 | 
    `wmodel`.`BATCH` AS WMODEL_BATCH, 
 | 
    `wmodel`.`PRO_USER_ID` AS WMODEL_PRO_USER_ID, 
 | 
    `wmodel`.`PRO_GROUP_ID` AS WMODEL_PRO_GROUP_ID, 
 | 
    `wmodel`.`QUALIFIED_NUM` AS WMODEL_QUALIFIED_NUM, 
 | 
    `wmodel`.`UNQUALIFIED_NUM` AS WMODEL_UNQUALIFIED_NUM, 
 | 
    `wmodel`.`CHECK_USER_ID` AS WMODEL_CHECK_USER_ID, 
 | 
    `wmodel`.`STATUS` AS WMODEL_STATUS, 
 | 
    `wmodel`.`LAST_DEAL_DATE` AS WMODEL_LAST_DEAL_DATE, 
 | 
    `wmodel`.`LAST_DEAL_INFO` AS WMODEL_LAST_DEAL_INFO, 
 | 
    `wmodel`.`URGENT` AS WMODEL_URGENT, 
 | 
    `whmodel`.`ID` AS WHMODEL_ID, 
 | 
    `whmodel`.`DELETED` AS WHMODEL_DELETED, 
 | 
    `whmodel`.`CREATE_USER` AS WHMODEL_CREATE_USER, 
 | 
    `whmodel`.`CREATE_TIME` AS WHMODEL_CREATE_TIME, 
 | 
    `whmodel`.`UPDATE_USER` AS WHMODEL_UPDATE_USER, 
 | 
    `whmodel`.`UPDATE_TIME` AS WHMODEL_UPDATE_TIME, 
 | 
    `whmodel`.`REMARK` AS WHMODEL_REMARK, 
 | 
    `whmodel`.`ROOT_DEPART_ID` AS WHMODEL_ROOT_DEPART_ID, 
 | 
    `whmodel`.`DEPART_ID` AS WHMODEL_DEPART_ID, 
 | 
    `whmodel`.`PROCEDURE_ID` AS WHMODEL_PROCEDURE_ID, 
 | 
    `whmodel`.`QRCODE` AS WHMODEL_QRCODE, 
 | 
    `whmodel`.`NAME` AS WHMODEL_NAME, 
 | 
    `whmodel`.`USE_LOCATION` AS WHMODEL_USE_LOCATION, 
 | 
    `whmodel`.`STATUS` AS WHMODEL_STATUS, 
 | 
    `whmodel`.`ADDR` AS WHMODEL_ADDR, 
 | 
    `lmodel`.`ID` AS LMODEL_ID, 
 | 
    `lmodel`.`DELETED` AS LMODEL_DELETED, 
 | 
    `lmodel`.`CREATE_USER` AS LMODEL_CREATE_USER, 
 | 
    `lmodel`.`CREATE_TIME` AS LMODEL_CREATE_TIME, 
 | 
    `lmodel`.`UPDATE_USER` AS LMODEL_UPDATE_USER, 
 | 
    `lmodel`.`UPDATE_TIME` AS LMODEL_UPDATE_TIME, 
 | 
    `lmodel`.`REMARK` AS LMODEL_REMARK, 
 | 
    `lmodel`.`ROOT_DEPART_ID` AS LMODEL_ROOT_DEPART_ID, 
 | 
    `lmodel`.`WAREHOUSE_ID` AS LMODEL_WAREHOUSE_ID, 
 | 
    `lmodel`.`UNION_NAME` AS LMODEL_UNION_NAME, 
 | 
    `lmodel`.`AREA` AS LMODEL_AREA, 
 | 
    `lmodel`.`SHELF` AS LMODEL_SHELF, 
 | 
    `lmodel`.`CELL` AS LMODEL_CELL, 
 | 
    `lmodel`.`QRCODE` AS LMODEL_QRCODE, 
 | 
    `lmodel`.`STATUS` AS LMODEL_STATUS, 
 | 
    `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, 
 | 
    (select st.batch from w_stock st where st.`LOCATION_ID`=a.`LOCATION_ID` and st.deleted=0 and st. `MATERIAL_ID` =a. `MATERIAL_ID` limit 1) as proBatch, 
 | 
    `cumodel`.`ID` AS CUMODEL_ID, 
 | 
    `cumodel`.`DELETED` AS CUMODEL_DELETED, 
 | 
    `cumodel`.`CREATE_USER` AS CUMODEL_CREATE_USER, 
 | 
    `cumodel`.`CREATE_TIME` AS CUMODEL_CREATE_TIME, 
 | 
    `cumodel`.`UPDATE_USER` AS CUMODEL_UPDATE_USER, 
 | 
    `cumodel`.`UPDATE_TIME` AS CUMODEL_UPDATE_TIME, 
 | 
    `cumodel`.`REMARK` AS CUMODEL_REMARK, 
 | 
    `cumodel`.`ROOT_DEPART_ID` AS CUMODEL_ROOT_DEPART_ID, 
 | 
    `cumodel`.`CATE_BIG_ID` AS CUMODEL_CATE_BIG_ID, 
 | 
    `cumodel`.`CATE_MIDDLE_ID` AS CUMODEL_CATE_MIDDLE_ID, 
 | 
    `cumodel`.`CATE_SMALL_ID` AS CUMODEL_CATE_SMALL_ID, 
 | 
    mmodel.code as materialCode, 
 | 
    mmodel.name as materialName, 
 | 
    `smodel`.code as SMODEL_CODE, 
 | 
    `smodel`.LABEL as SMODEL_LABEL , 
 | 
    ( select ifnull(c1.`NAME`,'')  from category c1 where c1.id = `cumodel`.CATE_BIG_ID limit 1 ) as categoryBigName , 
 | 
    ( select ifnull(c1.`NAME`,'')  from category c1 where c1.id = `cumodel`.CATE_MIDDLE_ID limit 1 )  as categoryMiddleName, 
 | 
    ( select ifnull(c1.`NAME`,'')  from category c1 where c1.id = `cumodel`.CATE_SMALL_ID limit 1 )  as categorySmallName, 
 | 
    bp.PREFIX as prefix 
 | 
    FROM `appliances` `a` 
 | 
    LEFT JOIN `department` `dmodel` ON a.DEPART_ID=dmodel.ID 
 | 
    LEFT JOIN `workorder` `wmodel` ON a.WORKORDER_ID=wmodel.ID 
 | 
    LEFT JOIN `material_distribute` `mdmodel` ON a.MATERIAL_ID=mdmodel.ID 
 | 
    LEFT JOIN `unit` `u` ON mdmodel.UNIT_ID=u.ID 
 | 
    LEFT JOIN `material` `mmodel` ON mdmodel.MATERIAL_ID=mmodel.ID 
 | 
    LEFT JOIN `warehouse` `whmodel` ON a.WAREHOUSE_ID=whmodel.ID 
 | 
    LEFT JOIN `warehouse_location` `lmodel` ON a.LOCATION_ID=lmodel.ID 
 | 
    LEFT JOIN `procedures` `pmodel` ON a.PROCEDURE_ID=pmodel.ID 
 | 
    LEFT JOIN `system_dict_data` `smodel` ON a.TYPE=smodel.ID 
 | 
    LEFT JOIN `category_union` `cumodel` ON a.`CATEGORY_ID`=cumodel.ID 
 | 
    LEFT JOIN `barcode_param` bp ON a.BRCODE = bp.id 
 | 
  
 | 
    <where> 
 | 
      <if test="rootDepartId != null  " > 
 | 
        and a.ROOT_DEPART_ID = #{rootDepartId} 
 | 
      </if> 
 | 
      <if test="departId != null  " > 
 | 
        and a.DEPART_ID = #{departId} 
 | 
      </if> 
 | 
      <if test="code != null and code != ''"> 
 | 
        and a.CODE like  concat ('%',#{code},'%') 
 | 
      </if> 
 | 
      <if test="choseIds != null and choseIds != ''"> 
 | 
          AND NOT EXISTS  ( select 1 from appliances ap where a.id = ap.id  and  FIND_IN_SET(ap.id, #{choseIds} )  ) 
 | 
      </if> 
 | 
      <if test="objType == 1  " > 
 | 
          AND  EXISTS ( 
 | 
          SELECT  1 FROM w_transfer_detail t WHERE  a.MATERIAL_ID = t.MATERIAL_ID  AND a.QUALITY_TYPE = t.QUALITY_TYPE 
 | 
            AND a.PROCEDURE_ID = t.PROCEDURE_ID AND t.TRANSFER_ID = #{ id} 
 | 
            <if test="inOrOut == 0" > 
 | 
              AND t.OUT_WAREHOUSE_ID = a.WAREHOUSE_ID 
 | 
            </if> 
 | 
          ) 
 | 
          <if test="inOrOut == 1" > 
 | 
            AND   a.WAREHOUSE_ID is null and a.LOCATION_ID is null 
 | 
            and exists ( 
 | 
            select 1 from w_outbound_record wob where wob.OUTBOUND_ID in ( 
 | 
            select wo.id  from w_outbound wo where wo.type = 0  and wo.ORIGIN_id = #{id} and wo.ORIGIN_TYPE  = 3 
 | 
            ) and a.id = wob.appliances_id 
 | 
            ) 
 | 
  
 | 
  
 | 
          </if> 
 | 
  
 | 
      </if> 
 | 
      <if test="objType == 2" > 
 | 
          AND  EXISTS ( 
 | 
          SELECT  1 FROM w_outbound_detail t WHERE  a.MATERIAL_ID = t.MATERIAL_ID  AND a.QUALITY_TYPE = t.QUALITY_TYPE 
 | 
          AND a.PROCEDURE_ID = t.PROCEDURE_ID AND t.OUTBOUND_ID = #{ id} 
 | 
          <if test="inOrOut == 0" > 
 | 
            AND t.WAREHOUSE_ID = a.WAREHOUSE_ID 
 | 
          </if> 
 | 
          ) 
 | 
          <if test="inOrOut == 1" > 
 | 
            AND   a.WAREHOUSE_ID is null and a.LOCATION_ID is null 
 | 
            and exists ( 
 | 
  
 | 
                select 1 from w_outbound_record wob where wob.OUTBOUND_ID  = #{id} and a.id = wob.appliances_id 
 | 
  
 | 
            ) 
 | 
          </if> 
 | 
      </if> 
 | 
  
 | 
    </where> 
 | 
  </select> 
 | 
  
 | 
  
 | 
</mapper> 
 |