package com.prolog.eis.roadway_allocation;

import com.prolog.eis.dto.strategy.AreaInfoDto;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class GoodsSplitStrategy extends AllocationStrategy<AreaInfoDto>{

    public GoodsSplitStrategy(int order) {
        this.order = order;
    }

    @Override
    public List<AreaInfoDto> sort(List<AreaInfoDto> list) {
        System.out.println("商品均分排序");
        List<AreaInfoDto> collect = list.stream().sorted(Comparator.comparing(AreaInfoDto::getGoodsNum)).collect(Collectors.toList());
        AreaInfoDto areaInfoDto = collect.get(0);
        List<AreaInfoDto> newAreaInfoDtoList = collect.stream().filter(x -> x.getGoodsNum().equals(areaInfoDto.getGoodsNum())).collect(Collectors.toList());
        System.out.println(newAreaInfoDtoList);
        return newAreaInfoDtoList;
    }
}
