|
@@ -384,31 +384,28 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|
// 父机构id
|
|
// 父机构id
|
|
Long schoolId = sysUser.getSchoolId();
|
|
Long schoolId = sysUser.getSchoolId();
|
|
SysOrg sysOrg = this.findRootOrg(schoolId);
|
|
SysOrg sysOrg = this.findRootOrg(schoolId);
|
|
- Long parentId = sysOrg.getId();
|
|
|
|
|
|
+ Long rootParentId = sysOrg.getId();
|
|
Map<String, Long> map = new HashMap<>();
|
|
Map<String, Long> map = new HashMap<>();
|
|
for (String orgInfo : orgInfoList) {
|
|
for (String orgInfo : orgInfoList) {
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ Long parentId = rootParentId;
|
|
String[] arr = orgInfo.split(SystemConstant.ORG_SPLIT);
|
|
String[] arr = orgInfo.split(SystemConstant.ORG_SPLIT);
|
|
for (int i = 0; i < arr.length; i++) {
|
|
for (int i = 0; i < arr.length; i++) {
|
|
SysOrg targetOrg;
|
|
SysOrg targetOrg;
|
|
- String orgDetailName = "";
|
|
|
|
|
|
+ StringBuilder orgDetailName = new StringBuilder();
|
|
String orgName = arr[i];
|
|
String orgName = arr[i];
|
|
|
|
|
|
// 拼机构元素详细名称
|
|
// 拼机构元素详细名称
|
|
for (int j = 0; j <= i; j++) {
|
|
for (int j = 0; j <= i; j++) {
|
|
- orgDetailName = orgDetailName + arr[j] + SystemConstant.ORG_SPLIT;
|
|
|
|
|
|
+ orgDetailName.append(arr[j]).append(SystemConstant.ORG_SPLIT);
|
|
}
|
|
}
|
|
if (orgDetailName.length() > 0) {
|
|
if (orgDetailName.length() > 0) {
|
|
- orgDetailName = orgDetailName.substring(0, orgDetailName.length() - SystemConstant.ORG_SPLIT.length());
|
|
|
|
|
|
+ orgDetailName = new StringBuilder(
|
|
|
|
+ orgDetailName.substring(0, orgDetailName.length() - SystemConstant.ORG_SPLIT.length()));
|
|
}
|
|
}
|
|
- if (!map.containsKey(orgDetailName)) {
|
|
|
|
|
|
+ if (!map.containsKey(orgDetailName.toString())) {
|
|
// 在map中没有找到,就去数据库查找
|
|
// 在map中没有找到,就去数据库查找
|
|
- targetOrg = this.getOne(new QueryWrapper<SysOrg>()
|
|
|
|
- .lambda()
|
|
|
|
- .eq(SysOrg::getSchoolId, schoolId)
|
|
|
|
- .eq(SysOrg::getName, orgName)
|
|
|
|
- .eq(SysOrg::getParentId, parentId));
|
|
|
|
|
|
+ targetOrg = this.getOne(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getSchoolId, schoolId)
|
|
|
|
+ .eq(SysOrg::getName, orgName).eq(SysOrg::getParentId, parentId));
|
|
|
|
|
|
// 如果在数据库中也没有找到这个机构元素,则新建当前机构元素并保存在数据库
|
|
// 如果在数据库中也没有找到这个机构元素,则新建当前机构元素并保存在数据库
|
|
if (Objects.isNull(targetOrg)) {
|
|
if (Objects.isNull(targetOrg)) {
|
|
@@ -416,12 +413,12 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|
}
|
|
}
|
|
|
|
|
|
// 不管是已有的还是新建的机构,都保存在map中方便后面查询 格式:(k -> 化学学院/核化学/聚变化学 v -> 11111111111)
|
|
// 不管是已有的还是新建的机构,都保存在map中方便后面查询 格式:(k -> 化学学院/核化学/聚变化学 v -> 11111111111)
|
|
- map.put(orgDetailName, targetOrg.getId());
|
|
|
|
|
|
+ map.put(orgDetailName.toString(), targetOrg.getId());
|
|
// 更新parentId为该机构元素的id,并作为数组下一个节点的父机构id
|
|
// 更新parentId为该机构元素的id,并作为数组下一个节点的父机构id
|
|
parentId = targetOrg.getId();
|
|
parentId = targetOrg.getId();
|
|
} else {
|
|
} else {
|
|
// 如果map中本身就有该机构元素,则直接获取该机构元素id作为 数组下一个节点的父机构id
|
|
// 如果map中本身就有该机构元素,则直接获取该机构元素id作为 数组下一个节点的父机构id
|
|
- parentId = map.get(orgDetailName);
|
|
|
|
|
|
+ parentId = map.get(orgDetailName.toString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|