Merge remote-tracking branch 'origin/feature/DM/nflg-bom' into feature/DM/nflg-bom

This commit is contained in:
大米 2024-05-16 17:36:29 +08:00
commit af37144ba0
1 changed files with 36 additions and 24 deletions

View File

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.fasterxml.jackson.core.JsonProcessingException;
@ -14,6 +15,7 @@ import com.nflg.product.bomnew.constant.BomConstant;
import com.nflg.product.bomnew.constant.DQBomStatusEnum;
import com.nflg.product.bomnew.constant.EBomExceptionStatusEnum;
import com.nflg.product.bomnew.constant.UserJobEnum;
import com.nflg.product.bomnew.mapper.master.MaterialMainMapper;
import com.nflg.product.bomnew.pojo.dto.BaseImportExcelDTO;
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomParentEntity;
@ -240,18 +242,48 @@ public class DQBomImportService {
);
}
List<String> materialNos = datas.stream().map(DQbomExcelVO::getMaterialNo).distinct().collect(Collectors.toList());
errorMsg.addAll(datas.stream()
.filter(d -> StrUtil.isBlank(d.getMaterialNo()) && StrUtil.isBlank(d.getDrawingNo()))
.map(d -> OperationErrorMsgVO.create("" + d.getRowNum() + "", "编号和图号都为空"))
.collect(Collectors.toList()));
//如果编号不为空则图号使用主物料图号
List<String> materialNos = datas.stream()
.map(DQbomExcelVO::getMaterialNo)
.filter(StrUtil::isNotBlank)
.distinct()
.collect(Collectors.toList());
List<BaseMaterialVO> materialBaseInfos = materialMainService.getMaterialBaseInfo(materialNos);
datas.forEach(d -> {
for (DQbomExcelVO d : datas) {
BaseMaterialVO vo = materialBaseInfos.stream()
.filter(m -> m.getMaterialNo().equals(d.getMaterialNo()))
.findFirst()
.orElse(null);
if (!Objects.isNull(vo)) {
if (Objects.nonNull(vo)) {
d.setDrawingNo(vo.getDrawingNo());
}
});
}
//如果编号为空图号不为空则编号使用主物料编号
List<String> drawingNos = datas.stream()
.filter(d -> StrUtil.isNotBlank(d.getDrawingNo()) && StrUtil.isBlank(d.getMaterialNo()))
.map(DQbomExcelVO::getDrawingNo)
.distinct()
.collect(Collectors.toList());
materialBaseInfos = SpringUtil.getBean(MaterialMainMapper.class).getMaterialByDrawingNo(drawingNos);
for (DQbomExcelVO d : datas) {
if (StrUtil.isNotBlank(d.getDrawingNo()) && StrUtil.isBlank(d.getMaterialNo())) {
BaseMaterialVO vo = materialBaseInfos.stream()
.filter(m -> m.getDrawingNo().equals(d.getDrawingNo()))
.findFirst()
.orElse(null);
if (Objects.nonNull(vo)) {
d.setMaterialNo(vo.getMaterialNo());
} else {
errorMsg.add(OperationErrorMsgVO.create("" + d.getRowNum() + "", "图号不存在"));
}
}
}
return errorMsg;
}
@ -266,27 +298,7 @@ public class DQBomImportService {
BomNewDQbomParentEntity parent = parents.stream().filter(p -> p.getMaterialNo().equals(data.getMaterialNo()))
.findFirst()
.orElse(null);
//if (parent == null && (count - 1 != index || datas.get(index + 1).getLevel() > data.getLevel())) {
if (parent == null && count - 1 > index && datas.get(index + 1).getLevel() > data.getLevel()) {
// if (index == 0) {
// BomNewDQbomParentEntity old = dQBomParentService.lambdaQuery()
// .eq(data.getProjectType().equals("L"), BomNewDQbomParentEntity::getMaterialNo, data.getMaterialNo())
// .eq(data.getProjectType().equals("T"), BomNewDQbomParentEntity::getMaterialName, data.getMaterialName())
// .orderByDesc(BomNewDQbomParentEntity::getRowId)
// .last(" limit 1")
// .one();
// if (!Objects.isNull(old)) {
// VUtils.isTure(Objects.equals(data.getMaterialUnit(), old.getMaterialUnit())
// || Objects.equals(data.getNum(), old.getNum())
// || Objects.equals(data.getMaterialTexture(), old.getMaterialTexture()))
// .throwMessage("导入的数据已存在,请勿重复导入");
// if (Objects.equals(old.getStatus(), DQBomStatusEnum.WAIT_CONVERT.getValue())) {
// VUtils.isTure(!Objects.equals(old.getCreatedBy(), SessionUtil.getUserCode()))
// .throwMessage(StrUtil.format("此物料已由{}导入过,不能再次导入", old.getCreatedName()));
// }
// }
// }
parent = new BomNewDQbomParentEntity();
parent.setRowId(IdWorker.getId());
parent.setLevel(data.getLevel());