package com.zbf.system.service.impl;

import java.util.List;
import java.util.stream.Collectors;

import com.zbf.common.annotation.DataScope;
import com.zbf.common.annotation.DataSource;
import com.zbf.common.enums.DataSourceType;
import com.zbf.system.domain.TBaseStorage;
import com.zbf.system.service.ITBaseStorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; //添加
import com.zbf.common.utils.DateUtils;
import com.zbf.system.domain.TOngoodsshelfBak;
import com.zbf.system.mapper.TOngoodsshelfBakMapper;
import com.zbf.system.service.ITOngoodsshelfBakService;

/**
 * 入库任务历史Service业务层处理
 *
 * @author tony
 * @date 2024-06-18
 */
@Service
public class TOngoodsshelfBakServiceImpl extends ServiceImpl<TOngoodsshelfBakMapper, TOngoodsshelfBak> implements ITOngoodsshelfBakService //修改
{
    @Autowired
    private TOngoodsshelfBakMapper tOngoodsshelfBakMapper;
    @Autowired
    private ITBaseStorageService baseStorageService;

    /**
     * 查询入库任务历史
     *
     * @param id 入库任务历史主键
     * @return 入库任务历史
     */
    @Override
    public TOngoodsshelfBak selectTOngoodsshelfBakById(String id)
    {
        return tOngoodsshelfBakMapper.selectTOngoodsshelfBakById(id);
    }

    /**
     * 查询入库任务历史列表
     *
     * @param tOngoodsshelfBak 入库任务历史
     * @return 入库任务历史
     */
    @DataSource(value = DataSourceType.MASTER)
    @Override
    public List<TOngoodsshelfBak> selectTOngoodsshelfBakList(TOngoodsshelfBak tOngoodsshelfBak)
    {
//        TBaseStorage baseStorage = new TBaseStorage();
//        baseStorage.setDeptId(tOngoodsshelfBak.getDeptId());
//        List<TBaseStorage> tBaseStorages = baseStorageService.selectTBaseStorageList(baseStorage);
//        tOngoodsshelfBak.setStorageList(tBaseStorages.stream().map(TBaseStorage::getStorageId).collect(Collectors.toList()));

        return tOngoodsshelfBakMapper.selectTOngoodsshelfBakList(tOngoodsshelfBak);
    }

    /**
     * 新增入库任务历史
     *
     * @param tOngoodsshelfBak 入库任务历史
     * @return 结果
     */
    @Override
    public int insertTOngoodsshelfBak(TOngoodsshelfBak tOngoodsshelfBak)
    {
        tOngoodsshelfBak.setCreateTime(DateUtils.getNowDate());
        return tOngoodsshelfBakMapper.insertTOngoodsshelfBak(tOngoodsshelfBak);
    }

    /**
     * 修改入库任务历史
     *
     * @param tOngoodsshelfBak 入库任务历史
     * @return 结果
     */
    @Override
    public int updateTOngoodsshelfBak(TOngoodsshelfBak tOngoodsshelfBak)
    {
                tOngoodsshelfBak.setUpdateTime(DateUtils.getNowDate());
        return tOngoodsshelfBakMapper.updateTOngoodsshelfBak(tOngoodsshelfBak);
    }

    /**
     * 批量删除入库任务历史
     *
     * @param ids 需要删除的入库任务历史主键
     * @return 结果
     */
    @Override
    public int deleteTOngoodsshelfBakByIds(String[] ids)
    {
        return tOngoodsshelfBakMapper.deleteTOngoodsshelfBakByIds(ids);
    }

    /**
     * 删除入库任务历史信息
     *
     * @param id 入库任务历史主键
     * @return 结果
     */
    @Override
    public int deleteTOngoodsshelfBakById(String id)
    {
        return tOngoodsshelfBakMapper.deleteTOngoodsshelfBakById(id);
    }


    /**
     * 批量禁用
     *
     * @param id 入库任务历史主键
     * @return 结果
     */
    @Override
    public int disabledTOngoodsshelfBakByIds(String[] ids) {
        return tOngoodsshelfBakMapper.disabledTOngoodsshelfBakByIds(ids);
    }

    /**
     * 批量启用
     *
     * @param id 入库任务历史主键
     * @return 结果
     */
    @Override
    public int enableTOngoodsshelfBakByIds(String[] ids) {
        return tOngoodsshelfBakMapper.enableTOngoodsshelfBakByIds(ids);
    }

    /**
     * 修改状态
     *
     * @param tOngoodsshelfBak 工序管理主键
     * @return 结果
     */
    @Override
    public int updateStatus(TOngoodsshelfBak tOngoodsshelfBak) {
        return tOngoodsshelfBakMapper.updateTOngoodsshelfBak(tOngoodsshelfBak);
    }

    @Override
    public List<TOngoodsshelfBak> list(LambdaQueryWrapper<TOngoodsshelfBak> tCkPickingwavegoodsBakLambdaQueryWrapper) {
        return tOngoodsshelfBakMapper.selectList(tCkPickingwavegoodsBakLambdaQueryWrapper);
    }

}
