package com.ho.flow.service;

import com.ho.common.tools.entity.SimpleUser;
import com.ho.flow.entity.WorkOrderSub;
import com.ho.flow.entity.WorkOrderPlan;
import com.ho.flow.vo.req.workorder.*;
import com.ho.flow.vo.resp.workorder.FallBackTaskResp;
import com.ho.flow.vo.resp.workorder.HisTaskResp;
import com.ho.flow.vo.resp.workorder.TaskDone;
import com.ho.flow.vo.resp.workorder.WorkOrderRespVO;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.task.Task;

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

/**
 * @author fancl
 * @desc: 流程控制接口
 * @date 2023/2/5
 */
public interface ProcessFlowService {
    //根据任务id查询任务
    Task getTaskById(TaskUserReq taskUserReq);

    //查代办列表,根据用户名集团id查询
    Map<String,List<Task>> getTodoList(SimpleUser simpleUser);

    //组装任务对象
    List<TaskDone> getToDoListFromTask(Map<String,List<Task>> taskMap,DoListTaskReq doListTaskReq);

    //保存工单并发起流程,代办人设置为自己
    String saveOrderAndStartProcess(WorkOrderAddReqVO workOrderAddReqVO);

    //工单详情
    WorkOrderRespVO getOrderDetail();

    //接收任务,对应claim
    void doClaimTask(TaskUserReq taskReq);

    //完成工单任务
    void doCompleteTask(DoTaskReq doTaskReq);

    void doNullifyTaskTask(DoTaskReq doTaskReq);

    //退回工单任务
    void doRejectTask(RejectTaskReq rejectTaskReq );

    //作废任务
    void doDiscardTask(TaskReq taskReq);


    List<FallBackTaskResp> getFallBackTask(FallBackTaskReq fallBackTaskReq);

    //查下一节点
    String getNextTaskName(String processInstId);


    List<HisTaskResp> getCirculationTask(CirculationTaskReq taskReq);


    List<HistoricTaskInstance> getDoneList(SimpleUser simpleUser);

    List<TaskDone> getDoneListFromTask(List<HistoricTaskInstance> taskList,DoListTaskReq doListTaskReq);

    //用于定时任务创建工单并流转工单
    void planAddWorkOrder(WorkOrderPlan workOrderPlan,List<String> userIds,List<WorkOrderSub> workOrderSubs);

    /**
     * 根据集团id部署工作流
     * @param groupId
     */
    void deploymentWorkflow(Integer groupId);
}
