Browse Source

基础框架发布: 8.2.22

1) 规则引擎中,增加 Java 执行引擎
  2) 规则引擎中,模型定义中,将参数附加属性中的枚举值变量替换成常量
  3) 规则引擎中,模型定义中,将参数选项属性中的枚举值变量替换成常量
main
wangshaoping 2 months ago
parent
commit
09420866e0
  1. 17
      io.sc.engine.rule.client/src/test/java/io/sc/engine/rule/client/test/TestGroovy.java
  2. 6
      io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/generator/impl/processor/DecisionTree.java
  3. 4
      io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/generator/impl/processor/ExecutionFlow.java
  4. 2
      io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/function/ArithmeticFunction.java

17
io.sc.engine.rule.client/src/test/java/io/sc/engine/rule/client/test/TestGroovy.java

@ -0,0 +1,17 @@
package io.sc.engine.rule.client.test;
import io.sc.engine.rule.client.runtime.impl.groovy.GroovyScriptExecutor;
import io.sc.platform.util.FileUtil;
import javax.script.CompiledScript;
import java.io.FileInputStream;
public class TestGroovy {
public static void main(String[] args) throws Exception {
String file ="/Users/wangshaoping/wspsc/workspace/wangshaoping/v8/platform/io.sc.engine.rule.client/src/test/resources/a.txt";
String content = FileUtil.readString(new FileInputStream(file));
GroovyScriptExecutor executor =new GroovyScriptExecutor();
CompiledScript compiledScript =executor.getCompiledScript(content);
System.out.println(compiledScript.getClass().getName());
}
}

6
io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/generator/impl/processor/DecisionTree.java

@ -90,10 +90,10 @@ public class DecisionTree {
GraphNode nexNode =edge.getOuts().get(0); //出口边指向的节点
if(i==0) {
sb.append("\tif((").append(GroovyExpressionReplacer.groovy(conditionNode.getCondition(),null)).append(")==").append(GroovyExpressionReplacer.groovy(edge.getValue(),edge.getValueType())).append("){").append("\n");
sb.append("\tif((").append(GroovyExpressionReplacer.groovy(conditionNode.getCondition(),null)).append(").equals(").append(GroovyExpressionReplacer.groovy(edge.getValue(),edge.getValueType())).append(")){").append("\n");
}else {
if(edge.getValue()!=null && !edge.getValue().trim().isEmpty()) {
sb.append("else if((").append(GroovyExpressionReplacer.groovy(conditionNode.getCondition(),null)).append(")==").append(GroovyExpressionReplacer.groovy(edge.getValue(),edge.getValueType())).append("){").append("\n");
sb.append("else if((").append(GroovyExpressionReplacer.groovy(conditionNode.getCondition(),null)).append(").equals(").append(GroovyExpressionReplacer.groovy(edge.getValue(),edge.getValueType())).append(")){").append("\n");
}else {
sb.append("else {").append("\n");
isElse =true;
@ -104,7 +104,7 @@ public class DecisionTree {
String[] commandSplits =commands.split("\n");
if(commandSplits!=null && commandSplits.length>0) {
for(String split : commandSplits) {
sb.append("\t\t\t").append(split).append("\n");
sb.append("\t\t\t").append(GroovyExpressionReplacer.groovy(split,null)).append("\n");
}
}
}

4
io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/generator/impl/processor/ExecutionFlow.java

@ -109,10 +109,10 @@ public class ExecutionFlow {
EdgeConditionBranchNode edge =(EdgeConditionBranchNode)outs.get(i); //出口边
GraphNode nexNode =edge.getOuts().get(0); //出口边指向的节点
if(i==0) {
sb.append("\tif((").append(GroovyExpressionReplacer.groovy(node.getCondition(),null)).append(")==").append(GroovyExpressionReplacer.groovy(edge.getValue(),edge.getValueType())).append("){").append("\n");
sb.append("\tif((").append(GroovyExpressionReplacer.groovy(node.getCondition(),null)).append(").equals(").append(GroovyExpressionReplacer.groovy(edge.getValue(),edge.getValueType())).append(")){").append("\n");
}else {
if(edge.getValue()!=null && !edge.getValue().trim().isEmpty()) {
sb.append("else if((").append(GroovyExpressionReplacer.groovy(node.getCondition(),null)).append(")==").append(GroovyExpressionReplacer.groovy(edge.getValue(),edge.getValueType())).append("){").append("\n");
sb.append("else if((").append(GroovyExpressionReplacer.groovy(node.getCondition(),null)).append(").equals(").append(GroovyExpressionReplacer.groovy(edge.getValue(),edge.getValueType())).append(")){").append("\n");
}else {
sb.append("else {").append("\n");
}

2
io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/function/ArithmeticFunction.java

@ -128,7 +128,7 @@ public class ArithmeticFunction {
public static Double divide(Number x, Number y, int scale, RoundingMode roundingMode) {
BigDecimal xx =new BigDecimal(x.toString());
BigDecimal yy =new BigDecimal(x.toString());
BigDecimal yy =new BigDecimal(y.toString());
return xx.divide(yy,scale,roundingMode).doubleValue();
}

Loading…
Cancel
Save