From fb31744f9bca4e8027fe7fd42aff77374b8d332c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E7=8E=89=E7=90=A6?= <7507756+jiang_yuqi@user.noreply.gitee.com> Date: Tue, 27 Feb 2024 02:45:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/vw_sql.sql | 54 +- .../controller/FlowInstanceController.java | 2 +- .../controller/FlowTaskController.java | 9 +- .../yanzhu/flowable/domain}/FlowTaskVo.java | 6 +- .../listener/FlowTaskEndListener.java | 29 + .../flowable/listener/FlowTaskListener.java | 3 - .../service/IFlowInstanceService.java | 2 +- .../flowable/service/IFlowTaskService.java | 2 +- .../impl/FlowDefinitionServiceImpl.java | 8 +- .../service/impl/FlowInstanceServiceImpl.java | 3 +- .../service/impl/FlowTaskServiceImpl.java | 20 +- yanzhu-ui/src/api/flowable/todo.js | 11 + .../task/myProcess/detail/detailDrawer.vue | 8 +- .../task/myProcess/editTaskDrawer.vue | 1200 ++++++++++++----- .../views/flowable/task/myProcess/index.vue | 24 +- .../task/myProcess/initTaskDrawer.vue | 6 +- .../src/views/flowable/task/todo/index.vue | 73 +- 17 files changed, 1034 insertions(+), 426 deletions(-) rename {yanzhu-system/src/main/java/com/yanzhu/system/domain/flowable => yanzhu-flowable/src/main/java/com/yanzhu/flowable/domain}/FlowTaskVo.java (87%) create mode 100644 yanzhu-flowable/src/main/java/com/yanzhu/flowable/listener/FlowTaskEndListener.java diff --git a/sql/vw_sql.sql b/sql/vw_sql.sql index 9bd1920..a817154 100644 --- a/sql/vw_sql.sql +++ b/sql/vw_sql.sql @@ -138,4 +138,56 @@ LEFT OUTER JOIN pro_project_apply ppa ON DEF.BUSINESS_KEY_ = ppa.id LEFT JOIN sys_user ru ON ru.user_id = RES.ASSIGNEE_ LEFT JOIN sys_dept rd ON rd.dept_id = ru.dept_id WHERE - RES.ASSIGNEE_ is not null and RES.END_TIME_ is not null) \ No newline at end of file + RES.ASSIGNEE_ is not null and RES.END_TIME_ is not null) + +##审批意见 +DROP view vw_flow_comment; +CREATE VIEW vw_flow_comment AS ( +SELECT + hi.ID_ as cc, + hc.ID_ AS commentId, + hc.TYPE_ AS commentType, + ht.ID_ AS taskId, + ht.NAME_ AS taskName, + ht.REV_ AS rev, + CASE +WHEN hc.TYPE_ = 1 and ht.NAME_ !='提交申请' THEN + '通过' +WHEN hc.TYPE_ = 2 THEN + '退回' +WHEN hc.TYPE_ = 3 THEN + '驳回' +WHEN hc.TYPE_ = 4 THEN + '委派' +WHEN hc.TYPE_ = 5 THEN + '转办' +WHEN hc.TYPE_ = 6 THEN + '终止' +WHEN hc.TYPE_ = 7 THEN + '撤回' +END AS commentResult, + ht.PROC_INST_ID_ AS procInstId, + ht.TASK_DEF_KEY_ AS taskDefKey, + ht.EXECUTION_ID_ AS executionId, + ht.DELETE_REASON_ AS deleteReason, + DATE_FORMAT( + ht.START_TIME_, + '%Y-%m-%d %H:%i:%S' +) AS startTime, + DATE_FORMAT( + ht.END_TIME_, + '%Y-%m-%d %H:%i:%S' +) AS endTime, + ht.DURATION_ AS duration, + hc.MESSAGE_ AS message, + ru.nick_name AS assigneeName, + rd.dept_name AS deptName, + r.role_name as candidate +FROM + act_hi_taskinst ht +LEFT JOIN act_hi_comment hc ON hc.TASK_ID_ = ht.ID_ or (hc.TASK_ID_ is null and hc.PROC_INST_ID_ = ht.PROC_INST_ID_) +LEFT JOIN act_hi_identitylink hi on hi.TYPE_ = 'candidate' and hi.TASK_ID_ = ht.ID_ and hi.USER_ID_ IS NULL +left JOIN sys_role r on r.role_id = hi.group_Id_ +LEFT JOIN sys_user ru ON ru.user_id = ht.ASSIGNEE_ +LEFT JOIN sys_dept rd ON rd.dept_id = ru.dept_id +where hc.TYPE_ is null or hc.TYPE_!='event') \ No newline at end of file diff --git a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowInstanceController.java b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowInstanceController.java index 3e73344..71ed4f1 100644 --- a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowInstanceController.java +++ b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowInstanceController.java @@ -2,7 +2,7 @@ package com.yanzhu.flowable.controller; import com.yanzhu.common.core.domain.AjaxResult; -import com.yanzhu.system.domain.flowable.FlowTaskVo; +import com.yanzhu.flowable.domain.FlowTaskVo; import com.yanzhu.flowable.service.IFlowInstanceService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; diff --git a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowTaskController.java b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowTaskController.java index 8c68a8d..ed887eb 100644 --- a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowTaskController.java +++ b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowTaskController.java @@ -5,7 +5,7 @@ import com.yanzhu.common.core.domain.AjaxResult; import com.yanzhu.common.enums.BusinessType; import com.yanzhu.flowable.domain.FlowTaskDto; import com.yanzhu.system.domain.flowable.FlowQueryVo; -import com.yanzhu.system.domain.flowable.FlowTaskVo; +import com.yanzhu.flowable.domain.FlowTaskVo; import com.yanzhu.flowable.service.IFlowTaskService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -95,6 +95,13 @@ public class FlowTaskController { return flowTaskService.complete(flowTaskVo); } + @ApiOperation(value = "重新提交流程") + @Log(title = "重新提交流程", businessType = BusinessType.UPDATE) + @PostMapping(value = "/completeAndModify") + public AjaxResult completeAndModify(@RequestBody FlowTaskVo flowTaskVo) { + return flowTaskService.complete(flowTaskVo); + } + @ApiOperation(value = "驳回任务") @Log(title = "驳回流程", businessType = BusinessType.UPDATE) @PostMapping(value = "/reject") diff --git a/yanzhu-system/src/main/java/com/yanzhu/system/domain/flowable/FlowTaskVo.java b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/domain/FlowTaskVo.java similarity index 87% rename from yanzhu-system/src/main/java/com/yanzhu/system/domain/flowable/FlowTaskVo.java rename to yanzhu-flowable/src/main/java/com/yanzhu/flowable/domain/FlowTaskVo.java index 79d6c38..c4287a5 100644 --- a/yanzhu-system/src/main/java/com/yanzhu/system/domain/flowable/FlowTaskVo.java +++ b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/domain/FlowTaskVo.java @@ -1,5 +1,6 @@ -package com.yanzhu.system.domain.flowable; +package com.yanzhu.flowable.domain; +import com.yanzhu.project.domain.ProProjectApply; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -45,6 +46,9 @@ public class FlowTaskVo { @ApiModelProperty("流程变量信息") private Map variables; + @ApiModelProperty("流程变量信息") + private ProProjectApply proProjectApply; + @ApiModelProperty("审批人") private String assignee; diff --git a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/listener/FlowTaskEndListener.java b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/listener/FlowTaskEndListener.java new file mode 100644 index 0000000..40a721e --- /dev/null +++ b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/listener/FlowTaskEndListener.java @@ -0,0 +1,29 @@ +package com.yanzhu.flowable.listener; + +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.delegate.DelegateExecution; +import org.flowable.engine.delegate.ExecutionListener; +import org.flowable.engine.delegate.TaskListener; +import org.flowable.task.service.delegate.DelegateTask; +import org.springframework.stereotype.Component; + +/** + * 任务监听器 + * + * create(创建):在任务被创建且所有的任务属性设置完成后才触发 + * assignment(指派):在任务被分配给某个办理人之后触发 + * complete(完成):在配置了监听器的上一个任务完成时触发 + * delete(删除):在任务即将被删除前触发。请注意任务由completeTask正常完成时也会触发 + * + * @author Tony + * @date 2021/4/20 + */ +@Slf4j +@Component +public class FlowTaskEndListener implements ExecutionListener { + + @Override + public void notify(DelegateExecution delegateExecution) { + log.info("任务结束监听器:{}", delegateExecution); + } +} diff --git a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/listener/FlowTaskListener.java b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/listener/FlowTaskListener.java index 8eef613..1c74ba9 100644 --- a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/listener/FlowTaskListener.java +++ b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/listener/FlowTaskListener.java @@ -22,11 +22,8 @@ public class FlowTaskListener implements TaskListener{ @Override public void notify(DelegateTask delegateTask) { - log.info("任务监听器:{}", delegateTask); // TODO 获取事件类型 delegateTask.getEventName(),可以通过监听器给任务执行人发送相应的通知消息 - - } } diff --git a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowInstanceService.java b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowInstanceService.java index 9024181..ed28ce4 100644 --- a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowInstanceService.java +++ b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowInstanceService.java @@ -1,7 +1,7 @@ package com.yanzhu.flowable.service; import com.yanzhu.common.core.domain.AjaxResult; -import com.yanzhu.system.domain.flowable.FlowTaskVo; +import com.yanzhu.flowable.domain.FlowTaskVo; import org.flowable.engine.history.HistoricProcessInstance; import java.util.Map; diff --git a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowTaskService.java b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowTaskService.java index 10f412d..e87f9ac 100644 --- a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowTaskService.java +++ b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowTaskService.java @@ -2,7 +2,7 @@ package com.yanzhu.flowable.service; import com.yanzhu.common.core.domain.AjaxResult; import com.yanzhu.system.domain.flowable.FlowQueryVo; -import com.yanzhu.system.domain.flowable.FlowTaskVo; +import com.yanzhu.flowable.domain.FlowTaskVo; import org.flowable.task.api.Task; import java.io.InputStream; diff --git a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowDefinitionServiceImpl.java b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowDefinitionServiceImpl.java index a98bacd..62740a5 100644 --- a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowDefinitionServiceImpl.java +++ b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowDefinitionServiceImpl.java @@ -199,12 +199,8 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl @Override public AjaxResult startProcessInstanceById(String procDefId, ProProjectApply proProjectApply) { try { - int res; - if(proProjectApply.getId()!=null){ - res = proProjectApplyService.updateProProjectApply(proProjectApply); - }else{ - res = proProjectApplyService.insertProProjectApply(proProjectApply); - } + /**保存流程表单**/ + int res = proProjectApplyService.insertProProjectApply(proProjectApply); if(res>0){ Map variables = new HashMap<>(); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId) diff --git a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowInstanceServiceImpl.java b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowInstanceServiceImpl.java index 65e2d19..b92db32 100644 --- a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowInstanceServiceImpl.java +++ b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowInstanceServiceImpl.java @@ -1,9 +1,8 @@ package com.yanzhu.flowable.service.impl; - import com.yanzhu.common.core.domain.AjaxResult; import com.yanzhu.common.utils.SecurityUtils; -import com.yanzhu.system.domain.flowable.FlowTaskVo; +import com.yanzhu.flowable.domain.FlowTaskVo; import com.yanzhu.flowable.factory.FlowServiceFactory; import com.yanzhu.flowable.service.IFlowInstanceService; import lombok.extern.slf4j.Slf4j; diff --git a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowTaskServiceImpl.java b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowTaskServiceImpl.java index 9b94349..397d2ab 100644 --- a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowTaskServiceImpl.java +++ b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowTaskServiceImpl.java @@ -1,6 +1,5 @@ package com.yanzhu.flowable.service.impl; - import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.TypeReference; @@ -19,8 +18,9 @@ import com.yanzhu.flowable.domain.FlowNextDto; import com.yanzhu.flowable.domain.FlowTaskDto; import com.yanzhu.flowable.domain.FlowViewerDto; import com.yanzhu.flowable.flow.ModelUtils; +import com.yanzhu.project.service.IProProjectApplyService; import com.yanzhu.system.domain.flowable.FlowQueryVo; -import com.yanzhu.system.domain.flowable.FlowTaskVo; +import com.yanzhu.flowable.domain.FlowTaskVo; import com.yanzhu.flowable.factory.FlowServiceFactory; import com.yanzhu.flowable.flow.CustomProcessDiagramGenerator; import com.yanzhu.flowable.flow.FindNextNodeUtil; @@ -56,6 +56,7 @@ import org.flowable.task.api.history.HistoricTaskInstance; import org.flowable.task.api.history.HistoricTaskInstanceQuery; import org.flowable.engine.impl.cmd.AddMultiInstanceExecutionCmd; import org.flowable.engine.impl.cmd.DeleteMultiInstanceExecutionCmd; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -86,6 +87,9 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask @Resource private ISysFormService sysFormService; + @Autowired + private IProProjectApplyService proProjectApplyService; + /** * 完成任务 * @@ -94,18 +98,22 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask @Transactional(rollbackFor = Exception.class) @Override public AjaxResult complete(FlowTaskVo taskVo) { + /**表单不为空时,重新修改表单**/ + if(!Objects.isNull(taskVo.getProProjectApply())){ + proProjectApplyService.updateProProjectApply(taskVo.getProProjectApply()); + } Task task = taskService.createTaskQuery().taskId(taskVo.getTaskId()).singleResult(); if (Objects.isNull(task)) { return AjaxResult.error("任务不存在"); } if (DelegationState.PENDING.equals(task.getDelegationState())) { taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.DELEGATE.getType(), taskVo.getComment()); - taskService.resolveTask(taskVo.getTaskId(), taskVo.getVariables()); + taskService.resolveTask(taskVo.getTaskId()); } else { + Long userId = SecurityUtils.getUserId(); taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.NORMAL.getType(), taskVo.getComment()); - Long userId = SecurityUtils.getLoginUser().getUser().getUserId(); - taskService.setAssignee(taskVo.getTaskId(), userId.toString()); - taskService.complete(taskVo.getTaskId(), taskVo.getVariables()); + taskService.setAssignee(taskVo.getTaskId(), Convert.toStr(userId)); + taskService.complete(taskVo.getTaskId()); } return AjaxResult.success(); } diff --git a/yanzhu-ui/src/api/flowable/todo.js b/yanzhu-ui/src/api/flowable/todo.js index 276977b..335262e 100644 --- a/yanzhu-ui/src/api/flowable/todo.js +++ b/yanzhu-ui/src/api/flowable/todo.js @@ -123,6 +123,7 @@ export function exportDeployment(query) { params: query }) } + // 流程节点表单 export function flowTaskForm(query) { return request({ @@ -131,3 +132,13 @@ export function flowTaskForm(query) { params: query }) } + +// 完成任务并修改表单 +export function completeAndModify(data) { + return request({ + url: '/flowable/task/completeAndModify', + method: 'post', + data: data + }) +} + diff --git a/yanzhu-ui/src/views/flowable/task/myProcess/detail/detailDrawer.vue b/yanzhu-ui/src/views/flowable/task/myProcess/detail/detailDrawer.vue index 531ac4f..d448400 100644 --- a/yanzhu-ui/src/views/flowable/task/myProcess/detail/detailDrawer.vue +++ b/yanzhu-ui/src/views/flowable/task/myProcess/detail/detailDrawer.vue @@ -20,7 +20,7 @@
- + - {{ parseTime(initData.createTime, "{y}-{m}-{d} {h}:{i}") }} + {{ options.createTime }} {{ parseTime(initData.useTime, "{y}-{m}-{d} {h}:{i}") }} @@ -523,7 +523,7 @@ export default { } .containers { width: 100%; - height: 150px; + height: 100px; .canvas { width: 100%; height: 100px; @@ -548,7 +548,7 @@ export default { } .djs-container svg { - min-height: 150px; + min-height: 100px; } .highlight.djs-shape .djs-visual > :nth-child(1) { diff --git a/yanzhu-ui/src/views/flowable/task/myProcess/editTaskDrawer.vue b/yanzhu-ui/src/views/flowable/task/myProcess/editTaskDrawer.vue index 385c519..d9b0a4b 100644 --- a/yanzhu-ui/src/views/flowable/task/myProcess/editTaskDrawer.vue +++ b/yanzhu-ui/src/views/flowable/task/myProcess/editTaskDrawer.vue @@ -1,379 +1,863 @@ - - - - \ No newline at end of file + .containers { + width: 100%; + height: 100px; + .canvas { + width: 100%; + height: 100px; + } + .panel { + position: absolute; + right: 0; + top: 50px; + width: 300px; + } + .load { + margin-right: 10px; + } + .el-form-item__label { + font-size: 13px; + } + .djs-palette { + left: 0px !important; + top: 0px; + border-top: none; + } + .djs-container svg { + min-height: 100px; + } + .highlight.djs-shape .djs-visual > :nth-child(1) { + fill: green !important; + stroke: green !important; + fill-opacity: 0.2 !important; + } + .highlight.djs-shape .djs-visual > :nth-child(2) { + fill: green !important; + } + .highlight.djs-shape .djs-visual > path { + fill: green !important; + fill-opacity: 0.2 !important; + stroke: green !important; + } + .highlight.djs-connection > .djs-visual > path { + stroke: green !important; + } + .highlight-todo.djs-connection > .djs-visual > path { + stroke: orange !important; + stroke-dasharray: 4px !important; + fill-opacity: 0.2 !important; + } + .highlight-todo.djs-shape .djs-visual > :nth-child(1) { + fill: orange !important; + stroke: orange !important; + stroke-dasharray: 4px !important; + fill-opacity: 0.2 !important; + } + .overlays-div { + font-size: 10px; + color: red; + width: 100px; + top: -20px !important; + } + } +} + diff --git a/yanzhu-ui/src/views/flowable/task/myProcess/index.vue b/yanzhu-ui/src/views/flowable/task/myProcess/index.vue index 0cf8229..3ac9e58 100644 --- a/yanzhu-ui/src/views/flowable/task/myProcess/index.vue +++ b/yanzhu-ui/src/views/flowable/task/myProcess/index.vue @@ -148,7 +148,7 @@ v{{ scope.row.procDefVersion }} - + -
+
提交申请 取 消
@@ -216,7 +217,7 @@ export default { form: { id: null, deptId: null, - projId: null, + projId: 0, projName: null, parProjName: null, applyType: null, @@ -281,6 +282,7 @@ export default { }, // 项目选择 projectChage(val) { + this.$forceUpdate(); for (let i = 0; i < this.projectOptions.length; i++) { if (this.projectOptions[i].id == val) { this.form.projName = this.projectOptions[i].name; diff --git a/yanzhu-ui/src/views/flowable/task/todo/index.vue b/yanzhu-ui/src/views/flowable/task/todo/index.vue index e45d782..871f359 100644 --- a/yanzhu-ui/src/views/flowable/task/todo/index.vue +++ b/yanzhu-ui/src/views/flowable/task/todo/index.vue @@ -68,7 +68,7 @@ - + - - + + + + + + + + - + - + + + + @@ -210,26 +241,20 @@ export default { this.queryParams.params["endDate"] = this.daterangeCheckTime[1]; } //重新刷新代办任务 - this.$store.dispatch('initMyTaskNum'); + this.$store.dispatch("initMyTaskNum"); myAwaitFlowTaskList(this.queryParams).then((response) => { - this.todoList = response.data.records; - this.total = response.data.total; + this.todoList = response.rows; + this.total = response.total; this.loading = false; }); }, // 跳转到处理页面 handleProcess(row) { - this.$router.push({ - path: "/flowable/task/todo/detail/index", - query: { - procInsId: row.procInsId, - executionId: row.executionId, - deployId: row.deployId, - taskId: row.taskId, - taskName: row.taskName, - startUser: row.startUserName + "-" + row.startDeptName, - }, - }); + //if (row.taskName == "提交申请") { + this.$refs.editTaskDrawer.show(row); + //} else { + // this.$refs.approveDrawer.show(row); + //} }, // 取消按钮 cancel() { @@ -250,7 +275,7 @@ export default { parentDeploymentId: null, engineVersion: null, }; - this.daterangeCheckTime=[]; + this.daterangeCheckTime = []; this.resetForm("form"); }, /** 搜索按钮操作 */ @@ -261,7 +286,7 @@ export default { /** 重置按钮操作 */ resetQuery() { this.resetForm("queryForm"); - this.daterangeCheckTime=[]; + this.daterangeCheckTime = []; this.handleQuery(); }, // 多选框选中数据