package com.unis.flowable.client;

import com.unis.common.utils.ResponseWrapper;
import com.unis.flowable.common.vo.CompleteGroupVO;
import com.unis.flowable.common.vo.FlowAbleCompleteVO;
import com.unis.flowable.common.vo.FlowTodoVO;
import com.unis.flowable.common.vo.StartNewTaskVO;
import com.unis.flowable.common.vo.VariableObject;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import java.util.HashMap;
import java.util.Map;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther:张新亮
 * @Date: 2019/7/12 0012 15:00
 * @Description:
 */
@FeignClient(name = "flowable-server")
@Component
public interface FlowAbleClient {


    /**
     *  启动工作流

     */
    @RequestMapping(method = RequestMethod.POST, value = "/task/start")
    ResponseWrapper start(@RequestBody StartNewTaskVO startNewTaskVO);


    /**
     *  查询待办个人任务和组任务合并列表---不分页
     * @param userId
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/task/findByUserAndGroupTaskNoPage")
    ResponseWrapper findByUserAndGroupTaskNoPage(@RequestParam(value = "userId") String userId,@RequestParam(value = "areaCode") String areaCode);


    /**
     *  个人任务审批
     * @returna
     */
    @RequestMapping(method = RequestMethod.POST, value = "/task/complete")
    ResponseWrapper complete(@RequestBody FlowAbleCompleteVO completeVO);


    /**
     * 组任务审核
     * @returna
     */
    @RequestMapping(method = RequestMethod.POST, value = "/task/completeGroup")
    ResponseWrapper completeGroup(@RequestBody CompleteGroupVO completeGroupVO);


    /**
     * 添加流程变量
     * @param values  添加流程变量
     * @param processId  流程ID
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/task/setVariableByTask")
    ResponseWrapper setVariableByTask(
            @RequestParam(value = "values") String values,
            @RequestParam(value = "processId") String processId

    );


    /**
     * 根据任务ID -- 查询待办 任务明细
     * @param taskId
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/task/findByFormKeyByTaskId/{taskId}/{procInsId}")
    ResponseWrapper findByFormKeyByTaskId(@PathVariable(value = "taskId") String taskId, @PathVariable(value = "procInsId") String procInsId);

    /**
     * 根据任务ID -- 查询办理任务明细
     * @param taskId
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/task/findByAlreadyDone/{taskId}/{procInsId}")
    ResponseWrapper findByAlreadyDone(@PathVariable(value = "taskId") String taskId, @PathVariable(value = "procInsId") String procInsId);


    /**
     *  获取已办列表---不分页
     * @param userId
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/task/findByAlreadyDoneoPage")
    ResponseWrapper findByAlreadyDoneoPage(@RequestParam(value = "userId") String userId);



    /**
     *  查询企业待办任务 列表
     * @param userId 用户ID
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/task/getUserTaskNoPage")
    ResponseWrapper getUserTaskNoPage(@RequestParam(value = "userId") String userId);


    /**
     * 拾取任务，将组任务分给个人任务
     * @param taskId 任务ID
     * @param userId 用户
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/task/claim")
    ResponseWrapper claim(@RequestParam(value = "taskId") String taskId, @RequestParam(value = "userId") String userId);


    /**
     *  生成流图 返回base64 编码
     * @param processId 流程ID
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/process/findByLcslImage/{processId}")
    ResponseWrapper findByLcslImage(@PathVariable(value = "processId") String processId);


    /**
     * 获取流程审批历史
     * @param processId   流程ID
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/task/findByProcessInfo")
    ResponseWrapper findByProcessInfo(@RequestParam(value = "processId") String processId);
    
    
    @RequestMapping(value="/task/processInfo", method=RequestMethod.GET)
	@ApiOperation(value="获取流程审批历史", notes = "审批历史信息")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "processId", value = "流程id", paramType = "query"),
	})
	public ResponseWrapper  processInfo(@RequestParam(value = "processId") String processId);


    @RequestMapping(value = "/task/variable", method = RequestMethod.POST)
	@ApiOperation(value="添加流程变量", notes = "添加流程变量")

	public  ResponseWrapper variable(@RequestBody VariableObject variableObject);
	
	
	
	@RequestMapping(value = "/task/variable", method = RequestMethod.GET)
	@ApiOperation(value="获取流程变量", notes = "获取流程变量")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "value", value = "变量 key键", paramType = "query"),
			@ApiImplicitParam(name = "processId", value = "流程ID", paramType = "query")

	})
	public  ResponseWrapper getVariableByTask(@PathVariable("value") String value,@PathVariable("processId") String processId);
	
	
	@RequestMapping(value = "/task/{bussinessId}", method = RequestMethod.GET)
	@ApiOperation(value="根据业务信息查询审批历史", notes = "根据业务信息查询审批历史")
	/*@ApiImplicitParams({
		@ApiImplicitParam(name = "bussinessId", value = "业务id（业务类型+数据id组成，TEST:001）", paramType = "query")
	})*/
	public ResponseWrapper bussinessId(@PathVariable("bussinessId") String bussinessId);
	
	
	
	@RequestMapping(value = "/task/completeTask", method = RequestMethod.POST)
	@ApiOperation(value="审批", notes = "审批（流程id与业务信息必传一个）")
	public  ResponseWrapper complete(
			@RequestBody FlowTodoVO completeVO
	);
	
	@RequestMapping(value = "/task/variableByBusiness", method = RequestMethod.GET)
	@ApiOperation(value="获取流程变量", notes = "获取流程变量")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "value", value = "变量 key键", paramType = "query"),
			@ApiImplicitParam(name = "bussinessId", value = "业务id（业务类型+数据id组成，TEST:001）", paramType = "query")

	})
	public  ResponseWrapper getVariableByBusiness(@PathVariable("value") String value,@PathVariable("bussinessId") String bussinessId);
	
	
	@RequestMapping(value = "/task/taskInfo/{userId}/{bussinessId}", method = RequestMethod.POST)
	@ApiOperation(value="根据用户i", notes = "根据业务信息查询审批历史")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "bussinessId", value = "业务id（业务类型+数据id组成，TEST:001）", paramType = "query"),
		@ApiImplicitParam(name = "userId", value = "用户id", paramType = "query"),
	})
	public ResponseWrapper taskInfo(@PathVariable("userId") String userId,@PathVariable("bussinessId") String bussinessId);
	
	@RequestMapping(value = "/task/taskInfos/{userId}/{bussinessId}", method = RequestMethod.POST)
	@ApiOperation(value="根据用户i", notes = "根据业务信息查询审批历史")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "bussinessId", value = "业务id（业务类型+数据id组成，TEST:001）", paramType = "query"),
		@ApiImplicitParam(name = "userId", value = "用户id", paramType = "query"),
	})
	public ResponseWrapper taskInfos(@PathVariable("userId") String userId,@PathVariable("bussinessId") String bussinessId);
}