风险点

This commit is contained in:
wzy-warehouse
2026-04-11 18:58:02 +08:00
parent fecd1510ec
commit 55739edea1
12 changed files with 518 additions and 34 deletions
@@ -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<List<XianRiskSpotsBasePoint>> getBasePoints() {
return ApiResponse.ok(xianRiskSpotsService.getBasePoints());
}
@GetMapping("point-detail/{id}")
public ApiResponse<XianRiskSpotsPointDetail> getPointDetailById(@PathVariable String id) {
return ApiResponse.ok(xianRiskSpotsService.getPointDetailById(Long.parseLong(id)));
}
}
@@ -154,32 +154,4 @@ public class XianHiddenDangerSpots {
result = prime * result + ((getIsDelete() == null) ? 0 : getIsDelete().hashCode()); result = prime * result + ((getIsDelete() == null) ? 0 : getIsDelete().hashCode());
return result; 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();
}
} }
@@ -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;
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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<XianRiskSpotsBasePoint> getBasePoints();
/**
* 根据id获取风险点详情
* @param id 风险点id
* @return 风险点详情
*/
XianRiskSpotsPointDetail getPointDetailById(Long id);
}
@@ -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<XianRiskSpotsBasePoint> getBasePoints();
/**
* 根据id获取风险点详情
* @param id 风险点id
* @return 风险点详情
*/
XianRiskSpotsPointDetail getPointDetailById(Long id);
}
@@ -22,10 +22,10 @@ public class IXianHiddenDangerSpotsServiceImpl implements XianHiddenDangerSpotsS
@Resource @Resource
private XianHiddenDangerSpotsMapper xianHiddenDangerSpotsMapper; private XianHiddenDangerSpotsMapper xianHiddenDangerSpotsMapper;
@Value("${init.data.base-points.rainstorm}") @Value("${init.data.base-points.hidden-danger.rainstorm}")
private String rainstormBasePointsKey; private String rainstormBasePointsKey;
@Value("${init.data.base-points.earthquake}") @Value("${init.data.base-points.hidden-danger.earthquake}")
private String earthquakeBasePointsKey; private String earthquakeBasePointsKey;
@Override @Override
@@ -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<String, Object> redisTemplate;
@Value("${init.data.base-points.risk}")
private String riskPointKey;
@Override
public List<XianRiskSpotsBasePoint> getBasePoints() {
// 从redis中读取基础点信息
Object data = redisTemplate.opsForValue().get(riskPointKey);
if (data == null) {
List<XianRiskSpotsBasePoint> 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);
}
}
@@ -3,6 +3,7 @@ package com.gis.xian.task;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.gis.xian.enums.DisasterTypeEnum; import com.gis.xian.enums.DisasterTypeEnum;
import com.gis.xian.mapper.XianHiddenDangerSpotsMapper; import com.gis.xian.mapper.XianHiddenDangerSpotsMapper;
import com.gis.xian.mapper.XianRiskSpotsMapper;
import jakarta.annotation.PostConstruct; import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -21,15 +22,21 @@ public class InitializeData {
@Resource @Resource
private XianHiddenDangerSpotsMapper xianHiddenDangerSpotsMapper; private XianHiddenDangerSpotsMapper xianHiddenDangerSpotsMapper;
@Resource
private XianRiskSpotsMapper xianRiskSpotsMapper;
@Resource @Resource
RedisTemplate<String, Object> redisTemplate; RedisTemplate<String, Object> redisTemplate;
@Value("${init.data.base-points.rainstorm}") @Value("${init.data.base-points.hidden-danger.rainstorm}")
private String rainstormBasePointsKey; private String rainstormBasePointsKey;
@Value("${init.data.base-points.earthquake}") @Value("${init.data.base-points.hidden-danger.earthquake}")
private String earthquakeBasePointsKey; private String earthquakeBasePointsKey;
@Value("${init.data.base-points.risk}")
private String riskBasePointsKey;
@PostConstruct @PostConstruct
@Async("xianPool") @Async("xianPool")
public void init() { public void init() {
@@ -39,6 +46,8 @@ public class InitializeData {
redisTemplate.opsForValue().set(rainstormBasePointsKey, JSON.toJSONString(xianHiddenDangerSpotsMapper.getBasePoints(DisasterTypeEnum.RAINSTORM.getType()))); redisTemplate.opsForValue().set(rainstormBasePointsKey, JSON.toJSONString(xianHiddenDangerSpotsMapper.getBasePoints(DisasterTypeEnum.RAINSTORM.getType())));
redisTemplate.opsForValue().set(earthquakeBasePointsKey, JSON.toJSONString(xianHiddenDangerSpotsMapper.getBasePoints(DisasterTypeEnum.EARTHQUAKE.getType()))); redisTemplate.opsForValue().set(earthquakeBasePointsKey, JSON.toJSONString(xianHiddenDangerSpotsMapper.getBasePoints(DisasterTypeEnum.EARTHQUAKE.getType())));
// 加载风险点基本信息写入redis
redisTemplate.opsForValue().set(riskBasePointsKey, JSON.toJSONString(xianRiskSpotsMapper.getBasePoints()));
log.info("初始化数据完成"); log.info("初始化数据完成");
} }
} }
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gis.xian.mapper.XianRiskSpotsMapper">
<resultMap id="XianRiskSpotsResultMap" type="com.gis.xian.entity.XianRiskSpots">
<id property="id" column="id" />
<result property="riskName" column="risk_name" />
<result property="unitCode" column="unit_code" />
<result property="riskLevel" column="risk_level" />
<result property="area" column="area" />
<result property="province" column="province" />
<result property="city" column="city" />
<result property="county" column="county" />
<result property="country" column="country" />
<result property="village" column="village" />
<result property="position" column="position" />
<result property="residentCounts" column="resident_counts" />
<result property="addressPopulation" column="address_population" />
<result property="riskProperty" column="risk_property" />
<result property="permanentPopulation" column="permanent_population" />
<result property="housing" column="housing" />
<result property="inspectorName" column="inspector_name" />
<result property="inspectorTele" column="inspector_tele" />
<result property="lon" column="lon" />
<result property="lat" column="lat" />
<result property="geom" column="geom" />
<result property="isDelete" column="is_delete" />
</resultMap>
<resultMap id="XianRiskSpotsBasePointResultMap" type="com.gis.xian.entity.XianRiskSpotsBasePoint">
<id property="id" column="id" />
<result property="lon" column="lon" />
<result property="lat" column="lat" />
</resultMap>
<resultMap id="XianRiskSpotsPointDetailResultMap" type="com.gis.xian.entity.XianRiskSpotsPointDetail">
<id property="id" column="id" />
<result property="riskName" column="risk_name" />
<result property="unitCode" column="unit_code" />
<result property="position" column="position" />
<result property="residentCounts" column="resident_counts" />
<result property="riskProperty" column="risk_property" />
<result property="permanentPopulation" column="permanent_population" />
<result property="housing" column="housing" />
<result property="inspectorName" column="inspector_name" />
<result property="inspectorTele" column="inspector_tele" />
<result property="lon" column="lon" />
<result property="lat" column="lat" />
</resultMap>
<!-- 获取所有风险点基础信息 -->
<select id="getBasePoints" resultMap="XianRiskSpotsBasePointResultMap">
SELECT id, lon, lat FROM xian_risk_spots
</select>
<!-- 根据id获取风险点信息 -->
<select id="getPointDetailById" resultType="com.gis.xian.entity.XianRiskSpotsPointDetail">
SELECT id, risk_name, unit_code, position, resident_counts, risk_property, permanent_population, housing, inspector_name, inspector_tele, lon, lat FROM xian_risk_spots
<where>
id = #{id}
</where>
</select>
</mapper>
@@ -10,5 +10,7 @@ init:
data: data:
# 基础信息点数据:滑坡、泥石流、山洪、内涝 # 基础信息点数据:滑坡、泥石流、山洪、内涝
base-points: base-points:
rainstorm: 'xian:init:data:base-points:rainstorm' hidden-danger:
earthquake: 'xian:init:data:base-points:earthquake' 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'