feat(ebom): 修复last_version_is的设置问题

This commit is contained in:
曹鹏飞 2024-06-23 19:44:07 +08:00
parent 0e80f4e4f7
commit c702a95282
1 changed files with 16 additions and 16 deletions

View File

@ -102,22 +102,22 @@ public class EBomImportService {
private void save(List<BomNewEbomParentEntity> parents, List<BomNewEbomChildEntity> children) { private void save(List<BomNewEbomParentEntity> parents, List<BomNewEbomChildEntity> children) {
Set<String> pMaterialNos = parents.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toSet()); Set<String> pMaterialNos = parents.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toSet());
List<BomNewEbomParentEntity> oldParents = bomNewEbomParentService.getLatestByMaterialNo(pMaterialNos); List<BomNewEbomParentEntity> oldParents = bomNewEbomParentService.getLatestByMaterialNo(pMaterialNos);
oldParents.forEach(p -> { if (CollUtil.isNotEmpty(oldParents)) {
if (!Objects.equals(p.getStatus(), EBomStatusEnum.PUBLISHED.getValue())) { oldParents.forEach(p -> {
bomNewEbomParentService.getBaseMapper().deleteById(p.getRowId()); if (!Objects.equals(p.getStatus(), EBomStatusEnum.PUBLISHED.getValue())) {
bomNewEbomChildService.deleteAllChildren(p.getRowId()); bomNewEbomParentService.getBaseMapper().deleteById(p.getRowId());
parents.stream().filter(it -> StrUtil.equals(it.getMaterialNo(), p.getMaterialNo())).forEach(it -> { bomNewEbomChildService.deleteAllChildren(p.getRowId());
it.setCurrentVersion(p.getCurrentVersion()); parents.stream().filter(it -> StrUtil.equals(it.getMaterialNo(), p.getMaterialNo())).forEach(it -> {
}); it.setCurrentVersion(p.getCurrentVersion());
p.setLastVersionIs(0); });
} else { } else {
parents.stream().filter(it -> StrUtil.equals(it.getMaterialNo(), p.getMaterialNo())).forEach(it -> { parents.stream().filter(it -> StrUtil.equals(it.getMaterialNo(), p.getMaterialNo())).forEach(it -> {
it.setCurrentVersion(VersionUtil.getNextVersionForSmallVersion(p.getCurrentVersion())); it.setCurrentVersion(VersionUtil.getNextVersionForSmallVersion(p.getCurrentVersion()));
}); });
} }
}); });
//bomNewEbomParentService.setLastVersionIs0(oldParents.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toSet())); bomNewEbomParentService.setLastVersionIs0(oldParents.stream().map(BomNewEbomParentEntity::getRowId).collect(Collectors.toList()));
bomNewEbomParentService.updateBatchById(oldParents.stream().filter(f -> f.getLastVersionIs() == 0).collect(Collectors.toList())); }
bomNewEbomParentService.saveBatch(parents); bomNewEbomParentService.saveBatch(parents);
bomNewEbomChildService.saveBatch(children); bomNewEbomChildService.saveBatch(children);
} }