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

import com.prolog.eis.dao.out.ContainerTaskDismantleMapper;
import com.prolog.eis.dto.outbound.ContainerTaskDismantleDto;
import com.prolog.eis.dto.page.AllotmentConfirm;
import com.prolog.eis.dto.page.AllotmentOrderDto;
import com.prolog.eis.model.container.ContainerTask;
import com.prolog.eis.model.out.ContainerTaskDismantle;
import com.prolog.eis.service.out.ContainerTaskDismantleService;
import com.prolog.framework.core.restriction.Criteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author zmr
 * @description: 出库任务拆零详情表-服务实现类
 * @date 2023-09-11 16:33
 */
@Service
public class ContainerTaskDismantleServiceImpl implements ContainerTaskDismantleService {

    @Autowired
    private ContainerTaskDismantleMapper containerTaskDismantleMapper;

    /**
     * 新增数据
     *
     * @param containerTaskDismantle 出库任务拆零详情表
     */
    @Override
    public long save(ContainerTaskDismantle containerTaskDismantle) {
        return containerTaskDismantleMapper.save(containerTaskDismantle);
    }

    /**
     * 新增批量数据
     *
     * @param containerTaskDismantleList 出库任务拆零详情表
     */
    @Override
    public long saveBatch(List<ContainerTaskDismantle> containerTaskDismantleList) {
        return containerTaskDismantleMapper.saveBatch(containerTaskDismantleList);
    }

    /**
     * 查询多条数据
     *
     * @param paramMap 查询起始位置
     * @return 对象列表
     */
    @Override
    public List<ContainerTaskDismantle> findByMap(Map<String, Object> paramMap) {
        return containerTaskDismantleMapper.findByMap(paramMap, ContainerTaskDismantle.class);
    }

    /**
     * 查询单条数据
     *
     * @param paramMap 查询起始位置
     * @return 对象
     */
    @Override
    public ContainerTaskDismantle findOneByMap(Map<String, Object> paramMap) {
        List<ContainerTaskDismantle> dataList = findByMap(paramMap);
        if(dataList.isEmpty()) {
            return null;
        }
        return dataList.get(0);
    }

    /**
     * 查询多条数据
     *
     * @param criteria 查询起始位置
     * @return 对象列表
     */
    @Override
    public List<ContainerTaskDismantle> findByCriteria(Criteria criteria) {
        return containerTaskDismantleMapper.findByCriteria(criteria);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ContainerTaskDismantle findById(int id) {
        return containerTaskDismantleMapper.findById(id, ContainerTaskDismantle.class);
    }

    /**
     * 修改数据
     *
     * @param containerTaskDismantle 实例对象
     */
    @Override
    public long update(ContainerTaskDismantle containerTaskDismantle) {
        return containerTaskDismantleMapper.update(containerTaskDismantle);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     */
    @Override
    public long deleteById(int id) {
        return containerTaskDismantleMapper.deleteById(id, ContainerTaskDismantle.class);
    }

    /**
     * 通过参数删除数据
     *
     * @param paramMap 参数
     */
    @Override
    public long deleteByMap(Map<String, Object> paramMap) {
        return containerTaskDismantleMapper.deleteByMap(paramMap, ContainerTaskDismantle.class);
    }

    /**
     * 通过参数查询总条数
     *
     * @param paramMap 参数
     */
    @Override
    public long findCountByMap(Map<String, Object> paramMap) {
        return containerTaskDismantleMapper.findCountByMap(paramMap, ContainerTaskDismantle.class);
    }

    @Override
    public List<ContainerTask> dismantleFullList(String containerNo) {
        return containerTaskDismantleMapper.dismantleFullList(containerNo);
    }

    @Override
    public List<ContainerTask> dismantleFullDetail(String  containerNo) {
        return containerTaskDismantleMapper.dismantleFullDetail(containerNo);
    }

    @Override
    public List<ContainerTask> findDismantlePickingList(String containerNo) throws Exception {
        return containerTaskDismantleMapper.findDismantlePickingList(containerNo);
    }
    @Override
    public ContainerTask findDismantlePickingDetail(String containerSubNo) throws Exception {
        return containerTaskDismantleMapper.findDismantlePickingDetail(containerSubNo);
    }

    @Override
    public List<AllotmentOrderDto> findAllotmentOrder(String itemId) {
        return containerTaskDismantleMapper.findAllotmentOrder(itemId);
    }

    @Override
    public AllotmentOrderDto findAllotmentOrderDetail(AllotmentConfirm req) {
        return containerTaskDismantleMapper.findAllotmentOrderDetail(req.getItemId(), req.getOutboundDetailId());
    }

    @Override
    public void updateMapByCriteria(Map<String, Object> map, Criteria criteria) {
        containerTaskDismantleMapper.updateMapByCriteria(map, criteria);
    }

    @Override
    public List<ContainerTaskDismantleDto> findContainerTaskList(String warehouseArea) {
        return containerTaskDismantleMapper.findContainerTaskList(warehouseArea);
    }

    @Override
    public long findCountByCriteria(Criteria criteria) {
        return containerTaskDismantleMapper.findCountByCriteria(criteria);
    }

    @Override
    public List<ContainerTaskDismantle>  findDismantleContainerTask(String containerSubNo) {
        return containerTaskDismantleMapper.findDismantleContainerTask(containerSubNo);
    }
}
