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

update:引擎同步执行调整

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