|
@@ -13,10 +13,12 @@ import com.qunzhixinxi.hnqz.admin.api.dto.SysStatisticDto;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.ReDeptDrug;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.ReDeptDrug;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysImplementPlan;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysImplementPlan;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.SysUser;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmAgentEvaluation;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmAgentEvaluation;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmDaDrugEntDrugtable;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmDaDrugEntDrugtable;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmQccInfo;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmQccInfo;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmScorePackage;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmScorePackage;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.WmScorePackageStatus;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmTask;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmTask;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskSupervision;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskSupervision;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskType;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskType;
|
|
@@ -24,10 +26,12 @@ import com.qunzhixinxi.hnqz.admin.service.ReDeptDrugService;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysEnterpriseAreaService;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysEnterpriseAreaService;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysImplementPlanService;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysImplementPlanService;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysUserService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmAgentEvaluationService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmAgentEvaluationService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmDaDrugEntDrugtableService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmDaDrugEntDrugtableService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmQccInfoService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmQccInfoService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmScorePackageService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmScorePackageService;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmScorePackageStatusService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskSupervisionService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskSupervisionService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskTypeService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskTypeService;
|
|
@@ -60,6 +64,7 @@ import java.util.stream.Collectors;
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
public class SysStatisticManager {
|
|
public class SysStatisticManager {
|
|
|
|
|
|
|
|
+ private final SysUserService sysUserService;
|
|
private final SysDeptService deptService;
|
|
private final SysDeptService deptService;
|
|
private final WmScorePackageService packageService;
|
|
private final WmScorePackageService packageService;
|
|
private final WmTaskService taskService;
|
|
private final WmTaskService taskService;
|
|
@@ -71,6 +76,7 @@ public class SysStatisticManager {
|
|
private final ReDeptDrugService deptDrugService;
|
|
private final ReDeptDrugService deptDrugService;
|
|
private final WmDaDrugEntDrugtableService drugTableService;
|
|
private final WmDaDrugEntDrugtableService drugTableService;
|
|
private final WmAgentEvaluationService agentEvaluationService;
|
|
private final WmAgentEvaluationService agentEvaluationService;
|
|
|
|
+ private final WmScorePackageStatusService scorePackageStatusService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取积分包统计
|
|
* 获取积分包统计
|
|
@@ -486,7 +492,7 @@ public class SysStatisticManager {
|
|
|
|
|
|
// 封装参数
|
|
// 封装参数
|
|
List<Map<String, Object>> collect = depts.stream().map(d -> {
|
|
List<Map<String, Object>> collect = depts.stream().map(d -> {
|
|
- Map<String, Object> map = new HashMap<>(7);
|
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>(6);
|
|
|
|
|
|
map.put("id", d.getDeptId());
|
|
map.put("id", d.getDeptId());
|
|
map.put("providerName", d.getName());
|
|
map.put("providerName", d.getName());
|
|
@@ -514,7 +520,7 @@ public class SysStatisticManager {
|
|
|
|
|
|
|
|
|
|
map.put("serviceMark", CollUtil.isNotEmpty(agentEvaluations) ? agentEvaluations.get(0) : null);
|
|
map.put("serviceMark", CollUtil.isNotEmpty(agentEvaluations) ? agentEvaluations.get(0) : null);
|
|
- map.put("average", 123);
|
|
|
|
|
|
+ // map.put("average", 123);
|
|
|
|
|
|
return map;
|
|
return map;
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
@@ -535,61 +541,116 @@ public class SysStatisticManager {
|
|
* @param user 操作人
|
|
* @param user 操作人
|
|
* @return 统计信息
|
|
* @return 统计信息
|
|
*/
|
|
*/
|
|
- public Page<Map<String, Object>> statProviderDataTree(SysStatisticDto.OnProviderTree 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%");
|
|
|
|
- records.put("taskPassedPercentage", "30%");
|
|
|
|
- records.put("taskPassedScore", 234);
|
|
|
|
- records.put("taskPassRate", "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%");
|
|
|
|
- child1.put("taskPassedPercentage", "30%");
|
|
|
|
- child1.put("taskPassedScore", 234);
|
|
|
|
- child1.put("taskPassRate", "30%");
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- Map<String, Object> child2 = new HashMap<>();
|
|
|
|
- child2.put("id", 12345);
|
|
|
|
- child2.put("parentId", 12345);
|
|
|
|
- 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("taskPassedPercentage", "30%");
|
|
|
|
- child2.put("taskPassedScore", 234);
|
|
|
|
- child2.put("taskPassRate", "30%");
|
|
|
|
- child2.put("children", Collections.emptyList());
|
|
|
|
-
|
|
|
|
- child1.put("children", Collections.singletonList(child2));
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- records.put("children", Collections.singletonList(child1));
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- Page<Map<String, Object>> page = new Page<>();
|
|
|
|
- page.setRecords(Collections.singletonList(records));
|
|
|
|
- page.setCurrent(1);
|
|
|
|
- page.setSize(20);
|
|
|
|
- page.setTotal(1);
|
|
|
|
-
|
|
|
|
- return page;
|
|
|
|
|
|
+ public Page<?> statProviderDataTree(SysStatisticDto.OnProviderTree query, HnqzUser user) {
|
|
|
|
+
|
|
|
|
+ // 获取服务商分页
|
|
|
|
+ Page<SysDept> page = new Page<>(query.getCurrent(), query.getSize());
|
|
|
|
+ deptService.page(page, Wrappers.<SysDept>lambdaQuery().eq(SysDept::getLevel, 4).eq(SysDept::getDelFlag, CommonConstants.STATUS_NORMAL));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<SysDept> depts = page.getRecords();
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isEmpty(depts)) {
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 获取企业ID
|
|
|
|
+ List<Integer> deptIds = depts.stream().mapToInt(SysDept::getDeptId).boxed().distinct().sorted().collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ // 获取员工
|
|
|
|
+ List<SysUser> users = sysUserService.list(Wrappers.<SysUser>lambdaQuery().in(SysUser::getDeptId, deptIds)
|
|
|
|
+ .eq(SysUser::getLockFlag, CommonConstants.STATUS_NORMAL)
|
|
|
|
+ .eq(SysUser::getDelFlag, CommonConstants.STATUS_NORMAL));
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isEmpty(users)) {
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<String> userIds = users.stream().map(u -> u.getUserId().toString()).distinct().sorted().collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Map<Integer, List<SysUser>> userCollect = users.stream().collect(Collectors.groupingBy(SysUser::getDeptId));
|
|
|
|
+
|
|
|
|
+ // 获取员工的包记录
|
|
|
|
+ Map<String, List<WmScorePackageStatus>> userId2PkgMap = scorePackageStatusService.list(Wrappers.<WmScorePackageStatus>lambdaQuery().in(WmScorePackageStatus::getUserId, userIds))
|
|
|
|
+ .stream().collect(Collectors.groupingBy(WmScorePackageStatus::getUserId));
|
|
|
|
+
|
|
|
|
+ // 获取员工的任务数
|
|
|
|
+ Map<String, List<WmTask>> userId2TaskMap = taskService.list(Wrappers.<WmTask>lambdaQuery().in(WmTask::getTaskUserId, userIds)).stream().collect(Collectors.groupingBy(WmTask::getTaskUserId));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<Map<String, Object>> buildMap = new ArrayList<>(depts.size());
|
|
|
|
+
|
|
|
|
+ for (SysDept dept : depts) {
|
|
|
|
+ Map<String, Object> map = new HashMap<>(7);
|
|
|
|
+ map.put("id", dept.getDeptId());
|
|
|
|
+ map.put("name", dept.getName());
|
|
|
|
+
|
|
|
|
+ List<SysUser> userList = userCollect.get(dept.getDeptId());
|
|
|
|
+ List<Map<String, Object>> userMap;
|
|
|
|
+ int deptPkgCount = 0;
|
|
|
|
+ long deptPkgScoreTotal = 0L;
|
|
|
|
+ int deptTaskCount = 0;
|
|
|
|
+ long deptTaskScoreTotal = 0L;
|
|
|
|
+ if (CollUtil.isNotEmpty(userList)) {
|
|
|
|
+
|
|
|
|
+ userMap = new ArrayList<>(userList.size());
|
|
|
|
+ for (SysUser u : userList) {
|
|
|
|
+ String uId = u.getUserId().toString();
|
|
|
|
+ Map<String, Object> uMap = new HashMap<>(7);
|
|
|
|
+ uMap.put("userId", u.getUserId());
|
|
|
|
+ uMap.put("userName", u.getRealname());
|
|
|
|
+ uMap.put("phone", u.getUsername());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ int userPkgCount = 0;
|
|
|
|
+ long userPkgScoreTotal = 0L;
|
|
|
|
+ List<WmScorePackageStatus> wmScorePackageStatuses = userId2PkgMap.get(uId);
|
|
|
|
+ if (CollUtil.isNotEmpty(wmScorePackageStatuses)) {
|
|
|
|
+ userPkgCount = wmScorePackageStatuses.size();
|
|
|
|
+ userPkgScoreTotal = wmScorePackageStatuses.stream().mapToLong(s -> Long.parseLong(s.getUserScore())).sum();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ uMap.put("userPkgCount", userPkgCount);
|
|
|
|
+ uMap.put("userPkgScoreTotal", userPkgScoreTotal);
|
|
|
|
+ deptPkgCount += userPkgCount;
|
|
|
|
+ deptPkgScoreTotal += userPkgScoreTotal;
|
|
|
|
+
|
|
|
|
+ int taskPkgCount = 0;
|
|
|
|
+ long taskScoreTotal = 0L;
|
|
|
|
+ List<WmTask> tasks = userId2TaskMap.get(uId);
|
|
|
|
+ if (CollUtil.isNotEmpty(tasks)) {
|
|
|
|
+ taskPkgCount = tasks.size();
|
|
|
|
+ taskScoreTotal = tasks.stream().mapToLong(WmTask::getScore).sum();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ uMap.put("userTaskCount", taskPkgCount);
|
|
|
|
+ uMap.put("taskScoreTotal", taskScoreTotal);
|
|
|
|
+ deptTaskCount += taskPkgCount;
|
|
|
|
+ deptTaskScoreTotal += taskScoreTotal;
|
|
|
|
+ userMap.add(uMap);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ userMap = Collections.emptyList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ map.put("userList", userMap);
|
|
|
|
+ map.put("deptPkgCount", deptPkgCount);
|
|
|
|
+ map.put("deptPkgScoreTotal", deptPkgScoreTotal);
|
|
|
|
+ map.put("deptTaskCount", deptTaskCount);
|
|
|
|
+ map.put("deptTaskScoreTotal", deptTaskScoreTotal);
|
|
|
|
+ buildMap.add(map);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Page<Map<String, Object>> builds = new Page<>(query.getCurrent(), query.getSize());
|
|
|
|
+ builds.setRecords(buildMap);
|
|
|
|
+ builds.setTotal(page.getTotal());
|
|
|
|
+
|
|
|
|
+ return builds;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|