Sfoglia il codice sorgente

modify:

1. 流程预警修改;
tags/24082801
WendyYang 2 mesi fa
parent
commit
ee631ea14f
10 ha cambiato i file con 235 aggiunte e 139 eliminazioni
  1. +3
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/WarningFlowTypeEnum.java
  2. +11
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectStatusChangeService.java
  3. +5
    -27
      hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningProjectTask.java
  4. +70
    -61
      hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningWithoutSubmitTask.java
  5. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/EarlyWarningManage.java
  6. +8
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/workbench/controller/WorkbenchController.java
  7. +102
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java
  8. +4
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/workbench/model/WorkbenchReq.java
  9. +29
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/workbench/model/vo/WorkbenchProjectEarlyWarnVO.java
  10. +2
    -42
      hz-pm-api/src/main/java/com/hz/pm/api/workbench/model/vo/WorkbenchVO.java

+ 3
- 3
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/WarningFlowTypeEnum.java Vedi File

@@ -23,15 +23,15 @@ public enum WarningFlowTypeEnum {
*/
UNIT_INNER_AUDIT(1, "预审申报", null, "declareManage/planDeclaration/preExaminationDeclare"),
PRELIMINARY_PREVIEW(2, "建设方案申报", null, "declareManage/constructionPlanDeclare"),
DEPT_UNITED_REVIEW(3, "采购结果备案", ProjectStatus.TO_BE_PURCHASED.getCode(), "declareManage/procurementRecord/purchaseResults"),
WITHOUT_PURCHASE(3, "采购结果备案", ProjectStatus.TO_BE_PURCHASED, "declareManage/procurementRecord/purchaseResults"),
CONSTRUCTION_PLAN_REVIEW(4, "初验备案", null, "declareManage/acceptanceApply/initialInspectionRecord"),
PROJECT_FINAL_INSPECTION(5, "验收申报", ProjectStatus.ON_PILOT_RUNNING.getCode(), "declareManage/acceptanceApply/finalInspectionDeclare");
PROJECT_FINAL_INSPECTION(5, "验收申报", ProjectStatus.ON_PILOT_RUNNING, "declareManage/acceptanceApply/finalInspectionDeclare");

private Integer code;
private String desc;

//对应的 待提交时的项目状态
private Integer projectStutas;
private ProjectStatus projectStatus;

private String path;



+ 11
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectStatusChangeService.java Vedi File

@@ -78,4 +78,15 @@ public interface IProjectStatusChangeService extends IService<ProjectStatusChang
Comparator.comparing(ProjectStatusChange::getCreateOn).reversed());
}

default Map<String, ProjectStatusChange> listLastEventMap(Collection<String> projectCodes,
ProjectStateChangeEvent event) {
Wrapper<ProjectStatusChange> query = Wrappers.lambdaQuery(ProjectStatusChange.class)
.in(ProjectStatusChange::getProjectCode, projectCodes)
.eq(ProjectStatusChange::getEvent, event)
.orderByDesc(ProjectStatusChange::getCreateOn);
return BizUtils.groupFirstMap(list(query),
ProjectStatusChange::getProjectCode,
Comparator.comparing(ProjectStatusChange::getCreateOn).reversed());
}

}

+ 5
- 27
hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningProjectTask.java Vedi File

@@ -1,7 +1,6 @@
package com.hz.pm.api.scheduler.task;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.StopWatch;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Sets;
import com.hz.pm.api.common.model.constant.BizConst;
@@ -10,6 +9,7 @@ import com.hz.pm.api.projectlib.model.entity.ProjectRenewalFundDeclaration;
import com.hz.pm.api.projectlib.model.enumeration.ProjectRenewalApprovalStatusEnum;
import com.hz.pm.api.projectlib.model.enumeration.WarningFlowTypeEnum;
import com.hz.pm.api.projectlib.model.enumeration.WarningOperationTypeEnum;
import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus;
import com.hz.pm.api.projectlib.service.IProjectRenewalFundDeclarationService;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.hz.pm.api.sys.enumeration.ProjectEarlyWarningStatusEnum;
@@ -23,12 +23,9 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.flowable.engine.TaskService;
import org.flowable.task.api.Task;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
@@ -52,26 +49,13 @@ public class EarlyWarningProjectTask {
private final IEarlyWarningRecordsService earlyWarningRecordsService;
private final IProjectRenewalFundDeclarationService renewalFundDeclarationService;
private final TaskService taskService;
@Value("${hostname:}")
private String HOST_NAME;

@Scheduled(fixedDelay = 12, initialDelay = 1, timeUnit = TimeUnit.MINUTES)
public void doEarlyWarningDeclared() throws UnknownHostException {
if (!HOST_NAME.equals(InetAddress.getLocalHost().getHostName())) {
return;
}

log.info("=========== 预警项目维度任务开始 ========");
StopWatch stopWatch = new StopWatch();
stopWatch.start();

@Scheduled(fixedDelay = 5, initialDelay = 5, timeUnit = TimeUnit.MINUTES)
public void doEarlyWarningDeclared() {
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getNewest, Boolean.TRUE));

if (CollUtil.isEmpty(projects)) {
log.info("系统没有项目 退出任务");
stopWatch.stop();
log.info("=========== 预警项目维度任务结束 耗时{}s", stopWatch.getTotalTimeSeconds());
return;
}

@@ -122,15 +106,9 @@ public class EarlyWarningProjectTask {
//3.去查询 各个报警 是否已经正常
List<ProjectEarlyWarning> trueWarnings = warnings.stream().filter(w -> Objects.nonNull(w.getNormal()) && !w.getNormal()).collect(Collectors.toList());
if (CollUtil.isEmpty(trueWarnings)) {
log.info("没有异常的项目 要去查询");
stopWatch.stop();
log.info("=========== 预警项目维度任务结束 耗时{}s", stopWatch.getTotalTimeSeconds());
return;
}
checkNormal(trueWarnings);

stopWatch.stop();
log.info("=========== 预警项目维度任务结束 耗时{}s", stopWatch.getTotalTimeSeconds());
}

//3.去查询 各个报警 是否已经正常
@@ -272,9 +250,9 @@ public class EarlyWarningProjectTask {
if (Objects.isNull(flowTypeEnum)) {
continue;
}
Integer projectStutas = flowTypeEnum.getProjectStutas();
ProjectStatus projectStatus = flowTypeEnum.getProjectStatus();
//已经不是这个状态了 说明已经被提交了
if (!projectStutas.equals(project.getStatus())) {
if (!projectStatus.eq(project.getStatus())) {
declaredWarning.setDeclaredWarning(Boolean.FALSE);
//其它三种 都没有 说明已经正常了
if (!declaredWarning.getProcessWarning() &&


hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningInstanceNotStartTask.java → hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningWithoutSubmitTask.java Vedi File

@@ -2,6 +2,7 @@ package com.hz.pm.api.scheduler.task;

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.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
@@ -11,23 +12,29 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.hz.pm.api.common.enumeration.CommonEnum;
import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent;
import com.hz.pm.api.common.util.EnvironmentUtil;
import com.hz.pm.api.common.util.StrUtils;
import com.hz.pm.api.projectdeclared.model.entity.Operation;
import com.hz.pm.api.projectdeclared.service.IOperationService;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectRenewalFundDeclaration;
import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange;
import com.hz.pm.api.projectlib.model.enumeration.ProjectRenewalApprovalStatusEnum;
import com.hz.pm.api.projectlib.model.enumeration.WarningFlowTypeEnum;
import com.hz.pm.api.projectlib.model.enumeration.WarningNoticeTypeEnum;
import com.hz.pm.api.projectlib.model.enumeration.WarningOperationTypeEnum;
import com.hz.pm.api.projectlib.service.IProjectRenewalFundDeclarationService;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.hz.pm.api.projectlib.service.IProjectStatusChangeService;
import com.hz.pm.api.sys.manage.EarlyWarningManage;
import com.hz.pm.api.sys.manage.RoleManage;
import com.hz.pm.api.sys.service.IProjectEarlyWarningService;
import com.hz.pm.api.user.helper.MhUnitCache;
import com.hz.pm.api.user.model.entity.UserInfo;
import com.hz.pm.api.user.model.enumeration.RoleEnum;
import com.hz.pm.api.user.service.IUserInfoService;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.basic.util.StrPool;
import com.wflow.bean.entity.WflowEarlyWarning;
import com.wflow.enums.WarningRuleTypeEnum;
@@ -42,6 +49,7 @@ import org.springframework.stereotype.Component;
import java.net.UnknownHostException;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -55,8 +63,8 @@ import java.util.stream.Collectors;
@Slf4j
@Component
@RequiredArgsConstructor
@ConditionalOnExpression("${early-warning-instance-task:false}")
public class EarlyWarningInstanceNotStartTask {
@ConditionalOnExpression("${early-warning-without-submit.open:false}")
public class EarlyWarningWithoutSubmitTask {

private final IEarlyWarningService earlyWarningService;
private final IProjectService projectService;
@@ -66,11 +74,22 @@ public class EarlyWarningInstanceNotStartTask {
private final IProjectRenewalFundDeclarationService renewalFundDeclarationService;
private final RoleManage roleManage;
private final IProjectEarlyWarningService projectEarlyWarningService;
private final MhUnitCache mhUnitCache;
private final IProjectStatusChangeService projectStatusChangeService;
private final EnvironmentUtil environmentUtil;

private ChronoUnit getTimeUnit() {
if (environmentUtil.isDevEnv()) {
return ChronoUnit.MINUTES;
} else {
return ChronoUnit.DAYS;
}
}

/**
* 填报预警
*/
@Scheduled(cron = "${early-warning-instance-task.cron:0 0/5 * * * ?}")
@Scheduled(cron = "${early-warning-without-submit.cron:0 0/5 * * * ?}")
public void doEarlyWarningDeclared() {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
@@ -80,14 +99,8 @@ public class EarlyWarningInstanceNotStartTask {
.eq(WflowEarlyWarning::getIsOpen, true);
List<WflowEarlyWarning> warnings = earlyWarningService.list(query);
for (WflowEarlyWarning warning : warnings) {
String noticeMethod = warning.getNoticeMethod();
if (StringUtils.isBlank(noticeMethod) ||
(!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) &&
!noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))) {
log.info("通知方式为空或者错误!");
return;
}

long mhUnitId = NumberUtil.parseLong(warning.getAreaCode());
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(mhUnitId);
String noticeContent = warning.getNoticeContent();
String adventContent = warning.getAdventContent();
String rule = warning.getRule();
@@ -100,63 +113,59 @@ public class EarlyWarningInstanceNotStartTask {
Integer biz = rJson.getInteger("biz");
String notice = rJson.getString("notice");
Integer adventTime = rJson.getInteger("adventTime");
if ((Objects.isNull(time) && Objects.isNull(adventTime)) || Objects.isNull(biz)) {
log.info("规则数据 错误 :{}", rJson);
WarningFlowTypeEnum flowType = WarningFlowTypeEnum.getByCode(biz);
if (((Objects.isNull(time) && Objects.isNull(adventTime)) || Objects.isNull(biz))
|| StrUtil.isBlank(notice)
|| flowType == null) {
log.warn("规则数据 错误 :{}", rJson);
return;
}

if (StringUtils.isBlank(notice)) {
log.info("取不到提醒人配置 : " + rJson);
return;
}

WarningFlowTypeEnum flowTypeEnum = WarningFlowTypeEnum.getByCode(biz);
if (Objects.isNull(flowTypeEnum)) {
log.info("匹配不到 业务类型");
return;
}
String path = flowTypeEnum.getPath();

//得出 对应待提交的项目状态
Integer projectStatus = flowTypeEnum.getProjectStutas();
String areaCode = warning.getAreaCode();
//测试先用分钟
String path = flowType.getPath();
//查询 所有这个区域的项目 未提交的项目
List<Project> needNextProjects = projectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getAreaCode, areaCode)
Wrapper<Project> projectQuery = Wrappers.lambdaQuery(Project.class)
.eq(Project::getBuildOrgCode, viewUnitIds)
.eq(Project::getNewest, Boolean.TRUE)
.eq(Project::getStatus, projectStatus));
.eq(Project::getStatus, flowType.getProjectStatus().getCode());
List<Project> needNextProjects = projectService.list(projectQuery);
Map<String, List<Integer>> noticeMap = Maps.newHashMap();
//需要发通知的项目
List<String> projectCodes = CollUtils.fieldList(needNextProjects, Project::getProjectCode);
Map<String, ProjectStatusChange> projectStatusChangeMap;
switch (flowType) {
case WITHOUT_PURCHASE:
projectStatusChangeMap = projectStatusChangeService.listLastEventMap(projectCodes,
ProjectStateChangeEvent.DECLARED_RECORD_PASS);
break;
default:
return;
}
// 需要发通知的项目
List<Project> needToWaringProjects = needNextProjects.stream()
.filter(p -> {
ProjectStatusChange change = projectStatusChangeMap.get(p.getProjectCode());
List<Integer> noticeTypes = Lists.newArrayList();
if (Objects.nonNull(time) && Duration.between(p.getUpdateOn(), LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60
Duration.between(p.getUpdateOn(), LocalDateTime.now()).toMinutes() <= time * 60 + 1) { //time * 60
noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.OVER.getCode());
}
if (Objects.nonNull(adventTime) && Duration.between(p.getUpdateOn(), LocalDateTime.now()).toMinutes() >= adventTime * 60 && //time * 60
Duration.between(p.getUpdateOn(), LocalDateTime.now()).toMinutes() <= adventTime * 60 + 1) {
noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.ADVENT.getCode());
}
if (CollUtil.isNotEmpty(noticeTypes)) {
noticeMap.put(p.getProjectCode(), noticeTypes);
//项目 填报预警
projectEarlyWarningService.earlyWarning(p,
WarningRuleTypeEnum.DECLARED_WARNING.getCode(), noticeTypes);
return Boolean.TRUE;
LocalDateTime touchTime = change == null ? null : change.getCreateOn();
if (touchTime != null) {
if (Objects.nonNull(time)) {
long duration = Duration.between(touchTime, LocalDateTime.now()).get(getTimeUnit());
if (duration >= time && duration < time + (environmentUtil.isDevEnv() ? 5 : 1)) {
noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.OVER.getCode());
}
}
if (Objects.nonNull(adventTime)) {
long duration = Duration.between(touchTime, LocalDateTime.now()).get(getTimeUnit());
if (duration >= adventTime && duration < adventTime + (environmentUtil.isDevEnv() ? 5 : 1)) {
noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.ADVENT.getCode());
}
}
if (CollUtil.isNotEmpty(noticeTypes)) {
noticeMap.put(p.getProjectCode(), noticeTypes);
//项目 填报预警
projectEarlyWarningService.earlyWarning(p, WarningRuleTypeEnum.DECLARED_WARNING.getCode(), noticeTypes);
return Boolean.TRUE;
}
}
return Boolean.FALSE;
})
.collect(Collectors.toList());

if (StringUtils.isBlank(noticeMethod) ||
(!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) &&
!noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))) {
log.info("通知方式为空或者错误!");
return;
}
}).collect(Collectors.toList());

for (Project needToWaringProject : needToWaringProjects) {
String username;
@@ -197,7 +206,7 @@ public class EarlyWarningInstanceNotStartTask {
List<Integer> noticeTypes = noticeMap.get(needToWaringProject.getProjectCode());
for (Integer noticeType : noticeTypes) {
for (String employeeCode : batchEmployees) {
earlyWarningManage.doEarlyWarning(noticeMethod, Objects.nonNull(noticeType) && noticeType.equals(1) ? noticeContent : adventContent,
earlyWarningManage.doEarlyWarning(warning.getNoticeMethod(), Objects.nonNull(noticeType) && noticeType.equals(1) ? noticeContent : adventContent,
adventTime, time, biz,
needToWaringProject.getUpdateOn(), Long.valueOf(employeeCode), needToWaringProject,
WarningRuleTypeEnum.DECLARED_WARNING.getCode(), noticeType, path, batchEmployeesStr,
@@ -216,7 +225,7 @@ public class EarlyWarningInstanceNotStartTask {
log.info("=========== 预警填报超时任务结束 耗时{}s", stopWatch.getTotalTimeSeconds());
}

@Scheduled(cron = "10 0/2 * * * ?")
//@Scheduled(cron = "10 0/2 * * * ?")
public void doEarlyWarningOperation() throws UnknownHostException {
log.info("=========== 预警实施超时任务开始 ========");
StopWatch stopWatch = new StopWatch();
@@ -400,7 +409,7 @@ public class EarlyWarningInstanceNotStartTask {
*
* @throws UnknownHostException
*/
@Scheduled(cron = "20 0/2 * * * ?")
//@Scheduled(cron = "20 0/2 * * * ?")
public void doEarlyWarningRenewalFund() throws UnknownHostException {
log.info("=========== 预警续建资金项目 超时任务开始 ========");
StopWatch stopWatch = new StopWatch();

+ 1
- 1
hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/EarlyWarningManage.java Vedi File

@@ -108,7 +108,7 @@ public class EarlyWarningManage {
records.setRuleType(WarningRuleTypeEnum.RENEWAL_FUND.getCode());
break;
default:
log.info("匹配不到 规则类型");
log.warn("匹配不到 规则类型");
return;
}



+ 8
- 1
hz-pm-api/src/main/java/com/hz/pm/api/workbench/controller/WorkbenchController.java Vedi File

@@ -7,6 +7,7 @@ import com.hz.pm.api.workbench.model.WorkbenchProjectLibReq;
import com.hz.pm.api.workbench.model.WorkbenchReq;
import com.hz.pm.api.workbench.model.vo.ProjectProcessStatVO;
import com.hz.pm.api.workbench.model.vo.ProjectTotalViewVO;
import com.hz.pm.api.workbench.model.vo.WorkbenchProjectEarlyWarnVO;
import com.hz.pm.api.workbench.model.vo.WorkbenchVO;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.log.annotation.WebLog;
@@ -73,8 +74,14 @@ public class WorkbenchController {

@GetMapping("/systemReplaceInfos")
@ApiOperation("获取项目替代情况")
public SystemReplaceInfoVO systemReplaceInfos(WorkbenchProjectLibReq req ) {
public SystemReplaceInfoVO systemReplaceInfos(WorkbenchProjectLibReq req) {
return workbenchManage.listSystemReplaceInfos(req);
}

@GetMapping("/projectEarlyWarnings")
@ApiOperation("获取项目预警")
public WorkbenchProjectEarlyWarnVO projectEarlyWarnings(WorkbenchReq req) {
return workbenchManage.projectEarlyWarnings(req);
}

}

+ 102
- 4
hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java Vedi File

@@ -1,13 +1,17 @@
package com.hz.pm.api.workbench.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
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.conditions.query.QueryWrapper;
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.constant.ExistsSqlConst;
@@ -36,9 +40,13 @@ import com.hz.pm.api.projectlib.service.IProjectGovSystemReplaceInfosService;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.hz.pm.api.projectlib.service.IProjectStatusChangeService;
import com.hz.pm.api.projectlib.service.IPurchaseStatusChangeService;
import com.hz.pm.api.sys.enumeration.ProjectEarlyWarningStatusEnum;
import com.hz.pm.api.sys.manage.EarlyWarningManage;
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.todocenter.manage.TodoCenterManage;
import com.hz.pm.api.todocenter.model.req.ToBeProcessedReq;
import com.hz.pm.api.todocenter.model.vo.ResToBeProcessedVO;
@@ -51,10 +59,7 @@ import com.hz.pm.api.workbench.converter.WorkbenchConverter;
import com.hz.pm.api.workbench.model.WorkbenchProcessNode;
import com.hz.pm.api.workbench.model.WorkbenchProjectLibReq;
import com.hz.pm.api.workbench.model.WorkbenchReq;
import com.hz.pm.api.workbench.model.vo.ProjectProcessStatVO;
import com.hz.pm.api.workbench.model.vo.ProjectTotalViewVO;
import com.hz.pm.api.workbench.model.vo.SystemReplaceStatVO;
import com.hz.pm.api.workbench.model.vo.WorkbenchVO;
import com.hz.pm.api.workbench.model.vo.*;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.basic.util.StrPool;
@@ -105,6 +110,7 @@ public class WorkbenchManage {
private final MhUnitCache mhUnitCache;
private final IProjectGovSystemReplaceInfosService systemReplaceInfosService;
private final IPurchaseStatusChangeService purchaseStatusChangeService;
private final IProjectEarlyWarningService projectEarlyWarningService;

public WorkbenchVO getWorkbenchData(Integer year) {
WorkbenchVO res = new WorkbenchVO();
@@ -697,4 +703,96 @@ public class WorkbenchManage {
retDetail.setReplaceDetail(retList);
return retDetail;
}

public WorkbenchProjectEarlyWarnVO projectEarlyWarnings(WorkbenchReq req) {
Long unitId = Optional.ofNullable(req.getUnitId()).orElseGet(LoginUserUtil::getMhUnitId);
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(unitId);
List<String> viewUnitIdList = CollUtils.convert(viewUnitIds, String::valueOf);
WorkbenchProjectEarlyWarnVO earlyWarningStat = new WorkbenchProjectEarlyWarnVO();
LambdaQueryWrapper<ProjectEarlyWarning> pageQuery = Wrappers.lambdaQuery(ProjectEarlyWarning.class)
.in(ProjectEarlyWarning::getBuildOrgCode, viewUnitIdList);
QueryWrapper<ProjectEarlyWarning> countQuery = new QueryWrapper<>();
countQuery.select("count(1) \"total\", status \"status\"");
countQuery.in("build_org_code", viewUnitIdList);
if (req.getUnitStrip() != null) {
String unitStripSql = String.format("select 1 from nd_project np where " +
"np.project_code = nd_project_early_warning.project_code " +
" and np.newest = 1 and np.unit_strip = %d", req.getUnitStrip());
countQuery.exists(unitStripSql);
pageQuery.exists(unitStripSql);
}
if (req.getProjectYear() != null) {
LocalDate startDate = LocalDate.of(req.getProjectYear(), 1, 1);
LocalDate endDate = LocalDate.now().plusDays(1);
pageQuery.between(ProjectEarlyWarning::getCreateOn, startDate, endDate);
countQuery.between("create_on", startDate, endDate);
}
countQuery.groupBy("status");
List<Map<String, Object>> counts = projectEarlyWarningService.listMaps(countQuery);
Map<String, Integer> countMap = CollUtils.listToMap(counts,
w -> MapUtil.getStr(w, "status"), w -> MapUtil.getInt(w, "total"));
earlyWarningStat.setOvertime(countMap.getOrDefault(ProjectEarlyWarningStatusEnum.OVER_TIME.name(), 0));
earlyWarningStat.setAdvent(countMap.getOrDefault(ProjectEarlyWarningStatusEnum.ADVENT_TIME.name(), 0));
earlyWarningStat.setTotal(earlyWarningStat.getAdvent() + earlyWarningStat.getOvertime());
if (counts.isEmpty()) {
return earlyWarningStat;
}
if (req.getProjectEarlyWarningStatus() == null) {
pageQuery.in(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.OVER_TIME,
ProjectEarlyWarningStatusEnum.ADVENT_TIME);
} else {
pageQuery.eq(ProjectEarlyWarning::getStatus, req.getProjectEarlyWarningStatus());
}
Page<ProjectEarlyWarning> page = Page.of(1, 500);
if (req.getProjectEarlyWarningStatus() == null) {
pageQuery.in(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.OVER_TIME,
ProjectEarlyWarningStatusEnum.ADVENT_TIME);
} else {
pageQuery.eq(ProjectEarlyWarning::getStatus, req.getProjectEarlyWarningStatus());
}
projectEarlyWarningService.page(page, pageQuery);
if (CollUtil.isNotEmpty(page.getRecords())) {
List<String> projectCodes = CollUtils.fieldList(page.getRecords(), ProjectEarlyWarning::getProjectCode);

Wrapper<WflowEarlyWarningRecords> wewQuery = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class)
.in(WflowEarlyWarningRecords::getProjectCode, projectCodes)
.orderByDesc(WflowEarlyWarningRecords::getWarningTime);
List<WflowEarlyWarningRecords> warningRecords = earlyWarningRecordsService.list(wewQuery);
Set<String> projectCodeSet = Sets.newHashSet();
Map<String, WflowEarlyWarningRecords> warningMap = warningRecords.stream()
.filter(w -> projectCodeSet.add(w.getProjectCode()))
.collect(Collectors.toMap(WflowEarlyWarningRecords::getProjectCode, w -> w));

Wrapper<Project> projectQuery = Wrappers.lambdaQuery(Project.class)
.select(Project::getProjectCode, Project::getProjectName)
.in(Project::getProjectCode, projectCodes)
.eq(Project::getNewest, Boolean.TRUE);
List<Project> projects = projectService.list(projectQuery);
Map<String, String> projectNameMap = projects.stream()
.collect(Collectors.toMap(Project::getProjectCode, Project::getProjectName));

List<ProjectEarlyWarningVO> warnings = page.getRecords().stream().map(o -> {
ProjectEarlyWarningVO vo = BeanUtil.copyProperties(o, ProjectEarlyWarningVO.class);
//取最新一条预警信息
if (warningMap.containsKey(vo.getProjectCode())) {
WflowEarlyWarningRecords wew = warningMap.get(vo.getProjectCode());
vo.setWarningTime(wew.getWarningTime());
vo.setInstStart(wew.getInstStart());
vo.setWarningUserId(wew.getWarningUserId());
vo.setNoticeMethod(wew.getNoticeMethod());
vo.setNoticeContent(wew.getNoticeContent());
vo.setPath(wew.getPath());
vo.setBatchUserIds(wew.getBatchUserIds());
vo.setRecordId(wew.getId());
}
vo.setProjectName(projectNameMap.get(o.getProjectCode()));
return vo;
}).filter(w -> Objects.nonNull(w.getWarningTime()))
.sorted(Comparator.comparing(ProjectEarlyWarningVO::getWarningTime).reversed())
.collect(Collectors.toList());
earlyWarningStat.setProjectEarlyWarnings(warnings);
}
return earlyWarningStat;
}

}

+ 4
- 0
hz-pm-api/src/main/java/com/hz/pm/api/workbench/model/WorkbenchReq.java Vedi File

@@ -1,5 +1,6 @@
package com.hz.pm.api.workbench.model;

import com.hz.pm.api.sys.enumeration.ProjectEarlyWarningStatusEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@@ -21,4 +22,7 @@ public class WorkbenchReq {
@ApiModelProperty("领域")
private Integer unitStrip;

@ApiModelProperty("预警状态")
private ProjectEarlyWarningStatusEnum projectEarlyWarningStatus;

}

+ 29
- 0
hz-pm-api/src/main/java/com/hz/pm/api/workbench/model/vo/WorkbenchProjectEarlyWarnVO.java Vedi File

@@ -0,0 +1,29 @@
package com.hz.pm.api.workbench.model.vo;

import com.hz.pm.api.sys.model.vo.ProjectEarlyWarningVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
* <p>
* ProjectEarlyWarning
* </p>
*
* @author WendyYang
* @since 00:28 2024/8/28
*/
@Data
public class WorkbenchProjectEarlyWarnVO {

private Integer total;

private Integer advent;

private Integer overtime;

@ApiModelProperty("超期项目预警")
private List<ProjectEarlyWarningVO> projectEarlyWarnings;

}

+ 2
- 42
hz-pm-api/src/main/java/com/hz/pm/api/workbench/model/vo/WorkbenchVO.java Vedi File

@@ -3,10 +3,8 @@ package com.hz.pm.api.workbench.model.vo;
import cn.hutool.core.util.ObjectUtil;
import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO;
import com.hz.pm.api.sys.model.vo.NoticeListItemVO;
import com.hz.pm.api.sys.model.vo.ProjectEarlyWarningVO;
import com.hz.pm.api.sys.model.vo.WflowEarlyWarningRecordsVO;
import com.hz.pm.api.todocenter.model.vo.TodoCenterStatisticsVO;
import com.ningdatech.basic.model.PageVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@@ -25,14 +23,6 @@ import java.util.Objects;
@Data
public class WorkbenchVO {

@ApiModelProperty("待办中心统计数据 以及代办处理")
public TodoCenterStatisticsVO todoCerter;

@ApiModelProperty("单位申报管理统计数据")
public DeclaredStatistics orgDeclared;

@ApiModelProperty("区域申报管理统计数据 只有区域管理员才有数据")
public DeclaredStatistics regionDeclared;

@ApiModelProperty("项目动态")
public List<ProjectLibListItemVO> projects;
@@ -40,41 +30,11 @@ public class WorkbenchVO {
@ApiModelProperty("公告列表")
public Map<String, List<NoticeListItemVO>> noticeList;

@ApiModelProperty("预警记录")
public List<EarlyWarning> earlyWarning;
private TodoCenterStatisticsVO todoCerter;

@ApiModelProperty("项目预警记录")
public ProjectEarlyWarning projectEarlyWarning;

@Data
public static class ProjectEarlyWarning {
@ApiModelProperty("统计数据-累积")
private WarningStatistics accumulate;

@ApiModelProperty("统计数据-当前")
private WarningStatistics current;

@ApiModelProperty("超期项目预警")
private PageVo<ProjectEarlyWarningVO> overs;

@ApiModelProperty("临期项目预警")
private PageVo<ProjectEarlyWarningVO> advents;
public WorkbenchProjectEarlyWarnVO workbenchProjectEarlyWarnVO;

@ApiModelProperty("正常项目")
private PageVo<ProjectEarlyWarningVO> normals;
}

@Data
public static class WarningStatistics {
@ApiModelProperty("正常")
private Integer normal = 0;

@ApiModelProperty("临期")
private Integer advent = 0;

@ApiModelProperty("超期")
private Integer over = 0;
}

@Data
public static class EarlyWarning {


Loading…
Annulla
Salva