package com.mortals.xhx.feign.flowable;

import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.xhx.common.pdu.api.ApiRespPdu;
import com.mortals.xhx.common.pdu.flow.*;
import com.mortals.xhx.feign.IFeign;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

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

/**
 * 工作流任务管理
 *
 * @author: finegirl
 * @date: 2021/7/31 19:52
 */
@FeignClient(name = "${application.register.service-name:government-workflow}")
public interface IApiFlowTaskFeign extends IFeign {


    /**
     * 我发起的流程
     *
     * @param userId
     * @param pageInfo
     * @return
     */
    @PostMapping("/flowable/task/myProcess")
    ApiRespPdu<Result<FlowTaskPdu>> myProcess(@RequestParam(value = "userId") String userId,
                                              @RequestParam(value = "tenantId") String tenantId,
                                              @RequestBody PageInfo pageInfo);


    /**
     * 撤回流程
     *
     * @param flowTaskPdu
     * @return
     */
    @PostMapping("/flowable/task/revokeProcess")
    ApiRespPdu<String> revokeProcess(@RequestBody FlowTaskPdu flowTaskPdu);


    /**
     * 取消申请
     *
     * @param flowTaskVoPdu
     * @return
     */
    @PostMapping("/flowable/task/stopProcess")
    ApiRespPdu<String> stopProcess(@RequestBody FlowTaskVoPdu flowTaskVoPdu);


    /**
     * 获取待办列表
     * 获取的列表需要和业务系统数据合并
     *
     * @param userId
     * @param pageInfo
     * @return
     */
    @PostMapping("/flowable/task/todoList")
    ApiRespPdu<Result<FlowTaskPdu>> todoList(@RequestParam(value = "userId") String userId,
                                             @RequestParam(value = "tenantId") String tenantId,
                                             @RequestBody PageInfo pageInfo);


    /**
     * 获取已办任务
     * 获取的列表需要和业务系统数据合并
     *
     * @param userId
     * @param pageInfo
     * @return
     */
    @PostMapping("/flowable/task/finishedList")
    ApiRespPdu<Result<FlowTaskPdu>> finishedList(@RequestParam(value = "userId") String userId,
                                                 @RequestParam(value = "tenantId") String tenantId,
                                                 @RequestBody PageInfo pageInfo);


    /**
     * 流程历史流转记录
     *
     * @param procInsId
     * @param deployId
     * @return
     */
    @PostMapping("/flowable/task/flowRecord")
    ApiRespPdu<List<FlowTaskPdu>> flowRecord(@RequestParam(required = false) String procInsId,
                                             @RequestParam(required = false) String deployId);

    /**
     * 获取流程变量
     *
     * @param taskId
     * @return
     */
    @PostMapping("/flowable/task/processVariables")
    ApiRespPdu<Map<String, Object>> processVariables(@RequestParam String taskId);


    /**
     * 审批任务
     *
     * @param flowTaskVoPdu
     * @return
     */
    @PostMapping("/flowable/task/complete")
    ApiRespPdu<String> complete(@RequestBody FlowTaskVoPdu flowTaskVoPdu);

    /**
     * 驳回任务
     *
     * @param flowTaskVoPdu
     * @return
     */
    @PostMapping("/flowable/task/reject")
    ApiRespPdu<String> reject(@RequestBody FlowTaskVoPdu flowTaskVoPdu);

    /**
     * 退回任务
     *
     * @param flowTaskVoPdu
     * @return
     */
    @PostMapping("/flowable/task/return")
    ApiRespPdu<String> taskReturn(@RequestBody FlowTaskVoPdu flowTaskVoPdu);

    /**
     * 删除任务
     *
     * @param flowTaskPdu
     * @return
     */
    @PostMapping("/flowable/task/delete")
    ApiRespPdu<String> delete(@RequestBody FlowTaskVoPdu flowTaskPdu);

    /**
     * 认领/签收任务
     *
     * @param flowTaskPdu
     * @return
     */
    @PostMapping("/flowable/task/claim")
    ApiRespPdu<String> claim(@RequestBody FlowTaskVoPdu flowTaskPdu);

    /**
     * 取消认领/签收任务
     *
     * @param flowTaskPdu
     * @return
     */
    @PostMapping("/flowable/task/unClaim")
    ApiRespPdu<String> unClaim(@RequestBody FlowTaskVoPdu flowTaskPdu);

    /**
     * 委派任务
     *
     * @param flowTaskPdu
     * @return
     */
    @PostMapping("/flowable/task/delegate")
    ApiRespPdu<String> delegateTask(@RequestBody FlowTaskVoPdu flowTaskPdu);

    /**
     * 转办任务
     *
     * @param flowTaskPdu
     * @return
     */
    @PostMapping("/flowable/task/assign")
    ApiRespPdu<String> assignTask(@RequestBody FlowTaskVoPdu flowTaskPdu);


    /**
     * 获取所有可回退的节点
     *
     * @param flowTaskVoPdu
     * @return
     */
    @PostMapping("/flowable/task/findReturnTaskList")
    ApiRespPdu<List<FlowUserTaskPdu>> findReturnTaskList(@RequestBody FlowTaskVoPdu flowTaskVoPdu);


    /**
     * 获取下一节点
     *
     * @param flowTaskVoPdu
     * @return
     */
    @PostMapping("/flowable/task/nextFlowNode")
    ApiRespPdu<FlowNextPdu> getNextFlowNode(@RequestBody FlowTaskVoPdu flowTaskVoPdu);


}

