From 55739edea19b5170c2123c54013da693375a92af Mon Sep 17 00:00:00 2001 From: wzy-warehouse <18135009705@163.com> Date: Sat, 11 Apr 2026 18:58:02 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A3=8E=E9=99=A9=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/XianRiskSpotsController.java | 31 +++ .../xian/entity/XianHiddenDangerSpots.java | 28 --- .../com/gis/xian/entity/XianRiskSpots.java | 185 ++++++++++++++++++ .../xian/entity/XianRiskSpotsBasePoint.java | 36 ++++ .../xian/entity/XianRiskSpotsPointDetail.java | 81 ++++++++ .../gis/xian/mapper/XianRiskSpotsMapper.java | 33 ++++ .../xian/service/XianRiskSpotsService.java | 21 ++ .../IXianHiddenDangerSpotsServiceImpl.java | 4 +- .../impl/IXianRiskSpotsServiceImpl.java | 47 +++++ .../com/gis/xian/task/InitializeData.java | 13 +- .../gis/xian/mapper/XianRiskSpotsMapper.xml | 67 +++++++ src/main/resources/config/redis/redis-key.yml | 6 +- 12 files changed, 518 insertions(+), 34 deletions(-) create mode 100644 src/main/java/com/gis/xian/controller/XianRiskSpotsController.java create mode 100644 src/main/java/com/gis/xian/entity/XianRiskSpots.java create mode 100644 src/main/java/com/gis/xian/entity/XianRiskSpotsBasePoint.java create mode 100644 src/main/java/com/gis/xian/entity/XianRiskSpotsPointDetail.java create mode 100644 src/main/java/com/gis/xian/mapper/XianRiskSpotsMapper.java create mode 100644 src/main/java/com/gis/xian/service/XianRiskSpotsService.java create mode 100644 src/main/java/com/gis/xian/service/impl/IXianRiskSpotsServiceImpl.java create mode 100644 src/main/resources/com/gis/xian/mapper/XianRiskSpotsMapper.xml diff --git a/src/main/java/com/gis/xian/controller/XianRiskSpotsController.java b/src/main/java/com/gis/xian/controller/XianRiskSpotsController.java new file mode 100644 index 0000000..8519ee9 --- /dev/null +++ b/src/main/java/com/gis/xian/controller/XianRiskSpotsController.java @@ -0,0 +1,31 @@ +package com.gis.xian.controller; + +import com.gis.xian.domain.ApiResponse; +import com.gis.xian.entity.XianRiskSpotsBasePoint; +import com.gis.xian.entity.XianRiskSpotsPointDetail; +import com.gis.xian.service.XianRiskSpotsService; +import jakarta.annotation.Resource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@RequestMapping("/risk-spots") +public class XianRiskSpotsController { + + @Resource + private XianRiskSpotsService xianRiskSpotsService; + + @GetMapping("/base-points") + public ApiResponse> getBasePoints() { + return ApiResponse.ok(xianRiskSpotsService.getBasePoints()); + } + + @GetMapping("point-detail/{id}") + public ApiResponse getPointDetailById(@PathVariable String id) { + return ApiResponse.ok(xianRiskSpotsService.getPointDetailById(Long.parseLong(id))); + } +} diff --git a/src/main/java/com/gis/xian/entity/XianHiddenDangerSpots.java b/src/main/java/com/gis/xian/entity/XianHiddenDangerSpots.java index 15afd9e..d709b44 100644 --- a/src/main/java/com/gis/xian/entity/XianHiddenDangerSpots.java +++ b/src/main/java/com/gis/xian/entity/XianHiddenDangerSpots.java @@ -154,32 +154,4 @@ public class XianHiddenDangerSpots { result = prime * result + ((getIsDelete() == null) ? 0 : getIsDelete().hashCode()); return result; } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(getClass().getSimpleName()); - sb.append(" ["); - sb.append("Hash = ").append(hashCode()); - sb.append(", id=").append(id); - sb.append(", fieldCode=").append(fieldCode); - sb.append(", province=").append(province); - sb.append(", provinceId=").append(provinceId); - sb.append(", city=").append(city); - sb.append(", cityId=").append(cityId); - sb.append(", county=").append(county); - sb.append(", countyId=").append(countyId); - sb.append(", village=").append(village); - sb.append(", disasterName=").append(disasterName); - sb.append(", lon=").append(lon); - sb.append(", lat=").append(lat); - sb.append(", geom=").append(geom); - sb.append(", position=").append(position); - sb.append(", disasterType=").append(disasterType); - sb.append(", scaleGrade=").append(scaleGrade); - sb.append(", riskGrade=").append(riskGrade); - sb.append(", isDelete=").append(isDelete); - sb.append("]"); - return sb.toString(); - } } \ No newline at end of file diff --git a/src/main/java/com/gis/xian/entity/XianRiskSpots.java b/src/main/java/com/gis/xian/entity/XianRiskSpots.java new file mode 100644 index 0000000..727af44 --- /dev/null +++ b/src/main/java/com/gis/xian/entity/XianRiskSpots.java @@ -0,0 +1,185 @@ +package com.gis.xian.entity; + +import lombok.Data; + +/** + * 地质灾害风险区 + * @TableName xian_risk_spots + */ +@Data +public class XianRiskSpots { + /** + * 序号 + */ + private Long id; + + /** + * 风险区名称 + */ + private String riskName; + + /** + * 统一编号 + */ + private String unitCode; + + /** + * 风险区等级 + */ + private String riskLevel; + + /** + * 面积 + */ + private Double area; + + /** + * 省 + */ + private String province; + + /** + * 市 + */ + private String city; + + /** + * 县 + */ + private String county; + + /** + * 乡 + */ + private String country; + + /** + * 村 + */ + private String village; + + /** + * 位置 + */ + private String position; + + /** + * 居民户数(户) + */ + private Integer residentCounts; + + /** + * 居民人口(人) + */ + private Integer addressPopulation; + + /** + * 威胁财产(万元) + */ + private Integer riskProperty; + + /** + * 常住人口(人) + */ + private Integer permanentPopulation; + + /** + * 住房(间) + */ + private Integer housing; + + /** + * 巡查员姓名 + */ + private String inspectorName; + + /** + * 巡查员电话 + */ + private String inspectorTele; + + /** + * 经度 + */ + private Double lon; + + /** + * 纬度 + */ + private Double lat; + + /** + * 空间 + */ + private Object geom; + + /** + * 逻辑删除标识,0未删除,1已删除 + */ + private Integer isDelete; + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + XianRiskSpots other = (XianRiskSpots) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getRiskName() == null ? other.getRiskName() == null : this.getRiskName().equals(other.getRiskName())) + && (this.getUnitCode() == null ? other.getUnitCode() == null : this.getUnitCode().equals(other.getUnitCode())) + && (this.getRiskLevel() == null ? other.getRiskLevel() == null : this.getRiskLevel().equals(other.getRiskLevel())) + && (this.getArea() == null ? other.getArea() == null : this.getArea().equals(other.getArea())) + && (this.getProvince() == null ? other.getProvince() == null : this.getProvince().equals(other.getProvince())) + && (this.getCity() == null ? other.getCity() == null : this.getCity().equals(other.getCity())) + && (this.getCounty() == null ? other.getCounty() == null : this.getCounty().equals(other.getCounty())) + && (this.getCountry() == null ? other.getCountry() == null : this.getCountry().equals(other.getCountry())) + && (this.getVillage() == null ? other.getVillage() == null : this.getVillage().equals(other.getVillage())) + && (this.getPosition() == null ? other.getPosition() == null : this.getPosition().equals(other.getPosition())) + && (this.getResidentCounts() == null ? other.getResidentCounts() == null : this.getResidentCounts().equals(other.getResidentCounts())) + && (this.getAddressPopulation() == null ? other.getAddressPopulation() == null : this.getAddressPopulation().equals(other.getAddressPopulation())) + && (this.getRiskProperty() == null ? other.getRiskProperty() == null : this.getRiskProperty().equals(other.getRiskProperty())) + && (this.getPermanentPopulation() == null ? other.getPermanentPopulation() == null : this.getPermanentPopulation().equals(other.getPermanentPopulation())) + && (this.getHousing() == null ? other.getHousing() == null : this.getHousing().equals(other.getHousing())) + && (this.getInspectorName() == null ? other.getInspectorName() == null : this.getInspectorName().equals(other.getInspectorName())) + && (this.getInspectorTele() == null ? other.getInspectorTele() == null : this.getInspectorTele().equals(other.getInspectorTele())) + && (this.getLon() == null ? other.getLon() == null : this.getLon().equals(other.getLon())) + && (this.getLat() == null ? other.getLat() == null : this.getLat().equals(other.getLat())) + && (this.getGeom() == null ? other.getGeom() == null : this.getGeom().equals(other.getGeom())) + && (this.getIsDelete() == null ? other.getIsDelete() == null : this.getIsDelete().equals(other.getIsDelete())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getRiskName() == null) ? 0 : getRiskName().hashCode()); + result = prime * result + ((getUnitCode() == null) ? 0 : getUnitCode().hashCode()); + result = prime * result + ((getRiskLevel() == null) ? 0 : getRiskLevel().hashCode()); + result = prime * result + ((getArea() == null) ? 0 : getArea().hashCode()); + result = prime * result + ((getProvince() == null) ? 0 : getProvince().hashCode()); + result = prime * result + ((getCity() == null) ? 0 : getCity().hashCode()); + result = prime * result + ((getCounty() == null) ? 0 : getCounty().hashCode()); + result = prime * result + ((getCountry() == null) ? 0 : getCountry().hashCode()); + result = prime * result + ((getVillage() == null) ? 0 : getVillage().hashCode()); + result = prime * result + ((getPosition() == null) ? 0 : getPosition().hashCode()); + result = prime * result + ((getResidentCounts() == null) ? 0 : getResidentCounts().hashCode()); + result = prime * result + ((getAddressPopulation() == null) ? 0 : getAddressPopulation().hashCode()); + result = prime * result + ((getRiskProperty() == null) ? 0 : getRiskProperty().hashCode()); + result = prime * result + ((getPermanentPopulation() == null) ? 0 : getPermanentPopulation().hashCode()); + result = prime * result + ((getHousing() == null) ? 0 : getHousing().hashCode()); + result = prime * result + ((getInspectorName() == null) ? 0 : getInspectorName().hashCode()); + result = prime * result + ((getInspectorTele() == null) ? 0 : getInspectorTele().hashCode()); + result = prime * result + ((getLon() == null) ? 0 : getLon().hashCode()); + result = prime * result + ((getLat() == null) ? 0 : getLat().hashCode()); + result = prime * result + ((getGeom() == null) ? 0 : getGeom().hashCode()); + result = prime * result + ((getIsDelete() == null) ? 0 : getIsDelete().hashCode()); + return result; + } +} \ No newline at end of file diff --git a/src/main/java/com/gis/xian/entity/XianRiskSpotsBasePoint.java b/src/main/java/com/gis/xian/entity/XianRiskSpotsBasePoint.java new file mode 100644 index 0000000..21eee8b --- /dev/null +++ b/src/main/java/com/gis/xian/entity/XianRiskSpotsBasePoint.java @@ -0,0 +1,36 @@ +package com.gis.xian.entity; + +import lombok.Data; + +import java.util.Objects; + +@Data +public class XianRiskSpotsBasePoint { + /** + * 序号 + */ + private Long id; + + /** + * 经度 + */ + private Double lon; + + /** + * 维度 + */ + private Double lat; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + XianRiskSpotsBasePoint that = (XianRiskSpotsBasePoint) o; + return Objects.equals(id, that.id) && Objects.equals(lon, that.lon) && Objects.equals(lat, that.lat); + } + + @Override + public int hashCode() { + return Objects.hash(id, lon, lat); + } +} diff --git a/src/main/java/com/gis/xian/entity/XianRiskSpotsPointDetail.java b/src/main/java/com/gis/xian/entity/XianRiskSpotsPointDetail.java new file mode 100644 index 0000000..e0cc734 --- /dev/null +++ b/src/main/java/com/gis/xian/entity/XianRiskSpotsPointDetail.java @@ -0,0 +1,81 @@ +package com.gis.xian.entity; + +import lombok.Data; + +import java.util.Objects; + +@Data +public class XianRiskSpotsPointDetail { + /** + * 序号 + */ + private Long id; + + /** + * 风险区名称 + */ + private String riskName; + + /** + * 统一编号 + */ + private String unitCode; + + /** + * 位置 + */ + private String position; + + /** + * 居民户数 + */ + private Integer residentCounts; + + /** + * 威胁财产 + */ + private Integer riskProperty; + + /** + * 常住人口 + */ + private Integer permanentPopulation; + + /** + * 住房 + */ + private Integer housing; + + /** + * 巡查员姓名 + */ + private String inspectorName; + + /** + * 巡查员电话 + */ + private String inspectorTele; + + /** + * 经度 + */ + private Double lon; + + /** + * 纬度 + */ + private Double lat; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + XianRiskSpotsPointDetail that = (XianRiskSpotsPointDetail) o; + return Objects.equals(id, that.id) && Objects.equals(riskName, that.riskName) && Objects.equals(unitCode, that.unitCode) && Objects.equals(position, that.position) && Objects.equals(residentCounts, that.residentCounts) && Objects.equals(riskProperty, that.riskProperty) && Objects.equals(permanentPopulation, that.permanentPopulation) && Objects.equals(housing, that.housing) && Objects.equals(inspectorName, that.inspectorName) && Objects.equals(inspectorTele, that.inspectorTele) && Objects.equals(lon, that.lon) && Objects.equals(lat, that.lat); + } + + @Override + public int hashCode() { + return Objects.hash(id, riskName, unitCode, position, residentCounts, riskProperty, permanentPopulation, housing, inspectorName, inspectorTele, lon, lat); + } +} diff --git a/src/main/java/com/gis/xian/mapper/XianRiskSpotsMapper.java b/src/main/java/com/gis/xian/mapper/XianRiskSpotsMapper.java new file mode 100644 index 0000000..f164f16 --- /dev/null +++ b/src/main/java/com/gis/xian/mapper/XianRiskSpotsMapper.java @@ -0,0 +1,33 @@ +package com.gis.xian.mapper; + +import com.gis.xian.entity.XianRiskSpots; +import com.gis.xian.entity.XianRiskSpotsBasePoint; +import com.gis.xian.entity.XianRiskSpotsPointDetail; + +import java.util.List; + +/** +* @author wzy +* @description 针对表【xian_risk_spots(地质灾害风险区)】的数据库操作Mapper +* @createDate 2026-04-11 10:38:29 +* @Entity com.gis.xian.entity.XianRiskSpots +*/ +public interface XianRiskSpotsMapper { + /** + * 获取所有风险点基础信息 + * @return 风险点基础列表 + */ + List getBasePoints(); + + + /** + * 根据id获取风险点详情 + * @param id 风险点id + * @return 风险点详情 + */ + XianRiskSpotsPointDetail getPointDetailById(Long id); +} + + + + diff --git a/src/main/java/com/gis/xian/service/XianRiskSpotsService.java b/src/main/java/com/gis/xian/service/XianRiskSpotsService.java new file mode 100644 index 0000000..f0c7cab --- /dev/null +++ b/src/main/java/com/gis/xian/service/XianRiskSpotsService.java @@ -0,0 +1,21 @@ +package com.gis.xian.service; + +import com.gis.xian.entity.XianRiskSpotsBasePoint; +import com.gis.xian.entity.XianRiskSpotsPointDetail; + +import java.util.List; + +public interface XianRiskSpotsService { + /** + * 获取所有风险点基础信息 + * @return 风险点基础列表 + */ + List getBasePoints(); + + /** + * 根据id获取风险点详情 + * @param id 风险点id + * @return 风险点详情 + */ + XianRiskSpotsPointDetail getPointDetailById(Long id); +} diff --git a/src/main/java/com/gis/xian/service/impl/IXianHiddenDangerSpotsServiceImpl.java b/src/main/java/com/gis/xian/service/impl/IXianHiddenDangerSpotsServiceImpl.java index 38b539a..9dd793c 100644 --- a/src/main/java/com/gis/xian/service/impl/IXianHiddenDangerSpotsServiceImpl.java +++ b/src/main/java/com/gis/xian/service/impl/IXianHiddenDangerSpotsServiceImpl.java @@ -22,10 +22,10 @@ public class IXianHiddenDangerSpotsServiceImpl implements XianHiddenDangerSpotsS @Resource private XianHiddenDangerSpotsMapper xianHiddenDangerSpotsMapper; - @Value("${init.data.base-points.rainstorm}") + @Value("${init.data.base-points.hidden-danger.rainstorm}") private String rainstormBasePointsKey; - @Value("${init.data.base-points.earthquake}") + @Value("${init.data.base-points.hidden-danger.earthquake}") private String earthquakeBasePointsKey; @Override diff --git a/src/main/java/com/gis/xian/service/impl/IXianRiskSpotsServiceImpl.java b/src/main/java/com/gis/xian/service/impl/IXianRiskSpotsServiceImpl.java new file mode 100644 index 0000000..9aaabcf --- /dev/null +++ b/src/main/java/com/gis/xian/service/impl/IXianRiskSpotsServiceImpl.java @@ -0,0 +1,47 @@ +package com.gis.xian.service.impl; + +import com.alibaba.fastjson2.JSON; +import com.gis.xian.entity.XianHiddenDangerSpotsBasePoint; +import com.gis.xian.entity.XianRiskSpotsBasePoint; +import com.gis.xian.entity.XianRiskSpotsPointDetail; +import com.gis.xian.enums.DisasterTypeEnum; +import com.gis.xian.mapper.XianRiskSpotsMapper; +import com.gis.xian.service.XianRiskSpotsService; +import jakarta.annotation.Resource; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class IXianRiskSpotsServiceImpl implements XianRiskSpotsService { + + @Resource + private XianRiskSpotsMapper xianRiskSpotsMapper; + + @Resource + private RedisTemplate redisTemplate; + + @Value("${init.data.base-points.risk}") + private String riskPointKey; + + @Override + public List getBasePoints() { + // 从redis中读取基础点信息 + Object data = redisTemplate.opsForValue().get(riskPointKey); + + if (data == null) { + List basePoints = xianRiskSpotsMapper.getBasePoints(); + redisTemplate.opsForValue().set(riskPointKey, JSON.toJSONString(basePoints)); + return basePoints; + } + + return JSON.parseArray(data.toString(), XianRiskSpotsBasePoint.class); + } + + @Override + public XianRiskSpotsPointDetail getPointDetailById(Long id) { + return xianRiskSpotsMapper.getPointDetailById(id); + } +} diff --git a/src/main/java/com/gis/xian/task/InitializeData.java b/src/main/java/com/gis/xian/task/InitializeData.java index 06672d4..d7c2c0b 100644 --- a/src/main/java/com/gis/xian/task/InitializeData.java +++ b/src/main/java/com/gis/xian/task/InitializeData.java @@ -3,6 +3,7 @@ package com.gis.xian.task; import com.alibaba.fastjson2.JSON; import com.gis.xian.enums.DisasterTypeEnum; import com.gis.xian.mapper.XianHiddenDangerSpotsMapper; +import com.gis.xian.mapper.XianRiskSpotsMapper; import jakarta.annotation.PostConstruct; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; @@ -21,15 +22,21 @@ public class InitializeData { @Resource private XianHiddenDangerSpotsMapper xianHiddenDangerSpotsMapper; + @Resource + private XianRiskSpotsMapper xianRiskSpotsMapper; + @Resource RedisTemplate redisTemplate; - @Value("${init.data.base-points.rainstorm}") + @Value("${init.data.base-points.hidden-danger.rainstorm}") private String rainstormBasePointsKey; - @Value("${init.data.base-points.earthquake}") + @Value("${init.data.base-points.hidden-danger.earthquake}") private String earthquakeBasePointsKey; + @Value("${init.data.base-points.risk}") + private String riskBasePointsKey; + @PostConstruct @Async("xianPool") public void init() { @@ -39,6 +46,8 @@ public class InitializeData { redisTemplate.opsForValue().set(rainstormBasePointsKey, JSON.toJSONString(xianHiddenDangerSpotsMapper.getBasePoints(DisasterTypeEnum.RAINSTORM.getType()))); redisTemplate.opsForValue().set(earthquakeBasePointsKey, JSON.toJSONString(xianHiddenDangerSpotsMapper.getBasePoints(DisasterTypeEnum.EARTHQUAKE.getType()))); + // 加载风险点基本信息写入redis + redisTemplate.opsForValue().set(riskBasePointsKey, JSON.toJSONString(xianRiskSpotsMapper.getBasePoints())); log.info("初始化数据完成"); } } diff --git a/src/main/resources/com/gis/xian/mapper/XianRiskSpotsMapper.xml b/src/main/resources/com/gis/xian/mapper/XianRiskSpotsMapper.xml new file mode 100644 index 0000000..f92ddda --- /dev/null +++ b/src/main/resources/com/gis/xian/mapper/XianRiskSpotsMapper.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/redis/redis-key.yml b/src/main/resources/config/redis/redis-key.yml index 8ed3171..6cd86aa 100644 --- a/src/main/resources/config/redis/redis-key.yml +++ b/src/main/resources/config/redis/redis-key.yml @@ -10,5 +10,7 @@ init: data: # 基础信息点数据:滑坡、泥石流、山洪、内涝 base-points: - rainstorm: 'xian:init:data:base-points:rainstorm' - earthquake: 'xian:init:data:base-points:earthquake' \ No newline at end of file + hidden-danger: + rainstorm: 'xian:init:data:base-points:hidden-danger:rainstorm' + earthquake: 'xian:init:data:base-points:hidden-danger:earthquake' + risk: 'xian:init:data:base-points:risk' \ No newline at end of file