Merge branch 'refs/heads/feature/DM/nflg-bom-dq' into sit_bak

This commit is contained in:
曹鹏飞 2024-05-23 18:20:30 +08:00
commit 03f141fde2
2 changed files with 38 additions and 42 deletions

View File

@ -247,20 +247,23 @@ public class DQBomImportService {
.map(d -> OperationErrorMsgVO.create("" + d.getRowNum() + "", "编号和图号都为空")) .map(d -> OperationErrorMsgVO.create("" + d.getRowNum() + "", "编号和图号都为空"))
.collect(Collectors.toList())); .collect(Collectors.toList()));
List<BaseMaterialVO> materialBaseInfos;
//如果编号不为空则图号使用主物料图号 //如果编号不为空则图号使用主物料图号
List<String> materialNos = datas.stream() List<String> materialNos = datas.stream()
.map(DQbomExcelVO::getMaterialNo) .map(DQbomExcelVO::getMaterialNo)
.filter(StrUtil::isNotBlank) .filter(StrUtil::isNotBlank)
.distinct() .distinct()
.collect(Collectors.toList()); .collect(Collectors.toList());
List<BaseMaterialVO> materialBaseInfos = materialMainService.getMaterialBaseInfo(materialNos); if (CollUtil.isNotEmpty(materialNos)) {
for (DQbomExcelVO d : datas) { materialBaseInfos = materialMainService.getMaterialBaseInfo(materialNos);
BaseMaterialVO vo = materialBaseInfos.stream() for (DQbomExcelVO d : datas) {
.filter(m -> m.getMaterialNo().equals(d.getMaterialNo())) BaseMaterialVO vo = materialBaseInfos.stream()
.findFirst() .filter(m -> m.getMaterialNo().equals(d.getMaterialNo()))
.orElse(null); .findFirst()
if (Objects.nonNull(vo)) { .orElse(null);
d.setDrawingNo(vo.getDrawingNo()); if (Objects.nonNull(vo)) {
d.setDrawingNo(vo.getDrawingNo());
}
} }
} }
@ -270,17 +273,19 @@ public class DQBomImportService {
.map(DQbomExcelVO::getDrawingNo) .map(DQbomExcelVO::getDrawingNo)
.distinct() .distinct()
.collect(Collectors.toList()); .collect(Collectors.toList());
materialBaseInfos = SpringUtil.getBean(MaterialMainMapper.class).getMaterialByDrawingNo(drawingNos); if (CollUtil.isNotEmpty(drawingNos)) {
for (DQbomExcelVO d : datas) { materialBaseInfos = SpringUtil.getBean(MaterialMainMapper.class).getMaterialByDrawingNo(drawingNos);
if (StrUtil.isNotBlank(d.getDrawingNo()) && StrUtil.isBlank(d.getMaterialNo())) { for (DQbomExcelVO d : datas) {
BaseMaterialVO vo = materialBaseInfos.stream() if (StrUtil.isNotBlank(d.getDrawingNo()) && StrUtil.isBlank(d.getMaterialNo())) {
.filter(m -> m.getDrawingNo().equals(d.getDrawingNo())) BaseMaterialVO vo = materialBaseInfos.stream()
.findFirst() .filter(m -> m.getDrawingNo().equals(d.getDrawingNo()))
.orElse(null); .findFirst()
if (Objects.nonNull(vo)) { .orElse(null);
d.setMaterialNo(vo.getMaterialNo()); if (Objects.nonNull(vo)) {
} else { d.setMaterialNo(vo.getMaterialNo());
errorMsg.add(OperationErrorMsgVO.create("" + d.getRowNum() + "", "图号不存在")); } else {
errorMsg.add(OperationErrorMsgVO.create("" + d.getRowNum() + "", "图号不存在"));
}
} }
} }
} }

View File

@ -593,13 +593,6 @@ public class DQBomService {
wrapper.eq(BomNewDQbomParentEntity::getMaterialNo, parent.getMaterialNo()); wrapper.eq(BomNewDQbomParentEntity::getMaterialNo, parent.getMaterialNo());
wrapper.ne(BomNewDQbomParentEntity::getRowId, parent.getRowId()); wrapper.ne(BomNewDQbomParentEntity::getRowId, parent.getRowId());
dQBomParentService.getBaseMapper().delete(wrapper); dQBomParentService.getBaseMapper().delete(wrapper);
List<BomNewDQbomChildEntity> cc = dQBomChildService.getByParentRowId(parent.getRowId());
cc.forEach(c -> {
c.setStatus(2);
c.setEditStatus(2);
c.setModifyTime(LocalDateTime.now());
});
children.addAll(cc);
BomNewPbomParentEntity pp = bomNewPbomParentService.lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo()) BomNewPbomParentEntity pp = bomNewPbomParentService.lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo())
.orderByDesc(BomNewPbomParentEntity::getRowId) .orderByDesc(BomNewPbomParentEntity::getRowId)
@ -611,20 +604,9 @@ public class DQBomService {
, parent.getCurrentVersion(), pp.getCurrentVersion())); , parent.getCurrentVersion(), pp.getCurrentVersion()));
} else { } else {
if (pp.getStatus() >= 4) { if (pp.getStatus() >= 4) {
// List<BomNewDQbomVO> dqChildren = getChild(parent.getRowId());
// Set<String> pChildren = bomNewPbomChildService.lambdaQuery()
// .select(BomNewPbomChildEntity::getMaterialNo)
// .eq(BomNewPbomChildEntity::getParentRowId, pp.getRowId())
// .list()
// .stream()
// .map(BomNewPbomChildEntity::getMaterialNo)
// .collect(Collectors.toSet());
// if (dqChildren.size() != pChildren.size()
// || !Sets.difference(dqChildren.stream().map(BomNewDQbomVO::getMaterialNo).collect(Collectors.toSet()), pChildren).isEmpty()) {
parent.setCurrentVersion(VersionUtil.getNextVersion(pp.getCurrentVersion())); parent.setCurrentVersion(VersionUtil.getNextVersion(pp.getCurrentVersion()));
pp.setLastVersionIs(0); pp.setLastVersionIs(0);
bomNewPbomParentService.updateById(pp); bomNewPbomParentService.updateById(pp);
// }
} else { } else {
parent.setCurrentVersion(pp.getCurrentVersion()); parent.setCurrentVersion(pp.getCurrentVersion());
bomNewPbomParentService.getBaseMapper().deleteById(pp.getRowId()); bomNewPbomParentService.getBaseMapper().deleteById(pp.getRowId());
@ -636,11 +618,20 @@ public class DQBomService {
parent.setCurrentVersion(VersionUtil.getNextVersion("")); parent.setCurrentVersion(VersionUtil.getNextVersion(""));
} }
//处理子级 //处理子级
dQBomParentService.lambdaQuery() List<BomNewDQbomChildEntity> cc = dQBomChildService.getByParentRowId(parent.getRowId());
.in(BomNewDQbomParentEntity::getMaterialNo, cc.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toList())) if (CollUtil.isNotEmpty(cc)) {
.eq(BomNewDQbomParentEntity::getStatus, 1) cc.forEach(c -> {
.list() c.setStatus(2);
.forEach(p -> buildTree(p, parents, children)); c.setEditStatus(2);
c.setModifyTime(LocalDateTime.now());
});
children.addAll(cc);
dQBomParentService.lambdaQuery()
.in(BomNewDQbomParentEntity::getMaterialNo, cc.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toList()))
.eq(BomNewDQbomParentEntity::getStatus, 1)
.list()
.forEach(p -> buildTree(p, parents, children));
}
} }
private int versionCompare(String version1, String version2) { private int versionCompare(String version1, String version2) {