package com.willalp.flow.service;

import com.willalp.flow.domain.HsFlowBase;
import com.willalp.flow.domain.HsFlowRunningRecord;
import com.willalp.flow.domain.HsFlowTask;
import com.willalp.flow.domain.req.FlowReq;
import com.willalp.system.domain.vo.PostTreeVo;

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

/**
 * 会山流程引擎业务接口
 * @author Administrator
 */
public interface HsFlowEngineService {

    /** 请假流程配置key*/
    String BIZ_LEAVE_FLOW_KEY = "biz_leave_flow_run_key";

    /** 投稿流程配置key*/
    String FILE_APPROVAL_FLOW_KEY = "file_approval_flow_run_key";

    /** 物资领用流程配置key*/
    String RESERVE_FLOW_KEY = "reserve_consuming_flow_run_key";
    /** 物资归还流程配置key*/
    String RESERVE_RETURN_FLOW_RUN_KEY = "reserve_return_flow_run_key";
    /** 物资登记流程配置key*/
    String RESERVE_REGISTER_FLOW_RUN_KEY = "reserve_register_flow_run_key";

    /** 员工入职流程配置key*/
    String PRSSONNEl_HIRE_APP_FLOW_RUN_KEY = "personnel_hire_approval_flow_run_key";
    /** 员工离职流程配置key*/
    String PERSONNEL_DIMISSION_APPROVAL_FLOW_RUN_KEY = "personnel_dimission_approval_flow_run_key";

    /** 空节点*/
    String EMPTY = "EMPTY";

    /** 根节点*/
    String ROOT = "ROOT";

    /** 审批节点*/
    String APPROVAL = "APPROVAL";

    /** 条件节点*/
    String CONDITION = "CONDITION";

    /** 条件节点组*/
    String CONDITIONS = "CONDITIONS";

    /** 并行节点*/
    String CONCURRENT = "CONCURRENT";

    /** 抄送节点*/
    String CC = "CC";

    /** 延时处理节点*/
    String DELAY = "DELAY";

    /** 触发器节点*/
    String TRIGGER = "TRIGGER";

    /**
     * 通用常量
     */
    String ONE = "1";
    String ZERO = "0";
    String FOUR = "4";
    String SEVEN = "7";
    String TITLE = "title";
    String P_LABEL_TAIL = "</p>";
    String APPLY_USER_NAME = "apply_user_name";

    /** 任务结束中文*/
    String TASK_END_CN_TEXT = "任务已结束";

    /** 任务自动结束中文*/
    String TASK_AUTO_END_CN_TEXT = "自动结束";

    /** 审批状态*/
    String APPROVED = "已通过";
    String UNDERWAY = "进行中";
    String DENIED = "已拒绝";
    String REJECT = "驳回";
    String CONSENT = "同意";

    /** 抄送信息*/
    String CC_TITLE = "审批抄送";


    /**
     * 提交并生成任务实例
     *
     * @param task 任务
     * @param params 表单数据
     * @return
     */
    Map<String, Object> submitTask(HsFlowTask task, Map<String, Object> params);


    /**
     * 提交任务候选人
     *
     * @param taskId
     * @param candidate
     * @param applyUserName
     * @return
     */
    int submitCandidate(String taskId, String candidate, String applyUserName);

    /**
     * 下一步
     *
     * @param flow
     * @return
     */
    int nextStep(FlowReq flow);

    /**
     * 所有基础节点运行逻辑封装
     *
     *  @param base 当前节点基本信息
     * @param task 当前任务
     * @param formData 表单业务数据
     * @return
     */
    HsFlowBase baseRun(HsFlowBase base, HsFlowTask task, Map<String, Object> formData);

    /**
     * 获取待办
     *
     * @param taskId
     * @return
     */
    List<HsFlowTask> getToDoByTaskId(String taskId);

    /**
     * 通过抄送ID获取任务信息
     *
     * @param ccId
     * @return
     */
    List<HsFlowTask> getTaskIdByCcId(String ccId);

    /**
     * 获取待办
     *
     * @param userCode
     * @return
     */
    List<HsFlowTask> getToDo(String userCode);

    /**
     * 获取已办
     *
     * @param userCode
     * @return
     */
    List<HsFlowTask> getDone(String userCode);

    /**
     * 获取已办
     *
     * @param userCode
     * @return
     */
    List<HsFlowTask> getInitiator(String userCode);

    /**
     * 获取当前任务记录
     *
     * @param taskId
     * @return
     */
    List<HsFlowRunningRecord> currentTaskRecords(String taskId);

    /**
     * 驳回时选择进度
     *
     * @param taskId
     * @return
     */
    List<HsFlowRunningRecord> rejectTaskRecords(String taskId);

    /**
     * 任务撤销
     *
     * @param taskId
     * @return
     */
    int revoke(String taskId);

    /**
     * 删除业务表单
     *
     * @param examplesId
     * @param businessId
     * @return
     */
    int removeBusinessForm(String examplesId, String businessId);

    /**
     * 获取审批树岗位
     *
     * @return
     * @param groupId
     * @param baseId
     */
    List<PostTreeVo> getApprovalTreePost(String groupId, String baseId);

    /**
     * 获取审批树岗位
     *
     * @return
     * @param groupId
     * @param baseId
     */
    List<PostTreeVo> getNextApprovalTreePost(String groupId, String baseId);
}
