采用indexRule获取并保存关联的原子指标关联信息

topo_dev
DESKTOP-DDTUS3E\yaxin
parent f8e18d9827
commit 081652b8fb

@ -47,23 +47,10 @@ public class ModelIndexAtomicRelationServiceImpl extends ServiceImpl<ModelIndexA
log.warn("saveByModelIndex: modelIndexId 为空,不保存关联关系....modelIndex:{}", JSONUtil.toJsonStr(modelIndex)); log.warn("saveByModelIndex: modelIndexId 为空,不保存关联关系....modelIndex:{}", JSONUtil.toJsonStr(modelIndex));
return; return;
} }
String judgeLogic = modelIndex.getJudgeLogic();
IndexRule indexRule = modelIndex.getIndexRule(); IndexRule indexRule = modelIndex.getIndexRule();
if (StrUtil.isNotEmpty(judgeLogic)){ if(Objects.nonNull(indexRule)){
List<String> atomicIndexIds = JudgeLogicUtil.pickAtomicIndexIds(judgeLogic);
atomicIndexIds.forEach(atomicIndexId -> {
ModelIndexAtomicRelation modelIndexAtomicRelation = new ModelIndexAtomicRelation();
modelIndexAtomicRelation.setModelIndexId(modelIndex.getId());
modelIndexAtomicRelation.setAtomicIndexId(atomicIndexId);
super.save(modelIndexAtomicRelation);
});
}else if(Objects.nonNull(indexRule)){
Set<String> ids = new HashSet<>(); Set<String> ids = new HashSet<>();
indexRule.getRuleConditionGroupList().forEach(ruleConditionGroup -> { indexRule.getRuleConditionGroupList().forEach(ruleConditionGroup -> ruleConditionGroup.getRuleConditionList().forEach(ruleCondition -> ids.add(ruleCondition.getAtomicIndexId())));
ruleConditionGroup.getRuleConditionList().forEach(ruleCondition -> {
ids.add(ruleCondition.getAtomicIndexId());
});
});
ids.forEach(atomicIndexId -> { ids.forEach(atomicIndexId -> {
ModelIndexAtomicRelation modelIndexAtomicRelation = new ModelIndexAtomicRelation(); ModelIndexAtomicRelation modelIndexAtomicRelation = new ModelIndexAtomicRelation();
modelIndexAtomicRelation.setModelIndexId(modelIndex.getId()); modelIndexAtomicRelation.setModelIndexId(modelIndex.getId());

@ -148,7 +148,7 @@ public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIn
@Override @Override
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class) @Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class)
public R<?> addOrUpd(ModelIndex modelIndex) { public R<?> addOrUpd(ModelIndex modelIndex) {
int i = 0; int i;
if (StringUtils.isEmpty(modelIndex.getId())) { if (StringUtils.isEmpty(modelIndex.getId())) {
i = modelIndexMapper.insert(modelIndex); i = modelIndexMapper.insert(modelIndex);
modelIndexAtomicRelationService.saveByModelIndex(modelIndex); modelIndexAtomicRelationService.saveByModelIndex(modelIndex);

Loading…
Cancel
Save