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; }