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.BaseAreaMapper;
import com.op.wms.domain.BaseArea;
import com.op.wms.service.IBaseAreaService;

/**
 * 库区Service业务层处理
 * 
 * @author Open Platform
 * @date 2023-07-04
 */
@Service
public class BaseAreaServiceImpl implements IBaseAreaService {
	@Autowired
	private BaseAreaMapper baseAreaMapper;

	/**
	 * 查询库区
	 * 
	 * @param areaId 库区主键
	 * @return 库区
	 */
	@Override
	@DS("#header.poolName")
	public BaseArea selectBaseAreaByAreaId(String areaId) {
		return baseAreaMapper.selectBaseAreaByAreaId(areaId);
	}

	/**
	 * 查询库区列表
	 * 
	 * @param baseArea 库区
	 * @return 库区
	 */
	@Override
	@DS("#header.poolName")
	public List<BaseArea> selectBaseAreaList(BaseArea baseArea) {
		return baseAreaMapper.selectBaseAreaList(baseArea);
	}

	/**
	 * 新增库区
	 * 
	 * @param baseArea 库区
	 * @return 结果
	 */
	@Override
	@DS("#header.poolName")
	public int insertBaseArea(BaseArea baseArea) {
		baseArea.setCreateTime(DateUtils.getNowDate());
		baseArea.setCreateBy(SecurityUtils.getUsername());
//		Integer count = baseAreaMapper.queryCount(baseArea);
//		count = count +1;
//		baseArea.setAreaId(count + "");
		return baseAreaMapper.insertBaseArea(baseArea);
	}

	/**
	 * 修改库区
	 * 
	 * @param baseArea 库区
	 * @return 结果
	 */
	@Override
	@DS("#header.poolName")
	public int updateBaseArea(BaseArea baseArea) {
		baseArea.setUpdateTime(DateUtils.getNowDate());
		baseArea.setUpdateBy(SecurityUtils.getUsername());
		return baseAreaMapper.updateBaseArea(baseArea);
	}

	/**
	 * 批量删除库区
	 * 
	 * @param areaIds 需要删除的库区主键
	 * @return 结果
	 */
	@Override
	@DS("#header.poolName")
	public int deleteBaseAreaByAreaIds(String[] areaIds) {
		return baseAreaMapper.deleteBaseAreaByAreaIds(areaIds);
	}

	/**
	 * 删除库区信息
	 * 
	 * @param areaId 库区主键
	 * @return 结果
	 */
	@Override
	@DS("#header.poolName")
	public int deleteBaseAreaByAreaId(String areaId) {
		return baseAreaMapper.deleteBaseAreaByAreaId(areaId);
	}
}
