From 1ba632774741f51ac5fea6cbfd20300999df44a0 Mon Sep 17 00:00:00 2001 From: konbai <1527468660@qq.com> Date: Sun, 15 Jan 2023 00:47:06 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=B7=A5=E4=BD=9C=E6=B5=81=E6=A8=A1?= =?UTF-8?q?=E5=9D=97):=20ModelUtils=20=E5=B7=A5=E5=85=B7=E7=B1=BB=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=8E=B7=E5=8F=96=E5=85=83=E7=B4=A0=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/flowable/utils/ModelUtils.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/utils/ModelUtils.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/utils/ModelUtils.java index 76d66a85..9a51125d 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/utils/ModelUtils.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/utils/ModelUtils.java @@ -130,6 +130,61 @@ public class ModelUtils { return null; } + /** + * 获取开始节点属性值 + * @param model bpmnModel对象 + * @param name 属性名 + * @return 属性值 + */ + public static String getStartEventAttributeValue(BpmnModel model, String name) { + StartEvent startEvent = getStartEvent(model); + return getElementAttributeValue(startEvent, name); + } + + /** + * 获取结束节点属性值 + * @param model bpmnModel对象 + * @param name 属性名 + * @return 属性值 + */ + public static String getEndEventAttributeValue(BpmnModel model, String name) { + EndEvent endEvent = getEndEvent(model); + return getElementAttributeValue(endEvent, name); + } + + /** + * 获取用户任务节点属性值 + * @param model bpmnModel对象 + * @param taskKey 任务Key + * @param name 属性名 + * @return 属性值 + */ + public static String getUserTaskAttributeValue(BpmnModel model, String taskKey, String name) { + UserTask userTask = getUserTaskByKey(model, taskKey); + return getElementAttributeValue(userTask, name); + } + + /** + * 获取元素属性值 + * @param baseElement 流程元素 + * @param name 属性名 + * @return 属性值 + */ + public static String getElementAttributeValue(BaseElement baseElement, String name) { + if (baseElement != null) { + List attributes = baseElement.getAttributes().get(name); + if (attributes != null && !attributes.isEmpty()) { + attributes.iterator().next().getValue(); + Iterator attrIterator = attributes.iterator(); + if(attrIterator.hasNext()) { + ExtensionAttribute attribute = attrIterator.next(); + return attribute.getValue(); + } + } + } + return null; + } + public static boolean isMultiInstance(BpmnModel model, String taskKey) { UserTask userTask = getUserTaskByKey(model, taskKey); if (ObjectUtil.isNotNull(userTask)) {