From f0d5c619d5656f5b84b9beaaf4f04607322ff16d Mon Sep 17 00:00:00 2001 From: yf001217 <834502597@qq.com> Date: Tue, 9 Jun 2026 16:36:26 +0800 Subject: [PATCH] =?UTF-8?q?pdi=E9=83=A8=E4=BB=B6=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...sPdiComponentBindingControllerService.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/QmsPdiComponentBindingControllerService.java b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/QmsPdiComponentBindingControllerService.java index edba6879..cfd0059c 100644 --- a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/QmsPdiComponentBindingControllerService.java +++ b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/QmsPdiComponentBindingControllerService.java @@ -50,6 +50,7 @@ public class QmsPdiComponentBindingControllerService { List bindings = new ArrayList<>(); for (QmsPdiComponentBindingSaveQO.ImageBindingQO image : request.getItems()) { + boolean hasComponentBinding = false; if (CollectionUtil.isEmpty(image.getComponents())) { bindings.add(new QmsPdiComponentBinding() .setPdiDetectionRulesId(request.getPdiDetectionRulesId()) @@ -58,6 +59,10 @@ public class QmsPdiComponentBindingControllerService { } for (QmsPdiComponentBindingSaveQO.ComponentBindingQO component : image.getComponents()) { + if (component.getPdiComponentId() == null) { + continue; + } + hasComponentBinding = true; bindings.add(new QmsPdiComponentBinding() .setPdiDetectionRulesId(request.getPdiDetectionRulesId()) .setUploadImageId(image.getUploadImageId()) @@ -66,6 +71,11 @@ public class QmsPdiComponentBindingControllerService { .setYCoordinatePoint(component.getYCoordinatePoint()) .setStatus(component.getStatus())); } + if (!hasComponentBinding) { + bindings.add(new QmsPdiComponentBinding() + .setPdiDetectionRulesId(request.getPdiDetectionRulesId()) + .setUploadImageId(image.getUploadImageId())); + } } if (CollectionUtil.isNotEmpty(bindings)) { @@ -164,7 +174,10 @@ public class QmsPdiComponentBindingControllerService { throw new NflgException(STATE.BusinessError, "部件绑定对象不能为空"); } if (component.getPdiComponentId() == null) { - throw new NflgException(STATE.BusinessError, "部件ID不能为空"); + if (hasBindingValue(component)) { + throw new NflgException(STATE.BusinessError, "部件ID为空时不能传入坐标或状态"); + } + continue; } if (StrUtil.isBlank(component.getXCoordinatePoint()) || StrUtil.isBlank(component.getYCoordinatePoint())) { throw new NflgException(STATE.BusinessError, "绑定部件时x轴坐标和y轴坐标不能为空"); @@ -280,6 +293,12 @@ public class QmsPdiComponentBindingControllerService { return status != null && (status == STATIC_STATUS || status == DYNAMIC_STATUS); } + private boolean hasBindingValue(QmsPdiComponentBindingSaveQO.ComponentBindingQO component) { + return StrUtil.isNotBlank(component.getXCoordinatePoint()) + || StrUtil.isNotBlank(component.getYCoordinatePoint()) + || component.getStatus() != null; + } + private String coordinateKey(Long uploadImageId, String xCoordinatePoint, String yCoordinatePoint) { return uploadImageId + "|" + xCoordinatePoint + "|" + yCoordinatePoint; }