|
|
@@ -38,6 +38,10 @@ public class CockpitInfrastructureManagementInformationService {
|
|
|
private static final List<String> INDUSTRIES = Arrays.asList("GAS", "WATER_SUPPLY", "DRAINAGE", "MANHOLE");
|
|
|
private static final String FACILITY = "FACILITY";
|
|
|
private static final String SMART_DEVICE = "SMART_DEVICE";
|
|
|
+ /** 排水行业码:`network_level` 二级分项只挂在这一行业的设施桶上。 */
|
|
|
+ private static final String DRAINAGE = "DRAINAGE";
|
|
|
+ /** 排水二级分类的**可解释码位**(0-污水 1-雨水),按码升序输出;其它码不进分项。 */
|
|
|
+ private static final List<String> DRAINAGE_LEVELS = Arrays.asList("0", "1");
|
|
|
|
|
|
private final CockpitInfrastructureManagementInformationAdapter adapter;
|
|
|
private final Clock clock;
|
|
|
@@ -104,8 +108,14 @@ public class CockpitInfrastructureManagementInformationService {
|
|
|
}
|
|
|
DistrictIndustryKey key = new DistrictIndustryKey(
|
|
|
CockpitDistrict.codeOf(relation.getDistrict()), industryCode);
|
|
|
- counters.computeIfAbsent(key, ignored -> new Counter())
|
|
|
- .add(FACILITY.equals(kind));
|
|
|
+ Counter counter = counters.computeIfAbsent(key, ignored -> new Counter());
|
|
|
+ counter.add(FACILITY.equals(kind));
|
|
|
+ // 雨污二级分项只对**排水设施**有意义:`network_level` 是跨行业共享列(字典
|
|
|
+ // `pipe_network_level`),燃气侧同一列存的是压力等级,不能拿燃气的码来拆雨污。
|
|
|
+ // 设备没有该列;认不出的码不猜、不进分项,仍留在 facilityCount 里如实可见。
|
|
|
+ if (FACILITY.equals(kind) && DRAINAGE.equals(industryCode)) {
|
|
|
+ counter.addDrainageLevel(drainageLevelOf(relation.getNetworkLevel()));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
List<DistrictIndustryCount> districtIndustry = new ArrayList<>();
|
|
|
@@ -117,7 +127,8 @@ public class CockpitInfrastructureManagementInformationService {
|
|
|
facilityCount += counter.facilityCount;
|
|
|
equipmentCount += counter.equipmentCount;
|
|
|
districtIndustry.add(new DistrictIndustryCount(
|
|
|
- key.district, key.industry, counter.facilityCount, counter.equipmentCount));
|
|
|
+ key.district, key.industry, counter.facilityCount, counter.equipmentCount,
|
|
|
+ counter.drainageLevelCounts()));
|
|
|
}
|
|
|
districtIndustry.sort(Comparator
|
|
|
.comparing(DistrictIndustryCount::getDistrict,
|
|
|
@@ -241,9 +252,25 @@ public class CockpitInfrastructureManagementInformationService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 排水 `network_level` → 可解释码位:只认 {@code 0-污水 / 1-雨水}。
|
|
|
+ *
|
|
|
+ * <p>其余值(空、脏码、燃气压力等级语义)一律回 {@code null}=不进分项 —— 该设施仍计在
|
|
|
+ * 行的 `facilityCount` 里,差值在面板上如实可见,不靠猜码补齐。
|
|
|
+ */
|
|
|
+ private static String drainageLevelOf(String raw) {
|
|
|
+ if (raw == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String value = raw.trim();
|
|
|
+ return DRAINAGE_LEVELS.contains(value) ? value : null;
|
|
|
+ }
|
|
|
+
|
|
|
private static final class Counter {
|
|
|
private int facilityCount;
|
|
|
private int equipmentCount;
|
|
|
+ /** 同一桶内按 `network_level` 码位累计的设施数;只对排水设施调用。 */
|
|
|
+ private final Map<String, Integer> drainageLevels = new LinkedHashMap<>();
|
|
|
|
|
|
private void add(boolean facility) {
|
|
|
if (facility) {
|
|
|
@@ -252,5 +279,23 @@ public class CockpitInfrastructureManagementInformationService {
|
|
|
equipmentCount++;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void addDrainageLevel(String level) {
|
|
|
+ if (level != null) {
|
|
|
+ drainageLevels.merge(level, 1, Integer::sum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 固定码位升序输出,只带真实出现的档位(0 与空分得开:0 是「确认没有」)。 */
|
|
|
+ private List<CockpitInfrastructureManagementInformationResponse.NetworkLevelCount> drainageLevelCounts() {
|
|
|
+ List<CockpitInfrastructureManagementInformationResponse.NetworkLevelCount> counts = new ArrayList<>();
|
|
|
+ for (String level : DRAINAGE_LEVELS) {
|
|
|
+ Integer count = drainageLevels.get(level);
|
|
|
+ if (count != null && count > 0) {
|
|
|
+ counts.add(new CockpitInfrastructureManagementInformationResponse.NetworkLevelCount(level, count));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return counts;
|
|
|
+ }
|
|
|
}
|
|
|
}
|