|
|
@@ -10,12 +10,10 @@ import com.zksy.base.domain.PipeNetworkBase;
|
|
|
import com.zksy.base.mapper.EquipmentBaseMapper;
|
|
|
import com.zksy.base.mapper.EquipmentTypeMapper;
|
|
|
import com.zksy.base.mapper.PipeNetworkBaseMapper;
|
|
|
-import com.zksy.drainage.domain.DrainageWarning;
|
|
|
import com.zksy.drainage.domain.EngineeringFacility;
|
|
|
import com.zksy.drainage.domain.WaterloggingPoint;
|
|
|
import com.zksy.drainage.dto.DrainageRiskItemVO;
|
|
|
import com.zksy.drainage.dto.DrainageRiskPageInDTO;
|
|
|
-import com.zksy.drainage.mapper.DrainageWarningMapper;
|
|
|
import com.zksy.drainage.mapper.EngineeringFacilityMapper;
|
|
|
import com.zksy.drainage.mapper.WaterloggingPointMapper;
|
|
|
import com.zksy.drainage.service.DrainageRiskService;
|
|
|
@@ -45,10 +43,11 @@ import java.util.stream.Collectors;
|
|
|
* 排水管网综合风险评估实现
|
|
|
*
|
|
|
* 评估对象为 pipe_network_base 中 network_type=1 的排水管网,输入数据全部来自本系统已有业务表:
|
|
|
- * 设备台账(equipment_base)、报警(alarm_data)、预警(early_warning)、
|
|
|
+ * 设备台账(equipment_base)、报警(alarm_data)、
|
|
|
* 易积水点(drainage_waterlogging_point)、工程设施(drainage_engineering_facility)。
|
|
|
*
|
|
|
- * 评分模型为 4 个维度合计 100 分:管网本体 35、运行报警 35、环境叠加 20、数据质量 10。
|
|
|
+ * 评分模型仅保留管网本体一个维度:管网本体 35 分(管龄/材质/管径/管线类别),
|
|
|
+ * 按 35 分制得分折算为百分制总分。报警、易积水点等数据仅作展示与风险构成要素,不参与计分。
|
|
|
* 结果整体走内存快照,避免逐行查库,也保证列表、统计、地图三处口径一致。
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@@ -89,9 +88,6 @@ public class DrainageRiskServiceImpl implements DrainageRiskService {
|
|
|
@Autowired
|
|
|
private AlarmDataMapper alarmDataMapper;
|
|
|
|
|
|
- @Autowired
|
|
|
- private DrainageWarningMapper drainageWarningMapper;
|
|
|
-
|
|
|
@Autowired
|
|
|
private WaterloggingPointMapper waterloggingPointMapper;
|
|
|
|
|
|
@@ -204,7 +200,7 @@ public class DrainageRiskServiceImpl implements DrainageRiskService {
|
|
|
assessBlock.put("riskLevelName", levelName(assessment.level));
|
|
|
assessBlock.put("riskColor", levelColor(assessment.level));
|
|
|
assessBlock.put("dimensions", assessment.dimensions);
|
|
|
- assessBlock.put("assessmentModel", "排水管网综合风险模型 v1(本体/报警/环境/数据质量)");
|
|
|
+ assessBlock.put("assessmentModel", "排水管网综合风险模型 v2(管网本体)");
|
|
|
assessBlock.put("assessmentTime", current.loadTime);
|
|
|
}
|
|
|
|
|
|
@@ -298,12 +294,7 @@ public class DrainageRiskServiceImpl implements DrainageRiskService {
|
|
|
.map(EquipmentBase::getEquipmentCode)
|
|
|
.filter(Objects::nonNull)
|
|
|
.collect(Collectors.toSet());
|
|
|
- Set<String> drainageEquipmentIds = equipments.stream()
|
|
|
- .map(EquipmentBase::getEquipmentId)
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .collect(Collectors.toSet());
|
|
|
Map<String, long[]> alarmStat = loadAlarmStat(drainageEquipmentCodes);
|
|
|
- Map<String, Long> warningStat = loadWarningStat(drainageEquipmentIds);
|
|
|
List<WaterloggingPoint> waterloggingPoints = loadWaterloggingPoints();
|
|
|
List<EngineeringFacility> facilities = loadFacilities();
|
|
|
|
|
|
@@ -320,7 +311,6 @@ public class DrainageRiskServiceImpl implements DrainageRiskService {
|
|
|
int alarmCount = 0;
|
|
|
int openAlarmCount = 0;
|
|
|
int highAlarmCount = 0;
|
|
|
- long openWarningCount = 0;
|
|
|
for (EquipmentBase equipment : matched) {
|
|
|
long[] stat = alarmStat.get(equipment.getEquipmentCode());
|
|
|
if (stat != null) {
|
|
|
@@ -328,17 +318,13 @@ public class DrainageRiskServiceImpl implements DrainageRiskService {
|
|
|
openAlarmCount += (int) stat[1];
|
|
|
highAlarmCount += (int) stat[2];
|
|
|
}
|
|
|
- Long warning = warningStat.get(equipment.getEquipmentId());
|
|
|
- if (warning != null) {
|
|
|
- openWarningCount += warning;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
int waterloggingCount = countPointsWithin(pipe, waterloggingPoints, WATERLOGGING_RADIUS_METERS);
|
|
|
int facilityCount = countFacilitiesWithin(pipe, facilities, FACILITY_RADIUS_METERS);
|
|
|
|
|
|
Assessment assessment = assess(pipe, matched.size(), alarmCount, openAlarmCount,
|
|
|
- highAlarmCount, (int) openWarningCount, waterloggingCount, facilityCount);
|
|
|
+ highAlarmCount, waterloggingCount, facilityCount);
|
|
|
|
|
|
DrainageRiskItemVO row = toRow(pipe, matched.size(), alarmCount, openAlarmCount,
|
|
|
waterloggingCount, assessment);
|
|
|
@@ -448,36 +434,6 @@ public class DrainageRiskServiceImpl implements DrainageRiskService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 近30天未闭环预警按设备ID聚合
|
|
|
- *
|
|
|
- * 只统计传入的排水设备ID,early_warning 中其他业务线的预警不进统计。
|
|
|
- */
|
|
|
- private Map<String, Long> loadWarningStat(Set<String> drainageEquipmentIds) {
|
|
|
- Map<String, Long> result = new HashMap<>();
|
|
|
- if (drainageEquipmentIds.isEmpty()) {
|
|
|
- return result;
|
|
|
- }
|
|
|
- try {
|
|
|
- QueryWrapper<DrainageWarning> wrapper = new QueryWrapper<>();
|
|
|
- wrapper.select("equipment_id as equipment_id", "count(*) as total_cnt")
|
|
|
- .ge("create_time", LocalDateTime.now().minusDays(RUNNING_WINDOW_DAYS))
|
|
|
- .in("equipment_id", drainageEquipmentIds)
|
|
|
- .and(w -> w.isNull("status").or().ne("status", "CLOSED"))
|
|
|
- .groupBy("equipment_id");
|
|
|
- List<Map<String, Object>> rows = drainageWarningMapper.selectMaps(wrapper);
|
|
|
- for (Map<String, Object> row : rows) {
|
|
|
- String equipmentId = str(row, "equipment_id");
|
|
|
- if (equipmentId != null) {
|
|
|
- result.put(equipmentId, num(row, "total_cnt"));
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.warn("统计排水管网预警数据失败", e);
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
private List<WaterloggingPoint> loadWaterloggingPoints() {
|
|
|
try {
|
|
|
LambdaQueryWrapper<WaterloggingPoint> wrapper = new LambdaQueryWrapper<>();
|
|
|
@@ -570,10 +526,12 @@ public class DrainageRiskServiceImpl implements DrainageRiskService {
|
|
|
/* ==================== 评分模型 ==================== */
|
|
|
|
|
|
/**
|
|
|
- * 四维评分:管网本体 35 + 运行报警 35 + 环境叠加 20 + 数据质量 10
|
|
|
+ * 评分仅保留管网本体维度:管网本体 35 分(管龄/材质/管径/管线类别),折算为百分制总分。
|
|
|
+ *
|
|
|
+ * 报警、易积水点、设施等数据保留用于展示与风险构成要素,不再单独计分。
|
|
|
*/
|
|
|
private Assessment assess(PipeNetworkBase pipe, int equipmentCount, int alarmCount, int openAlarmCount,
|
|
|
- int highAlarmCount, int openWarningCount, int waterloggingCount, int facilityCount) {
|
|
|
+ int highAlarmCount, int waterloggingCount, int facilityCount) {
|
|
|
int age = pipeAge(pipe.getBuildDate());
|
|
|
|
|
|
int ageScore = age <= 5 ? 3 : age <= 10 ? 8 : age <= 15 ? 12 : age <= 20 ? 14 : 15;
|
|
|
@@ -582,23 +540,7 @@ public class DrainageRiskServiceImpl implements DrainageRiskService {
|
|
|
int levelScore = levelScore(pipe.getNetworkLevel());
|
|
|
int pipeScore = ageScore + materialScore + diameterScore + levelScore;
|
|
|
|
|
|
- int alarmScore = alarmCount <= 0 ? 0 : alarmCount <= 2 ? 8 : alarmCount <= 5 ? 12 : 15;
|
|
|
- int openScore = openAlarmCount <= 0 ? 0 : openAlarmCount == 1 ? 5 : openAlarmCount == 2 ? 8 : 10;
|
|
|
- int highScore = highAlarmCount <= 0 ? 0 : highAlarmCount == 1 ? 5 : 10;
|
|
|
- int runningScore = alarmScore + openScore + highScore;
|
|
|
-
|
|
|
- int waterScore = waterloggingCount <= 0 ? 0 : waterloggingCount == 1 ? 5 : waterloggingCount == 2 ? 7 : 10;
|
|
|
- int warningScore = openWarningCount <= 0 ? 0 : openWarningCount == 1 ? 4 : 6;
|
|
|
- int facilityScore = facilityCount > 0 ? 4 : 0;
|
|
|
- int environmentScore = waterScore + warningScore + facilityScore;
|
|
|
-
|
|
|
- int missingCoordinate = hasAnyCoordinate(pipe) ? 0 : 4;
|
|
|
- int missingMaterial = isBlank(pipe.getMaterial()) ? 3 : 0;
|
|
|
- int missingDimension = isBlank(pipe.getLength() == null ? null : pipe.getLength().toPlainString())
|
|
|
- || pipe.getDiameter() == null ? 3 : 0;
|
|
|
- int qualityScore = missingCoordinate + missingMaterial + missingDimension;
|
|
|
-
|
|
|
- int total = Math.min(100, pipeScore + runningScore + environmentScore + qualityScore);
|
|
|
+ int total = (int) Math.round(Math.min(35, pipeScore) / 35.0 * 100.0);
|
|
|
String level = total >= 70 ? LEVEL_HIGH : total >= 40 ? LEVEL_MEDIUM : LEVEL_LOW;
|
|
|
|
|
|
Assessment assessment = new Assessment();
|
|
|
@@ -608,10 +550,7 @@ public class DrainageRiskServiceImpl implements DrainageRiskService {
|
|
|
assessment.openAlarmCount = openAlarmCount;
|
|
|
assessment.waterloggingCount = waterloggingCount;
|
|
|
assessment.dimensions = dimensions(pipeScore, ageScore, materialScore, diameterScore, levelScore,
|
|
|
- runningScore, alarmScore, openScore, highScore,
|
|
|
- environmentScore, waterScore, warningScore, facilityScore,
|
|
|
- qualityScore, missingCoordinate, missingMaterial, missingDimension,
|
|
|
- age, pipe.getMaterial(), pipe.getDiameter(), waterloggingCount, facilityCount);
|
|
|
+ age, pipe.getMaterial(), pipe.getDiameter());
|
|
|
assessment.factors = factors(pipe, age, alarmCount, openAlarmCount, highAlarmCount,
|
|
|
waterloggingCount, facilityCount);
|
|
|
assessment.measures = measures(level, age, alarmCount, openAlarmCount, waterloggingCount);
|
|
|
@@ -621,11 +560,7 @@ public class DrainageRiskServiceImpl implements DrainageRiskService {
|
|
|
}
|
|
|
|
|
|
private List<Map<String, Object>> dimensions(int pipeScore, int ageScore, int materialScore, int diameterScore,
|
|
|
- int levelScore, int runningScore, int alarmScore, int openScore,
|
|
|
- int highScore, int environmentScore, int waterScore, int warningScore,
|
|
|
- int facilityScore, int qualityScore, int missingCoordinate,
|
|
|
- int missingMaterial, int missingDimension, int age, String material,
|
|
|
- BigDecimal diameter, int waterloggingCount, int facilityCount) {
|
|
|
+ int levelScore, int age, String material, BigDecimal diameter) {
|
|
|
List<Map<String, Object>> dimensions = new ArrayList<>();
|
|
|
|
|
|
Map<String, Object> pipeDim = dimension("pipe", "管网本体", pipeScore, 35);
|
|
|
@@ -635,24 +570,6 @@ public class DrainageRiskServiceImpl implements DrainageRiskService {
|
|
|
addItem(pipeDim, "管线类别", levelScore, "按类别影响范围计分");
|
|
|
dimensions.add(pipeDim);
|
|
|
|
|
|
- Map<String, Object> runningDim = dimension("running", "运行报警", runningScore, 35);
|
|
|
- addItem(runningDim, "近30天报警", alarmScore, alarmScore + " 分");
|
|
|
- addItem(runningDim, "未处置报警", openScore, openScore + " 分");
|
|
|
- addItem(runningDim, "高等级报警", highScore, highScore + " 分");
|
|
|
- dimensions.add(runningDim);
|
|
|
-
|
|
|
- Map<String, Object> envDim = dimension("environment", "环境叠加", environmentScore, 20);
|
|
|
- addItem(envDim, "周边易积水点", waterScore, waterloggingCount + " 处");
|
|
|
- addItem(envDim, "周边未闭环预警", warningScore, "按关联设备预警计分");
|
|
|
- addItem(envDim, "周边工程设施", facilityScore, facilityCount + " 处");
|
|
|
- dimensions.add(envDim);
|
|
|
-
|
|
|
- Map<String, Object> qualityDim = dimension("quality", "数据质量", qualityScore, 10);
|
|
|
- addItem(qualityDim, "坐标完整性", missingCoordinate, missingCoordinate > 0 ? "缺起终点坐标" : "正常");
|
|
|
- addItem(qualityDim, "材质完整性", missingMaterial, missingMaterial > 0 ? "缺材质" : "正常");
|
|
|
- addItem(qualityDim, "规格完整性", missingDimension, missingDimension > 0 ? "缺管径或长度" : "正常");
|
|
|
- dimensions.add(qualityDim);
|
|
|
-
|
|
|
return dimensions;
|
|
|
}
|
|
|
|
|
|
@@ -709,9 +626,6 @@ public class DrainageRiskServiceImpl implements DrainageRiskService {
|
|
|
if (facilityCount > 0) {
|
|
|
factors.add("周边 " + (int) FACILITY_RADIUS_METERS + " 米内存在 " + facilityCount + " 处泵站/闸门等设施");
|
|
|
}
|
|
|
- if (!hasAnyCoordinate(pipe)) {
|
|
|
- factors.add("缺少起终点坐标,未能完成空间关联,实际风险可能被低估");
|
|
|
- }
|
|
|
if (factors.isEmpty()) {
|
|
|
factors.add("管网本体状态良好,近 " + RUNNING_WINDOW_DAYS + " 天无关联报警");
|
|
|
}
|