package com.qqchen.deploy.backend.workflow.service;

import com.qqchen.deploy.backend.framework.service.IBaseService;
import com.qqchen.deploy.backend.workflow.dto.WorkflowCategoryDTO;
import com.qqchen.deploy.backend.workflow.dto.WorkflowDefinitionDTO;
import com.qqchen.deploy.backend.workflow.dto.WorkflowDesignDTO;
import com.qqchen.deploy.backend.workflow.dto.WorkflowExecutionDTO;
import com.qqchen.deploy.backend.workflow.dto.WorkflowInstanceCreateDTO;
import com.qqchen.deploy.backend.workflow.dto.WorkflowInstanceDTO;
import com.qqchen.deploy.backend.workflow.dto.query.WorkflowDefinitionQuery;
import com.qqchen.deploy.backend.workflow.entity.WorkflowDefinition;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 工作流定义服务接口
 */
public interface IWorkflowDefinitionService extends IBaseService<WorkflowDefinition, WorkflowDefinitionDTO, WorkflowDefinitionQuery, Long> {

    WorkflowDefinitionDTO saveWorkflowDesign(WorkflowDefinitionDTO dto) throws Exception;

    /**
     * 部署工作流
     *
     * @param dto 工作流定义DTO
     * @return 工作流定义DTO
     */
    Deployment deployWorkflow(WorkflowDefinition workflowDefinition);
    
    /**
     * 挂起工作流实例
     *
     * @param processInstanceId 流程实例ID
     */
    void suspendWorkflow(String processInstanceId);
    
    /**
     * 恢复工作流实例
     *
     * @param processInstanceId 流程实例ID
     */
    void resumeWorkflow(String processInstanceId);
    
    /**
     * 获取工作流执行状态
     *
     * @param processInstanceId 流程实例ID
     * @return 工作流执行状态DTO
     */
    WorkflowExecutionDTO getWorkflowExecution(String processInstanceId);

    void disable(Long id);

    void enable(Long id);

    void publishedWorkflowDesign(Long workflowDefinitionId);

    List<WorkflowCategoryDTO> getWorkflowCategories();

    List<WorkflowDefinitionDTO> findPublishedWorkflow();
}
