<?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.deer.wms.base.system.dao.CombineBoxRecordMapper">
  <resultMap id="BaseResultMap" type="com.deer.wms.base.system.model.CombineBoxRecord">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="combine_id" jdbcType="INTEGER" property="combineId" />
    <result column="from_box_code" jdbcType="VARCHAR" property="fromBoxCode" />
    <result column="from_quantity" jdbcType="INTEGER" property="fromQuantity" />
    <result column="to_box_code" jdbcType="VARCHAR" property="toBoxCode" />
    <result column="to_quantity" jdbcType="INTEGER" property="toQuantity" />
    <result column="create_time" jdbcType="VARCHAR" property="createTime" />
    <result column="card_no" jdbcType="VARCHAR" property="cardNo" />
    <result column="from_batch" jdbcType="VARCHAR" property="fromBatch" />
    <result column="to_batch" jdbcType="VARCHAR" property="toBatch" />
    <result column="item_code" jdbcType="VARCHAR" property="itemCode" />
    <result column="sub_inventory_id" jdbcType="INTEGER" property="subInventoryId" />
    <result column="from_exp" jdbcType="VARCHAR" property="fromExp" />
    <result column="to_exp" jdbcType="VARCHAR" property="toExp" />
  </resultMap>

  <resultMap id="Dto" type="com.deer.wms.base.system.model.CombineBoxRecordDto" extends="BaseResultMap">
    <result column="operator_name" jdbcType="VARCHAR" property="operatorName" />
    <result column="sub_inventory_name" jdbcType="VARCHAR" property="subInventoryName" />
  </resultMap>

  <select id="findList" parameterType="com.deer.wms.base.system.model.CombineBoxRecordCriteria" resultMap="Dto">
    select
    cbr.*,
    op.operator_name,
    si.sub_inventory_name
    from combine_box_record cbr
    left join sub_inventory si on si.sub_inventory_id = cbr.sub_inventory_id
    left join operator op on op.operator_card = cbr.card_no
    where 1=1
    <if test="subInventoryId != null and subInventoryId != -1">
      and cbr.sub_inventory_id = #{subInventoryId}
    </if>
    <if test="startTime != null and startTime != ''">
      and cbr.create_time &gt;= #{startTime}
    </if>
    <if test="endTime != null and endTime != ''">
      and cbr.create_time &lt;= #{endTime}
    </if>
    <if test="itemCode != null and itemCode != ''">
        and cbr.item_code = #{itemCode}
    </if>
  </select>
</mapper>