提交 598966bc 编写于 作者: zhouweidong's avatar zhouweidong

补充空配置时不生成drools文件,业务类别属性判断

上级 a5e36e12
......@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Primary;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.io.File;
import java.util.*;
......@@ -66,6 +67,7 @@ public class RuleItemExService extends RuleItemServiceImpl {
@Override
public RuleItem buildRuleFile(RuleItem et){
try {
boolean hasBusinesscatField=false;
//获取实体配置信息
String strCfg = et.getCfg();
String strRuleid = et.getRuleId();
......@@ -82,6 +84,16 @@ public class RuleItemExService extends RuleItemServiceImpl {
log.error(String.format("由于[%s-%s]规则尚未配置规则,将不予生成drl规则文件~!",strRuleid,strRulename));
return et;
}
JSONObject cfg=JSONObject.parseObject(strCfg);
JSONArray fieldArray= cfg.getJSONArray("field") , groupArray =cfg.getJSONArray("group") ,releationArray=cfg.getJSONArray("releation");
if( (ObjectUtils.isEmpty(fieldArray) || (!ObjectUtils.isEmpty(fieldArray) && fieldArray.size()==0 )) &&
(ObjectUtils.isEmpty(groupArray) || (!ObjectUtils.isEmpty(groupArray) && groupArray.size()==0 )) &&
(ObjectUtils.isEmpty(releationArray) || (!ObjectUtils.isEmpty(releationArray) && releationArray.size()==0 ))
)
{
log.error(String.format("由于[%s-%s]规则尚未配置规则,将不予生成drl规则文件~!",strRuleid,strRulename));
return et;
}
//准备模板参数
JSONObject obj=null;
if(!StringUtils.isEmpty(strFieldset)){
......@@ -106,7 +118,7 @@ public class RuleItemExService extends RuleItemServiceImpl {
synchronized(lockModel)
{
Hashtable<String,String> modelset=new Hashtable<String,String>();
param.put("rulecond",parseGroup(JSONObject.parseObject(strCfg),modelset));
param.put("rulecond",parseGroup(cfg,modelset));
param.put("releationcond",parseRelationArr(JSONObject.parseObject(strCfg),modelset));
String strCond="";
......@@ -125,7 +137,15 @@ public class RuleItemExService extends RuleItemServiceImpl {
param.put("keyvaluefield",getFieldkeyset(strKeyvaluefield,modelset));
param.put("ext2field",getFieldset(strExt2field,modelset));
param.put("domainsfield",getFieldset(strDomainsfield,modelset));
param.put("businesscat",StringUtils.isEmpty(strBusinesscatfield)?et.getBusinessCat():getFieldset(strBusinesscatfield,modelset));
param.put("dimfield",getFieldset(strDomainsfield,modelset));
if (!StringUtils.isEmpty(strBusinesscatfield)) {
hasBusinesscatField = true;
param.put("businesscatfield", getFieldset(strBusinesscatfield, modelset));
} else {
strBusinesscatfield = et.getBusinessCat();
param.put("businesscat", strBusinesscatfield);
}
param.put("hasbusinesscatfield", hasBusinesscatField);
}
String[] groupArr=strRuleGroup.split(";");
......
......@@ -10,7 +10,7 @@ activation-group "<#if rulecode??>${rulecode}</#if>"
item:ModelObj( <#if rulecond??>${rulecond}</#if> )
<#if (releationcond??)>${releationcond}</#if>
then
BaseService.saveResult(item,"<#if rulecode??>${rulecode}</#if>","<#if rulename??>${rulename}</#if>","<#if memo??>${memo}</#if>",<#if businesscat??>${businesscat}</#if>,1,${keyvaluefield},${domainsfield},${dimfield},${metricfield},${timefield},${ext1field},${ext2field});
BaseService.saveResult(item,"<#if rulecode??>${rulecode}</#if>","<#if rulename??>${rulename}</#if>","<#if memo??>${memo}</#if>",<#if businesscat??><#if hasbusinesscatfield>${businesscatfield}<#else>"${businesscat}"</#if></#if>,1,${keyvaluefield},${domainsfield},${dimfield},${metricfield},${timefield},${ext1field},${ext2field});
end
rule "<#if rulecode??>${rulecode}_d</#if>"
salience 0
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册