|
@@ -5,12 +5,14 @@ import cn.hutool.core.lang.tree.Tree;
|
|
|
import cn.hutool.core.lang.tree.TreeNode;
|
|
|
import cn.hutool.core.lang.tree.TreeUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.UpmsState;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.UpmsType;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.dto.SysStatisticDto;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.ReDeptDrug;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.SysAreaEntity;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysImplementPlan;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysUser;
|
|
@@ -23,9 +25,11 @@ import com.qunzhixinxi.hnqz.admin.api.entity.WmTask;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskSupervision;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskType;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.ReDeptDrugService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysAreaEntityService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysEnterpriseAreaService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysImplementPlanService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysUserAreaService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysUserService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmAgentEvaluationService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmDaDrugEntDrugtableService;
|
|
@@ -37,11 +41,11 @@ import com.qunzhixinxi.hnqz.admin.service.WmTaskSupervisionService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskTypeService;
|
|
|
import com.qunzhixinxi.hnqz.common.core.constant.CommonConstants;
|
|
|
import com.qunzhixinxi.hnqz.common.security.service.HnqzUser;
|
|
|
+import com.qunzhixinxi.hnqz.common.security.util.SecurityUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
@@ -70,6 +74,8 @@ public class SysStatisticManager {
|
|
|
private final WmTaskService taskService;
|
|
|
private final WmTaskTypeService taskTypeService;
|
|
|
private final WmTaskSupervisionService taskSupervisionService;
|
|
|
+ private final SysAreaEntityService areaEntityService;
|
|
|
+ private final SysUserAreaService userAreaService;
|
|
|
private final SysEnterpriseAreaService enterpriseAreaService;
|
|
|
private final SysImplementPlanService implementPlanService;
|
|
|
private final WmQccInfoService qccInfoService;
|
|
@@ -284,10 +290,49 @@ public class SysStatisticManager {
|
|
|
*/
|
|
|
public Page<?> statPlanTree(SysStatisticDto.OnPlanTree query, HnqzUser user) {
|
|
|
|
|
|
+
|
|
|
Page<SysImplementPlan> page = new Page<>(query.getCurrent(), query.getSize());
|
|
|
|
|
|
+ // 获取当前操作人的角色
|
|
|
+ List<Integer> roles = SecurityUtils.getRoles();
|
|
|
+
|
|
|
+ LambdaQueryWrapper<SysImplementPlan> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+
|
|
|
+ boolean rootFlag = false;
|
|
|
+
|
|
|
+ // 服务商
|
|
|
+ if (roles.contains(37)) {
|
|
|
+ queryWrapper.eq(SysImplementPlan::getConsigneeId, user.getDeptId());
|
|
|
+ }
|
|
|
+ // 区域管理员 || 地市经理
|
|
|
+ else if (CollUtil.containsAny(roles, List.of(4, 43))) {
|
|
|
+ queryWrapper.eq(SysImplementPlan::getConsignorId, user.getDeptId());
|
|
|
+
|
|
|
+ List<Integer> entIds = getEntIds(user);
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(entIds)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ queryWrapper.in(SysImplementPlan::getConsigneeId, entIds);
|
|
|
+
|
|
|
+ }
|
|
|
+ // 其他
|
|
|
+ else {
|
|
|
+ rootFlag = true;
|
|
|
+ queryWrapper.eq(SysImplementPlan::getParentId, 0);
|
|
|
+ List<Integer> entIds = getEntIds(user);
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(entIds)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ queryWrapper.in(SysImplementPlan::getConsigneeId, entIds);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// 获取父级分页信息
|
|
|
- implementPlanService.page(page, Wrappers.<SysImplementPlan>lambdaQuery().eq(SysImplementPlan::getParentId, 0));
|
|
|
+ implementPlanService.page(page, queryWrapper);
|
|
|
|
|
|
List<SysImplementPlan> plans = page.getRecords();
|
|
|
|
|
@@ -348,12 +393,22 @@ public class SysStatisticManager {
|
|
|
return node;
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
+ List<Tree<Integer>> temps = new ArrayList<>();
|
|
|
|
|
|
- List<Tree<Integer>> builds = TreeUtil.build(treeNodes, 0);
|
|
|
+ if (rootFlag) {
|
|
|
+ List<Tree<Integer>> builds = TreeUtil.build(treeNodes, 0);
|
|
|
+ temps.addAll(builds);
|
|
|
+ } else {
|
|
|
|
|
|
+ for (TreeNode<Integer> node : treeNodes) {
|
|
|
+ List<Tree<Integer>> build = TreeUtil.build(Collections.singletonList(node), node.getParentId());
|
|
|
+ temps.addAll(build);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
Page<Tree<Integer>> build = new Page<>();
|
|
|
- build.setRecords(builds);
|
|
|
+ build.setRecords(temps);
|
|
|
build.setCurrent(page.getCurrent());
|
|
|
build.setSize(page.getSize());
|
|
|
build.setTotal(page.getTotal());
|
|
@@ -372,11 +427,50 @@ public class SysStatisticManager {
|
|
|
*/
|
|
|
public Page<?> statPkgTree(SysStatisticDto.OnPkgTree query, HnqzUser user) {
|
|
|
|
|
|
-
|
|
|
// 获取所有父级执行包
|
|
|
Page<WmScorePackage> page = new Page<>(query.getCurrent(), query.getSize());
|
|
|
|
|
|
- packageService.page(page, Wrappers.<WmScorePackage>lambdaQuery().eq(WmScorePackage::getRelationScoreId, ""));
|
|
|
+ // 获取当前操作人的角色
|
|
|
+ List<Integer> roles = SecurityUtils.getRoles();
|
|
|
+
|
|
|
+ LambdaQueryWrapper<WmScorePackage> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+
|
|
|
+ boolean rootFlag = false;
|
|
|
+
|
|
|
+ // 服务商
|
|
|
+ if (roles.contains(37)) {
|
|
|
+ queryWrapper.eq(WmScorePackage::getDeptId, user.getDeptId());
|
|
|
+ }
|
|
|
+ // 区域管理员 || 地市经理
|
|
|
+ else if (CollUtil.containsAny(roles, List.of(4, 43))) {
|
|
|
+ queryWrapper.eq(WmScorePackage::getSendPackageDeptId, user.getDeptId());
|
|
|
+
|
|
|
+ List<Integer> entIds = getEntIds(user);
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(entIds)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ queryWrapper.in(WmScorePackage::getDeptId, entIds);
|
|
|
+ }
|
|
|
+ // 其他
|
|
|
+ else {
|
|
|
+ rootFlag = true;
|
|
|
+ queryWrapper.eq(WmScorePackage::getRelationScoreId, "");
|
|
|
+
|
|
|
+ List<Integer> entIds = getEntIds(user);
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(entIds)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ queryWrapper.in(WmScorePackage::getDeptId, entIds);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ packageService.page(page, queryWrapper);
|
|
|
|
|
|
List<WmScorePackage> pkgs = page.getRecords();
|
|
|
|
|
@@ -429,10 +523,22 @@ public class SysStatisticManager {
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
- List<Tree<Integer>> builds = TreeUtil.build(treeNodes, 0);
|
|
|
+ List<Tree<Integer>> temps = new ArrayList<>();
|
|
|
+
|
|
|
+ if (rootFlag) {
|
|
|
+ List<Tree<Integer>> builds = TreeUtil.build(treeNodes, 0);
|
|
|
+ temps.addAll(builds);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ for (TreeNode<Integer> node : treeNodes) {
|
|
|
+ List<Tree<Integer>> build = TreeUtil.build(Collections.singletonList(node), node.getParentId());
|
|
|
+ temps.addAll(build);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
Page<Tree<Integer>> page1 = new Page<>();
|
|
|
- page1.setRecords(builds);
|
|
|
+ page1.setRecords(temps);
|
|
|
page1.setCurrent(page.getCurrent());
|
|
|
page1.setSize(page.getSize());
|
|
|
page1.setTotal(page.getTotal());
|
|
@@ -451,7 +557,39 @@ public class SysStatisticManager {
|
|
|
|
|
|
// 获取服务商分页
|
|
|
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<Integer> roles = SecurityUtils.getRoles();
|
|
|
+
|
|
|
+ LambdaQueryWrapper<SysDept> queryWrapper = Wrappers.<SysDept>lambdaQuery().eq(SysDept::getLevel, 4).eq(SysDept::getDelFlag, CommonConstants.STATUS_NORMAL);
|
|
|
+
|
|
|
+
|
|
|
+ // 服务商
|
|
|
+ if (roles.contains(37)) {
|
|
|
+ queryWrapper.eq(SysDept::getDeptId, user.getDeptId());
|
|
|
+ }
|
|
|
+ // 区域管理员 || 地市经理
|
|
|
+ else if (CollUtil.containsAny(roles, List.of(4, 43))) {
|
|
|
+
|
|
|
+ List<Integer> entIds = getEntIds(user);
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(entIds)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+ queryWrapper.in(SysDept::getDeptId, entIds);
|
|
|
+ }
|
|
|
+ // 其他
|
|
|
+ else {
|
|
|
+ List<Integer> entIds = getEntIds(user);
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(entIds)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+ queryWrapper.in(SysDept::getDeptId, entIds);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ deptService.page(page, queryWrapper);
|
|
|
|
|
|
List<SysDept> depts = page.getRecords();
|
|
|
|
|
@@ -543,9 +681,42 @@ public class SysStatisticManager {
|
|
|
*/
|
|
|
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<Integer> roles = SecurityUtils.getRoles();
|
|
|
+
|
|
|
+ LambdaQueryWrapper<SysDept> queryWrapper = Wrappers.<SysDept>lambdaQuery().eq(SysDept::getLevel, 4).eq(SysDept::getDelFlag, CommonConstants.STATUS_NORMAL);
|
|
|
+
|
|
|
+
|
|
|
+ // 服务商
|
|
|
+ if (roles.contains(37)) {
|
|
|
+ queryWrapper.eq(SysDept::getDeptId, user.getDeptId());
|
|
|
+ }
|
|
|
+ // 区域管理员 || 地市经理
|
|
|
+ else if (CollUtil.containsAny(roles, List.of(4, 43))) {
|
|
|
+
|
|
|
+ List<Integer> entIds = getEntIds(user);
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(entIds)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+ queryWrapper.in(SysDept::getDeptId, entIds);
|
|
|
+ }
|
|
|
+ // 其他
|
|
|
+ else {
|
|
|
+ List<Integer> entIds = getEntIds(user);
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(entIds)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+ queryWrapper.in(SysDept::getDeptId, entIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取服务商分页
|
|
|
+ deptService.page(page, queryWrapper);
|
|
|
|
|
|
|
|
|
List<SysDept> depts = page.getRecords();
|
|
@@ -621,7 +792,7 @@ public class SysStatisticManager {
|
|
|
List<WmTask> tasks = userId2TaskMap.get(uId);
|
|
|
if (CollUtil.isNotEmpty(tasks)) {
|
|
|
taskPkgCount = tasks.size();
|
|
|
- taskScoreTotal = tasks.stream().mapToLong(WmTask::getScore).sum();
|
|
|
+ taskScoreTotal = tasks.stream().mapToLong(WmTask::getScore).sum();
|
|
|
}
|
|
|
|
|
|
uMap.put("userTaskCount", taskPkgCount);
|
|
@@ -662,9 +833,42 @@ public class SysStatisticManager {
|
|
|
*/
|
|
|
public Page<?> statSupData(SysStatisticDto.OnSupData 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<Integer> roles = SecurityUtils.getRoles();
|
|
|
+
|
|
|
+ LambdaQueryWrapper<SysDept> queryWrapper = Wrappers.<SysDept>lambdaQuery().eq(SysDept::getLevel, 4).eq(SysDept::getDelFlag, CommonConstants.STATUS_NORMAL);
|
|
|
+
|
|
|
+
|
|
|
+ // 服务商
|
|
|
+ if (roles.contains(37)) {
|
|
|
+ queryWrapper.eq(SysDept::getDeptId, user.getDeptId());
|
|
|
+ }
|
|
|
+ // 区域管理员 || 地市经理
|
|
|
+ else if (CollUtil.containsAny(roles, List.of(4, 43))) {
|
|
|
+
|
|
|
+ List<Integer> entIds = getEntIds(user);
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(entIds)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+ queryWrapper.in(SysDept::getDeptId, entIds);
|
|
|
+ }
|
|
|
+ // 其他
|
|
|
+ else {
|
|
|
+ List<Integer> entIds = getEntIds(user);
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(entIds)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+ queryWrapper.in(SysDept::getDeptId, entIds);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 获取服务商分页
|
|
|
+
|
|
|
+ deptService.page(page, queryWrapper);
|
|
|
|
|
|
|
|
|
List<SysDept> depts = page.getRecords();
|
|
@@ -731,4 +935,36 @@ public class SysStatisticManager {
|
|
|
|
|
|
return builds;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private List<Integer> getEntIds(HnqzUser user) {
|
|
|
+
|
|
|
+ // 获取当前用户的区域
|
|
|
+ List<Long> list = userAreaService.listUserAreas((long) user.getId());
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取市级
|
|
|
+ List<Long> collect = areaEntityService.list(Wrappers.<SysAreaEntity>lambdaQuery()
|
|
|
+ .in(SysAreaEntity::getAreaId, list)
|
|
|
+ .eq(SysAreaEntity::getAreaType, UpmsType.AreaType.DISTRICT))
|
|
|
+ .stream()
|
|
|
+ .mapToLong(SysAreaEntity::getAreaId)
|
|
|
+ .boxed()
|
|
|
+ .distinct()
|
|
|
+ .sorted()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(collect)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取企业
|
|
|
+ return enterpriseAreaService.listAreaEnts(collect).stream().mapToInt(Long::intValue).boxed().distinct().sorted().collect(Collectors.toList());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|