| <?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="com.zy.asrs.common.wms.mapper.OrderDetlMapper"> | 
|   | 
|     <sql id="pakOutPageCondition"> | 
|         <if test="map.order_id!=null and map.order_id!='' "> | 
|             and mod.order_id = #{map.order_id} | 
|         </if> | 
|         <if test="map.matnr!=null and map.matnr!='' "> | 
|             and mod.matnr = #{map.matnr} | 
|         </if> | 
|         <if test="map.maktx!=null and map.maktx!='' "> | 
|             and mod.maktx = #{map.maktx} | 
|         </if> | 
|         <if test="map.batch!=null and map.batch!='' "> | 
|             and mod.batch = #{map.batch} | 
|         </if> | 
|     </sql> | 
|   | 
|     <select id="selectItem" resultType="com.zy.asrs.common.wms.entity.OrderDetl"> | 
|         select * from wms_order_detl | 
|         where 1=1 | 
|         and order_id = #{orderId} | 
|         and matnr = #{matnr} | 
|         <choose> | 
|             <when test="batch != null and batch != ''"> | 
|                 and batch = #{batch} | 
|             </when> | 
|             <otherwise> | 
|                 and (batch IS NULL OR batch = '') | 
|             </otherwise> | 
|         </choose> | 
|     </select> | 
|   | 
|     <select id="getPakoutPage" resultType="com.zy.asrs.common.wms.entity.OrderDetl"> | 
|         select | 
|         mod.* | 
|         from wms_order_detl mod | 
|         inner join wms_order mo on mod.order_id = mo.id | 
|         inner join wms_doc_type mdt on mo.doc_type = mdt.doc_id | 
|         where 1=1 | 
|         and mo.settle <= 2 | 
|         and mo.status = 1 | 
|         and mdt.pakout = 1 | 
|         <include refid="pakOutPageCondition"></include> | 
|     </select> | 
|   | 
|     <update id="increase"> | 
|         update wms_order_detl | 
|         set qty = qty + #{qty} | 
|         where 1=1 | 
|         and order_id = #{orderId} | 
|         and matnr = #{matnr} | 
|         and host_id = #{hostId} | 
|         <choose> | 
|             <when test="batch != null and batch != ''"> | 
|                 and batch = #{batch} | 
|             </when> | 
|             <otherwise> | 
|                 and (batch IS NULL OR batch = '') | 
|             </otherwise> | 
|         </choose> | 
|     </update> | 
|   | 
|     <update id="decrease"> | 
|         update wms_order_detl | 
|         set qty = qty - #{qty} | 
|         where 1=1 | 
|         and order_no = #{orderNo} | 
|         and matnr = #{matnr} | 
|         and host_id = #{hostId} | 
|         <choose> | 
|             <when test="batch != null and batch != ''"> | 
|                 and batch = #{batch} | 
|             </when> | 
|             <otherwise> | 
|                 and (batch IS NULL OR batch = '') | 
|             </otherwise> | 
|         </choose> | 
|     </update> | 
|   | 
| </mapper> |