demand: 扫描漏组批次supplierCode线程安全问题修复

committer: heyu
This commit is contained in:
aike 2025-07-11 09:01:08 +08:00
parent 4341a91a90
commit cbf8f70fa9

View File

@ -4501,7 +4501,7 @@ public class EmisBaseService {
}
public EmisBaseService.ProcessResult processWaybillBatch(List<EmisWaybill> waybills,
Map<String, List<EmisTransPlanRule>> transPlanRulesByLineCode) {
Map<String, List<EmisTransPlanRule>> transPlanRulesByLineCode) {
int successCount = 0;
int failCount = 0;
List<String> failedBillCodes = new ArrayList<>();
@ -4585,13 +4585,29 @@ public class EmisBaseService {
String key = batch.getStartSiteCode() + "_" + batch.getNextSiteCode();
if (mergedBatches.containsKey(key)) {
EmisTmsSiteBatch existingBatch = mergedBatches.get(key);
String existingSupplier = existingBatch.getSupplierCode();
String newSupplier = batch.getSupplierCode();
if (!existingSupplier.equals(newSupplier)) {
existingBatch.setSupplierCode(existingSupplier + "," + newSupplier);
// 合并supplierCode,去重、排序
Set<String> supplierSet = new TreeSet<>();
if (StringUtils.isNotBlank(existingBatch.getSupplierCode())) {
supplierSet.addAll(Arrays.asList(existingBatch.getSupplierCode().split(",")));
}
if (StringUtils.isNotBlank(batch.getSupplierCode())) {
supplierSet.addAll(Arrays.asList(batch.getSupplierCode().split(",")));
}
// 新建一个新的Batch对象,复制属性,保证线程安全
EmisTmsSiteBatch newBatch = new EmisTmsSiteBatch();
BeanUtils.copyProperties(existingBatch, newBatch);
newBatch.setSupplierCode(String.join(",", supplierSet));
mergedBatches.put(key, newBatch);
} else {
mergedBatches.put(key, batch);
// 新建对象,避免外部引用被修改
EmisTmsSiteBatch newBatch = new EmisTmsSiteBatch();
BeanUtils.copyProperties(batch, newBatch);
Set<String> supplierSet = new TreeSet<>();
if (StringUtils.isNotBlank(batch.getSupplierCode())) {
supplierSet.addAll(Arrays.asList(batch.getSupplierCode().split(",")));
}
newBatch.setSupplierCode(String.join(",", supplierSet));
mergedBatches.put(key, newBatch);
}
}
waybillBatches = new ArrayList<>(mergedBatches.values());