package com.op.wms.service.impl;

import java.util.List;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.utils.DateUtils;
import com.op.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.wms.mapper.BaseWarehouseMapper;
import com.op.wms.domain.BaseWarehouse;
import com.op.wms.service.IBaseWarehouseService;

/**
 * 仓库管理Service业务层处理
 * 
 * @author Open Platform
 * @date 2023-07-04
 */
@Service
public class BaseWarehouseServiceImpl implements IBaseWarehouseService {
	@Autowired
	private BaseWarehouseMapper baseWarehouseMapper;

	/**
	 * 查询仓库管理
	 * 
	 * @param warehouseId 仓库管理主键
	 * @return 仓库管理
	 */
	@Override
	@DS("#header.poolName")
	public BaseWarehouse selectBaseWarehouseByWarehouseId(String warehouseId) {
		return baseWarehouseMapper.selectBaseWarehouseByWarehouseId(warehouseId);
	}

	/**
	 * 查询仓库管理列表
	 * 
	 * @param baseWarehouse 仓库管理
	 * @return 仓库管理
	 */
	@Override
	@DS("#header.poolName")
	public List<BaseWarehouse> selectBaseWarehouseList(BaseWarehouse baseWarehouse) {
		return baseWarehouseMapper.selectBaseWarehouseList(baseWarehouse);
	}

	/**
	 * 新增仓库管理
	 * 
	 * @param baseWarehouse 仓库管理
	 * @return 结果
	 */
	@Override
	@DS("#header.poolName")
	public int insertBaseWarehouse(BaseWarehouse baseWarehouse) {
		baseWarehouse.setCreateTime(DateUtils.getNowDate());
		baseWarehouse.setCreateBy(SecurityUtils.getUsername());
//		Integer count = baseWarehouseMapper.queryCount(baseWarehouse);
//		count = count +1;
//		baseWarehouse.setWarehouseId(count + "");
		return baseWarehouseMapper.insertBaseWarehouse(baseWarehouse);
	}

	/**
	 * 修改仓库管理
	 * 
	 * @param baseWarehouse 仓库管理
	 * @return 结果
	 */
	@Override
	@DS("#header.poolName")
	public int updateBaseWarehouse(BaseWarehouse baseWarehouse) {
		baseWarehouse.setUpdateTime(DateUtils.getNowDate());
		baseWarehouse.setUpdateBy(SecurityUtils.getUsername());
		return baseWarehouseMapper.updateBaseWarehouse(baseWarehouse);
	}

	/**
	 * 批量删除仓库管理
	 * 
	 * @param warehouseIds 需要删除的仓库管理主键
	 * @return 结果
	 */
	@Override
	@DS("#header.poolName")
	public int deleteBaseWarehouseByWarehouseIds(String[] warehouseIds) {
		return baseWarehouseMapper.deleteBaseWarehouseByWarehouseIds(warehouseIds);
	}

	/**
	 * 删除仓库管理信息
	 * 
	 * @param warehouseId 仓库管理主键
	 * @return 结果
	 */
	@Override
	@DS("#header.poolName")
	public int deleteBaseWarehouseByWarehouseId(String warehouseId) {
		return baseWarehouseMapper.deleteBaseWarehouseByWarehouseId(warehouseId);
	}
}
