修改导入拆分结果支持组织机构重复名称
This commit is contained in:
+90
-5
@@ -2,6 +2,7 @@ package com.jero.modules.split.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -2679,7 +2680,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
// 树形字典
|
||||
List<SysDict> sysDictTreeList = sysDictService.list(new LambdaQueryWrapper<SysDict>().eq(SysDict::getAttributeType, "2"));
|
||||
// 组织结构
|
||||
List<SysDepart> sysDepartList = sysDepartService.list();
|
||||
List<SysDepart> departList = sysDepartService.list();
|
||||
Map<String, List<SysDepart>> departMap = departList.stream().collect(Collectors.groupingBy(SysDepart::getDepartName));
|
||||
Map<String, String> departPartMap = SysDepart.buildPaths(departList);
|
||||
// 适用零部件
|
||||
List<PartName> partNameList = new ArrayList<>();
|
||||
//存放数据验证结果信息
|
||||
@@ -3175,8 +3178,27 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
|
||||
if (StringUtils.isNotBlank(value)){
|
||||
for (String v : value.split(",")) {
|
||||
Optional<SysDepart> first = sysDepartList.stream().filter(o -> v.equals(o.getDepartName())).findFirst();
|
||||
if (!first.isPresent()) {
|
||||
String[] splitValue = v.split("/");
|
||||
List<SysDepart> sysDeparts = departMap.get(splitValue[splitValue.length - 1]);
|
||||
if (sysDeparts != null) {
|
||||
if (sysDeparts.size() == 1) {
|
||||
continue;
|
||||
}
|
||||
if (sysDeparts.size() > 1) {
|
||||
// 叶子节点名称重复,需要寻找全路径
|
||||
String nodeId = departPartMap.get(value);
|
||||
if (StrUtil.isBlank(nodeId)) {
|
||||
if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())) {
|
||||
errorMsg += fieldName + "中组织机构" + v + "不存在;";
|
||||
} else {
|
||||
errorMsg += fieldName + " " + v + "Not exist;";
|
||||
}
|
||||
countError++;
|
||||
valueList = Collections.emptyList();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())) {
|
||||
errorMsg += fieldName + "中组织机构" + v + "不存在;";
|
||||
} else {
|
||||
@@ -3185,9 +3207,23 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
countError++;
|
||||
valueList = Collections.emptyList();
|
||||
break;
|
||||
}else {
|
||||
valueList.add(first.get().getId());
|
||||
}
|
||||
String cellValue = this.convertMultiOrgId(value, departMap, departPartMap);
|
||||
valueList.add(cellValue);
|
||||
|
||||
// Optional<SysDepart> first = sysDepartList.stream().filter(o -> v.equals(o.getDepartName())).findFirst();
|
||||
// if (!first.isPresent()) {
|
||||
// if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())) {
|
||||
// errorMsg += fieldName + "中组织机构" + v + "不存在;";
|
||||
// } else {
|
||||
// errorMsg += fieldName + " " + v + "Not exist;";
|
||||
// }
|
||||
// countError++;
|
||||
// valueList = Collections.emptyList();
|
||||
// break;
|
||||
// }else {
|
||||
// valueList.add(first.get().getId());
|
||||
// }
|
||||
}
|
||||
}
|
||||
}else if (FieldTypeEnum.TREE_BOX.getValue().equals(fieldShowType)) {
|
||||
@@ -3346,6 +3382,55 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
// 组织机构
|
||||
public boolean multiOrgValid(String cellValue, Map<String, List<SysDepart>> sysDepartMap, Map<String, String> sysDepartPathMap) {
|
||||
String[] cellValues = cellValue.split(",");
|
||||
for (String value : cellValues) {
|
||||
String[] splitValue = value.split("/");
|
||||
List<SysDepart> sysDeparts = sysDepartMap.get(splitValue[splitValue.length - 1]);
|
||||
if (sysDeparts != null) {
|
||||
if (sysDeparts.size() == 1) continue;
|
||||
if (sysDeparts.size() > 1) {
|
||||
// 叶子节点名称重复,需要寻找全路径
|
||||
String nodeId = sysDepartPathMap.get(value);
|
||||
if (StrUtil.isBlank(nodeId)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// 多选部门转换
|
||||
public String convertMultiOrgId(String cellValue, Map<String, List<SysDepart>> sysDepartMap, Map<String, String> sysDepartPathMap) {
|
||||
if (StrUtil.isBlank(cellValue)) {
|
||||
return null;
|
||||
}
|
||||
StringBuilder result = new StringBuilder();
|
||||
String[] cellValues = cellValue.split(",");
|
||||
for (String value : cellValues) {
|
||||
String[] splitValue = value.split("/");
|
||||
List<SysDepart> sysDeparts = sysDepartMap.get(splitValue[splitValue.length - 1]);
|
||||
if (sysDeparts != null) {
|
||||
if (sysDeparts.size() == 1) {
|
||||
result.append(sysDeparts.get(0).getId()).append(",");
|
||||
}
|
||||
if (sysDeparts.size() > 1) {
|
||||
// 叶子节点名称重复,需要寻找全路径
|
||||
String nodeId = sysDepartPathMap.get(value);
|
||||
result.append(nodeId).append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 去除掉最后的逗号
|
||||
return result.substring(0, result.length() - 1);
|
||||
}
|
||||
|
||||
private List<PartName> partNameGetLevelPath(List<PartName> partNames) {
|
||||
List<PartName> list = new ArrayList<>();
|
||||
// 一级节点
|
||||
|
||||
Reference in New Issue
Block a user