fix: 修复原始bom导入excel时图号为空导致的空指针异常

This commit is contained in:
曹鹏飞 2024-04-02 16:26:57 +08:00
parent 58c22a4ca5
commit c8569361ce
1 changed files with 14 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -13,6 +14,7 @@ import com.mzt.logapi.context.LogRecordContext;
import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.bomnew.constant.*;
import com.nflg.product.bomnew.mapper.master.BomNewOriginalParentMapper;
import com.nflg.product.bomnew.pojo.dto.BaseImportExcelDTO;
import com.nflg.product.bomnew.pojo.dto.BomNewOriginalExcelDTO;
import com.nflg.product.bomnew.pojo.dto.OriginalSaveBomDTO;
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalChildEntity;
@ -610,9 +612,9 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
String uuid = IdUtil.simpleUUID();
EecExcelUtil.handlerExcel(file.getInputStream(), BomNewOriginalExcelDTO.class, BomNewOriginalParentService::handlerExcelRow);
List<BomNewOriginalExcelDTO> excelContext = excelContextTL.get();
List<Integer> noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(u -> u.getRowNum()).collect(Collectors.toList());
List<Integer> noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(BaseImportExcelDTO::getRowNum).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noLevelNo)).throwMessage(StrUtil.join(",", noLevelNo) + "层次为空");
List<Integer> noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(u -> u.getRowNum()).collect(Collectors.toList());
List<Integer> noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(BaseImportExcelDTO::getRowNum).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noDrawingNo)).throwMessage(StrUtil.join(",", noDrawingNo) + "图号为空");
// List<Integer> noNum = excelContext.stream().filter(u -> Objects.isNull(u.getQty())).map(u->u.getRowNum()).collect(Collectors.toList());
// VUtils.isTure(CollUtil.isNotEmpty(noNum)).throwMessage( StrUtil.join(",",noNum )+"数量为空");
@ -655,16 +657,22 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
}
public static void handlerExcelRow(BomNewOriginalExcelDTO data) {
rowNum.set(rowNum.get() + 1);
data.setRowNum(rowNum.get());
// data.setOrderNo(data.getLevelNo());
data.setChartNo(StrUtil.trim(data.getChartNo()).replace("", "(").replace("", ")").replace(" ", ""));
if (data.getChartNo().equals("")) {
log.debug("原始bom导入excel" + rowNum.get() + "行:" + JSON.toJSONString(data));
if (Objects.isNull(data.getChartNo()) || data.getChartNo().trim().equals("")) {
data.setChartNo("");
} else {
data.setChartNo(StrUtil.trim(data.getChartNo()).replace("", "(").replace("", ")").replace(" ", ""));
}
if (data.getMaterialNo()!=null && "".contentEquals(StrUtil.trim(data.getMaterialNo()))) {
if (Objects.isNull(data.getMaterialNo()) || data.getMaterialNo().trim().equals("")) {
data.setMaterialNo("");
}
rowNum.set(rowNum.get() + 1);
excelContextTL.get().add(data);