提交 74d33fab authored 作者: ww1xhqc's avatar ww1xhqc

Merge remote-tracking branch 'origin/master'

...@@ -11,12 +11,9 @@ import com.tykj.workflowcore.base.util.ClassUtil; ...@@ -11,12 +11,9 @@ import com.tykj.workflowcore.base.util.ClassUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.URL;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -40,14 +37,6 @@ public class ApiService { ...@@ -40,14 +37,6 @@ public class ApiService {
* @return 结构化列表数据,内容为带有指定注解的方法列表,也就是列出主项目中可调用的方法。 * @return 结构化列表数据,内容为带有指定注解的方法列表,也就是列出主项目中可调用的方法。
*/ */
public List<ClassInfo> findAll() { public List<ClassInfo> findAll() {
List<ClassInfo> classInfos = load();
for (ClassInfo classInfo : classInfos) {
System.out.println(classInfo);
}
return classInfos;
}
private List<ClassInfo> load() {
//获取所有类 //获取所有类
List<Class<?>> classes = ClassUtil.loadClassByLoader(getClass().getClassLoader()); List<Class<?>> classes = ClassUtil.loadClassByLoader(getClass().getClassLoader());
return classes.stream() return classes.stream()
......
package com.tykj.workflowcore.workflow_editer.controller; package com.tykj.workflowcore.workflow_editer.controller;
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.entity.NodePage; import com.tykj.workflowcore.workflow_editer.entity.NodePage;
import com.tykj.workflowcore.workflow_editer.entity.WorkFlowUser; import com.tykj.workflowcore.workflow_editer.entity.WorkFlowUser;
...@@ -8,10 +9,12 @@ import com.tykj.workflowcore.workflow_editer.vo.DeployedVo; ...@@ -8,10 +9,12 @@ import com.tykj.workflowcore.workflow_editer.vo.DeployedVo;
import com.tykj.workflowcore.workflow_editer.vo.FlowsInfoVo; import com.tykj.workflowcore.workflow_editer.vo.FlowsInfoVo;
import com.tykj.workflowcore.workflow_editer.vo.PageVo; import com.tykj.workflowcore.workflow_editer.vo.PageVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
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.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -106,17 +109,21 @@ public class FlowsInfoController { ...@@ -106,17 +109,21 @@ public class FlowsInfoController {
@PostMapping("/updateByProcessName") @PostMapping("/updateByProcessName")
@ApiOperation(value = "通过流程名称修改") @ApiOperation(value = "通过流程名称修改")
public void updateByProcessName(@RequestBody FlowsInfoVo flowsInfoVo) { public ResponseEntity updateByProcessName(@RequestBody FlowsInfoVo flowsInfoVo) {
flowInfoService.findByFlowName(flowsInfoVo); FlowsInfo flowsInfo = flowInfoService.findByFlowName(flowsInfoVo);
return ResultUtil.success(flowsInfo.getFlowName(),"流程修改成功");
} }
@PostMapping("/updateByDesc") @PostMapping("/updateByDesc")
@ApiOperation(value = "通过流程描述修改") @ApiOperation(value = "通过流程描述修改")
public void updateByDesc(@RequestBody FlowsInfoVo flowsInfoVo) { public ResponseEntity updateByDesc(@RequestBody FlowsInfoVo flowsInfoVo) {
flowInfoService.findByDesc(flowsInfoVo);
FlowsInfo flowsInfo = flowInfoService.findByDesc(flowsInfoVo);
return ResultUtil.success(flowsInfo.getFlowDescribe(),"流程修改成功");
} }
@PostMapping("/createFlow") @PostMapping("/createFlow")
@ApiModelProperty("创建成功")
public Long createFlow(@RequestBody FlowsInfoVo flowsInfovo){ public Long createFlow(@RequestBody FlowsInfoVo flowsInfovo){
return workFlowService.createFlow(flowsInfovo.toEntity()); return workFlowService.createFlow(flowsInfovo.toEntity());
} }
......
...@@ -32,6 +32,7 @@ public class FormPageController { ...@@ -32,6 +32,7 @@ public class FormPageController {
@Autowired @Autowired
private FormPageService formPageService; private FormPageService formPageService;
// @Autowired // @Autowired
// private PageEntityService pageEntityService; // private PageEntityService pageEntityService;
......
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.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;
import com.tykj.workflowcore.workflow_editer.util.PageUtil; import com.tykj.workflowcore.workflow_editer.util.PageUtil;
import com.tykj.workflowcore.workflow_editer.vo.*; import com.tykj.workflowcore.workflow_editer.vo.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
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.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -100,4 +103,16 @@ public class WorkFlowController { ...@@ -100,4 +103,16 @@ public class WorkFlowController {
flowInfoService.deleteById(flowsInfo.getId()); flowInfoService.deleteById(flowsInfo.getId());
workFlowService.deleteFlow(deployId); workFlowService.deleteFlow(deployId);
} }
@PostMapping("/flowProgress")
@ApiOperation("流程进度")
public void flowProgress(@RequestBody FlowProcessVo flowProcessVo) throws IOException {
workFlowService.flowProgress(flowProcessVo.getResponse(),flowProcessVo.getProcessInstanceId());
}
@PostMapping("getInvokeRequest")
@ApiOperation("调用服务接口")
public InvokeRequest getInvokeRequest(@RequestBody InvokeRequestVo invokeRequestVo) throws IOException {
return workFlowService.saveInvokeRequest(invokeRequestVo);
}
} }
...@@ -65,6 +65,9 @@ public class FlowsInfo { ...@@ -65,6 +65,9 @@ public class FlowsInfo {
@ApiModelProperty("开始节点的id") @ApiModelProperty("开始节点的id")
private String startId; private String startId;
@ApiModelProperty("流程实例id")
private String processInstanceId;
/** /**
* @Description: * @Description:
* @params: 部署id * @params: 部署id
......
package com.tykj.workflowcore.workflow_editer.entity;
import org.flowable.common.engine.api.delegate.Expression;
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
import org.flowable.engine.impl.persistence.entity.ExecutionEntityManager;
import org.flowable.engine.impl.util.CommandContextUtil;
/**
* ClassName: VariablesMap
* Package: com.example.flowable.expense.controller
* Description:
* Datetime: 2021/3/10 19:08
*
* @Author: zsp
*/
public class VariablesMap implements Command<Object> {
private String processInstanceId;
private Expression expression;
public VariablesMap(String processInstanceId, Expression expression) {
this.processInstanceId = processInstanceId;
this.expression = expression;
}
@Override
public Object execute(CommandContext commandContext) {
ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager();
ExecutionEntity executionEntity =
executionEntityManager.findChildExecutionsByProcessInstanceId(processInstanceId).get(0);
return expression.getValue(executionEntity);
}
}
...@@ -64,4 +64,11 @@ public interface FlowInfoService { ...@@ -64,4 +64,11 @@ public interface FlowInfoService {
*/ */
void deleteById(Long id); void deleteById(Long id);
/**
* 根据流程主键查询
* @param flowKey 流程主键
* @return flowsInfo 对象
*/
FlowsInfo findByFlowKey(String flowKey);
} }
package com.tykj.workflowcore.workflow_editer.service; package com.tykj.workflowcore.workflow_editer.service;
import com.tykj.workflowcore.api.entity.InvokeRequest;
import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo; import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo;
import com.tykj.workflowcore.workflow_editer.vo.*; import com.tykj.workflowcore.workflow_editer.vo.*;
import org.flowable.task.api.Task; import org.flowable.task.api.Task;
...@@ -7,7 +8,9 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -7,7 +8,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -113,5 +116,20 @@ public interface WorkFlowService { ...@@ -113,5 +116,20 @@ public interface WorkFlowService {
* @param deployId 部署id * @param deployId 部署id
*/ */
void deleteFlow(String deployId); void deleteFlow(String deployId);
/**
* 流程的进度
* @param httpServletResponse
* @param processId 流程实例id
*/
void flowProgress (HttpServletResponse httpServletResponse, String processId) throws IOException;
/**
* 调用服务接口vo
* @param invokeRequestVo 调用服务接口vo
* @return 调用服务接口实体
*/
InvokeRequest saveInvokeRequest(InvokeRequestVo invokeRequestVo);
} }
...@@ -84,4 +84,9 @@ public class FlowInfoServiceImpl implements FlowInfoService { ...@@ -84,4 +84,9 @@ public class FlowInfoServiceImpl implements FlowInfoService {
public void deleteById(Long id) { public void deleteById(Long id) {
flowsInfoMapper.deleteById(id); flowsInfoMapper.deleteById(id);
} }
@Override
public FlowsInfo findByFlowKey(String flowKey) {
return flowsInfoMapper.findByFlowKey(flowKey);
}
} }
package com.tykj.workflowcore.workflow_editer.service.impl; package com.tykj.workflowcore.workflow_editer.service.impl;
import com.tykj.workflowcore.api.entity.InvokeRequest;
import com.tykj.workflowcore.api.entity.Parameter;
import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo; 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.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;
...@@ -12,13 +15,15 @@ import org.dom4j.Document; ...@@ -12,13 +15,15 @@ import org.dom4j.Document;
import org.dom4j.DocumentException; import org.dom4j.DocumentException;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.io.SAXReader; import org.dom4j.io.SAXReader;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.common.engine.api.delegate.Expression;
import org.flowable.common.engine.impl.identity.Authentication; import org.flowable.common.engine.impl.identity.Authentication;
import org.flowable.engine.HistoryService; import org.flowable.engine.*;
import org.flowable.engine.RepositoryService; import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.repository.Deployment; import org.flowable.engine.repository.Deployment;
import org.flowable.engine.runtime.Execution;
import org.flowable.engine.runtime.ProcessInstance; import org.flowable.engine.runtime.ProcessInstance;
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;
...@@ -29,6 +34,7 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -29,6 +34,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
...@@ -58,6 +64,11 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -58,6 +64,11 @@ public class WorkFlowServiceImpl implements WorkFlowService {
@Autowired @Autowired
private NodePageService nodePageService; private NodePageService nodePageService;
@Autowired
ProcessEngineConfigurationImpl processEngineConfiguration;
@Autowired
private ProcessEngine processEngine;
@Autowired @Autowired
ClassLoader classLoader; ClassLoader classLoader;
@Override @Override
...@@ -217,10 +228,13 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -217,10 +228,13 @@ public class WorkFlowServiceImpl implements WorkFlowService {
Authentication.setAuthenticatedUserId(currentUser.getId()+""); Authentication.setAuthenticatedUserId(currentUser.getId()+"");
runtimeService.startProcessInstanceByKey(startFlowVo.getFlowKey(), startFlowVo.getMap()); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(startFlowVo.getFlowKey(),
startFlowVo.getMap());
//存储流程实例id
//根据flowKey查询出一个FlowInfo
FlowsInfo flowsInfo = flowsInfoMapper.findByFlowKey(startFlowVo.getFlowKey());
flowsInfo.setProcessInstanceId(processInstance.getProcessInstanceId());
flowsInfoMapper.save(flowsInfo);
} }
...@@ -276,6 +290,10 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -276,6 +290,10 @@ public class WorkFlowServiceImpl implements WorkFlowService {
claimTask(task.getId(),userService.getCurrentUser().getId()); claimTask(task.getId(),userService.getCurrentUser().getId());
taskService.complete(task.getId(),map); taskService.complete(task.getId(),map);
} }
if (taskVo.getTaskId() == null){
//流程结束了
//保存调用接口
}
} }
...@@ -305,6 +323,92 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -305,6 +323,92 @@ public class WorkFlowServiceImpl implements WorkFlowService {
repositoryService.deleteDeployment(deployId); repositoryService.deleteDeployment(deployId);
} }
@Override
public void flowProgress(HttpServletResponse httpServletResponse, String processId) throws IOException {
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processId).singleResult();
//流程走完的不显示图
if (pi == null) {
return;
}
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
//使用流程实例ID,查询正在执行的执行对象表,返回流程实例对象
String processInstanceId = task.getProcessInstanceId();
List<Execution> executions = runtimeService
.createExecutionQuery()
.processInstanceId(processInstanceId)
.list();
//得到正在执行的Activity的Id
List<String> activityIds = new ArrayList<>();
List<String> flows = new ArrayList<>();
for (Execution exe : executions) {
List<String> ids = runtimeService.getActiveActivityIds(exe.getId());
activityIds.addAll(ids);
}
//获取流程图
BpmnModel bpmnModel = repositoryService.getBpmnModel(pi.getProcessDefinitionId());
ProcessEngineConfiguration engconf = processEngine.getProcessEngineConfiguration();
ProcessDiagramGenerator diagramGenerator = engconf.getProcessDiagramGenerator();
InputStream in = diagramGenerator.generateDiagram(bpmnModel, "png", activityIds, flows, engconf.getActivityFontName(), engconf.getLabelFontName(),engconf.getAnnotationFontName(),engconf.getClassLoader(),1.0,true);
OutputStream out = null;
byte[] buf = new byte[1024];
int legth = 0;
try {
out = httpServletResponse.getOutputStream();
while ((legth = in.read(buf)) != -1) {
out.write(buf, 0, legth);
}
} finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
}
@Override
public InvokeRequest saveInvokeRequest(InvokeRequestVo invokeRequestVo) {
//取出变量池的值
Expression expression = processEngineConfiguration.getExpressionManager().createExpression(invokeRequestVo.getExp());
ManagementService managementService = processEngine.getManagementService();
VariablesMap variablesMap = new VariablesMap(invokeRequestVo.getProcessInstanceId(),expression);
Object o = managementService.executeCommand(variablesMap);
Map<String, Object> map = new HashMap<>();
if (o instanceof Map){
//如果是对象
map = (Map<String, Object>) o;
}else {
//如果是字段
map.put("o",o);
}
//构建InvokeRequest
InvokeRequest invokeRequest = new InvokeRequest();
// invokeRequest.setClassName("com.tykj.www");
// invokeRequest.setName("add");
invokeRequest.setClassName(invokeRequestVo.getClassName());
invokeRequest.setName(invokeRequestVo.getName());
// Parameter parameter = new Parameter();
// parameter.setClassName("expense");
List<Parameter> parameterList = invokeRequestVo.getParameterList();
Parameter parameter = new Parameter();
parameter.setInstance(map);
parameterList.add(parameter);
invokeRequest.setParams(parameterList);
return invokeRequest;
}
@Override @Override
public Map<String,Object> setVariables(@RequestBody Map<String,Object> maxMap) { public Map<String,Object> setVariables(@RequestBody Map<String,Object> maxMap) {
......
package com.tykj.workflowcore.workflow_editer.vo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.servlet.http.HttpServletResponse;
/**
* ClassName: FlowProcessVo
* Package: com.tykj.workflowcore.workflow_editer.vo
* Description:
* Datetime: 2021/3/10 9:59
*
* @Author: zsp
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Api("流程进度")
public class FlowProcessVo {
@ApiModelProperty
private HttpServletResponse response;
@ApiModelProperty("流程实例Id")
private String processInstanceId;
}
package com.tykj.workflowcore.workflow_editer.vo;
import com.tykj.workflowcore.api.entity.InvokeRequest;
import com.tykj.workflowcore.api.entity.Parameter;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* ClassName: InvokeRequestVo
* Package: com.tykj.workflowcore.workflow_editer.vo
* Description:
* Datetime: 2021/3/10 20:17
*
* @Author: zsp
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Api(tags = "调用服务接口vo")
public class InvokeRequestVo {
@ApiModelProperty("流程实例id")
private String processInstanceId;
@ApiModelProperty("流程表达式")
private String exp;
@ApiModelProperty("类名")
private String className;
@ApiModelProperty("方法名")
private String name;
private List<Parameter> parameterList;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论