<?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.WorkStageRuntimeMapper">

    <resultMap id="waveStorageVO" type="com.prolog.cs.biz.outbound.model.vo.WorkStageVO">
        <result column="id" property="id"/>
        <result column="bill_group_id" property="billGroupId"/>
        <result column="consignor_id" property="consignorId"/>
        <result column="warehouse_id" property="warehouseId"/>
        <result column="building_code" property="buildingCode"/>
        <result column="case_qty" property="caseQty"/>
        <result column="stage_id" property="stageId"/>
        <result column="stage_code" property="stageCode"/>
        <result column="wave_id" property="waveId"/>
        <result column="gmt_create" property="gmtCreate"/>


    </resultMap>
    <update id="updateStatus">
        UPDATE WMS_WORK_STAGE_RUNTIME  SET status = 0
        WHERE BILL_GROUP_ID =  #{billGroupId}
    </update>

    <select id="findWorkStage" resultMap="waveStorageVO">
        select
        a.id,
        a.bill_group_id,
        a.consignor_id,
        a.building_code,
        a.case_qty,
        a.stage_id,
        a.stage_code,
        a.gmt_create,
        bill.warehouse_id
        from wms_work_stage_runtime a
        left join wms_wave_bill bill on bill.id = a.bill_group_id
        where 1=1
        <if test="waveId != null and waveId != ''">
            and bill.wave_id = #{waveId}
        </if>
        <if test="warehouseId != null and warehouseId != ''">
            and bill.warehouse_id = #{warehouseId}
        </if>
        <if test="billGroupId != null and billGroupId != ''">
            and bill.id = #{billGroupId}
        </if>

    </select>

</mapper>