package com.hw.qms.service.impl;

import java.util.List;

import com.hw.common.core.constant.QmsConstants;
import com.hw.qms.domain.MesBaseBarcodeInfo;
import com.hw.qms.domain.QmsCheckResultDetail;
import com.hw.qms.domain.QmsCheckRuleDetail;
import com.hw.qms.domain.vo.QmsMaterialCheckVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hw.qms.mapper.QmsCheckRuleProjectMapper;
import com.hw.qms.domain.QmsCheckRuleProject;
import com.hw.qms.service.IQmsCheckRuleProjectService;

/**
 * 检验规则项目Service业务层处理
 *
 * @author xins
 * @date 2024-01-23
 */
@Service
public class QmsCheckRuleProjectServiceImpl implements IQmsCheckRuleProjectService {
    @Autowired
    private QmsCheckRuleProjectMapper qmsCheckRuleProjectMapper;

    /**
     * 查询检验规则项目
     *
     * @param checkRuleId 检验规则项目主键
     * @return 检验规则项目
     */
    @Override
    public QmsCheckRuleProject selectQmsCheckRuleProjectByCheckRuleId(Long checkRuleId) {
        return qmsCheckRuleProjectMapper.selectQmsCheckRuleProjectByCheckRuleId(checkRuleId);
    }

    /**
     * 查询检验规则项目列表
     *
     * @param qmsCheckRuleProject 检验规则项目
     * @return 检验规则项目
     */
    @Override
    public List<QmsCheckRuleProject> selectQmsCheckRuleProjectList(QmsCheckRuleProject qmsCheckRuleProject) {
        return qmsCheckRuleProjectMapper.selectQmsCheckRuleProjectList(qmsCheckRuleProject);
    }

    /**
     * 新增检验规则项目
     *
     * @param qmsCheckRuleProject 检验规则项目
     * @return 结果
     */
    @Override
    public int insertQmsCheckRuleProject(QmsCheckRuleProject qmsCheckRuleProject) {
        return qmsCheckRuleProjectMapper.insertQmsCheckRuleProject(qmsCheckRuleProject);
    }

    /**
     * 修改检验规则项目
     *
     * @param qmsCheckRuleProject 检验规则项目
     * @return 结果
     */
    @Override
    public int updateQmsCheckRuleProject(QmsCheckRuleProject qmsCheckRuleProject) {
        return qmsCheckRuleProjectMapper.updateQmsCheckRuleProject(qmsCheckRuleProject);
    }

    /**
     * 批量删除检验规则项目
     *
     * @param checkRuleIds 需要删除的检验规则项目主键
     * @return 结果
     */
    @Override
    public int deleteQmsCheckRuleProjectByCheckRuleIds(Long[] checkRuleIds) {
        return qmsCheckRuleProjectMapper.deleteQmsCheckRuleProjectByCheckRuleIds(checkRuleIds);
    }

    /**
     * 删除检验规则项目信息
     *
     * @param checkRuleId 检验规则项目主键
     * @return 结果
     */
    @Override
    public int deleteQmsCheckRuleProjectByCheckRuleId(Long checkRuleId) {
        return qmsCheckRuleProjectMapper.deleteQmsCheckRuleProjectByCheckRuleId(checkRuleId);
    }


    /**
     * 获取检验规则项目
     * @param materialId 物料ID
     * @return
     */
    @Override
    public List<QmsCheckRuleProject> getCheckRuleProjects(Long materialId) {
        QmsCheckRuleProject queryCheckRuleProject = new QmsCheckRuleProject();
        queryCheckRuleProject.setTargetType(QmsConstants.QMS_CHECK_RULE_DETAIL_TARGET_TYPE_MATERIAL);
        queryCheckRuleProject.setTargetId(materialId);

        List<QmsCheckRuleProject> checkRuleProjects = qmsCheckRuleProjectMapper.selectQmsCheckRuleProjectListByTarget(queryCheckRuleProject);

        return checkRuleProjects;
    }



    /**
     * 查询检验规则项目列表,Join checkproject
     *
     * @param qmsCheckRuleProject 检验规则项目
     * @return 检验规则项目
     */
    @Override
    public List<QmsCheckRuleProject> selectQmsCheckRuleProjectJoinList(QmsCheckRuleProject qmsCheckRuleProject) {
        return qmsCheckRuleProjectMapper.selectQmsCheckRuleProjectJoinList(qmsCheckRuleProject);
    }

    /**
     * 批量删除检验规则项目
     *
     * @param checkRuleProjectList 需要删除的检验规则项目列表
     * @return 结果
     */
    @Override
    public int deleteQmsCheckRuleProjects(List<QmsCheckRuleProject> checkRuleProjectList)
    {
        return qmsCheckRuleProjectMapper.deleteQmsCheckRuleProjects(checkRuleProjectList);
    }
}
