From 5c27e69eadd0dff5f6da6385cadef32fc78ecb23 Mon Sep 17 00:00:00 2001 From: jing's Date: Tue, 26 Mar 2024 11:40:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=A0=B4=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/aggreg/OptionalExcelService.java | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/aggreg/OptionalExcelService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/aggreg/OptionalExcelService.java index 3ed9971f..f710088e 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/aggreg/OptionalExcelService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/aggreg/OptionalExcelService.java @@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateUtil; import cn.hutool.core.lang.TypeReference; -import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; import com.alibaba.fastjson.JSON; @@ -21,19 +20,19 @@ import com.nflg.product.bomnew.pojo.dto.OptionalEbomMainDTO; import com.nflg.product.bomnew.pojo.entity.OptionalEbomImportChildEntity; import com.nflg.product.bomnew.pojo.entity.OptionalEbomImportEntity; import com.nflg.product.bomnew.pojo.entity.OptionalEbomMainEntity; -import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO; -import com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO; import com.nflg.product.bomnew.service.*; import com.nflg.product.bomnew.service.domain.OptionalEBom.ConvertToMainHistory; import lombok.extern.slf4j.Slf4j; import nflg.product.common.constant.STATE; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.InputStream; -import java.util.*; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -374,8 +373,13 @@ public class OptionalExcelService { for (; row < list.size(); row++) { ImportExcelField rowField = list.get(row); optionName = rowField.getCellFirst(); - optionName= optionName.replace("\t", " "); + if(!rowField.getCellFirst().equals(rowField.getCellSecond())){ + throw new NflgBusinessException(STATE.Error, StrUtil.format("第{}行,{} excel格式错误", rowField.getLineNo(), optionName)); + + } + + optionName= optionName.replace("\t", " "); //黄色根部选项解析 int optionParentPos = optionName.indexOf(" "); @@ -392,9 +396,11 @@ public class OptionalExcelService { optionalEbomInportExcelDTO.getOptionInfo().add(optionalEbomImportL1); while (++row> group1 = classList.parallelStream() .collect(Collectors.groupingBy(ImportExcelField::getCellFirst, LinkedHashMap::new, Collectors.toList())); - if (group1 == null || CollectionUtil.isEmpty(group1)) { - throw new NflgBusinessException(STATE.Error, StrUtil.format("转换{}选项下数据异常", optionName)); + if ( CollectionUtil.isEmpty(group1)) { + throw new NflgBusinessException(STATE.Error, StrUtil.format("转换数据异常,解析 {} 下数据失败,请确认excel格式及数据", optionName)); } parseOptionColumn2(group1, optionalEbomImportL1); classList.clear(); @@ -464,7 +470,7 @@ public class OptionalExcelService { } if(optionalEbomInportExcelDTO==null){ - throw new NflgBusinessException(STATE.Error, "解析数据失败"); + throw new NflgBusinessException(STATE.Error, "解析excel数据失败"); } // if (optionalEbomInportExcelDTO != null) { @@ -488,16 +494,17 @@ public class OptionalExcelService { // } // } + log.info( JSON.toJSONString(optionalEbomInportExcelDTO)); //检查是否满足条件 除了‘无’ ,物料号不能为空 String hintMsg = isValiData(optionalEbomInportExcelDTO.getOptionInfo()); if (StrUtil.isNotEmpty(hintMsg)) { throw new NflgBusinessException(STATE.Error, hintMsg); } - System.out.println(JSON.toJSONString(optionalEbomInportExcelDTO)); - // return true; + + return true; //保存db - return batchExcelToRepertory(optionalEbomInportExcelDTO); + // return batchExcelToRepertory(optionalEbomInportExcelDTO); }