package com.hw.wms.service.impl;

import java.util.List;

import com.hw.common.core.exception.ServiceException;
import com.hw.wms.domain.WmsProductStock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hw.wms.mapper.WmsProductStockSaleorderMapper;
import com.hw.wms.domain.WmsProductStockSaleorder;
import com.hw.wms.service.IWmsProductStockSaleorderService;

/**
 * 成品订单库存记录Service业务层处理
 *
 * @author xins
 * @date 2024-02-22
 */
@Service
public class WmsProductStockSaleorderServiceImpl implements IWmsProductStockSaleorderService
{
    @Autowired
    private WmsProductStockSaleorderMapper wmsProductStockSaleorderMapper;

    /**
     * 查询成品订单库存记录
     *
     * @param productStockSaleorderId 成品订单库存记录主键
     * @return 成品订单库存记录
     */
    @Override
    public WmsProductStockSaleorder selectWmsProductStockSaleorderByProductStockSaleorderId(Long productStockSaleorderId)
    {
        return wmsProductStockSaleorderMapper.selectWmsProductStockSaleorderByProductStockSaleorderId(productStockSaleorderId);
    }

    /**
     * 查询成品订单库存记录列表
     *
     * @param wmsProductStockSaleorder 成品订单库存记录
     * @return 成品订单库存记录
     */
    @Override
    public List<WmsProductStockSaleorder> selectWmsProductStockSaleorderList(WmsProductStockSaleorder wmsProductStockSaleorder)
    {
        return wmsProductStockSaleorderMapper.selectWmsProductStockSaleorderList(wmsProductStockSaleorder);
    }

    /**
     * 新增成品订单库存记录
     *
     * @param wmsProductStockSaleorder 成品订单库存记录
     * @return 结果
     */
    @Override
    public int insertWmsProductStockSaleorder(WmsProductStockSaleorder wmsProductStockSaleorder)
    {
        return wmsProductStockSaleorderMapper.insertWmsProductStockSaleorder(wmsProductStockSaleorder);
    }

    /**
     * 修改成品订单库存记录
     *
     * @param wmsProductStockSaleorder 成品订单库存记录
     * @return 结果
     */
    @Override
    public int updateWmsProductStockSaleorder(WmsProductStockSaleorder wmsProductStockSaleorder)
    {
        return wmsProductStockSaleorderMapper.updateWmsProductStockSaleorder(wmsProductStockSaleorder);
    }

    /**
     * 批量删除成品订单库存记录
     *
     * @param productStockSaleorderIds 需要删除的成品订单库存记录主键
     * @return 结果
     */
    @Override
    public int deleteWmsProductStockSaleorderByProductStockSaleorderIds(Long[] productStockSaleorderIds)
    {
        return wmsProductStockSaleorderMapper.deleteWmsProductStockSaleorderByProductStockSaleorderIds(productStockSaleorderIds);
    }

    /**
     * 删除成品订单库存记录信息
     *
     * @param productStockSaleorderId 成品订单库存记录主键
     * @return 结果
     */
    @Override
    public int deleteWmsProductStockSaleorderByProductStockSaleorderId(Long productStockSaleorderId)
    {
        return wmsProductStockSaleorderMapper.deleteWmsProductStockSaleorderByProductStockSaleorderId(productStockSaleorderId);
    }



    /**
     * 根据销售订单查询成品库存列表Join material,warehouse
     *
     * @param wmsProductStockSaleorder 成品销售订单库存信息
     * @return 成品销售订单库存信息
     */
    @Override
    public List<WmsProductStockSaleorder> selectWmsProductStockSaleordersBySaleorder(WmsProductStockSaleorder wmsProductStockSaleorder) {
        List<WmsProductStockSaleorder> list = wmsProductStockSaleorderMapper.selectWmsProductStockSaleorderJoinList(wmsProductStockSaleorder);
        if (list == null || list.isEmpty()) {
            throw new ServiceException("无此销售订单库存信息");
        }

        return list;
    }

}
