|
|
@ -16,6 +16,7 @@ import io.sc.engine.rule.core.po.lib.IndicatorProcessor; |
|
|
import io.sc.engine.rule.core.po.lib.Lib; |
|
|
import io.sc.engine.rule.core.po.lib.Lib; |
|
|
import io.sc.engine.rule.core.po.model.Model; |
|
|
import io.sc.engine.rule.core.po.model.Model; |
|
|
import io.sc.engine.rule.core.po.model.Parameter; |
|
|
import io.sc.engine.rule.core.po.model.Parameter; |
|
|
|
|
|
import io.sc.engine.rule.core.po.model.ParameterInOptionAddtion; |
|
|
import io.sc.engine.rule.core.po.model.ParameterInOptionItem; |
|
|
import io.sc.engine.rule.core.po.model.ParameterInOptionItem; |
|
|
import io.sc.engine.rule.core.po.model.parameter.InOptionParameter; |
|
|
import io.sc.engine.rule.core.po.model.parameter.InOptionParameter; |
|
|
import io.sc.engine.rule.core.po.model.parameter.IndicatorParameter; |
|
|
import io.sc.engine.rule.core.po.model.parameter.IndicatorParameter; |
|
|
@ -66,59 +67,108 @@ public class ExecuteUnit4Resource extends ExecuteUnit { |
|
|
if (parameters == null || parameters.isEmpty()) { |
|
|
if (parameters == null || parameters.isEmpty()) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
for(Parameter parameter : parameters){ |
|
|
for(Parameter parameter : parameters) { |
|
|
if(!StringUtils.hasText(parameter.getProperties())) { continue; } |
|
|
if (!StringUtils.hasText(parameter.getProperties())) { |
|
|
List<ParameterProperty> properties =ObjectMapperUtil.json().readValue(parameter.getProperties(), new TypeReference<List<ParameterProperty>>() {}); |
|
|
continue; |
|
|
if(properties==null || properties.isEmpty()) { continue; } |
|
|
} |
|
|
for(ParameterProperty property : properties){ |
|
|
List<ParameterProperty> properties = ObjectMapperUtil.json().readValue(parameter.getProperties(), new TypeReference<List<ParameterProperty>>() { |
|
|
|
|
|
}); |
|
|
|
|
|
//1) 处理参数的扩展属性中的枚举值
|
|
|
|
|
|
if (properties != null && !properties.isEmpty()) { |
|
|
|
|
|
for (ParameterProperty property : properties) { |
|
|
// 替换 value
|
|
|
// 替换 value
|
|
|
PlaceHolder placeHolder =PlaceHolder.extract(property.value); |
|
|
PlaceHolder placeHolder = PlaceHolder.extract(property.value); |
|
|
Set<String> enumRefs =placeHolder.getEnumRefs(); |
|
|
Set<String> enumRefs = placeHolder.getEnumRefs(); |
|
|
if(enumRefs==null || enumRefs.isEmpty()) { continue; } |
|
|
if (enumRefs != null && !enumRefs.isEmpty()) { |
|
|
for(String enumRef : enumRefs){ |
|
|
for (String enumRef : enumRefs) { |
|
|
String enumValue =findEnumValue(enumRef); |
|
|
String enumValue = findEnumValue(enumRef); |
|
|
if(!StringUtils.hasText(enumValue)){ continue; } |
|
|
if (!StringUtils.hasText(enumValue)) { |
|
|
property.value =property.value.replace("#{" + enumRef.replace(".","}.#{") + "}",enumValue); |
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
property.value = property.value.replace("#{" + enumRef.replace(".", "}.#{") + "}", enumValue); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 替换 prompt
|
|
|
// 替换 prompt
|
|
|
placeHolder =PlaceHolder.extract(property.prompt); |
|
|
placeHolder = PlaceHolder.extract(property.prompt); |
|
|
enumRefs =placeHolder.getEnumRefs(); |
|
|
enumRefs = placeHolder.getEnumRefs(); |
|
|
if(enumRefs==null || enumRefs.isEmpty()) { continue; } |
|
|
if (enumRefs != null && !enumRefs.isEmpty()) { |
|
|
for(String enumRef : enumRefs){ |
|
|
for (String enumRef : enumRefs) { |
|
|
String enumValue =findEnumValue(enumRef); |
|
|
String enumValue = findEnumValue(enumRef); |
|
|
if(!StringUtils.hasText(enumValue)){ continue; } |
|
|
if (!StringUtils.hasText(enumValue)) { |
|
|
property.prompt =property.prompt.replace("#{" + enumRef.replace(".","}.#{") + "}",enumValue); |
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
property.prompt = property.prompt.replace("#{" + enumRef.replace(".", "}.#{") + "}", enumValue); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
parameter.setProperties(ObjectMapperUtil.json().writeValueAsString(properties)); |
|
|
parameter.setProperties(ObjectMapperUtil.json().writeValueAsString(properties)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 处理选项参数的选项
|
|
|
// 2) 处理选项参数的选项中的枚举值
|
|
|
if(ParameterType.IN_OPTION.equals(parameter.getType())){ |
|
|
if(ParameterType.IN_OPTION.equals(parameter.getType())){ |
|
|
InOptionParameter inOptionParameter =(InOptionParameter)parameter; |
|
|
InOptionParameter inOptionParameter =(InOptionParameter)parameter; |
|
|
//选项
|
|
|
|
|
|
List<ParameterInOptionItem> items =inOptionParameter.getOptions(); |
|
|
List<ParameterInOptionItem> items =inOptionParameter.getOptions(); |
|
|
if(items==null || items.isEmpty()) { continue; } |
|
|
if(items==null || items.isEmpty()) { continue; } |
|
|
for(ParameterInOptionItem item : items){ |
|
|
for(ParameterInOptionItem item : items){ |
|
|
|
|
|
//显示条件
|
|
|
PlaceHolder placeHolder =PlaceHolder.extract(item.getCondition()); |
|
|
PlaceHolder placeHolder =PlaceHolder.extract(item.getCondition()); |
|
|
Set<String> enumRefs =placeHolder.getEnumRefs(); |
|
|
Set<String> enumRefs =placeHolder.getEnumRefs(); |
|
|
if(enumRefs==null || enumRefs.isEmpty()) { continue; } |
|
|
if(enumRefs!=null && !enumRefs.isEmpty()) { |
|
|
for(String enumRef : enumRefs){ |
|
|
for (String enumRef : enumRefs) { |
|
|
String enumValue =findEnumValue(enumRef); |
|
|
String enumValue = findEnumValue(enumRef); |
|
|
if(!StringUtils.hasText(enumValue)){ continue; } |
|
|
if (!StringUtils.hasText(enumValue)) { |
|
|
item.setCondition(item.getCondition().replace("#{" + enumRef.replace(".","}.#{") + "}",enumValue)); |
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
item.setCondition(item.getCondition().replace("#{" + enumRef.replace(".", "}.#{") + "}", enumValue)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//自动选择条件
|
|
|
placeHolder =PlaceHolder.extract(item.getConfig()); |
|
|
placeHolder =PlaceHolder.extract(item.getConfig()); |
|
|
enumRefs =placeHolder.getEnumRefs(); |
|
|
enumRefs =placeHolder.getEnumRefs(); |
|
|
if(enumRefs==null || enumRefs.isEmpty()) { continue; } |
|
|
if(enumRefs!=null && !enumRefs.isEmpty()) { |
|
|
for(String enumRef : enumRefs){ |
|
|
for (String enumRef : enumRefs) { |
|
|
String enumValue =findEnumValue(enumRef); |
|
|
String enumValue = findEnumValue(enumRef); |
|
|
if(!StringUtils.hasText(enumValue)){ continue; } |
|
|
if (!StringUtils.hasText(enumValue)) { |
|
|
item.setConfig(item.getConfig().replace("#{" + enumRef.replace(".","}.#{") + "}",enumValue)); |
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
item.setConfig(item.getConfig().replace("#{" + enumRef.replace(".", "}.#{") + "}", enumValue)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 3) 处理选项参数不录项中的枚举值
|
|
|
|
|
|
if(ParameterType.IN_OPTION.equals(parameter.getType())){ |
|
|
|
|
|
InOptionParameter inOptionParameter =(InOptionParameter)parameter; |
|
|
|
|
|
List<ParameterInOptionAddtion> additions =inOptionParameter.getAdditons(); |
|
|
|
|
|
if(additions==null || additions.isEmpty()) { continue; } |
|
|
|
|
|
for(ParameterInOptionAddtion addition : additions){ |
|
|
|
|
|
//显示条件
|
|
|
|
|
|
PlaceHolder placeHolder =PlaceHolder.extract(addition.getCondition()); |
|
|
|
|
|
Set<String> enumRefs =placeHolder.getEnumRefs(); |
|
|
|
|
|
if(enumRefs!=null && !enumRefs.isEmpty()) { |
|
|
|
|
|
for (String enumRef : enumRefs) { |
|
|
|
|
|
String enumValue = findEnumValue(enumRef); |
|
|
|
|
|
if (!StringUtils.hasText(enumValue)) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
addition.setCondition(addition.getCondition().replace("#{" + enumRef.replace(".", "}.#{") + "}", enumValue)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//默认值
|
|
|
|
|
|
placeHolder =PlaceHolder.extract(addition.getDefaultValue()); |
|
|
|
|
|
enumRefs =placeHolder.getEnumRefs(); |
|
|
|
|
|
if(enumRefs!=null && !enumRefs.isEmpty()) { |
|
|
|
|
|
for (String enumRef : enumRefs) { |
|
|
|
|
|
String enumValue = findEnumValue(enumRef); |
|
|
|
|
|
if (!StringUtils.hasText(enumValue)) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
addition.setDefaultValue(addition.getDefaultValue().replace("#{" + enumRef.replace(".", "}.#{") + "}", enumValue)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
//
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|