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

import com.prolog.eis.dao.container.EmptyContainerTaskMapper;
import com.prolog.eis.enums.base.LayerEnum;
import com.prolog.eis.enums.wms.WmsCarryTaskInCode;
import com.prolog.eis.model.container.EmptyContainerTask;
import com.prolog.eis.service.container.EmptyContainerTaskService;
import com.prolog.framework.core.restriction.Criteria;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;


@Slf4j
@Service
@RequiredArgsConstructor
public class EmptyContainerTaskServiceImpl implements EmptyContainerTaskService {

    private final EmptyContainerTaskMapper emptyContainerTaskMapper;

    @Override
    public void save(String containerNo, LayerEnum layerEnum, WmsCarryTaskInCode wmsCarryTaskInCode) {
        EmptyContainerTask emptyContainerTask = new EmptyContainerTask();
        emptyContainerTask.setContainerNo(containerNo);
        emptyContainerTask.setLayer(layerEnum.getCode());
        emptyContainerTask.setCreateTime(LocalDateTime.now());
        emptyContainerTask.setWmsLocationCode(wmsCarryTaskInCode.getCode());
        emptyContainerTaskMapper.save(emptyContainerTask);
    }

    @Override
    public List<EmptyContainerTask> findByCriteria(Criteria criteria) {
        return emptyContainerTaskMapper.findByCriteria(criteria);
    }

    @Override
    public void deleteById(Integer id) {
        emptyContainerTaskMapper.deleteById(id, EmptyContainerTask.class);
    }
}
