| | |
| | | for (MdmItemImportExcelVO importVO : importList) { |
| | | // 2.1 基础校验 |
| | | if (StrUtil.isBlank(importVO.getCode()) || StrUtil.isBlank(importVO.getName())) { |
| | | respVO.getFailureList().put(StrUtil.blankToDefault(importVO.getName(), importVO.getCode()), "物料编码和物料名称不能为空"); |
| | | String failKey = StrUtil.isNotBlank(importVO.getName()) ? importVO.getName() |
| | | : (StrUtil.isNotBlank(importVO.getCode()) ? importVO.getCode() : "(名称和编码为空的行)"); |
| | | respVO.getFailureList().put(failKey, "物料编码和物料名称不能为空"); |
| | | continue; |
| | | } |
| | | // 2.2 解析分类 |
| | |
| | | if (StrUtil.isNotBlank(importVO.getCategoryCode())) { |
| | | categoryId = categoryCodeIdMap.get(importVO.getCategoryCode()); |
| | | if (categoryId == null) { |
| | | respVO.getFailureList().put(importVO.getName(), "物料分类编码不存在:" + importVO.getCategoryCode()); |
| | | respVO.getFailureList().put(StrUtil.blankToDefault(importVO.getName(), importVO.getCode()), "物料分类编码不存在:" + importVO.getCategoryCode()); |
| | | continue; |
| | | } |
| | | } |
| | |
| | | if (StrUtil.isNotBlank(importVO.getUnitMeasureCode())) { |
| | | unitMeasureId = unitCodeIdMap.get(importVO.getUnitMeasureCode()); |
| | | if (unitMeasureId == null) { |
| | | respVO.getFailureList().put(importVO.getName(), "计量单位编码不存在:" + importVO.getUnitMeasureCode()); |
| | | respVO.getFailureList().put(StrUtil.blankToDefault(importVO.getName(), importVO.getCode()), "计量单位编码不存在:" + importVO.getUnitMeasureCode()); |
| | | continue; |
| | | } |
| | | } |
| | |
| | | if (StrUtil.isNotBlank(importVO.getUnitMeasureCode2())) { |
| | | unitMeasureId2 = unitCodeIdMap.get(importVO.getUnitMeasureCode2()); |
| | | if (unitMeasureId2 == null) { |
| | | respVO.getFailureList().put(importVO.getName(), "辅单位1编码不存在:" + importVO.getUnitMeasureCode2()); |
| | | respVO.getFailureList().put(StrUtil.blankToDefault(importVO.getName(), importVO.getCode()), "辅单位1编码不存在:" + importVO.getUnitMeasureCode2()); |
| | | continue; |
| | | } |
| | | } |
| | |
| | | if (StrUtil.isNotBlank(importVO.getUnitMeasureCode3())) { |
| | | unitMeasureId3 = unitCodeIdMap.get(importVO.getUnitMeasureCode3()); |
| | | if (unitMeasureId3 == null) { |
| | | respVO.getFailureList().put(importVO.getName(), "辅单位2编码不存在:" + importVO.getUnitMeasureCode3()); |
| | | respVO.getFailureList().put(StrUtil.blankToDefault(importVO.getName(), importVO.getCode()), "辅单位2编码不存在:" + importVO.getUnitMeasureCode3()); |
| | | continue; |
| | | } |
| | | } |
| | |
| | | try { |
| | | if (existByCode != null) { |
| | | if (!Boolean.TRUE.equals(isUpdateSupport)) { |
| | | respVO.getFailureList().put(importVO.getName(), "物料编码已存在"); |
| | | respVO.getFailureList().put(StrUtil.blankToDefault(importVO.getName(), importVO.getCode()), "物料编码已存在"); |
| | | continue; |
| | | } |
| | | saveReqVO.setId(existByCode.getId()); |
| | |
| | | String reason = ex instanceof cn.iocoder.yudao.framework.common.exception.ServiceException |
| | | ? ((cn.iocoder.yudao.framework.common.exception.ServiceException) ex).getMessage() |
| | | : ex.getMessage(); |
| | | respVO.getFailureList().put(importVO.getName(), reason == null ? "导入失败" : reason); |
| | | respVO.getFailureList().put(StrUtil.blankToDefault(importVO.getName(), importVO.getCode()), reason == null ? "导入失败" : reason); |
| | | } |
| | | } |
| | | return respVO; |