|
@@ -347,53 +347,74 @@ public class SysStatisticManager {
|
|
|
* @param user 操作人
|
|
|
* @return 统计信息
|
|
|
*/
|
|
|
- public Page<Map<String, Object>> statPkgTree(SysStatisticDto.OnPkgTree query, HnqzUser user) {
|
|
|
+ public Page<?> statPkgTree(SysStatisticDto.OnPkgTree query, HnqzUser user) {
|
|
|
|
|
|
- Map<String, Object> records = new HashMap<>();
|
|
|
- records.put("id", 123);
|
|
|
- records.put("parentId", -1);
|
|
|
- records.put("pkgName", "测试计划");
|
|
|
- records.put("pkgScore", 123456);
|
|
|
- records.put("pickerName", "测试服务提供方1");
|
|
|
- records.put("createTime", LocalDateTime.now());
|
|
|
- records.put("completeScore", 12345);
|
|
|
- records.put("completeRate", "30%");
|
|
|
|
|
|
- Map<String, Object> child1 = new HashMap<>();
|
|
|
- child1.put("id", 1234);
|
|
|
- child1.put("parentId", 123);
|
|
|
- child1.put("pkgName", "测试计划");
|
|
|
- child1.put("pkgScore", 123456);
|
|
|
- child1.put("pickerName", "测试服务提供方1");
|
|
|
- child1.put("createTime", LocalDateTime.now());
|
|
|
- child1.put("completeScore", 12345);
|
|
|
- child1.put("completeRate", "30%");
|
|
|
+ // 获取所有父级执行包
|
|
|
+ Page<WmScorePackage> page = new Page<>(query.getCurrent(), query.getSize());
|
|
|
|
|
|
+ packageService.page(page, Wrappers.<WmScorePackage>lambdaQuery().eq(WmScorePackage::getRelationScoreId, ""));
|
|
|
|
|
|
- Map<String, Object> child2 = new HashMap<>();
|
|
|
- child2.put("id", 1234);
|
|
|
- child2.put("parentId", 123);
|
|
|
- child2.put("pkgName", "测试计划");
|
|
|
- child2.put("pkgScore", 123456);
|
|
|
- child2.put("pickerName", "测试服务提供方1");
|
|
|
- child2.put("createTime", LocalDateTime.now());
|
|
|
- child2.put("completeScore", 12345);
|
|
|
- child2.put("completeRate", "30%");
|
|
|
- child2.put("children", Collections.emptyList());
|
|
|
+ List<WmScorePackage> pkgs = page.getRecords();
|
|
|
|
|
|
- child1.put("children", Collections.singletonList(child2));
|
|
|
+ if (CollUtil.isEmpty(pkgs)){
|
|
|
+ return page;
|
|
|
+ }
|
|
|
|
|
|
+ List<WmScorePackage> cont = new LinkedList<>(pkgs);
|
|
|
+ if (CollUtil.isNotEmpty(pkgs)) {
|
|
|
+ while (true) {
|
|
|
|
|
|
- records.put("children", Collections.singletonList(child1));
|
|
|
+ // 获取子集
|
|
|
+ List<String> parentPkgIds = pkgs.stream().map(WmScorePackage::getId).distinct().sorted().collect(Collectors.toList());
|
|
|
|
|
|
+ List<WmScorePackage> subPkgs = packageService.list(Wrappers.<WmScorePackage>lambdaQuery().in(WmScorePackage::getRelationScoreId, parentPkgIds));
|
|
|
|
|
|
- Page<Map<String, Object>> page = new Page<>();
|
|
|
- page.setRecords(Collections.singletonList(records));
|
|
|
- page.setCurrent(1);
|
|
|
- page.setSize(20);
|
|
|
- page.setTotal(1);
|
|
|
+ if (CollUtil.isEmpty(subPkgs)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- return page;
|
|
|
+ cont.addAll(subPkgs);
|
|
|
+
|
|
|
+ pkgs = subPkgs;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取承接对象信息
|
|
|
+ List<Integer> deptIds = cont.stream().mapToInt(p -> Integer.parseInt(p.getDeptId())).distinct().boxed().sorted().collect(Collectors.toList());
|
|
|
+ Map<Integer, String> dId2NameMap = deptService.list(Wrappers.<SysDept>lambdaQuery().in(SysDept::getDeptId, deptIds)).stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getName));
|
|
|
+
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
|
|
+ List<TreeNode<Integer>> treeNodes = cont.stream().map(pkg -> {
|
|
|
+ TreeNode<Integer> node = new TreeNode<>();
|
|
|
+ node.setId(Integer.parseInt(pkg.getId()));
|
|
|
+ node.setParentId(StrUtil.isBlank(pkg.getRelationScoreId()) ? 0 : Integer.parseInt(pkg.getRelationScoreId()));
|
|
|
+ node.setName(pkg.getScorePackageName());
|
|
|
+ node.setWeight(pkg.getScore());
|
|
|
+
|
|
|
+ Map<String, Object> extra = new HashMap<>(5);
|
|
|
+
|
|
|
+ extra.put("pkgScore", pkg.getScore());
|
|
|
+ extra.put("availScore", pkg.getKfpjf());
|
|
|
+ extra.put("pickerName", dId2NameMap.get(Integer.valueOf(pkg.getDeptId())) == null ? "" : dId2NameMap.get(Integer.valueOf(pkg.getDeptId())));
|
|
|
+ extra.put("pkgPeriod", String.format("%s 至 %s", formatter.format(pkg.getStartTime()), formatter.format(pkg.getEndTime())));
|
|
|
+ extra.put("createTime", pkg.getCreateTime());
|
|
|
+
|
|
|
+ node.setExtra(extra);
|
|
|
+
|
|
|
+ return node;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ List<Tree<Integer>> builds = TreeUtil.build(treeNodes, 0);
|
|
|
+
|
|
|
+ Page<Tree<Integer>> page1 = new Page<>();
|
|
|
+ page1.setRecords(builds);
|
|
|
+ page1.setCurrent(page.getCurrent());
|
|
|
+ page1.setSize(page.getSize());
|
|
|
+ page1.setTotal(page.getTotal());
|
|
|
+
|
|
|
+ return page1;
|
|
|
}
|
|
|
|
|
|
/**
|