From 11a0b15d198b0b4f45b7b9dd6d64b1cdeecb9dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E9=B8=BF=E5=B1=95?= <18031053041@163.com> Date: Mon, 11 May 2026 09:00:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=93=E5=BA=93=E7=BB=91=E5=AE=9A=E6=9B=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../persistence/AssociationWarehouseImpl.java | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/associationWarehouse/repository/persistence/AssociationWarehouseImpl.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/associationWarehouse/repository/persistence/AssociationWarehouseImpl.java index dc3fc8eb6..5860b8df2 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/associationWarehouse/repository/persistence/AssociationWarehouseImpl.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/associationWarehouse/repository/persistence/AssociationWarehouseImpl.java @@ -107,7 +107,31 @@ public class AssociationWarehouseImpl extends ServiceImpl().lambda() + .eq(AssociationWarehouse::getWarehouseId, associationWarehouseDO.getWarehouseId()) + .eq(AssociationWarehouse::getDelFlag, 1) + .and(w -> w.isNull(AssociationWarehouse::getIsDefault) + .or() + .ne(AssociationWarehouse::getIsDefault, 2))); + List stillBoundRows = associationWarehouseMapper.selectList(new QueryWrapper().lambda() + .eq(AssociationWarehouse::getWarehouseId, associationWarehouseDO.getWarehouseId()) + .eq(AssociationWarehouse::getDelFlag, 1)); + Set alreadyBoundCorrelationIds = stillBoundRows.stream() + .map(AssociationWarehouse::getCorrelationId) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + LinkedHashSet distinctCorrelationIds = CollectionUtils.isEmpty(associationWarehouseDO.getCorrelationIdList()) + ? new LinkedHashSet<>() + : new LinkedHashSet<>(associationWarehouseDO.getCorrelationIdList()); + for (Long correlationId : distinctCorrelationIds) { + if (correlationId == null) { + continue; + } + // 仍在库内的绑定(多为创建人默认仓 is_default=2)不再插入,否则撞唯一 IDX_ASS_COR_WAR_ID + if (alreadyBoundCorrelationIds.contains(correlationId)) { + continue; + } AssociationWarehouse associationWarehouse = new AssociationWarehouse(); associationWarehouse.setOrganizationId(loginUser.getUserPo().getOrganizationId()); associationWarehouse.setOrganizationName(loginUser.getUserPo().getOrganizationName()); @@ -121,13 +145,6 @@ public class AssociationWarehouseImpl extends ServiceImpl().lambda() - .eq(AssociationWarehouse::getWarehouseId, associationWarehouseDO.getWarehouseId()) - .eq(AssociationWarehouse::getDelFlag, 1) - .and(w -> w.isNull(AssociationWarehouse::getIsDefault) - .or() - .ne(AssociationWarehouse::getIsDefault, 2))); } return saveBatch(associationWarehouseList); }