34 changed files with 1021 additions and 3 deletions
@ -0,0 +1,8 @@ |
|||||
|
dependencies { |
||||
|
api( |
||||
|
project(":io.sc.engine.rule.core"), |
||||
|
project(":io.sc.engine.rule.client"), |
||||
|
|
||||
|
project(":io.sc.platform.mvc"), |
||||
|
) |
||||
|
} |
@ -0,0 +1,113 @@ |
|||||
|
package io.sc.engine.rule.client.spring.initializer; |
||||
|
|
||||
|
import io.sc.engine.rule.client.Executor; |
||||
|
import io.sc.engine.rule.client.spring.service.ExecutorFactoryService; |
||||
|
import io.sc.engine.rule.core.classes.ResourceAbstract; |
||||
|
import io.sc.engine.rule.core.enums.DeployStatus; |
||||
|
import io.sc.platform.core.initializer.ApplicationInitializer; |
||||
|
import io.sc.platform.core.initializer.ApplicationInitializerExecuteException; |
||||
|
import io.sc.platform.mvc.service.SystemParameterService; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.context.ApplicationContext; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Map.Entry; |
||||
|
|
||||
|
@Component |
||||
|
public class AutoCompileDeployedModelInitializer implements ApplicationInitializer { |
||||
|
private static final Logger log =LoggerFactory.getLogger(AutoCompileDeployedModelInitializer.class); |
||||
|
private static final String AUTO_COMPILE_MODE_KEY ="parameter.re.client.autoCompile"; |
||||
|
|
||||
|
private SystemParameterService systemParameterService; |
||||
|
private ExecutorFactoryService executorFactoryService; |
||||
|
|
||||
|
@Override |
||||
|
public void init(ApplicationContext applicationContext) { |
||||
|
//this.systemParameterService =applicationContext.getBean(SystemParameterService.class);
|
||||
|
//this.executorFactoryService =applicationContext.getBean(ExecutorFactoryService.class);
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int getOrder() { |
||||
|
return 10000; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public synchronized boolean isInitialized() { |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void execute() throws ApplicationInitializerExecuteException { |
||||
|
if(1==1)return; |
||||
|
String autoCompile =systemParameterService.getParameter(AUTO_COMPILE_MODE_KEY,"none"); |
||||
|
log.info("auto Complile Mode [{}]",autoCompile); |
||||
|
if("none".equalsIgnoreCase(autoCompile)) {//系统启动时不自动编译资源
|
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if(executorFactoryService!=null) { |
||||
|
Executor executor=executorFactoryService.getExecutor(); |
||||
|
if(executor!=null) { |
||||
|
try { |
||||
|
List<ResourceAbstract> resources =executor.getLoader().getAllReleasableResourceAbstract(); |
||||
|
if(resources!=null && resources.size()>0) { |
||||
|
|
||||
|
if ("deployed".equalsIgnoreCase(autoCompile)) { |
||||
|
autoCompileDeployed(executor, resources); |
||||
|
} |
||||
|
|
||||
|
if ("last".equalsIgnoreCase(autoCompile)) { |
||||
|
autoCompileLast(executor, resources); |
||||
|
} |
||||
|
|
||||
|
if ("deployed-and-last".equalsIgnoreCase(autoCompile)) { |
||||
|
autoCompileDeployed(executor, resources); |
||||
|
autoCompileLast(executor, resources); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
}catch (Exception e){ |
||||
|
throw new ApplicationInitializerExecuteException(e); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void autoCompileDeployed(Executor executor, List<ResourceAbstract> resources) throws Exception{ |
||||
|
if(resources!=null && resources.size()>0) { |
||||
|
for(ResourceAbstract resource : resources) { |
||||
|
if(DeployStatus.ON_LINE.equals(resource.getStatus())) { |
||||
|
log.info("auto compile deployed resource {}_V{}({}) ......",resource.getCode(),resource.getVersion(),resource.getName()); |
||||
|
executor.compileByCode(resource.getCode(), resource.getVersion()); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void autoCompileLast(Executor executor,List<ResourceAbstract> resources) throws Exception{ |
||||
|
Map<String,ResourceAbstract> last =new HashMap<String,ResourceAbstract>(); |
||||
|
if(resources!=null && resources.size()>0) { |
||||
|
for(ResourceAbstract resource : resources) { |
||||
|
ResourceAbstract resourceAbstract =last.get(resource.getCode()); |
||||
|
if(resourceAbstract==null) { |
||||
|
last.put(resource.getCode(),resource); |
||||
|
}else { |
||||
|
if(resource.getVersion()>resourceAbstract.getVersion()) { |
||||
|
last.put(resource.getCode(),resource); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
for(Entry<String, ResourceAbstract> entry : last.entrySet()) { |
||||
|
ResourceAbstract resource =entry.getValue(); |
||||
|
log.info("auto compile deployed resource {}_V{}({}) ......",resource.getCode(),resource.getVersion(),resource.getName()); |
||||
|
executor.compileByCode(resource.getCode(), resource.getVersion()); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
/* |
||||
|
* 自动组件扫描插件配置 |
||||
|
* 功能: 该插件配置为框架提供自动扫描组件的包名,配置的包名将会自动被 spring 进行扫描 |
||||
|
* 使用说明: |
||||
|
* includes: 包含自动扫描的包名列表 |
||||
|
* excludes: 排除自动扫描的包名列表 |
||||
|
* 注意: 当一个包名同时存在于 includes 和 excludes 中, excludes 优先, 即该包不会被自动扫描 |
||||
|
*/ |
||||
|
|
||||
|
{ |
||||
|
"includes":[ |
||||
|
"io.sc.engine.rule.client.spring.controller", |
||||
|
"io.sc.engine.rule.client.spring.service.impl" |
||||
|
] |
||||
|
} |
@ -0,0 +1,6 @@ |
|||||
|
dependencies { |
||||
|
api( |
||||
|
project(":io.sc.engine.rule.core"), |
||||
|
project(":io.sc.platform.groovy"), |
||||
|
) |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
dependencies { |
||||
|
api( |
||||
|
"org.springframework:spring-core", |
||||
|
"com.fasterxml.jackson.core:jackson-annotations", |
||||
|
"com.fasterxml.jackson.core:jackson-core", |
||||
|
"com.fasterxml.jackson.core:jackson-databind", |
||||
|
"org.slf4j:slf4j-api", |
||||
|
"org.freemarker:freemarker", |
||||
|
|
||||
|
"org.codehaus.groovy:groovy", |
||||
|
"org.codehaus.groovy:groovy-jsr223", |
||||
|
"org.codehaus.groovy:groovy-datetime", |
||||
|
"org.codehaus.groovy:groovy-dateutil", |
||||
|
"org.codehaus.groovy:groovy-json", |
||||
|
"org.codehaus.groovy:groovy-sql", |
||||
|
"org.codehaus.groovy:groovy-xml", |
||||
|
"org.apache.commons:commons-math3:${commons_math3_version}", |
||||
|
|
||||
|
"org.nasdanika.core:mxgraph:${mxgraph_version}", |
||||
|
|
||||
|
"org.jpmml:pmml-evaluator:${jpmml_version}", |
||||
|
"org.jpmml:pmml-evaluator-extension:${jpmml_version}", |
||||
|
"com.belerweb:pinyin4j:${pinyin4j_version}", |
||||
|
) |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
package io.sc.engine.rule.core.code; |
||||
|
|
||||
|
import io.sc.engine.rule.core.code.impl.support.ResourceWrapper; |
||||
|
|
||||
|
/** |
||||
|
* 代码生成器接口 |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
public interface CodeGenerator { |
||||
|
/** |
||||
|
* 生成可执行的源代码 |
||||
|
* @param resourceId 资源ID |
||||
|
* @param wrapper 资源封装器对象 |
||||
|
* @return 源代码封装对象 |
||||
|
* @throws Exception 违例 |
||||
|
*/ |
||||
|
public SourceCode generateSourceCodeById(String resourceId,ResourceWrapper wrapper) throws Exception; |
||||
|
|
||||
|
/** |
||||
|
* 生成可执行的源代码 |
||||
|
* @param resourceCode 资源代码 |
||||
|
* @param version 模型版本 |
||||
|
* @param wrapper 资源封装器对象 |
||||
|
* @return 源代码封装对象 |
||||
|
* @throws Exception 违例 |
||||
|
*/ |
||||
|
public SourceCode generateSourceCodeByCode(String resourceCode,Integer version,ResourceWrapper wrapper) throws Exception; |
||||
|
} |
@ -0,0 +1,87 @@ |
|||||
|
package io.sc.engine.rule.core.code.impl.support.processor; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
import io.sc.engine.rule.core.po.model.Parameter; |
||||
|
import io.sc.engine.rule.core.po.model.processor.ConditionRangeParameterProcessor; |
||||
|
import io.sc.engine.rule.core.util.CodeReplacer; |
||||
|
import io.sc.engine.rule.core.util.ExpressionReplacer; |
||||
|
import io.sc.engine.rule.core.util.JacksonObjectMapper; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import com.fasterxml.jackson.core.type.TypeReference; |
||||
|
|
||||
|
@JsonIgnoreProperties(ignoreUnknown=true) |
||||
|
public class ConditionRange { |
||||
|
private String uuid; |
||||
|
private String condition; |
||||
|
private String value; |
||||
|
|
||||
|
public static List<ConditionRange> parse(String json) throws Exception{ |
||||
|
return JacksonObjectMapper.getDefaultObjectMapper().readValue(json, new TypeReference<List<ConditionRange>>(){}); |
||||
|
} |
||||
|
|
||||
|
public static String generateGroovyCode(Parameter parameter,ConditionRangeParameterProcessor processor) throws Exception{ |
||||
|
if(parameter==null || processor==null){ |
||||
|
return null; |
||||
|
} |
||||
|
try { |
||||
|
List<ConditionRange> conditionRanges =parse(processor.getConditionRange()); |
||||
|
List<ConditionRange> _conditionRanges =new ArrayList<ConditionRange>(); |
||||
|
|
||||
|
//移除没有填写条件的条件范围
|
||||
|
if(conditionRanges!=null && conditionRanges.size()>0) { |
||||
|
for(ConditionRange conditionRange : conditionRanges) { |
||||
|
if(conditionRange.getCondition()!=null && !"".equals(conditionRange.getCondition().trim())) { |
||||
|
_conditionRanges.add(conditionRange); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if(_conditionRanges!=null && _conditionRanges.size()>0) { |
||||
|
StringBuilder sb =new StringBuilder(); |
||||
|
int size =_conditionRanges.size(); |
||||
|
for(int i=0;i<size;i++) { |
||||
|
ConditionRange conditionRange =_conditionRanges.get(i); |
||||
|
if(i==0) { |
||||
|
sb.append("if("); |
||||
|
}else { |
||||
|
sb.append("else if("); |
||||
|
} |
||||
|
sb.append(ExpressionReplacer.groovy(conditionRange.condition, null)); |
||||
|
sb.append(")").append("{").append("\n"); |
||||
|
if(conditionRange.value==null || conditionRange.value.trim().isEmpty()){ |
||||
|
sb.append("\t\t\t").append(ExpressionReplacer.ARGUMENT_NAME).append(".").append(CodeReplacer.fieldName(parameter.getCode())).append(" =null;\n"); |
||||
|
}else { |
||||
|
sb.append("\t\t\t").append(ExpressionReplacer.ARGUMENT_NAME).append(".").append(CodeReplacer.fieldName(parameter.getCode())).append(" =").append(ExpressionReplacer.groovy(conditionRange.value,parameter.getValueType())).append(";\n"); |
||||
|
} |
||||
|
sb.append("\t\t}"); |
||||
|
} |
||||
|
return sb.toString(); |
||||
|
} |
||||
|
}catch(Exception e) { |
||||
|
throw new RuntimeException("There was a Error when generate " + parameter.getName()+ "'s ConditionRange groovy source code.", e); |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
public String getUuid() { |
||||
|
return uuid; |
||||
|
} |
||||
|
public void setUuid(String uuid) { |
||||
|
this.uuid = uuid; |
||||
|
} |
||||
|
public String getCondition() { |
||||
|
return condition; |
||||
|
} |
||||
|
public void setCondition(String condition) { |
||||
|
this.condition = condition; |
||||
|
} |
||||
|
public String getValue() { |
||||
|
return value; |
||||
|
} |
||||
|
public void setValue(String value) { |
||||
|
this.value = value; |
||||
|
} |
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
package io.sc.engine.rule.core.mxgraph.po; |
||||
|
|
||||
|
/** |
||||
|
* 指令集节点 |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
public class CommandSetNode extends GraphNode{ |
||||
|
private String commands; //指令集
|
||||
|
|
||||
|
/** |
||||
|
* 获取指令集 |
||||
|
* @return 指令集 |
||||
|
*/ |
||||
|
public String getCommands() { |
||||
|
return commands; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 设置指令集 |
||||
|
* @param commands 指令集 |
||||
|
*/ |
||||
|
public void setCommands(String commands) { |
||||
|
this.commands = commands; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public String toString() { |
||||
|
return "CommandSetNode [id=" + id |
||||
|
+ ", label=" + label |
||||
|
+ ", commands=" + commands |
||||
|
+ ", outs=" + outs + "]"; |
||||
|
} |
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
package io.sc.engine.rule.core.mxgraph.po; |
||||
|
|
||||
|
/** |
||||
|
* 条件节点 |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
public class ConditionNode extends GraphNode{ |
||||
|
private String condition; //条件
|
||||
|
|
||||
|
/** |
||||
|
* 获取条件 |
||||
|
* @return 条件 |
||||
|
*/ |
||||
|
public String getCondition() { |
||||
|
return condition; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 设置条件 |
||||
|
* @param condition 条件 |
||||
|
*/ |
||||
|
public void setCondition(String condition) { |
||||
|
this.condition = condition; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public String toString() { |
||||
|
return "ConditionNode [id=" + id |
||||
|
+ ", label=" + label |
||||
|
+ ", condition=" + condition |
||||
|
+ ", outs=" + outs + "]"; |
||||
|
} |
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
package io.sc.engine.rule.core.po.lib.processor; |
||||
|
|
||||
|
import io.sc.engine.rule.core.enums.ProcessorType; |
||||
|
import io.sc.engine.rule.core.po.lib.IndicatorProcessor; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import com.fasterxml.jackson.annotation.JsonTypeName; |
||||
|
|
||||
|
/** |
||||
|
* 指标处理器(条件范围操作) |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
@JsonTypeName("CONDITION_RANGE") |
||||
|
@JsonIgnoreProperties(ignoreUnknown=true) |
||||
|
public class ConditionRangeIndicatorProcessor extends IndicatorProcessor { |
||||
|
private String conditionRange;//条件分段函数
|
||||
|
|
||||
|
@Override |
||||
|
public ProcessorType getType() { |
||||
|
return ProcessorType.CONDITION_RANGE; |
||||
|
} |
||||
|
|
||||
|
public String getConditionRange() { |
||||
|
return conditionRange; |
||||
|
} |
||||
|
|
||||
|
public void setConditionRange(String conditionRange) { |
||||
|
this.conditionRange = conditionRange; |
||||
|
} |
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
package io.sc.engine.rule.core.po.model.processor; |
||||
|
|
||||
|
import io.sc.engine.rule.core.enums.ProcessorType; |
||||
|
import io.sc.engine.rule.core.po.model.ParameterProcessor; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import com.fasterxml.jackson.annotation.JsonTypeName; |
||||
|
|
||||
|
/** |
||||
|
* 模型参数处理器(条件范围操作) |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
@JsonTypeName("CONDITION_RANGE") |
||||
|
@JsonIgnoreProperties(ignoreUnknown=true) |
||||
|
public class ConditionRangeParameterProcessor extends ParameterProcessor { |
||||
|
private String conditionRange;//条件分段函数
|
||||
|
|
||||
|
@Override |
||||
|
public ProcessorType getType() { |
||||
|
return ProcessorType.CONDITION_RANGE; |
||||
|
} |
||||
|
|
||||
|
public String getConditionRange() { |
||||
|
return conditionRange; |
||||
|
} |
||||
|
|
||||
|
public void setConditionRange(String conditionRange) { |
||||
|
this.conditionRange = conditionRange; |
||||
|
} |
||||
|
} |
@ -0,0 +1,59 @@ |
|||||
|
package io.sc.engine.rule.core.util; |
||||
|
|
||||
|
import org.springframework.util.StringUtils; |
||||
|
|
||||
|
/** |
||||
|
* 实体代码转换器 |
||||
|
* 将不合法的标识转换为合法标识(将非标识字符替换为下划线) |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
public class CodeConvertor { |
||||
|
/** |
||||
|
* 将字符串转换为符合程序标识符的字符串(由 a-z,A-Z,_ 组成,且开头不能为数字) |
||||
|
* @param str 字符串 |
||||
|
* @return 合法的标识字符串 |
||||
|
*/ |
||||
|
public static String toID(String str) { |
||||
|
if(StringUtils.hasText(str)) { |
||||
|
char[] chars =str.toCharArray(); |
||||
|
if(chars!=null && chars.length>0) { |
||||
|
boolean firstCharIsNumber =true; |
||||
|
for(int i=0;i<chars.length;i++) { |
||||
|
if(firstCharIsNumber) { |
||||
|
char c =chars[i]; |
||||
|
if(c>='0' && c<='9') { |
||||
|
chars[i] ='_'; |
||||
|
} |
||||
|
firstCharIsNumber =false; |
||||
|
continue; |
||||
|
} |
||||
|
char c =chars[i]; |
||||
|
if((c>='0' && c<='9') || (c>='A' && c<='Z') || (c>='a' && c<='z') || (c=='_')) { |
||||
|
|
||||
|
}else { |
||||
|
chars[i] ='_'; |
||||
|
} |
||||
|
} |
||||
|
return new String(chars); |
||||
|
} |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
public static String toName(String str) { |
||||
|
if(StringUtils.hasText(str)) { |
||||
|
char[] chars =str.toCharArray(); |
||||
|
if(chars!=null && chars.length>0) { |
||||
|
for(int i=0;i<chars.length;i++) { |
||||
|
char c =chars[i]; |
||||
|
if(c=='.' || c=='$' || c=='{' || c=='}' || c=='\r' || c=='\n') { |
||||
|
chars[i] ='_'; |
||||
|
} |
||||
|
} |
||||
|
return new String(chars); |
||||
|
} |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
} |
@ -0,0 +1,101 @@ |
|||||
|
package io.sc.engine.rule.core.util; |
||||
|
|
||||
|
import java.util.Arrays; |
||||
|
|
||||
|
/** |
||||
|
* 代码替换器 |
||||
|
* 当代码作为 groovy 或 java 代码的变量或者方法名时,不能和 java 语言保留的关键字冲突,需要进行相应的替换 |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
public class CodeReplacer { |
||||
|
public static final String CLASS_NAME_PREFIX ="C"; |
||||
|
public static final String FIELD_NAME_PREFIX ="_"; |
||||
|
public static final String METHOD_NAME_PREFIX ="_"; |
||||
|
public static final String VAR_NAME_PREFIX ="_"; |
||||
|
|
||||
|
private static final String[] 关键字 =new String[] { |
||||
|
"abstract", "assert", "boolean", "break", "byte", |
||||
|
"case", "catch", "char", "class", "const", |
||||
|
"continue", "default", "do", "double", "else", |
||||
|
"enum", "extends", "final", "finally", "float", |
||||
|
"for", "goto", "if", "implements", "import", |
||||
|
"instanceof", "int", "interface", "long", "native", |
||||
|
"new", "package", "private", "protected", "public", |
||||
|
"return", "short", "static", "strictfp", "super", |
||||
|
"switch", "synchronized", "this", "throw", "throws", |
||||
|
"transient", "try", "void", "volatile", "while" |
||||
|
}; |
||||
|
private static String[] 标志符 =new String[] {"null","true","false"}; |
||||
|
|
||||
|
/** |
||||
|
* 将字符串转换成合法的Java类名 |
||||
|
* @param code 字符串 |
||||
|
* @return 合法的Java类名 |
||||
|
*/ |
||||
|
public static String className(String code) { |
||||
|
return Strings.toUpperFristChar(code); |
||||
|
} |
||||
|
|
||||
|
public static String className(String code,Integer version) { |
||||
|
if(code!=null && version!=null) { |
||||
|
return Strings.toUpperFristChar(code) + "_V" + version; |
||||
|
} |
||||
|
return Strings.toUpperFristChar(code); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将字符串转换成合法的Java方法名 |
||||
|
* @param code 字符串 |
||||
|
* @return 合法的Java方法名 |
||||
|
*/ |
||||
|
public static String methodName(String code) { |
||||
|
if(code!=null) { |
||||
|
if(Arrays.binarySearch(关键字, code)>-1 || Arrays.binarySearch(标志符, code)>-1) { |
||||
|
return METHOD_NAME_PREFIX + code; |
||||
|
} |
||||
|
} |
||||
|
return code; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将字符串转换成合法的Java字段名 |
||||
|
* @param code 字符串 |
||||
|
* @return 合法的Java字段名 |
||||
|
*/ |
||||
|
public static String fieldName(String code) { |
||||
|
if(code!=null) { |
||||
|
if(Arrays.binarySearch(关键字, code)>-1 || Arrays.binarySearch(标志符, code)>-1) { |
||||
|
return FIELD_NAME_PREFIX + code; |
||||
|
} |
||||
|
} |
||||
|
return code; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将字符串转换成合法的Java变量名 |
||||
|
* @param code 字符串 |
||||
|
* @return 合法的Java变量名 |
||||
|
*/ |
||||
|
public static String varName(String code) { |
||||
|
if(code!=null) { |
||||
|
if(Arrays.binarySearch(关键字, code)>-1 || Arrays.binarySearch(标志符, code)>-1) { |
||||
|
return VAR_NAME_PREFIX + code; |
||||
|
} |
||||
|
} |
||||
|
return code; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将字符串转换成合法的Java变量名 |
||||
|
* @param code 字符串 |
||||
|
* @param version 版本 |
||||
|
* @return 合法的Java变量名 |
||||
|
*/ |
||||
|
public static String varName(String code,Integer version) { |
||||
|
if(code!=null && version!=null) { |
||||
|
return Strings.toLowerFristChar(code) + "_V" + version; |
||||
|
} |
||||
|
return Strings.toLowerFristChar(code); |
||||
|
} |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
module.exports = { |
||||
|
presets: [ |
||||
|
"@babel/preset-env", |
||||
|
[ |
||||
|
"@babel/preset-typescript", |
||||
|
{ |
||||
|
allExtensions: true, //支持所有文件扩展名 |
||||
|
}, |
||||
|
], |
||||
|
], |
||||
|
plugins: [ |
||||
|
"@babel/plugin-transform-class-properties", |
||||
|
"@babel/plugin-transform-object-rest-spread", |
||||
|
"@vue/babel-plugin-jsx", |
||||
|
] |
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
.luckysheet-datavisual-quick-menu{width:120px;overflow:auto;margin-top:15px}.luckysheet-datavisual-quick-menu::-webkit-scrollbar{display:none}.luckysheet-datavisual-quick-menu>div{text-align:left;padding:4px 4px;border-right:3px solid #fff;color:#777;cursor:pointer;line-height:1.4em;word-wrap:break-word}.luckysheet-datavisual-quick-menu>div:hover{color:#000}.luckysheet-datavisual-quick-menu>div i{width:15px}.luckysheet-datavisual-quick-menu>div:hover i{color:#ff7e7e}.luckysheet-datavisual-quick-menu>div.luckysheet-datavisual-quick-menu-active{border-right:3px solid #ff7e7e;color:#000;font-weight:700}.luckysheet-datavisual-quick-menu>div.luckysheet-datavisual-quick-menu-active:hover i{color:#000}.luckysheet-datavisual-quick-range{padding:5px 0}.luckysheet-datavisual-range-container{background:#fff;border:1px solid #d9d9d9;border-top:1px solid silver;min-width:20px;width:100%;max-width:200px;display:inline-block}.luckysheet-datavisual-range-container-focus{border:1px solid #4d90fe;box-shadow:inset 0 1px 2px rgba(0,0,0,.3);outline:none}.luckysheet-datavisual-range-input,.luckysheet-datavisual-range-input:focus{background:transparent!important;border:none!important;box-sizing:border-box;box-shadow:none;height:25px;margin:0;outline:none!important;padding:1px 8px!important;width:100%}.luckysheet-datavisual-range-button-container{overflow:hidden;padding:0 0 0 8px;text-align:right;width:21px}.luckysheet-datavisual-range-button-container div{padding:2px 10px 0 10px;font-size:18px;cursor:pointer;color:#6598f3}.luckysheet-datavisual-range-button-container div:hover{color:#ff7e7e}.luckysheet-datavisual-quick-m{margin-top:5px;min-height:500px;top:50px;font-size:12px}.luckysheet-datavisual-quick-list{left:110px;right:0;bottom:0;top:80px;position:absolute;overflow:auto;border-top:1px solid #e5e5e5;padding:5px 3px 35px 3px}.luckysheet-datavisual-quick-list-title{padding:4px 6px;background:#e5e5e5;margin-top:10px}.luckysheet-datavisual-quick-list-ul{overflow:hidden}.luckysheet-datavisual-quick-list-item{display:inline-block;margin:5px 8px;border:1px solid #dadada;width:100px;height:80px}.luckysheet-datavisual-quick-list-item:hover{border:1px solid #ff7e7e;box-shadow:0 0 20px #ff7e7e}.luckysheet-datavisual-quick-list-item img{display:inline-block;width:100px;height:80px}.luckysheet-datavisual-quick-list-item-active{border:1px solid #6598f3;box-shadow:0 0 20px #6598f3}.chart-base-slider .el-slider__runway.show-input{margin-right:72px}.chart-base-slider .el-slider__input.el-input-number--mini{width:56px}.chart-base-slider .input_content{margin:6px 0 0 5px}.title{font-weight:700}.el-row{font-size:12px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.chartSetting{width:100%;height:100%} |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 31 KiB |
@ -0,0 +1,46 @@ |
|||||
|
import packageJson from '../package.json'; |
||||
|
import { createApp } from 'vue'; |
||||
|
import platform from 'platform-core'; |
||||
|
import { ApplicationInitializer, ComponentManager } from 'platform-core'; |
||||
|
import localMocks from './mock'; |
||||
|
import localI18nMessages from './i18n'; |
||||
|
import localMenus from './menus/menus.json'; |
||||
|
import localRoutes from './routes/routes.json'; |
||||
|
import localComponents from './components'; |
||||
|
import App from './App.vue'; |
||||
|
|
||||
|
import 'platform-core/dist/css/platform-core.css'; |
||||
|
import './css/tailwind.css'; |
||||
|
|
||||
|
// 设置远程组件加载器
|
||||
|
// 覆盖 platform-core 包中的 remoteComponentLoader 函数
|
||||
|
// 只有在主前端项目中编写如下的 remoteComponentLoader 函数才能实现 webpack MF 的 shared 功能
|
||||
|
ComponentManager.setRemoteComponentLoader((moduleName: string, componentName: string): any => { |
||||
|
return async () => { |
||||
|
await __webpack_init_sharing__('default'); |
||||
|
const container = window[moduleName]; |
||||
|
if (container) { |
||||
|
await container.init(__webpack_share_scopes__.default); |
||||
|
const factory = await window[moduleName].get(componentName); |
||||
|
return factory(); |
||||
|
} else { |
||||
|
throw new Error('window["' + moduleName + '"] is undefined!'); |
||||
|
} |
||||
|
}; |
||||
|
}); |
||||
|
|
||||
|
//初始化平台
|
||||
|
ApplicationInitializer.initialize({ |
||||
|
moduleName: packageJson.name, |
||||
|
moduleVersion: packageJson.version, |
||||
|
localMocks: localMocks, |
||||
|
localI18nMessages: localI18nMessages, |
||||
|
localMenus: localMenus, |
||||
|
localRoutes: localRoutes, |
||||
|
localComponents: localComponents, |
||||
|
callback: () => { |
||||
|
const app = createApp(App); |
||||
|
app.use(platform); |
||||
|
app.mount('#app'); |
||||
|
}, |
||||
|
}); |
@ -0,0 +1,9 @@ |
|||||
|
dependencies { |
||||
|
api( |
||||
|
// "io.sc:io.sc.platform.groovy:${platform_version}", |
||||
|
// "io.sc:io.sc.platform.system:${platform_version}", |
||||
|
project(":io.sc.platform.groovy"), |
||||
|
project(":io.sc.platform.data"), |
||||
|
project(":io.sc.platform.system"), |
||||
|
) |
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
dependencies { |
||||
|
api( |
||||
|
project(":io.sc.platform.attachment"), |
||||
|
project(":io.sc.platform.attachment.api"), |
||||
|
project(":io.sc.platform.core"), |
||||
|
project(":io.sc.platform.flowable"), |
||||
|
project(":io.sc.platform.orm"), |
||||
|
project(":io.sc.platform.mvc"), |
||||
|
|
||||
|
project(":io.sc.engine.rule.core"), |
||||
|
project(":io.sc.engine.rule.client"), |
||||
|
project(":io.sc.engine.rule.client.spring"), |
||||
|
project(":io.sc.engine.rule.frontend"), |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
processResources { |
||||
|
filesMatching('**/*.java') { |
||||
|
filteringCharset = 'UTF-8' |
||||
|
filter(org.apache.tools.ant.filters.ReplaceTokens, beginToken: '', endToken: '',tokens: [version: '' + project.version]) |
||||
|
} |
||||
|
|
||||
|
doLast{ |
||||
|
// 为了能够兼容 eclipse 和 idea 两种开发环境,调整如下: |
||||
|
// 1. 将 environment.properties 文件放在了 src/main/resources 目录中 |
||||
|
// 2. 在打包时,将该文件删除 |
||||
|
delete "$buildDir/resources/main/running-mode.properties" |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
package io.sc.engine.rule.server.common; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 代码/名称替换器接口 |
||||
|
* 主要是用于在计算机存储和人们阅读之间进行转换,计算机中存储为代码形式,而人们阅读是以名称形式显示 |
||||
|
* 当实体类实现此接口时,通过覆盖 replace 方法实现对实体属性进行代码/名称替换 |
||||
|
*/ |
||||
|
public interface CodeAndNameReplacer { |
||||
|
/** |
||||
|
* 替换代码/名称 |
||||
|
* @param mapping 可替换的 mapping |
||||
|
* @return 是否发生替换 |
||||
|
*/ |
||||
|
public boolean replace(Map<String,String> mapping); |
||||
|
} |
@ -0,0 +1,58 @@ |
|||||
|
package io.sc.engine.rule.server.lib.entity.processor; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonTypeName; |
||||
|
import io.sc.engine.rule.core.enums.ProcessorType; |
||||
|
import io.sc.engine.rule.core.util.ExpressionReplacer; |
||||
|
import io.sc.engine.rule.server.lib.entity.IndicatorProcessorEntity; |
||||
|
import io.sc.engine.rule.server.lib.vo.processor.ConditionRangeIndicatorProcessorVo; |
||||
|
|
||||
|
import javax.persistence.Column; |
||||
|
import javax.persistence.DiscriminatorValue; |
||||
|
import javax.persistence.Entity; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 指标处理器(条件范围操作)实体类 |
||||
|
*/ |
||||
|
@Entity |
||||
|
@DiscriminatorValue("CONDITION_RANGE") |
||||
|
@JsonTypeName("CONDITION_RANGE") |
||||
|
public class ConditionRangeIndicatorProcessorEntity extends IndicatorProcessorEntity { |
||||
|
//条件分段函数
|
||||
|
@Column(name="CONDITION_RANGE_") |
||||
|
private String conditionRange; |
||||
|
|
||||
|
@Override |
||||
|
public ConditionRangeIndicatorProcessorVo toVo() { |
||||
|
ConditionRangeIndicatorProcessorVo vo =new ConditionRangeIndicatorProcessorVo(); |
||||
|
super.toVo(vo); |
||||
|
vo.setType(this.getType()); |
||||
|
vo.setConditionRange(this.getConditionRange()); |
||||
|
return vo; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ProcessorType getType() { |
||||
|
return ProcessorType.CONDITION_RANGE; |
||||
|
} |
||||
|
|
||||
|
public String getConditionRange() { |
||||
|
return conditionRange; |
||||
|
} |
||||
|
|
||||
|
public void setConditionRange(String conditionRange) { |
||||
|
this.conditionRange = conditionRange; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public boolean replace(Map<String, String> mapping) { |
||||
|
String replaced =ExpressionReplacer.replace(this.conditionRange, mapping); |
||||
|
replaced =(replaced==null?"":replaced); |
||||
|
boolean result =false; |
||||
|
if(!replaced.equals(this.conditionRange)) { |
||||
|
result =true; |
||||
|
} |
||||
|
this.conditionRange =replaced; |
||||
|
return result; |
||||
|
} |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
package io.sc.engine.rule.server.lib.vo.processor; |
||||
|
|
||||
|
import io.sc.engine.rule.core.enums.ProcessorType; |
||||
|
import io.sc.engine.rule.server.lib.vo.IndicatorProcessorVo; |
||||
|
|
||||
|
/** |
||||
|
* 指标处理器(条件范围操作)Vo 类 |
||||
|
*/ |
||||
|
public class ConditionRangeIndicatorProcessorVo extends IndicatorProcessorVo { |
||||
|
//条件分段函数
|
||||
|
private String conditionRange; |
||||
|
|
||||
|
@Override |
||||
|
public ProcessorType getType() { |
||||
|
return ProcessorType.CONDITION_RANGE; |
||||
|
} |
||||
|
|
||||
|
public String getConditionRange() { |
||||
|
return conditionRange; |
||||
|
} |
||||
|
|
||||
|
public void setConditionRange(String conditionRange) { |
||||
|
this.conditionRange = conditionRange; |
||||
|
} |
||||
|
} |
@ -0,0 +1,57 @@ |
|||||
|
package io.sc.engine.rule.server.model.entity.processor; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonTypeName; |
||||
|
import io.sc.engine.rule.core.enums.ProcessorType; |
||||
|
import io.sc.engine.rule.core.util.ExpressionReplacer; |
||||
|
import io.sc.engine.rule.server.model.entity.ParameterProcessorEntity; |
||||
|
import io.sc.engine.rule.server.model.vo.processor.ConditionRangeParameterProcessorVo; |
||||
|
|
||||
|
import javax.persistence.Column; |
||||
|
import javax.persistence.DiscriminatorValue; |
||||
|
import javax.persistence.Entity; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 模型参数处理器(条件范围操作)实体类 |
||||
|
*/ |
||||
|
@Entity |
||||
|
@DiscriminatorValue("CONDITION_RANGE") |
||||
|
@JsonTypeName("CONDITION_RANGE") |
||||
|
public class ConditionRangeParameterProcessorEntity extends ParameterProcessorEntity { |
||||
|
//条件分段函数
|
||||
|
@Column(name="CONDITION_RANGE_") |
||||
|
private String conditionRange; |
||||
|
|
||||
|
@Override |
||||
|
public ConditionRangeParameterProcessorVo toVo() { |
||||
|
ConditionRangeParameterProcessorVo vo =new ConditionRangeParameterProcessorVo(); |
||||
|
super.toVo(vo); |
||||
|
vo.setConditionRange(this.getConditionRange()); |
||||
|
return vo; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ProcessorType getType() { |
||||
|
return ProcessorType.CONDITION_RANGE; |
||||
|
} |
||||
|
|
||||
|
public String getConditionRange() { |
||||
|
return conditionRange; |
||||
|
} |
||||
|
|
||||
|
public void setConditionRange(String conditionRange) { |
||||
|
this.conditionRange = conditionRange; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public boolean replace(Map<String, String> mapping) { |
||||
|
String replaced =ExpressionReplacer.replace(this.conditionRange, mapping); |
||||
|
replaced =(replaced==null?"":replaced); |
||||
|
boolean result =false; |
||||
|
if(!replaced.equals(this.conditionRange)) { |
||||
|
result =true; |
||||
|
} |
||||
|
this.conditionRange =replaced; |
||||
|
return result; |
||||
|
} |
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
package io.sc.engine.rule.server.model.vo.processor; |
||||
|
|
||||
|
import io.sc.engine.rule.core.enums.ProcessorType; |
||||
|
import io.sc.engine.rule.server.model.vo.ParameterProcessorVo; |
||||
|
|
||||
|
/** |
||||
|
* 模型参数处理器(条件范围操作)Vo 类 |
||||
|
*/ |
||||
|
public class ConditionRangeParameterProcessorVo extends ParameterProcessorVo { |
||||
|
//条件分段函数
|
||||
|
private String conditionRange; |
||||
|
|
||||
|
@Override |
||||
|
public ProcessorType getType() { |
||||
|
return ProcessorType.CONDITION_RANGE; |
||||
|
} |
||||
|
|
||||
|
public String getConditionRange() { |
||||
|
return conditionRange; |
||||
|
} |
||||
|
|
||||
|
public void setConditionRange(String conditionRange) { |
||||
|
this.conditionRange = conditionRange; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,46 @@ |
|||||
|
package io.sc.engine.rule.server.util; |
||||
|
|
||||
|
import java.util.Comparator; |
||||
|
import java.util.Map; |
||||
|
import java.util.TreeMap; |
||||
|
|
||||
|
public class CodeAndNameMapping { |
||||
|
private Map<String,String> code2NameMapping =createOrderableMap(); |
||||
|
private Map<String,String> name2CodeMapping =createOrderableMap(); |
||||
|
|
||||
|
public void addCode2Name(String code,String name) { |
||||
|
code2NameMapping.put(code, name); |
||||
|
} |
||||
|
|
||||
|
public void addName2Code(String name,String code) { |
||||
|
name2CodeMapping.put(name, code); |
||||
|
} |
||||
|
|
||||
|
public Map<String, String> getCode2NameMapping() { |
||||
|
return code2NameMapping; |
||||
|
} |
||||
|
public void setCode2NameMapping(Map<String, String> code2NameMapping) { |
||||
|
this.code2NameMapping = code2NameMapping; |
||||
|
} |
||||
|
public Map<String, String> getName2CodeMapping() { |
||||
|
return name2CodeMapping; |
||||
|
} |
||||
|
public void setName2CodeMapping(Map<String, String> name2CodeMapping) { |
||||
|
this.name2CodeMapping = name2CodeMapping; |
||||
|
} |
||||
|
|
||||
|
private Map<String,String> createOrderableMap(){ |
||||
|
return new TreeMap<String,String>(new Comparator<String>() { |
||||
|
@Override |
||||
|
public int compare(String o1, String o2) { |
||||
|
if(o1.length()>o2.length()) { |
||||
|
return -1; |
||||
|
}else if(o1.length()<o2.length()) { |
||||
|
return 1; |
||||
|
}else { |
||||
|
return o2.compareTo(o1); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
@ -0,0 +1,44 @@ |
|||||
|
/* |
||||
|
* 自动组件扫描插件配置 |
||||
|
* 功能: 该插件配置为框架提供自动扫描组件的包名,配置的包名将会自动被 spring 进行扫描 |
||||
|
* 使用说明: |
||||
|
* includes: 包含自动扫描的包名列表 |
||||
|
* excludes: 排除自动扫描的包名列表 |
||||
|
* 注意: 当一个包名同时存在于 includes 和 excludes 中, excludes 优先, 即该包不会被自动扫描 |
||||
|
*/ |
||||
|
|
||||
|
{ |
||||
|
"includes":[ |
||||
|
"io.sc.engine.rule.server.asciidoc.service.impl", |
||||
|
"io.sc.engine.rule.server.dictionary.controller", |
||||
|
"io.sc.engine.rule.server.lib.controller", |
||||
|
"io.sc.engine.rule.server.model.controller", |
||||
|
"io.sc.engine.rule.server.resource.controller", |
||||
|
"io.sc.engine.rule.server.scorecard.controller", |
||||
|
"io.sc.engine.rule.server.testcase.controller", |
||||
|
"io.sc.engine.rule.server.migration.controller", |
||||
|
|
||||
|
"io.sc.engine.rule.server.dictionary.service.impl", |
||||
|
"io.sc.engine.rule.server.lib.service.impl", |
||||
|
"io.sc.engine.rule.server.migration.service.impl", |
||||
|
"io.sc.engine.rule.server.model.service.impl", |
||||
|
"io.sc.engine.rule.server.resource.service.impl", |
||||
|
"io.sc.engine.rule.server.scorecard.service.impl", |
||||
|
"io.sc.engine.rule.server.service.impl", |
||||
|
"io.sc.engine.rule.server.testcase.service.impl", |
||||
|
|
||||
|
"io.sc.engine.rule.server.validator.service", |
||||
|
|
||||
|
"io.sc.engine.rule.server.common.bean", |
||||
|
"io.sc.engine.rule.server.common.initializer", |
||||
|
"io.sc.engine.rule.server.testcase.bean", |
||||
|
|
||||
|
"io.sc.engine.rule.server.jpa.listener", |
||||
|
"io.sc.engine.rule.server.jpa.listener.handler", |
||||
|
|
||||
|
"io.sc.engine.rule.server.workflow.controller", |
||||
|
"io.sc.engine.rule.server.workflow.listener", |
||||
|
"io.sc.engine.rule.server.workflow.service.impl" |
||||
|
], |
||||
|
"excludes":[] |
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
dependencies { |
||||
|
api( |
||||
|
project(":io.sc.platform.orm.api"), |
||||
|
) |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
dependencies { |
||||
|
api( |
||||
|
project(":io.sc.platform.mvc"), |
||||
|
project(":io.sc.platform.security"), |
||||
|
|
||||
|
project(":io.sc.platform.attachment.api"), |
||||
|
) |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
/* |
||||
|
* 自动组件扫描插件配置 |
||||
|
* 功能: 该插件配置为框架提供自动扫描组件的包名,配置的包名将会自动被 spring 进行扫描 |
||||
|
* 使用说明: |
||||
|
* includes: 包含自动扫描的包名列表 |
||||
|
* excludes: 排除自动扫描的包名列表 |
||||
|
* 注意: 当一个包名同时存在于 includes 和 excludes 中, excludes 优先, 即该包不会被自动扫描 |
||||
|
*/ |
||||
|
|
||||
|
{ |
||||
|
"includes":[ |
||||
|
"io.sc.platform.attachment.controller", |
||||
|
"io.sc.platform.attachment.service.impl" |
||||
|
], |
||||
|
"excludes":[] |
||||
|
} |
Loading…
Reference in new issue