fix: 81780 国内标准-导入正确数据,提示分标委和零部件填写错误

This commit is contained in:
2024-02-05 17:19:43 +08:00
parent fb2f1ec371
commit 9d7bc1e83c
@@ -10,14 +10,10 @@ import com.jero.common.system.vo.DictModel;
import com.jero.common.util.CommonUtils;
import com.jero.common.util.oConvertUtils;
import com.jero.modules.laws.common.constant.FieldCommon;
import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard;
import com.jero.modules.laws.standard.entity.LawsOverseasStandard;
import com.jero.modules.laws.standard.entity.LawsTreeNode;
import com.jero.modules.laws.standard.service.ILawsDomesticStandardService;
import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService;
import com.jero.modules.laws.standard.service.ILawsOverseasStandardService;
import com.jero.modules.laws.standard.service.ILawsTreeNodeService;
import com.jero.modules.laws.standard.entity.*;
import com.jero.modules.laws.standard.service.*;
import com.jero.modules.laws.standardization.entity.LawsStandardization;
import com.jero.modules.laws.standardization.service.ILawsStandardizationService;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
import com.jero.modules.system.entity.SysDepart;
@@ -82,6 +78,12 @@ public class ImportUtil {
@Resource
private ILawsOverseasStandardService overseasStandardService;
@Resource
private PartNameService partNameService;
@Resource
private ILawsStandardizationService standardizationService;
public List<String> validExcelData(Sheet sheet, List<LawsTag> headerList, Map<String, File> fileMap, List<Map<String, Object>> insertDataList) {
List<String> errMsgList = new ArrayList<>();
@@ -327,8 +329,20 @@ public class ImportUtil {
}
}
// 分标委
if (FieldCommon.BIDDING_COMMITTEE.equals(tag.getDbFieldName())) {
if (!this.biddingCommitteeValid(cellValue)) {
log.error("" + row + "" + tag.getDbFieldTxt() + "填写错误 ");
errMsg.append("").append(row).append("").append(tag.getDbFieldTxt()).append("填写错误 ");
} else {
// 转为id
cellValue = this.convertBiddingCommitteeValid(cellValue);
}
}
// 下拉单选
if (FieldShowTypeEnum.DROPDOWN_SINGLE_SELECT.getValue().equals(tag.getFieldShowType())) {
if (FieldShowTypeEnum.DROPDOWN_SINGLE_SELECT.getValue().equals(tag.getFieldShowType()) &&
!FieldCommon.BIDDING_COMMITTEE.equals(tag.getDbFieldName())) {
if (!this.singleDictValid(tag.getDictField(), cellValue)) {
log.error("" + row + "" + tag.getDbFieldTxt() + "填写错误 ");
errMsg.append("").append(row).append("").append(tag.getDbFieldTxt()).append("填写错误 ");
@@ -505,6 +519,35 @@ public class ImportUtil {
return errMsgList;
}
private String convertBiddingCommitteeValid(String cellValue) {
List<String> valueList = Arrays.asList(cellValue.split(","));
LambdaQueryWrapper<LawsStandardization> wrapper = new LambdaQueryWrapper<>();
wrapper.in(LawsStandardization::getName, valueList);
List<LawsStandardization> list = standardizationService.list(wrapper);
Map<String, String> systemMap = list.stream().collect(Collectors.toMap(LawsStandardization::getName, LawsStandardization::getId));
StringBuilder result = new StringBuilder();
for (String value : valueList) {
result.append(systemMap.get(value)).append(",");
}
// 去除掉最后的逗号
return result.substring(0, result.length() - 1);
}
private boolean biddingCommitteeValid(String cellValue) {
String[] valueList = cellValue.split(",");
LambdaQueryWrapper<LawsStandardization> wrapper = new LambdaQueryWrapper<>();
wrapper.in(LawsStandardization::getName, Arrays.asList(valueList));
List<LawsStandardization> list = standardizationService.list(wrapper);
Map<String, String> map = list.stream().collect(Collectors.toMap(LawsStandardization::getName, LawsStandardization::getId));
for (String value : valueList) {
if (map.get(value) == null) {
return false;
}
}
return true;
}
public Date convertDate(String cellValue) {
if (StrUtil.isBlank(cellValue)) {
return null;
@@ -709,13 +752,14 @@ public class ImportUtil {
// 零部件转换
public String convertPartId(String cellValue) {
List<String> valueList = Arrays.asList(cellValue.split(","));
LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper = new LambdaQueryWrapper<>();
sysDictItemLambdaQueryWrapper.in(SysDictItem::getItemText, valueList);
Map<String, String> idMap = sysDictItemService.list(sysDictItemLambdaQueryWrapper).stream()
.collect(Collectors.toMap(SysDictItem::getItemText, SysDictItem::getItemValue));
LambdaQueryWrapper<PartName> partNameLambdaQueryWrapper = new LambdaQueryWrapper<>();
partNameLambdaQueryWrapper.in(PartName::getName, valueList);
List<PartName> partNameList = partNameService.list(partNameLambdaQueryWrapper);
Map<String, String> partMap = partNameList.stream().collect(Collectors.toMap(PartName::getName, PartName::getCode));
StringBuilder result = new StringBuilder();
for (String value : valueList) {
result.append(idMap.get(value)).append(",");
result.append(partMap.get(value)).append(",");
}
// 去除掉最后的逗号
return result.substring(0, result.length() - 1);
@@ -817,11 +861,12 @@ public class ImportUtil {
// 零部件
public boolean partValid(String cellValue) {
String[] valueList = cellValue.split(",");
List<DictModel> partDictModelList = sysBaseAPI.getDictItems("part_name");
Map<String, DictModel> partDictModelMap = partDictModelList.stream()
.collect(Collectors.toMap(DictModel::getText, d -> d));
LambdaQueryWrapper<PartName> partNameWrapper = new LambdaQueryWrapper<>();
partNameWrapper.in(PartName::getName, Arrays.asList(valueList));
List<PartName> list = partNameService.list(partNameWrapper);
Map<String, String> partNameMap = list.stream().collect(Collectors.toMap(PartName::getName, PartName::getCode));
for (String value : valueList) {
if (!partDictModelMap.containsKey(value)) {
if (partNameMap.get(value) == null) {
return false;
}
}