提交 f46d11a7 编写于 作者: xuhui961310148's avatar xuhui961310148

update:引擎同步执行调整

上级 6df239dc
......@@ -140,55 +140,42 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
@Override
public RuleEngine syncRun(RuleEngine et) {
log.info("引擎同步校验入参:" + JSON.toJSONString(et));
if(!StringUtils.isEmpty(et.getEngineId())) {
if (StringUtils.isEmpty(et.get("datakeys"))){
return super.syncRun(et);
}
String dataKeys = et.get("datakeys").toString();
boolean flag = false;
String ruleIds = null;
if (!StringUtils.isEmpty(et.get("ruleids"))){
flag = true;
ruleIds = et.get("ruleids").toString();
}
CachedBeanCopier.copy(get(et.getEngineId()), et);
String batch = BaseEntityServiceImpl.Tag_Batch_SyncRun + "_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new java.util.Date())+"["+et.getModelName()+"]";
List<EntityObj> lists = JSON.parseArray(dataKeys,EntityObj.class);
BaseRequest msg = new BaseRequest();
if (!StringUtils.isEmpty(ruleIds)){
msg = proxy.getRequest2(et.getEngineId(),batch,ruleIds).copy(true);
}else {
msg = proxy.getRequest(et.getEngineId(),batch).copy(true);
}
msg.setId(IdWorker.getIdStr());
ExecLog execlog=new ExecLog();
execlog.setId(msg.getId());
execlog.setName(msg.getBatch());
execlog.setKeyValueField(msg.getModel());
execlog.setSystemId(msg.getSystemid());
ruExecLogService.create(execlog);
msg.setDatas(liteDataService.getModelObjs(msg.getModelId(),msg.getFillpropertys(),lists));
baseEntityService.processAll(msg);
if (flag){
ArrayList<String> ruleIdsList = new ArrayList<>();
String[] array = ruleIds.split(";|,");
for (int i = 0; i < array.length; i++) {
ruleIdsList.add(array[i]);
}
ArrayList<String> dataKeysList = new ArrayList<>();
for (EntityObj entityObj : lists) {
for (Map.Entry<String, Object> entries : entityObj.entrySet()){
dataKeysList.add((String) entries.getValue());
}
}
QueryWrapper<ExecResult> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("systemid",et.getSystemId()).in("ruleid",ruleIdsList).in("keyvaluefield",dataKeysList);
List<ExecResult> execResults = execResultExService.list(queryWrapper);
et.set("result",execResults);
return et;
if (StringUtils.isEmpty(et.getEngineId()) || StringUtils.isEmpty(et.getDatakeys()))
return super.syncRun(et);
String dataKeys = et.getDatakeys();
String ruleIds = et.getRuleids();
CachedBeanCopier.copy(get(et.getEngineId()), et);
String batch = BaseEntityServiceImpl.Tag_Batch_SyncRun + "_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new java.util.Date())+"["+et.getModelName()+"]";
List<EntityObj> lists = JSON.parseArray(dataKeys,EntityObj.class);
BaseRequest msg = new BaseRequest();
if (!StringUtils.isEmpty(ruleIds)){
msg = proxy.getRequest2(et.getEngineId(),batch,ruleIds).copy(true);
}else {
msg = proxy.getRequest(et.getEngineId(),batch).copy(true);
}
msg.setId(IdWorker.getIdStr());
ExecLog execlog=new ExecLog();
execlog.setId(msg.getId());
execlog.setName(msg.getBatch());
execlog.setKeyValueField(msg.getModel());
execlog.setSystemId(msg.getSystemid());
ruExecLogService.create(execlog);
msg.setDatas(liteDataService.getModelObjs(msg.getModelId(),msg.getFillpropertys(),lists));
baseEntityService.processAll(msg);
List<String> ruleIdsList = msg.getRuleIds();
ArrayList<String> dataKeysList = new ArrayList<>();
for (EntityObj entityObj : lists) {
for (Map.Entry<String, Object> entries : entityObj.entrySet()){
dataKeysList.add((String) entries.getValue());
}
}
return super.syncRun(et);
QueryWrapper<ExecResult> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("systemid",et.getSystemId()).in("ruleid",ruleIdsList).in("keyvaluefield",dataKeysList);
List<ExecResult> execResults = execResultExService.list(queryWrapper);
et.setResult(JSON.toJSONString(execResults));
et.setDatakeys(dataKeys);
et.setRuleids(ruleIds);
return et;
}
@Autowired
......@@ -267,6 +254,7 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
msg.setResultDataSource(resultDataSource);
msg.setResultTableName(resultTableName);
List<String> rules = new ArrayList<>();
List<String> ruleIdList = new ArrayList<>();
DataModel dataModel=liteModelService.getDataModel(et.getModelId());
HashSet<String> fillpropertys=new HashSet<>();
Wrapper<RuleItem> wrappers = Wrappers.<RuleItem>lambdaQuery().eq(RuleItem::getModelId,et.getModelId()).ne(RuleItem::getGroup,"REP").like(RuleItem::getGroup,et.getGroup());
......@@ -279,6 +267,7 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
wrappers = Wrappers.<RuleItem>lambdaQuery().in(RuleItem::getRuleId,collection);
}
ruleItemService.list(wrappers).forEach(ruleItem -> {
ruleIdList.add(ruleItem.getRuleId());
String path=rulePath + et.getGroup() + File.separator + ruleItem.getRuleId() + ".drl";
File file=new File(path);
if(!file.exists())
......@@ -304,6 +293,7 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
}
});
msg.setRules(rules);
msg.setRuleIds(ruleIdList);
msg.setFillpropertys(fillpropertys);
return msg;
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册