Browse Source

debug 驾驶舱算法

master
PoffyZhang 1 year ago
parent
commit
c2a0198891
2 changed files with 28 additions and 4 deletions
  1. +27
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/handle/CockpitStatsHandler.java
  2. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/CockpitStatsManage.java

+ 27
- 3
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/handle/CockpitStatsHandler.java View File

@@ -12,9 +12,11 @@ import com.ningdatech.pmapi.dashboard.service.ICockpitStatsService;
import com.ningdatech.pmapi.sys.model.dto.RegionDTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
@@ -36,14 +38,16 @@ public class CockpitStatsHandler {

private final ICockpitStatsService cockpitStatsService;

public CockpitStatsVO convertCockpitStats(CockpitStats cockpitStats,Integer year) {
private static final List<Integer> years = Lists.newArrayList(2021,2022,2023,2024);

public CockpitStatsVO convertCockpitStats(CockpitStats cockpitStats,String regionCode,Integer year) {
CockpitStatsVO res = BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.class);

if(Objects.isNull(cockpitStats)){
return res;
}
//监测数据
res.setMonitorData(convertMonitor(cockpitStats));
res.setMonitorData(convertMonitor(cockpitStats,regionCode));
//专家数据
res.setExpertData(convertExpertData(cockpitStats));
//顶部数据
@@ -163,13 +167,33 @@ public class CockpitStatsHandler {
return regionData;
}

private CockpitStatsVO.Monitor convertMonitor(CockpitStats cockpitStats) {
private CockpitStatsVO.Monitor convertMonitor(CockpitStats cockpitStats,String regionCode) {
CockpitStatsVO.Monitor monitor = BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.Monitor.class);
monitor.setPasswordGradeCharts(buidPasswordGradeCharts(cockpitStats));
monitor.setSecrecyGradeCharts(buidSecrecyGradeCharts(cockpitStats));
monitor.setMonitorSafetyInputRate(computeSafetyRate(regionCode));
return monitor;
}

/**
* 安全投入 比 图
* @param regionCode
* @return
*/
private List<CockpitStatsVO.SafetyInput> computeSafetyRate(String regionCode) {
List<CockpitStats> cocks = cockpitStatsService.list(Wrappers.lambdaQuery(CockpitStats.class)
.eq(StringUtils.isNotBlank(regionCode), CockpitStats::getRegionCode, regionCode)
.eq(StringUtils.isBlank(regionCode), CockpitStats::getRegionCode, DashboardConstant.CockpitStats.TOTAL)
.in(CockpitStats::getYear, years));
return cocks.stream().map(c -> {
CockpitStatsVO.SafetyInput safetyInput = new CockpitStatsVO.SafetyInput();
safetyInput.setYear(c.getYear());
safetyInput.setRate(Objects.nonNull(c.getMonitorDeclaredAmount()) ?
c.getMonitorSafetyInputAmount().divide(c.getMonitorDeclaredAmount(),2, RoundingMode.CEILING): BigDecimal.ZERO);
return safetyInput;
}).collect(Collectors.toList());
}

private List<CockpitStatsVO.SecrecyGradeChart> buidSecrecyGradeCharts(CockpitStats cockpitStats) {
List<CockpitStatsVO.SecrecyGradeChart> chars = Lists.newArrayList();
chars.add(new CockpitStatsVO.SecrecyGradeChart(1,cockpitStats.getMonitorSecrecyGrade1Num()));


+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/CockpitStatsManage.java View File

@@ -47,6 +47,6 @@ public class CockpitStatsManage {
return new CockpitStatsVO();
}

return convertCockpitStats.convertCockpitStats(cockpitStats,year);
return convertCockpitStats.convertCockpitStats(cockpitStats,regionCode,year);
}
}

Loading…
Cancel
Save