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,13 +247,15 @@ 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)) {
materialBaseInfos = materialMainService.getMaterialBaseInfo(materialNos);
for (DQbomExcelVO d : datas) { for (DQbomExcelVO d : datas) {
BaseMaterialVO vo = materialBaseInfos.stream() BaseMaterialVO vo = materialBaseInfos.stream()
.filter(m -> m.getMaterialNo().equals(d.getMaterialNo())) .filter(m -> m.getMaterialNo().equals(d.getMaterialNo()))
@ -263,6 +265,7 @@ public class DQBomImportService {
d.setDrawingNo(vo.getDrawingNo()); d.setDrawingNo(vo.getDrawingNo());
} }
} }
}
//如果编号为空图号不为空则编号使用主物料编号 //如果编号为空图号不为空则编号使用主物料编号
List<String> drawingNos = datas.stream() List<String> drawingNos = datas.stream()
@ -270,6 +273,7 @@ public class DQBomImportService {
.map(DQbomExcelVO::getDrawingNo) .map(DQbomExcelVO::getDrawingNo)
.distinct() .distinct()
.collect(Collectors.toList()); .collect(Collectors.toList());
if (CollUtil.isNotEmpty(drawingNos)) {
materialBaseInfos = SpringUtil.getBean(MaterialMainMapper.class).getMaterialByDrawingNo(drawingNos); materialBaseInfos = SpringUtil.getBean(MaterialMainMapper.class).getMaterialByDrawingNo(drawingNos);
for (DQbomExcelVO d : datas) { for (DQbomExcelVO d : datas) {
if (StrUtil.isNotBlank(d.getDrawingNo()) && StrUtil.isBlank(d.getMaterialNo())) { if (StrUtil.isNotBlank(d.getDrawingNo()) && StrUtil.isBlank(d.getMaterialNo())) {
@ -284,6 +288,7 @@ public class DQBomImportService {
} }
} }
} }
}
return errorMsg; return errorMsg;
} }

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,12 +618,21 @@ public class DQBomService {
parent.setCurrentVersion(VersionUtil.getNextVersion("")); parent.setCurrentVersion(VersionUtil.getNextVersion(""));
} }
//处理子级 //处理子级
List<BomNewDQbomChildEntity> cc = dQBomChildService.getByParentRowId(parent.getRowId());
if (CollUtil.isNotEmpty(cc)) {
cc.forEach(c -> {
c.setStatus(2);
c.setEditStatus(2);
c.setModifyTime(LocalDateTime.now());
});
children.addAll(cc);
dQBomParentService.lambdaQuery() dQBomParentService.lambdaQuery()
.in(BomNewDQbomParentEntity::getMaterialNo, cc.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toList())) .in(BomNewDQbomParentEntity::getMaterialNo, cc.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toList()))
.eq(BomNewDQbomParentEntity::getStatus, 1) .eq(BomNewDQbomParentEntity::getStatus, 1)
.list() .list()
.forEach(p -> buildTree(p, parents, children)); .forEach(p -> buildTree(p, parents, children));
} }
}
private int versionCompare(String version1, String version2) { private int versionCompare(String version1, String version2) {
if (StrUtil.isBlank(version1)) return 1; if (StrUtil.isBlank(version1)) return 1;