diff --git a/.gitignore b/.gitignore index b425f09ad0e75e91fc43f1aee01bb3a918eec8c0..dd86af7f607cc8cf03d56f3db66f43ce045f5017 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,6 @@ build/ .vscode/ ### Mac OS ### -.DS_Store \ No newline at end of file +.DS_Store + +logs \ No newline at end of file diff --git a/src/main/java/com/qjl/parser/logicflow/LogicFlowParser.java b/src/main/java/com/qjl/parser/logicflow/LogicFlowParser.java index cf942eda0c533fa971f7a0f45a82c074a3475a73..6dee838ee60a93cdbf31bdbe70baaffcbd3ffeb5 100644 --- a/src/main/java/com/qjl/parser/logicflow/LogicFlowParser.java +++ b/src/main/java/com/qjl/parser/logicflow/LogicFlowParser.java @@ -1,5 +1,6 @@ package com.qjl.parser.logicflow; +import com.google.common.collect.Sets; import com.qjl.core.ELNode; import com.qjl.parser.ELParser; import lombok.Data; @@ -437,6 +438,13 @@ public class LogicFlowParser implements ELParser { */ private String findWhenContainAnyOne(Set childrenInWhen, Set targetIds) { Map nodeMap = context.getNodeMap(); + //先看是否有包含所有targetIds的when组件 + for (String whenId : childrenInWhen) { + LfNode lfNode = nodeMap.get(whenId); + if (lfNode != null && Sets.newHashSet(getAllChildNodeInWhen(lfNode)).containsAll(targetIds)) { + return whenId; + } + } for (String whenId : childrenInWhen) { LfNode lfNode = nodeMap.get(whenId); if (lfNode == null) { diff --git a/src/main/resources/json/json0525.json b/src/main/resources/json/json0525.json new file mode 100644 index 0000000000000000000000000000000000000000..758d5317e748db491a758195fdb0f78425dde852 --- /dev/null +++ b/src/main/resources/json/json0525.json @@ -0,0 +1,685 @@ +{ + "nodes": [ + { + "id": "N2", + "type": "CommonNode", + "x": 360, + "y": 380, + "properties": { + "nodeType": "COMMON", + "nodeId": "N2" + }, + "text": { + "x": 360, + "y": 380, + "value": "N2" + } + }, + { + "id": "N4", + "type": "CommonNode", + "x": 760, + "y": 120, + "properties": { + "nodeType": "COMMON", + "nodeId": "N4" + }, + "text": { + "x": 760, + "y": 120, + "value": "N4" + } + }, + { + "id": "N6", + "type": "CommonNode", + "x": 780, + "y": 240, + "properties": { + "nodeType": "COMMON", + "nodeId": "N6" + }, + "text": { + "x": 780, + "y": 240, + "value": "N6" + } + }, + { + "id": "N8", + "type": "CommonNode", + "x": 780, + "y": 380, + "properties": { + "nodeType": "COMMON", + "nodeId": "N8" + }, + "text": { + "x": 780, + "y": 380, + "value": "N8" + } + }, + { + "id": "N10", + "type": "CommonNode", + "x": 800, + "y": 500, + "properties": { + "nodeType": "COMMON", + "nodeId": "N10" + }, + "text": { + "x": 800, + "y": 500, + "value": "N10" + } + }, + { + "id": "N12", + "type": "CommonNode", + "x": 960, + "y": 600, + "properties": { + "nodeType": "COMMON", + "nodeId": "N12" + }, + "text": { + "x": 960, + "y": 600, + "value": "N12" + } + }, + { + "id": "N14", + "type": "CommonNode", + "x": 1100, + "y": 180, + "properties": { + "nodeType": "COMMON", + "nodeId": "N14" + }, + "text": { + "x": 1100, + "y": 180, + "value": "N14" + } + }, + { + "id": "N16", + "type": "CommonNode", + "x": 1120, + "y": 380, + "properties": { + "nodeType": "COMMON", + "nodeId": "N16" + }, + "text": { + "x": 1120, + "y": 380, + "value": "N16" + } + }, + { + "id": "N18", + "type": "CommonNode", + "x": 1440, + "y": 220, + "properties": { + "nodeType": "COMMON", + "nodeId": "N18" + }, + "text": { + "x": 1440, + "y": 220, + "value": "N18" + } + }, + { + "id": "N20", + "type": "CommonNode", + "x": 1380, + "y": 580, + "properties": { + "nodeType": "COMMON", + "nodeId": "N20" + }, + "text": { + "x": 1380, + "y": 580, + "value": "N20" + } + }, + { + "id": "N22", + "type": "CommonNode", + "x": 1680, + "y": 420, + "properties": { + "nodeType": "COMMON", + "nodeId": "N22" + }, + "text": { + "x": 1680, + "y": 420, + "value": "N22" + } + }, + { + "id": "W1", + "type": "WhenGroupNode", + "x": 762, + "y": 179.5, + "properties": { + "nodeType": "WHEN", + "nodeSize": { + "width": 297, + "height": 224 + } + }, + "children": [ + "N4", + "N6" + ] + }, + { + "id": "W2", + "type": "WhenGroupNode", + "x": 840, + "y": 540, + "properties": { + "nodeType": "WHEN", + "nodeSize": { + "width": 384, + "height": 206 + } + }, + "children": [ + "N10", + "N12" + ] + }, + { + "id": "W3", + "type": "WhenGroupNode", + "x": 900, + "y": 240, + "properties": { + "nodeType": "WHEN", + "nodeSize": { + "width": 685, + "height": 380 + } + }, + "children": [ + "W1", + "N8", + "N14", + "N16" + ] + }, + { + "id": "W4", + "type": "WhenGroupNode", + "x": 1000, + "y": 340, + "properties": { + "nodeType": "WHEN", + "nodeSize": { + "width": 1023, + "height": 648 + } + }, + "children": [ + "W2", + "W3", + "N18", + "N20" + ] + } + ], + "edges": [ + { + "id": "9f065130-e2e3-449c-9935-86570e7a0921", + "type": "polyline", + "sourceNodeId": "N2", + "targetNodeId": "N4", + "startPoint": { + "x": 420, + "y": 380 + }, + "endPoint": { + "x": 700, + "y": 120 + }, + "properties": {}, + "pointsList": [ + { + "x": 420, + "y": 380 + }, + { + "x": 451, + "y": 380 + }, + { + "x": 451, + "y": 120 + }, + { + "x": 700, + "y": 120 + } + ] + }, + { + "id": "1bb4af96-975b-446e-bda0-5746beaf5c16", + "type": "polyline", + "sourceNodeId": "N2", + "targetNodeId": "N6", + "startPoint": { + "x": 420, + "y": 380 + }, + "endPoint": { + "x": 720, + "y": 240 + }, + "properties": {}, + "pointsList": [ + { + "x": 420, + "y": 380 + }, + { + "x": 450, + "y": 380 + }, + { + "x": 450, + "y": 240 + }, + { + "x": 720, + "y": 240 + } + ] + }, + { + "id": "6b3e0697-d338-46f9-a30c-da952e8170e4", + "type": "polyline", + "sourceNodeId": "N2", + "targetNodeId": "N8", + "startPoint": { + "x": 420, + "y": 380 + }, + "endPoint": { + "x": 720, + "y": 380 + }, + "properties": {}, + "pointsList": [ + { + "x": 420, + "y": 380 + }, + { + "x": 720, + "y": 380 + } + ] + }, + { + "id": "baa4844a-8c25-4d1e-9515-c3dc3fa9800d", + "type": "polyline", + "sourceNodeId": "N2", + "targetNodeId": "N10", + "startPoint": { + "x": 420, + "y": 380 + }, + "endPoint": { + "x": 740, + "y": 500 + }, + "properties": {}, + "pointsList": [ + { + "x": 420, + "y": 380 + }, + { + "x": 450, + "y": 380 + }, + { + "x": 450, + "y": 500 + }, + { + "x": 740, + "y": 500 + } + ] + }, + { + "id": "08a1e5d7-d21e-4e7d-9c67-88bbb6273887", + "type": "polyline", + "sourceNodeId": "N2", + "targetNodeId": "N12", + "startPoint": { + "x": 420, + "y": 380 + }, + "endPoint": { + "x": 900, + "y": 600 + }, + "properties": {}, + "pointsList": [ + { + "x": 420, + "y": 380 + }, + { + "x": 450, + "y": 380 + }, + { + "x": 450, + "y": 600 + }, + { + "x": 900, + "y": 600 + } + ] + }, + { + "id": "8ab4265f-af99-4d22-8ea5-7dba96f2de68", + "type": "polyline", + "sourceNodeId": "N4", + "targetNodeId": "N14", + "startPoint": { + "x": 820, + "y": 120 + }, + "endPoint": { + "x": 1040, + "y": 180 + }, + "properties": {}, + "pointsList": [ + { + "x": 820, + "y": 120 + }, + { + "x": 930, + "y": 120 + }, + { + "x": 930, + "y": 180 + }, + { + "x": 1040, + "y": 180 + } + ] + }, + { + "id": "98c0b73c-48d6-451c-87d5-8a8118806244", + "type": "polyline", + "sourceNodeId": "N6", + "targetNodeId": "N14", + "startPoint": { + "x": 840, + "y": 240 + }, + "endPoint": { + "x": 1040, + "y": 180 + }, + "properties": {}, + "pointsList": [ + { + "x": 840, + "y": 240 + }, + { + "x": 931, + "y": 240 + }, + { + "x": 931, + "y": 180 + }, + { + "x": 1040, + "y": 180 + } + ] + }, + { + "id": "3946346e-282c-4bcf-bb37-d6a16680be75", + "type": "polyline", + "sourceNodeId": "N8", + "targetNodeId": "N16", + "startPoint": { + "x": 840, + "y": 380 + }, + "endPoint": { + "x": 1060, + "y": 380 + }, + "properties": {}, + "pointsList": [ + { + "x": 840, + "y": 380 + }, + { + "x": 1060, + "y": 380 + } + ] + }, + { + "id": "298e891f-985d-4c98-976d-77dd2e35b825", + "type": "polyline", + "sourceNodeId": "N14", + "targetNodeId": "N18", + "startPoint": { + "x": 1160, + "y": 180 + }, + "endPoint": { + "x": 1380, + "y": 220 + }, + "properties": {}, + "pointsList": [ + { + "x": 1160, + "y": 180 + }, + { + "x": 1270, + "y": 180 + }, + { + "x": 1270, + "y": 220 + }, + { + "x": 1380, + "y": 220 + } + ] + }, + { + "id": "53832fd3-75f8-4a68-9178-7f99516da2f2", + "type": "polyline", + "sourceNodeId": "N16", + "targetNodeId": "N18", + "startPoint": { + "x": 1180, + "y": 380 + }, + "endPoint": { + "x": 1380, + "y": 220 + }, + "properties": {}, + "pointsList": [ + { + "x": 1180, + "y": 380 + }, + { + "x": 1271, + "y": 380 + }, + { + "x": 1271, + "y": 220 + }, + { + "x": 1380, + "y": 220 + } + ] + }, + { + "id": "08843d3a-9584-45ea-98be-c4dd6e2eb31f", + "type": "polyline", + "sourceNodeId": "N10", + "targetNodeId": "N20", + "startPoint": { + "x": 860, + "y": 496 + }, + "endPoint": { + "x": 1380, + "y": 540 + }, + "properties": {}, + "pointsList": [ + { + "x": 860, + "y": 496 + }, + { + "x": 1380, + "y": 496 + }, + { + "x": 1380, + "y": 540 + } + ] + }, + { + "id": "58e6d95d-5767-41c1-9a13-85e583d4ed5c", + "type": "polyline", + "sourceNodeId": "N12", + "targetNodeId": "N20", + "startPoint": { + "x": 1020, + "y": 600 + }, + "endPoint": { + "x": 1320, + "y": 583 + }, + "properties": {}, + "pointsList": [ + { + "x": 1020, + "y": 600 + }, + { + "x": 1170, + "y": 600 + }, + { + "x": 1170, + "y": 583 + }, + { + "x": 1320, + "y": 583 + } + ] + }, + { + "id": "e6fedb1d-a80e-42e8-b1ec-0ff0b3830da6", + "type": "polyline", + "sourceNodeId": "N20", + "targetNodeId": "N22", + "startPoint": { + "x": 1440, + "y": 580 + }, + "endPoint": { + "x": 1620, + "y": 420 + }, + "properties": {}, + "pointsList": [ + { + "x": 1440, + "y": 580 + }, + { + "x": 1590, + "y": 580 + }, + { + "x": 1590, + "y": 420 + }, + { + "x": 1620, + "y": 420 + } + ] + }, + { + "id": "3ee121f4-ed9e-4009-83ae-7df8273a4364", + "type": "polyline", + "sourceNodeId": "N18", + "targetNodeId": "N22", + "startPoint": { + "x": 1500, + "y": 220 + }, + "endPoint": { + "x": 1620, + "y": 420 + }, + "properties": {}, + "pointsList": [ + { + "x": 1500, + "y": 220 + }, + { + "x": 1590, + "y": 220 + }, + { + "x": 1590, + "y": 420 + }, + { + "x": 1620, + "y": 420 + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 0000000000000000000000000000000000000000..12e1ffb44841c5f1b095d3a4afd2fdf4acbbb38f --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + + ${LOG_PATH:-./logs}/application.log + + ${LOG_PATH:-./logs}/application.%d{yyyy-MM-dd}.%i.log + + 250MB + + 30 + + + + %d{ISO8601} [%X{sequenceId:-}][%X{traceId:-}] [%t] %-5level %logger{36} - %msg %n + + + + + + + + + diff --git a/src/test/java/com/qjl/TestParser.java b/src/test/java/com/qjl/TestParser.java index 696e2147d3c6a5a0508f61d8a10bbfb6c4eb6d14..512be138260e5e6129f65854db71b912bb799edb 100644 --- a/src/test/java/com/qjl/TestParser.java +++ b/src/test/java/com/qjl/TestParser.java @@ -4,11 +4,17 @@ import cn.hutool.core.io.resource.ResourceUtil; import com.qjl.core.ELNode; import com.qjl.core.ExpressLanguageParseException; import com.qjl.parser.ELParser; +import com.qjl.parser.logicflow.LfNode; +import com.qjl.parser.logicflow.LfNodePropertyEnum; import com.qjl.parser.logicflow.LogicFlow; import com.qjl.parser.logicflow.LogicFlowParser; import com.qjl.util.Json2ELNodeParser; import org.junit.Test; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + /** * @author : zhangrongyan * @date : 2023/1/13 14:02 @@ -29,7 +35,14 @@ public class TestParser { ELParser parser = new LogicFlowParser(logicFlow); ELNode elNodeFromLogicFlowData = parser.extractElNode(); try { - System.out.println(elNodeFromLogicFlowData.generateEl()); + String el = elNodeFromLogicFlowData.generateEl(); + System.out.println(el); + List missingNodeIds = logicFlow.getNodes().stream().map(LfNode::getProperties) + .map(e -> e.get(LfNodePropertyEnum.nodeId.name())).filter(Objects::nonNull) + .map(Object::toString).filter(e -> !el.contains(e)).collect(Collectors.toList()); + if(!missingNodeIds.isEmpty()) { + throw new ExpressLanguageParseException("nodes missing " + missingNodeIds); + } } catch (ExpressLanguageParseException e) { e.printStackTrace(); } @@ -72,4 +85,9 @@ public class TestParser { public void testLogicFlowBugDataToElNode0427() throws ExpressLanguageParseException { doWithLogicFlowJson("json/bug0427.json"); } + + @Test + public void testLogicFlowBugDataToElNode0525() throws ExpressLanguageParseException { + doWithLogicFlowJson("json/json0525.json"); + } }