bug修改
This commit is contained in:
parent
3d95bb3c91
commit
c8dafceaff
@ -279,7 +279,7 @@ public class XzRiskPredictionController {
|
|||||||
BigDecimal riskScore = this.getRiskScore(projectSn, date, enterpriseIds, safeInspections);
|
BigDecimal riskScore = this.getRiskScore(projectSn, date, enterpriseIds, safeInspections);
|
||||||
BigDecimal aiScore = this.getAiScore(projectSn, date, aiAnalyseHardWareAlarmRecords, enterpriseIds, hardwareIds, aiAnalyseHardWareAlarmRecordLastMonths);
|
BigDecimal aiScore = this.getAiScore(projectSn, date, aiAnalyseHardWareAlarmRecords, enterpriseIds, hardwareIds, aiAnalyseHardWareAlarmRecordLastMonths);
|
||||||
BigDecimal total = hiddenDangerScore.add(dangerEngScore).add(riskScore).add(aiScore).add(new BigDecimal(30)).setScale(0, RoundingMode.HALF_UP);
|
BigDecimal total = hiddenDangerScore.add(dangerEngScore).add(riskScore).add(aiScore).add(new BigDecimal(30)).setScale(0, RoundingMode.HALF_UP);
|
||||||
o.setMonthlySafetyScoreRiskRate(NumberUtils.subtract(1D, NumberUtils.div(total.doubleValue(), 100D, 2)));
|
o.setMonthlySafetyScoreRate(NumberUtils.subtract(1D, NumberUtils.div(total.doubleValue(), 100D, 2), 2));
|
||||||
|
|
||||||
o.setTotalPersonnelRiskRate(Optional.ofNullable(enterpriseIdForWorkerRiskMap.get(mainEnterprise.getId())).map(map -> NumberUtils.div(MapUtils.getDouble(map, "area"), 100.0, 2)).orElse(0.0));
|
o.setTotalPersonnelRiskRate(Optional.ofNullable(enterpriseIdForWorkerRiskMap.get(mainEnterprise.getId())).map(map -> NumberUtils.div(MapUtils.getDouble(map, "area"), 100.0, 2)).orElse(0.0));
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ public class XzRiskPredictionController {
|
|||||||
o.setUnclosedHiddenDangersRate(NumberUtils.div(inspectionNotCount, inspectionCount, 2));
|
o.setUnclosedHiddenDangersRate(NumberUtils.div(inspectionNotCount, inspectionCount, 2));
|
||||||
o.setEnterpriseId(mainEnterprise.getId());
|
o.setEnterpriseId(mainEnterprise.getId());
|
||||||
o.setEnterpriseName(mainEnterprise.getEnterpriseName());
|
o.setEnterpriseName(mainEnterprise.getEnterpriseName());
|
||||||
o.setArea(NumberUtils.percent(PolygonUtil.calRadioArea(1.0, 5, o.getSevereWeatherRate(), o.getUnclosedHiddenDangersRate(), o.getMonthlySafetyScoreRiskRate(), o.getTotalSpecialOperationsRiskRate(), o.getTotalPersonnelRiskRate()), 2));
|
o.setArea(NumberUtils.percent(PolygonUtil.calRadioArea(1.0, 5, o.getSevereWeatherRate(), o.getUnclosedHiddenDangersRate(), o.getMonthlySafetyScoreRate(), o.getTotalSpecialOperationsRiskRate(), o.getTotalPersonnelRiskRate()), 2));
|
||||||
rtList.add(o);
|
rtList.add(o);
|
||||||
}
|
}
|
||||||
return Result.success(rtList);
|
return Result.success(rtList);
|
||||||
@ -462,11 +462,11 @@ public class XzRiskPredictionController {
|
|||||||
long specialCount = inspectionRecords.stream().filter(r -> r.getType() != null && r.getType() != 1).count();
|
long specialCount = inspectionRecords.stream().filter(r -> r.getType() != null && r.getType() != 1).count();
|
||||||
o.setTotalSpecialOperationsRiskRate(NumberUtils.div(specialNotCount, specialCount, 2));
|
o.setTotalSpecialOperationsRiskRate(NumberUtils.div(specialNotCount, specialCount, 2));
|
||||||
JSONObject ssJo = BeanUtil.toBean(securityQualityInspectionRecordController.getStatScore(projectSn), JSONObject.class);
|
JSONObject ssJo = BeanUtil.toBean(securityQualityInspectionRecordController.getStatScore(projectSn), JSONObject.class);
|
||||||
o.setMonthlySafetyScoreRiskRate(NumberUtils.subtract(1D, NumberUtils.div(ssJo.getJSONObject("result").getDouble("total"), 100D, 2)));
|
o.setMonthlySafetyScoreRate(NumberUtils.subtract(1D, NumberUtils.div(ssJo.getJSONObject("result").getDouble("total"), 100D, 2), 2));
|
||||||
long inspectionCount = inspectionRecords.stream().filter(r -> true).count();
|
long inspectionCount = inspectionRecords.stream().filter(r -> true).count();
|
||||||
long inspectionNotCount = inspectionRecords.stream().filter(r -> r.getStatus() != 5).count();
|
long inspectionNotCount = inspectionRecords.stream().filter(r -> r.getStatus() != 5).count();
|
||||||
o.setUnclosedHiddenDangersRate(NumberUtils.div(inspectionNotCount, inspectionCount, 2));
|
o.setUnclosedHiddenDangersRate(NumberUtils.div(inspectionNotCount, inspectionCount, 2));
|
||||||
o.setArea(NumberUtils.percent(PolygonUtil.calRadioArea(1.0, 5, o.getSevereWeatherRate(), o.getUnclosedHiddenDangersRate(), o.getMonthlySafetyScoreRiskRate(), o.getTotalSpecialOperationsRiskRate(), o.getTotalPersonnelRiskRate()), 2));
|
o.setArea(NumberUtils.percent(PolygonUtil.calRadioArea(1.0, 5, o.getSevereWeatherRate(), o.getUnclosedHiddenDangersRate(), o.getMonthlySafetyScoreRate(), o.getTotalSpecialOperationsRiskRate(), o.getTotalPersonnelRiskRate()), 2));
|
||||||
return Result.success(o);
|
return Result.success(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -741,7 +741,14 @@ public class XzRiskPredictionController {
|
|||||||
// 安全评分
|
// 安全评分
|
||||||
List<WorkerInfo> list = workerInfoService.list(Wrappers.<WorkerInfo>lambdaQuery().eq(WorkerInfo::getProjectSn, projectSn).eq(WorkerInfo::getInserviceType, 1));
|
List<WorkerInfo> list = workerInfoService.list(Wrappers.<WorkerInfo>lambdaQuery().eq(WorkerInfo::getProjectSn, projectSn).eq(WorkerInfo::getInserviceType, 1));
|
||||||
Double safeScore = list.stream().mapToDouble(e -> e.getSafeScore()).sum();
|
Double safeScore = list.stream().mapToDouble(e -> e.getSafeScore()).sum();
|
||||||
resultMap.put("safe", list.size() == 0 ? null : new BigDecimal(1).subtract(new BigDecimal(safeScore).divide(new BigDecimal(100)).divide(new BigDecimal(list.size()), 2, BigDecimal.ROUND_HALF_UP)));
|
BigDecimal safe = null;
|
||||||
|
if (list.size() != 0) {
|
||||||
|
safe = new BigDecimal(1).subtract(new BigDecimal(safeScore).divide(new BigDecimal(100)).divide(new BigDecimal(list.size()), 2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
if (safe.compareTo(BigDecimal.valueOf(0)) < 0) {
|
||||||
|
safe = BigDecimal.valueOf(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resultMap.put("safe", safe);
|
||||||
// 一级二级分险占比
|
// 一级二级分险占比
|
||||||
if (records.size() > 0) {
|
if (records.size() > 0) {
|
||||||
long inspectionCount = records.stream().filter(x -> x.getLevel() == 1 || x.getLevel() == 2).count();
|
long inspectionCount = records.stream().filter(x -> x.getLevel() == 1 || x.getLevel() == 2).count();
|
||||||
@ -804,7 +811,14 @@ public class XzRiskPredictionController {
|
|||||||
// 安全评分
|
// 安全评分
|
||||||
List<WorkerInfo> list = allWorkerList.stream().filter(a -> enterpriseIds.contains(a.getEnterpriseId())).collect(Collectors.toList());
|
List<WorkerInfo> list = allWorkerList.stream().filter(a -> enterpriseIds.contains(a.getEnterpriseId())).collect(Collectors.toList());
|
||||||
Double safeScore = list.stream().mapToDouble(e -> e.getSafeScore()).sum();
|
Double safeScore = list.stream().mapToDouble(e -> e.getSafeScore()).sum();
|
||||||
resultMap.put("safe", list.size() == 0 ? null : new BigDecimal(1).subtract(new BigDecimal(safeScore).divide(new BigDecimal(100)).divide(new BigDecimal(list.size()), 2, BigDecimal.ROUND_HALF_UP)));
|
BigDecimal safe = null;
|
||||||
|
if (list.size() != 0) {
|
||||||
|
safe = new BigDecimal(1).subtract(new BigDecimal(safeScore).divide(new BigDecimal(100)).divide(new BigDecimal(list.size()), 2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
if (safe.compareTo(BigDecimal.valueOf(0)) < 0) {
|
||||||
|
safe = BigDecimal.valueOf(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resultMap.put("safe", safe);
|
||||||
// 一级二级分险占比
|
// 一级二级分险占比
|
||||||
if (xzSecurityQualityInspectionRecords.size() > 0) {
|
if (xzSecurityQualityInspectionRecords.size() > 0) {
|
||||||
long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getLevel() == 1 || x.getLevel() == 2).count();
|
long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getLevel() == 1 || x.getLevel() == 2).count();
|
||||||
|
|||||||
@ -37,7 +37,7 @@ public class RiskTrendByMainEnterpriseVo {
|
|||||||
* 月度安全评分风险
|
* 月度安全评分风险
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty("月度安全评分风险")
|
@ApiModelProperty("月度安全评分风险")
|
||||||
private Double monthlySafetyScoreRiskRate;
|
private Double monthlySafetyScoreRate;
|
||||||
/**
|
/**
|
||||||
* 未闭合隐患占比
|
* 未闭合隐患占比
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -258,9 +258,6 @@ public class NumberUtils {
|
|||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
System.out.println(randomNum(6));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取字符串中的第一个数字
|
* 获取字符串中的第一个数字
|
||||||
@ -314,6 +311,19 @@ public class NumberUtils {
|
|||||||
if (b1 == null || b2 == null) {
|
if (b1 == null || b2 == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return b1 - b2;
|
return NumberUtil.sub(b1, b2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 相减
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Double subtract(Double b1, Double b2, Integer scale) {
|
||||||
|
if (b1 == null || b2 == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return NumberUtil.round(NumberUtil.sub(b1, b2), scale).doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user