|
@@ -8,11 +8,15 @@ import cn.hutool.core.lang.tree.TreeUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.constant.UpmsType;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.dto.SysStatisticDto;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysImplementPlan;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmScorePackage;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmTask;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskType;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysImplementPlanService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmScorePackageService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskTypeService;
|
|
@@ -22,17 +26,15 @@ import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import javax.validation.constraints.NotNull;
|
|
|
-import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
-import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -47,9 +49,11 @@ import java.util.stream.Collectors;
|
|
|
@AllArgsConstructor
|
|
|
public class SysStatisticManager {
|
|
|
|
|
|
+ private final SysDeptService deptService;
|
|
|
private final WmScorePackageService packageService;
|
|
|
private final WmTaskService taskService;
|
|
|
private final WmTaskTypeService taskTypeService;
|
|
|
+ private final SysImplementPlanService implementPlanService;
|
|
|
|
|
|
/**
|
|
|
* 获取积分包统计
|
|
@@ -255,59 +259,83 @@ public class SysStatisticManager {
|
|
|
* @param user 查询人
|
|
|
* @return 统计信息
|
|
|
*/
|
|
|
- public Page<Map<String, Object>> statPlanTree(SysStatisticDto.OnPlanTree query, HnqzUser user) {
|
|
|
+ public Page<?> statPlanTree(SysStatisticDto.OnPlanTree query, HnqzUser user) {
|
|
|
|
|
|
- Map<String, Object> records = new HashMap<>();
|
|
|
- records.put("id", 123);
|
|
|
- records.put("parentId", -1);
|
|
|
- records.put("planName", "测试计划");
|
|
|
- records.put("planScore", 123456);
|
|
|
- records.put("planPeriod", "2024-01-01~2025-01-01");
|
|
|
- records.put("providerName", "测试服务提供方");
|
|
|
- records.put("createTime", LocalDateTime.now());
|
|
|
- records.put("distScore", 12345);
|
|
|
- records.put("distRate", "30%");
|
|
|
- records.put("serCompleteRate", "10%");
|
|
|
+ Page<SysImplementPlan> page = new Page<>(query.getCurrent(), query.getSize());
|
|
|
|
|
|
- Map<String, Object> child1 = new HashMap<>();
|
|
|
- child1.put("id", 1234);
|
|
|
- child1.put("parentId", 123);
|
|
|
- child1.put("planName", "测试计划1");
|
|
|
- child1.put("planScore", 123456);
|
|
|
- child1.put("planPeriod", "2024-01-01~2025-01-01");
|
|
|
- child1.put("providerName", "测试服务提供方1");
|
|
|
- child1.put("createTime", LocalDateTime.now());
|
|
|
- child1.put("distScore", 12345);
|
|
|
- child1.put("distRate", "30%");
|
|
|
- child1.put("serCompleteRate", "10%");
|
|
|
+ // 获取父级分页信息
|
|
|
+ implementPlanService.page(page, Wrappers.<SysImplementPlan>lambdaQuery().eq(SysImplementPlan::getParentId, 0));
|
|
|
|
|
|
+ List<SysImplementPlan> plans = page.getRecords();
|
|
|
|
|
|
- Map<String, Object> child2 = new HashMap<>();
|
|
|
- child2.put("id", 12345);
|
|
|
- child2.put("parentId", 1234);
|
|
|
- child2.put("planName", "测试计划1");
|
|
|
- child2.put("planScore", 123456);
|
|
|
- child2.put("planPeriod", "2024-01-01~2025-01-01");
|
|
|
- child2.put("providerName", "测试服务提供方1");
|
|
|
- child2.put("createTime", LocalDateTime.now());
|
|
|
- child2.put("distScore", 12345);
|
|
|
- child2.put("distRate", "30%");
|
|
|
- child2.put("serCompleteRate", "10%");
|
|
|
- child2.put("children", Collections.emptyList());
|
|
|
+ if (CollUtil.isEmpty(plans)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
|
|
|
- child1.put("children", Collections.singletonList(child2));
|
|
|
+ // 按照类型进行分类
|
|
|
+ Map<UpmsType.ImplementPlanType, List<SysImplementPlan>> collect = plans.stream().collect(Collectors.groupingBy(SysImplementPlan::getPlanType));
|
|
|
|
|
|
+ // 获取季度的信息
|
|
|
+ List<SysImplementPlan> qrtPlanList = collect.get(UpmsType.ImplementPlanType.QRT);
|
|
|
|
|
|
- records.put("children", Collections.singletonList(child1));
|
|
|
+ List<SysImplementPlan> cont = new LinkedList<>(plans);
|
|
|
|
|
|
+ if (CollUtil.isNotEmpty(qrtPlanList)) {
|
|
|
+ while (true) {
|
|
|
|
|
|
- Page<Map<String, Object>> page = new Page<>();
|
|
|
- page.setRecords(Collections.singletonList(records));
|
|
|
- page.setCurrent(1);
|
|
|
- page.setSize(20);
|
|
|
- page.setTotal(1);
|
|
|
+ // 获取子集
|
|
|
+ List<Integer> parentQrtPlanIds = qrtPlanList.stream().mapToInt(SysImplementPlan::getPlanId).boxed().distinct().sorted().collect(Collectors.toList());
|
|
|
|
|
|
- return page;
|
|
|
+ List<SysImplementPlan> subQrtPlans = implementPlanService.list(Wrappers.<SysImplementPlan>lambdaQuery().in(SysImplementPlan::getParentId, parentQrtPlanIds));
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(subQrtPlans)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ cont.addAll(subQrtPlans);
|
|
|
+
|
|
|
+ qrtPlanList = subQrtPlans;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取承接对象信息
|
|
|
+ List<Integer> deptIds = cont.stream().mapToInt(SysImplementPlan::getConsigneeId).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(plan -> {
|
|
|
+ TreeNode<Integer> node = new TreeNode<>();
|
|
|
+ node.setId(plan.getPlanId());
|
|
|
+ node.setParentId(plan.getParentId());
|
|
|
+ node.setName(plan.getPlanName());
|
|
|
+ node.setWeight(plan.getPlanScore());
|
|
|
+
|
|
|
+ Map<String, Object> extra = new HashMap<>(5);
|
|
|
+
|
|
|
+ extra.put("providerName", dId2NameMap.get(plan.getConsigneeId()));
|
|
|
+ extra.put("planScore", plan.getPlanScore());
|
|
|
+ extra.put("planPeriod", String.format("%s 至 %s", formatter.format(plan.getPlanIssue()), formatter.format(plan.getPlanExpiry())));
|
|
|
+ extra.put("createTime", plan.getCreateTime());
|
|
|
+ extra.put("planType", plan.getPlanType());
|
|
|
+
|
|
|
+ node.setExtra(extra);
|
|
|
+
|
|
|
+ return node;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ List<Tree<Integer>> builds = TreeUtil.build(treeNodes, 0);
|
|
|
+
|
|
|
+
|
|
|
+ Page<Tree<Integer>> build = new Page<>();
|
|
|
+ build.setRecords(builds);
|
|
|
+ build.setCurrent(page.getCurrent());
|
|
|
+ build.setSize(page.getSize());
|
|
|
+ build.setTotal(page.getTotal());
|
|
|
+
|
|
|
+ return build;
|
|
|
|
|
|
|
|
|
}
|