Переглянути джерело

优化工作台

tags/24080901
PoffyZhang 1 рік тому
джерело
коміт
2b8a94625d
12 змінених файлів з 135 додано та 8 видалено
  1. +7
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/DataScopeContext.java
  2. +1
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/DataScopeProvider.java
  3. +10
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/DashboardUserDataScopeProviderImpl.java
  4. +14
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/ExpertDataScopeProviderImpl.java
  5. +10
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/OrdinaryUserDataScopeProviderImpl.java
  6. +10
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/OrgAdminDataScopeProviderImpl.java
  7. +19
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/RegionAdminDataScopeProviderImpl.java
  8. +14
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/SuperAdminDataScopeProviderImpl.java
  9. +8
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/VisitoyDataScopeProviderImpl.java
  10. +7
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/datascope/utils/DataScopeUtil.java
  11. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java
  12. +33
    -6
      pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java

+ 7
- 0
pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/DataScopeContext.java Переглянути файл

@@ -35,4 +35,11 @@ public class DataScopeContext implements Serializable {
return dataScopeProvider.findDataFieldProperty();
}

public static Optional<DataScopeDTO> getDataScopeHasUserId(String roleCode,Long userId) {
DataScopeProvider dataScopeProvider = DSP_MAP.get(roleCode);
if (dataScopeProvider == null) {
throw new IllegalArgumentException(String.format(WARN_MSG, roleCode));
}
return dataScopeProvider.findDataFieldProperty(userId);
}
}

+ 1
- 0
pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/DataScopeProvider.java Переглянути файл

@@ -22,4 +22,5 @@ public interface DataScopeProvider {
**/
Optional<DataScopeDTO> findDataFieldProperty();

Optional<DataScopeDTO> findDataFieldProperty(Long userId);
}

+ 10
- 0
pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/DashboardUserDataScopeProviderImpl.java Переглянути файл

@@ -39,4 +39,14 @@ public class DashboardUserDataScopeProviderImpl implements DataScopeProvider {
return Optional.ofNullable(ds);
}

@Override
public Optional<DataScopeDTO> findDataFieldProperty(Long userId) {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
DataScopeDTO ds = new DataScopeDTO();
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRegionCodes(Lists.newArrayList(userFullInfo.getRegionCode()));
ds.setUserId(userFullInfo.getUserId());
ds.setRole(RoleEnum.DASHBOARD);
return Optional.ofNullable(ds);
}
}

+ 14
- 0
pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/ExpertDataScopeProviderImpl.java Переглянути файл

@@ -48,4 +48,18 @@ public class ExpertDataScopeProviderImpl implements DataScopeProvider {
return Optional.ofNullable(ds);
}

@Override
public Optional<DataScopeDTO> findDataFieldProperty(Long userId) {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
//所有 丽水市的code
Collection<String> regionCodes = regionCacheHelper.listChildRegionCodeList(RegionConst.RC_LS,
RegionConst.RL_CITY);

DataScopeDTO ds = new DataScopeDTO();
ds.setRegionCodes(regionCodes.stream().collect(Collectors.toList()));
ds.setUserId(userFullInfo.getUserId());
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.EXPERT);
return Optional.ofNullable(ds);
}
}

+ 10
- 0
pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/OrdinaryUserDataScopeProviderImpl.java Переглянути файл

@@ -38,4 +38,14 @@ public class OrdinaryUserDataScopeProviderImpl implements DataScopeProvider {
return Optional.ofNullable(ds);
}

@Override
public Optional<DataScopeDTO> findDataFieldProperty(Long userId) {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
DataScopeDTO ds = new DataScopeDTO();
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRegionCodes(Lists.newArrayList(userFullInfo.getRegionCode()));
ds.setUserId(userFullInfo.getUserId());
ds.setRole(RoleEnum.NORMAL_MEMBER);
return Optional.ofNullable(ds);
}
}

+ 10
- 0
pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/OrgAdminDataScopeProviderImpl.java Переглянути файл

@@ -37,4 +37,14 @@ public class OrgAdminDataScopeProviderImpl implements DataScopeProvider {
return Optional.of(ds);
}

@Override
public Optional<DataScopeDTO> findDataFieldProperty(Long userId) {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
DataScopeDTO ds = new DataScopeDTO();
ds.setOrgCode(userFullInfo.getEmpPosUnitCode());
ds.setUserId(userFullInfo.getUserId());
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.COMPANY_MANAGER);
return Optional.of(ds);
}
}

+ 19
- 0
pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/RegionAdminDataScopeProviderImpl.java Переглянути файл

@@ -54,4 +54,23 @@ public class RegionAdminDataScopeProviderImpl implements DataScopeProvider {
return Optional.of(ds);
}

@Override
public Optional<DataScopeDTO> findDataFieldProperty(Long userId) {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
//借由 丽水市的code 来映射市本级的regionCode
Collection<String> regionCodes = regionCacheHelper.listChildRegionCodeList(userFullInfo.getRegionCode(),
RegionConst.RL_CITY);
//如果不是市本级的话 就直接放入本区域的县就好了
if(CollUtil.isEmpty(regionCodes)){
regionCodes = Lists.newArrayList();
regionCodes.add(userFullInfo.getRegionCode());
}

DataScopeDTO ds = new DataScopeDTO();
ds.setRegionCodes(new ArrayList<>(regionCodes));
ds.setUserId(userFullInfo.getUserId());
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.REGION_MANAGER);
return Optional.of(ds);
}
}

+ 14
- 0
pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/SuperAdminDataScopeProviderImpl.java Переглянути файл

@@ -48,4 +48,18 @@ public class SuperAdminDataScopeProviderImpl implements DataScopeProvider {
return Optional.of(ds);
}

@Override
public Optional<DataScopeDTO> findDataFieldProperty(Long userId) {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
//所有 丽水市的code
Collection<String> regionCodes = regionCacheHelper.listChildRegionCodeList(RegionConst.RC_LS,
RegionConst.RL_CITY);

DataScopeDTO ds = new DataScopeDTO();
ds.setRegionCodes(new ArrayList<>(regionCodes));
ds.setUserId(userFullInfo.getUserId());
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.SUPER_ADMIN);
return Optional.of(ds);
}
}

+ 8
- 0
pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/VisitoyDataScopeProviderImpl.java Переглянути файл

@@ -34,4 +34,12 @@ public class VisitoyDataScopeProviderImpl implements DataScopeProvider {
return Optional.ofNullable(ds);
}

@Override
public Optional<DataScopeDTO> findDataFieldProperty(Long userId) {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
DataScopeDTO ds = new DataScopeDTO();
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.SUPER_ADMIN);
return Optional.ofNullable(ds);
}
}

+ 7
- 0
pmapi/src/main/java/com/ningdatech/pmapi/datascope/utils/DataScopeUtil.java Переглянути файл

@@ -24,6 +24,13 @@ public class DataScopeUtil {
return DataScopeContext.getDataScope(user.getRoleCode().name());
}

public static Optional<DataScopeDTO> getCurrentUserDataScopeHasUserId(UserFullInfoDTO user) {
if (Objects.isNull(user) || Objects.isNull(user.getRoleCode())) {
return Optional.empty();
}
return DataScopeContext.getDataScopeHasUserId(user.getRoleCode().name(),user.getUserId());
}

public static Optional<DataScopeDTO> getCurrentUserDataScope() {
UserInfoDetails loginUser = LoginUserUtil.loginUserDetail();
if (Objects.isNull(loginUser) || Objects.isNull(loginUser.getRoleCode())) {


+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java Переглянути файл

@@ -1322,7 +1322,7 @@ public class ProjectLibManage {
* @param query
*/
public UserFullInfoDTO buildProjectLibPermission(LambdaQueryWrapper<Project> query, UserFullInfoDTO user) {
Optional<DataScopeDTO> currentUserDataScope = DataScopeUtil.getCurrentUserDataScope(user);
Optional<DataScopeDTO> currentUserDataScope = DataScopeUtil.getCurrentUserDataScopeHasUserId(user);
if (!currentUserDataScope.isPresent()) {
log.warn("没有取到权限信息 当前查询 没有权限条件");
return user;
@@ -1367,7 +1367,7 @@ public class ProjectLibManage {
}

public ProjectListReq buildProjectLibPermission(ProjectListReq req,UserFullInfoDTO user) {
Optional<DataScopeDTO> currentUserDataScope = DataScopeUtil.getCurrentUserDataScope(user);
Optional<DataScopeDTO> currentUserDataScope = DataScopeUtil.getCurrentUserDataScopeHasUserId(user);
if (!currentUserDataScope.isPresent()) {
log.warn("没有取到权限信息 当前查询 没有权限条件");
return req;


+ 33
- 6
pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java Переглянути файл

@@ -2,6 +2,7 @@ package com.ningdatech.pmapi.workbench.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.StopWatch;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -34,6 +35,7 @@ import com.ningdatech.pmapi.workbench.model.vo.WorkbenchVO;
import com.wflow.enums.WarningNoticeTypeEnum;
import com.wflow.enums.WarningRuleTypeEnum;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

@@ -52,6 +54,7 @@ import java.util.stream.Collectors;
*/
@Component
@AllArgsConstructor
@Slf4j
public class WorkbenchManage {

private final TodoCenterManage todoCenterManage;
@@ -79,6 +82,8 @@ public class WorkbenchManage {

CompletableFuture.allOf(
CompletableFuture.runAsync(() -> {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
//1.待办中心数据
TodoCenterStatisticsVO statisticsVO = todoCenterManage.todoCenterStatistics(user.getEmployeeCode());
ToBeProcessedReq toBeProcessedReq = new ToBeProcessedReq();
@@ -89,8 +94,13 @@ public class WorkbenchManage {
statisticsVO.setTodoList(todoCenterManage.todoProjectList(toBeProcessedReq).getRecords()
.stream().map(WorkbenchConverter::convert).collect(Collectors.toList()));
res.setTodoCerter(statisticsVO);
stopWatch.stop();
log.info("待办中心数据 耗时,{} s",stopWatch.getTotalTimeSeconds());
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> {
StopWatch stopWatch = new StopWatch();
stopWatch.start();

//2.项目统计数据
res.setOrgDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage
.declaredProjectOrgStatistics(year, user),defaultDeclaredProjectManage.declaredProjectOrgStatistics(year - 1, user)));
@@ -98,26 +108,43 @@ public class WorkbenchManage {
res.setRegionDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage
.declaredProjectRegionStatistics(year, user),defaultDeclaredProjectManage.declaredProjectRegionStatistics(year - 1, user)));
}
stopWatch.stop();
log.info("项目统计数据 耗时,{} s",stopWatch.getTotalTimeSeconds());
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> {
StopWatch stopWatch = new StopWatch();
stopWatch.start();

//3.所有公告按类型分
NoticeListReq noticeListReq = new NoticeListReq();
noticeListReq.setPageNumber(1);
noticeListReq.setPageSize(1000);
res.setNoticeList(noticeManage.listToMapByManager(noticeListReq,user));
stopWatch.stop();
log.info("公告 耗时,{} s",stopWatch.getTotalTimeSeconds());
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> {
StopWatch stopWatch = new StopWatch();
stopWatch.start();

//4.项目预警记录
res.setProjectEarlyWarning(getProjectEarlyWarning(user));
log.info("项目预警记录 耗时,{} s",stopWatch.getTotalTimeSeconds());
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> {
StopWatch stopWatch = new StopWatch();
stopWatch.start();

// 项目列表
ProjectListReq projectListReq = new ProjectListReq();
projectListReq.setPageNumber(1);
projectListReq.setPageSize(2000);
projectListReq.setProjectYear(year);
res.setProjects(new ArrayList<>(projectLibManage.listWithPermissionWorkbentch(projectListReq,user).getRecords()));
log.info("工作台 项目列表 耗时,{} s",stopWatch.getTotalTimeSeconds());
}, ForkJoinPool.commonPool())
).join();

//这个不能放入子线程
ProjectListReq projectListReq = new ProjectListReq();
projectListReq.setPageNumber(1);
projectListReq.setPageSize(2000);
projectListReq.setProjectYear(year);
res.setProjects(new ArrayList<>(projectLibManage.listWithPermissionWorkbentch(projectListReq,user).getRecords()));
return res;
}



Завантаження…
Відмінити
Зберегти