package com.qmth.sop.business.activiti.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qmth.sop.business.bean.params.FlowApproveParam;
import com.qmth.sop.business.bean.result.FlowViewResult;
import com.qmth.sop.business.bean.result.WorkTaskResult;
import com.qmth.sop.common.enums.FlowTaskTypeEnum;
import com.qmth.sop.common.enums.TFCustomTypeEnum;
import org.activiti.engine.task.Task;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @Description: activiti service
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2021/7/12
 */
public interface ActivitiService {

    /**
     * 根据deploymentId查找processDefinitionId
     *
     * @param deploymentId
     * @return
     */
    String findProcessDefinitionIdByDeploymentId(String deploymentId);

    /**
     * 上传流程
     *
     * @param file
     * @return
     * @throws IOException
     */
    public Map<String, Object> upload(MultipartFile file) throws Exception;

    /**
     * 部署流程
     *
     * @param tfCustomTypeEnumList
     * @return
     * @throws IOException
     */
    public Map<String, Object> createDeployment(List<TFCustomTypeEnum> tfCustomTypeEnumList) throws Exception;

    /**
     * 审批任务
     *
     * @param flowApproveParam
     * @return
     */
    public Map<String, Object> taskApprove(FlowApproveParam flowApproveParam) throws InterruptedException;

    /**
     * 审批任务
     *
     * @param flowApproveParam
     * @return
     */
    public Map<String, Object> taskApproveCommon(FlowApproveParam flowApproveParam) throws InterruptedException;

    /**
     * 获取流程表单属性接口
     *
     * @param flowDeploymentId
     * @param flowId
     * @param taskId
     * @param dynamicTable
     * @param crmNo
     * @return
     */
    public Map<String, Object> formPropertiesGet(String flowDeploymentId, Long flowId, Long taskId, Boolean dynamicTable, String crmNo) throws Exception;

    /**
     * 获取用户待办
     *
     * @param iPage
     * @param userId
     * @param type
     * @param serviceId
     * @param customName
     * @param flowTaskTypeEnum
     * @param crmNo
     * @return
     */
    public IPage<WorkTaskResult> getFlowTaskList(IPage<Map> iPage, Long userId, TFCustomTypeEnum type, Long serviceId, String customName, FlowTaskTypeEnum flowTaskTypeEnum, String crmNo);

    /**
     * 获取用户待办计数
     *
     * @param userId
     * @param type
     * @param serviceId
     * @param customName
     * @param flowTaskTypeEnum
     * @param crmNo
     * @return
     */
    public int getFlowTaskListCount(Long userId, TFCustomTypeEnum type, Long serviceId, String customName, FlowTaskTypeEnum flowTaskTypeEnum, String crmNo);

    /**
     * 流程节点转他人审批
     *
     * @param userId
     * @param taskId
     * @return
     */
    public Boolean taskApproverExchange(Long userId, Long taskId);

    /**
     * 流程终止
     *
     * @param flowId
     * @return
     */
    public Boolean flowEnd(Long flowId);

    /**
     * 流程批量终止
     *
     * @param flowIds
     * @return
     */
    public Boolean flowEnd(List<Long> flowIds);

    /**
     * 流程终止
     *
     * @param crmNo
     * @return
     */
    public Boolean flowEnd(String crmNo);

    /**
     * 获取流程详细信息接口
     *
     * @param flowId
     * @param code
     * @return
     */
    public FlowViewResult flowView(Long flowId, String code);

    /**
     * 获取流程节点审批人员
     *
     * @param task
     * @return
     */
    public List<String> getTaskApprove(Task task);
}
