package com.leanwo.activiti.service.base.impl;

import java.util.List;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.leanwo.activiti.dto.BaseObjectResponse;
import com.leanwo.activiti.dto.BaseResponse;
import com.leanwo.activiti.dto.ProcessReportResultResponse;
import com.leanwo.activiti.dto.base.DocumentInfoDto;
import com.leanwo.activiti.dto.base.GroupDto;
import com.leanwo.activiti.dto.base.GroupUsersDto;
import com.leanwo.activiti.dto.base.LeaderUserDto;
import com.leanwo.activiti.dto.base.NodeApprovedRequest;
import com.leanwo.activiti.dto.base.NodeApprovedResponse;
import com.leanwo.activiti.dto.base.TaskCreateEmailDto;
import com.leanwo.activiti.dto.base.TaskDefineDto;
import com.leanwo.activiti.dto.base.TaskInstanceSaveRequest;
import com.leanwo.activiti.dto.base.TaskInstanceUpdateRequest;
import com.leanwo.activiti.dto.base.TaskType;
import com.leanwo.activiti.dto.base.UserDto;
import com.leanwo.activiti.dto.base.UserReadDocumentSimpleDto;
import com.leanwo.activiti.dto.base.WorkrecordDto;

/**
 * Prodog服务器
 * 
 * @author YangZhiJie
 *
 */
@Service
@FeignClient(value = "prodog-server", fallback = ProdogServerImpl.class, configuration = {
		KeepErrMsgConfiguration.class })
public interface ProdogServer {

	/**
	 * 获取Prodog系统中数据库版本
	 * 
	 * @return
	 */
	@RequestMapping(value = "/api/dbTimeStampResource", method = RequestMethod.GET)
	byte[] getProdogDbVersion();

	/**
	 * 审批单据
	 * 
	 * @param documentInfoDto
	 */
	@RequestMapping(value = "/api/documentResource/approve", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
	void approveDocument(@RequestBody DocumentInfoDto documentInfoDto);

	/**
	 * 拒绝单据
	 * 
	 * @param documentInfoDto
	 */
	@RequestMapping(value = "/api/documentResource/reject", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
	void rejectDocument(@RequestBody DocumentInfoDto documentInfoDto);

	/**
	 * 撤销单据
	 * 
	 * @param documentInfoDto
	 */
	@RequestMapping(value = "/api/documentResource/withdraw", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
	void withdrawDocument(@RequestBody DocumentInfoDto documentInfoDto);

	/**
	 * 获取所有的用户组 用于与工作路服务器之间进行数据交互
	 * 
	 * @return
	 */
	@RequestMapping(value = "/api/groupResource/list", method = RequestMethod.POST, consumes = "application/x-www-form-urlencoded", produces = "application/json")
	GroupDto[] listGroup(@RequestParam("ufts") String ufts);

	/**
	 * 获取所有的用户组 用于与工作路服务器之间进行数据交互
	 * 
	 * @return
	 */
	@RequestMapping(value = "/api/groupUserResource/listGroupUsers", method = RequestMethod.POST, consumes = "application/x-www-form-urlencoded", produces = "application/json")
	GroupUsersDto[] listGroupUsers(@RequestParam("ufts") String ufts);

	/**
	 * 查询流程报表定时执行定义
	 * 
	 * @return 流程报表定时执行定义集合
	 * @author YangZhiJie 20190329
	 */
	@RequestMapping(value = "/api/TaskDefineResource/list", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
	List<TaskDefineDto> listTaskDefine(@RequestBody TaskType taskType);

	/**
	 * 自动运行流程和报表
	 * 
	 * @param ProcessReportExecutorDto
	 *            流程报表自动执行DTO.
	 * @return 是否运行成功
	 * @author YangZhiJie 20190329
	 */
	@RequestMapping(value = "/api/ProcessReportResource/autoRun", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
	ProcessReportResultResponse autoRunProcessReport(@RequestParam("accountId") Long accountId, @RequestBody TaskDefineDto taskDefineDto);

	/**
	 * 查询所有用户 用于工作流服务器之间的数据交互
	 * 
	 * @return
	 */
	@RequestMapping(value = "/api/userResource/listUser", method = RequestMethod.POST, consumes = "application/x-www-form-urlencoded", produces = "application/json")
	UserDto[] listUser(@RequestParam("ufts") String ufts);

	/**
	 * 生成待办任务
	 * 
	 * @param workRecordMessageDto
	 * @return recordId
	 * @author shenchong 2020-09-08 11:00:15
	 * @author YangZhiJie 2021-02-02
	 */
	@RequestMapping(value = "/api/dingTalkResource/createWorkrecord", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
	String createWorkrecord(@RequestBody WorkrecordDto workrecordDto);

	/**
	 * 更新待办任务
	 * 
	 * @param userIds
	 * @return
	 * @author shenchong 2020-09-08 11:15:55
	 * @author YangZhiJie 2021-02-02
	 */
	@RequestMapping(value = "/api/dingTalkResource/updateWorkrecord", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
	Boolean updateWorkrecord(@RequestBody WorkrecordDto workrecordDto);

	/**
	 * 根据用户组编号查询用户
	 * 
	 * @author shenchong 2020-11-04 10:41:08
	 * @param userIds
	 * @return
	 */
	@RequestMapping(value = "/api/userResource/listUserIdByGroupIds", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
	List<Long> listUserIdByGroupIds(@RequestBody List<Long> groupId);

	/**
	 * 根据用户id，查询用户的主管领导
	 * 
	 * @param userId
	 *            用户id
	 * @return 用户的主管领导集合
	 * @author YangZhiJie 2021-01-22
	 */
	@RequestMapping(value = "/api/userResource/listLeaderUser", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
	List<LeaderUserDto> listLeaderUser(@RequestParam("userId") Long userId);

	/**
	 * 根据部门Id集合，查询部门的主管领导
	 * 
	 * @param userId
	 *            用户id
	 * @return 用户的主管领导集合
	 * @author YangZhiJie 2021-01-22
	 */
	@RequestMapping(value = "/api/userResource/listLeaderUserByOrganizationIds", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
	List<LeaderUserDto> listLeaderUserByOrganizationIds(@RequestBody List<Long> organizationIds);

	/**
	 * 根据userReadDocumentSimpleDto生成待审阅单据
	 * 
	 * @param userReadDocumentSimpleDto
	 */
	@RequestMapping(value = "/api/UserReadDocumentResource/saveByUserReadDocumentSimpleDto", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
	void saveByUserReadDocumentSimpleDto(@RequestBody UserReadDocumentSimpleDto userReadDocumentSimpleDto);

	@RequestMapping(value = "/api/documentResource/afterNodeApproved", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
	NodeApprovedResponse afterNodeApproved(NodeApprovedRequest nodeApprovedRequest);

	/**
	 * 创建邮件消息
	 * 
	 * @param emailDto
	 * @return
	 * @author GuoZhiBo 20211119
	 */
	@RequestMapping(value = "/api/EmailResource/createEmailByTask", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
	String createEmailByTask(@RequestBody TaskCreateEmailDto emailDto);

	/**
	 * 生成流程实例
	 * 
	 * @param emailDto
	 * @return
	 * @author GuoZhiBo 20211119
	 */
	@RequestMapping(value = "/api/TaskInstanceResource/saveTaskInstance", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
	BaseResponse addTaskInstance(@RequestBody TaskInstanceSaveRequest taskInstanceSaveRequest);

	/**
	 * 更新流程实例
	 * 
	 * @param emailDto
	 * @return
	 * @author GuoZhiBo 20211119
	 */
	@RequestMapping(value = "/api/TaskInstanceResource/updateTaskInstance", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
	BaseResponse updateTaskInstance(@RequestBody TaskInstanceUpdateRequest taskInstanceUpdateRequest);
	
	
	

	/**
	 * 标签核对单生成报表
	 * @param assetLabelPrintCheckId 标签核对单Id
	 */
	@RequestMapping(value = "/api/AssetLabelPrintCheckResource/generateReport", method = RequestMethod.GET, produces = "application/json")
	BaseObjectResponse<String> generateReport(@RequestParam(value = "assetLabelPrintCheckId") Long assetLabelPrintCheckId);
	
}
