1.修改单词拼写错误
This commit is contained in:
parent
0a8964d69a
commit
bb12a1fe76
|
@ -9,7 +9,7 @@ import cn.hutool.json.JSONUtil;
|
||||||
import com.example.liteflow.mysql.entity.BaseDataEntity;
|
import com.example.liteflow.mysql.entity.BaseDataEntity;
|
||||||
import com.example.liteflow.mysql.entity.BaseNodeEntity;
|
import com.example.liteflow.mysql.entity.BaseNodeEntity;
|
||||||
import com.example.liteflow.mysql.model.BaseCenter;
|
import com.example.liteflow.mysql.model.BaseCenter;
|
||||||
import com.example.liteflow.mysql.model.role.Role;
|
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;
|
||||||
|
@ -52,8 +52,8 @@ public class CenterCmp extends NodeIfComponent {
|
||||||
String nodeRole = baseNodeEntity.getNodeRole();
|
String nodeRole = baseNodeEntity.getNodeRole();
|
||||||
String templateId = baseNodeEntity.getTemplateId();
|
String templateId = baseNodeEntity.getTemplateId();
|
||||||
log.info("nodeRole = {}", nodeRole);
|
log.info("nodeRole = {}", nodeRole);
|
||||||
List<Role> roles = JSONUtil.toList(JSONUtil.parseArray(nodeRole), Role.class);
|
List<Rule> rules = JSONUtil.toList(JSONUtil.parseArray(nodeRole), Rule.class);
|
||||||
List<Map<String, Object>> collect = roles.stream().map(RoleUtil::parseRole).collect(Collectors.toList());
|
List<Map<String, Object>> collect = rules.stream().map(RoleUtil::parseRole).collect(Collectors.toList());
|
||||||
String droolStr = JSONUtil.toJsonStr(collect);
|
String droolStr = JSONUtil.toJsonStr(collect);
|
||||||
|
|
||||||
// 替换规则中的关键字
|
// 替换规则中的关键字
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.example.liteflow.mysql.model.node;
|
package com.example.liteflow.mysql.model.node;
|
||||||
|
|
||||||
import com.example.liteflow.mysql.model.OutputFrom;
|
import com.example.liteflow.mysql.model.OutputFrom;
|
||||||
import com.example.liteflow.mysql.model.role.Role;
|
import com.example.liteflow.mysql.model.rule.Rule;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -35,7 +35,7 @@ public class CreateNodeFrom {
|
||||||
/**
|
/**
|
||||||
* 规则
|
* 规则
|
||||||
*/
|
*/
|
||||||
private List<Role> roles;
|
private List<Rule> rules;
|
||||||
/**
|
/**
|
||||||
* 节点对应输出节点id
|
* 节点对应输出节点id
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.example.liteflow.mysql.model.node;
|
package com.example.liteflow.mysql.model.node;
|
||||||
|
|
||||||
import com.example.liteflow.mysql.model.OutputFrom;
|
import com.example.liteflow.mysql.model.OutputFrom;
|
||||||
import com.example.liteflow.mysql.model.role.Role;
|
import com.example.liteflow.mysql.model.rule.Rule;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -20,7 +20,7 @@ public class UpdateNodeFrom {
|
||||||
/**
|
/**
|
||||||
* 规则
|
* 规则
|
||||||
*/
|
*/
|
||||||
private List<Role> roles;
|
private List<Rule> rules;
|
||||||
/**
|
/**
|
||||||
* 内容
|
* 内容
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.liteflow.mysql.model.role;
|
package com.example.liteflow.mysql.model.rule;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.liteflow.mysql.model.role;
|
package com.example.liteflow.mysql.model.rule;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import java.util.List;
|
||||||
* @date: 2022年12月07日 16:04
|
* @date: 2022年12月07日 16:04
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class Role {
|
public class Rule {
|
||||||
// 逻辑运算符"$or"
|
// 逻辑运算符"$or"
|
||||||
private String logicOperators;
|
private String logicOperators;
|
||||||
// 条件运算符:"$eq"
|
// 条件运算符:"$eq"
|
||||||
|
@ -18,6 +18,6 @@ public class Role {
|
||||||
private String matchingValue;
|
private String matchingValue;
|
||||||
// 匹配内容
|
// 匹配内容
|
||||||
private String matchingContent;
|
private String matchingContent;
|
||||||
private List<Role> children;
|
private List<Rule> children;
|
||||||
private List<Match> matches;
|
private List<Match> matches;
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.liteflow.mysql.model.role;
|
package com.example.liteflow.mysql.model.rule;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import java.util.List;
|
||||||
* @date: 2022年12月07日 10:41
|
* @date: 2022年12月07日 10:41
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class RoleForm {
|
public class RuleForm {
|
||||||
private String roleName;
|
private String roleName;
|
||||||
private List<Role> roles;
|
private List<Rule> rules;
|
||||||
}
|
}
|
|
@ -18,7 +18,7 @@ import com.example.liteflow.mysql.model.OutputFrom;
|
||||||
import com.example.liteflow.mysql.model.node.BaseNodeVO;
|
import com.example.liteflow.mysql.model.node.BaseNodeVO;
|
||||||
import com.example.liteflow.mysql.model.node.CreateNodeFrom;
|
import com.example.liteflow.mysql.model.node.CreateNodeFrom;
|
||||||
import com.example.liteflow.mysql.model.node.UpdateNodeFrom;
|
import com.example.liteflow.mysql.model.node.UpdateNodeFrom;
|
||||||
import com.example.liteflow.mysql.model.role.Role;
|
import com.example.liteflow.mysql.model.rule.Rule;
|
||||||
import com.example.liteflow.mysql.service.BaseNodeService;
|
import com.example.liteflow.mysql.service.BaseNodeService;
|
||||||
import com.example.liteflow.mysql.service.BaseTemplateService;
|
import com.example.liteflow.mysql.service.BaseTemplateService;
|
||||||
import com.yomahub.liteflow.flow.FlowBus;
|
import com.yomahub.liteflow.flow.FlowBus;
|
||||||
|
@ -58,10 +58,10 @@ public class BaseNodeServiceImpl extends ServiceImpl<BaseNodeMapper, BaseNodeEnt
|
||||||
}
|
}
|
||||||
BaseNodeEntity baseNodeEntity = BeanUtil.toBean(createNodeFrom, BaseNodeEntity.class);
|
BaseNodeEntity baseNodeEntity = BeanUtil.toBean(createNodeFrom, BaseNodeEntity.class);
|
||||||
baseNodeEntity.setNodeClass(nodeEnum.getNodeClass());
|
baseNodeEntity.setNodeClass(nodeEnum.getNodeClass());
|
||||||
List<Role> roles = createNodeFrom.getRoles();
|
List<Rule> rules = createNodeFrom.getRules();
|
||||||
OutputFrom content = createNodeFrom.getContent();
|
OutputFrom content = createNodeFrom.getContent();
|
||||||
if (CollUtil.isNotEmpty(roles) && NodeEnum.IfNode.getName().equals(nodeType)) {
|
if (CollUtil.isNotEmpty(rules) && NodeEnum.IfNode.getName().equals(nodeType)) {
|
||||||
baseNodeEntity.setNodeRole(JSONUtil.toJsonStr(roles));
|
baseNodeEntity.setNodeRole(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 {
|
||||||
|
@ -77,8 +77,8 @@ public class BaseNodeServiceImpl extends ServiceImpl<BaseNodeMapper, BaseNodeEnt
|
||||||
String id = updateNodeFrom.getId();
|
String id = updateNodeFrom.getId();
|
||||||
String nodeContentId = updateNodeFrom.getNodeContentId();
|
String nodeContentId = updateNodeFrom.getNodeContentId();
|
||||||
Integer enableMark = updateNodeFrom.getEnableMark();
|
Integer enableMark = updateNodeFrom.getEnableMark();
|
||||||
List<Role> roles = updateNodeFrom.getRoles();
|
List<Rule> rules = updateNodeFrom.getRules();
|
||||||
String roleStr = ObjectUtil.isNotNull(roles) ? JSONUtil.toJsonStr(roles) : "";
|
String roleStr = 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<>();
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.example.liteflow.mysql.util;
|
package com.example.liteflow.mysql.util;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.example.liteflow.mysql.model.role.Match;
|
import com.example.liteflow.mysql.model.rule.Match;
|
||||||
import com.example.liteflow.mysql.model.role.Role;
|
import com.example.liteflow.mysql.model.rule.Rule;
|
||||||
import org.assertj.core.util.Lists;
|
import org.assertj.core.util.Lists;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -15,13 +15,13 @@ import java.util.stream.Collectors;
|
||||||
* @date: 2022年12月08日 15:37
|
* @date: 2022年12月08日 15:37
|
||||||
*/
|
*/
|
||||||
public class RoleUtil {
|
public class RoleUtil {
|
||||||
public static Map<String, Object> parseRole(Role role) {
|
public static Map<String, Object> parseRole(Rule rule) {
|
||||||
List<Match> matchList = role.getMatches();
|
List<Match> matchList = rule.getMatches();
|
||||||
List<Role> roleChildren = role.getChildren();
|
List<Rule> ruleChildren = rule.getChildren();
|
||||||
String logicOperators = role.getLogicOperators();
|
String logicOperators = rule.getLogicOperators();
|
||||||
if (CollUtil.isNotEmpty(roleChildren)) {
|
if (CollUtil.isNotEmpty(ruleChildren)) {
|
||||||
List<Map<String,Object>> collect = roleChildren.stream().map(child -> {
|
List<Map<String,Object>> collect = ruleChildren.stream().map(child -> {
|
||||||
List<Role> 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(RoleUtil::parseRole).collect(Collectors.toList());
|
||||||
String childLogicOperators = child.getLogicOperators();
|
String childLogicOperators = child.getLogicOperators();
|
||||||
|
@ -62,9 +62,9 @@ public class RoleUtil {
|
||||||
childMap.put(logicOperators, list);
|
childMap.put(logicOperators, list);
|
||||||
return childMap;
|
return childMap;
|
||||||
} else {
|
} else {
|
||||||
String matchingValue = role.getMatchingValue();
|
String matchingValue = rule.getMatchingValue();
|
||||||
String matchingContent = role.getMatchingContent();
|
String matchingContent = rule.getMatchingContent();
|
||||||
String conditionalOperators = role.getConditionalOperators();
|
String conditionalOperators = rule.getConditionalOperators();
|
||||||
List<String> itemList = Lists.newArrayList(matchingValue, matchingContent);
|
List<String> itemList = Lists.newArrayList(matchingValue, matchingContent);
|
||||||
Map<String, Object> itemMap = new HashMap<>();
|
Map<String, Object> itemMap = new HashMap<>();
|
||||||
itemMap.put(conditionalOperators, itemList);
|
itemMap.put(conditionalOperators, itemList);
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
"nodeName": "costCenter01Cmp",
|
"nodeName": "costCenter01Cmp",
|
||||||
"nodeType": "IfNode",
|
"nodeType": "IfNode",
|
||||||
"nodeContentId": "2480deadc736b40435a2b6930851aaa5",
|
"nodeContentId": "2480deadc736b40435a2b6930851aaa5",
|
||||||
"roles": [
|
"rules": [
|
||||||
{
|
{
|
||||||
"logicOperators": "$or",
|
"logicOperators": "$or",
|
||||||
"children": [
|
"children": [
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
"nodeName": "costCenter02Cmp",
|
"nodeName": "costCenter02Cmp",
|
||||||
"nodeType": "IfNode",
|
"nodeType": "IfNode",
|
||||||
"nodeContentId": "0264efebbfb4c7cb5e4cb81092e1bce4",
|
"nodeContentId": "0264efebbfb4c7cb5e4cb81092e1bce4",
|
||||||
"roles": [
|
"rules": [
|
||||||
{
|
{
|
||||||
"logicOperators": "$or",
|
"logicOperators": "$or",
|
||||||
"children": [
|
"children": [
|
||||||
|
@ -140,7 +140,7 @@
|
||||||
"nodeName": "profitCenter01Cmp",
|
"nodeName": "profitCenter01Cmp",
|
||||||
"nodeType": "IfNode",
|
"nodeType": "IfNode",
|
||||||
"nodeContentId": "1a1df8cbdc9983fa03b3060049293b87",
|
"nodeContentId": "1a1df8cbdc9983fa03b3060049293b87",
|
||||||
"roles": [
|
"rules": [
|
||||||
{
|
{
|
||||||
"logicOperators": "$or",
|
"logicOperators": "$or",
|
||||||
"children": [
|
"children": [
|
||||||
|
@ -196,7 +196,7 @@
|
||||||
"nodeName": "profitCenter02Cmp",
|
"nodeName": "profitCenter02Cmp",
|
||||||
"nodeType": "IfNode",
|
"nodeType": "IfNode",
|
||||||
"nodeContentId": "f050bd67f23cd0152f17d4f82d29b8a4",
|
"nodeContentId": "f050bd67f23cd0152f17d4f82d29b8a4",
|
||||||
"roles": [
|
"rules": [
|
||||||
{
|
{
|
||||||
"logicOperators": "$or",
|
"logicOperators": "$or",
|
||||||
"children": [
|
"children": [
|
||||||
|
|
|
@ -4,16 +4,12 @@ import cn.hutool.json.JSONUtil;
|
||||||
import com.example.liteflow.mysql.enums.MathOperatorEnum;
|
import com.example.liteflow.mysql.enums.MathOperatorEnum;
|
||||||
import com.example.liteflow.mysql.enums.NodeEnum;
|
import com.example.liteflow.mysql.enums.NodeEnum;
|
||||||
import com.example.liteflow.mysql.model.node.CreateNodeFrom;
|
import com.example.liteflow.mysql.model.node.CreateNodeFrom;
|
||||||
import com.example.liteflow.mysql.model.role.Match;
|
import com.example.liteflow.mysql.model.rule.Match;
|
||||||
import com.example.liteflow.mysql.model.role.Role;
|
import com.example.liteflow.mysql.model.rule.Rule;
|
||||||
import com.example.liteflow.mysql.model.role.RoleForm;
|
import com.example.liteflow.mysql.model.rule.RuleForm;
|
||||||
import com.yomahub.liteflow.flow.FlowBus;
|
|
||||||
import com.yomahub.liteflow.flow.element.Node;
|
|
||||||
import org.assertj.core.util.Lists;
|
import org.assertj.core.util.Lists;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -30,13 +26,13 @@ public class MyTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test01() {
|
public void test01() {
|
||||||
List<Role> roles = new ArrayList<>();
|
List<Rule> rules = new ArrayList<>();
|
||||||
Role role = new Role();
|
Rule rule = new Rule();
|
||||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
List<Role> children = new ArrayList<>();
|
List<Rule> children = new ArrayList<>();
|
||||||
Role childRole = new Role();
|
Rule childRule = new Rule();
|
||||||
childRole.setLogicOperators(MathOperatorEnum.and.getOperator());
|
childRule.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
|
|
||||||
List<Match> matches = new ArrayList<>();
|
List<Match> matches = new ArrayList<>();
|
||||||
Match match = new Match();
|
Match match = new Match();
|
||||||
|
@ -50,31 +46,31 @@ public class MyTest {
|
||||||
match.setMatchingContent("1");
|
match.setMatchingContent("1");
|
||||||
matches.add(match);
|
matches.add(match);
|
||||||
|
|
||||||
childRole.setMatches(matches);
|
childRule.setMatches(matches);
|
||||||
children.add(childRole);
|
children.add(childRule);
|
||||||
role.setChildren(children);
|
rule.setChildren(children);
|
||||||
roles.add(role);
|
rules.add(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));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test02() {
|
public void test02() {
|
||||||
List<Role> roles = new ArrayList<>();
|
List<Rule> rules = new ArrayList<>();
|
||||||
Role role = new Role();
|
Rule rule = new Rule();
|
||||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
Role child = new Role();
|
Rule child = new Rule();
|
||||||
child.setLogicOperators(MathOperatorEnum.or.getOperator());
|
child.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
Role sun = new Role();
|
Rule sun = new Rule();
|
||||||
sun.setLogicOperators(MathOperatorEnum.or.getOperator());
|
sun.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
|
|
||||||
List<Role> sunList = new ArrayList<>();
|
List<Rule> sunList = new ArrayList<>();
|
||||||
|
|
||||||
List<Match> matches = new ArrayList<>();
|
List<Match> matches = new ArrayList<>();
|
||||||
Match match = new Match();
|
Match match = new Match();
|
||||||
|
@ -92,12 +88,12 @@ public class MyTest {
|
||||||
sunList.add(sun);
|
sunList.add(sun);
|
||||||
child.setChildren(sunList);
|
child.setChildren(sunList);
|
||||||
|
|
||||||
List<Role> children = Lists.newArrayList(child);
|
List<Rule> children = Lists.newArrayList(child);
|
||||||
role.setChildren(children);
|
rule.setChildren(children);
|
||||||
roles.add(role);
|
rules.add(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));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -105,8 +101,8 @@ public class MyTest {
|
||||||
@Test
|
@Test
|
||||||
public void test3() {
|
public void test3() {
|
||||||
|
|
||||||
Role role = new Role();
|
Rule rule = new Rule();
|
||||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
List<Match> matches = new ArrayList<>();
|
List<Match> matches = new ArrayList<>();
|
||||||
Match match = new Match();
|
Match match = new Match();
|
||||||
|
@ -115,17 +111,17 @@ public class MyTest {
|
||||||
match.setMatchingContent("1");
|
match.setMatchingContent("1");
|
||||||
matches.add(match);
|
matches.add(match);
|
||||||
|
|
||||||
role.setMatches(matches);
|
rule.setMatches(matches);
|
||||||
List<Role> roles = Lists.newArrayList(role);
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test4() {
|
public void test4() {
|
||||||
Role role = new Role();
|
Rule rule = new Rule();
|
||||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
List<Match> matches = new ArrayList<>();
|
List<Match> matches = new ArrayList<>();
|
||||||
Match match = new Match();
|
Match match = new Match();
|
||||||
|
@ -140,34 +136,34 @@ public class MyTest {
|
||||||
match.setMatchingContent("2");
|
match.setMatchingContent("2");
|
||||||
matches.add(match);
|
matches.add(match);
|
||||||
|
|
||||||
role.setMatches(matches);
|
rule.setMatches(matches);
|
||||||
List<Role> roles = Lists.newArrayList(role);
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test5() {
|
public void test5() {
|
||||||
Role role = new Role();
|
Rule rule = new Rule();
|
||||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
role.setConditionalOperators(MathOperatorEnum.eq.getOperator());
|
rule.setConditionalOperators(MathOperatorEnum.eq.getOperator());
|
||||||
role.setMatchingValue("1");
|
rule.setMatchingValue("1");
|
||||||
role.setMatchingContent("1");
|
rule.setMatchingContent("1");
|
||||||
|
|
||||||
List<Role> roles = Lists.newArrayList(role);
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test6() {
|
public void test6() {
|
||||||
Role role = new Role();
|
Rule rule = new Rule();
|
||||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
Role child = new Role();
|
Rule child = new Rule();
|
||||||
child.setLogicOperators(MathOperatorEnum.and.getOperator());
|
child.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
List<Match> matches = new ArrayList<>();
|
List<Match> matches = new ArrayList<>();
|
||||||
Match match = new Match();
|
Match match = new Match();
|
||||||
|
@ -183,13 +179,13 @@ public class MyTest {
|
||||||
matches.add(match);
|
matches.add(match);
|
||||||
|
|
||||||
child.setMatches(matches);
|
child.setMatches(matches);
|
||||||
List<Role> children = Lists.newArrayList(child);
|
List<Rule> children = Lists.newArrayList(child);
|
||||||
role.setChildren(children);
|
rule.setChildren(children);
|
||||||
|
|
||||||
Role role2 = new Role();
|
Rule rule2 = new Rule();
|
||||||
role2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
rule2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
Role child2 = new Role();
|
Rule child2 = new Rule();
|
||||||
child2.setLogicOperators(MathOperatorEnum.and.getOperator());
|
child2.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
List<Match> matches2 = new ArrayList<>();
|
List<Match> matches2 = new ArrayList<>();
|
||||||
Match match2 = new Match();
|
Match match2 = new Match();
|
||||||
|
@ -205,22 +201,22 @@ public class MyTest {
|
||||||
matches2.add(match2);
|
matches2.add(match2);
|
||||||
|
|
||||||
child2.setMatches(matches2);
|
child2.setMatches(matches2);
|
||||||
List<Role> children2 = Lists.newArrayList(child2);
|
List<Rule> children2 = Lists.newArrayList(child2);
|
||||||
role2.setChildren(children2);
|
rule2.setChildren(children2);
|
||||||
|
|
||||||
List<Role> roles = Lists.newArrayList(role, role2);
|
List<Rule> rules = Lists.newArrayList(rule, rule2);
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test7() {
|
public void test7() {
|
||||||
Role role = new Role();
|
Rule rule = new Rule();
|
||||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
Role child = new Role();
|
Rule child = new Rule();
|
||||||
child.setLogicOperators(MathOperatorEnum.and.getOperator());
|
child.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
List<Match> matches = new ArrayList<>();
|
List<Match> matches = new ArrayList<>();
|
||||||
Match match = new Match();
|
Match match = new Match();
|
||||||
|
@ -248,13 +244,13 @@ public class MyTest {
|
||||||
matches.add(match);
|
matches.add(match);
|
||||||
|
|
||||||
child.setMatches(matches);
|
child.setMatches(matches);
|
||||||
List<Role> children = Lists.newArrayList(child);
|
List<Rule> children = Lists.newArrayList(child);
|
||||||
role.setChildren(children);
|
rule.setChildren(children);
|
||||||
|
|
||||||
List<Role> roles = Lists.newArrayList(role);
|
List<Rule> rules = Lists.newArrayList(rule);
|
||||||
RoleForm roleForm = new RoleForm();
|
RuleForm ruleForm = new RuleForm();
|
||||||
roleForm.setRoles(roles);
|
ruleForm.setRules(rules);
|
||||||
roleForm.setRoleName("costCenter01Cmp");
|
ruleForm.setRoleName("costCenter01Cmp");
|
||||||
// baseRoleService.createRole(roleForm);
|
// baseRoleService.createRole(roleForm);
|
||||||
// System.out.println(JSONUtil.toJsonStr(roles));
|
// System.out.println(JSONUtil.toJsonStr(roles));
|
||||||
// List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
// List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||||
|
@ -263,13 +259,13 @@ public class MyTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test8() {
|
public void test8() {
|
||||||
Role role = new Role();
|
Rule rule = new Rule();
|
||||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
Role child = new Role();
|
Rule child = new Rule();
|
||||||
child.setLogicOperators(MathOperatorEnum.or.getOperator());
|
child.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
Role sun = new Role();
|
Rule sun = new Rule();
|
||||||
sun.setLogicOperators(MathOperatorEnum.and.getOperator());
|
sun.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
List<Match> matches = new ArrayList<>();
|
List<Match> matches = new ArrayList<>();
|
||||||
Match match = new Match();
|
Match match = new Match();
|
||||||
|
@ -285,10 +281,10 @@ public class MyTest {
|
||||||
matches.add(match);
|
matches.add(match);
|
||||||
|
|
||||||
sun.setMatches(matches);
|
sun.setMatches(matches);
|
||||||
List<Role> sunList = Lists.newArrayList(sun);
|
List<Rule> sunList = Lists.newArrayList(sun);
|
||||||
child.setChildren(sunList);
|
child.setChildren(sunList);
|
||||||
List<Role> children = Lists.newArrayList(child);
|
List<Rule> children = Lists.newArrayList(child);
|
||||||
role.setChildren(children);
|
rule.setChildren(children);
|
||||||
|
|
||||||
|
|
||||||
List<Match> matches2 = new ArrayList<>();
|
List<Match> matches2 = new ArrayList<>();
|
||||||
|
@ -297,26 +293,26 @@ public class MyTest {
|
||||||
match2.setMatchingValue("businessType");
|
match2.setMatchingValue("businessType");
|
||||||
match2.setMatchingContent("businessTypeList");
|
match2.setMatchingContent("businessTypeList");
|
||||||
matches2.add(match2);
|
matches2.add(match2);
|
||||||
Role role2 = new Role();
|
Rule rule2 = new Rule();
|
||||||
role2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
rule2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
role2.setMatches(matches2);
|
rule2.setMatches(matches2);
|
||||||
|
|
||||||
List<Role> roles = Lists.newArrayList(role, role2);
|
List<Rule> rules = Lists.newArrayList(rule, rule2);
|
||||||
RoleForm roleForm = new RoleForm();
|
RuleForm ruleForm = new RuleForm();
|
||||||
roleForm.setRoles(roles);
|
ruleForm.setRules(rules);
|
||||||
roleForm.setRoleName("costCenter02Cmp");
|
ruleForm.setRoleName("costCenter02Cmp");
|
||||||
// baseRoleService.createRole(roleForm);
|
// baseRoleService.createRole(roleForm);
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test09() {
|
public void test09() {
|
||||||
Role role = new Role();
|
Rule rule = new Rule();
|
||||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
Role child = new Role();
|
Rule child = new Rule();
|
||||||
child.setLogicOperators(MathOperatorEnum.and.getOperator());
|
child.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
|
|
||||||
List<Match> matches = new ArrayList<>();
|
List<Match> matches = new ArrayList<>();
|
||||||
|
@ -339,12 +335,12 @@ public class MyTest {
|
||||||
matches.add(match);
|
matches.add(match);
|
||||||
|
|
||||||
child.setMatches(matches);
|
child.setMatches(matches);
|
||||||
List<Role> children = Lists.newArrayList(child);
|
List<Rule> children = Lists.newArrayList(child);
|
||||||
role.setChildren(children);
|
rule.setChildren(children);
|
||||||
|
|
||||||
Role role2 = new Role();
|
Rule rule2 = new Rule();
|
||||||
role2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
rule2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
Role child2 = new Role();
|
Rule child2 = new Rule();
|
||||||
child2.setLogicOperators(MathOperatorEnum.and.getOperator());
|
child2.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
List<Match> matches2 = new ArrayList<>();
|
List<Match> matches2 = new ArrayList<>();
|
||||||
Match match2 = new Match();
|
Match match2 = new Match();
|
||||||
|
@ -359,25 +355,25 @@ public class MyTest {
|
||||||
match2.setMatchingContent("businessTypeList");
|
match2.setMatchingContent("businessTypeList");
|
||||||
matches2.add(match2);
|
matches2.add(match2);
|
||||||
child2.setMatches(matches2);
|
child2.setMatches(matches2);
|
||||||
List<Role> children2 = Lists.newArrayList(child2);
|
List<Rule> children2 = Lists.newArrayList(child2);
|
||||||
role2.setChildren(children2);
|
rule2.setChildren(children2);
|
||||||
|
|
||||||
List<Role> roles = Lists.newArrayList(role, role2);
|
List<Rule> rules = Lists.newArrayList(rule, rule2);
|
||||||
RoleForm roleForm = new RoleForm();
|
RuleForm ruleForm = new RuleForm();
|
||||||
roleForm.setRoles(roles);
|
ruleForm.setRules(rules);
|
||||||
roleForm.setRoleName("profitCenter01Cmp");
|
ruleForm.setRoleName("profitCenter01Cmp");
|
||||||
// baseRoleService.createRole(roleForm);
|
// baseRoleService.createRole(roleForm);
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test10() {
|
public void test10() {
|
||||||
Role role = new Role();
|
Rule rule = new Rule();
|
||||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
Role child = new Role();
|
Rule child = new Rule();
|
||||||
child.setLogicOperators(MathOperatorEnum.and.getOperator());
|
child.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
|
|
||||||
List<Match> matches = new ArrayList<>();
|
List<Match> matches = new ArrayList<>();
|
||||||
|
@ -394,12 +390,12 @@ public class MyTest {
|
||||||
matches.add(match);
|
matches.add(match);
|
||||||
|
|
||||||
child.setMatches(matches);
|
child.setMatches(matches);
|
||||||
List<Role> children = Lists.newArrayList(child);
|
List<Rule> children = Lists.newArrayList(child);
|
||||||
role.setChildren(children);
|
rule.setChildren(children);
|
||||||
|
|
||||||
Role role2 = new Role();
|
Rule rule2 = new Rule();
|
||||||
role2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
rule2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
Role child2 = new Role();
|
Rule child2 = new Rule();
|
||||||
child2.setLogicOperators(MathOperatorEnum.and.getOperator());
|
child2.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
List<Match> matches2 = new ArrayList<>();
|
List<Match> matches2 = new ArrayList<>();
|
||||||
Match match2 = new Match();
|
Match match2 = new Match();
|
||||||
|
@ -414,25 +410,25 @@ public class MyTest {
|
||||||
match2.setMatchingContent("businessTypeList");
|
match2.setMatchingContent("businessTypeList");
|
||||||
matches2.add(match2);
|
matches2.add(match2);
|
||||||
child2.setMatches(matches2);
|
child2.setMatches(matches2);
|
||||||
List<Role> children2 = Lists.newArrayList(child2);
|
List<Rule> children2 = Lists.newArrayList(child2);
|
||||||
role2.setChildren(children2);
|
rule2.setChildren(children2);
|
||||||
|
|
||||||
List<Role> roles = Lists.newArrayList(role, role2);
|
List<Rule> rules = Lists.newArrayList(rule, rule2);
|
||||||
RoleForm roleForm = new RoleForm();
|
RuleForm ruleForm = new RuleForm();
|
||||||
roleForm.setRoles(roles);
|
ruleForm.setRules(rules);
|
||||||
roleForm.setRoleName("profitCenter02Cmp");
|
ruleForm.setRoleName("profitCenter02Cmp");
|
||||||
// baseRoleService.createRole(roleForm);
|
// baseRoleService.createRole(roleForm);
|
||||||
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));
|
||||||
}
|
}
|
||||||
private Map<String, Object> parseRole(Role role) {
|
private Map<String, Object> parseRole(Rule rule) {
|
||||||
List<Match> matchList = role.getMatches();
|
List<Match> matchList = rule.getMatches();
|
||||||
List<Role> roleChildren = role.getChildren();
|
List<Rule> ruleChildren = rule.getChildren();
|
||||||
String logicOperators = role.getLogicOperators();
|
String logicOperators = rule.getLogicOperators();
|
||||||
if (CollUtil.isNotEmpty(roleChildren)) {
|
if (CollUtil.isNotEmpty(ruleChildren)) {
|
||||||
List<Map<String,Object>> collect = roleChildren.stream().map(child -> {
|
List<Map<String,Object>> collect = ruleChildren.stream().map(child -> {
|
||||||
List<Role> 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::parseRole).collect(Collectors.toList());
|
||||||
String childLogicOperators = child.getLogicOperators();
|
String childLogicOperators = child.getLogicOperators();
|
||||||
|
@ -473,9 +469,9 @@ public class MyTest {
|
||||||
childMap.put(logicOperators, list);
|
childMap.put(logicOperators, list);
|
||||||
return childMap;
|
return childMap;
|
||||||
} else {
|
} else {
|
||||||
String matchingValue = role.getMatchingValue();
|
String matchingValue = rule.getMatchingValue();
|
||||||
String matchingContent = role.getMatchingContent();
|
String matchingContent = rule.getMatchingContent();
|
||||||
String conditionalOperators = role.getConditionalOperators();
|
String conditionalOperators = rule.getConditionalOperators();
|
||||||
List<String> itemList = Lists.newArrayList(matchingValue, matchingContent);
|
List<String> itemList = Lists.newArrayList(matchingValue, matchingContent);
|
||||||
Map<String, Object> itemMap = new HashMap<>();
|
Map<String, Object> itemMap = new HashMap<>();
|
||||||
itemMap.put(conditionalOperators, itemList);
|
itemMap.put(conditionalOperators, itemList);
|
||||||
|
@ -503,5 +499,8 @@ public class MyTest {
|
||||||
createNodeFrom.setNodeName("costCenter01Cmp");
|
createNodeFrom.setNodeName("costCenter01Cmp");
|
||||||
createNodeFrom.setNodeType(NodeEnum.IfNode.getName());
|
createNodeFrom.setNodeType(NodeEnum.IfNode.getName());
|
||||||
System.out.println(JSONUtil.toJsonStr(createNodeFrom));
|
System.out.println(JSONUtil.toJsonStr(createNodeFrom));
|
||||||
|
|
||||||
|
String str = "2";
|
||||||
|
System.out.println(str.equals(null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue