package com.prolog.eis.pallet_positioning;

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

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

/**
 * @author wk
 * 库存定位策略   --> 追加同一托盘任务最多，出库托盘最少
 */
public class PalletTaskStrategy extends PositioningStrategy<ContainerInfoDto> {

    public PalletTaskStrategy(int order) {
        this.order = order;
    }
    @Override
    public List<ContainerInfoDto> sort(List<ContainerInfoDto> containerInfoDtoList, BigDecimal qty) {
        System.out.println("追加最多，出库托盘最少排序");
        List<ContainerInfoDto> collect = containerInfoDtoList.stream().sorted(Comparator.comparing(ContainerInfoDto::getOrderNum,Comparator.reverseOrder())).collect(Collectors.toList());
        ContainerInfoDto containerInfoDto = collect.get(0);
        List<ContainerInfoDto> newContainerInfoDtoList = collect.stream().filter(x -> x.getOrderNum().equals(containerInfoDto.getOrderNum())).collect(Collectors.toList());
        return newContainerInfoDtoList;
    }
}
