select itde.goods_id as goodsId, goods.goods_code as pnumber, goods.goods_name as pname , goods.specification as specType , itde.measure_unit as measureUnit from t_b_materialsusing_detail itde left join t_b_materialsusing it on itde.fk_id = it.id left join t_b_goods_info goods on itde.goods_id = goods.id where 1= 1 and it.order_onumber in (select max(order_onumber) from t_b_materialsusing where 1 = 1 <#if ( warehouseid )?? && warehouseid ?length gt 0> /* 仓库 */ and warehouse_id = :warehouseid )