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

import com.prolog.eis.core.dto.route.CarryTaskCallbackDto;
import com.prolog.eis.dao.shelves.PalletInfoMapper;
import com.prolog.eis.model.shelves.PalletInfo;
import com.prolog.eis.service.shelves.CallBackDataService;
import com.prolog.eis.service.shelves.PalletMoveExecuteService;
import com.prolog.framework.utils.MapUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service
public class CallBackDataServiceImpl implements CallBackDataService {

    @Resource
    private PalletInfoMapper palletInfoMapper;

    @Resource
    private PalletMoveExecuteService palletMoveExecuteService;


    @Override
    public void pallNoArriveDeal(PalletInfo palletInfo, CarryTaskCallbackDto carryTaskCallbackDto) throws Exception {
        List<PalletInfo> wmsInTaskList = palletInfoMapper.findByMap(MapUtils.put("palletNo", carryTaskCallbackDto.getContainerNo()).getMap(),PalletInfo.class);

        if (wmsInTaskList.isEmpty()) {
            log.error("入库任务中不存在托盘："+carryTaskCallbackDto.getPalletNo()+"的任务！");
            return;
        }
        palletMoveExecuteService.palletMoveComplete(carryTaskCallbackDto);
    }
}
