Browse Source

工作台查询修改

tags/24080901
WendyYang 7 months ago
parent
commit
0e02386dc2
4 changed files with 46 additions and 223 deletions
  1. +0
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/ProjectGovSystemReplaceInfoController.java
  2. +14
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectGovSystemReplaceInfoManage.java
  3. +5
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/workbench/controller/WorkbenchController.java
  4. +27
    -213
      hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java

+ 0
- 3
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/ProjectGovSystemReplaceInfoController.java View File

@@ -2,15 +2,12 @@ package com.hz.pm.api.projectlib.controller;

import com.hz.pm.api.projectlib.manage.ProjectGovSystemReplaceInfoManage;
import com.hz.pm.api.projectlib.model.vo.SystemReplaceInfoVO;
import com.hz.pm.api.projectlib.model.vo.UnitProjectGovSystemReplaceVO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
* <p>
* ProjectGovSystemReplaceInfoController


+ 14
- 4
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectGovSystemReplaceInfoManage.java View File

@@ -18,7 +18,10 @@ import com.ningdatech.basic.util.CollUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

@@ -77,8 +80,6 @@ public class ProjectGovSystemReplaceInfoManage {
item.getProjectSystemReplaces().add(projectSystem);
Map<Integer, List<ProjectGovSystemReplaceInfos>> replaceInfoGroup = CollUtils.group(replaceInfos,
ProjectGovSystemReplaceInfos::getBatchNo);
before.addAndGet(CollUtils.sum(replaceInfoGroup.entrySet(), w -> w.getValue().size()));
after.addAndGet(replaceInfoGroup.size());
List<GovSystemReplaceInfoDTO> replaceInfoList = replaceInfoGroup.entrySet().stream()
.sorted(Comparator.comparingInt(Map.Entry::getKey))
.map(w -> {
@@ -88,8 +89,17 @@ public class ProjectGovSystemReplaceInfoManage {
replaceInfo.setReplaceType(firstReplaceInfo.getReplaceType());
replaceInfo.setTargetSystemName(firstReplaceInfo.getTargetSystem());
List<String> sourceSystemNames = CollUtils.fieldList(currBatchValues,
ProjectGovSystemReplaceInfos::getSourceSystem);
val -> {
String sourceSystem = val.getSourceSystem();
if (!StrUtil.SLASH.equals(sourceSystem)) {
before.incrementAndGet();
}
return sourceSystem;
});
replaceInfo.setSourceSystemNames(sourceSystemNames);
if (!StrUtil.SLASH.equals(replaceInfo.getTargetSystemName())) {
after.incrementAndGet();
}
return replaceInfo;
}).collect(Collectors.toList());
projectSystem.setReplaceSystems(replaceInfoList);


+ 5
- 3
hz-pm-api/src/main/java/com/hz/pm/api/workbench/controller/WorkbenchController.java View File

@@ -12,10 +12,12 @@ import org.springframework.web.bind.annotation.*;
import java.time.LocalDate;

/**
* 工作台前端控制器
* <p>
* WorkbenchController
* </p>
*
* @author ZPF
* @since 2023/03/17 15:35
* @author WendyYang
* @since 18:59 2024/3/23
*/
@RestController
@AllArgsConstructor


+ 27
- 213
hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java View File

@@ -1,39 +1,29 @@
package com.hz.pm.api.workbench.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.StopWatch;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Sets;
import com.hz.pm.api.common.helper.UserInfoHelper;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.model.entity.KeyValDTO;
import com.hz.pm.api.common.util.DecimalUtil;
import com.hz.pm.api.projectdeclared.manage.DefaultDeclaredProjectManage;
import com.hz.pm.api.projectlib.entity.ProjectGovSystemReplaceInfos;
import com.hz.pm.api.projectlib.manage.ProjectLibManage;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.enumeration.GovSystemReplaceTypeEnum;
import com.hz.pm.api.projectlib.model.req.ProjectListReq;
import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO;
import com.hz.pm.api.projectlib.service.IProjectGovSystemReplaceInfosService;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.hz.pm.api.sys.enumeration.ProjectEarlyWarningStatusEnum;
import com.hz.pm.api.sys.manage.EarlyWarningManage;
import com.hz.pm.api.sys.manage.NoticeManage;
import com.hz.pm.api.sys.model.entity.ProjectEarlyWarning;
import com.hz.pm.api.sys.model.entity.WflowEarlyWarningRecords;
import com.hz.pm.api.sys.model.vo.ProjectEarlyWarningVO;
import com.hz.pm.api.sys.service.IEarlyWarningRecordsService;
import com.hz.pm.api.sys.service.IProjectEarlyWarningService;
import com.hz.pm.api.sys.utils.EarlyWarningUtil;
import com.hz.pm.api.todocenter.manage.TodoCenterManage;
import com.hz.pm.api.todocenter.model.req.ToBeProcessedReq;
import com.hz.pm.api.todocenter.model.vo.ResToBeProcessedVO;
import com.hz.pm.api.todocenter.model.vo.TodoCenterStatisticsVO;
import com.hz.pm.api.todocenter.model.vo.TodoVO;
import com.hz.pm.api.user.helper.MhUnitCache;
@@ -42,12 +32,10 @@ import com.hz.pm.api.user.util.LoginUserUtil;
import com.hz.pm.api.workbench.converter.WorkbenchConverter;
import com.hz.pm.api.workbench.model.vo.ProjectTotalViewVO;
import com.hz.pm.api.workbench.model.vo.WorkbenchVO;
import com.hz.pm.api.workbench.model.vo.WorkbenchVO.WarningStatistics;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.basic.util.StrPool;
import com.wflow.bean.entity.WflowEarlyWarning;
import com.wflow.enums.WarningNoticeTypeEnum;
import com.wflow.service.IEarlyWarningService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -59,27 +47,24 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ForkJoinPool;
import java.util.stream.Collectors;

/**
* @Classname WorkbenchManage
* @Description
* @Date 2023/3/20 10:56
* @Author PoffyZhang
* <p>
* WorkbenchManage
* </p>
*
* @author WendyYang
* @since 18:58 2024/3/23
*/
@Slf4j
@Component
@AllArgsConstructor
@Slf4j
public class WorkbenchManage {

private final TodoCenterManage todoCenterManage;
private final DefaultDeclaredProjectManage defaultDeclaredProjectManage;
private final IEarlyWarningRecordsService earlyWarningRecordsService;
private final IEarlyWarningService earlyWarningService;
private final IProjectEarlyWarningService projectEarlyWarningService;
private final NoticeManage noticeManage;
private final UserInfoHelper userInfoHelper;
private final ProjectLibManage projectLibManage;
private final EarlyWarningManage earlyWarningManage;
@@ -91,196 +76,25 @@ public class WorkbenchManage {
WorkbenchVO res = new WorkbenchVO();
Long userId = LoginUserUtil.getUserId();
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(userId);
CompletableFuture.allOf(
CompletableFuture.runAsync(() -> {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
//1.待办中心数据
TodoCenterStatisticsVO todoCenterStat = todoCenterManage.todoCenterStatistics(userId);
ToBeProcessedReq toBeProcessedReq = new ToBeProcessedReq();
toBeProcessedReq.page(1, 5);
toBeProcessedReq.setLoginUserId(userId);
toBeProcessedReq.setUserId(userId);
List<TodoVO> todoList = todoCenterManage.todoProjectList(toBeProcessedReq)
.getRecords().stream()
.map(WorkbenchConverter::convert)
.collect(Collectors.toList());
todoCenterStat.setTodoList(todoList);
res.setTodoCerter(todoCenterStat);
stopWatch.stop();
log.info("待办中心数据 耗时,{} s", stopWatch.getLastTaskTimeMillis());
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
//2.项目统计数据
res.setOrgDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectOrgStatistics(year, user),
defaultDeclaredProjectManage.declaredProjectOrgStatistics(year - 1, user)));
if (user.getSuperAdmin() || user.getRegionAdmin()) {
res.setRegionDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectRegionStatistics(year, user),
defaultDeclaredProjectManage.declaredProjectRegionStatistics(year - 1, user)));
} else {
res.setRegionDeclared(new WorkbenchVO.DeclaredStatistics());
}
stopWatch.stop();
log.info("项目统计数据 耗时,{} s", stopWatch.getTotalTimeMillis());
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
// 项目列表
ProjectListReq projectListReq = new ProjectListReq();
projectListReq.page(1, 20);
projectListReq.setProjectYear(year);
res.setProjects(new ArrayList<>(projectLibManage.listWithPermissionWorkBench(projectListReq, user).getRecords()));
log.info("项目列表 耗时,{} s", stopWatch.getTotalTimeSeconds());
}, ForkJoinPool.commonPool())
).join();

// 待办中心数据
TodoCenterStatisticsVO todoStat = todoCenterManage.todoCenterStatistics(userId);
ToBeProcessedReq todoReq = new ToBeProcessedReq();
todoReq.page(1, 50);
todoReq.setLoginUserId(userId);
todoReq.setUserId(userId);
PageVo<ResToBeProcessedVO> todoPage = todoCenterManage.todoProjectList(todoReq);
List<TodoVO> todoList = CollUtils.fieldList(todoPage.getRecords(), WorkbenchConverter::convert);
todoStat.setTodoList(todoList);
res.setTodoCerter(todoStat);
// 项目列表
ProjectListReq projReq = new ProjectListReq();
projReq.page(1, 20);
projReq.setProjectYear(year);
PageVo<ProjectLibListItemVO> projPage = projectLibManage.listWithPermissionWorkBench(projReq, user);
res.setProjects(new ArrayList<>(projPage.getRecords()));
return res;
}

private WorkbenchVO.ProjectEarlyWarning getProjectEarlyWarning(UserFullInfoDTO user) {
WorkbenchVO.ProjectEarlyWarning projectEarlyWarning = new WorkbenchVO.ProjectEarlyWarning();
LambdaQueryWrapper<Project> pQuery = Wrappers.lambdaQuery(Project.class)
.select(Project::getProjectName, Project::getProjectCode)
.eq(Project::getNewest, Boolean.TRUE);
EarlyWarningUtil.buildPermissionProjectWrapper(pQuery, user);
List<Project> projects = projectService.list(pQuery);
Map<String, String> projectNameMap = CollUtils.listToMap(projects,
Project::getProjectCode, Project::getProjectName, (v1, v2) -> v1);


//4.1
//累积预警统计
WarningStatistics accumulate = new WarningStatistics();
LambdaQueryWrapper<WflowEarlyWarningRecords> overWrapper = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class)
.eq(WflowEarlyWarningRecords::getNoticeType, WarningNoticeTypeEnum.OVER.getCode())
.or(q2 -> q2.isNull(WflowEarlyWarningRecords::getNoticeType));
EarlyWarningUtil.buildPermissionFullWrapper(overWrapper, user);
long overCount = earlyWarningRecordsService.count(overWrapper);
accumulate.setOver((int) overCount);
LambdaQueryWrapper<WflowEarlyWarningRecords> adventWrapper = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class)
.eq(WflowEarlyWarningRecords::getNoticeType, WarningNoticeTypeEnum.ADVENT.getCode());
EarlyWarningUtil.buildPermissionFullWrapper(adventWrapper, user);
long adventCount = earlyWarningRecordsService.count(adventWrapper);
accumulate.setAdvent((int) adventCount);
projectEarlyWarning.setAccumulate(accumulate);

//4.2
//当前
//4.2.1 超期
Page<ProjectEarlyWarning> overPage = Page.of(1, 1000);
Page<ProjectEarlyWarning> adventPage = Page.of(1, 1000);
Page<ProjectEarlyWarning> normalPage = Page.of(1, 1000);
LambdaQueryWrapper<ProjectEarlyWarning> overPewWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class)
.eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.OVER_TIME.name())
.eq((user.getIsOrgAdmin() && !user.getSuperAdmin()) || user.notAdmin(), ProjectEarlyWarning::getBuildOrgCode, user.getMhUnitId());
projectEarlyWarningService.page(overPage, overPewWrapper);
LambdaQueryWrapper<ProjectEarlyWarning> adventPewWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class)
.eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.ADVENT_TIME.name())
.eq((user.getIsOrgAdmin() && !user.getSuperAdmin()) || user.notAdmin(), ProjectEarlyWarning::getBuildOrgCode, user.getMhUnitId());
projectEarlyWarningService.page(adventPage, adventPewWrapper);
LambdaQueryWrapper<ProjectEarlyWarning> normalWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class)
.eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.NORMAL.name())
.eq((user.getIsOrgAdmin() && !user.getSuperAdmin()) || user.notAdmin(), ProjectEarlyWarning::getBuildOrgCode, user.getMhUnitIdStr());
projectEarlyWarningService.page(normalPage, normalWrapper);

WarningStatistics current = new WarningStatistics();
long overTotal = overPage.getTotal();
long adventTotal = adventPage.getTotal();
long normalTotal = normalPage.getTotal();
current.setAdvent((int) adventTotal);
current.setOver((int) overTotal);
current.setNormal((int) normalTotal);
projectEarlyWarning.setCurrent(current);

List<WflowEarlyWarningRecords> warningRecords = earlyWarningRecordsService.list(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class)
.eq((user.getIsOrgAdmin() && !user.getSuperAdmin()) || user.notAdmin(), WflowEarlyWarningRecords::getBuildOrgCode, user.getMhUnitId())
.orderByDesc(WflowEarlyWarningRecords::getWarningTime));
Set<String> projectCodeSet = Sets.newHashSet();
Map<String, WflowEarlyWarningRecords> warningMap = warningRecords.stream()
.filter(w -> projectCodeSet.add(w.getProjectCode()))
.collect(Collectors.toMap(WflowEarlyWarningRecords::getProjectCode, w -> w));
LocalDateTime now = LocalDateTime.now();
if (CollUtil.isNotEmpty(overPage.getRecords())) {
List<ProjectEarlyWarningVO> overVos = overPage.getRecords().stream().map(o -> {
ProjectEarlyWarningVO vo = BeanUtil.copyProperties(o, ProjectEarlyWarningVO.class);
//取最新一条预警信息
if (warningMap.containsKey(vo.getProjectCode())) {
WflowEarlyWarningRecords currRecord = warningMap.get(vo.getProjectCode());
vo.setWarningTime(currRecord.getWarningTime());
vo.setInstStart(currRecord.getInstStart());
vo.setWarningUserId(currRecord.getWarningUserId());
vo.setNoticeMethod(currRecord.getNoticeMethod());
vo.setNoticeContent(currRecord.getNoticeContent());
vo.setPath(currRecord.getPath());
vo.setBatchUserIds(currRecord.getBatchUserIds());
vo.setRecordId(currRecord.getId());
} else {
vo.setWarningTime(now);
}
vo.setProjectName(projectNameMap.get(o.getProjectCode()));
return vo;
}).sorted(Comparator.comparing(ProjectEarlyWarningVO::getWarningTime).reversed())
.collect(Collectors.toList());
projectEarlyWarning.setOvers(PageVo.of(overVos, overPage.getTotal()));
} else {
projectEarlyWarning.setOvers(PageVo.empty());
}

if (CollUtil.isNotEmpty(adventPage.getRecords())) {
List<ProjectEarlyWarningVO> adventVos = adventPage.getRecords().stream().map(o -> {
ProjectEarlyWarningVO vo = BeanUtil.copyProperties(o, ProjectEarlyWarningVO.class);
//取最新一条预警信息
if (warningMap.containsKey(vo.getProjectCode())) {
WflowEarlyWarningRecords currRecord = warningMap.get(vo.getProjectCode());
vo.setWarningTime(currRecord.getWarningTime());
vo.setInstStart(currRecord.getInstStart());
vo.setWarningUserId(currRecord.getWarningUserId());
vo.setNoticeMethod(currRecord.getNoticeMethod());
vo.setNoticeContent(currRecord.getNoticeContent());
vo.setPath(currRecord.getPath());
vo.setBatchUserIds(currRecord.getBatchUserIds());
vo.setRecordId(currRecord.getId());
} else {
vo.setWarningTime(now);
}
vo.setProjectName(projectNameMap.get(o.getProjectCode()));
return vo;
}).sorted(Comparator.comparing(ProjectEarlyWarningVO::getWarningTime).reversed())
.collect(Collectors.toList());
projectEarlyWarning.setAdvents(PageVo.of(adventVos, adventPage.getTotal()));
} else {
projectEarlyWarning.setAdvents(PageVo.empty());
}

if (CollUtil.isNotEmpty(normalPage.getRecords())) {
List<ProjectEarlyWarningVO> normalVos = normalPage.getRecords().stream().map(o -> {
ProjectEarlyWarningVO vo = BeanUtil.copyProperties(o, ProjectEarlyWarningVO.class);
//取最新一条预警信息
if (warningMap.containsKey(vo.getProjectCode())) {
WflowEarlyWarningRecords currRecord = warningMap.get(vo.getProjectCode());
vo.setWarningTime(currRecord.getWarningTime());
vo.setInstStart(currRecord.getInstStart());
vo.setWarningUserId(currRecord.getWarningUserId());
vo.setNoticeMethod(currRecord.getNoticeMethod());
vo.setNoticeContent(currRecord.getNoticeContent());
vo.setPath(currRecord.getPath());
vo.setBatchUserIds(currRecord.getBatchUserIds());
vo.setRecordId(currRecord.getId());
}
vo.setProjectName(projectNameMap.get(o.getProjectCode()));
return vo;
}).sorted(Comparator.comparing(ProjectEarlyWarningVO::getId).reversed())
.collect(Collectors.toList());
projectEarlyWarning.setNormals(PageVo.of(normalVos, normalPage.getTotal()));
} else {
projectEarlyWarning.setNormals(PageVo.empty());
}
return projectEarlyWarning;
}

/**
* 催办
*
@@ -340,7 +154,7 @@ public class WorkbenchManage {
projectYear = LocalDate.now().getYear();
}
LambdaQueryWrapper<Project> query = Wrappers.lambdaQuery(Project.class)
.select(Project::getReviewAmount, Project::getApprovalAmount, Project::getId)
.select(Project::getReviewAmount, Project::getApprovalGovOwnFinanceAmount, Project::getId)
.eq(Project::getProjectYear, projectYear)
.eq(Project::getNewest, Boolean.TRUE);
List<Long> viewUnitIds = mhUnitCache.getChildrenIdsRecursion(unitId);
@@ -350,7 +164,7 @@ public class WorkbenchManage {
if (projects.isEmpty()) {
return retDetail;
}
BigDecimal approvalAmount = DecimalUtil.sum(projects, Project::getApprovalAmount);
BigDecimal approvalAmount = DecimalUtil.sum(projects, Project::getApprovalGovOwnFinanceAmount);
BigDecimal reviewAmount = DecimalUtil.sum(projects, Project::getReviewAmount);
retDetail.setTotalExecuteAmount(BigDecimal.ZERO);
retDetail.setTotalApprovalAmount(approvalAmount);


Loading…
Cancel
Save