From 1a7b143bcba90b80cc5442c0f31e577beb3b0426 Mon Sep 17 00:00:00 2001 From: 刘小明 <liuxm_a@163.com> Date: 星期二, 13 八月 2024 10:47:24 +0800 Subject: [PATCH] 整理权限 --- pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java | 28 +++++++++++++++++++++++----- 1 files changed, 23 insertions(+), 5 deletions(-) diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java index 37ca3a5..4f2a3b7 100644 --- a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java +++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @Slf4j @@ -105,12 +106,12 @@ List<PrAssemblyPlan> onlinePlanList = planList.stream().filter(plan -> plan.getStatus() == PlanStatusEnum.NORMAL.getCode()).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(planList)) { if (planList.stream().anyMatch(plan -> plan.getInputNumber() > 0)) { //瀛樺湪浠诲姟宸茬粡鎶曞叆鐢熶骇 - if (!originProductionProcess.getProName().equals(process.getProName())) { - throw new RuntimeException("瀛樺湪宸茬粡鎶曞叆鐢熶骇缁戝畾鐨勪换鍔�,浜у搧涓嶈兘淇敼"); + if (!originProductionProcess.getProId().equals(process.getProId())) { + throw new RuntimeException("瀛樺湪宸茬粡鎶曞叆鐢熶骇鐨勭粦瀹氫换鍔�,浜у搧涓嶈兘淇敼"); } //鑺傜偣id涓嶈兘鍒犻櫎 - if (!originProductionProcess.getNodes().stream().allMatch(node -> process.getNodes().stream().anyMatch(node::equals))) { - throw new RuntimeException("瀛樺湪宸茬粡鎶曞叆鐢熶骇缁戝畾鐨勪换鍔�,鑺傜偣涓嶈兘鍒犻櫎"); + if (!originProductionProcess.getNodes().stream().allMatch(node -> process.getNodes().stream().anyMatch(newNode -> node.getId().equals(newNode.getId())))) { + throw new RuntimeException("宸叉湁缁戝畾鐨勪换鍔℃姇鍏ョ敓浜�,鑺傜偣涓嶈兘鍒犻櫎"); } } else if (CollectionUtils.isNotEmpty(onlinePlanList)) { //鍏堝皢缁勮浠诲姟缃负鏆傚仠鐘舵�� @@ -130,7 +131,13 @@ .collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(nodeIdsToDelete)) { nodeDao.deleteByNodeId(nodeIdsToDelete); - workDao.deleteByNodeId(nodeIdsToDelete); + } + //鍘熸潵鑺傜偣鐨凷OP鍏ㄩ儴鍒犻櫎 + List<Long> originNodeIds = originProductionProcess.getNodes().stream() + .map(PrProductionNode::getId) // 鏄犲皠鑺傜偣鍒板叾ID + .collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(originNodeIds)) { + workDao.deleteByNodeId(originNodeIds); } saveNodesAndInstructions(process); return count; @@ -144,10 +151,21 @@ if (loginUser != null) { process.creator = loginUser.id; } + AtomicInteger startCount = new AtomicInteger(); + AtomicInteger endCount = new AtomicInteger(); process.nodes.forEach(node -> { node.processId = process.id; node.deleted = false; + if(node.isStart){ + startCount.getAndIncrement(); + } + if(node.isEnd){ + endCount.getAndIncrement(); + } }); + if (startCount.get() != 1 || endCount.get() != 1) { + throw new RuntimeException("鑺傜偣寮�濮嬪拰缁撴潫鑺傜偣鏈変笖鍙兘鏈変竴涓�"); + } } // 灏嗚妭鐐瑰拰宸ヤ綔鎸囩ず鐨勪繚瀛橀�昏緫灏佽鍒颁竴涓柟娉曚腑 -- Gitblit v1.8.0