|
|
@@ -4,6 +4,21 @@ import com.zksy.base.domain.ManholeBase;
|
|
|
import com.zksy.base.domain.PipeNetworkBase;
|
|
|
import com.zksy.base.service.ManholeBaseService;
|
|
|
import com.zksy.base.service.PipeNetworkBaseService;
|
|
|
+import com.zksy.watersupply.domain.PumpStationInfo;
|
|
|
+import com.zksy.watersupply.domain.WaterFireHydrantInfo;
|
|
|
+import com.zksy.watersupply.domain.WaterPlantInfo;
|
|
|
+import com.zksy.watersupply.domain.WaterSourceInfo;
|
|
|
+import com.zksy.watersupply.domain.WaterUserInfo;
|
|
|
+import com.zksy.watersupply.service.IPumpStationInfoService;
|
|
|
+import com.zksy.watersupply.service.IWaterFireHydrantInfoService;
|
|
|
+import com.zksy.watersupply.service.IWaterPlantInfoService;
|
|
|
+import com.zksy.watersupply.service.IWaterSourceInfoService;
|
|
|
+import com.zksy.watersupply.service.IWaterUserInfoService;
|
|
|
+import com.zksy.drainage.domain.DrainageGateInfo;
|
|
|
+import com.zksy.drainage.domain.DrainageStorageInfo;
|
|
|
+import com.zksy.drainage.service.DrainageGateInfoService;
|
|
|
+import com.zksy.drainage.service.DrainageStorageInfoService;
|
|
|
+import com.zksy.cockpit.foundation.CockpitFacilityContract;
|
|
|
import com.zksy.cockpit.foundation.CockpitCoordinateValidation;
|
|
|
import com.zksy.cockpit.foundation.CockpitCoordinateValidator;
|
|
|
import com.zksy.cockpit.foundation.CockpitPipeNetworkType;
|
|
|
@@ -30,15 +45,39 @@ import java.util.stream.Collectors;
|
|
|
public class CockpitFacilityGeometryService {
|
|
|
private final PipeNetworkBaseService networks;
|
|
|
private final ManholeBaseService manholes;
|
|
|
+ private final IWaterPlantInfoService plants;
|
|
|
+ private final IPumpStationInfoService stations;
|
|
|
+ private final IWaterSourceInfoService waterSources;
|
|
|
+ private final IWaterUserInfoService waterUsers;
|
|
|
+ private final IWaterFireHydrantInfoService hydrants;
|
|
|
+ private final DrainageGateInfoService gates;
|
|
|
+ private final DrainageStorageInfoService storages;
|
|
|
private final Clock clock;
|
|
|
|
|
|
+ /** Spring 注入使用全依赖构造器;保留三参构造器给既有单测/直接实例化。 */
|
|
|
+ @org.springframework.beans.factory.annotation.Autowired
|
|
|
public CockpitFacilityGeometryService(PipeNetworkBaseService networks,
|
|
|
- ManholeBaseService manholes, Clock clock) {
|
|
|
+ ManholeBaseService manholes, IWaterPlantInfoService plants,
|
|
|
+ IPumpStationInfoService stations, IWaterSourceInfoService waterSources,
|
|
|
+ IWaterUserInfoService waterUsers, IWaterFireHydrantInfoService hydrants,
|
|
|
+ DrainageGateInfoService gates, DrainageStorageInfoService storages, Clock clock) {
|
|
|
this.networks = networks;
|
|
|
this.manholes = manholes;
|
|
|
+ this.plants = plants;
|
|
|
+ this.stations = stations;
|
|
|
+ this.waterSources = waterSources;
|
|
|
+ this.waterUsers = waterUsers;
|
|
|
+ this.hydrants = hydrants;
|
|
|
+ this.gates = gates;
|
|
|
+ this.storages = storages;
|
|
|
this.clock = clock;
|
|
|
}
|
|
|
|
|
|
+ public CockpitFacilityGeometryService(PipeNetworkBaseService networks,
|
|
|
+ ManholeBaseService manholes, Clock clock) {
|
|
|
+ this(networks, manholes, null, null, null, null, null, null, null, clock);
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional(readOnly = true)
|
|
|
public CockpitFacilityGeometryResponse load() {
|
|
|
try {
|
|
|
@@ -61,6 +100,7 @@ public class CockpitFacilityGeometryService {
|
|
|
null, null, null, "Point",
|
|
|
Collections.singletonList(pair(manhole.getLongitude(), manhole.getLatitude()))));
|
|
|
}
|
|
|
+ addFacilityFeatures(features);
|
|
|
List<Coverage> coverage = new ArrayList<>();
|
|
|
for (String industry : Arrays.asList("GAS", "WATER_SUPPLY", "DRAINAGE")) {
|
|
|
coverage.add(coverage(features, industry, "pipe_network_base", "LineString", "TWO_ENDPOINTS_ONLY"));
|
|
|
@@ -75,6 +115,7 @@ public class CockpitFacilityGeometryService {
|
|
|
coverage.add(new Coverage("MANHOLE", null, "LineString", "UNAVAILABLE",
|
|
|
"NO_PIPELINE_SOURCE", 0, 0, 0));
|
|
|
coverage.add(coverage(features, "UNKNOWN", "pipe_network_base", "LineString", "UNKNOWN_NETWORK_TYPE"));
|
|
|
+ addFacilityCoverage(coverage, features);
|
|
|
String generatedAt = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(
|
|
|
clock.instant().atZone(ZoneId.of("Asia/Shanghai")));
|
|
|
return new CockpitFacilityGeometryResponse(generatedAt, features, coverage);
|
|
|
@@ -86,6 +127,84 @@ public class CockpitFacilityGeometryService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /** 设施台账的 Point Feature:坐标来自各设施表自身字段,不另外回查 entity detail。 */
|
|
|
+ private void addFacilityFeatures(List<Feature> features) {
|
|
|
+ if (plants != null) {
|
|
|
+ for (WaterPlantInfo v : plants.list()) {
|
|
|
+ if (v != null) addPointFeature(features, "water_plant_info", v.getId(), v.getPlantCode(),
|
|
|
+ v.getPlantName(), "WATER_SUPPLY", "WATER_PLANT", v.getLongitude(), v.getLatitude());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (stations != null) {
|
|
|
+ for (PumpStationInfo v : stations.list()) {
|
|
|
+ if (v == null) continue;
|
|
|
+ String typeCode = CockpitFacilityContract.pumpStationTypeCode(v.getStationType());
|
|
|
+ String industry = "1".equals(typeCode) ? "DRAINAGE" : "WATER_SUPPLY";
|
|
|
+ addPointFeature(features, "pump_station_info", v.getId(), v.getStationCode(),
|
|
|
+ v.getStationName(), industry, "PUMP_STATION", v.getLongitude(), v.getLatitude());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (waterSources != null) {
|
|
|
+ for (WaterSourceInfo v : waterSources.list()) {
|
|
|
+ if (v != null) addPointFeature(features, "water_source_info", v.getId(), v.getSourceId(),
|
|
|
+ v.getSourceName(), "WATER_SUPPLY", "WATER_SOURCE", v.getLongitude(), v.getLatitude());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (waterUsers != null) {
|
|
|
+ for (WaterUserInfo v : waterUsers.list()) {
|
|
|
+ if (v != null) addPointFeature(features, "water_user_info", v.getId(), v.getUserCode(),
|
|
|
+ v.getUserName(), "WATER_SUPPLY", "WATER_USER", v.getLongitude(), v.getLatitude());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (hydrants != null) {
|
|
|
+ for (WaterFireHydrantInfo v : hydrants.list()) {
|
|
|
+ if (v != null) addPointFeature(features, "water_fire_hydrant_info", v.getHydrantId(),
|
|
|
+ v.getHydrantCode(), v.getHydrantName(), "WATER_SUPPLY", "WATER_FIRE_HYDRANT",
|
|
|
+ v.getLongitude(), v.getLatitude());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (gates != null) {
|
|
|
+ for (DrainageGateInfo v : gates.list()) {
|
|
|
+ if (v != null) addPointFeature(features, "drainage_gate_info", v.getFacilityId(),
|
|
|
+ v.getFacilityCode(), v.getFacilityName(), "DRAINAGE", "DRAINAGE_GATE",
|
|
|
+ v.getLongitude(), v.getLatitude());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (storages != null) {
|
|
|
+ for (DrainageStorageInfo v : storages.list()) {
|
|
|
+ if (v != null) addPointFeature(features, "drainage_storage_info", v.getFacilityId(),
|
|
|
+ v.getFacilityCode(), v.getFacilityName(), "DRAINAGE", "DRAINAGE_STORAGE",
|
|
|
+ v.getLongitude(), v.getLatitude());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void addPointFeature(List<Feature> features, String source, String sourceId, String code,
|
|
|
+ String name, String industry, String typeCode, java.math.BigDecimal longitude,
|
|
|
+ java.math.BigDecimal latitude) {
|
|
|
+ if (sourceId == null || sourceId.trim().isEmpty()) return;
|
|
|
+ List<List<java.math.BigDecimal>> coordinates = Collections.singletonList(pair(longitude, latitude));
|
|
|
+ CockpitCoordinateValidation validation = validate(longitude, latitude);
|
|
|
+ Geometry geometry = "INVALID".equals(validation.getState()) ? null
|
|
|
+ : new Geometry("Point", coordinates.get(0));
|
|
|
+ Properties properties = new Properties(source, sourceId.trim(), code, name, industry, typeCode,
|
|
|
+ null, null, typeCode, null, null, null, coordinates, validation,
|
|
|
+ Collections.singletonList(validation));
|
|
|
+ features.add(new Feature(source + ":" + sourceId.trim(), geometry, properties));
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void addFacilityCoverage(List<Coverage> coverage, List<Feature> features) {
|
|
|
+ coverage.add(coverage(features, "WATER_SUPPLY", "water_plant_info", "Point", "FACILITY_POINT"));
|
|
|
+ coverage.add(coverage(features, "WATER_SUPPLY", "pump_station_info", "Point", "FACILITY_POINT"));
|
|
|
+ coverage.add(coverage(features, "DRAINAGE", "pump_station_info", "Point", "FACILITY_POINT"));
|
|
|
+ coverage.add(coverage(features, "WATER_SUPPLY", "water_source_info", "Point", "FACILITY_POINT"));
|
|
|
+ coverage.add(coverage(features, "WATER_SUPPLY", "water_user_info", "Point", "FACILITY_POINT"));
|
|
|
+ coverage.add(coverage(features, "WATER_SUPPLY", "water_fire_hydrant_info", "Point", "FACILITY_POINT"));
|
|
|
+ coverage.add(coverage(features, "DRAINAGE", "drainage_gate_info", "Point", "FACILITY_POINT"));
|
|
|
+ coverage.add(coverage(features, "DRAINAGE", "drainage_storage_info", "Point", "FACILITY_POINT"));
|
|
|
+ }
|
|
|
+
|
|
|
private static Feature feature(String source, String sourceId, String code, String name, String industry,
|
|
|
String typeCode, String networkType, String networkLevel, String pointType, String networkId, BigDecimal diameter, String remark, String geometryType,
|
|
|
List<List<BigDecimal>> coordinates) {
|