<?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.BomExtMapper"> 
 | 
  
 | 
  <!-- 管理页面查询 --> 
 | 
  <resultMap id="BomExtListVO" type="doumeemes.dao.ext.vo.BomExtListVO" 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="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="umodel" javaType="doumeemes.dao.business.model.Unit"> 
 | 
      <id column="UMODEL_ID" jdbcType="INTEGER" property="id"/> 
 | 
      <result column="UMODEL_DELETED" jdbcType="TINYINT" property="deleted"/> 
 | 
      <result column="UMODEL_CREATE_USER" jdbcType="INTEGER" property="createUser"/> 
 | 
      <result column="UMODEL_CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/> 
 | 
      <result column="UMODEL_UPDATE_USER" jdbcType="INTEGER" property="updateUser"/> 
 | 
      <result column="UMODEL_UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/> 
 | 
      <result column="UMODEL_REMARK" jdbcType="VARCHAR" property="remark"/> 
 | 
      <result column="UMODEL_ROOT_DEPART_ID" jdbcType="INTEGER" property="rootDepartId"/> 
 | 
      <result column="UMODEL_NAME" jdbcType="VARCHAR" property="name"/> 
 | 
      <result column="UMODEL_TYPE" jdbcType="TINYINT" property="type"/> 
 | 
      <result column="UMODEL_STATUS" jdbcType="TINYINT" property="status"/> 
 | 
    </association> 
 | 
    <association property="rmodel" javaType="doumeemes.dao.business.model.Route"> 
 | 
      <id column="RMODEL_ID" jdbcType="INTEGER" property="id"/> 
 | 
      <result column="RMODEL_DELETED" jdbcType="TINYINT" property="deleted"/> 
 | 
      <result column="RMODEL_CREATE_USER" jdbcType="INTEGER" property="createUser"/> 
 | 
      <result column="RMODEL_CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/> 
 | 
      <result column="RMODEL_UPDATE_USER" jdbcType="INTEGER" property="updateUser"/> 
 | 
      <result column="RMODEL_UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/> 
 | 
      <result column="RMODEL_REMARK" jdbcType="VARCHAR" property="remark"/> 
 | 
      <result column="RMODEL_DEPART_ID" jdbcType="INTEGER" property="departId"/> 
 | 
      <result column="RMODEL_ROOT_DEPART_ID" jdbcType="INTEGER" property="rootDepartId"/> 
 | 
      <result column="RMODEL_CODE" jdbcType="VARCHAR" property="code"/> 
 | 
      <result column="RMODEL_NAME" jdbcType="VARCHAR" property="name"/> 
 | 
      <result column="RMODEL_STATUS" jdbcType="INTEGER" property="status"/> 
 | 
    </association> 
 | 
  </resultMap> 
 | 
  <select id="selectList" parameterType="doumeemes.dao.ext.dto.QueryBomExtDTO" resultMap="BomExtListVO"> 
 | 
    SELECT 
 | 
      `a`.*, 
 | 
      `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, 
 | 
      `mmodel`.`ID` AS MMODEL_ID, 
 | 
      `mmodel`.`DELETED` AS MMODEL_DELETED, 
 | 
      `mmodel`.`CREATE_USER` AS MMODEL_CREATE_USER, 
 | 
      `mmodel`.`CREATE_TIME` AS MMODEL_CREATE_TIME, 
 | 
      `mmodel`.`UPDATE_USER` AS MMODEL_UPDATE_USER, 
 | 
      `mmodel`.`UPDATE_TIME` AS MMODEL_UPDATE_TIME, 
 | 
      `mmodel`.`REMARK` AS MMODEL_REMARK, 
 | 
      `mmodel`.`ROOT_DEPART_ID` AS MMODEL_ROOT_DEPART_ID, 
 | 
      `mmodel`.`NAME` AS MMODEL_NAME, 
 | 
      `mmodel`.`CODE` AS MMODEL_CODE, 
 | 
      `mmodel`.`ATTR` AS MMODEL_ATTR, 
 | 
      `mmodel`.`UNION_NAME` AS MMODEL_UNION_NAME, 
 | 
      `mmodel`.`UNIT_ID` AS MMODEL_UNIT_ID, 
 | 
      `mmodel`.`CATE_UNION_ID` AS MMODEL_CATE_UNION_ID, 
 | 
      `mmodel`.`FORMATION` AS MMODEL_FORMATION, 
 | 
      `mmodel`.`QRCODE_ID` AS MMODEL_QRCODE_ID, 
 | 
      `mmodel`.`STATUS` AS MMODEL_STATUS, 
 | 
      `mmodel`.`VALID_TIME` AS MMODEL_VALID_TIME, 
 | 
      `mmodel`.`INVALID_TIME` AS MMODEL_INVALID_TIME, 
 | 
      `mmodel`.`CHECK_WAY` AS MMODEL_CHECK_WAY, 
 | 
      `mmodel`.`QUALITY_REQUIRE` AS MMODEL_QUALITY_REQUIRE, 
 | 
      `mmodel`.`CHECK_NOTE` AS MMODEL_CHECK_NOTE, 
 | 
      `umodel`.`ID` AS UMODEL_ID, 
 | 
      `umodel`.`DELETED` AS UMODEL_DELETED, 
 | 
      `umodel`.`CREATE_USER` AS UMODEL_CREATE_USER, 
 | 
      `umodel`.`CREATE_TIME` AS UMODEL_CREATE_TIME, 
 | 
      `umodel`.`UPDATE_USER` AS UMODEL_UPDATE_USER, 
 | 
      `umodel`.`UPDATE_TIME` AS UMODEL_UPDATE_TIME, 
 | 
      `umodel`.`REMARK` AS UMODEL_REMARK, 
 | 
      `umodel`.`ROOT_DEPART_ID` AS UMODEL_ROOT_DEPART_ID, 
 | 
      `umodel`.`NAME` AS UMODEL_NAME, 
 | 
      `umodel`.`TYPE` AS UMODEL_TYPE, 
 | 
      `umodel`.`STATUS` AS UMODEL_STATUS, 
 | 
      `rmodel`.`ID` AS RMODEL_ID, 
 | 
      `rmodel`.`DELETED` AS RMODEL_DELETED, 
 | 
      `rmodel`.`CREATE_USER` AS RMODEL_CREATE_USER, 
 | 
      `rmodel`.`CREATE_TIME` AS RMODEL_CREATE_TIME, 
 | 
      `rmodel`.`UPDATE_USER` AS RMODEL_UPDATE_USER, 
 | 
      `rmodel`.`UPDATE_TIME` AS RMODEL_UPDATE_TIME, 
 | 
      `rmodel`.`REMARK` AS RMODEL_REMARK, 
 | 
      `rmodel`.`DEPART_ID` AS RMODEL_DEPART_ID, 
 | 
      `rmodel`.`ROOT_DEPART_ID` AS RMODEL_ROOT_DEPART_ID, 
 | 
      `rmodel`.`CODE` AS RMODEL_CODE, 
 | 
      `rmodel`.`NAME` AS RMODEL_NAME, 
 | 
      `rmodel`.`STATUS` AS RMODEL_STATUS, 
 | 
           p.NAME as procedureName 
 | 
    FROM `bom` `a` 
 | 
    LEFT JOIN `department` `dmodel` ON a.DEPART_ID=dmodel.ID 
 | 
    left join  material_distribute md on a.MATERIAL_ID = md.id 
 | 
    LEFT JOIN `material` `mmodel` ON md.MATERIAL_ID=mmodel.ID 
 | 
    LEFT JOIN `unit` `umodel` ON a.UNIT_ID=umodel.ID 
 | 
    LEFT JOIN `route` `rmodel` ON a.ROUTE_ID=rmodel.ID 
 | 
    LEFT JOIN `procedures` `p` ON a.PROCEDURE_ID=p.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="materialId != null"> 
 | 
        AND `a`.`MATERIAL_ID` = #{materialId} 
 | 
      </if> 
 | 
      <if test="version != null and version != ''"> 
 | 
        AND `a`.`VERSION` = #{version} 
 | 
      </if> 
 | 
      <if test="unitId != null"> 
 | 
        AND `a`.`UNIT_ID` = #{unitId} 
 | 
      </if> 
 | 
      <if test="routeId != null"> 
 | 
        AND `a`.`ROUTE_ID` = #{routeId} 
 | 
      </if> 
 | 
      <if test="status != null"> 
 | 
        AND `a`.`STATUS` = #{status} 
 | 
      </if> 
 | 
      <if test="validTime != null"> 
 | 
        AND `a`.`VALID_TIME` = #{validTime} 
 | 
      </if> 
 | 
      <if test="invalidTime != null"> 
 | 
        AND `a`.`INVALID_TIME` = #{invalidTime} 
 | 
      </if> 
 | 
      <if test="papercode != null and papercode != ''"> 
 | 
        AND `a`.`PAPERCODE` = #{papercode} 
 | 
      </if> 
 | 
      <if test="mjcode != null and mjcode != ''"> 
 | 
        AND `a`.`MJCODE` = #{mjcode} 
 | 
      </if> 
 | 
      <if test="wltx != null and wltx != ''"> 
 | 
        AND `a`.`WLTX` = #{wltx} 
 | 
      </if> 
 | 
      <if test="rate != null and rate != ''"> 
 | 
        AND `a`.`RATE` = #{rate} 
 | 
      </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="mmodelId != null"> 
 | 
        AND `mmodel`.`ID` = #{mmodelId} 
 | 
      </if> 
 | 
      <if test="mmodelDeleted != null"> 
 | 
        AND `mmodel`.`DELETED` = #{mmodelDeleted} 
 | 
      </if> 
 | 
      <if test="mmodelCreateUser != null"> 
 | 
        AND `mmodel`.`CREATE_USER` = #{mmodelCreateUser} 
 | 
      </if> 
 | 
      <if test="mmodelCreateTime != null"> 
 | 
        AND `mmodel`.`CREATE_TIME` = #{mmodelCreateTime} 
 | 
      </if> 
 | 
      <if test="mmodelUpdateUser != null"> 
 | 
        AND `mmodel`.`UPDATE_USER` = #{mmodelUpdateUser} 
 | 
      </if> 
 | 
      <if test="mmodelUpdateTime != null"> 
 | 
        AND `mmodel`.`UPDATE_TIME` = #{mmodelUpdateTime} 
 | 
      </if> 
 | 
      <if test="mmodelRemark != null and mmodelRemark != ''"> 
 | 
        AND `mmodel`.`REMARK` = #{mmodelRemark} 
 | 
      </if> 
 | 
      <if test="mmodelRootDepartId != null"> 
 | 
        AND `mmodel`.`ROOT_DEPART_ID` = #{mmodelRootDepartId} 
 | 
      </if> 
 | 
      <if test="mmodelName != null and mmodelName != ''"> 
 | 
        AND `mmodel`.`NAME` = #{mmodelName} 
 | 
      </if> 
 | 
      <if test="mmodelCode != null and mmodelCode != ''"> 
 | 
        AND `mmodel`.`CODE` = #{mmodelCode} 
 | 
      </if> 
 | 
      <if test="mmodelAttr != null and mmodelAttr != ''"> 
 | 
        AND `mmodel`.`ATTR` = #{mmodelAttr} 
 | 
      </if> 
 | 
      <if test="mmodelUnionName != null and mmodelUnionName != ''"> 
 | 
        AND `mmodel`.`UNION_NAME` = #{mmodelUnionName} 
 | 
      </if> 
 | 
      <if test="mmodelUnitId != null"> 
 | 
        AND `mmodel`.`UNIT_ID` = #{mmodelUnitId} 
 | 
      </if> 
 | 
      <if test="mmodelCateUnionId != null"> 
 | 
        AND `mmodel`.`CATE_UNION_ID` = #{mmodelCateUnionId} 
 | 
      </if> 
 | 
      <if test="mmodelFormation != null"> 
 | 
        AND `mmodel`.`FORMATION` = #{mmodelFormation} 
 | 
      </if> 
 | 
      <if test="mmodelQrcodeId != null and mmodelQrcodeId != ''"> 
 | 
        AND `mmodel`.`QRCODE_ID` = #{mmodelQrcodeId} 
 | 
      </if> 
 | 
      <if test="mmodelStatus != null"> 
 | 
        AND `mmodel`.`STATUS` = #{mmodelStatus} 
 | 
      </if> 
 | 
      <if test="mmodelValidTime != null"> 
 | 
        AND `mmodel`.`VALID_TIME` = #{mmodelValidTime} 
 | 
      </if> 
 | 
      <if test="mmodelInvalidTime != null"> 
 | 
        AND `mmodel`.`INVALID_TIME` = #{mmodelInvalidTime} 
 | 
      </if> 
 | 
      <if test="mmodelCheckWay != null"> 
 | 
        AND `mmodel`.`CHECK_WAY` = #{mmodelCheckWay} 
 | 
      </if> 
 | 
      <if test="mmodelQualityRequire != null and mmodelQualityRequire != ''"> 
 | 
        AND `mmodel`.`QUALITY_REQUIRE` = #{mmodelQualityRequire} 
 | 
      </if> 
 | 
      <if test="mmodelCheckNote != null and mmodelCheckNote != ''"> 
 | 
        AND `mmodel`.`CHECK_NOTE` = #{mmodelCheckNote} 
 | 
      </if> 
 | 
      <if test="umodelId != null"> 
 | 
        AND `umodel`.`ID` = #{umodelId} 
 | 
      </if> 
 | 
      <if test="umodelDeleted != null"> 
 | 
        AND `umodel`.`DELETED` = #{umodelDeleted} 
 | 
      </if> 
 | 
      <if test="umodelCreateUser != null"> 
 | 
        AND `umodel`.`CREATE_USER` = #{umodelCreateUser} 
 | 
      </if> 
 | 
      <if test="umodelCreateTime != null"> 
 | 
        AND `umodel`.`CREATE_TIME` = #{umodelCreateTime} 
 | 
      </if> 
 | 
      <if test="umodelUpdateUser != null"> 
 | 
        AND `umodel`.`UPDATE_USER` = #{umodelUpdateUser} 
 | 
      </if> 
 | 
      <if test="umodelUpdateTime != null"> 
 | 
        AND `umodel`.`UPDATE_TIME` = #{umodelUpdateTime} 
 | 
      </if> 
 | 
      <if test="umodelRemark != null and umodelRemark != ''"> 
 | 
        AND `umodel`.`REMARK` = #{umodelRemark} 
 | 
      </if> 
 | 
      <if test="umodelRootDepartId != null"> 
 | 
        AND `umodel`.`ROOT_DEPART_ID` = #{umodelRootDepartId} 
 | 
      </if> 
 | 
      <if test="umodelName != null and umodelName != ''"> 
 | 
        AND `umodel`.`NAME` = #{umodelName} 
 | 
      </if> 
 | 
      <if test="umodelType != null"> 
 | 
        AND `umodel`.`TYPE` = #{umodelType} 
 | 
      </if> 
 | 
      <if test="umodelStatus != null"> 
 | 
        AND `umodel`.`STATUS` = #{umodelStatus} 
 | 
      </if> 
 | 
      <if test="rmodelId != null"> 
 | 
        AND `rmodel`.`ID` = #{rmodelId} 
 | 
      </if> 
 | 
      <if test="rmodelDeleted != null"> 
 | 
        AND `rmodel`.`DELETED` = #{rmodelDeleted} 
 | 
      </if> 
 | 
      <if test="rmodelCreateUser != null"> 
 | 
        AND `rmodel`.`CREATE_USER` = #{rmodelCreateUser} 
 | 
      </if> 
 | 
      <if test="rmodelCreateTime != null"> 
 | 
        AND `rmodel`.`CREATE_TIME` = #{rmodelCreateTime} 
 | 
      </if> 
 | 
      <if test="rmodelUpdateUser != null"> 
 | 
        AND `rmodel`.`UPDATE_USER` = #{rmodelUpdateUser} 
 | 
      </if> 
 | 
      <if test="rmodelUpdateTime != null"> 
 | 
        AND `rmodel`.`UPDATE_TIME` = #{rmodelUpdateTime} 
 | 
      </if> 
 | 
      <if test="rmodelRemark != null and rmodelRemark != ''"> 
 | 
        AND `rmodel`.`REMARK` = #{rmodelRemark} 
 | 
      </if> 
 | 
      <if test="rmodelDepartId != null"> 
 | 
        AND `rmodel`.`DEPART_ID` = #{rmodelDepartId} 
 | 
      </if> 
 | 
      <if test="rmodelRootDepartId != null"> 
 | 
        AND `rmodel`.`ROOT_DEPART_ID` = #{rmodelRootDepartId} 
 | 
      </if> 
 | 
      <if test="rmodelCode != null and rmodelCode != ''"> 
 | 
        AND `rmodel`.`CODE` = #{rmodelCode} 
 | 
      </if> 
 | 
      <if test="rmodelName != null and rmodelName != ''"> 
 | 
        AND `rmodel`.`NAME` = #{rmodelName} 
 | 
      </if> 
 | 
      <if test="rmodelStatus != null"> 
 | 
        AND `rmodel`.`STATUS` = #{rmodelStatus} 
 | 
      </if> 
 | 
    </where> 
 | 
  </select> 
 | 
  <select id="selectByModel" parameterType="doumeemes.dao.ext.dto.QueryBomExtDTO" resultMap="BomExtListVO"> 
 | 
    SELECT 
 | 
      `a`.*, 
 | 
       (select b.id from bom_version b where b.bom_id=a.id and b.deleted=0  order by b.CREATE_TIME desc limit 1) as bomVersionId 
 | 
    FROM `bom` `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="materialId != null"> 
 | 
        AND `a`.`MATERIAL_ID` = #{materialId} 
 | 
      </if> 
 | 
      <if test="version != null and version != ''"> 
 | 
        AND `a`.`VERSION` = #{version} 
 | 
      </if> 
 | 
      <if test="unitId != null"> 
 | 
        AND `a`.`UNIT_ID` = #{unitId} 
 | 
      </if> 
 | 
      <if test="routeId != null"> 
 | 
        AND `a`.`ROUTE_ID` = #{routeId} 
 | 
      </if> 
 | 
      <if test="status != null"> 
 | 
        AND `a`.`STATUS` = #{status} 
 | 
      </if> 
 | 
      <if test="validTime != null"> 
 | 
        AND `a`.`VALID_TIME` = #{validTime} 
 | 
      </if> 
 | 
      <if test="invalidTime != null"> 
 | 
        AND `a`.`INVALID_TIME` = #{invalidTime} 
 | 
      </if> 
 | 
      <if test="papercode != null and papercode != ''"> 
 | 
        AND `a`.`PAPERCODE` = #{papercode} 
 | 
      </if> 
 | 
      <if test="mjcode != null and mjcode != ''"> 
 | 
        AND `a`.`MJCODE` = #{mjcode} 
 | 
      </if> 
 | 
      <if test="wltx != null and wltx != ''"> 
 | 
        AND `a`.`WLTX` = #{wltx} 
 | 
      </if> 
 | 
      <if test="rate != null and rate != ''"> 
 | 
        AND `a`.`RATE` = #{rate} 
 | 
      </if> 
 | 
      <if test="procedureId != null "> 
 | 
        AND `a`.`PROCEDURE_ID` = #{procedureId} 
 | 
      </if> 
 | 
    </where> 
 | 
    limit 1 
 | 
  </select> 
 | 
  
 | 
  <select id="selectAdminList" parameterType="doumeemes.dao.ext.beanDto.QueryBomDTO" resultMap="BomExtListVO"> 
 | 
    SELECT 
 | 
    `a`.*, 
 | 
    `dmodel`.`NAME` AS departName, 
 | 
    `mmodel`.`NAME` AS materialName, 
 | 
    `mmodel`.`CODE` AS materialCode, 
 | 
    `umodel`.`NAME` AS unitName, 
 | 
    `rmodel`.`NAME` AS routeName, 
 | 
    `rmodel`.`CODE` AS routeCode, 
 | 
    p.NAME as procedureName, 
 | 
    f.id as factoryId, 
 | 
    f.name as factoryName , 
 | 
    ( SELECT ifnull( count( 1 ), 0 ) FROM route_procedure rp WHERE rp.ROUTE_ID = a.ROUTE_ID ) AS routeNum 
 | 
    FROM `bom` `a` 
 | 
    LEFT JOIN `department` `dmodel` ON a.DEPART_ID=dmodel.ID 
 | 
    left join material_distribute md on a.MATERIAL_ID = md.id 
 | 
    LEFT JOIN `material` `mmodel` ON md.MATERIAL_ID=mmodel.ID 
 | 
    LEFT JOIN `unit` `umodel` ON a.UNIT_ID=umodel.ID 
 | 
    LEFT JOIN `route` `rmodel` ON a.ROUTE_ID=rmodel.ID 
 | 
    LEFT JOIN `procedures` `p` ON a.PROCEDURE_ID=p.id 
 | 
    LEFT JOIN `department` `f` ON p.ORG_ID = f.id 
 | 
    <where> 
 | 
      <if test="materialCode != null and materialCode != ''"> 
 | 
        AND mmodel.CODE like CONCAT( '%',#{materialCode},'%') 
 | 
      </if> 
 | 
      <if test="materialName != null and materialName != ''"> 
 | 
        AND mmodel.NAME like CONCAT( '%',#{materialName},'%') 
 | 
      </if> 
 | 
  
 | 
      <if test="absolutionMaterialName != null and absolutionMaterialName != ''"> 
 | 
        AND mmodel.NAME =#{absolutionMaterialName} 
 | 
      </if> 
 | 
      <if test="routeId != null"> 
 | 
        AND rmodel.id = #{routeId} 
 | 
      </if> 
 | 
      <if test="status != null"> 
 | 
        AND a.STATUS = #{status} 
 | 
      </if> 
 | 
  
 | 
      <if test="rootDepartId != null"> 
 | 
        AND `a`.`ROOT_DEPART_ID` = #{rootDepartId} 
 | 
      </if> 
 | 
  
 | 
      <if test="departId != null"> 
 | 
        AND `a`.`DEPART_ID` = #{departId} 
 | 
      </if> 
 | 
      <if test="deleted != null"> 
 | 
        AND `a`.`DELETED` = #{deleted} 
 | 
      </if> 
 | 
  
 | 
    </where> 
 | 
    order by a.CREATE_TIME desc 
 | 
  </select> 
 | 
  
 | 
  <select id="selectBeanById"  resultMap="BomExtListVO"> 
 | 
    SELECT 
 | 
    `a`.*, 
 | 
    `dmodel`.`NAME` AS departName, 
 | 
    `mmodel`.`NAME` AS materialName, 
 | 
    `mmodel`.`CODE` AS materialCode, 
 | 
    `umodel`.`NAME` AS unitName, 
 | 
    `rmodel`.`NAME` AS routeName, 
 | 
    p.NAME as procedureName, 
 | 
         f.id as factoryId, 
 | 
         f.name as factoryName , 
 | 
    ( SELECT ifnull( count( 1 ), 0 ) FROM route_procedure rp WHERE rp.ROUTE_ID = a.ROUTE_ID ) AS routeNum 
 | 
    FROM `bom` `a` 
 | 
    LEFT JOIN `department` `dmodel` ON a.DEPART_ID=dmodel.ID 
 | 
    left join material_distribute md on a.MATERIAL_ID = md.id 
 | 
    LEFT JOIN `material` `mmodel` ON md.MATERIAL_ID=mmodel.ID 
 | 
    LEFT JOIN `unit` `umodel` ON a.UNIT_ID=umodel.ID 
 | 
    LEFT JOIN `route` `rmodel` ON a.ROUTE_ID=rmodel.ID 
 | 
    LEFT JOIN `procedures` `p` ON a.PROCEDURE_ID=p.id 
 | 
    LEFT JOIN `department` `f` ON p.ORG_ID = f.id 
 | 
    where  1 = 1 and a.id = #{id} 
 | 
  </select> 
 | 
  
 | 
  
 | 
  
 | 
  <select id="getBomMaterial" parameterType="doumeemes.dao.ext.dto.QueryBomExtDTO" resultMap="BomExtListVO"> 
 | 
    SELECT 
 | 
    `a`.*, 
 | 
    `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, 
 | 
    `mmodel`.`ID` AS MMODEL_ID, 
 | 
    `mmodel`.`DELETED` AS MMODEL_DELETED, 
 | 
    `mmodel`.`CREATE_USER` AS MMODEL_CREATE_USER, 
 | 
    `mmodel`.`CREATE_TIME` AS MMODEL_CREATE_TIME, 
 | 
    `mmodel`.`UPDATE_USER` AS MMODEL_UPDATE_USER, 
 | 
    `mmodel`.`UPDATE_TIME` AS MMODEL_UPDATE_TIME, 
 | 
    `mmodel`.`REMARK` AS MMODEL_REMARK, 
 | 
    `mmodel`.`ROOT_DEPART_ID` AS MMODEL_ROOT_DEPART_ID, 
 | 
    `mmodel`.`NAME` AS MMODEL_NAME, 
 | 
    `mmodel`.`CODE` AS MMODEL_CODE, 
 | 
    `mmodel`.`ATTR` AS MMODEL_ATTR, 
 | 
    `mmodel`.`UNION_NAME` AS MMODEL_UNION_NAME, 
 | 
    `mmodel`.`UNIT_ID` AS MMODEL_UNIT_ID, 
 | 
    `mmodel`.`CATE_UNION_ID` AS MMODEL_CATE_UNION_ID, 
 | 
    `mmodel`.`FORMATION` AS MMODEL_FORMATION, 
 | 
    `mmodel`.`QRCODE_ID` AS MMODEL_QRCODE_ID, 
 | 
    `mmodel`.`STATUS` AS MMODEL_STATUS, 
 | 
    `mmodel`.`VALID_TIME` AS MMODEL_VALID_TIME, 
 | 
    `mmodel`.`INVALID_TIME` AS MMODEL_INVALID_TIME, 
 | 
    `mmodel`.`CHECK_WAY` AS MMODEL_CHECK_WAY, 
 | 
    `mmodel`.`QUALITY_REQUIRE` AS MMODEL_QUALITY_REQUIRE, 
 | 
    `mmodel`.`CHECK_NOTE` AS MMODEL_CHECK_NOTE, 
 | 
    `umodel`.`ID` AS UMODEL_ID, 
 | 
    `umodel`.`DELETED` AS UMODEL_DELETED, 
 | 
    `umodel`.`CREATE_USER` AS UMODEL_CREATE_USER, 
 | 
    `umodel`.`CREATE_TIME` AS UMODEL_CREATE_TIME, 
 | 
    `umodel`.`UPDATE_USER` AS UMODEL_UPDATE_USER, 
 | 
    `umodel`.`UPDATE_TIME` AS UMODEL_UPDATE_TIME, 
 | 
    `umodel`.`REMARK` AS UMODEL_REMARK, 
 | 
    `umodel`.`ROOT_DEPART_ID` AS UMODEL_ROOT_DEPART_ID, 
 | 
    `umodel`.`NAME` AS UMODEL_NAME, 
 | 
    `umodel`.`TYPE` AS UMODEL_TYPE, 
 | 
    `umodel`.`STATUS` AS UMODEL_STATUS, 
 | 
    `rmodel`.`ID` AS RMODEL_ID, 
 | 
    `rmodel`.`DELETED` AS RMODEL_DELETED, 
 | 
    `rmodel`.`CREATE_USER` AS RMODEL_CREATE_USER, 
 | 
    `rmodel`.`CREATE_TIME` AS RMODEL_CREATE_TIME, 
 | 
    `rmodel`.`UPDATE_USER` AS RMODEL_UPDATE_USER, 
 | 
    `rmodel`.`UPDATE_TIME` AS RMODEL_UPDATE_TIME, 
 | 
    `rmodel`.`REMARK` AS RMODEL_REMARK, 
 | 
    `rmodel`.`DEPART_ID` AS RMODEL_DEPART_ID, 
 | 
    `rmodel`.`ROOT_DEPART_ID` AS RMODEL_ROOT_DEPART_ID, 
 | 
    `rmodel`.`CODE` AS RMODEL_CODE, 
 | 
    `rmodel`.`NAME` AS RMODEL_NAME, 
 | 
    `rmodel`.`STATUS` AS RMODEL_STATUS, 
 | 
    p.NAME as procedureName 
 | 
    FROM `bom` `a` 
 | 
    LEFT JOIN `department` `dmodel` ON a.DEPART_ID=dmodel.ID 
 | 
    left join  material_distribute md on a.MATERIAL_ID = md.id 
 | 
    LEFT JOIN `material` `mmodel` ON md.MATERIAL_ID=mmodel.ID 
 | 
    LEFT JOIN `unit` `umodel` ON a.UNIT_ID=umodel.ID 
 | 
    LEFT JOIN `route` `rmodel` ON a.ROUTE_ID=rmodel.ID 
 | 
    LEFT JOIN `procedures` `p` ON a.PROCEDURE_ID=p.id 
 | 
    <where> 
 | 
      AND `a`.`DELETED` = 0 
 | 
      AND a.STATUS = 1 
 | 
      <if test="rootDepartId != null"> 
 | 
        AND `a`.`ROOT_DEPART_ID` = #{rootDepartId} 
 | 
      </if> 
 | 
      <if test="departId != null"> 
 | 
        AND `rmodel`.`DEPART_ID` = #{departId} 
 | 
      </if> 
 | 
      <if test="materialCode != null and materialCode != '' "> 
 | 
        AND ( `mmodel`.`CODE` like CONCAT('%',#{materialCode},'%') or `mmodel`.`NAME` like CONCAT('%',#{materialCode},'%') ) 
 | 
      </if> 
 | 
    </where> 
 | 
  </select> 
 | 
  
 | 
  <select id="checkIsHave"  resultType="java.lang.Integer"> 
 | 
  
 | 
    select count(1) from bom b inner join route r on b.ROUTE_ID = r.ID 
 | 
  
 | 
    where 1  =  1  and b.DELETED = 0 
 | 
  
 | 
    and b.MATERIAL_ID = #{ materialId} 
 | 
  
 | 
    and r.DEPART_ID in ( select rc.depart_id from route rc where rc.id = #{ routeId} ) 
 | 
  
 | 
  </select> 
 | 
</mapper> 
 |