|
@@ -90,9 +90,10 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
|
|
|
archiveTree.setTenantId(AuthUtil.getTenantId());
|
|
|
archiveTree.setParentId(0L);
|
|
|
archiveTree.setAncestors(String.valueOf(0));
|
|
|
- archiveTree.setNodeName("系统级归档树");
|
|
|
- archiveTree.setFullName("系统级归档树");
|
|
|
+ archiveTree.setNodeName("系统级归档模板");
|
|
|
+ archiveTree.setFullName("系统级归档模板");
|
|
|
archiveTree.setIsStorageNode(0);
|
|
|
+ archiveTree.setSort(0);
|
|
|
if (AuthUtil.getUserId() != null && AuthUtil.getDeptId() != null) {
|
|
|
archiveTree.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
archiveTree.setCreateUser(AuthUtil.getUserId());
|
|
@@ -115,8 +116,12 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<ArchiveTree> selectByParentId(String id) {
|
|
|
- return baseMapper.selectList(Wrappers.<ArchiveTree>query().lambda().eq(ArchiveTree::getParentId, id));
|
|
|
+ public List<ArchiveTree> selectByParentIdOrId(String id) {
|
|
|
+ return baseMapper.selectList(Wrappers.<ArchiveTree>query().lambda()
|
|
|
+ .eq(ArchiveTree::getParentId, id)
|
|
|
+ .or()
|
|
|
+ .eq(ArchiveTree::getId, id)
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -178,7 +183,31 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
|
|
|
//如果是电子原生文件,那么默认是存储节点
|
|
|
archiveTreeDTO.setIsStorageNode(1);
|
|
|
}
|
|
|
+
|
|
|
+ //新增节点默认排序
|
|
|
+ //获取当前同级节点List
|
|
|
+ if (archiveTreeDTO.getId() == null) {
|
|
|
+ List<ArchiveTree> trees = baseMapper.selectList(Wrappers.<ArchiveTree>query().lambda()
|
|
|
+ .eq(ArchiveTree::getParentId, archiveTreeDTO.getParentId())
|
|
|
+ );
|
|
|
+ //判空
|
|
|
+ List<ArchiveTree> collect = trees.stream().filter(f -> {
|
|
|
+ if (f.getSort() == null) {
|
|
|
+ f.setSort(0);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ //获取最大Sort
|
|
|
+ Optional<ArchiveTree> max = collect.stream().max(Comparator.comparingInt(ArchiveTree::getSort));
|
|
|
+ Integer sort = 0;
|
|
|
+ if (max.isPresent()) {
|
|
|
+ sort = max.get().getSort();
|
|
|
+ }
|
|
|
+ archiveTreeDTO.setSort(sort + 1);
|
|
|
+ }
|
|
|
+
|
|
|
return save(archiveTreeDTO);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|