1. 同步主数据物料时,需要控制批次大小

This commit is contained in:
chenbowen
2025-12-24 18:00:30 +08:00
parent 398432ddd1
commit cc5ba069b6
2 changed files with 9 additions and 1 deletions

View File

@@ -72,4 +72,5 @@ public interface ErrorCodeConstants {
// ========== 主数据同步 ==========
ErrorCode MASTER_DATA_SYNC_DISABLED = new ErrorCode(1_027_900_001, "主数据同步功能已禁用");
ErrorCode MASTER_DATA_SYNC_BATCH_SIZE_TOO_LARGE = new ErrorCode(1_027_900_002, "最大批次不得超过 1000");
}

View File

@@ -75,6 +75,9 @@ public class MasterDataSyncServiceImpl implements MasterDataSyncService {
if (!properties.isEnabled()) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.MASTER_DATA_SYNC_DISABLED);
}
if (command.getBatchSize() > 1000) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.MASTER_DATA_SYNC_BATCH_SIZE_TOO_LARGE, command.getBatchSize());
}
MasterDataSyncReport report = MasterDataSyncReport.start(command);
List<String> materialCodes = sanitizeCodes(command.getMaterialCodes());
report.setMaterialCodes(materialCodes);
@@ -306,7 +309,11 @@ public class MasterDataSyncServiceImpl implements MasterDataSyncService {
continue;
}
MaterialInfomationDO current = existingById.get(codeId);
String name = normalizeValue(item.getMaterialName());
// 名称优先取 MDM 的长描述desclong若为空再回退到 desc1
String name = normalizeValue(item.getLongDescription());
if (name == null) {
name = normalizeValue(item.getMaterialName());
}
if (current == null) {
MaterialInfomationDO created = MaterialInfomationDO.builder()
.id(codeId)