<script>
SELECT
  stage.id,
  stage.building_code,
  stage.stage_code,
  stage.stage_type,
  stage.case_qty,
  bill.warehouse_id,
  bill.CONTACT_NAME,
  bill.CONTACT_TEL,
  bill.SRC_CODE,
  bill.RECEIVE_ADDRESS,
  bill.ship_line_id,
  stage.bill_group_id,
  omsBill.CONSIGNORNAME
FROM
  upcloud_base_wh_outbound.upcloud_biz_outbound.wms_work_stage_runtime  stage
  LEFT JOIN upcloud_base_wh_outbound.upcloud_biz_outbound.wms_wave_bill bill ON stage.bill_group_id = bill.BILL_GROUP_ID
  left join  upcloud_base_wh_outbound.upcloud_biz_outbound.OMS_DO_BILL_H omsBill on omsbill.billno=bill.src_code
where 1 = 1
<if test="params.waveId != null and params.waveId != ''">
  and bill.wave_id = #{waveId}
</if>
<if test="params.warehouseId != null and params.warehouseId != ''">
  and bill.warehouse_id = #{warehouseId}
</if>
<if test="params.billCode != null and params.billCode != ''">
  and bill.src_code = #{billCode}
</if>
order by bill.src_code

</script>