package com.prolog.eis.service.buildwave.impl;

import com.prolog.eis.algorithm.PickOrderBuilder;
import com.prolog.eis.dto.buildwave.BuildWaveDispatchDto;
import com.prolog.eis.dto.buildwave.PObOrderCollection;
import com.prolog.eis.dto.buildwave.PObPickOrderDto;
import com.prolog.eis.dto.buildwave.PObResultDto;
import com.prolog.eis.service.buildwave.BuildWaveService;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * @Version: 1.0
 * @Author: wuhan
 * @Created: 2024/7/30 15:07
 */
@Service
public class BuildWaveServiceImpl implements BuildWaveService {
    @Override
    public PObResultDto buildWave(BuildWaveDispatchDto dispatchDto) throws Exception {
        PObOrderCollection orderCollection = new PObOrderCollection();
        orderCollection.setOrderList(dispatchDto.getOrderList());

        PickOrderBuilder pickOrderBuilder = new PickOrderBuilder(orderCollection, dispatchDto.getMaxWaveOrderCount(), new BigDecimal(99999999), 99999999, dispatchDto.getStoreMap());
        PObPickOrderDto pickOrder = pickOrderBuilder.takerPickOrder();

        if (pickOrder.getOrderList() == null || pickOrder.getOrderList().size() == 0) {
            return null;
        } else {
            PObResultDto result = new PObResultDto();
            result.setOrderList(pickOrder.getOrderList());

            return result;
        }
    }
}
