From f29fa3dc5a7c38301c55166d9f065965912bc0b1 Mon Sep 17 00:00:00 2001 From: liyongde <1419499670@qq.com> Date: Mon, 17 Aug 2026 21:17:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=A0=A1=E9=AA=8C=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A1=8C=E6=A0=87=E8=AF=86=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SubPackageRelationServiceImpl.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/service/subpackagerelation/SubPackageRelationServiceImpl.java b/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/service/subpackagerelation/SubPackageRelationServiceImpl.java index ef3fdadb..2a3e98ac 100644 --- a/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/service/subpackagerelation/SubPackageRelationServiceImpl.java +++ b/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/service/subpackagerelation/SubPackageRelationServiceImpl.java @@ -34,6 +34,8 @@ public class SubPackageRelationServiceImpl implements SubPackageRelationService /** 必填字段缺失错误码 */ private static final String REQUIRED_FIELD_MISSING = "REQUIRED_FIELD_MISSING"; + /** 前端行标识重复错误码 */ + private static final String DUPLICATE_CLIENT_KEY = "DUPLICATE_CLIENT_KEY"; /** 木箱类型不存在错误码 */ private static final String BOX_TYPE_NOT_FOUND = "BOX_TYPE_NOT_FOUND"; /** 木箱容量超限错误码 */ @@ -60,6 +62,12 @@ public class SubPackageRelationServiceImpl implements SubPackageRelationService public SubPackageRelationBatchCreateRespVO batchCreateSubPackageRelation(SubPackageRelationBatchCreateReqVO reqVO) { List failures = new ArrayList<>(); List validItems = new ArrayList<>(); + Map clientKeyCounts = new HashMap<>(); + for (SubPackageRelationBatchCreateItemReqVO item : reqVO.getItems()) { + if (item != null && StringUtils.hasText(item.getClientKey())) { + clientKeyCounts.merge(item.getClientKey(), 1, Integer::sum); + } + } for (int index = 0; index < reqVO.getItems().size(); index++) { SubPackageRelationBatchCreateItemReqVO item = reqVO.getItems().get(index); int rowIndex = index + 1; @@ -94,6 +102,11 @@ public class SubPackageRelationServiceImpl implements SubPackageRelationService "缺失字段:" + String.join("、", missingFields))); continue; } + if (clientKeyCounts.get(item.getClientKey()) > 1) { + failures.add(buildFailure(item.getClientKey(), rowIndex, DUPLICATE_CLIENT_KEY, + "前端行标识 clientKey 重复")); + continue; + } validItems.add(new BatchItemContext(item, rowIndex)); } if (CollUtil.isEmpty(validItems)) {