提交 79825b99 authored 作者: zhoushaopan's avatar zhoushaopan

[工作流模块] 新增了一个查询可发起流程

上级 8a3081aa
...@@ -16,6 +16,7 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -16,6 +16,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamException;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException;
/** /**
...@@ -73,7 +74,7 @@ public class FlowsInfoController { ...@@ -73,7 +74,7 @@ public class FlowsInfoController {
@PostMapping("/saveXml") @PostMapping("/saveXml")
@ApiOperation(value = "保存xml以及其他流程信息") @ApiOperation(value = "保存xml以及其他流程信息")
public ResponseEntity saveXml(@RequestBody FlowsInfoVo flowsInfoVo) throws FileNotFoundException, XMLStreamException { public ResponseEntity saveXml(@RequestBody FlowsInfoVo flowsInfoVo) throws IOException, XMLStreamException {
//保存节点信息 //保存节点信息
nodeInfoService.saveNodeInfoList(flowsInfoVo.getNodeInfoList()); nodeInfoService.saveNodeInfoList(flowsInfoVo.getNodeInfoList());
//保存xml信息 //保存xml信息
......
...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -38,6 +39,13 @@ public class WorkFlowController { ...@@ -38,6 +39,13 @@ public class WorkFlowController {
return ResultUtil.success("流程开启成功"); return ResultUtil.success("流程开启成功");
} }
@GetMapping("/deployFlow")
@ApiOperation("部署流程")
public ResponseEntity deployFlow(Integer id) throws FileNotFoundException {
workFlowService.deployXml(id);
return ResultUtil.success("流程部署成功");
}
@PostMapping("/findUserTask") @PostMapping("/findUserTask")
@ApiOperation("任务个人待办列表") @ApiOperation("任务个人待办列表")
public List<Map<String,Object>> findUserTask(@RequestBody NextTaskVo nextTaskVo){ public List<Map<String,Object>> findUserTask(@RequestBody NextTaskVo nextTaskVo){
......
...@@ -66,6 +66,9 @@ public class FlowsInfo extends BaseEntity { ...@@ -66,6 +66,9 @@ public class FlowsInfo extends BaseEntity {
@ApiModelProperty("流程实例id") @ApiModelProperty("流程实例id")
private String processInstanceId; private String processInstanceId;
@ApiModelProperty("是否和之前一样 0是一样 1不一样")
private Integer isOld;
/** /**
* @Description: * @Description:
* @params: 部署id * @params: 部署id
......
...@@ -58,6 +58,8 @@ public class FlowsInfoVo { ...@@ -58,6 +58,8 @@ public class FlowsInfoVo {
@ApiModelProperty("开始节点的id") @ApiModelProperty("开始节点的id")
private String startPageId; private String startPageId;
@ApiModelProperty("是否和之前一样 0是一样 1不一样")
private Integer isOld = 1;
@ApiModelProperty() @ApiModelProperty()
private List<NodeInfo> nodeInfoList; private List<NodeInfo> nodeInfoList;
......
package com.tykj.workflowcore.workflow_editer.entity.vo;
import com.tykj.workflowcore.base.page.JpaCustomPage;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author HuangXiahao
* @version V1.0
* @class SearchFlowInfoVo
* @packageName com.tykj.workflowcore.workflow_editer.entity.vo
**/
@AllArgsConstructor
@NoArgsConstructor
@Data
public class SearchAllFlowInfoVo extends JpaCustomPage {
@ApiModelProperty(value = "状态",notes = "0 可用,1 暂停")
private Integer state ;
@ApiModelProperty("流程名称")
private String flowName;
@ApiModelProperty("流程主键")
private String flowKey;
}
...@@ -36,7 +36,7 @@ public interface WorkFlowService { ...@@ -36,7 +36,7 @@ public interface WorkFlowService {
* 接收前端的流程文件 * 接收前端的流程文件
* @param flowsInfoVo * @param flowsInfoVo
*/ */
void flowXml(@RequestBody FlowsInfoVo flowsInfoVo) throws XMLStreamException, FileNotFoundException; void flowXml(@RequestBody FlowsInfoVo flowsInfoVo) throws XMLStreamException, IOException;
/** /**
* 创建流程 * 创建流程
...@@ -45,12 +45,19 @@ public interface WorkFlowService { ...@@ -45,12 +45,19 @@ public interface WorkFlowService {
*/ */
Integer createFlow(@RequestBody FlowsInfo flowsInfo); Integer createFlow(@RequestBody FlowsInfo flowsInfo);
// /**
// * 部署xml流程文件
// * @param flowsInfo
// * @throws FileNotFoundException
// */
// void deployXml(FlowsInfo flowsInfo) throws FileNotFoundException;
/** /**
* 部署xml流程文件 * 部署xml流程文件
* @param flowsInfo * @param id
* @throws FileNotFoundException * @throws FileNotFoundException
*/ */
void deployXml(FlowsInfo flowsInfo) throws FileNotFoundException; void deployXml(Integer id) throws FileNotFoundException;
/** /**
* 存储变量池 选择变量条件 * 存储变量池 选择变量条件
......
...@@ -15,10 +15,7 @@ import com.tykj.workflowcore.workflow_editer.service.VariableStorageService; ...@@ -15,10 +15,7 @@ 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.util.UserServiceBeanUtil; import com.tykj.workflowcore.workflow_editer.util.UserServiceBeanUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.dom4j.Attribute; import org.dom4j.*;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader; import org.dom4j.io.SAXReader;
import org.flowable.bpmn.converter.BpmnXMLConverter; import org.flowable.bpmn.converter.BpmnXMLConverter;
import org.flowable.bpmn.model.*; import org.flowable.bpmn.model.*;
...@@ -44,6 +41,7 @@ import javax.xml.stream.XMLInputFactory; ...@@ -44,6 +41,7 @@ import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamReader;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
...@@ -120,11 +118,38 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -120,11 +118,38 @@ public class WorkFlowServiceImpl implements WorkFlowService {
} }
@Override @Override
public void flowXml(@RequestBody FlowsInfoVo flowsInfoVo) throws XMLStreamException, FileNotFoundException { public void flowXml(@RequestBody FlowsInfoVo flowsInfoVo) throws XMLStreamException, IOException {
String basePath = System.getProperty("user.dir") + "\\xml\\"; String basePath = System.getProperty("user.dir") + "\\xml\\";
Integer id = flowsInfoVo.getId(); Integer id = flowsInfoVo.getId();
String flowKey = flowsInfoVo.getFlowKey(); String flowKey = flowsInfoVo.getFlowKey();
String fileXml = flowsInfoVo.getFileXml(); String fileXml = flowsInfoVo.getFileXml();
//根据ID查询出一个flowsinfo
if (id != null){
FlowsInfo oldFlowInfo = flowsInfoMapper.findById(id).get();
//得到老的fileXml
String filePath = System.getProperty("user.dir")+oldFlowInfo.getFilePath();
File oldFile = new File(filePath);
File file = new File(filePath);
if(!file.exists()){
flowsInfoVo.setIsOld(1);
}else {
FileInputStream inputStream = new FileInputStream(file);
int length = inputStream.available();
byte bytes[] = new byte[length];
inputStream.read(bytes);
inputStream.close();
String oldXml =new String(bytes, StandardCharsets.UTF_8);
if (oldXml.equals(fileXml)){
flowsInfoVo.setIsOld(0);
}else {
flowsInfoVo.setIsOld(1);
}
}
}else {
flowsInfoVo.setIsOld(1);
}
//end
//生成xml文件 //生成xml文件
File file = FileUtil.createFileByString(basePath + flowKey + "bpmn20.xml", File file = FileUtil.createFileByString(basePath + flowKey + "bpmn20.xml",
flowsInfoVo.getFileXml().replaceAll("\\[\\?\\?[^\\]]+\\?\\?\\]", "").replaceAll("&lt;","<").replaceAll("&gt;",">")); flowsInfoVo.getFileXml().replaceAll("\\[\\?\\?[^\\]]+\\?\\?\\]", "").replaceAll("&lt;","<").replaceAll("&gt;",">"));
...@@ -137,8 +162,6 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -137,8 +162,6 @@ public class WorkFlowServiceImpl implements WorkFlowService {
flowsInfo.setFilePath("\\xml\\" + flowKey + "bpmn20.xml"); flowsInfo.setFilePath("\\xml\\" + flowKey + "bpmn20.xml");
flowsInfo.setFileCustomPath("\\xml\\" + flowKey + "bpmnCustom20.xml"); flowsInfo.setFileCustomPath("\\xml\\" + flowKey + "bpmnCustom20.xml");
flowsInfo.setId(id); flowsInfo.setId(id);
//更新并保存
FlowsInfo save = flowsInfoMapper.save(flowsInfo);
//进行第一部的校验 //进行第一部的校验
InputStream inputStream = new FileInputStream(file);//实例化FileInputStream InputStream inputStream = new FileInputStream(file);//实例化FileInputStream
BpmnXMLConverter converter = new BpmnXMLConverter(); BpmnXMLConverter converter = new BpmnXMLConverter();
...@@ -151,7 +174,6 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -151,7 +174,6 @@ public class WorkFlowServiceImpl implements WorkFlowService {
List<ValidationError> validate = defaultProcessValidator.validate(bpmnModel); List<ValidationError> validate = defaultProcessValidator.validate(bpmnModel);
StringBuffer message = new StringBuffer(); StringBuffer message = new StringBuffer();
if (validate.size()!=0){ if (validate.size()!=0){
for (int i =0;i<validate.size();i++){ for (int i =0;i<validate.size();i++){
ValidationError validationError = validate.get(i); ValidationError validationError = validate.get(i);
String problem = validationError.getProblem(); String problem = validationError.getProblem();
...@@ -159,18 +181,14 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -159,18 +181,14 @@ public class WorkFlowServiceImpl implements WorkFlowService {
message.append("\r\n"); message.append("\r\n");
} }
throw new ApiException(null,message.toString()); throw new ApiException(null,message.toString());
}else {
//通过id状态
Integer state = save.getState();
if(state == 1){
return;
}else {
//自动部署
deployXml(save);
}
} }
//更新并保存
flowsInfoMapper.save(flowsInfo);
// else {
// //自动部署
// deployXml(save);
//
// }
} }
...@@ -184,7 +202,8 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -184,7 +202,8 @@ public class WorkFlowServiceImpl implements WorkFlowService {
@Override @Override
public void deployXml(FlowsInfo flowsInfo) { public void deployXml(Integer id) {
FlowsInfo flowsInfo = flowsInfoMapper.findById(id).get();
Deployment deploy = null; Deployment deploy = null;
try { try {
deploy = repositoryService.createDeployment().addInputStream(System.getProperty("user.dir") + flowsInfo.getResourceName(), deploy = repositoryService.createDeployment().addInputStream(System.getProperty("user.dir") + flowsInfo.getResourceName(),
...@@ -218,8 +237,6 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -218,8 +237,6 @@ public class WorkFlowServiceImpl implements WorkFlowService {
} }
@Override @Override
public List<Map<String, Object>> findTaskByUserId(NextTaskVo nextTaskVo) { public List<Map<String, Object>> findTaskByUserId(NextTaskVo nextTaskVo) {
List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
...@@ -343,13 +360,20 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -343,13 +360,20 @@ public class WorkFlowServiceImpl implements WorkFlowService {
repositoryService.suspendProcessDefinitionByKey(flowKey, true, new Date()); repositoryService.suspendProcessDefinitionByKey(flowKey, true, new Date());
flowsInfo.setState(1); flowsInfo.setState(1);
} else { } else {
if (flowsInfo.getIsOld() == 1){
deployXml(id);
//还原标志位
flowsInfo.setIsOld(0);
}else {
//激活 //激活
repositoryService.activateProcessDefinitionByKey(flowKey, true, new Date()); repositoryService.activateProcessDefinitionByKey(flowKey, true, new Date());
}
flowsInfo.setState(0); flowsInfo.setState(0);
} }
} else { } else {
throw new ApiException("该流程未编辑流程图无法被启用"); deployXml(id);
flowsInfo.setState(0);
flowsInfo.setIsOld(0);
} }
flowsInfoMapper.save(flowsInfo); flowsInfoMapper.save(flowsInfo);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论