Browse Source

feat:fta:复制为同源转移门的数据验证完善:不允许将同源转移门复制到当前子集中

张元铭 4 months ago
parent
commit
8f3d8c9be5

+ 1 - 1
nationrel-module-fta-api/src/main/java/com/nationrel/modules/fta/constant/FtaConstants.java

@@ -112,7 +112,7 @@ public final class FtaConstants {
     // sql
     // ==================
 
-    public static final String SQL_LIMIT_1 = "LiMIT 1"; //
+    public static final String SQL_LIMIT_1 = " LIMIT 1"; //
 
 }
 

+ 3 - 8
nationrel-module-fta-biz/src/main/java/com/nationrel/modules/fta/service/FtaDiagramDataService.java

@@ -239,7 +239,7 @@ public class FtaDiagramDataService {
                         .and(o -> o.eq(FtaNode::getMasterId, entity.getMasterId()).or()
                                 .eq(FtaNode::getId, entity.getMasterId()))
                         .isNotNull(FtaNode::getDistributionTypeCode)
-                        .last(" LIMIT 1"));
+                        .last(FtaConstants.SQL_LIMIT_1));
                 if (nodeMapper.selectCount(new LambdaQueryWrapper<FtaNode>()
                         .in(FtaNode::getTypeCode, typeCodeList)
                         .and(o -> o.eq(FtaNode::getMasterId, entity.getMasterId()).or()
@@ -1260,12 +1260,9 @@ public class FtaDiagramDataService {
             List<FtaEdge> allEdges = generateEdgesByNodes(allNodes);
             ArrayList<String> childrenIds = new ArrayList<>();
             getRelevanceIdByNodeId(allEdges, sourceMiddleId, childrenIds);
-            if (sourceMiddleId.equals(targetMiddleId)) {
+            if (allNodes.stream().filter(v -> childrenIds.contains(v.getId())).anyMatch(v -> targetMiddleId.equals(v.getId()))) {
                 throw new DescribeException(FtaParamDataExceptionEnum.getLanguageMessageByKey(FtaParamDataExceptionEnum.不允许将同源转移门复制到当前子集中, userInfo.getLanguageKey()), ResponseStatus.WARN.getStatus());
             }
-//            if (allNodes.stream().filter(v -> childrenIds.contains(v.getId())).anyMatch(v -> FtaNodeEnum.转移门.getIndex().equals(v.getTypeCode()))) {
-//                throw new DescribeException(FtaParamDataExceptionEnum.getLanguageMessageByKey(FtaParamDataExceptionEnum.被复制的子集中包含转移门不允许复制为同源转移门, userInfo.getLanguageKey()), ResponseStatus.WARN.getStatus());
-//            }
             // 当被复制的是门,且复制类型为重复时:复制为同源转移门
             return nodeCopyTransfer(userInfo, middleNode, targetGate);
         } else if (FtaNodeEnum.重复事件.getIndex().equals(sourceChildrenNode.getTypeCode()) ||
@@ -1437,8 +1434,6 @@ public class FtaDiagramDataService {
             analysisMapper.inserts(insertAnalysis);
         }
         nodeService.saveBatch(insertNodes);
-        // 顶事件上面是没有数据的,如果被复制的是顶事件,需要额外增加一条连线
-        String newEdgeId = UUIDUtil.getUuid();
         JSONObject result = new JSONObject();
         if (!CollectionUtils.isEmpty(copyAnalysisIds)) {
             result.put(FtaConstants.REFRESH_ANALYSIS_TREE, true);
@@ -1743,7 +1738,7 @@ public class FtaDiagramDataService {
         FtaOperator operator = operatorMapper.selectOne(new LambdaQueryWrapper<FtaOperator>()
                 .eq(FtaOperator::getAnalysisId, analysisId)
                 .isNull(FtaOperator::getFatherId)
-                .orderByDesc(FtaOperator::getInsertTime).last(" LIMIT 1"));
+                .orderByDesc(FtaOperator::getInsertTime).last(FtaConstants.SQL_LIMIT_1));
         if (operator != null) {
             String projectId = analysisMapper.selectOne(new LambdaQueryWrapper<FtaAnalysis>()
                     .select(FtaAnalysis::getProjectId).eq(FtaAnalysis::getAnalysisId, analysisId)).getProjectId();

+ 2 - 1
nationrel-module-fta-biz/src/main/java/com/nationrel/modules/fta/service/FtaOperatorService.java

@@ -1,6 +1,7 @@
 package com.nationrel.modules.fta.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.nationrel.modules.fta.constant.FtaConstants;
 import com.nationrel.modules.fta.entity.FtaNode;
 import com.nationrel.modules.fta.entity.FtaOperator;
 import com.nationrel.modules.fta.entity.FtaOperatorDetail;
@@ -56,7 +57,7 @@ public class FtaOperatorService {
                     .select(FtaOperator::getId, FtaOperator::getOperatorType)
                     .eq(FtaOperator::getAnalysisId, analysisId)
                     .isNull(FtaOperator::getFatherId)
-                    .orderByAsc(FtaOperator::getInsertTime).last(" LIMIT 1"));
+                    .orderByAsc(FtaOperator::getInsertTime).last(FtaConstants.SQL_LIMIT_1));
             delOperatorIds.add(operator.getId());
             // 最早的操作的关联子操作
             delOperatorIds.addAll(operatorMapper.selectList(new LambdaQueryWrapper<FtaOperator>()