1.修改拼写错误

This commit is contained in:
chenweilong 2022-12-19 11:58:02 +08:00
parent 1e01f892a3
commit 4c9ca48b37
6 changed files with 28 additions and 28 deletions

View File

@ -13,7 +13,7 @@ import com.example.liteflow.mysql.model.rule.Rule;
import com.example.liteflow.mysql.service.BaseDataService; import com.example.liteflow.mysql.service.BaseDataService;
import com.example.liteflow.mysql.service.BaseNodeService; import com.example.liteflow.mysql.service.BaseNodeService;
import com.example.liteflow.mysql.util.ConditionParser; import com.example.liteflow.mysql.util.ConditionParser;
import com.example.liteflow.mysql.util.RoleUtil; import com.example.liteflow.mysql.util.RuleUtil;
import com.googlecode.aviator.AviatorEvaluator; import com.googlecode.aviator.AviatorEvaluator;
import com.yomahub.liteflow.core.NodeIfComponent; import com.yomahub.liteflow.core.NodeIfComponent;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -48,12 +48,12 @@ public class CenterCmp extends NodeIfComponent {
String nodeName = this.getName(); String nodeName = this.getName();
log.info("nodeId = {}, nodeName = {}", nodeId, nodeName); log.info("nodeId = {}, nodeName = {}", nodeId, nodeName);
BaseNodeEntity baseNodeEntity = baseNodeService.getByNodeId(nodeId); BaseNodeEntity baseNodeEntity = baseNodeService.getByNodeId(nodeId);
if (ObjectUtil.isNotNull(baseNodeEntity) && StrUtil.isNotBlank(baseNodeEntity.getNodeRole())) { if (ObjectUtil.isNotNull(baseNodeEntity) && StrUtil.isNotBlank(baseNodeEntity.getNodeRule())) {
String nodeRole = baseNodeEntity.getNodeRole(); String nodeRule = baseNodeEntity.getNodeRule();
String templateId = baseNodeEntity.getTemplateId(); String templateId = baseNodeEntity.getTemplateId();
log.info("nodeRole = {}", nodeRole); log.info("nodeRule = {}", nodeRule);
List<Rule> rules = JSONUtil.toList(JSONUtil.parseArray(nodeRole), Rule.class); List<Rule> rules = JSONUtil.toList(JSONUtil.parseArray(nodeRule), Rule.class);
List<Map<String, Object>> collect = rules.stream().map(RoleUtil::parseRole).collect(Collectors.toList()); List<Map<String, Object>> collect = rules.stream().map(RuleUtil::parseRule).collect(Collectors.toList());
String droolStr = JSONUtil.toJsonStr(collect); String droolStr = JSONUtil.toJsonStr(collect);
// 替换规则中的关键字 // 替换规则中的关键字

View File

@ -53,8 +53,8 @@ public class BaseNodeEntity {
/** /**
* 节点规则 * 节点规则
*/ */
@TableField("node_role") @TableField("node_rule")
private String nodeRole; private String nodeRule;
/** /**
* 节点对应输出节点id * 节点对应输出节点id
*/ */

View File

@ -48,7 +48,7 @@ public class BaseNodeVO {
/** /**
* 节点规则 * 节点规则
*/ */
private String nodeRole; private String nodeRule;
/** /**
* 节点对应输出节点id * 节点对应输出节点id
*/ */

View File

@ -66,7 +66,7 @@ public class BaseNodeServiceImpl extends ServiceImpl<BaseNodeMapper, BaseNodeEnt
List<Rule> rules = createNodeFrom.getRules(); List<Rule> rules = createNodeFrom.getRules();
OutputFrom content = createNodeFrom.getContent(); OutputFrom content = createNodeFrom.getContent();
if (CollUtil.isNotEmpty(rules) && NodeEnum.IfNode.getName().equals(nodeType)) { if (CollUtil.isNotEmpty(rules) && NodeEnum.IfNode.getName().equals(nodeType)) {
baseNodeEntity.setNodeRole(JSONUtil.toJsonStr(rules)); baseNodeEntity.setNodeRule(JSONUtil.toJsonStr(rules));
} else if (ObjectUtil.isNotNull(content) && NodeEnum.CommonNode.getName().equals(nodeType)) { } else if (ObjectUtil.isNotNull(content) && NodeEnum.CommonNode.getName().equals(nodeType)) {
baseNodeEntity.setNodeContent(JSONUtil.toJsonStr(content)); baseNodeEntity.setNodeContent(JSONUtil.toJsonStr(content));
} else { } else {
@ -83,14 +83,14 @@ public class BaseNodeServiceImpl extends ServiceImpl<BaseNodeMapper, BaseNodeEnt
String nodeContentId = updateNodeFrom.getNodeContentId(); String nodeContentId = updateNodeFrom.getNodeContentId();
Integer enableMark = updateNodeFrom.getEnableMark(); Integer enableMark = updateNodeFrom.getEnableMark();
List<Rule> rules = updateNodeFrom.getRules(); List<Rule> rules = updateNodeFrom.getRules();
String roleStr = ObjectUtil.isNotNull(rules) ? JSONUtil.toJsonStr(rules) : ""; String ruleStr = ObjectUtil.isNotNull(rules) ? JSONUtil.toJsonStr(rules) : "";
OutputFrom content = updateNodeFrom.getContent(); OutputFrom content = updateNodeFrom.getContent();
String contentStr = ObjectUtil.isNotNull(content) ? JSONUtil.toJsonStr(content) : ""; String contentStr = ObjectUtil.isNotNull(content) ? JSONUtil.toJsonStr(content) : "";
LambdaUpdateWrapper<BaseNodeEntity> updateWrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<BaseNodeEntity> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(BaseNodeEntity::getId, id) updateWrapper.eq(BaseNodeEntity::getId, id)
.set(BaseNodeEntity::getEnableMark, enableMark) .set(BaseNodeEntity::getEnableMark, enableMark)
.set(StrUtil.isNotBlank(contentStr), BaseNodeEntity::getNodeContent, contentStr) .set(StrUtil.isNotBlank(contentStr), BaseNodeEntity::getNodeContent, contentStr)
.set(StrUtil.isNotBlank(roleStr), BaseNodeEntity::getNodeRole, roleStr) .set(StrUtil.isNotBlank(ruleStr), BaseNodeEntity::getNodeRule, ruleStr)
.set(StrUtil.isNotBlank(nodeContentId), BaseNodeEntity::getNodeContentId, nodeContentId); .set(StrUtil.isNotBlank(nodeContentId), BaseNodeEntity::getNodeContentId, nodeContentId);
try { try {
this.update(updateWrapper); this.update(updateWrapper);

View File

@ -14,14 +14,14 @@ import java.util.stream.Collectors;
* @author: 陈韦龙 * @author: 陈韦龙
* @date: 2022年12月08日 15:37 * @date: 2022年12月08日 15:37
*/ */
public class RoleUtil { public class RuleUtil {
/** /**
* 规则解析 * 规则解析
* *
* @param rule 规则 * @param rule 规则
* @return Map<String, Object> * @return Map<String, Object>
*/ */
public static Map<String, Object> parseRole(Rule rule) { public static Map<String, Object> parseRule(Rule rule) {
List<Match> matchList = rule.getMatches(); List<Match> matchList = rule.getMatches();
List<Rule> ruleChildren = rule.getChildren(); List<Rule> ruleChildren = rule.getChildren();
String logicOperators = rule.getLogicOperators(); String logicOperators = rule.getLogicOperators();
@ -31,7 +31,7 @@ public class RoleUtil {
List<Rule> sunList = child.getChildren(); List<Rule> sunList = child.getChildren();
// 存在子嵌套子的情况 // 存在子嵌套子的情况
if (CollUtil.isNotEmpty(sunList)) { if (CollUtil.isNotEmpty(sunList)) {
List<Map<String, Object>> sunCollect = sunList.stream().map(RoleUtil::parseRole).collect(Collectors.toList()); List<Map<String, Object>> sunCollect = sunList.stream().map(RuleUtil::parseRule).collect(Collectors.toList());
String childLogicOperators = child.getLogicOperators(); String childLogicOperators = child.getLogicOperators();
Map<String, Object> itemMap = new HashMap<>(); Map<String, Object> itemMap = new HashMap<>();
itemMap.put(childLogicOperators, sunCollect); itemMap.put(childLogicOperators, sunCollect);

View File

@ -51,7 +51,7 @@ public class MyTest {
rules.add(rule); rules.add(rule);
System.out.println(JSONUtil.toJsonStr(rules)); System.out.println(JSONUtil.toJsonStr(rules));
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList()); List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRule).collect(Collectors.toList());
System.out.println(JSONUtil.toJsonStr(collect)); System.out.println(JSONUtil.toJsonStr(collect));
} }
@ -92,7 +92,7 @@ public class MyTest {
rules.add(rule); rules.add(rule);
System.out.println(JSONUtil.toJsonStr(rules)); System.out.println(JSONUtil.toJsonStr(rules));
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList()); List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRule).collect(Collectors.toList());
System.out.println(JSONUtil.toJsonStr(collect)); System.out.println(JSONUtil.toJsonStr(collect));
} }
@ -113,7 +113,7 @@ public class MyTest {
rule.setMatches(matches); rule.setMatches(matches);
List<Rule> rules = Lists.newArrayList(rule); List<Rule> rules = Lists.newArrayList(rule);
System.out.println(JSONUtil.toJsonStr(rules)); System.out.println(JSONUtil.toJsonStr(rules));
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList()); List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRule).collect(Collectors.toList());
System.out.println(JSONUtil.toJsonStr(collect)); System.out.println(JSONUtil.toJsonStr(collect));
} }
@ -138,7 +138,7 @@ public class MyTest {
rule.setMatches(matches); rule.setMatches(matches);
List<Rule> rules = Lists.newArrayList(rule); List<Rule> rules = Lists.newArrayList(rule);
System.out.println(JSONUtil.toJsonStr(rules)); System.out.println(JSONUtil.toJsonStr(rules));
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList()); List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRule).collect(Collectors.toList());
System.out.println(JSONUtil.toJsonStr(collect)); System.out.println(JSONUtil.toJsonStr(collect));
} }
@ -153,7 +153,7 @@ public class MyTest {
List<Rule> rules = Lists.newArrayList(rule); List<Rule> rules = Lists.newArrayList(rule);
System.out.println(JSONUtil.toJsonStr(rules)); System.out.println(JSONUtil.toJsonStr(rules));
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList()); List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRule).collect(Collectors.toList());
System.out.println(JSONUtil.toJsonStr(collect)); System.out.println(JSONUtil.toJsonStr(collect));
} }
@ -205,7 +205,7 @@ public class MyTest {
List<Rule> rules = Lists.newArrayList(rule, rule2); List<Rule> rules = Lists.newArrayList(rule, rule2);
System.out.println(JSONUtil.toJsonStr(rules)); System.out.println(JSONUtil.toJsonStr(rules));
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList()); List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRule).collect(Collectors.toList());
System.out.println(JSONUtil.toJsonStr(collect)); System.out.println(JSONUtil.toJsonStr(collect));
} }
@ -247,8 +247,8 @@ public class MyTest {
rule.setChildren(children); rule.setChildren(children);
List<Rule> rules = Lists.newArrayList(rule); List<Rule> rules = Lists.newArrayList(rule);
// System.out.println(JSONUtil.toJsonStr(roles)); // System.out.println(JSONUtil.toJsonStr(rules));
// List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList()); // List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList());
// System.out.println(JSONUtil.toJsonStr(collect)); // System.out.println(JSONUtil.toJsonStr(collect));
} }
@ -294,7 +294,7 @@ public class MyTest {
List<Rule> rules = Lists.newArrayList(rule, rule2); List<Rule> rules = Lists.newArrayList(rule, rule2);
System.out.println(JSONUtil.toJsonStr(rules)); System.out.println(JSONUtil.toJsonStr(rules));
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList()); List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRule).collect(Collectors.toList());
System.out.println(JSONUtil.toJsonStr(collect)); System.out.println(JSONUtil.toJsonStr(collect));
} }
@ -351,7 +351,7 @@ public class MyTest {
List<Rule> rules = Lists.newArrayList(rule, rule2); List<Rule> rules = Lists.newArrayList(rule, rule2);
System.out.println(JSONUtil.toJsonStr(rules)); System.out.println(JSONUtil.toJsonStr(rules));
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList()); List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRule).collect(Collectors.toList());
System.out.println(JSONUtil.toJsonStr(collect)); System.out.println(JSONUtil.toJsonStr(collect));
} }
@ -402,10 +402,10 @@ public class MyTest {
List<Rule> rules = Lists.newArrayList(rule, rule2); List<Rule> rules = Lists.newArrayList(rule, rule2);
System.out.println(JSONUtil.toJsonStr(rules)); System.out.println(JSONUtil.toJsonStr(rules));
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList()); List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRule).collect(Collectors.toList());
System.out.println(JSONUtil.toJsonStr(collect)); System.out.println(JSONUtil.toJsonStr(collect));
} }
private Map<String, Object> parseRole(Rule rule) { private Map<String, Object> parseRule(Rule rule) {
List<Match> matchList = rule.getMatches(); List<Match> matchList = rule.getMatches();
List<Rule> ruleChildren = rule.getChildren(); List<Rule> ruleChildren = rule.getChildren();
String logicOperators = rule.getLogicOperators(); String logicOperators = rule.getLogicOperators();
@ -413,7 +413,7 @@ public class MyTest {
List<Map<String,Object>> collect = ruleChildren.stream().map(child -> { List<Map<String,Object>> collect = ruleChildren.stream().map(child -> {
List<Rule> sunList = child.getChildren(); List<Rule> sunList = child.getChildren();
if (CollUtil.isNotEmpty(sunList)) { if (CollUtil.isNotEmpty(sunList)) {
List<Map<String, Object>> sunCollect = sunList.stream().map(this::parseRole).collect(Collectors.toList()); List<Map<String, Object>> sunCollect = sunList.stream().map(this::parseRule).collect(Collectors.toList());
String childLogicOperators = child.getLogicOperators(); String childLogicOperators = child.getLogicOperators();
Map<String, Object> itemMap = new HashMap<>(); Map<String, Object> itemMap = new HashMap<>();
itemMap.put(childLogicOperators, sunCollect); itemMap.put(childLogicOperators, sunCollect);