package com.ruoyi.invest.service.impl;

import com.ruoyi.invest.domain.FlowBaseInfo;
import com.ruoyi.invest.mapper.FlowBaseInfoMapper;
import com.ruoyi.invest.service.IFlowBaseInfoService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;


@Service
public class FlowBaseInfoServiceImpl implements IFlowBaseInfoService {
    @Autowired
    private FlowBaseInfoMapper flowBaseInfoMapper;


    /**
     * 录入流程审核过程中的相关信息
     */
    @Override
    public boolean addActivitiBaseInfo(FlowBaseInfo actBaseInfo) {

        Integer effectCount = flowBaseInfoMapper.insert(actBaseInfo);

        boolean addOk = effectCount != null && effectCount > 0 ? true : false;

        return addOk;

    }

    /**
     * 根据流程实例id获取流程审核过程中的相关信息
     */
    @Override
    public List<FlowBaseInfo> searchFlowBaseInfoByProcInsId(String procInsId) {

        List<FlowBaseInfo> lstActBaseInfo = flowBaseInfoMapper.selectByProcInsId(procInsId);

        return lstActBaseInfo;
    }

    /**
     * 根据实例Id 查询当前审批人
     * @param procInsId
     * @return
     */
    @Override
    public FlowBaseInfo selectCurrentApproval(String procInsId){
        return flowBaseInfoMapper.selectCurrentApproval(procInsId);
    }
    /**
     * 根据流程实例id获取流程审核过程中的相关信息
     */
    @Override
    public List<FlowBaseInfo> searchFlowBaseInfoByProcInsIdAndTaskDefKey(String procInsId, String taskDefKey) {

        List<FlowBaseInfo> lstActBaseInfo = flowBaseInfoMapper.selectByProcInsIdAndTaskDefKey(procInsId,taskDefKey);

        return lstActBaseInfo;
    }

    /**
     * 删除流程审批过程中的相关信息
     */
    @Override
    public boolean deleteFlowBaseInfo(FlowBaseInfo actBaseInfo) {

        Integer effectCount = flowBaseInfoMapper.delete(actBaseInfo);

        boolean delOk = effectCount != null && effectCount > 0 ? true : false;

        return delOk;
    }

    /**
     * 删除流程审批过程中的相关信息
     */
    @Override
    public boolean deleteByProAndtaskDefkey(FlowBaseInfo actBaseInfo) {

        Integer effectCount = flowBaseInfoMapper.deleteByProAndtaskDefkey(actBaseInfo);

        boolean delOk = effectCount != null && effectCount > 0 ? true : false;

        return delOk;
    }






    @Override
    public Integer checkReStatus(FlowBaseInfo act) {
        Integer check=flowBaseInfoMapper.checkReStatus(act);
        return check;
    }
    @Override
    public List<FlowBaseInfo> searchFlowBaseInfoByProcInsIdAndTaskName(String procInsId, String taskName) {
        return flowBaseInfoMapper.searchFlowBaseInfoByProcInsIdAndTaskName(procInsId,taskName);
    }
    /**
     * 根据实例Id 查询当前审批人
     * @param procInsId
     * @return
     */
    @Override
    public FlowBaseInfo selectLasterByProcInsId(String procInsId){
        return flowBaseInfoMapper.selectLasterByProcInsId(procInsId);
    }
}
