diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/wt/controller/SdWTMonitorController.java b/backend/src/main/java/com/yfd/platform/qgc_env/wt/controller/SdWTMonitorController.java index 8212bef8..828e4caf 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_env/wt/controller/SdWTMonitorController.java +++ b/backend/src/main/java/com/yfd/platform/qgc_env/wt/controller/SdWTMonitorController.java @@ -321,4 +321,10 @@ public class SdWTMonitorController { public ResponseResult getOneLevelListCust(@RequestBody DataSourceRequest dataSourceRequest) { return ResponseResult.successData(sdDzChuiXiangListService.processKendoList(dataSourceRequest)); } + + @PostMapping("/getFacilityPointList/GetKendoListCust") + @Operation(summary = "低温水减缓设施描点") + public ResponseResult getFacilityPointKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) { + return ResponseResult.successData(sdWtMonitorService.getFacilityPointKendoListCust(dataSourceRequest)); + } } diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/wt/entity/vo/DwSlowFacilityMapVO.java b/backend/src/main/java/com/yfd/platform/qgc_env/wt/entity/vo/DwSlowFacilityMapVO.java new file mode 100644 index 00000000..f4033274 --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/qgc_env/wt/entity/vo/DwSlowFacilityMapVO.java @@ -0,0 +1,83 @@ +package com.yfd.platform.qgc_env.wt.entity.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +@Schema(description = "低温水减缓设施描点VO") +public class DwSlowFacilityMapVO { + + @Schema(description = "站点编码") + private String stcd; + + @Schema(description = "关联电站编码") + private String rstcd; + + @Schema(description = "关联电站编码(冗余)") + private String rstcds; + + @Schema(description = "站名") + private String stnm; + + @Schema(description = "标题名称") + private String titleName; + + @Schema(description = "站点类型编码") + private String sttpCode; + + @Schema(description = "站点类型映射") + private String sttpMap; + + @Schema(description = "描点状态") + private String anchoPointState; + + @Schema(description = "地图避让") + private Integer distance; + + @Schema(description = "建设状态 0=规划,1=在建,2=已建") + private String bldstt; + + @Schema(description = "经度") + private BigDecimal lgtd; + + @Schema(description = "纬度") + private BigDecimal lttd; + + @Schema(description = "遥测方式") + private String dtmel; + + @Schema(description = "流域编码") + private String rvcd; + + @Schema(description = "行政区编码") + private String addvcd; + + @Schema(description = "基地编码") + private String baseId; + + @Schema(description = "关联电站名称") + private String ennm; + + @Schema(description = "运行状态") + private String status; + + @Schema(description = "站点类型") + private String sttp; + + @Schema(description = "设施类型") + private String dwtp; + + @Schema(description = "设施类型名称") + private String dwtpName; + + @Schema(description = "站点类型名称") + private String sttpName; + + @Schema(description = "是否接入:0=未接入 1=已接入") + private Integer dtin; + + @Schema(description = "达标状态子类型(1=正常运行,2=暂无数据,3=未正常运行)") + private Integer stdSstate; +} \ No newline at end of file diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/wt/service/SdWtMonitorService.java b/backend/src/main/java/com/yfd/platform/qgc_env/wt/service/SdWtMonitorService.java index c6d44008..ba092d0a 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_env/wt/service/SdWtMonitorService.java +++ b/backend/src/main/java/com/yfd/platform/qgc_env/wt/service/SdWtMonitorService.java @@ -13,6 +13,7 @@ import com.yfd.platform.qgc_env.wt.entity.vo.WtBaseInfoVo; import com.yfd.platform.qgc_env.wt.entity.vo.WtrvAmendSaveVo; import com.yfd.platform.qgc_env.wt.entity.vo.WtrvVo; import com.yfd.platform.qgc_env.wt.entity.vo.WtrvAmendResultVo; +import com.yfd.platform.qgc_env.wt.entity.vo.DwSlowFacilityMapVO; import java.util.List; @@ -51,4 +52,6 @@ public interface SdWtMonitorService { DataSourceResult getMonthDetailList(DataSourceRequest dataSourceRequest); List getWtvtDefaultTreeStcd(DataSourceRequest dataSourceRequest); + + DataSourceResult getFacilityPointKendoListCust(DataSourceRequest dataSourceRequest); } diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/wt/service/impl/SdWtMonitorServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_env/wt/service/impl/SdWtMonitorServiceImpl.java index fa485604..b6ce2afd 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_env/wt/service/impl/SdWtMonitorServiceImpl.java +++ b/backend/src/main/java/com/yfd/platform/qgc_env/wt/service/impl/SdWtMonitorServiceImpl.java @@ -20,7 +20,9 @@ import com.yfd.platform.qgc_env.wt.entity.vo.WtTreeStcdVo; import com.yfd.platform.qgc_env.wt.entity.vo.WtrvAmendResultVo; import com.yfd.platform.qgc_env.wt.entity.vo.WtrvAmendSaveVo; import com.yfd.platform.qgc_env.wt.entity.vo.WtrvVo; +import com.yfd.platform.qgc_env.wt.entity.vo.DwSlowFacilityMapVO; import com.yfd.platform.qgc_env.wt.mapper.SdWtMonitorMapper; +import com.yfd.platform.qgc_env.wt.utils.SiteAvoidanceUtils; import com.yfd.platform.qgc_env.wt.service.SdWtMonitorService; import com.yfd.platform.utils.QgcQueryWrapperUtil; import jakarta.annotation.Resource; @@ -2830,4 +2832,93 @@ public class SdWtMonitorServiceImpl implements SdWtMonitorService { private String ennm; } + @Override + public DataSourceResult getFacilityPointKendoListCust(DataSourceRequest dataSourceRequest) { + DataSourceResult dataSourceResult = new DataSourceResult<>(); + dataSourceResult.setAggregates(new HashMap<>()); + + if (dataSourceRequest == null) { + dataSourceResult.setData(new ArrayList<>()); + dataSourceResult.setTotal(0L); + return dataSourceResult; + } + + DataSourceLoadOptionsBase devRequest = dataSourceRequest.toDevRequest(); + String bldsttCcode = QgcQueryWrapperUtil.getFilterFieldValue(devRequest, "bldsttCcode"); + + StringBuilder sql = new StringBuilder(); + sql.append("SELECT ") + .append("t.STCD AS stcd, ") + .append("t.RSTCD AS rstcd, ") + .append("t.RSTCD AS rstcds, ") + .append("t.STNM AS stnm, ") + .append("t.STNM AS titleName, ") + .append("t.STTP AS sttpCode, ") + .append("t.STTP AS sttpMap, ") + .append("t.STTP AS anchoPointState, ") + .append("t.BLDSTT_CODE AS bldstt, ") + .append("t.LGTD AS lgtd, ") + .append("t.LTTD AS lttd, ") + .append("CAST(NULL AS NUMBER) AS dtmel, ") + .append("eng.RVCD AS rvcd, ") + .append("eng.ADDVCD AS addvcd, ") + .append("eng.BASE_ID AS baseId, ") + .append("eng.ENNM AS ennm, ") + .append("NULL AS status, ") + .append("t.STTP AS sttp, ") + .append("t.STTP AS dwtp, ") + .append("sttp.STTP_NAME AS dwtpName, ") + .append("sttp.STTP_NAME AS sttpName, ") + .append("t.DTIN AS dtin, ") + .append("NULL AS stdSstate ") + .append("FROM SD_DFLTKW_B_H t ") + .append("LEFT JOIN SD_ENGINFO_B_H eng ON eng.STCD = t.RSTCD AND NVL(eng.IS_DELETED, 0) = 0 ") + .append("LEFT JOIN SD_STTP_B sttp ON sttp.STTP_CODE = t.STTP AND NVL(sttp.IS_DELETED, 0) = 0 ") + .append("WHERE NVL(t.IS_DELETED, 0) = 0 ") + .append("AND NVL(t.USFL, 1) = 1 ") + .append("AND t.LGTD IS NOT NULL ") + .append("AND t.LTTD IS NOT NULL "); + + if (StrUtil.isNotEmpty(bldsttCcode)) { + sql.append(" AND t.BLDSTT_CODE = #{map.bldsttCcode} "); + } + + Map paramMap = new HashMap<>(); + if (StrUtil.isNotEmpty(bldsttCcode)) { + paramMap.put("bldsttCcode", bldsttCcode); + } + + DataSourceLoadOptionsBase loadOptions = dataSourceRequest.toDevRequest(); + Page page = loadOptions == null ? null : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake()); + List resultList = microservicDynamicSQLMapper.pageAllListWithResultType(page, sql.toString(), paramMap, DwSlowFacilityMapVO.class); + + for (DwSlowFacilityMapVO vo : resultList) { + String sttpCode = vo.getSttpCode(); + String bldstt = vo.getBldstt(); + boolean isBuilt = "2".equals(bldstt); + + if ("DW_2".equals(sttpCode)) { + vo.setAnchoPointState(isBuilt ? "dws_1" : "dws_1_incomplete"); + } else if ("DW_5".equals(sttpCode)) { + vo.setAnchoPointState(isBuilt ? "dws_2" : "dws_2_incomplete"); + } else if ("DW_6".equals(sttpCode)) { + vo.setAnchoPointState(isBuilt ? "dws_3" : "dws_3_incomplete"); + } else { + vo.setAnchoPointState(isBuilt ? "dws_4" : "dws_4_incomplete"); + } + vo.setSttpCode("DW"); + } + + SiteAvoidanceUtils.calcSiteMapLev(resultList, + DwSlowFacilityMapVO::getStcd, + DwSlowFacilityMapVO::getLgtd, + DwSlowFacilityMapVO::getLttd, + DwSlowFacilityMapVO::getAnchoPointState, + DwSlowFacilityMapVO::setDistance); + + dataSourceResult.setData(resultList); + dataSourceResult.setTotal(page == null ? resultList.size() : page.getTotal()); + return dataSourceResult; + } + } diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/wt/utils/SiteAvoidanceUtils.java b/backend/src/main/java/com/yfd/platform/qgc_env/wt/utils/SiteAvoidanceUtils.java new file mode 100644 index 00000000..33491f5d --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/qgc_env/wt/utils/SiteAvoidanceUtils.java @@ -0,0 +1,282 @@ +package com.yfd.platform.qgc_env.wt.utils; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.function.Function; + +public class SiteAvoidanceUtils { + + private final static int DEFAULT_LEVEL = 50000000; + private final static int LEVEL1 = 1500000; + private final static double LEVEL1_DISTANCE = 1.2; + private final static int LEVEL2 = 800000; + private final static double LEVEL2_DISTANCE = 0.8; + private final static int LEVEL3 = 400000; + private final static double LEVEL3_DISTANCE = 0.4; + private final static int LEVEL4 = 50000; + private final static double LEVEL4_DISTANCE = 0.1; + + public static List calcSiteMapLev(List vos, Function stcdGetter, Function lgtdGetter, + Function lttdGetter, Function anchoPointStateGetter, + BiConsumer valueSetter) { + return calcSiteMapLev(vos, null, stcdGetter, lgtdGetter, lttdGetter, anchoPointStateGetter, valueSetter); + } + + public static List calcSiteMapLev(List vos, BaseAnchoPointAo ao, Function stcdGetter, + Function lgtdGetter, Function lttdGetter, + Function anchoPointStateGetter, BiConsumer valueSetter) { + if (ao == null) { + ao = new BaseAnchoPointAo(); + } + if (ao.getDefaultLevel() == null) { + ao.setDefaultLevel(DEFAULT_LEVEL); + } + if (ao.getLevel1() == null) { + ao.setLevel1(LEVEL1); + } + if (ao.getLevel1Distance() == null) { + ao.setLevel1Distance(LEVEL1_DISTANCE); + } + if (ao.getLevel2() == null) { + ao.setLevel2(LEVEL2); + } + if (ao.getLevel2Distance() == null) { + ao.setLevel2Distance(LEVEL2_DISTANCE); + } + if (ao.getLevel3() == null) { + ao.setLevel3(LEVEL3); + } + if (ao.getLevel3Distance() == null) { + ao.setLevel3Distance(LEVEL3_DISTANCE); + } + if (ao.getLevel4() == null) { + ao.setLevel4(LEVEL4); + } + if (ao.getLevel4Distance() == null) { + ao.setLevel4Distance(LEVEL4_DISTANCE); + } + if (ao.getCategory() == null) { + ao.setCategory(true); + } + + if (ao.getMinX() != null && ao.getMinY() != null && ao.getMaxX() != null && ao.getMaxY() != null) { + List filterVos = new ArrayList<>(vos.size()); + for (T vo : vos) { + if (lgtdGetter.apply(vo) == null || lgtdGetter.apply(vo).doubleValue() < ao.getMinX() || lgtdGetter.apply(vo).doubleValue() > ao.getMaxX()) { + continue; + } + if (lttdGetter.apply(vo) == null || lttdGetter.apply(vo).doubleValue() < ao.getMinY() || lttdGetter.apply(vo).doubleValue() > ao.getMaxY()) { + continue; + } + filterVos.add(vo); + } + if (filterVos.isEmpty()) { + return new ArrayList<>(); + } + vos = filterVos; + } + + Set meterMapData = new HashSet<>(); + for (int i = 0; i < vos.size(); i++) { + fori(vos, i, meterMapData, ao, stcdGetter, lgtdGetter, lttdGetter, anchoPointStateGetter, valueSetter); + } + return vos; + } + + private static void fori(List partitionLayerMeterList, int i, Set meterMapData, BaseAnchoPointAo ao, + Function stcdGetter, Function lgtdGetter, + Function lttdGetter, Function anchoPointStateGetter, + BiConsumer valueSetter) { + T siteAvoidanceDto = partitionLayerMeterList.get(i); + + String category = anchoPointStateGetter.apply(siteAvoidanceDto); + if (!ao.getCategory()) { + category = null; + } + String stcd = stcdGetter.apply(siteAvoidanceDto); + BigDecimal x1 = lgtdGetter.apply(siteAvoidanceDto); + BigDecimal y1 = lttdGetter.apply(siteAvoidanceDto); + if (meterMapData.contains(stcd + category)) { + return; + } + valueSetter.accept(siteAvoidanceDto, ao.getDefaultLevel()); + for (int j = i + 1; j < partitionLayerMeterList.size(); j++) { + forj(j, partitionLayerMeterList, meterMapData, category, stcd, x1, y1, ao, stcdGetter, lgtdGetter, lttdGetter, anchoPointStateGetter, valueSetter); + } + } + + private static void forj(int j, List partitionLayerMeterList, Set meterMapData, String category, + String stcd, BigDecimal x1, BigDecimal y1, BaseAnchoPointAo ao, + Function stcdGetter, Function lgtdGetter, + Function lttdGetter, Function anchoPointStateGetter, + BiConsumer valueSetter) { + T baseAnchoPointVo = partitionLayerMeterList.get(j); + String category2 = anchoPointStateGetter.apply(baseAnchoPointVo); + if (!ao.getCategory()) { + category = null; + } + String stcd2 = stcdGetter.apply(baseAnchoPointVo); + BigDecimal x2 = lgtdGetter.apply(baseAnchoPointVo); + BigDecimal y2 = lttdGetter.apply(baseAnchoPointVo); + if (!ao.getCategory()) { + category = null; + } + if (meterMapData.contains(stcd2 + category2)) { + return; + } + if (x1 == null || x2 == null || y1 == null || y2 == null) { + return; + } + if (!(stcd + category).equals(stcd2 + category2)) { + double dx = Math.abs(x1.doubleValue() - x2.doubleValue()); + double dy = Math.abs(y1.doubleValue() - y2.doubleValue()); + double distance = Math.sqrt(dx * dx + dy * dy); + if (distance < ao.getLevel4Distance()) { + valueSetter.accept(baseAnchoPointVo, ao.getLevel4()); + meterMapData.add(stcd2 + category2); + } else if (distance < ao.getLevel3Distance()) { + valueSetter.accept(baseAnchoPointVo, ao.getLevel3()); + meterMapData.add(stcd2 + category2); + } else if (distance < ao.getLevel2Distance()) { + valueSetter.accept(baseAnchoPointVo, ao.getLevel2()); + meterMapData.add(stcd2 + category2); + } else if (distance < ao.getLevel1Distance()) { + valueSetter.accept(baseAnchoPointVo, ao.getLevel1()); + meterMapData.add(stcd2 + category2); + } + } + } + + public static class BaseAnchoPointAo { + private Integer defaultLevel; + private Integer level1; + private Double level1Distance; + private Integer level2; + private Double level2Distance; + private Integer level3; + private Double level3Distance; + private Integer level4; + private Double level4Distance; + private Boolean category; + private Double minX; + private Double minY; + private Double maxX; + private Double maxY; + + public Integer getDefaultLevel() { + return defaultLevel; + } + + public void setDefaultLevel(Integer defaultLevel) { + this.defaultLevel = defaultLevel; + } + + public Integer getLevel1() { + return level1; + } + + public void setLevel1(Integer level1) { + this.level1 = level1; + } + + public Double getLevel1Distance() { + return level1Distance; + } + + public void setLevel1Distance(Double level1Distance) { + this.level1Distance = level1Distance; + } + + public Integer getLevel2() { + return level2; + } + + public void setLevel2(Integer level2) { + this.level2 = level2; + } + + public Double getLevel2Distance() { + return level2Distance; + } + + public void setLevel2Distance(Double level2Distance) { + this.level2Distance = level2Distance; + } + + public Integer getLevel3() { + return level3; + } + + public void setLevel3(Integer level3) { + this.level3 = level3; + } + + public Double getLevel3Distance() { + return level3Distance; + } + + public void setLevel3Distance(Double level3Distance) { + this.level3Distance = level3Distance; + } + + public Integer getLevel4() { + return level4; + } + + public void setLevel4(Integer level4) { + this.level4 = level4; + } + + public Double getLevel4Distance() { + return level4Distance; + } + + public void setLevel4Distance(Double level4Distance) { + this.level4Distance = level4Distance; + } + + public Boolean getCategory() { + return category; + } + + public void setCategory(Boolean category) { + this.category = category; + } + + public Double getMinX() { + return minX; + } + + public void setMinX(Double minX) { + this.minX = minX; + } + + public Double getMinY() { + return minY; + } + + public void setMinY(Double minY) { + this.minY = minY; + } + + public Double getMaxX() { + return maxX; + } + + public void setMaxX(Double maxX) { + this.maxX = maxX; + } + + public Double getMaxY() { + return maxY; + } + + public void setMaxY(Double maxY) { + this.maxY = maxY; + } + } +} \ No newline at end of file