<?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.prolog.cs.biz.outbound.dao.WaveMapper">
    <resultMap id="WaveDO" type="com.prolog.cs.biz.outbound.model.entity.WaveDO">
        <result column="id" property="id"/>
        <result column="code" property="code"/>
        <result column="status" property="status"/>
        <result column="warehouse_id" property="warehouseId"/>
        <result column="error_msg" property="errorMsg"/>
        <result column="priority" property="priority"/>
        <result column="GMT_CREATE" property="gmtCreate"/>
        <result column="CREATOR" property="creator"/>


    </resultMap>

    <select id="getWaveDos" resultMap="WaveDO">
        SELECT  DISTINCT wave.*
        FROM WMS_WAVE wave
        LEFT JOIN WMS_WAVE_BILL bill ON bill.wave_id = wave.id
        WHERE  1=1
        <!--<choose>
            <when test="type != null and type != ''">
                and wave.type != '1'
            </when>
            <otherwise>
                and (wave.type is null or wave.type='1')
            </otherwise>
        </choose>-->
        <if test="waveId != null and waveId != ''">
            and wave.id = #{waveId}
        </if>
        <if test="warehouseId != null and warehouseId != ''">
            and wave.warehouse_id = #{warehouseId}
        </if>
        <if test="status != null and status != ''">
            and wave.status = #{status}
        </if>
        <if test="consignorId != null and consignorId != ''">
            and bill.CONSIGNOR_ID = #{consignorId}
        </if>
        <if test="billCode != null and billCode != ''">
            and bill.code like concat(concat('%',#{billCode}),'%')
        </if>
        ORDER BY wave.gmt_create  DESC
    </select>
</mapper>