|
@@ -1,11 +1,9 @@
|
|
|
package org.springblade.manager.service.impl;
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import org.redisson.api.RedissonClient;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.common.utils.SystemUtils;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
@@ -15,6 +13,7 @@ import org.springblade.core.tool.utils.StringUtil;
|
|
|
import org.springblade.manager.entity.*;
|
|
|
import org.springblade.manager.mapper.*;
|
|
|
import org.springblade.manager.service.WbsTreeSynchronousRecordService;
|
|
|
+import org.springblade.manager.vo.WbsNodeTableVO;
|
|
|
import org.springblade.manager.vo.WbsTreeSynchronousRecordVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -202,6 +201,58 @@ public class WbsTreeSynchronousRecordServiceImpl extends ServiceImpl<WbsTreeSync
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<WbsNodeTableVO> getRecommendTable(Long projectId, Long pKeyId) {
|
|
|
+ //查询当前节点是否存在 initTableName
|
|
|
+ WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.selectById(pKeyId);
|
|
|
+ List<WbsNodeTableVO> list = wbsTreePrivateMapper.getRecommendTable(wbsTreePrivate);
|
|
|
+ list.sort((obj1, obj2) -> {
|
|
|
+ String ancestors1 = obj1.getAncestorPId();
|
|
|
+ String ancestors2 = obj2.getAncestorPId();
|
|
|
+ return compareAncestors(ancestors1, ancestors2);
|
|
|
+ });
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ //排序规则
|
|
|
+ private int compareAncestors(String ancestors1, String ancestors2) {
|
|
|
+ if (ancestors1 == null && ancestors2 == null) return 0;
|
|
|
+ if (ancestors1 == null) return -1;
|
|
|
+ if (ancestors2 == null) return 1;
|
|
|
+
|
|
|
+ String[] arr1 = ancestors1.split(",");
|
|
|
+ String[] arr2 = ancestors2.split(",");
|
|
|
+
|
|
|
+ int minLength = Math.min(arr1.length, arr2.length);
|
|
|
+
|
|
|
+ // 比较相同索引的ID
|
|
|
+ for (int i = 0; i < minLength; i++) {
|
|
|
+ String id1 = arr1[i].trim();
|
|
|
+ String id2 = arr2[i].trim();
|
|
|
+
|
|
|
+ if (!id1.equals(id2)) {
|
|
|
+ // 查询数据库获取排序值
|
|
|
+ Integer sort1 = wbsTreePrivateMapper.selectById(id1).getSort();
|
|
|
+ Integer sort2 = wbsTreePrivateMapper.selectById(id2).getSort();
|
|
|
+
|
|
|
+ // 比较排序值
|
|
|
+ if (sort1 != null && sort2 != null) {
|
|
|
+ return Integer.compare(sort1, sort2);
|
|
|
+ } else if (sort1 != null) {
|
|
|
+ return -1;
|
|
|
+ } else if (sort2 != null) {
|
|
|
+ return 1;
|
|
|
+ } else {
|
|
|
+ return id1.compareTo(id2); // 降级方案
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果共同部分都相同,长度短的排在前面(父级在子级前面)
|
|
|
+ return Integer.compare(arr1.length, arr2.length);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public List<WbsTreeSynchronousRecordVo> getProjectTemplate(String nodeIds) {
|
|
|
|
|
@@ -290,6 +341,10 @@ public class WbsTreeSynchronousRecordServiceImpl extends ServiceImpl<WbsTreeSync
|
|
|
.eq(WbsTreeSynchronousRecord::getId, wbsTreeSynchronousRecord.getId()));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|