Browse Source

列表 参数问题 debug

master
PoffyZhang 11 months ago
parent
commit
62507dfea5
5 changed files with 264 additions and 31 deletions
  1. +150
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/EarlyWarningStatisticsManage.java
  2. +17
    -14
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/EarlyWarningStatisticsVO.java
  3. +15
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/mapper/ProjectMapper.xml
  4. +64
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/utils/EarlyWarningUtil.java
  5. +18
    -17
      pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java

+ 150
- 0
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/EarlyWarningStatisticsManage.java View File

@@ -1,10 +1,36 @@
package com.ningdatech.pmapi.dashboard.manage;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum;
import com.ningdatech.pmapi.common.model.entity.DataDTO;
import com.ningdatech.pmapi.dashboard.model.vo.EarlyWarningStatisticsVO;
import com.ningdatech.pmapi.projectlib.enumeration.WarningFlowTypeEnum;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst;
import com.ningdatech.pmapi.projectlib.service.IProjectInstService;
import com.ningdatech.pmapi.sys.model.entity.WflowEarlyWarningRecords;
import com.ningdatech.pmapi.sys.service.IEarlyWarningRecordsService;
import com.ningdatech.pmapi.sys.utils.EarlyWarningUtil;
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import com.wflow.enums.WarningRuleTypeEnum;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.HistoryService;
import org.flowable.engine.TaskService;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.task.api.Task;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

/**
* @Classname EarlyWarningStatisticsManage
* @Description
@@ -16,13 +42,137 @@ import org.springframework.stereotype.Component;
@Slf4j
public class EarlyWarningStatisticsManage {

private final IEarlyWarningRecordsService earlyWarningRecordsService;

private final HistoryService historyService;

private final IProjectInstService projectInstService;

private final TaskService taskService;

private static final List<Integer> threeYears = Lists.newArrayList(LocalDateTime.now().getYear() - 2,
LocalDateTime.now().getYear() - 1,LocalDateTime.now().getYear());

public EarlyWarningStatisticsVO statistics(Integer year) {
UserInfoDetails user = LoginUserUtil.loginUserDetail();
EarlyWarningStatisticsVO res = new EarlyWarningStatisticsVO();
LambdaQueryWrapper<WflowEarlyWarningRecords> wrapper = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class);
EarlyWarningUtil.buildPermissonWrapper(wrapper,user);
List<WflowEarlyWarningRecords> records = earlyWarningRecordsService.list(wrapper);
//累积总告警数
res.setAccumulatedAlarmsTotal(records.size());
res.setAccumulatedAlarmsFlow(records.stream().filter(a -> {
if (Objects.nonNull(a.getRuleType()) &&
a.getRuleType().equals(WarningRuleTypeEnum.PROCESS_WARNING.getCode())) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}).collect(Collectors.toList()).size());
res.setAccumulatedAlarmsFilling(records.stream().filter(a -> {
if (Objects.nonNull(a.getRuleType()) &&
a.getRuleType().equals(WarningRuleTypeEnum.DECLARED_WARNING.getCode())) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}).collect(Collectors.toList()).size());

//近三年
List<DataDTO> threeYearsAlarms = Lists.newArrayList();
for(Integer thisYear : threeYears){
DataDTO yearData = new DataDTO();
yearData.setName(thisYear.toString());
yearData.setNum(records.stream().filter(r -> {
if(Objects.nonNull(r.getWarningTime()) &&
thisYear.equals(r.getWarningTime().getYear())){
return Boolean.TRUE;
}
return Boolean.FALSE;
}).collect(Collectors.toList()).size());
threeYearsAlarms.add(yearData);
}
res.setThreeYearsAlarms(threeYearsAlarms);

//当前各流程报警数
List<DataDTO> alarmsFlowsNow = Lists.newArrayList();
for(ProjectProcessStageEnum stageEnum : ProjectProcessStageEnum.values()){
DataDTO flowData = new DataDTO();
String processName = stageEnum.getDesc();
Integer processType = stageEnum.getCode();
flowData.setName(processName);
flowData.setCode(processType.toString());
flowData.setNum(computeFlowWarningNow(processType,records));
alarmsFlowsNow.add(flowData);
}
res.setAlarmsFlowsNow(alarmsFlowsNow);

//当前各填报报警数
List<DataDTO> alarmsFillingNow = Lists.newArrayList();
for(WarningFlowTypeEnum fillingEnum : WarningFlowTypeEnum.values()){
DataDTO fillingData = new DataDTO();
String processName = fillingEnum.getDesc();
Integer processType = fillingEnum.getCode();
fillingData.setName(processName);
fillingData.setCode(processType.toString());
fillingData.setNum(computeFlowWarningNow(processType,records));
alarmsFillingNow.add(fillingData);
}
res.setAlarmsFillingNow(alarmsFillingNow);

return res;
}

//计算某个流程当前正在告警的数量
private Integer computeFlowWarningNow(Integer processType,List<WflowEarlyWarningRecords> records) {
List<WflowEarlyWarningRecords> processRecords = records.stream().filter(r -> {
if (Objects.nonNull(r.getRuleType()) &&
WarningRuleTypeEnum.PROCESS_WARNING.getCode().equals(r.getRuleType())) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}).filter(r -> Objects.nonNull(r.getNodeId())).collect(Collectors.toList());
if(CollUtil.isEmpty(processRecords)){
return 0;
}
Map<String, List<WflowEarlyWarningRecords>> warningMap = processRecords.stream()
.collect(Collectors.groupingBy(WflowEarlyWarningRecords::getNodeId));

//1.先查出 所育 这个类型的 流程
List<ProjectInst> proInsts = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class)
.eq(ProjectInst::getInstType, processType));
if(CollUtil.isEmpty(proInsts)){
return 0;
}
//2.再筛选一下 选出 正在审核 未完成的
Set<String> instCodes = proInsts.stream().map(ProjectInst::getInstCode)
.collect(Collectors.toSet());
List<HistoricProcessInstance> processes = historyService.createHistoricProcessInstanceQuery()
.processInstanceIds(instCodes)
.unfinished()
.orderByProcessInstanceStartTime()
.asc()
.list();
if(CollUtil.isEmpty(processes)){
return 0;
}
//查出所有正在执行的工作流任务
List<Task> tasks = taskService.createTaskQuery()
.list();
if(CollUtil.isEmpty(tasks)){
return 0;
}
Map<String, List<Task>> taskMap = tasks.stream()
.collect(Collectors.groupingBy(Task::getProcessInstanceId));
return processes.stream().filter(p -> {
if(taskMap.containsKey(p.getId())){
List<Task> tasksThis = taskMap.get(p.getId());
for(Task taskThis : tasksThis){
//说明 当前有告警
if(warningMap.containsKey(taskThis.getTaskDefinitionKey())){
return Boolean.TRUE;
}
}
}
return Boolean.FALSE;
}).collect(Collectors.toList()).size();
}
}

+ 17
- 14
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/EarlyWarningStatisticsVO.java View File

@@ -14,24 +14,27 @@ import java.util.List;
public class EarlyWarningStatisticsVO implements Serializable {
private static final long serialVersionUID = 1L;

@ApiModelProperty("评审召开总数")
private Integer meetingTotal = 0;
@ApiModelProperty("累积报警数")
private Integer accumulatedAlarmsTotal = 0;

@ApiModelProperty("评审通过数")
private Integer passReview = 0;
@ApiModelProperty("流程累积报警数")
private Integer accumulatedAlarmsFlow = 0;

@ApiModelProperty("评审不通过率")
private BigDecimal notPassRate = BigDecimal.ZERO;
@ApiModelProperty("填报累积报警数")
private Integer accumulatedAlarmsFilling = 0;

@ApiModelProperty("各区县召开总数")
private List<DataDTO> regionMeetings;
@ApiModelProperty("近三年累积报警数")
private List<DataDTO> threeYearsAlarms;

@ApiModelProperty("预审/验收 会议情况")
private List<DataDTO> meetingTypes;
@ApiModelProperty("当前各流程报警情况")
private List<DataDTO> alarmsFlowsNow;

@ApiModelProperty("各区县不通过率")
private List<DataDTO> notPassRegionMeetings;
@ApiModelProperty("当前各填报报警情况")
private List<DataDTO> alarmsFillingNow;

@ApiModelProperty("各部门不通过top10")
private List<DataDTO> notPassTop10;
@ApiModelProperty("建设周期预警监测")
private List<DataDTO> constructionAlarms;

@ApiModelProperty("安全监测")
private List<DataDTO> safetyMonitoring;
}

+ 15
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/mapper/ProjectMapper.xml View File

@@ -68,6 +68,9 @@
<if test="req.buildOrgName != null and req.buildOrgName != ''">
and p.build_org_name like concat('%',#{req.buildOrgName},'%')
</if>
<if test="req.buildOrg != null and req.buildOrg != ''">
and p.build_org_name like concat('%',#{req.buildOrg},'%')
</if>
<if test="req.status != null">
and p.status = #{req.status}
</if>
@@ -156,6 +159,9 @@
<if test="req.buildOrgName != null and req.buildOrgName != ''">
and b.base_build_deprt like concat('%',#{req.buildOrgName},'%')
</if>
<if test="req.buildOrg != null and req.buildOrg != ''">
and b.base_build_deprt like concat('%',#{req.buildOrg},'%')
</if>
<if test="req.status != null">
and b.base_proj_set_prog = #{req.status}
</if>
@@ -244,6 +250,9 @@
<if test="req.buildOrgName != null and req.buildOrgName != ''">
and b.base_build_deprt like concat('%',#{req.buildOrgName},'%')
</if>
<if test="req.buildOrg != null and req.buildOrg != ''">
and b.base_build_deprt like concat('%',#{req.buildOrg},'%')
</if>
<if test="req.status != null">
and b.base_proj_set_prog = #{req.status}
</if>
@@ -356,6 +365,9 @@
<if test="req.buildOrgName != null and req.buildOrgName != ''">
and p.build_org_name like concat('%',#{req.buildOrgName},'%')
</if>
<if test="req.buildOrg != null and req.buildOrg != ''">
and p.build_org_name like concat('%',#{req.buildOrg},'%')
</if>
<if test="req.status != null">
and p.status = #{req.status}
</if>
@@ -444,6 +456,9 @@
<if test="req.buildOrgName != null and req.buildOrgName != ''">
and b.base_build_deprt like concat('%',#{req.buildOrgName},'%')
</if>
<if test="req.buildOrg != null and req.buildOrg != ''">
and b.base_build_deprt like concat('%',#{req.buildOrg},'%')
</if>
<if test="req.status != null">
and b.base_proj_set_prog = #{req.status}
</if>


+ 64
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/utils/EarlyWarningUtil.java View File

@@ -0,0 +1,64 @@
package com.ningdatech.pmapi.sys.utils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.sys.model.entity.WflowEarlyWarningRecords;
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO;
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;

/**
* @Classname EarlyWarningUtil
* @Description
* @Date 2023/12/7 14:14
* @Author PoffyZhang
*/
public class EarlyWarningUtil {

public static void buildPermissonWrapper(LambdaQueryWrapper<WflowEarlyWarningRecords> wrapper,
UserInfoDetails user) {
//如果是超管的话
if(user.getSuperAdmin()){
//可以看所有
//如果是区管
}else if(user.getRegionAdmin()){
wrapper.eq(WflowEarlyWarningRecords::getAreaCode,user.getRegionCode());
}else if(user.getIsOrgAdmin()){
wrapper.eq(WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode());
}else{
//否则都只能看自己单位的
wrapper.eq(WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode());
}
}

public static void buildPermissonFullWrapper(LambdaQueryWrapper<WflowEarlyWarningRecords> wrapper,
UserFullInfoDTO user) {
//如果是超管的话
if(user.getSuperAdmin()){
//可以看所有
//如果是区管
}else if(user.getRegionAdmin()){
wrapper.eq(WflowEarlyWarningRecords::getAreaCode,user.getRegionCode());
}else if(user.getIsOrgAdmin()){
wrapper.eq(WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode());
}else{
//否则都只能看自己单位的
wrapper.eq(WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode());
}
}

public static void buildPermissonProjectWrapper(LambdaQueryWrapper<Project> wrapper,
UserFullInfoDTO user) {
//如果是超管的话
if(user.getSuperAdmin()){
//可以看所有
//如果是区管
}else if(user.getRegionAdmin()){
wrapper.eq(Project::getAreaCode,user.getRegionCode());
}else if(user.getIsOrgAdmin()){
wrapper.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode());
}else{
//否则都只能看自己单位的
wrapper.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode());
}
}
}

+ 18
- 17
pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java View File

@@ -26,6 +26,7 @@ import com.ningdatech.pmapi.sys.model.req.NoticeListReq;
import com.ningdatech.pmapi.sys.model.vo.ProjectEarlyWarningVO;
import com.ningdatech.pmapi.sys.service.IEarlyWarningRecordsService;
import com.ningdatech.pmapi.sys.service.IProjectEarlyWarningService;
import com.ningdatech.pmapi.sys.utils.EarlyWarningUtil;
import com.ningdatech.pmapi.todocenter.manage.TodoCenterManage;
import com.ningdatech.pmapi.todocenter.model.req.ToBeProcessedReq;
import com.ningdatech.pmapi.todocenter.model.vo.TodoCenterStatisticsVO;
@@ -40,6 +41,7 @@ import com.wflow.service.IEarlyWarningService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.record.DVALRecord;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
@@ -157,11 +159,10 @@ public class WorkbenchManage {

private WorkbenchVO.ProjectEarlyWarning getProjectEarlyWarning(UserFullInfoDTO user) {
WorkbenchVO.ProjectEarlyWarning projectEarlyWarning = new WorkbenchVO.ProjectEarlyWarning();

List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getNewest, Boolean.TRUE)
.eq(user.getRegionAdmin()&&!user.getSuperAdmin(),Project::getAreaCode,user.getRegionCode())
.eq((user.getIsOrgAdmin()&&!user.getSuperAdmin()) || user.notAdmin(),Project::getBuildOrgCode,user.getEmpPosUnitCode()));
LambdaQueryWrapper<Project> projectWrapper = Wrappers.lambdaQuery(Project.class)
.eq(Project::getNewest, Boolean.TRUE);
EarlyWarningUtil.buildPermissonProjectWrapper(projectWrapper,user);
List<Project> projects = projectService.list(projectWrapper);
Set<String> projectCodeS = Sets.newHashSet();
Map<String,String> projectNameMap = projects.stream()
.filter(p -> projectCodeS.add(p.getProjectCode()))
@@ -170,16 +171,16 @@ public class WorkbenchManage {
//4.1
//累积预警统计
WorkbenchVO.WarningStatistics accumulate = new WorkbenchVO.WarningStatistics();
Long overCount = earlyWarningRecordsService.count(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class)
LambdaQueryWrapper<WflowEarlyWarningRecords> overWrapper = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class)
.eq(WflowEarlyWarningRecords::getNoticeType, WarningNoticeTypeEnum.OVER.getCode())
.or(q2 -> q2.isNull(WflowEarlyWarningRecords::getNoticeType))
.eq(user.getRegionAdmin()&&!user.getSuperAdmin(),WflowEarlyWarningRecords::getAreaCode,user.getRegionCode())
.eq((user.getIsOrgAdmin()&&!user.getSuperAdmin()) || user.notAdmin(),WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode()));
.or(q2 -> q2.isNull(WflowEarlyWarningRecords::getNoticeType));
EarlyWarningUtil.buildPermissonFullWrapper(overWrapper,user);
Long overCount = earlyWarningRecordsService.count(overWrapper);
accumulate.setOver(overCount.intValue());
Long adventCount = earlyWarningRecordsService.count(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class)
.eq(WflowEarlyWarningRecords::getNoticeType, WarningNoticeTypeEnum.ADVENT.getCode())
.eq(user.getRegionAdmin(),WflowEarlyWarningRecords::getAreaCode,user.getRegionCode())
.eq((user.getIsOrgAdmin()&&!user.getSuperAdmin()) || user.notAdmin(),WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode()));
LambdaQueryWrapper<WflowEarlyWarningRecords> adventWrapper = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class)
.eq(WflowEarlyWarningRecords::getNoticeType, WarningNoticeTypeEnum.ADVENT.getCode());
EarlyWarningUtil.buildPermissonFullWrapper(adventWrapper,user);
Long adventCount = earlyWarningRecordsService.count(adventWrapper);
accumulate.setAdvent(adventCount.intValue());
projectEarlyWarning.setAccumulate(accumulate);

@@ -189,16 +190,16 @@ public class WorkbenchManage {
Page<ProjectEarlyWarning> overPage = Page.of(1,1000);
Page<ProjectEarlyWarning> adventPage = Page.of(1,1000);
Page<ProjectEarlyWarning> normalPage = Page.of(1,1000);
LambdaQueryWrapper<ProjectEarlyWarning> overWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class)
LambdaQueryWrapper<ProjectEarlyWarning> overPWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class)
.eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.OVER_TIME.name())
.eq(user.getRegionAdmin()&&!user.getSuperAdmin(),ProjectEarlyWarning::getAreaCode,user.getRegionCode())
.eq((user.getIsOrgAdmin()&&!user.getSuperAdmin()) || user.notAdmin(),ProjectEarlyWarning::getBuildOrgCode,user.getEmpPosUnitCode());
projectEarlyWarningService.page(overPage,overWrapper);
LambdaQueryWrapper<ProjectEarlyWarning> adventWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class)
projectEarlyWarningService.page(overPage,overPWrapper);
LambdaQueryWrapper<ProjectEarlyWarning> adventPWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class)
.eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.ADVENT_TIME.name())
.eq(user.getRegionAdmin()&&!user.getSuperAdmin(),ProjectEarlyWarning::getAreaCode,user.getRegionCode())
.eq((user.getIsOrgAdmin()&&!user.getSuperAdmin()) || user.notAdmin(),ProjectEarlyWarning::getBuildOrgCode,user.getEmpPosUnitCode());
projectEarlyWarningService.page(adventPage,adventWrapper);
projectEarlyWarningService.page(adventPage,adventPWrapper);
LambdaQueryWrapper<ProjectEarlyWarning> normalWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class)
.eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.NORMAL.name())
.eq(user.getRegionAdmin()&&!user.getSuperAdmin(),ProjectEarlyWarning::getAreaCode,user.getRegionCode())


Loading…
Cancel
Save