|
@@ -1,6 +1,7 @@
|
|
|
package com.nationrel.modules.fta.service;
|
|
|
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -198,42 +199,55 @@ public class FtaDiagramDataService {
|
|
|
String childId = UUIDUtil.getUuid();
|
|
|
// 记录新增的id
|
|
|
ArrayList<String> operatorInsertNodeIds = new ArrayList<>();
|
|
|
- if (FtaNodeEnum.底事件.getIndex().equals(entity.getTypeCode())
|
|
|
- || FtaNodeEnum.重复事件.getIndex().equals(entity.getTypeCode())
|
|
|
- || FtaNodeEnum.未展开事件.getIndex().equals(entity.getTypeCode())) {
|
|
|
+ // Node typeCode
|
|
|
+ String typeCode = entity.getTypeCode();
|
|
|
+ if (FtaNodeEnum.底事件.getIndex().equals(typeCode)
|
|
|
+ || FtaNodeEnum.重复事件.getIndex().equals(typeCode)
|
|
|
+ || FtaNodeEnum.未展开事件.getIndex().equals(typeCode)
|
|
|
+ || FtaNodeEnum.重复未展开事件.getIndex().equals(typeCode)) {
|
|
|
FtaNode masterNode = null;
|
|
|
- if (FtaNodeEnum.重复事件.getIndex().equals(entity.getTypeCode())) {
|
|
|
+ if (FtaNodeEnum.重复事件.getIndex().equals(typeCode)
|
|
|
+ || FtaNodeEnum.重复未展开事件.getIndex().equals(typeCode)) {
|
|
|
// 添加重复事件时,同一个父中间事件下不能存在相同的重复事件(也包括被重复的底事件)
|
|
|
List<String> ids = nodeMapper.selectList(new LambdaQueryWrapper<FtaNode>()
|
|
|
.select(FtaNode::getId)
|
|
|
.eq(FtaNode::getAnalysisId, analysisId)
|
|
|
.eq(FtaNode::getFatherId, fatherNode.getId()))
|
|
|
.stream().map(FtaNode::getId).collect(Collectors.toList());
|
|
|
+ // 节点类型列表
|
|
|
+ List<String> typeCodeList = new ArrayList<>();
|
|
|
+ if (StrUtil.equals(typeCode, FtaNodeEnum.重复事件.getIndex())) {
|
|
|
+ typeCodeList.add(FtaNodeEnum.重复事件.getIndex());
|
|
|
+ typeCodeList.add(FtaNodeEnum.底事件.getIndex());
|
|
|
+ } else {
|
|
|
+ typeCodeList.add(FtaNodeEnum.重复未展开事件.getIndex());
|
|
|
+ typeCodeList.add(FtaNodeEnum.未展开事件.getIndex());
|
|
|
+ }
|
|
|
if (!CollectionUtils.isEmpty(ids)) {
|
|
|
Long count = nodeMapper.selectCount(new LambdaQueryWrapper<FtaNode>()
|
|
|
.eq(FtaNode::getAnalysisId, analysisId)
|
|
|
- .in(FtaNode::getTypeCode, FtaNodeEnum.重复事件.getIndex(), FtaNodeEnum.底事件.getIndex())
|
|
|
+ .in(FtaNode::getTypeCode, typeCodeList)
|
|
|
.in(FtaNode::getFatherId, ids)
|
|
|
.and(o -> o.eq(FtaNode::getMasterId, entity.getMasterId()).or().eq(FtaNode::getId, entity.getMasterId())));
|
|
|
if (!CollectionUtils.isEmpty(ids) && count > 0) {
|
|
|
throw new DescribeException(FtaParamDataExceptionEnum.getLanguageMessageByKey(FtaParamDataExceptionEnum.同一个门下禁止添加同一个重复事件, userInfo.getLanguageKey()), ResponseStatus.WARN.getStatus());
|
|
|
}
|
|
|
}
|
|
|
- // 不再区分底事件和重复事件,都变为重复事件,存储一个相同的masterId, 存储相同的数据,都一起更新
|
|
|
+ // 不再区分底事件和重复事件 OR 未展开事件和重复未展开事件,都变为重复事件 OR 重复未展开事件,存储一个相同的masterId, 存储相同的数据,都一起更新
|
|
|
masterNode = nodeMapper.selectOne(new LambdaQueryWrapper<FtaNode>()
|
|
|
- .in(FtaNode::getTypeCode, FtaNodeEnum.重复事件.getIndex(), FtaNodeEnum.底事件.getIndex())
|
|
|
+ .in(FtaNode::getTypeCode, typeCodeList)
|
|
|
.and(o -> o.eq(FtaNode::getMasterId, entity.getMasterId()).or()
|
|
|
.eq(FtaNode::getId, entity.getMasterId()))
|
|
|
.isNotNull(FtaNode::getDistributionTypeCode)
|
|
|
.last(" LIMIT 1"));
|
|
|
if (nodeMapper.selectCount(new LambdaQueryWrapper<FtaNode>()
|
|
|
- .in(FtaNode::getTypeCode, FtaNodeEnum.重复事件.getIndex(), FtaNodeEnum.底事件.getIndex())
|
|
|
+ .in(FtaNode::getTypeCode, typeCodeList)
|
|
|
.and(o -> o.eq(FtaNode::getMasterId, entity.getMasterId()).or()
|
|
|
.eq(FtaNode::getId, entity.getMasterId()))) == 1) {
|
|
|
// 如果是第一次添加重复事件,则需要将原来的底事件也转为重复事件
|
|
|
nodeMapper.updateById(FtaNode.builder().id(masterNode.getId())
|
|
|
.masterId(StringUtils.isNotBlank(masterNode.getMasterId()) ? masterNode.getMasterId() : masterNode.getId())
|
|
|
- .typeCode(FtaNodeEnum.重复事件.getIndex()).build());
|
|
|
+ .typeCode(typeCode).build());
|
|
|
}
|
|
|
}
|
|
|
// 添加其他事件时,实际添加的是中间事件和一个事件
|
|
@@ -264,10 +278,10 @@ public class FtaDiagramDataService {
|
|
|
.fatherId(middleEvent.getId())
|
|
|
.nodeLevel(fatherNode.getNodeLevel() + 1)
|
|
|
.masterId(entity.getMasterId())
|
|
|
- .typeCode(entity.getTypeCode())
|
|
|
+ .typeCode(typeCode)
|
|
|
.distributionTypeCode(entity.getDistributionTypeCode())
|
|
|
.build();
|
|
|
- if (FtaNodeEnum.重复事件.getIndex().equals(entity.getTypeCode()) && masterNode != null) {
|
|
|
+ if ((FtaNodeEnum.重复事件.getIndex().equals(typeCode) || FtaNodeEnum.重复未展开事件.getIndex().equals(typeCode)) && masterNode != null) {
|
|
|
// 如果添加的是重复事件,则新添加的计算参数设置为原master的数据
|
|
|
event.setMasterId(StringUtils.isNotBlank(masterNode.getMasterId()) ? masterNode.getMasterId() : masterNode.getId());
|
|
|
event.setDistributionTypeCode(masterNode.getDistributionTypeCode());
|
|
@@ -280,7 +294,7 @@ public class FtaDiagramDataService {
|
|
|
operatorInsertNodeIds.add(event.getId());
|
|
|
operatorService.insert(userInfo, operatorInsertNodeIds, analysisId, null, FtaOperatorTypeEnum.新增节点和连线.getIndex());
|
|
|
return ServerResponse.createBySuccess();
|
|
|
- } else if (FtaNodeEnum.中间事件.getIndex().equals(entity.getTypeCode())) {
|
|
|
+ } else if (FtaNodeEnum.中间事件.getIndex().equals(typeCode)) {
|
|
|
if (StringUtils.isBlank(entity.getCode())) {
|
|
|
entity.setCode(FtaConstants.EVENT_CODE + getEventCode(fatherNode.getAnalysisId(), userInfo).getData());
|
|
|
}
|
|
@@ -288,7 +302,7 @@ public class FtaDiagramDataService {
|
|
|
FtaNode middleEvent = FtaNode.builder()
|
|
|
.analysisId(entity.getAnalysisId())
|
|
|
.id(eventId)
|
|
|
- .typeCode(entity.getTypeCode())
|
|
|
+ .typeCode(typeCode)
|
|
|
.code(entity.getCode())
|
|
|
.name(entity.getName())
|
|
|
.fatherId(entity.getSourceId())
|
|
@@ -386,7 +400,7 @@ public class FtaDiagramDataService {
|
|
|
.fatherId(topEvent.getId())
|
|
|
.nodeLevel(1)
|
|
|
.id(andGateId)
|
|
|
- .typeCode(FtaNodeEnum.与门.getIndex()).build();
|
|
|
+ .typeCode(FtaNodeEnum.或门.getIndex()).build();
|
|
|
nodeMapper.insert(andGate);
|
|
|
|
|
|
}
|
|
@@ -470,8 +484,9 @@ public class FtaDiagramDataService {
|
|
|
.disableMove(entity.getDisableMove()).leaf(entity.getLeaf()).build();
|
|
|
if (FtaNodeEnum.底事件.getIndex().equals(entity.getTypeCode())
|
|
|
|| FtaNodeEnum.未展开事件.getIndex().equals(entity.getTypeCode())
|
|
|
- || FtaNodeEnum.重复事件.getIndex().equals(entity.getTypeCode())) {
|
|
|
- // 底事件和未展开事件和重复事件:更新计算参数
|
|
|
+ || FtaNodeEnum.重复事件.getIndex().equals(entity.getTypeCode())
|
|
|
+ || FtaNodeEnum.重复未展开事件.getIndex().equals(entity.getTypeCode())) {
|
|
|
+ // 底事件和未展开事件和重复事件和重复未展开事件:更新计算参数
|
|
|
update.setDistributionTypeCode(entity.getDistributionTypeCode());
|
|
|
update.setParamLamdba(entity.getParamLamdba());
|
|
|
update.setParamF(entity.getParamF());
|
|
@@ -480,7 +495,7 @@ public class FtaDiagramDataService {
|
|
|
nodeMapper.update(FtaNode.builder().distributionTypeCode(entity.getDistributionTypeCode()).build(),
|
|
|
new LambdaQueryWrapper<FtaNode>().in(FtaNode::getAnalysisId, analysisIds));
|
|
|
}
|
|
|
- if (FtaNodeEnum.重复事件.getIndex().equals(entity.getTypeCode())) {
|
|
|
+ if (FtaNodeEnum.重复事件.getIndex().equals(entity.getTypeCode()) || FtaNodeEnum.重复未展开事件.getIndex().equals(entity.getTypeCode())) {
|
|
|
ArrayList<FtaNode> updateMirrors = new ArrayList<>();
|
|
|
updateMirrors.add(entity);
|
|
|
nodeMapper.updateMirrorNodes(updateMirrors);
|
|
@@ -489,7 +504,7 @@ public class FtaDiagramDataService {
|
|
|
// 如果是重复事件则需要更新所有关联的重复事件的父节点
|
|
|
FtaNode child = nodeMapper.selectOne(new LambdaQueryWrapper<FtaNode>()
|
|
|
.eq(FtaNode::getFatherId, old.getId()));
|
|
|
- if (FtaNodeEnum.重复事件.getIndex().equals(child.getTypeCode())) {
|
|
|
+ if (FtaNodeEnum.重复事件.getIndex().equals(child.getTypeCode()) || FtaNodeEnum.重复未展开事件.getIndex().equals(child.getTypeCode())) {
|
|
|
ArrayList<FtaNode> updateMirrors = new ArrayList<>();
|
|
|
updateMirrors.add(FtaNode.builder().code(entity.getCode()).name(entity.getName()).masterId(child.getMasterId()).build());
|
|
|
nodeMapper.updateMirrorFatherNodes(updateMirrors);
|
|
@@ -797,7 +812,7 @@ public class FtaDiagramDataService {
|
|
|
ArrayList<FtaNode> updateMirrors = new ArrayList<>();
|
|
|
ArrayList<String> validMirrorIds = new ArrayList<>();
|
|
|
parms.forEach(node -> {
|
|
|
- if (FtaNodeEnum.重复事件.getIndex().equals(node.getTypeCode()) && !validMirrorIds.contains(node.getMasterId())) {
|
|
|
+ if ((FtaNodeEnum.重复事件.getIndex().equals(node.getTypeCode()) || FtaNodeEnum.重复未展开事件.getIndex().equals(node.getTypeCode())) && !validMirrorIds.contains(node.getMasterId())) {
|
|
|
updateMirrors.add(node);
|
|
|
validMirrorIds.add(node.getMasterId());
|
|
|
} else {
|
|
@@ -928,13 +943,16 @@ public class FtaDiagramDataService {
|
|
|
nodeMapper.deleteBatchIds(delNodeIds);
|
|
|
result.put(FtaConstants.REFRESH_ANALYSIS_TREE, true);
|
|
|
} else if (FtaNodeEnum.重复事件.getIndex().equals(old.getTypeCode())
|
|
|
- || FtaNodeEnum.未展开事件.getIndex().equals(old.getTypeCode())) {
|
|
|
+ || FtaNodeEnum.未展开事件.getIndex().equals(old.getTypeCode())
|
|
|
+ || FtaNodeEnum.重复未展开事件.getIndex().equals(old.getTypeCode())) {
|
|
|
// 删除重复事件和未展开事件
|
|
|
// 需要一起删除上方的中间事件
|
|
|
delNodeIds.add(nodeId);
|
|
|
delNodeIds.add(old.getFatherId());
|
|
|
// 找出需要删除的线
|
|
|
getEdgeIdsByNodeIds(delEdgeIds, edges, old);
|
|
|
+
|
|
|
+
|
|
|
if (FtaNodeEnum.重复事件.getIndex().equals(old.getTypeCode())) {
|
|
|
// 删除重复事件时,如果删掉这个重复事件后,相关联的重复事件只剩一个,则将最后一个重复事件转为底事件
|
|
|
List<FtaNode> mirrors = nodeMapper.selectList(new LambdaQueryWrapper<FtaNode>()
|
|
@@ -946,6 +964,17 @@ public class FtaDiagramDataService {
|
|
|
nodeMapper.update(FtaNode.builder().typeCode(FtaNodeEnum.底事件.getIndex()).build(),
|
|
|
new LambdaUpdateWrapper<FtaNode>().eq(FtaNode::getId, lastMirror.getId()));
|
|
|
}
|
|
|
+ } else if (FtaNodeEnum.重复未展开事件.getIndex().equals(old.getTypeCode())) {
|
|
|
+ // 删除重复事件时,如果删掉这个重复事件后,相关联的重复事件只剩一个,则将最后一个重复事件转为底事件
|
|
|
+ List<FtaNode> mirrors = nodeMapper.selectList(new LambdaQueryWrapper<FtaNode>()
|
|
|
+ .select(FtaNode::getId, FtaNode::getMasterId)
|
|
|
+ .eq(FtaNode::getMasterId, old.getMasterId()));
|
|
|
+ if (mirrors.size() == 2) {
|
|
|
+ // 将最后一个重复事件更新为底事件
|
|
|
+ FtaNode lastMirror = mirrors.stream().filter(o -> !o.getId().equals(old.getId())).findFirst().orElse(new FtaNode());
|
|
|
+ nodeMapper.update(FtaNode.builder().typeCode(FtaNodeEnum.未展开事件.getIndex()).build(),
|
|
|
+ new LambdaUpdateWrapper<FtaNode>().eq(FtaNode::getId, lastMirror.getId()));
|
|
|
+ }
|
|
|
}
|
|
|
nodeMapper.deleteBatchIds(delNodeIds);
|
|
|
// 更新被删除的节点的父节那一层级右侧其它的连线顺序
|
|
@@ -1239,23 +1268,30 @@ public class FtaDiagramDataService {
|
|
|
// }
|
|
|
// 当被复制的是门,且复制类型为重复时:复制为同源转移门
|
|
|
return nodeCopyTransfer(userInfo, middleNode, targetGate);
|
|
|
- } else if (FtaNodeEnum.重复事件.getIndex().equals(sourceChildrenNode.getTypeCode()) || isPasteToMirror) {
|
|
|
+ } else if (FtaNodeEnum.重复事件.getIndex().equals(sourceChildrenNode.getTypeCode()) ||
|
|
|
+ FtaNodeEnum.重复未展开事件.getIndex().equals(sourceChildrenNode.getTypeCode()) ||
|
|
|
+ isPasteToMirror) {
|
|
|
// 复制的是重复事件 或 将底事件粘贴为重复事件 时,同一个父中间事件下不能存在相同的重复事件(也包括被重复的底事件)
|
|
|
-// List<String> ids = nodeMapper.selectList(new LambdaQueryWrapper<FtaNode>()
|
|
|
-// .select(FtaNode::getId)
|
|
|
-// .eq(FtaNode::getAnalysisId, analysisId)
|
|
|
-// .eq(FtaNode::getFatherId, targetGate.getId()))
|
|
|
-// .stream().map(FtaNode::getId).collect(Collectors.toList());
|
|
|
-// if (!CollectionUtils.isEmpty(ids)) {
|
|
|
- Long count = nodeMapper.selectCount(new LambdaQueryWrapper<FtaNode>()
|
|
|
- .eq(FtaNode::getAnalysisId, analysisId)
|
|
|
- .in(FtaNode::getTypeCode, FtaNodeEnum.重复事件.getIndex(), FtaNodeEnum.底事件.getIndex())
|
|
|
- .eq(FtaNode::getFatherId, targetGate.getId())
|
|
|
- .and(o -> o.eq(FtaNode::getMasterId, sourceChildrenNode.getMasterId()).or().eq(FtaNode::getId, sourceChildrenNode.getMasterId())));
|
|
|
- if (count > 0) {
|
|
|
- throw new DescribeException(FtaParamDataExceptionEnum.getLanguageMessageByKey(FtaParamDataExceptionEnum.同一个门下禁止添加同一个重复事件, userInfo.getLanguageKey()), ResponseStatus.WARN.getStatus());
|
|
|
+ if (StringUtils.isNotBlank(sourceChildrenNode.getMasterId())) {
|
|
|
+ List<String> ids = nodeMapper.selectList(new LambdaQueryWrapper<FtaNode>()
|
|
|
+ .select(FtaNode::getId)
|
|
|
+ .eq(FtaNode::getAnalysisId, analysisId)
|
|
|
+ .eq(FtaNode::getFatherId, targetGate.getId()))
|
|
|
+ .stream().map(FtaNode::getId).collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(ids)) {
|
|
|
+ Long count = nodeMapper.selectCount(new LambdaQueryWrapper<FtaNode>()
|
|
|
+ .eq(FtaNode::getAnalysisId, analysisId)
|
|
|
+ .in(FtaNode::getTypeCode, FtaNodeEnum.重复事件.getIndex(), FtaNodeEnum.底事件.getIndex(),
|
|
|
+ FtaNodeEnum.重复未展开事件.getIndex(), FtaNodeEnum.未展开事件.getIndex())
|
|
|
+ .in(FtaNode::getFatherId, ids)
|
|
|
+ .and(o -> o.eq(FtaNode::getMasterId, sourceChildrenNode.getMasterId()).or().eq(FtaNode::getId, sourceChildrenNode.getMasterId())));
|
|
|
+ if (count > 0) {
|
|
|
+ throw new DescribeException(FtaParamDataExceptionEnum.getLanguageMessageByKey(FtaParamDataExceptionEnum.同一个门下禁止添加同一个重复事件, userInfo.getLanguageKey()), ResponseStatus.WARN.getStatus());
|
|
|
+ }
|
|
|
}
|
|
|
-// }
|
|
|
+ } else if (middleNode.getFatherId().equals(targetGate.getId())) {
|
|
|
+ throw new DescribeException(FtaParamDataExceptionEnum.getLanguageMessageByKey(FtaParamDataExceptionEnum.同一个门下禁止添加同一个重复事件, userInfo.getLanguageKey()), ResponseStatus.WARN.getStatus());
|
|
|
+ }
|
|
|
}
|
|
|
// 被复制的中间事件需要重新设定顺序
|
|
|
Long edgeOrder = nodeMapper.selectCount(new LambdaQueryWrapper<FtaNode>()
|
|
@@ -1274,10 +1310,10 @@ public class FtaDiagramDataService {
|
|
|
// 需要对新的数据进行重新编号
|
|
|
String numberStr = "%04d";
|
|
|
final int[] number = {Integer.parseInt(getEventCode(middleNode.getAnalysisId(), userInfo).getData())};
|
|
|
- if (String.valueOf(number[0]).length() > 4) {
|
|
|
- // 超长
|
|
|
- numberStr = "%0" + String.valueOf(number[0]).length() + "d";
|
|
|
- }
|
|
|
+ if (String.valueOf(number[0]).length() > 4) {
|
|
|
+ // 超长
|
|
|
+ numberStr = "%0" + String.valueOf(number[0]).length() + "d";
|
|
|
+ }
|
|
|
// 获取该节点下的子集id(需要复制的id)
|
|
|
getRelevanceIdByNodeId(allEdges, middleNode.getId(), copyNodeIds);
|
|
|
getEdgeIdsByNodeIds(copyEdgeIds, allEdges, copyNodeIds);
|
|
@@ -1321,14 +1357,19 @@ public class FtaDiagramDataService {
|
|
|
String finalNumberStr = numberStr;
|
|
|
needUpdateNodes.forEach(item -> {
|
|
|
if (isPasteToMirror && sourceChildrenNode.getId().equals(item.getId())) {
|
|
|
+ String typeCode = FtaNodeEnum.重复事件.getIndex();
|
|
|
+ if (StrUtil.equals(sourceChildrenNode.getTypeCode(), FtaNodeEnum.未展开事件.getIndex()) || StrUtil.equals(sourceChildrenNode.getTypeCode(), FtaNodeEnum.重复未展开事件.getIndex())) {
|
|
|
+ typeCode = FtaNodeEnum.重复未展开事件.getIndex();
|
|
|
+ }
|
|
|
// 底事件复制为重复事件时,设置新复制出来的节点为重复事件
|
|
|
- item.setTypeCode(FtaNodeEnum.重复事件.getIndex());
|
|
|
+ item.setTypeCode(typeCode);
|
|
|
item.setMasterId(StringUtils.isNotBlank(item.getMasterId()) ? item.getMasterId() : item.getId());
|
|
|
// 更新这个原来的底事件为重复事件
|
|
|
nodeMapper.updateById(FtaNode.builder().id(item.getId())
|
|
|
.masterId(StringUtils.isNotBlank(item.getMasterId()) ? item.getMasterId() : item.getId())
|
|
|
- .typeCode(FtaNodeEnum.重复事件.getIndex()).build());
|
|
|
- } else if (!FtaNodeEnum.重复事件.getIndex().equals(item.getTypeCode())) {
|
|
|
+ .typeCode(typeCode).build());
|
|
|
+ } else if (!FtaNodeEnum.重复事件.getIndex().equals(item.getTypeCode()) ||
|
|
|
+ !FtaNodeEnum.重复未展开事件.getIndex().equals(item.getTypeCode())) {
|
|
|
// 非重复事件时,重置masterId
|
|
|
item.setMasterId(null);
|
|
|
}
|
|
@@ -1359,7 +1400,7 @@ public class FtaDiagramDataService {
|
|
|
insertNodes.forEach(node -> {
|
|
|
// 更新节点的fatherId
|
|
|
node.setFatherId(StringUtils.isNotBlank(oldNodeIdAndNewMap.get(node.getFatherId())) ? oldNodeIdAndNewMap.get(node.getFatherId()) : "0");
|
|
|
- if (FtaNodeEnum.重复事件.getIndex().equals(node.getTypeCode()) && !isPasteToMirror) {
|
|
|
+ if ((FtaNodeEnum.重复事件.getIndex().equals(node.getTypeCode()) || FtaNodeEnum.重复未展开事件.getIndex().equals(node.getTypeCode())) && !isPasteToMirror) {
|
|
|
// 不需要重新设置code的重复事件的父中间事件id
|
|
|
valid.add(node.getFatherId());
|
|
|
} else if (FtaNodeEnum.转移门.getIndex().equals(node.getTypeCode()) && mirrorTransferAnalysisIds.contains(node.getChildrenAnalysisId())) {
|
|
@@ -1593,13 +1634,15 @@ public class FtaDiagramDataService {
|
|
|
nodes = nodeMapper.selectList(new LambdaQueryWrapper<FtaNode>()
|
|
|
.in(FtaNode::getAnalysisId, analysisIds)
|
|
|
.and(o -> o.eq(FtaNode::getTypeCode, FtaNodeEnum.底事件.getIndex())
|
|
|
- .or().eq(FtaNode::getTypeCode, FtaNodeEnum.重复事件.getIndex())));
|
|
|
+ .or().eq(FtaNode::getTypeCode, FtaNodeEnum.重复事件.getIndex())
|
|
|
+ .or().eq(FtaNode::getTypeCode, FtaNodeEnum.未展开事件.getIndex())));
|
|
|
} else {
|
|
|
// 当该分析中不包含父子分析,直接取值
|
|
|
nodes = nodeMapper.selectList(
|
|
|
new LambdaQueryWrapper<FtaNode>().eq(FtaNode::getAnalysisId, analysisId)
|
|
|
.and(o -> o.eq(FtaNode::getTypeCode, FtaNodeEnum.底事件.getIndex())
|
|
|
- .or().eq(FtaNode::getTypeCode, FtaNodeEnum.重复事件.getIndex())));
|
|
|
+ .or().eq(FtaNode::getTypeCode, FtaNodeEnum.重复事件.getIndex())
|
|
|
+ .or().eq(FtaNode::getTypeCode, FtaNodeEnum.未展开事件.getIndex())));
|
|
|
}
|
|
|
Map<String, List<FtaNode>> map = null;
|
|
|
if (!CollectionUtils.isEmpty(nodes)) {
|
|
@@ -1868,7 +1911,8 @@ public class FtaDiagramDataService {
|
|
|
nodeMapper.selectList(new LambdaQueryWrapper<FtaNode>()
|
|
|
.select(FtaNode::getMasterId, FtaNode::getId, FtaNode::getTypeCode)
|
|
|
.in(FtaNode::getAnalysisId, allAnalysisId)
|
|
|
- .in(FtaNode::getTypeCode, FtaNodeEnum.底事件.getIndex(), FtaNodeEnum.重复事件.getIndex())
|
|
|
+ .in(FtaNode::getTypeCode, FtaNodeEnum.底事件.getIndex(), FtaNodeEnum.重复事件.getIndex(),
|
|
|
+ FtaNodeEnum.未展开事件.getIndex(), FtaNodeEnum.重复未展开事件.getIndex())
|
|
|
.isNotNull(FtaNode::getMasterId)
|
|
|
.ne(FtaNode::getMasterId, StringUtils.EMPTY))
|
|
|
.stream().collect(Collectors.groupingBy(FtaNode::getMasterId))
|
|
@@ -1876,23 +1920,43 @@ public class FtaDiagramDataService {
|
|
|
if (list.size() > 1) {
|
|
|
// 如果masterId关联的底事件或重复事件的数量大于1,则需要更新这些事件为重复事件
|
|
|
// 需要更新为重复事件的底事件ids
|
|
|
- List<String> updateIds = list.stream()
|
|
|
- .filter(node -> FtaNodeEnum.底事件.getIndex().equals(node.getTypeCode()))
|
|
|
- .map(FtaNode::getId).collect(Collectors.toList());
|
|
|
- if (!CollectionUtils.isEmpty(updateIds)) {
|
|
|
+ Map<String, List<String>> idsMap = list.stream()
|
|
|
+ .filter(node -> FtaNodeEnum.底事件.getIndex().equals(node.getTypeCode()) ||
|
|
|
+ FtaNodeEnum.未展开事件.getIndex().equals(node.getTypeCode()))
|
|
|
+ .collect(Collectors.groupingBy(FtaNode::getTypeCode,
|
|
|
+ Collectors.mapping(FtaNode::getId, Collectors.toList())));
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(idsMap.get(FtaNodeEnum.底事件.getIndex()))) {
|
|
|
+ List<String> updateIds = idsMap.get(FtaNodeEnum.底事件.getIndex());
|
|
|
// 将这些底事件更新为重复事件
|
|
|
nodeMapper.update(FtaNode.builder().typeCode(FtaNodeEnum.重复事件.getIndex()).build(),
|
|
|
new LambdaQueryWrapper<FtaNode>()
|
|
|
.in(FtaNode::getAnalysisId, allAnalysisId)
|
|
|
.in(FtaNode::getId, updateIds));
|
|
|
}
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(idsMap.get(FtaNodeEnum.未展开事件.getIndex()))) {
|
|
|
+ List<String> updateIds = idsMap.get(FtaNodeEnum.未展开事件.getIndex());
|
|
|
+ // 将这些底事件更新为重复未展开事件
|
|
|
+ nodeMapper.update(FtaNode.builder().typeCode(FtaNodeEnum.重复未展开事件.getIndex()).build(),
|
|
|
+ new LambdaQueryWrapper<FtaNode>()
|
|
|
+ .in(FtaNode::getAnalysisId, allAnalysisId)
|
|
|
+ .in(FtaNode::getId, updateIds));
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
// 如果这个事件是重复事件,则更新这个事件为底事件
|
|
|
- if (FtaNodeEnum.重复事件.getIndex().equals(list.get(0).getTypeCode())) {
|
|
|
+ String firstNodeTypeCode = list.get(0).getTypeCode();
|
|
|
+ if (FtaNodeEnum.重复事件.getIndex().equals(firstNodeTypeCode)) {
|
|
|
nodeMapper.update(FtaNode.builder().typeCode(FtaNodeEnum.底事件.getIndex()).build(),
|
|
|
new LambdaQueryWrapper<FtaNode>()
|
|
|
.in(FtaNode::getAnalysisId, allAnalysisId)
|
|
|
.eq(FtaNode::getId, list.get(0).getId()));
|
|
|
+ } else if (FtaNodeEnum.重复未展开事件.getIndex().equals(firstNodeTypeCode)) {
|
|
|
+ nodeMapper.update(FtaNode.builder().typeCode(FtaNodeEnum.未展开事件.getIndex()).build(),
|
|
|
+ new LambdaQueryWrapper<FtaNode>()
|
|
|
+ .in(FtaNode::getAnalysisId, allAnalysisId)
|
|
|
+ .eq(FtaNode::getId, list.get(0).getId()));
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -2569,7 +2633,7 @@ public class FtaDiagramDataService {
|
|
|
// results.put("sigma", node.getP2Value());
|
|
|
// } else if (FtaDistributingTypeCodeEnum.FixedProb.getIndex().equals(node.getDistributionTypeCode())) {
|
|
|
// results.put("R", node.getP1Value());
|
|
|
- // 包含固定失效概率的数据不能计算
|
|
|
+ // 包含固定失效概率的数据不能计算
|
|
|
// }
|
|
|
requestPlotData.put("results", results);
|
|
|
requestPlotData.put("settings", new JSONObject());
|