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

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

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

}
