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 LessTaskStrategy extends PositioningStrategy<ContainerInfoDto> {

    public LessTaskStrategy(int order) {
        this.order = order;
    }
    @Override
    public List<ContainerInfoDto> sort(List<ContainerInfoDto> containerInfoDtoList, BigDecimal qty) {
        List<ContainerInfoDto> collect = containerInfoDtoList.stream().sorted(Comparator.comparing(ContainerInfoDto::getTaskNum)).collect(Collectors.toList());
        ContainerInfoDto containerInfoDto = collect.get(0);
        List<ContainerInfoDto> newContainerInfoDtoList = collect.stream().filter(x -> x.getTaskNum().equals(containerInfoDto.getTaskNum())).collect(Collectors.toList());
        return newContainerInfoDtoList;
    }
}
