提交 3640194c 编写于 作者: sq3536's avatar sq3536

优化

上级 37988d56
......@@ -6,6 +6,8 @@ import cn.ibizlab.core.rule.domain.ExecLog;
import cn.ibizlab.core.rule.domain.ExecResult;
import cn.ibizlab.core.rule.service.IExecLogService;
import cn.ibizlab.core.rule.service.IExecResultService;
import cn.ibizlab.util.helper.DataObject;
import cn.ibizlab.util.helper.RuleUtils;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import lombok.extern.slf4j.Slf4j;
import org.kie.api.KieBase;
......@@ -61,53 +63,46 @@ public class BaseEntityServiceImpl implements BaseEntityService
result.setRuleName(RULENAME);
result.setName(RU_EXECRESULTNAME);
result.setRetValue(RETVALUE);
if(param.get("systemid")!=null)
result.setSystemId(param.get("systemid").toString());
if(BUSINESSCAT!=null && BUSINESSCAT instanceof String){
result.setBusinessCat(String.valueOf(BUSINESSCAT));
}
if(KEYVALUEFIELD==null)
{
result.setKeyValueField(param.getRowKey());
}
else
{
result.setKeyValueField(KEYVALUEFIELD.toString());
}
result.setKeyValueField(DataObject.getStringValue(valueOf(KEYVALUEFIELD),param.getRowKey()));
if(METRICFIELD!=null) {
Object val = METRICFIELD;
if ( (val instanceof BigDecimal))
result.setMetricField(((BigDecimal) val));
else if ( (val instanceof BigInteger))
result.setMetricField(new BigDecimal((BigInteger) val));
else if ( (val instanceof Double))
result.setMetricField(new BigDecimal((Double) val));
else if ( (val instanceof Float))
result.setMetricField(new BigDecimal(((Float) val).doubleValue()));
else if ( (val instanceof Long))
result.setMetricField(new BigDecimal((Long) val));
else if ( (val instanceof Integer))
result.setMetricField(new BigDecimal((int)val));
if(1==RETVALUE)
{
result.setSystemId(DataObject.getStringValue(param.get("systemid"),null));
result.setBusinessCat(DataObject.getStringValue(valueOf(BUSINESSCAT),null));
if(METRICFIELD!=null) {
Object val = METRICFIELD;
if ( (val instanceof BigDecimal))
result.setMetricField(((BigDecimal) val));
else if ( (val instanceof Double))
result.setMetricField(new BigDecimal((Double) val));
else if ( (val instanceof Float))
result.setMetricField(new BigDecimal(((Float) val).doubleValue()));
else if ( (val instanceof Integer))
result.setMetricField(new BigDecimal((int)val));
else
result.setMetricField(new BigDecimal(1));
}
else
result.setMetricField(new BigDecimal(1));
Object timefield=valueOf(TIMEFIELD);
if(timefield!=null&&timefield instanceof Timestamp)
result.setTimeField((Timestamp)timefield);
if(EXT1FIELD!=null) {
String ext1=valuesOf(EXT1FIELD);
if(ext1!=null&&ext1.length()>330)
ext1=ext1.substring(0,330)+"...";
result.setExt1Field(ext1);
}
if(EXT2FIELD!=null) {
String ext2=valuesOf(EXT2FIELD);
if(ext2!=null&&ext2.length()>330)
ext2=ext2.substring(0,330)+"...";
result.setExt2Field(ext2);
}
}
else
result.setMetricField(new BigDecimal(1));
if(DOMAINSFIELD!=null)
{
result.setDomainsField(DOMAINSFIELD.toString());
}
else
{
result.setDomainsField(result.getKeyValueField());
}
if(TIMEFIELD!=null&&TIMEFIELD instanceof Timestamp)
result.setTimeField((Timestamp)TIMEFIELD);
if(EXT1FIELD!=null)
result.setExt1Field(EXT1FIELD.toString());
if(EXT2FIELD!=null)
result.setExt2Field(EXT2FIELD.toString());
Object resultDataSource = ExecResultExService.Default_ResultDataSource;
Object resultTableName = ExecResultExService.Default_ResultTableName;
if(param.containsKey(RuleEngineExService.Setting_ResultDataSource)){
......@@ -123,20 +118,22 @@ public class BaseEntityServiceImpl implements BaseEntityService
if(DIMFIELD == null){
return;
}
List dims = new ArrayList();
List dims = null;
if(DIMFIELD instanceof List){
dims = (List)DIMFIELD;
}else if(DIMFIELD instanceof String){
dims.add(DIMFIELD);
}else {
dims = new ArrayList();
dims.add(DataObject.getStringValue(DIMFIELD,null));
}
for(Object obj : dims){
if(StringUtils.isEmpty(obj))
result.setDimField(DataObject.getStringValue(obj,null));
if(StringUtils.isEmpty(result.getDimField()))
continue;
result.setDimField(String.valueOf(obj));
result.setId(result.getDefaultKey(true).toString());
if(result.getRetValue()==1)
{
result.setRuleId(RULECODE);
result.setDomainsField(DataObject.getStringValue(valueOf(DOMAINSFIELD),result.getDimField()));
ruExecResultService.saveAsync(result);
}
else
......@@ -146,6 +143,45 @@ public class BaseEntityServiceImpl implements BaseEntityService
}
}
private Object valueOf(Object val)
{
Object rt=null;
if(val!=null && val instanceof List)
{
for(Object item:(List)val){
if(item!=null) {
if(rt==null|| RuleUtils.gt(rt,val))
rt = item;
}
}
}
else if(val!=null)
{
rt=val;
}
return rt;
}
private String valuesOf(Object val)
{
String rt=null;
if(val!=null && val instanceof List)
{
for(Object item:(List)val){
if(item!=null) {
if(!StringUtils.isEmpty(rt))
rt=rt+",";
rt = rt+DataObject.getStringValue(item,"");
}
}
}
else
{
rt=DataObject.getStringValue(val,null);
}
return rt;
}
@Autowired
private IExecResultService ruExecResultService;
......
......@@ -15,6 +15,7 @@ import cn.ibizlab.core.rule.domain.RuleItem;
import cn.ibizlab.core.rule.service.IExecLogService;
import cn.ibizlab.core.rule.service.IRuleItemService;
import cn.ibizlab.core.rule.service.impl.RuleEngineServiceImpl;
import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.helper.CachedBeanCopier;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
......@@ -94,11 +95,15 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
{
CachedBeanCopier.copy(get(et.getEngineId()), et);
if("RUNNING".equalsIgnoreCase(et.getState()))
throw new BadRequestAlertException("引擎正在执行中,不能重复执行","RuleEngine",et.getEngineId());
BaseRequest msg=new BaseRequest();
msg.setId(IdWorker.getIdStr());
msg.setModel(et.getModelName());
msg.setEngineId(et.getEngineId());
java.sql.Timestamp starttime = new java.sql.Timestamp(System.currentTimeMillis());
liteDataService.processDataModel(et.getModelId(), et.getLastRuntime(), new LiteDataCallback<List<EntityObj>>() {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册