fix: 子卷包装关系新增判断erp卷号是否存在

This commit is contained in:
2026-08-18 13:57:14 +08:00
parent 68a7112921
commit d3feb61e62
5 changed files with 260 additions and 73 deletions

View File

@@ -31,5 +31,12 @@ public interface SlittingproductionplanMapper extends BaseMapperX<Slittingproduc
.orderByDesc(SlittingproductionplanDO::getWorkorderId));
}
/**
* 根据 ERP 子卷号集合查询分切生产计划
*/
default List<SlittingproductionplanDO> selectListByExtContainerNames(Collection<String> extContainerNames) {
return selectList(SlittingproductionplanDO::getExtContainerName, extContainerNames);
}
}

View File

@@ -3,6 +3,7 @@ package cn.code.nl.module.lms.service.subpackagerelation;
import cn.hutool.core.collection.CollUtil;
import cn.code.nl.module.lms.dal.dataobject.boxtype.BoxTypeDO;
import cn.code.nl.module.lms.dal.mysql.boxtype.BoxTypeMapper;
import cn.code.nl.module.lms.dal.mysql.slittingproductionplan.SlittingproductionplanMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
@@ -38,6 +39,8 @@ public class SubPackageRelationServiceImpl implements SubPackageRelationService
private static final String DUPLICATE_CLIENT_KEY = "DUPLICATE_CLIENT_KEY";
/** 子卷号重复错误码 */
private static final String DUPLICATE_CONTAINER_NAME = "DUPLICATE_CONTAINER_NAME";
/** ERP 卷号未同步错误码 */
private static final String ERP_CONTAINER_NOT_SYNCED = "ERP_CONTAINER_NOT_SYNCED";
/** 木箱类型不存在错误码 */
private static final String BOX_TYPE_NOT_FOUND = "BOX_TYPE_NOT_FOUND";
/** 木箱已绑定其他类型错误码 */
@@ -55,6 +58,10 @@ public class SubPackageRelationServiceImpl implements SubPackageRelationService
@Resource
private BoxTypeMapper boxTypeMapper;
/** 分切生产计划数据访问对象 */
@Resource
private SlittingproductionplanMapper slittingproductionplanMapper;
/** 子卷包装关系分组独立事务保存服务 */
@Resource
private SubPackageRelationBatchSaveService batchSaveService;
@@ -161,6 +168,34 @@ public class SubPackageRelationServiceImpl implements SubPackageRelationService
.build();
}
containerNames = validItems.stream()
.map(context -> context.item().getContainerName().trim())
.collect(Collectors.toCollection(LinkedHashSet::new));
Set<String> syncedContainerNames = slittingproductionplanMapper
.selectListByExtContainerNames(containerNames).stream()
.map(item -> item.getExtContainerName())
.filter(Objects::nonNull)
.map(String::trim)
.collect(Collectors.toSet());
List<BatchItemContext> syncedItems = new ArrayList<>();
for (BatchItemContext context : validItems) {
String containerName = context.item().getContainerName().trim();
if (!syncedContainerNames.contains(containerName)) {
failures.add(buildFailure(context.item().getClientKey(), context.rowIndex(),
ERP_CONTAINER_NOT_SYNCED, "ERP 卷号未同步:" + containerName));
continue;
}
syncedItems.add(context);
}
validItems = syncedItems;
if (CollUtil.isEmpty(validItems)) {
return SubPackageRelationBatchCreateRespVO.builder()
.successCount(0)
.failureCount(failures.size())
.failures(failures)
.build();
}
Set<String> boxTypes = validItems.stream()
.map(context -> context.item().getBoxType())
.collect(Collectors.toCollection(LinkedHashSet::new));