提交 e24c88b9 authored 作者: zhoushaopan's avatar zhoushaopan

新增历史查询

上级 1210e35a
...@@ -21,6 +21,12 @@ public class ResultUtil<T> { ...@@ -21,6 +21,12 @@ public class ResultUtil<T> {
public static <T> ResponseEntity<ResultObj<T>> success(T data,String message) { public static <T> ResponseEntity<ResultObj<T>> success(T data,String message) {
return ResponseEntity.ok(new ResultObj<>(data,message)); return ResponseEntity.ok(new ResultObj<>(data,message));
} }
/**
* 成功返回结果
*/
public static <T> ResponseEntity<ResultObj<T>> success(String message) {
return ResponseEntity.ok(new ResultObj<>(message));
}
/** /**
* 成功返回结果 * 成功返回结果
......
...@@ -84,22 +84,23 @@ public class FlowsInfoController { ...@@ -84,22 +84,23 @@ public class FlowsInfoController {
@GetMapping("/deploy") @GetMapping("/deploy")
@ApiOperation(value = "部署流程",notes = "0 部署成功") @ApiOperation(value = "部署流程",notes = "0 部署成功")
public Integer deploy(Long id) throws FileNotFoundException { public ResponseEntity deploy(Long id) throws FileNotFoundException {
//根据id 查询出flowsInfo //根据id 查询出flowsInfo
FlowsInfo flowsInfo = flowInfoService.findById(id); FlowsInfo flowsInfo = flowInfoService.findById(id);
if (flowsInfo.getState() == 0){ if (flowsInfo.getState() == 0){
return 0; return ResultUtil.success(flowsInfo.getState(),"该流程已经被部署");
} }
workFlowService.deployXml(flowsInfo); workFlowService.deployXml(flowsInfo);
return flowsInfo.getState(); return ResultUtil.success(flowsInfo.getState(),"流程部署成功");
} }
@PostMapping("/saveXml02") @PostMapping("/saveXml02")
@ApiOperation(value = "保存xml02") @ApiOperation(value = "保存xml02")
public void saveXml02(@RequestBody FlowsInfoVo flowsInfoVo) { public ResponseEntity saveXml02(@RequestBody FlowsInfoVo flowsInfoVo) {
List<NodePage> nodePages = flowsInfoVo.getNodePages(); List<NodePage> nodePages = flowsInfoVo.getNodePages();
nodePageService.saveNodePages(nodePages); nodePageService.saveNodePages(nodePages);
workFlowService.flowXml(flowsInfoVo); workFlowService.flowXml(flowsInfoVo);
return ResultUtil.success("文件保存成功");
} }
@PostMapping("/updateByProcessName") @PostMapping("/updateByProcessName")
...@@ -119,15 +120,15 @@ public class FlowsInfoController { ...@@ -119,15 +120,15 @@ public class FlowsInfoController {
@PostMapping("/createFlow") @PostMapping("/createFlow")
@ApiModelProperty("创建成功") @ApiModelProperty("创建成功")
public Long createFlow(@RequestBody FlowsInfoVo flowsInfovo){ public ResponseEntity createFlow(@RequestBody FlowsInfoVo flowsInfovo){
return workFlowService.createFlow(flowsInfovo.toEntity()); return ResultUtil.success(workFlowService.createFlow(flowsInfovo.toEntity()),"流程创建成功");
} }
@PostMapping("/saveVariableStorage") @PostMapping("/saveVariableStorage")
@ApiModelProperty("保存函数调用配置") @ApiModelProperty("保存函数调用配置")
public ResponseEntity saveVariableStorage(@RequestBody VariableStorageVo variableStorageVo){ public ResponseEntity saveVariableStorage(@RequestBody VariableStorageVo variableStorageVo){
VariableStorage variableStorage = variableStorageService.saveVariableStorageService(variableStorageVo.toEntity()); VariableStorage variableStorage = variableStorageService.saveVariableStorageService(variableStorageVo.toEntity());
return ResultUtil.success(variableStorage,"保存成功"); return ResultUtil.success(variableStorage,"调用接口成功");
} }
@PostMapping("/test") @PostMapping("/test")
......
...@@ -63,8 +63,9 @@ public class FormPageController { ...@@ -63,8 +63,9 @@ public class FormPageController {
@ApiOperation("删除页面") @ApiOperation("删除页面")
@DeleteMapping("deletePage") @DeleteMapping("deletePage")
public void deletePage(Long id){ public ResponseEntity deletePage(Long id){
formPageService.deletePage(id); formPageService.deletePage(id);
return ResultUtil.success("删除页面成功");
} }
@PostMapping("/findByPages") @PostMapping("/findByPages")
......
package com.tykj.workflowcore.workflow_editer.controller; package com.tykj.workflowcore.workflow_editer.controller;
import com.tykj.workflowcore.api.entity.InvokeRequest; import com.tykj.workflowcore.api.entity.InvokeRequest;
import com.tykj.workflowcore.base.result.ResultUtil;
import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo; import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo;
import com.tykj.workflowcore.workflow_editer.service.FlowInfoService; import com.tykj.workflowcore.workflow_editer.service.FlowInfoService;
import com.tykj.workflowcore.workflow_editer.service.WorkFlowService; import com.tykj.workflowcore.workflow_editer.service.WorkFlowService;
...@@ -10,6 +11,7 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -10,6 +11,7 @@ import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.flowable.task.api.Task; import org.flowable.task.api.Task;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
...@@ -64,37 +66,40 @@ public class WorkFlowController { ...@@ -64,37 +66,40 @@ public class WorkFlowController {
@PostMapping("/findTaskDetail") @PostMapping("/findTaskDetail")
@ApiOperation("任务个人待办详情") @ApiOperation("任务个人待办详情")
public Map<String, Object> findTaskDetail(Long userId,String taskId){ public Map<String, Object> findTaskDetail(String taskId){
return workFlowService.findTaskDetail(taskId);
return workFlowService.findTaskDetail(userId, taskId);
} }
@PostMapping("/completeTask") @PostMapping("/completeTask")
@ApiOperation("完成任务") @ApiOperation("完成任务")
public void completeTask(@RequestBody TaskVo taskVo){ public ResponseEntity completeTask(@RequestBody TaskVo taskVo){
workFlowService.completeTask(taskVo); workFlowService.completeTask(taskVo);
return ResultUtil.success("该任务已完成");
} }
@PostMapping("/isTransferTask") @PostMapping("/isTransferTask")
@ApiOperation("是否转交任务") @ApiOperation("是否转交任务")
public void isTransferTask(@RequestBody TransferTask transferTask){ public ResponseEntity isTransferTask(@RequestBody TransferTask transferTask){
workFlowService.transferTask(transferTask); workFlowService.transferTask(transferTask);
return ResultUtil.success("该任务转交成功");
} }
@PostMapping("/isSuspension") @PostMapping("/isSuspension")
@ApiOperation("是否挂起") @ApiOperation("是否挂起")
public void isSuspension(@RequestBody SuspendVo suspendVo){ public ResponseEntity isSuspension(@RequestBody SuspendVo suspendVo){
workFlowService.suspendOrActivateProcessDefinitionByKey(suspendVo); workFlowService.suspendOrActivateProcessDefinitionByKey(suspendVo);
return ResultUtil.success("该流程已被挂起");
} }
@DeleteMapping("/deleteFlow") @DeleteMapping("/deleteFlow")
@ApiOperation("是否删除") @ApiOperation("是否删除")
public void deleteFlow(String deployId){ public ResponseEntity deleteFlow(String deployId){
//根据流程id查询出flowsInfo //根据流程id查询出flowsInfo
FlowsInfo flowsInfo = flowInfoService.findByDeployId(deployId); FlowsInfo flowsInfo = flowInfoService.findByDeployId(deployId);
//删除flowsInfo //删除flowsInfo
flowInfoService.deleteById(flowsInfo.getId()); flowInfoService.deleteById(flowsInfo.getId());
workFlowService.deleteFlow(deployId); workFlowService.deleteFlow(deployId);
return ResultUtil.success("该流程已被删除");
} }
@PostMapping("/flowProgress") @PostMapping("/flowProgress")
...@@ -103,4 +108,10 @@ public class WorkFlowController { ...@@ -103,4 +108,10 @@ public class WorkFlowController {
workFlowService.flowProgress(flowProcessVo.getResponse(),flowProcessVo.getProcessInstanceId()); workFlowService.flowProgress(flowProcessVo.getResponse(),flowProcessVo.getProcessInstanceId());
} }
@PostMapping("/findHistoryTask")
@ApiOperation("已办任务")
public List findHistoryTask(String userId) {
return workFlowService.findHistoryTask(userId);
}
} }
...@@ -27,4 +27,10 @@ public interface FlowsInfoMapper extends JpaRepository<FlowsInfo,Long>, JpaSpeci ...@@ -27,4 +27,10 @@ public interface FlowsInfoMapper extends JpaRepository<FlowsInfo,Long>, JpaSpeci
*/ */
FlowsInfo findByDeployId(String deployId); FlowsInfo findByDeployId(String deployId);
/**
* 根据流程实例id查询
* @param processInstanceId 流程实例id
* @return
*/
FlowsInfo findByProcessInstanceId(String processInstanceId);
} }
...@@ -76,11 +76,13 @@ public interface WorkFlowService { ...@@ -76,11 +76,13 @@ public interface WorkFlowService {
/** /**
* 查看具体的任务详情 * 查看具体的任务详情
* @param userId 用户id // * @param detailTaskVo 任务详情
* @param taskId 任务Id
* @return 任务列表 * @return 任务列表
*/ */
Map<String,Object> findTaskDetail(Long userId, String taskId); // Map<String,Object> findTaskDetail(DetailTaskVo detailTaskVo);
Map<String,Object> findTaskDetail(String taskId);
/** /**
...@@ -125,6 +127,11 @@ public interface WorkFlowService { ...@@ -125,6 +127,11 @@ public interface WorkFlowService {
*/ */
void flowProgress (HttpServletResponse httpServletResponse, String processId) throws IOException; void flowProgress (HttpServletResponse httpServletResponse, String processId) throws IOException;
/**
* 查已办任务
* @param userId 用户id
* @return 任务已办列表
*/
List<Object> findHistoryTask(String userId);
} }
...@@ -4,13 +4,11 @@ import com.alibaba.fastjson.JSONArray; ...@@ -4,13 +4,11 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.tykj.workflowcore.api.entity.InvokeRequest; import com.tykj.workflowcore.api.entity.InvokeRequest;
import com.tykj.workflowcore.api.entity.Parameter; import com.tykj.workflowcore.api.entity.Parameter;
import com.tykj.workflowcore.workflow_editer.entity.CommandGetValue; import com.tykj.workflowcore.workflow_editer.entity.*;
import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo;
import com.tykj.workflowcore.workflow_editer.entity.VariablesMap;
import com.tykj.workflowcore.workflow_editer.entity.WorkFlowUser;
import com.tykj.workflowcore.workflow_editer.mapper.FlowsInfoMapper; import com.tykj.workflowcore.workflow_editer.mapper.FlowsInfoMapper;
import com.tykj.workflowcore.workflow_editer.service.NodePageService; import com.tykj.workflowcore.workflow_editer.service.NodePageService;
import com.tykj.workflowcore.workflow_editer.service.UserService; import com.tykj.workflowcore.workflow_editer.service.UserService;
import com.tykj.workflowcore.workflow_editer.service.VariableStorageService;
import com.tykj.workflowcore.workflow_editer.service.WorkFlowService; import com.tykj.workflowcore.workflow_editer.service.WorkFlowService;
import com.tykj.workflowcore.workflow_editer.vo.*; import com.tykj.workflowcore.workflow_editer.vo.*;
import org.dom4j.Attribute; import org.dom4j.Attribute;
...@@ -30,6 +28,8 @@ import org.flowable.image.ProcessDiagramGenerator; ...@@ -30,6 +28,8 @@ import org.flowable.image.ProcessDiagramGenerator;
import org.flowable.task.api.Task; import org.flowable.task.api.Task;
import org.flowable.task.api.TaskQuery; import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstance; import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
import org.flowable.variable.api.history.HistoricVariableInstance;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -73,6 +73,9 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -73,6 +73,9 @@ public class WorkFlowServiceImpl implements WorkFlowService {
@Autowired @Autowired
private ProcessEngine processEngine; private ProcessEngine processEngine;
@Autowired
private VariableStorageService variableStorageService;
@Autowired @Autowired
ClassLoader classLoader; ClassLoader classLoader;
@Override @Override
...@@ -262,6 +265,7 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -262,6 +265,7 @@ public class WorkFlowServiceImpl implements WorkFlowService {
map.put("taskDesc",task.getDescription()); map.put("taskDesc",task.getDescription());
map.put("createTime",task.getCreateTime()); map.put("createTime",task.getCreateTime());
map.put("promoter",processInstance.getStartUserId()); map.put("promoter",processInstance.getStartUserId());
map.put("processInstanceId",processInstance.getId());
listMap.add(map); listMap.add(map);
} }
return listMap; return listMap;
...@@ -269,9 +273,18 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -269,9 +273,18 @@ public class WorkFlowServiceImpl implements WorkFlowService {
} }
@Override @Override
public Map<String, Object> findTaskDetail(Long userId, String taskId) { public Map<String, Object> findTaskDetail(String taskId) {
Map<String, Object> variables = new HashMap<>();
Map<String, Object> variables = taskService.getVariables(taskId); //流程还在运行
if (taskId != null){
variables = taskService.getVariables(taskId);
}else {
//流程已经结束
//从历史中查询
HistoricTaskInstance historicTaskInstance =
historyService.createHistoricTaskInstanceQuery().taskId(taskId).finished().singleResult();
variables.put("historicTaskInstance",historicTaskInstance);
}
return variables; return variables;
} }
...@@ -296,8 +309,16 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -296,8 +309,16 @@ public class WorkFlowServiceImpl implements WorkFlowService {
} }
if (taskVo.getTaskId() == null){ if (taskVo.getTaskId() == null){
//流程结束了 //流程结束了
//通过processInstanceId查询出flowKey
FlowsInfo flowsInfo = flowsInfoMapper.findByProcessInstanceId(processInstanceId);
List<VariableStorage> variableStorageList = variableStorageService.findByFlowKey(flowsInfo.getFlowKey());
for (VariableStorage variableStorage : variableStorageList) {
String variableInfo = variableStorage.getVariableInfo();
//调用服务接口
InvokeRequestVo invokeRequestVo = (InvokeRequestVo) JSONObject.parse(variableInfo);
getApiInvokeParam(invokeRequestVo);
}
//保存调用接口
} }
...@@ -377,6 +398,15 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -377,6 +398,15 @@ public class WorkFlowServiceImpl implements WorkFlowService {
} }
@Override
public List<Object> findHistoryTask(String userId) {
List<HistoricTaskInstance> taskInstanceList =
historyService.createHistoricTaskInstanceQuery().taskAssignee(userId).finished().list();
ArrayList<Object> arrayList = new ArrayList<>();
arrayList.addAll(taskInstanceList);
return arrayList;
}
/** /**
* 获取调用Api用的参数 * 获取调用Api用的参数
* @param invokeRequestVo 调用服务接口vo * @param invokeRequestVo 调用服务接口vo
......
...@@ -27,13 +27,12 @@ public class InvokeRequestVo { ...@@ -27,13 +27,12 @@ public class InvokeRequestVo {
@ApiModelProperty("流程实例id") @ApiModelProperty("流程实例id")
private String processInstanceId; private String processInstanceId;
@ApiModelProperty("类名") @ApiModelProperty("类名")
private String className; private String className;
@ApiModelProperty("方法名") @ApiModelProperty("方法名")
private String name; private String name;
@ApiModelProperty("参数列表")
private List<Parameter> parameterList; private List<Parameter> parameterList;
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论