|
@@ -98,58 +98,76 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean submit(WbsTree dept) {
|
|
|
- if (Func.isEmpty(dept.getParentId())) {
|
|
|
- dept.setTenantId(AuthUtil.getTenantId());
|
|
|
- dept.setParentId(BladeConstant.TOP_PARENT_ID);
|
|
|
- dept.setAncestors(String.valueOf(BladeConstant.TOP_PARENT_ID));
|
|
|
+ public boolean submit(WbsTree wbsTree) {
|
|
|
+ if (Func.isEmpty(wbsTree.getParentId())) {
|
|
|
+ wbsTree.setTenantId(AuthUtil.getTenantId());
|
|
|
+ wbsTree.setParentId(BladeConstant.TOP_PARENT_ID);
|
|
|
+ wbsTree.setAncestors(String.valueOf(BladeConstant.TOP_PARENT_ID));
|
|
|
}
|
|
|
- if (dept.getParentId() > 0) {
|
|
|
- WbsTree parent = getById(dept.getParentId());
|
|
|
- if (Func.toLong(dept.getParentId()) == Func.toLong(dept.getId())) {
|
|
|
+ if (wbsTree.getParentId() > 0) {
|
|
|
+ WbsTree parent = getById(wbsTree.getParentId());
|
|
|
+ if (Func.toLong(wbsTree.getParentId()) == Func.toLong(wbsTree.getId())) {
|
|
|
throw new ServiceException("父节点不可选择自身!");
|
|
|
}
|
|
|
- dept.setTenantId(parent.getTenantId());
|
|
|
- String ancestors = parent.getAncestors() + StringPool.COMMA + dept.getParentId();
|
|
|
- dept.setAncestors(ancestors);
|
|
|
+ wbsTree.setTenantId(parent.getTenantId());
|
|
|
+ String ancestors = parent.getAncestors() + StringPool.COMMA + wbsTree.getParentId();
|
|
|
+ wbsTree.setAncestors(ancestors);
|
|
|
+ }
|
|
|
+ if (wbsTree.getMajorDataType() == null) {
|
|
|
+ wbsTree.setMajorDataType(0);
|
|
|
}
|
|
|
- if (dept.getMajorDataType() == null) {
|
|
|
- dept.setMajorDataType(0);
|
|
|
+ wbsTree.setStatus(1);
|
|
|
+ wbsTree.setIsDeleted(BladeConstant.DB_NOT_DELETED);
|
|
|
+ //新增节点默认排序
|
|
|
+ //获取当前同级节点List
|
|
|
+ if (wbsTree.getId() == null) {
|
|
|
+ List<WbsTree> trees = baseMapper.selectList(Wrappers.<WbsTree>query().lambda()
|
|
|
+ .eq(WbsTree::getParentId, wbsTree.getParentId())
|
|
|
+ .eq(WbsTree::getType, 1)
|
|
|
+ );
|
|
|
+ //判空
|
|
|
+ List<WbsTree> collect = trees.stream().filter(f -> {
|
|
|
+ if (f.getSort() == null) {
|
|
|
+ f.setSort(0);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ //获取最大Sort
|
|
|
+ Integer sortMax = collect.stream().max(Comparator.comparingInt(WbsTree::getSort)).get().getSort();
|
|
|
+ wbsTree.setSort(sortMax + 1);
|
|
|
}
|
|
|
- dept.setStatus(1);
|
|
|
- dept.setIsDeleted(BladeConstant.DB_NOT_DELETED);
|
|
|
- return saveOrUpdate(dept);
|
|
|
+ return saveOrUpdate(wbsTree);
|
|
|
}
|
|
|
|
|
|
- public boolean submit2(FormElementDTO dept) {
|
|
|
- if (Func.isEmpty(dept.getParentId())) {
|
|
|
- dept.setTenantId(AuthUtil.getTenantId());
|
|
|
- dept.setParentId(BladeConstant.TOP_PARENT_ID);
|
|
|
- dept.setAncestors(String.valueOf(BladeConstant.TOP_PARENT_ID));
|
|
|
+ public boolean submit2(FormElementDTO fd) {
|
|
|
+ if (Func.isEmpty(fd.getParentId())) {
|
|
|
+ fd.setTenantId(AuthUtil.getTenantId());
|
|
|
+ fd.setParentId(BladeConstant.TOP_PARENT_ID);
|
|
|
+ fd.setAncestors(String.valueOf(BladeConstant.TOP_PARENT_ID));
|
|
|
}
|
|
|
- if (dept.getParentId() > 0) {
|
|
|
- WbsTree parent = getById(dept.getParentId());
|
|
|
- if (Func.toLong(dept.getParentId()) == Func.toLong(dept.getId())) {
|
|
|
+ if (fd.getParentId() > 0) {
|
|
|
+ WbsTree parent = getById(fd.getParentId());
|
|
|
+ if (Func.toLong(fd.getParentId()) == Func.toLong(fd.getId())) {
|
|
|
throw new ServiceException("父节点不可选择自身!");
|
|
|
}
|
|
|
- dept.setTenantId(parent.getTenantId());
|
|
|
- String ancestors = parent.getAncestors() + StringPool.COMMA + dept.getParentId();
|
|
|
- dept.setAncestors(ancestors);
|
|
|
+ fd.setTenantId(parent.getTenantId());
|
|
|
+ String ancestors = parent.getAncestors() + StringPool.COMMA + fd.getParentId();
|
|
|
+ fd.setAncestors(ancestors);
|
|
|
//设置表示该父节点下存在表单
|
|
|
baseMapper.updateIsExistFormById(parent.getId());
|
|
|
}
|
|
|
//设置类型默认值为 '2' 表单
|
|
|
- dept.setType(2);
|
|
|
- dept.setIsDeleted(BladeConstant.DB_NOT_DELETED);
|
|
|
- return saveOrUpdate(dept);
|
|
|
+ fd.setType(2);
|
|
|
+ fd.setIsDeleted(BladeConstant.DB_NOT_DELETED);
|
|
|
+ return saveOrUpdate(fd);
|
|
|
}
|
|
|
|
|
|
- public boolean submit3(WbsTree dept) {
|
|
|
- if (dept.getParentId() > 0) {
|
|
|
+ public boolean submit3(WbsTree wbsTree) {
|
|
|
+ if (wbsTree.getParentId() > 0) {
|
|
|
//设置表示该父节点下存在表单
|
|
|
- baseMapper.updateIsExistFormById(dept.getParentId());
|
|
|
+ baseMapper.updateIsExistFormById(wbsTree.getParentId());
|
|
|
}
|
|
|
- return save(dept);
|
|
|
+ return save(wbsTree);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -234,6 +252,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
IOException | ClassNotFoundException e) {
|
|
|
throw new ServiceException("操作失败,请上传正确模板内容");
|
|
|
} finally {
|
|
|
+ assert canonicalPath != null;
|
|
|
File file2 = new File(canonicalPath);
|
|
|
if (file2.isFile() && file2.exists()) {
|
|
|
file2.delete();
|
|
@@ -519,10 +538,8 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<SaveUserInfoByProjectVO2> findProjectAndContractList(Long userId) {
|
|
|
+ public List<Map> findProjectAndContractList(Long userId) {
|
|
|
List<SaveUserInfoByProjectVO2> list = baseMapper.selectListByUserId(userId);
|
|
|
-
|
|
|
- //TODO 合并projectName返回
|
|
|
Map<String, List<SaveUserInfoByProjectVO2>> collect = list.stream().collect(Collectors.groupingBy(SaveUserInfoByProjectVO2::getProjectName));
|
|
|
List<Map> collect1 = collect.entrySet().stream().map(entity -> {
|
|
|
Map resultMap = new HashMap();
|
|
@@ -530,9 +547,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
resultMap.put("dataInfo", entity.getValue());
|
|
|
return resultMap;
|
|
|
}).collect(Collectors.toList());
|
|
|
-
|
|
|
-
|
|
|
- return list;
|
|
|
+ return collect1;
|
|
|
}
|
|
|
|
|
|
@Override
|