|
|
@ -1,15 +1,20 @@ |
|
|
|
package io.sc.engine.rule.server.lib.entity.processor; |
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonTypeName; |
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
|
import com.fasterxml.jackson.core.type.TypeReference; |
|
|
|
import io.sc.engine.rule.core.enums.ProcessorType; |
|
|
|
import io.sc.engine.rule.core.enums.ReplaceMode; |
|
|
|
import io.sc.engine.rule.server.common.service.support.ParameterAndValueType; |
|
|
|
import io.sc.engine.rule.server.lib.entity.IndicatorProcessorEntity; |
|
|
|
import io.sc.engine.rule.server.lib.vo.processor.ObjectPropertiesIndicatorProcessorVo; |
|
|
|
import io.sc.platform.util.ObjectMapperUtil; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
import javax.persistence.Column; |
|
|
|
import javax.persistence.DiscriminatorValue; |
|
|
|
import javax.persistence.Entity; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* 模型参数处理器(对象属性操作)实体类 |
|
|
@ -66,7 +71,7 @@ public class ObjectPropertiesIndicatorProcessorEntity extends IndicatorProcessor |
|
|
|
} |
|
|
|
this.objectCondition =replaced; |
|
|
|
|
|
|
|
replaced =parameterAndValueType.replace(this.objectProperties, mode); |
|
|
|
replaced =replaceJsonString(this.objectProperties, parameterAndValueType, mode); |
|
|
|
replaced =(replaced==null?"":replaced); |
|
|
|
if(!replaced.equals(this.objectProperties)) { |
|
|
|
result =true; |
|
|
@ -74,4 +79,50 @@ public class ObjectPropertiesIndicatorProcessorEntity extends IndicatorProcessor |
|
|
|
this.objectProperties =replaced; |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private String replaceJsonString(String json, ParameterAndValueType parameterAndValueType, ReplaceMode mode) { |
|
|
|
if(!StringUtils.hasText(json)){ |
|
|
|
return json; |
|
|
|
} |
|
|
|
try { |
|
|
|
List<ObjectPropertiesItem> items = ObjectMapperUtil.json().readValue(json, new TypeReference<List<ObjectPropertiesItem>>() { |
|
|
|
}); |
|
|
|
for (ObjectPropertiesItem item : items) { |
|
|
|
item.setExpression(parameterAndValueType.replace(item.getExpression(), mode)); |
|
|
|
} |
|
|
|
return ObjectMapperUtil.json().writeValueAsString(items); |
|
|
|
} catch (Exception e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static class ObjectPropertiesItem { |
|
|
|
private String code; |
|
|
|
private String name; |
|
|
|
private String expression; |
|
|
|
|
|
|
|
public String getCode() { |
|
|
|
return code; |
|
|
|
} |
|
|
|
|
|
|
|
public void setCode(String code) { |
|
|
|
this.code = code; |
|
|
|
} |
|
|
|
|
|
|
|
public String getName() { |
|
|
|
return name; |
|
|
|
} |
|
|
|
|
|
|
|
public void setName(String name) { |
|
|
|
this.name = name; |
|
|
|
} |
|
|
|
|
|
|
|
public String getExpression() { |
|
|
|
return expression; |
|
|
|
} |
|
|
|
|
|
|
|
public void setExpression(String expression) { |
|
|
|
this.expression = expression; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|