移动破解析调整

This commit is contained in:
jing's 2024-03-26 11:40:00 +08:00
parent e61a20e7f9
commit 5c27e69ead
1 changed files with 22 additions and 15 deletions

View File

@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.TypeReference; import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON; 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.OptionalEbomImportChildEntity;
import com.nflg.product.bomnew.pojo.entity.OptionalEbomImportEntity; import com.nflg.product.bomnew.pojo.entity.OptionalEbomImportEntity;
import com.nflg.product.bomnew.pojo.entity.OptionalEbomMainEntity; 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.*;
import com.nflg.product.bomnew.service.domain.OptionalEBom.ConvertToMainHistory; import com.nflg.product.bomnew.service.domain.OptionalEBom.ConvertToMainHistory;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import nflg.product.common.constant.STATE; import nflg.product.common.constant.STATE;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.InputStream; 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.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -374,8 +373,13 @@ public class OptionalExcelService {
for (; row < list.size(); row++) { for (; row < list.size(); row++) {
ImportExcelField rowField = list.get(row); ImportExcelField rowField = list.get(row);
optionName = rowField.getCellFirst(); 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(" "); int optionParentPos = optionName.indexOf(" ");
@ -392,9 +396,11 @@ public class OptionalExcelService {
optionalEbomInportExcelDTO.getOptionInfo().add(optionalEbomImportL1); optionalEbomInportExcelDTO.getOptionInfo().add(optionalEbomImportL1);
while (++row<list.size()){ while (++row<list.size()){
ImportExcelField rowField1 = list.get(row); ImportExcelField rowFieldChild = list.get(row);
if(StrUtil.contains(rowField1.getCellFirst(),optionalEbomImportL1.getOptionDrawingNo())) {
classList.add(rowField1); if(!rowFieldChild.getCellFirst().equals(rowFieldChild.getCellSecond())){
// if(StrUtil.contains(rowField1.getCellFirst(),optionalEbomImportL1.getOptionDrawingNo())) {
classList.add(rowFieldChild);
}else{ }else{
--row; --row;
break; break;
@ -403,8 +409,8 @@ public class OptionalExcelService {
Map<String, List<ImportExcelField>> group1 = classList.parallelStream() Map<String, List<ImportExcelField>> group1 = classList.parallelStream()
.collect(Collectors.groupingBy(ImportExcelField::getCellFirst, LinkedHashMap::new, Collectors.toList())); .collect(Collectors.groupingBy(ImportExcelField::getCellFirst, LinkedHashMap::new, Collectors.toList()));
if (group1 == null || CollectionUtil.isEmpty(group1)) { if ( CollectionUtil.isEmpty(group1)) {
throw new NflgBusinessException(STATE.Error, StrUtil.format("转换{}选项下数据异常", optionName)); throw new NflgBusinessException(STATE.Error, StrUtil.format("转换数据异常,解析 {} 下数据失败请确认excel格式及数据", optionName));
} }
parseOptionColumn2(group1, optionalEbomImportL1); parseOptionColumn2(group1, optionalEbomImportL1);
classList.clear(); classList.clear();
@ -464,7 +470,7 @@ public class OptionalExcelService {
} }
if(optionalEbomInportExcelDTO==null){ if(optionalEbomInportExcelDTO==null){
throw new NflgBusinessException(STATE.Error, "解析数据失败"); throw new NflgBusinessException(STATE.Error, "解析excel数据失败");
} }
// if (optionalEbomInportExcelDTO != null) { // if (optionalEbomInportExcelDTO != null) {
@ -488,16 +494,17 @@ public class OptionalExcelService {
// } // }
// } // }
log.info( JSON.toJSONString(optionalEbomInportExcelDTO));
//检查是否满足条件 除了 物料号不能为空 //检查是否满足条件 除了 物料号不能为空
String hintMsg = isValiData(optionalEbomInportExcelDTO.getOptionInfo()); String hintMsg = isValiData(optionalEbomInportExcelDTO.getOptionInfo());
if (StrUtil.isNotEmpty(hintMsg)) { if (StrUtil.isNotEmpty(hintMsg)) {
throw new NflgBusinessException(STATE.Error, hintMsg); throw new NflgBusinessException(STATE.Error, hintMsg);
} }
System.out.println(JSON.toJSONString(optionalEbomInportExcelDTO));
// return true; return true;
//保存db //保存db
return batchExcelToRepertory(optionalEbomInportExcelDTO); // return batchExcelToRepertory(optionalEbomInportExcelDTO);
} }