diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index a70d560..693ec56 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -86,7 +86,7 @@ token: # 令牌密钥 secret: abcdefghijklmnopqrstuvwxyz # 令牌有效期(默认30分钟) - expireTime: 300 + expireTime: 30 # MyBatis配置 mybatis: diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowTaskController.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowTaskController.java index 70c3da7..5c88db7 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowTaskController.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowTaskController.java @@ -171,4 +171,14 @@ public class FlowTaskController { } } } + + /** + * 生成流程图 + * + * @param procInsId 任务ID + */ + @RequestMapping("/flowViewer/{procInsId}") + public AjaxResult getFlowViewer(@PathVariable("procInsId") String procInsId) { + return flowTaskService.getFlowViewer(procInsId); + } } diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/dto/FlowViewerDto.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/dto/FlowViewerDto.java new file mode 100644 index 0000000..29b4776 --- /dev/null +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/dto/FlowViewerDto.java @@ -0,0 +1,16 @@ +package com.ruoyi.flowable.domain.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author Xuan xuan + * @date 2021/4/21 20:55 + */ +@Data +public class FlowViewerDto implements Serializable { + + private String key; + private boolean completed; +} diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/listener/UserTaskListener.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/listener/UserTaskListener.java new file mode 100644 index 0000000..4f2b653 --- /dev/null +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/listener/UserTaskListener.java @@ -0,0 +1,18 @@ +package com.ruoyi.flowable.listener; + +import org.flowable.engine.delegate.TaskListener; +import org.flowable.task.service.delegate.DelegateTask; +import org.springframework.stereotype.Component; + +/** + * @author Xuan xuan + * @date 2021/4/20 + */ +public class UserTaskListener implements TaskListener{ + + @Override + public void notify(DelegateTask delegateTask) { + + } + +} diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowTaskService.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowTaskService.java index dd0a0c4..1e82eab 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowTaskService.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowTaskService.java @@ -137,6 +137,13 @@ public interface IFlowTaskService { */ InputStream diagram(String processId); + /** + * 获取流程执行过程 + * @param procInsId + * @return + */ + AjaxResult getFlowViewer(String procInsId); + /** * 获取流程变量 * @param taskId diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java index 2eefcbd..2f62870 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java @@ -14,6 +14,7 @@ import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.flowable.domain.dto.FlowCommentDto; import com.ruoyi.flowable.domain.dto.FlowNextDto; import com.ruoyi.flowable.domain.dto.FlowTaskDto; +import com.ruoyi.flowable.domain.dto.FlowViewerDto; import com.ruoyi.flowable.domain.vo.FlowTaskVo; import com.ruoyi.flowable.factory.FlowServiceFactory; import com.ruoyi.flowable.flow.CustomProcessDiagramGenerator; @@ -535,13 +536,12 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask FlowNode flowNode = (FlowNode) bpmnModel.getMainProcess().getFlowElement(activityId); //记录原活动方向 - List oriSequenceFlows = new ArrayList(); - oriSequenceFlows.addAll(flowNode.getOutgoingFlows()); + List oriSequenceFlows = new ArrayList<>(flowNode.getOutgoingFlows()); //清理活动方向 flowNode.getOutgoingFlows().clear(); //建立新方向 - List newSequenceFlowList = new ArrayList(); + List newSequenceFlowList = new ArrayList<>(); SequenceFlow newSequenceFlow = new SequenceFlow(); newSequenceFlow.setId("newSequenceFlowId"); newSequenceFlow.setSourceFlowElement(flowNode); @@ -550,14 +550,15 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask flowNode.setOutgoingFlows(newSequenceFlowList); Authentication.setAuthenticatedUserId(loginUser.getUserId().toString()); - taskService.addComment(task.getId(), task.getProcessInstanceId(), "撤回"); + taskService.addComment(task.getId(), task.getProcessInstanceId(), FlowComment.NORMAL.getType(),"撤回"); - Map currentVariables = new HashMap(); - currentVariables.put("applier", loginUser.getUserName()); + Map currentVariables = new HashMap<>(); + currentVariables.put(ProcessConstants.PROCESS_INITIATOR, loginUser.getUserId().toString()); //完成任务 taskService.complete(task.getId(), currentVariables); //恢复原方向 flowNode.setOutgoingFlows(oriSequenceFlows); + return AjaxResult.success(); } @@ -592,6 +593,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask ProcessDefinition pd = repositoryService.createProcessDefinitionQuery() .processDefinitionId(task.getProcessDefinitionId()) .singleResult(); + flowTask.setDeployId(pd.getDeploymentId()); flowTask.setProcDefName(pd.getName()); flowTask.setProcDefVersion(pd.getVersion()); flowTask.setProcInsId(task.getProcessInstanceId()); @@ -666,6 +668,9 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask } page.setTotal(hisTaskList.size()); page.setRecords(hisTaskList); +// Map result = new HashMap<>(); +// result.put("result",page); +// result.put("finished",true); return AjaxResult.success(page); } @@ -734,13 +739,13 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask } } map.put("flowList", hisFlowList); - // 查询当前任务是否完成 - List taskList = taskService.createTaskQuery().processInstanceId(procInsId).list(); - if (CollectionUtils.isNotEmpty(taskList)) { - map.put("finished", true); - } else { - map.put("finished", false); - } +// // 查询当前任务是否完成 +// List taskList = taskService.createTaskQuery().processInstanceId(procInsId).list(); +// if (CollectionUtils.isNotEmpty(taskList)) { +// map.put("finished", true); +// } else { +// map.put("finished", false); +// } } // 第一次申请获取初始化表单 if (StringUtils.isNotBlank(deployId)) { @@ -814,6 +819,32 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask } + /** + * 获取流程执行过程 + * + * @param procInsId + * @return + */ + @Override + public AjaxResult getFlowViewer(String procInsId) { + List flowViewerList = new ArrayList<>(); + FlowViewerDto flowViewerDto; + // 获得活动的节点 + List hisActIns = historyService.createHistoricActivityInstanceQuery() + .processInstanceId(procInsId) + .orderByHistoricActivityInstanceStartTime() + .asc().list(); + for (HistoricActivityInstance activityInstance : hisActIns) { + if (!"sequenceFlow".equals(activityInstance.getActivityType())) { + flowViewerDto = new FlowViewerDto(); + flowViewerDto.setKey(activityInstance.getActivityId()); + flowViewerDto.setCompleted(!Objects.isNull(activityInstance.getEndTime())); + flowViewerList.add(flowViewerDto); + } + } + return AjaxResult.success(flowViewerList); + } + /** * 获取流程变量 * @@ -846,8 +877,10 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask List nextUserTask = FindNextNodeUtil.getNextUserTasks(repositoryService, task, new HashMap<>()); if (CollectionUtils.isNotEmpty(nextUserTask)) { for (UserTask userTask : nextUserTask) { + MultiInstanceLoopCharacteristics characteristics = userTask.getLoopCharacteristics(); String dataType = userTask.getAttributeValue(ProcessConstants.NAMASPASE, ProcessConstants.PROCESS_CUSTOM_DATA_TYPE); String userType = userTask.getAttributeValue(ProcessConstants.NAMASPASE, ProcessConstants.PROCESS_CUSTOM_USER_TYPE); + if (ProcessConstants.DATA_TYPE.equals(dataType)) { // 指定单个人员 if (ProcessConstants.USER_TYPE_ASSIGNEE.equals(userType)) { diff --git a/ruoyi-ui/public/favicon.ico b/ruoyi-ui/public/favicon.ico index e263760..3da25d8 100644 Binary files a/ruoyi-ui/public/favicon.ico and b/ruoyi-ui/public/favicon.ico differ diff --git a/ruoyi-ui/src/api/flowable/definition.js b/ruoyi-ui/src/api/flowable/definition.js index 5c1411f..d1ad9d0 100644 --- a/ruoyi-ui/src/api/flowable/definition.js +++ b/ruoyi-ui/src/api/flowable/definition.js @@ -68,6 +68,14 @@ export function readImage(deployId) { }) } +// 读取image文件 +export function getFlowViewer(procInsId) { + return request({ + url: '/flowable/task/flowViewer/' + procInsId, + method: 'get' + }) +} + // 读取xml文件 export function saveXml(data) { return request({ diff --git a/ruoyi-ui/src/api/login.js b/ruoyi-ui/src/api/login.js index 869cd9f..9ddd1c1 100644 --- a/ruoyi-ui/src/api/login.js +++ b/ruoyi-ui/src/api/login.js @@ -37,4 +37,4 @@ export function getCodeImg() { url: '/captchaImage', method: 'get' }) -} \ No newline at end of file +} diff --git a/ruoyi-ui/src/components/BpmnViewer/src/BpmnViewer.vue b/ruoyi-ui/src/components/BpmnViewer/src/BpmnViewer.vue index ed0d2cc..6f42826 100644 --- a/ruoyi-ui/src/components/BpmnViewer/src/BpmnViewer.vue +++ b/ruoyi-ui/src/components/BpmnViewer/src/BpmnViewer.vue @@ -40,7 +40,9 @@ export default { try { // let xmlData = this.xmlData.replace('xmlns:camunda', 'xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" xmlns:camunda') // console.log('xmlData', xmlData) + const { warning } = await bpmnViewer.importXML(this.xmlData); + // console.log('rendered', warning); let canvas = bpmnViewer.get('canvas'); // canvas.zoom('fit-viewport') @@ -143,8 +145,8 @@ export default { } }; - - diff --git a/ruoyi-ui/src/views/flowable/definition/model.vue b/ruoyi-ui/src/views/flowable/definition/model.vue index 2e33117..e56a949 100644 --- a/ruoyi-ui/src/views/flowable/definition/model.vue +++ b/ruoyi-ui/src/views/flowable/definition/model.vue @@ -48,12 +48,14 @@ export default { data() { return { xml: "", // 后端查询到的xml + modeler:"", xmlOpen: false, xmlTitle: '', xmlContent: '', users: [], groups: [], categorys: [], + }; }, created () { @@ -72,7 +74,8 @@ export default { getModelDetail(deployId) { // 发送请求,获取xml readXml(deployId).then(res =>{ - this.xml = res.data + this.xml = res.data; + this.modeler = res.data }) }, /** 保存xml */ diff --git a/ruoyi-ui/src/views/flowable/task/finished/index.vue b/ruoyi-ui/src/views/flowable/task/finished/index.vue index 5b43519..a19f22e 100644 --- a/ruoyi-ui/src/views/flowable/task/finished/index.vue +++ b/ruoyi-ui/src/views/flowable/task/finished/index.vue @@ -240,7 +240,7 @@ export default { procInsId: row.procInsId, deployId: row.deployId, taskId: row.taskId, - isFinished: 1 + finished: false }}) }, /** 修改按钮操作 */ diff --git a/ruoyi-ui/src/views/flowable/task/process/index.vue b/ruoyi-ui/src/views/flowable/task/process/index.vue index f37d3a0..d9034fc 100644 --- a/ruoyi-ui/src/views/flowable/task/process/index.vue +++ b/ruoyi-ui/src/views/flowable/task/process/index.vue @@ -292,7 +292,9 @@ export default { this.$router.push({ path: '/flowable/task/record/index', query: { deployId: row.deploymentId, - procDefId:row.id } + procDefId:row.id, + finished: true + } }) }, /** 撤回流程申请 */ @@ -313,7 +315,7 @@ export default { procInsId: row.procInsId, deployId: row.deployId, taskId: row.taskId, - isFinished: 1 + finished: false }}) }, /** 修改按钮操作 */ diff --git a/ruoyi-ui/src/views/flowable/task/record/flow.vue b/ruoyi-ui/src/views/flowable/task/record/flow.vue new file mode 100644 index 0000000..22982d0 --- /dev/null +++ b/ruoyi-ui/src/views/flowable/task/record/flow.vue @@ -0,0 +1,32 @@ + + diff --git a/ruoyi-ui/src/views/flowable/task/record/index.vue b/ruoyi-ui/src/views/flowable/task/record/index.vue index f05e047..42c5f6b 100644 --- a/ruoyi-ui/src/views/flowable/task/record/index.vue +++ b/ruoyi-ui/src/views/flowable/task/record/index.vue @@ -6,14 +6,15 @@ 返回 - + +
- -
+ +
@@ -27,7 +28,7 @@ @@ -102,30 +103,54 @@ - + + + + + + + + +
流程图
- - - -
+ +