昨晚升级代码生成器,支持生成权限注解和菜单的SQL,修改驳回bug,以后保存流程强制要求第一个用户任务节点必须是发起人节点。
1、前端增加发起人设置
<el-radio label="INITIATOR">发起人</el-radio>
相应代码
if (this.containsKey(this.bpmnElement.businessObject, 'assignee') && this.bpmnElement.businessObject.assignee === '${INITIATOR}') { this.defaultTaskForm.dataType = "INITIATOR"; } changeDataType(val) { if (val === 'INITIATOR') { this.userTaskForm.assignee = "${INITIATOR}"; this.userTaskForm.text = "流程发起人"; const taskAttr = Object.create(null); taskAttr['assignee'] = this.userTaskForm['assignee'] || null; window.bpmnInstances.modeling.updateProperties(this.bpmnElement, taskAttr); }
2、后端流程保存修改
//传节点定义key获取当前节点 List<org.flowable.bpmn.model.Process> processes = bpmnModel.getProcesses(); //查看第一个用户任务节点是否是发起人节点 List<FlowNode> flowNodes = processes.get(0).findFlowElementsOfType(FlowNode.class); List<SequenceFlow> outgoingFlows = flowNodes.get(0).getOutgoingFlows(); //遍历返回下一个节点信息 for (SequenceFlow outgoingFlow : outgoingFlows) { //类型自己判断(获取下个节点是任务节点) FlowElement targetFlowElement = outgoingFlow.getTargetFlowElement(); //下个是节点 if(targetFlowElement instanceof UserTask){// 下个出口是用户任务,而且是要发起人节点才让保存 if(StringUtils.equals(((UserTask) targetFlowElement).getAssignee(), "${INITIATOR}")) { break; } else { return Result.error("导入失败,流程第一个用户任务节点必须是发起人节点"); } } }
3、后端发起流程修改
SysUser sysUser = iFlowThirdService.getLoginUser(); identityService.setAuthenticatedUserId(sysUser.getUsername()); variables.put(ProcessConstants.PROCESS_INITIATOR, sysUser.getUsername());
4、后端驳回修改
if (StrUtil.equals(targetUserTask.getAssignee().toString(),"${INITIATOR}")) {//是否为发起人节点 //开始节点 设置处理人为申请人 taskService.setAssignee(targetTask.getId(), startUserId); }
5、效果图