package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.InspectInforMapper;
import com.ruoyi.system.domain.InspectInfor;
import com.ruoyi.system.service.IInspectInforService;

/**
 * 送检信息Service业务层处理
 * 
 * @author boman
 * @date 2021-12-27
 */
@Service
public class InspectInforServiceImpl implements IInspectInforService 
{
    @Autowired
    private InspectInforMapper inspectInforMapper;

    /**
     * 查询送检信息
     * 
     * @param inspectId 送检信息主键
     * @return 送检信息
     */
    @Override
    public InspectInfor selectInspectInforByInspectId(Long inspectId)
    {
        return inspectInforMapper.selectInspectInforByInspectId(inspectId);
    }

    /**
     * 查询送检信息列表
     * 
     * @param inspectInfor 送检信息
     * @return 送检信息
     */
    @Override
    public List<InspectInfor> selectInspectInforList(InspectInfor inspectInfor)
    {
        return inspectInforMapper.selectInspectInforList(inspectInfor);
    }

    /**
     * 新增送检信息
     * 
     * @param inspectInfor 送检信息
     * @return 结果
     */
    @Override
    public int insertInspectInfor(InspectInfor inspectInfor)
    {
        inspectInfor.setCreateTime(DateUtils.getNowDate());
        return inspectInforMapper.insertInspectInfor(inspectInfor);
    }

    /**
     * 修改送检信息
     * 
     * @param inspectInfor 送检信息
     * @return 结果
     */
    @Override
    public int updateInspectInfor(InspectInfor inspectInfor)
    {
        inspectInfor.setUpdateTime(DateUtils.getNowDate());
        return inspectInforMapper.updateInspectInfor(inspectInfor);
    }

    /**
     * 批量删除送检信息
     * 
     * @param inspectIds 需要删除的送检信息主键
     * @return 结果
     */
    @Override
    public int deleteInspectInforByInspectIds(Long[] inspectIds)
    {
        return inspectInforMapper.deleteInspectInforByInspectIds(inspectIds);
    }

    /**
     * 删除送检信息信息
     * 
     * @param inspectId 送检信息主键
     * @return 结果
     */
    @Override
    public int deleteInspectInforByInspectId(Long inspectId)
    {
        return inspectInforMapper.deleteInspectInforByInspectId(inspectId);
    }

    /**
     * 校验样品名称的唯一性
     * @param inspectInfor
     * @return
     */
    @Override
    public String checkSampleNameUnique(InspectInfor inspectInfor) {
        Long inspectId = StringUtils.isNull(inspectInfor.getInspectId()) ? -1L : inspectInfor.getInspectId();
        InspectInfor info = inspectInforMapper.checkSampleNameUnique(inspectInfor.getSampleName());
        if (StringUtils.isNotNull(info) && info.getInspectId().longValue() != inspectId.longValue())
        {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }
}
