提交 c77a1008 authored 作者: ww1xhqc's avatar ww1xhqc

Merge remote-tracking branch 'origin/master'

...@@ -56,7 +56,8 @@ ...@@ -56,7 +56,8 @@
│ └─frame --核心逻辑所在位置 │ └─frame --核心逻辑所在位置
``` ```
## 使用方式 ## 使用方式
### 安装 ### 后端安装
#### maven #### maven
``` ```
<dependency> <dependency>
...@@ -69,7 +70,7 @@ ...@@ -69,7 +70,7 @@
1. 获取 workflow-core-0.0.1-SNAPSHOT.jar 1. 获取 workflow-core-0.0.1-SNAPSHOT.jar
2. 在你自己项目的根目录下创建lib文件夹 并将 jar 包放入 2. 在你自己项目的根目录下创建lib文件夹 并将 jar 包放入
3. pom 添加 如下 3. pom 添加 如下
``` ```
<dependency> <dependency>
<groupId>com.tykj</groupId> <groupId>com.tykj</groupId>
...@@ -79,7 +80,11 @@ ...@@ -79,7 +80,11 @@
<systemPath>${basedir}/lib/workflow-core-0.0.1-SNAPSHOT.jar</systemPath> <systemPath>${basedir}/lib/workflow-core-0.0.1-SNAPSHOT.jar</systemPath>
</dependency> </dependency>
``` ```
### 调用 ### 前端安装
```
npm install workflow-form
```
### 配置
1. 在springboot 启动类上添加注解 @EnableWorkFlowCore 1. 在springboot 启动类上添加注解 @EnableWorkFlowCore
``` ```
@EnableWorkFlowCore @EnableWorkFlowCore
...@@ -145,5 +150,119 @@ public class FlowUserServiceImpl implements UserService { ...@@ -145,5 +150,119 @@ public class FlowUserServiceImpl implements UserService {
} }
``` ```
### 使用
1. 工作流部分
1. 建立数据模型
![image-20210315130344008](images\image-20210315130344008.png)
2. 建立流程
![image-20210315131641756](images\image-20210315131641756.png)
3. 为节点配置页面
![image-20210315131723560](images\image-20210315131723560.png)
![image-20210315132632917](images\image-20210315132632917.png)
4. 配置节点的审核人
![image-20210315132126849](images\image-20210315132126849.png)
2. 宿主系统部分
1. 查询可发起流程
```
接口返回值示例
{
"message": "查询成功",
"data": {
"content": [
{
"id": 2,
"createdTime": "2021-03-15T03:00:48.028+00:00",
"updatedTime": "2021-03-15T03:10:33.009+00:00",
"deleted": 0,
"userId": null,
"userName": null,
"flowName": "测试1",
"resourceName": "processId_2850e08d-0e3d-4925-93f6-adce8a9e2246bpmn20.xml",
"flowKey": "processId_2850e08d-0e3d-4925-93f6-adce8a9e2246",
//前端组件需要使用该数据
"state": 0,
"filePath": "\\xml\\processId_2850e08d-0e3d-4925-93f6-adce8a9e2246bpmn20.xml",
"flowDescribe": "测试2",
"startId": null,
"startPageId": 1, //前端组件需要使用该数据
"processInstanceId": null,
"deployId": "a4c408b0-853a-11eb-81c9-d2c637ad090d"
},
{
"id": 3,
"createdTime": "2021-03-15T03:17:30.914+00:00",
"updatedTime": "2021-03-15T03:17:31.850+00:00",
"deleted": 0,
"userId": null,
"userName": null,
"flowName": "测试流程1",
"resourceName": "processId_560c6b5c-8be5-40b8-852f-8e174346e9c8bpmn20.xml",
"flowKey": "processId_560c6b5c-8be5-40b8-852f-8e174346e9c8",
"state": 0,
"filePath": "\\xml\\processId_560c6b5c-8be5-40b8-852f-8e174346e9c8bpmn20.xml",
"flowDescribe": "测试流程描述1",
"startId": null,
"startPageId": null,
"processInstanceId": null,
"deployId": "fa83de4c-853c-11eb-81c9-d2c637ad090d"
}
],
"pageable": {
"sort": {
"sorted": false,
"unsorted": true,
"empty": true
},
"offset": 0,
"pageSize": 15,
"pageNumber": 0,
"paged": true,
"unpaged": false
},
"totalElements": 2,
"last": true,
"totalPages": 1,
"number": 0,
"size": 15,
"sort": {
"sorted": false,
"unsorted": true,
"empty": true
},
"numberOfElements": 2,
"first": true,
"empty": false
}
}
```
2. 渲染页面
```
fromUtil.creatFrom(pageId,flowKey)
```
(渲染出来的表单页面中的逻辑由工作流控制,用户完成表单所有操作后页面会自动关闭)
3. 模拟效果
![image-20210315132852126](images\image-20210315132852126.png)
![image-20210315132859363](images\image-20210315132859363.png)
...@@ -24,7 +24,4 @@ public class ResultObj<T> { ...@@ -24,7 +24,4 @@ public class ResultObj<T> {
this.message = "no message"; this.message = "no message";
} }
public ResultObj(String m) {
this.message = m;
}
} }
...@@ -25,7 +25,7 @@ public class ResultUtil<T> { ...@@ -25,7 +25,7 @@ public class ResultUtil<T> {
* 成功返回结果 * 成功返回结果
*/ */
public static <T> ResponseEntity<ResultObj<T>> success(String message) { public static <T> ResponseEntity<ResultObj<T>> success(String message) {
return ResponseEntity.ok(new ResultObj<>(message)); return ResponseEntity.ok(new ResultObj<>(null,message));
} }
/** /**
......
...@@ -52,22 +52,12 @@ public class FlowsInfoController { ...@@ -52,22 +52,12 @@ public class FlowsInfoController {
@GetMapping("editFlow") @GetMapping("editFlow")
@ApiOperation(value = "编辑流程") @ApiOperation(value = "编辑流程")
public String editFlow(Integer id){ public ResponseEntity editFlow(Integer id){
return flowInfoService.editFlow(id).getFilePath(); return ResultUtil.success(flowInfoService.editFlow(id),"查询成功");
}
@GetMapping("/deploy")
@ApiOperation(value = "部署流程",notes = "部署成功")
public ResponseEntity deploy(Integer id) throws FileNotFoundException {
//根据id 查询出flowsInfo
FlowsInfo flowsInfo = flowInfoService.findById(id);
if (flowsInfo.getState() == 0){
return ResultUtil.success(flowsInfo.getState(),"该流程已经被部署");
}
workFlowService.deployXml(flowsInfo);
return ResultUtil.success(flowsInfo.getState(),"流程部署成功");
} }
@PostMapping("/saveXml") @PostMapping("/saveXml")
@ApiOperation(value = "保存xml以及其他流程信息") @ApiOperation(value = "保存xml以及其他流程信息")
public ResponseEntity saveXml(@RequestBody FlowsInfoVo flowsInfoVo) { public ResponseEntity saveXml(@RequestBody FlowsInfoVo flowsInfoVo) {
......
...@@ -27,9 +27,6 @@ import java.util.Map; ...@@ -27,9 +27,6 @@ import java.util.Map;
@RequestMapping("/workFlow") @RequestMapping("/workFlow")
public class WorkFlowController { public class WorkFlowController {
@Autowired
private FlowInfoService flowInfoService;
@Autowired @Autowired
private WorkFlowService workFlowService; private WorkFlowService workFlowService;
...@@ -44,7 +41,6 @@ public class WorkFlowController { ...@@ -44,7 +41,6 @@ public class WorkFlowController {
@PostMapping("/findUserTask") @PostMapping("/findUserTask")
@ApiOperation("任务个人待办列表") @ApiOperation("任务个人待办列表")
public List<Map<String,Object>> findUserTask(@RequestBody NextTaskVo nextTaskVo){ public List<Map<String,Object>> findUserTask(@RequestBody NextTaskVo nextTaskVo){
return workFlowService.findTaskByUserId(nextTaskVo); return workFlowService.findTaskByUserId(nextTaskVo);
} }
......
...@@ -45,7 +45,7 @@ public class FlowsInfo extends BaseEntity { ...@@ -45,7 +45,7 @@ public class FlowsInfo extends BaseEntity {
@ApiModelProperty("流程主键") @ApiModelProperty("流程主键")
private String flowKey; private String flowKey;
@ApiModelProperty(value = "部署状态",notes = "0 已部署,1 未部署") @ApiModelProperty(value = "部署状态",notes = "0 已启用,1 未启用")
private Integer state; private Integer state;
@ApiModelProperty("文件路径") @ApiModelProperty("文件路径")
......
...@@ -53,7 +53,6 @@ public class FlowInfoServiceImpl implements FlowInfoService { ...@@ -53,7 +53,6 @@ public class FlowInfoServiceImpl implements FlowInfoService {
FlowsInfo byDesc = flowsInfoMapper.findByFlowKey(flowKey); FlowsInfo byDesc = flowsInfoMapper.findByFlowKey(flowKey);
byDesc.setFlowDescribe(describe); byDesc.setFlowDescribe(describe);
// //进行更新 // //进行更新
// FlowsInfo flowsInfo = flowsInfoMapper.save(byDesc);
return flowsInfoMapper.save(byDesc); return flowsInfoMapper.save(byDesc);
} }
......
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,6 +4,7 @@ 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.api.service.SpringBeanService; import com.tykj.workflowcore.api.service.SpringBeanService;
import com.tykj.workflowcore.base.result.ApiException;
import com.tykj.workflowcore.workflow_editer.entity.*; import com.tykj.workflowcore.workflow_editer.entity.*;
import com.tykj.workflowcore.workflow_editer.dao.FlowsInfoMapper; import com.tykj.workflowcore.workflow_editer.dao.FlowsInfoMapper;
import com.tykj.workflowcore.workflow_editer.entity.vo.*; import com.tykj.workflowcore.workflow_editer.entity.vo.*;
...@@ -149,7 +150,7 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -149,7 +150,7 @@ public class WorkFlowServiceImpl implements WorkFlowService {
//生成xml文件 //生成xml文件
File f = null; File f = null;
try { try {
f = new File(classLoader.getResource("").getPath()+"/xml/"+flowKey+"bpmn20.xml"); f = new File(System.getProperty("user.dir")+"\\xml\\"+flowKey+"bpmn20.xml");
// 判断文件是否存在 // 判断文件是否存在
if(!f.exists()){ if(!f.exists()){
f.createNewFile(); f.createNewFile();
...@@ -188,8 +189,8 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -188,8 +189,8 @@ public class WorkFlowServiceImpl implements WorkFlowService {
} }
FlowsInfo flowsInfo = new FlowsInfo(); FlowsInfo flowsInfo = new FlowsInfo();
BeanUtils.copyProperties(flowsInfoVo,flowsInfo); BeanUtils.copyProperties(flowsInfoVo,flowsInfo);
flowsInfo.setResourceName(flowKey+"bpmn.xml"); flowsInfo.setResourceName(flowKey+"bpmn20.xml");
flowsInfo.setFilePath(classLoader.getResource("").getPath()+"/xml/"+flowKey+"bpmn20.xml"); flowsInfo.setFilePath("\\xml\\"+flowKey+"bpmn20.xml");
flowsInfo.setId(id); flowsInfo.setId(id);
//更新并保存 //更新并保存
FlowsInfo save = flowsInfoMapper.save(flowsInfo); FlowsInfo save = flowsInfoMapper.save(flowsInfo);
...@@ -208,8 +209,8 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -208,8 +209,8 @@ public class WorkFlowServiceImpl implements WorkFlowService {
public void deployXml(FlowsInfo flowsInfo) { public void deployXml(FlowsInfo flowsInfo) {
Deployment deploy = null; Deployment deploy = null;
try { try {
deploy = repositoryService.createDeployment().addInputStream(flowsInfo.getResourceName(), deploy = repositoryService.createDeployment().addInputStream(System.getProperty("user.dir")+flowsInfo.getResourceName(),
new FileInputStream(flowsInfo.getFilePath())).deploy(); new FileInputStream(System.getProperty("user.dir") +flowsInfo.getFilePath())).deploy();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -335,15 +336,21 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -335,15 +336,21 @@ public class WorkFlowServiceImpl implements WorkFlowService {
//通过流程ID 查询出flowsInfo //通过流程ID 查询出flowsInfo
FlowsInfo flowsInfo = flowsInfoMapper.findById(id).get(); FlowsInfo flowsInfo = flowsInfoMapper.findById(id).get();
String flowKey = flowsInfo.getFlowKey(); String flowKey = flowsInfo.getFlowKey();
if (flowsInfo.getState() == 0){ List<Deployment> list = repositoryService.createDeploymentQuery().processDefinitionKey(flowKey).list();
//挂起 if (list!=null&&list.size()>0){
repositoryService.suspendProcessDefinitionByKey(flowKey, true, new Date()); if (flowsInfo.getState() == 0){
flowsInfo.setState(1); //挂起
repositoryService.suspendProcessDefinitionByKey(flowKey, true, new Date());
flowsInfo.setState(1);
}else {
//激活
repositoryService.activateProcessDefinitionByKey(flowKey,true, new Date());
flowsInfo.setState(0);
}
}else { }else {
//激活 throw new ApiException("该流程未编辑流程图无法被启用");
repositoryService.activateProcessDefinitionByKey(flowKey,true, new Date());
flowsInfo.setState(0);
} }
flowsInfoMapper.save(flowsInfo); flowsInfoMapper.save(flowsInfo);
} }
...@@ -351,10 +358,14 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -351,10 +358,14 @@ public class WorkFlowServiceImpl implements WorkFlowService {
@Override @Override
public void deleteFlow(Integer id) { public void deleteFlow(Integer id) {
//通过流程id查询出flowsInfo //通过流程id查询出flowsInfo
FlowsInfo flowsInfo = flowsInfoMapper.findById(id).get(); Optional<FlowsInfo> flowsInfoMapperById = flowsInfoMapper.findById(id);
if(flowsInfo.getState() == 0){ if (flowsInfoMapperById.isPresent()){
flowsInfo.setState(1); FlowsInfo flowsInfo = flowsInfoMapperById.get();
flowsInfoMapper.save(flowsInfo); if(flowsInfo.getState() == 0){
flowsInfoMapper.deleteById(id);
}
}else {
throw new ApiException("流程不存在");
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论