|
|
@@ -23,12 +23,15 @@ import com.wflow.enums.WarningNoticeTypeEnum; |
|
|
|
import com.wflow.enums.WarningRuleTypeEnum; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
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.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
@@ -62,6 +65,11 @@ public class EarlyWarningStatisticsManage { |
|
|
|
|
|
|
|
public EarlyWarningStatisticsVO statistics(Integer year) { |
|
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
|
|
|
|
|
//项目 |
|
|
|
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(Project::getNewest, Boolean.TRUE)); |
|
|
|
|
|
|
|
EarlyWarningStatisticsVO res = new EarlyWarningStatisticsVO(); |
|
|
|
LambdaQueryWrapper<WflowEarlyWarningRecords> wrapper = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class); |
|
|
|
EarlyWarningUtil.buildPermissonWrapper(wrapper,user); |
|
|
@@ -113,7 +121,7 @@ public class EarlyWarningStatisticsManage { |
|
|
|
for(WarningFlowTypeEnum fillingEnum : WarningFlowTypeEnum.values()){ |
|
|
|
String processName = fillingEnum.getDesc(); |
|
|
|
Integer projectStutas = fillingEnum.getProjectStutas(); |
|
|
|
alarmsFillingNow.add(DataDTO.of(processName,computeFillingNow(projectStutas,records))); |
|
|
|
alarmsFillingNow.add(DataDTO.of(processName,computeFillingNow(projectStutas,records,projects))); |
|
|
|
} |
|
|
|
res.setAlarmsFillingNow(alarmsFillingNow); |
|
|
|
|
|
|
@@ -122,7 +130,7 @@ public class EarlyWarningStatisticsManage { |
|
|
|
for(WarningNoticeTypeEnum noticeTypeEnum : WarningNoticeTypeEnum.values()){ |
|
|
|
String name = noticeTypeEnum.getDesc(); |
|
|
|
Integer noticeType = noticeTypeEnum.getCode(); |
|
|
|
alarmsConstruction.add(DataDTO.of(name,computeConstruction(noticeType,records))); |
|
|
|
alarmsConstruction.add(DataDTO.of(name,computeConstruction(noticeType,records,projects))); |
|
|
|
} |
|
|
|
res.setConstructionAlarms(alarmsConstruction); |
|
|
|
|
|
|
@@ -131,9 +139,9 @@ public class EarlyWarningStatisticsManage { |
|
|
|
//--1 安全设计 |
|
|
|
safetyMonitoring.add(DataDTO.of("安全设计",0)); |
|
|
|
//--2 安全投入低于5% |
|
|
|
safetyMonitoring.add(DataDTO.of("安全投入低于5%",0)); |
|
|
|
safetyMonitoring.add(DataDTO.of("安全投入低于5%",computeSafeLessFive(projects))); |
|
|
|
//--3 非信创 |
|
|
|
safetyMonitoring.add(DataDTO.of("非信创",0)); |
|
|
|
safetyMonitoring.add(DataDTO.of("非信创",computeNotXinChuang(projects))); |
|
|
|
//--4 等保未做 |
|
|
|
safetyMonitoring.add(DataDTO.of("等保未做",0)); |
|
|
|
//--5 密评未做 |
|
|
@@ -142,7 +150,27 @@ public class EarlyWarningStatisticsManage { |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
private Integer computeConstruction(Integer noticeType, List<WflowEarlyWarningRecords> records) { |
|
|
|
//计算非信创 |
|
|
|
private Integer computeNotXinChuang(List<Project> projects) { |
|
|
|
return projects.stream().filter(p -> StringUtils.isNotBlank(p.getCloudType()) && |
|
|
|
!p.getCloudType().contains("2")) |
|
|
|
.collect(Collectors.toList()).size(); |
|
|
|
} |
|
|
|
|
|
|
|
//计算安全投入低于5% |
|
|
|
private Integer computeSafeLessFive(List<Project> projects) { |
|
|
|
return projects.stream().filter(p -> { |
|
|
|
//计算出 安全投入 |
|
|
|
BigDecimal rate = new BigDecimal(DashboardProjectManage.convertSafetyInputRate(p)); |
|
|
|
if (rate.compareTo(new BigDecimal(5)) < 0) { |
|
|
|
return Boolean.TRUE; |
|
|
|
} |
|
|
|
return Boolean.FALSE; |
|
|
|
}).collect(Collectors.toList()).size(); |
|
|
|
} |
|
|
|
|
|
|
|
private Integer computeConstruction(Integer noticeType, List<WflowEarlyWarningRecords> records, |
|
|
|
List<Project> projects) { |
|
|
|
//终验告警 |
|
|
|
List<WflowEarlyWarningRecords> constructionRecords = records.stream().filter(r -> { |
|
|
|
if (Objects.nonNull(r.getRuleType()) && |
|
|
@@ -160,12 +188,26 @@ public class EarlyWarningStatisticsManage { |
|
|
|
WflowEarlyWarningRecords::getProjectCode)); |
|
|
|
|
|
|
|
//待终验的项目 |
|
|
|
List<Project> tobeFinalProjects = projectService.list(Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(Project::getNewest, Boolean.TRUE) |
|
|
|
.eq(Project::getStatus, ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode())); |
|
|
|
List<Project> tobeFinalProjects = projects.stream().filter(p -> { |
|
|
|
if(Objects.nonNull(p.getStatus()) && |
|
|
|
p.getStatus().equals(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode())){ |
|
|
|
return Boolean.TRUE; |
|
|
|
} |
|
|
|
return Boolean.FALSE; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
return tobeFinalProjects.stream().filter(p -> { |
|
|
|
if(recordsMap.containsKey(p.getProjectCode())){ |
|
|
|
List<WflowEarlyWarningRecords> warningRecords = recordsMap.get(p.getProjectCode()); |
|
|
|
//如果是临期的 不能包含有超期的 |
|
|
|
if(noticeType.equals(WarningNoticeTypeEnum.ADVENT.getCode())){ |
|
|
|
for(WflowEarlyWarningRecords warningRecord : warningRecords){ |
|
|
|
if(Objects.isNull(warningRecord.getNoticeType()) || warningRecord.getNoticeType() |
|
|
|
.equals(WarningNoticeTypeEnum.OVER.getCode())){ |
|
|
|
return Boolean.FALSE; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//这个状态有告警 并且 这个项目也是这个类型 |
|
|
|
return Boolean.TRUE; |
|
|
|
} |
|
|
@@ -173,7 +215,8 @@ public class EarlyWarningStatisticsManage { |
|
|
|
}).collect(Collectors.toList()).size(); |
|
|
|
} |
|
|
|
|
|
|
|
private Integer computeFillingNow(Integer projectStutas, List<WflowEarlyWarningRecords> records) { |
|
|
|
private Integer computeFillingNow(Integer projectStutas, List<WflowEarlyWarningRecords> records, |
|
|
|
List<Project> projects) { |
|
|
|
List<WflowEarlyWarningRecords> fillingRecords = records.stream().filter(r -> { |
|
|
|
if (Objects.nonNull(r.getRuleType()) && |
|
|
|
WarningRuleTypeEnum.DECLARED_WARNING.getCode().equals(r.getRuleType())) { |
|
|
@@ -187,9 +230,12 @@ public class EarlyWarningStatisticsManage { |
|
|
|
Map<String, List<WflowEarlyWarningRecords>> warningMap = fillingRecords.stream() |
|
|
|
.collect(Collectors.groupingBy(WflowEarlyWarningRecords::getProjectCode)); |
|
|
|
|
|
|
|
List<Project> thisStatusProjects = projectService.list(Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(Project::getNewest, Boolean.TRUE) |
|
|
|
.eq(Project::getStatus, projectStutas)); |
|
|
|
List<Project> thisStatusProjects = projects.stream().filter(p -> { |
|
|
|
if(Objects.nonNull(p.getStatus()) && p.getStatus().equals(projectStutas)){ |
|
|
|
return Boolean.TRUE; |
|
|
|
} |
|
|
|
return Boolean.FALSE; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
return thisStatusProjects.stream().filter(p -> { |
|
|
|
if(warningMap.containsKey(p.getProjectCode())){ |
|
|
|