| <?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.BomDetailExtMapper"> | 
|   | 
|   <!-- 管理页面查询 --> | 
|   <resultMap id="BomDetailExtListVO" type="doumeemes.dao.ext.vo.BomDetailExtListVO" autoMapping="true"> | 
|     <id column="ID" jdbcType="INTEGER" property="id"/> | 
|   </resultMap> | 
|   <select id="selectList" parameterType="doumeemes.dao.ext.dto.QueryBomDetailExtDTO" resultMap="BomDetailExtListVO"> | 
|     SELECT | 
|       `a`.`ID`, | 
|       `a`.`DELETED`, | 
|       `a`.`CREATE_USER`, | 
|       `a`.`CREATE_TIME`, | 
|       `a`.`UPDATE_USER`, | 
|       `a`.`UPDATE_TIME`, | 
|       `a`.`REMARK`, | 
|       `a`.`BOM_ID`, | 
|       `a`.`MATERIAL_ID`, | 
|       `a`.`UNIT_ID`, | 
|       `a`.`PROCEDURE_ID`, | 
|       `a`.`NUM` | 
|     <if test="workorderId !=null"> | 
|       ,(select sum(b.num) from workorder_record b where b.workorder_id=#{workorderId} and b.type=0 and b.deleted=0) as workorderNum | 
|     </if> | 
|     FROM `bom_detail` `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="bomId != null"> | 
|         AND `a`.`BOM_ID` = #{bomId} | 
|       </if> | 
|       <if test="materialId != null"> | 
|         AND `a`.`MATERIAL_ID` = #{materialId} | 
|       </if> | 
|       <if test="unitId != null"> | 
|         AND `a`.`UNIT_ID` = #{unitId} | 
|       </if> | 
|       <if test="procedureId != null"> | 
|         AND `a`.`PROCEDURE_ID` = #{procedureId} | 
|       </if> | 
|       <if test="num != null"> | 
|         AND `a`.`NUM` = #{num} | 
|       </if> | 
|     </where> | 
|   </select> | 
|   | 
|   | 
|   <select id="bomDetailListByBomVersionId"  resultType="doumeemes.dao.business.model.BomDetail"> | 
|   | 
|     select b.*  , m.code as materialCode , m.name as materialName , u.name as unitName  from bom_detail b | 
|   | 
|     left join material_distribute md on b.material_id = md.id | 
|   | 
|     left join material m on md.material_id = m.id | 
|   | 
|     left join unit u on m.unit_id = u.id | 
|   | 
|     where 1 = 1 | 
|   | 
|     and b.bom_id = #{bomVersionId} | 
|   | 
|   | 
|   </select> | 
|   | 
| </mapper> |