<?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="net.lab1024.sa.admin.module.business.wms.receive.asnDetail.dao.AsnDetailDao">

    <!-- 查询结果列 -->
    <sql id="base_columns">
        t_asn_detail.asn_detail_id,
        t_asn_detail.asn_id,
        t_asn_detail.item_id,
        t_asn_detail.order_quantity,
        t_asn_detail.received_quantity,
        t_asn_detail.create_time
    </sql>

    <!-- 分页查询 -->
    <select id="queryPage"
            resultType="net.lab1024.sa.admin.module.business.wms.receive.asnDetail.domain.vo.AsnDetailVO">
        SELECT
        <include refid="base_columns"/>
        FROM t_asn_detail
        <if test="queryForm.keywords != null and queryForm.keywords != ''">
            LEFT JOIN t_item ON t_asn_detail.item_id = t_item.item_id
        </if>
        <where>
            <if test="queryForm.asnId != null">
                AND t_asn_detail.asn_id = #{queryForm.asnId}
            </if>
            <if test="queryForm.keywords != null and queryForm.keywords != ''">
                AND (
                t_item.item_code LIKE CONCAT(#{queryForm.keywords}, '%')
                OR t_item.item_name LIKE CONCAT(#{queryForm.keywords}, '%')
                )
            </if>
        </where>
    </select>


</mapper>
