feat: 导入企标引用标准自动带

This commit is contained in:
2024-09-13 20:18:19 +08:00
parent ce48098cb4
commit 6df10430c0
2 changed files with 39 additions and 11 deletions
@@ -1720,10 +1720,16 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
headerList.remove(headerList.size() - 1); headerList.remove(headerList.size() - 1);
headerList.add(inspectContentTag); headerList.add(inspectContentTag);
} }
List<LawsDomesticStandard> list = lawsDomesticStandardService.list();
List<String> standardNoList = list.stream().map(LawsDomesticStandard::getStandardNumber)
.filter(e -> !e.contains("-") & !e.contains(""))
.collect(Collectors.toList());
// 获取错误信息 // 获取错误信息
errMsgList = importUtil.validExcelData(sheet, headerList, fileMap, insertDataList, errMsgList = importUtil.validExcelData(sheet, headerList, fileMap, insertDataList,
treeNodeMap, treeNodePathMap, treeNodeMap, treeNodePathMap,
sysDeaprtMap, sysDepartPathMap); sysDeaprtMap, sysDepartPathMap,
standardNoList);
} }
return errMsgList; return errMsgList;
} }
@@ -77,7 +77,8 @@ public class ImportUtil {
Map<String, List<LawsTreeNode>> treeNodeMap, Map<String, List<LawsTreeNode>> treeNodeMap,
Map<String, String> treeNodePathMap, Map<String, String> treeNodePathMap,
Map<String, List<SysDepart>> sysDepartMap, Map<String, List<SysDepart>> sysDepartMap,
Map<String, String> sysDepartPathMap Map<String, String> sysDepartPathMap,
List<String> fbStandardNoList
) { ) {
List<String> errMsgList = new ArrayList<>(); List<String> errMsgList = new ArrayList<>();
Map<String, Integer> keyMap = new HashMap<>(); Map<String, Integer> keyMap = new HashMap<>();
@@ -273,7 +274,6 @@ public class ImportUtil {
cellValue = this.convertDictValue(tag.getDictField(), cellValue); cellValue = this.convertDictValue(tag.getDictField(), cellValue);
} }
} }
// 组织机构 // 组织机构
if (FieldShowTypeEnum.SINGLE_ORGANIZATION_DIALOG.getValue().equals(tag.getFieldShowType()) || if (FieldShowTypeEnum.SINGLE_ORGANIZATION_DIALOG.getValue().equals(tag.getFieldShowType()) ||
FieldShowTypeEnum.MULTI_ORGANIZATION_DIALOG.getValue().equals(tag.getFieldShowType())) { FieldShowTypeEnum.MULTI_ORGANIZATION_DIALOG.getValue().equals(tag.getFieldShowType())) {
@@ -392,14 +392,8 @@ public class ImportUtil {
// 企标稽查内容文件导入 // 企标稽查内容文件导入
if (FieldCommon.REFERENCE_STANDARD.equals(tag.getDbFieldName()) && if (FieldCommon.REFERENCE_STANDARD.equals(tag.getDbFieldName()) &&
TableNameEnum.ENTERPRISE_STANDARDS.getValue().equals(tag.getIsModel())) { TableNameEnum.ENTERPRISE_STANDARDS.getValue().equals(tag.getIsModel())) {
// if (!this.inspectContentFileValid(cellValue, fileMap)) { // 将转好的值加入Map
// log.error("第" + row + "列" + tag.getDbFieldTxt() + "填写错误 "); parameterMap.put(FieldCommon.REFERENCE_STANDARD, this.convertReferenceStandard(cellValue, fbStandardNoList));
// errMsg.append("第").append(row).append("列").append(tag.getDbFieldTxt()).append("填写错误 ");
// } else {
// // 转为List
// // 将转好的值加入Map
// parameterMap.put(tag.getDbFieldName(), this.convertInspectContentFile(cellValue, fileMap));
// }
} }
} }
if (errMsg.toString().contains("") || errMsg.toString().contains("重复") || errMsg.toString().contains("已存在")) { if (errMsg.toString().contains("") || errMsg.toString().contains("重复") || errMsg.toString().contains("已存在")) {
@@ -411,6 +405,34 @@ public class ImportUtil {
return errMsgList; return errMsgList;
} }
private String convertReferenceStandard(String cellValue, List<String> fbStandardNoList) {
if (StrUtil.isBlank(cellValue)) {
return "";
}
List<String> standardNoList = new ArrayList<>(Arrays.asList(cellValue.split(",")));
Iterator<String> iterator = standardNoList.iterator();
List<String> addStandardNoList = new ArrayList<>();
while (iterator.hasNext()) {
String standardNo = iterator.next();
if (standardNo.contains("-") || standardNo.contains("")) {
continue;
}
List<String> match = fbStandardNoList.stream().filter(s -> s.contains(standardNo)).collect(Collectors.toList());
if (!match.isEmpty()) {
iterator.remove();
addStandardNoList.addAll(match);
}
}
String result = String.join(",", standardNoList);
if (!addStandardNoList.isEmpty()) {
if (!result.isEmpty()) {
result += ",";
}
result += String.join(",", addStandardNoList);
}
return result;
}
// 体系校验 // 体系校验
public boolean standardSystemValid(String cellValue, Map<String, List<LawsTreeNode>> treeNodeMap, Map<String, String> treeNodePathMap) { public boolean standardSystemValid(String cellValue, Map<String, List<LawsTreeNode>> treeNodeMap, Map<String, String> treeNodePathMap) {
String[] cellValues = cellValue.split(","); String[] cellValues = cellValue.split(",");