package com.jeeplus.flowable.feign;

import com.jeeplus.common.constant.AppNameConstants;
import com.jeeplus.flowable.factory.FlowableApiFallbackFactory;
import org.flowable.bpmn.model.FlowNode;
//import org.flowable.task.api.Task;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
//import org.flowable.task.api.Task;

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


@FeignClient(contextId = "flowableApi", name = AppNameConstants.APP_FLOWABLE_SERVICE, fallbackFactory = FlowableApiFallbackFactory.class)
public interface IFlowableApi {

    @RequestMapping(value = "/flowable/task/historicTaskList3", method = RequestMethod.POST)
    Map historicTaskList3(@RequestParam(value = "procInsId")String procInsId);

    @RequestMapping(value = "/flowable/task/historicTaskList2", method = RequestMethod.POST)
    Map historicTaskList2(@RequestParam(value = "procInsId")String procInsId);

    /**
     * 根据通知信息查询数据
     * @param map
     * @return
     */
    @RequestMapping(value = "/flowable/task/insertMyNotice2", method = RequestMethod.POST)
    void insertMyNotice(@RequestBody Map<String ,String > map);

    /**
     * 根据通知信息查询数据
     * @param map
     * @return
     */
    @RequestMapping(value = "/flowable/task/updateMyNotice2", method = RequestMethod.POST)
    void updateMyNotice(@RequestBody Map<String ,String > map);

    /**
     * 根据通知信息查询数据
     * @param map
     * @return
     */
    @RequestMapping(value = "/flowable/task/getRepetitionCountBymyNoticeTitle", method = RequestMethod.POST)
    String getRepetitionCountBymyNoticeTitle(@RequestBody Map<String ,String > map);

    /**
     * 发送通知
     */
    @RequestMapping(value = "/flowable/task/add", method = RequestMethod.POST)
    String add(@RequestBody Map<String ,String > map);

    /**
     * 已经签收或者等待签收的任务
     * @param map
     * @return
     */
    @RequestMapping(value = "/flowable/task/taskDispose", method = RequestMethod.POST)
    String taskDispose(@RequestBody Map<String ,String > map);

    /**
     * 根据processInstanceId获取taskId
     * @param processInstanceId
     * @return
     */
    @GetMapping(value = "/flowable/task/getCurrentTask")
    FlowNode getCurrentTask(@RequestParam(value = "processInstanceId") String processInstanceId);

    /**
     * 根据procInsId获取taskId
     * @param procInsId
     * @return
     */
    @GetMapping(value = "/flowable/task/getTaskIdByprocInstId")
    String getTaskIdByprocInstId(@RequestParam(value = "procInsId") String procInsId);

    /**
     * 获取当前节点审核人
     * @param taskId
     * @return
     */
    @GetMapping(value = "/flowable/task/getTaskAuditUsers")
    List <String> getTaskAuditUsers(@RequestParam(value = "taskId") String taskId);

    /**
     * 获取当前节点名称
     * @param processInstanceId
     * @return
     */
    @GetMapping(value = "/flowable/task/getCurrentTaskName")
    String getCurrentTaskName(@RequestParam(value = "processInstanceId") String processInstanceId);

    /**
     * 审核通过或驳回
     */
    @GetMapping(value = "/flowable/task/auditByProcInsIdAndFlag")
    void auditByProcInsIdAndFlag(@RequestParam(value = "procInsId")String procInsId,@RequestParam(value = "flag")String flag,
                                 @RequestParam(value = "assignee")String assignee,@RequestParam(value = "comm")String comm);

    /**
     * 检查是否为最后一个审核节点
     */
    @GetMapping(value = "/flowable/task/checkIsLastTask")
    boolean checkIsLastTask(@RequestParam(value = "procInsId")String procInsId);
}
