|
@@ -12,9 +12,11 @@ import com.ningdatech.pmapi.dashboard.service.ICockpitStatsService; |
|
|
import com.ningdatech.pmapi.sys.model.dto.RegionDTO; |
|
|
import com.ningdatech.pmapi.sys.model.dto.RegionDTO; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
|
|
|
import java.math.RoundingMode; |
|
|
import java.util.Comparator; |
|
|
import java.util.Comparator; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
@@ -36,14 +38,16 @@ public class CockpitStatsHandler { |
|
|
|
|
|
|
|
|
private final ICockpitStatsService cockpitStatsService; |
|
|
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); |
|
|
CockpitStatsVO res = BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.class); |
|
|
|
|
|
|
|
|
if(Objects.isNull(cockpitStats)){ |
|
|
if(Objects.isNull(cockpitStats)){ |
|
|
return res; |
|
|
return res; |
|
|
} |
|
|
} |
|
|
//监测数据 |
|
|
//监测数据 |
|
|
res.setMonitorData(convertMonitor(cockpitStats)); |
|
|
|
|
|
|
|
|
res.setMonitorData(convertMonitor(cockpitStats,regionCode)); |
|
|
//专家数据 |
|
|
//专家数据 |
|
|
res.setExpertData(convertExpertData(cockpitStats)); |
|
|
res.setExpertData(convertExpertData(cockpitStats)); |
|
|
//顶部数据 |
|
|
//顶部数据 |
|
@@ -163,13 +167,33 @@ public class CockpitStatsHandler { |
|
|
return regionData; |
|
|
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); |
|
|
CockpitStatsVO.Monitor monitor = BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.Monitor.class); |
|
|
monitor.setPasswordGradeCharts(buidPasswordGradeCharts(cockpitStats)); |
|
|
monitor.setPasswordGradeCharts(buidPasswordGradeCharts(cockpitStats)); |
|
|
monitor.setSecrecyGradeCharts(buidSecrecyGradeCharts(cockpitStats)); |
|
|
monitor.setSecrecyGradeCharts(buidSecrecyGradeCharts(cockpitStats)); |
|
|
|
|
|
monitor.setMonitorSafetyInputRate(computeSafetyRate(regionCode)); |
|
|
return monitor; |
|
|
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) { |
|
|
private List<CockpitStatsVO.SecrecyGradeChart> buidSecrecyGradeCharts(CockpitStats cockpitStats) { |
|
|
List<CockpitStatsVO.SecrecyGradeChart> chars = Lists.newArrayList(); |
|
|
List<CockpitStatsVO.SecrecyGradeChart> chars = Lists.newArrayList(); |
|
|
chars.add(new CockpitStatsVO.SecrecyGradeChart(1,cockpitStats.getMonitorSecrecyGrade1Num())); |
|
|
chars.add(new CockpitStatsVO.SecrecyGradeChart(1,cockpitStats.getMonitorSecrecyGrade1Num())); |
|
|