pdi部件绑定修改

This commit is contained in:
yf001217 2026-06-09 16:36:26 +08:00
parent cd7149b5b7
commit f0d5c619d5
1 changed files with 20 additions and 1 deletions

View File

@ -50,6 +50,7 @@ public class QmsPdiComponentBindingControllerService {
List<QmsPdiComponentBinding> 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;
}