This commit is contained in:
zhuangzhuang2000
2026-04-27 14:52:04 +08:00
parent 969a239474
commit 0289f84fc2
10 changed files with 495 additions and 2 deletions
@@ -0,0 +1,28 @@
package com.gis.xian.controller;
import com.gis.xian.domain.ApiResponse;
import com.gis.xian.vo.XianReservoirListBasePointVo;
import com.gis.xian.vo.XianReservoirListPointDetailVo;
import com.gis.xian.service.XianReservoirListService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/reservoir")
public class XianReservoirListController extends BaseController{
@Resource
private XianReservoirListService xianReservoirListService;
@GetMapping("/base-points")
public ApiResponse<List<XianReservoirListBasePointVo>> getBasePoints() {
return ApiResponse.ok(xianReservoirListService.getBasePoints());
}
@GetMapping("/point-detail/{id}")
public ApiResponse<XianReservoirListPointDetailVo> getPointDetailById(@PathVariable String id) {
return ApiResponse.ok(xianReservoirListService.getPointDetailById(Long.parseLong(id)));
}
}
@@ -0,0 +1,169 @@
package com.gis.xian.entity;
import lombok.Data;
/**
* 水库信息表
* @TableName xian_reservoir_list
*/
@Data
public class XianReservoirList {
/**
* ID
*/
private Long id;
/**
* 行政区划代码
*/
private String adminCode;
/**
* 水库名称
*/
private String reservoirName;
/**
* 水库位置
*/
private String location;
/**
* 水库安全状态编码
*/
private Integer safetyStatus;
/**
* 安全评定时间
*/
private String safetyAssessTime;
/**
* 安全评定结果
*/
private String safetyAssessResult;
/**
* 除险加固情况
*/
private String reinforceInfo;
/**
* 净防洪库容(万立方米)
*/
private Integer netFloodCapacity;
/**
* 工程规模编码
*/
private Integer projectScale;
/**
* 是否有隐患
*/
private String hasHiddenDanger;
/**
* 备注1
*/
private Integer note1;
/**
* 经度
*/
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;
}
XianReservoirList other = (XianReservoirList) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getAdminCode() == null ? other.getAdminCode() == null : this.getAdminCode().equals(other.getAdminCode()))
&& (this.getReservoirName() == null ? other.getReservoirName() == null : this.getReservoirName().equals(other.getReservoirName()))
&& (this.getLocation() == null ? other.getLocation() == null : this.getLocation().equals(other.getLocation()))
&& (this.getSafetyStatus() == null ? other.getSafetyStatus() == null : this.getSafetyStatus().equals(other.getSafetyStatus()))
&& (this.getSafetyAssessTime() == null ? other.getSafetyAssessTime() == null : this.getSafetyAssessTime().equals(other.getSafetyAssessTime()))
&& (this.getSafetyAssessResult() == null ? other.getSafetyAssessResult() == null : this.getSafetyAssessResult().equals(other.getSafetyAssessResult()))
&& (this.getReinforceInfo() == null ? other.getReinforceInfo() == null : this.getReinforceInfo().equals(other.getReinforceInfo()))
&& (this.getNetFloodCapacity() == null ? other.getNetFloodCapacity() == null : this.getNetFloodCapacity().equals(other.getNetFloodCapacity()))
&& (this.getProjectScale() == null ? other.getProjectScale() == null : this.getProjectScale().equals(other.getProjectScale()))
&& (this.getHasHiddenDanger() == null ? other.getHasHiddenDanger() == null : this.getHasHiddenDanger().equals(other.getHasHiddenDanger()))
&& (this.getNote1() == null ? other.getNote1() == null : this.getNote1().equals(other.getNote1()))
&& (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 + ((getAdminCode() == null) ? 0 : getAdminCode().hashCode());
result = prime * result + ((getReservoirName() == null) ? 0 : getReservoirName().hashCode());
result = prime * result + ((getLocation() == null) ? 0 : getLocation().hashCode());
result = prime * result + ((getSafetyStatus() == null) ? 0 : getSafetyStatus().hashCode());
result = prime * result + ((getSafetyAssessTime() == null) ? 0 : getSafetyAssessTime().hashCode());
result = prime * result + ((getSafetyAssessResult() == null) ? 0 : getSafetyAssessResult().hashCode());
result = prime * result + ((getReinforceInfo() == null) ? 0 : getReinforceInfo().hashCode());
result = prime * result + ((getNetFloodCapacity() == null) ? 0 : getNetFloodCapacity().hashCode());
result = prime * result + ((getProjectScale() == null) ? 0 : getProjectScale().hashCode());
result = prime * result + ((getHasHiddenDanger() == null) ? 0 : getHasHiddenDanger().hashCode());
result = prime * result + ((getNote1() == null) ? 0 : getNote1().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;
}
@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(", adminCode=").append(adminCode);
sb.append(", reservoirName=").append(reservoirName);
sb.append(", location=").append(location);
sb.append(", safetyStatus=").append(safetyStatus);
sb.append(", safetyAssessTime=").append(safetyAssessTime);
sb.append(", safetyAssessResult=").append(safetyAssessResult);
sb.append(", reinforceInfo=").append(reinforceInfo);
sb.append(", netFloodCapacity=").append(netFloodCapacity);
sb.append(", projectScale=").append(projectScale);
sb.append(", hasHiddenDanger=").append(hasHiddenDanger);
sb.append(", note1=").append(note1);
sb.append(", lon=").append(lon);
sb.append(", lat=").append(lat);
sb.append(", geom=").append(geom);
sb.append(", isDelete=").append(isDelete);
sb.append("]");
return sb.toString();
}
}
@@ -0,0 +1,26 @@
package com.gis.xian.mapper;
import com.gis.xian.entity.XianReservoirList;
import java.util.List;
/**
* @author strong
* @description 针对表【xian_reservoir_list(水库信息表)】的数据库操作Mapper
* @createDate 2026-04-27 14:25:32
* @Entity com.gis.xian.entity.XianReservoirList
*/
public interface XianReservoirListMapper {
/**
* 获取所有水库基础点
* @return 基础点列表
*/
List<XianReservoirList> getBasePoints();
/**
* 根据id获取水库详情
* @param id 水库id
* @return 水库详情
*/
XianReservoirList getPointDetailById(Long id);
}
@@ -0,0 +1,22 @@
package com.gis.xian.service;
import com.gis.xian.vo.XianReservoirListBasePointVo;
import com.gis.xian.vo.XianReservoirListPointDetailVo;
import java.util.List;
public interface XianReservoirListService {
/**
* 获取所有水库基础点
* @return 基础点列表
*/
List<XianReservoirListBasePointVo> getBasePoints();
/**
* 根据id获取水库详情
* @param id 水库id
* @return 水库详情
*/
XianReservoirListPointDetailVo getPointDetailById(Long id);
}
@@ -0,0 +1,46 @@
package com.gis.xian.service.impl;
import com.alibaba.fastjson2.JSON;
import com.gis.xian.entity.XianReservoirList;
import com.gis.xian.vo.XianReservoirListBasePointVo;
import com.gis.xian.vo.XianReservoirListPointDetailVo;
import com.gis.xian.mapper.XianReservoirListMapper;
import com.gis.xian.service.XianReservoirListService;
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 IXianReservoirListServiceImpl implements XianReservoirListService {
@Resource
private RedisTemplate<String, Object> redisTemplate;
@Resource
private XianReservoirListMapper xianReservoirListMapper;
@Value("${init.data.base-points.reservoir}")
private String reservoirBasePointsKey;
@Override
public List<XianReservoirListBasePointVo> getBasePoints() {
// 从redis中读取基础点信息
Object data = redisTemplate.opsForValue().get(reservoirBasePointsKey);
if (data == null) {
List<XianReservoirListBasePointVo> basePoints = XianReservoirListBasePointVo.entity2Vo(xianReservoirListMapper.getBasePoints());
redisTemplate.opsForValue().set(reservoirBasePointsKey, JSON.toJSONString(basePoints));
return basePoints;
}
return JSON.parseArray(data.toString(), XianReservoirListBasePointVo.class);
}
@Override
public XianReservoirListPointDetailVo getPointDetailById(Long id) {
return XianReservoirListPointDetailVo.entity2Vo(xianReservoirListMapper.getPointDetailById(id));
}
}
@@ -49,6 +49,9 @@ public class InitializeData {
@Resource @Resource
private XianBridgeMapper xianBridgeMapper; private XianBridgeMapper xianBridgeMapper;
@Resource
private XianReservoirListMapper xianReservoirListMapper;
@Resource @Resource
RedisTemplate<String, Object> redisTemplate; RedisTemplate<String, Object> redisTemplate;
@@ -82,6 +85,9 @@ public class InitializeData {
@Value("${init.data.base-points.bridge}") @Value("${init.data.base-points.bridge}")
private String bridgeBasePointsKey; private String bridgeBasePointsKey;
@Value("${init.data.base-points.reservoir}")
private String reservoirBasePointsKey;
@EventListener(ApplicationReadyEvent.class) @EventListener(ApplicationReadyEvent.class)
@Async("xianPool") @Async("xianPool")
public void init() { public void init() {
@@ -177,11 +183,20 @@ public class InitializeData {
log.info("加载桥梁基本信息写入redis完成"); log.info("加载桥梁基本信息写入redis完成");
}); });
CompletableFuture<Void> reservoirFuture = CompletableFuture.runAsync(() -> {
redisTemplate.opsForValue().set(reservoirBasePointsKey, JSON.toJSONString(
XianReservoirListBasePointVo.entity2Vo(
xianReservoirListMapper.getBasePoints())
)
);
log.info("加载水库基本信息写入redis完成");
});
// 等待所有任务完成 // 等待所有任务完成
CompletableFuture.allOf( CompletableFuture.allOf(
rainstormFuture, earthquakeFuture, riskFuture, hospitalsFuture, rainstormFuture, earthquakeFuture, riskFuture, hospitalsFuture,
dangerousSourceFuture, emergencyShelterFuture, firefighterFuture, storePointsFuture, schoolFuture, dangerousSourceFuture, emergencyShelterFuture, firefighterFuture, storePointsFuture, schoolFuture,
bridgeFuture bridgeFuture, reservoirFuture
).join(); ).join();
log.info("初始化数据完成"); log.info("初始化数据完成");
@@ -0,0 +1,66 @@
package com.gis.xian.vo;
import com.gis.xian.entity.XianReservoirList;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* 水库-基本点信息
* @TableName xian_reservoir_list
*/
@Data
public class XianReservoirListBasePointVo {
/**
* id
*/
private Long id;
/**
* 水库名称
*/
private String reservoirName;
/**
* 经度
*/
private Double lon;
/**
* 纬度
*/
private Double lat;
public static XianReservoirListBasePointVo entity2Vo(XianReservoirList entity) {
XianReservoirListBasePointVo vo = new XianReservoirListBasePointVo();
vo.setId(entity.getId());
vo.setReservoirName(entity.getReservoirName());
vo.setLon(entity.getLon());
vo.setLat(entity.getLat());
return vo;
}
public static List<XianReservoirListBasePointVo> entity2Vo(List<XianReservoirList> entityList) {
List<XianReservoirListBasePointVo> voList = new ArrayList<>();
for (XianReservoirList entity : entityList) {
voList.add(entity2Vo(entity));
}
return voList;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
XianReservoirListBasePointVo that = (XianReservoirListBasePointVo) o;
return Objects.equals(id, that.id) && Objects.equals(reservoirName, that.reservoirName)
&& Objects.equals(lon, that.lon) && Objects.equals(lat, that.lat);
}
@Override
public int hashCode() {
return Objects.hash(id, reservoirName, lon, lat);
}
}
@@ -0,0 +1,79 @@
package com.gis.xian.vo;
import com.gis.xian.entity.XianReservoirList;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* 水库-详细信息
* @TableName xian_reservoir_list
*/
@Data
public class XianReservoirListPointDetailVo {
/**
* id
*/
private Long id;
/**
* 水库名称
*/
private String reservoirName;
/**
* 水库位置
*/
private String location;
/**
* 安全评定结果
*/
private String safetyAssessResult;
/**
* 经度
*/
private Double lon;
/**
* 纬度
*/
private Double lat;
public static XianReservoirListPointDetailVo entity2Vo(XianReservoirList entity) {
XianReservoirListPointDetailVo vo = new XianReservoirListPointDetailVo();
vo.setId(entity.getId());
vo.setReservoirName(entity.getReservoirName());
vo.setLocation(entity.getLocation());
vo.setSafetyAssessResult(entity.getSafetyAssessResult());
vo.setLon(entity.getLon());
vo.setLat(entity.getLat());
return vo;
}
public static List<XianReservoirListPointDetailVo> entity2Vo(List<XianReservoirList> entityList) {
List<XianReservoirListPointDetailVo> voList = new ArrayList<>();
for (XianReservoirList entity : entityList) {
voList.add(entity2Vo(entity));
}
return voList;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
XianReservoirListPointDetailVo that = (XianReservoirListPointDetailVo) o;
return Objects.equals(id, that.id) && Objects.equals(reservoirName, that.reservoirName)
&& Objects.equals(location, that.location) && Objects.equals(safetyAssessResult, that.safetyAssessResult)
&& Objects.equals(lon, that.lon) && Objects.equals(lat, that.lat);
}
@Override
public int hashCode() {
return Objects.hash(id, reservoirName, location, safetyAssessResult, lon, lat);
}
}
@@ -0,0 +1,41 @@
<?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.XianReservoirListMapper">
<resultMap id="BaseResultMap" type="com.gis.xian.entity.XianReservoirList">
<id property="id" column="id" />
<result property="adminCode" column="admin_code" />
<result property="reservoirName" column="reservoir_name" />
<result property="location" column="location" />
<result property="safetyStatus" column="safety_status" />
<result property="safetyAssessTime" column="safety_assess_time" />
<result property="safetyAssessResult" column="safety_assess_result" />
<result property="reinforceInfo" column="reinforce_info" />
<result property="netFloodCapacity" column="net_flood_capacity" />
<result property="projectScale" column="project_scale" />
<result property="hasHiddenDanger" column="has_hidden_danger" />
<result property="note1" column="note1" />
<result property="lon" column="longitude" />
<result property="lat" column="latitude" />
<result property="geom" column="geom" />
<result property="isDelete" column="is_delete" />
</resultMap>
<!-- 获取所有水库基础点 -->
<select id="getBasePoints" resultMap="BaseResultMap">
SELECT id, reservoir_name, longitude, latitude FROM xian_reservoir_list
<where>
is_delete = 0
</where>
</select>
<!-- 根据id获取水库详情 -->
<select id="getPointDetailById" resultMap="BaseResultMap">
SELECT id, reservoir_name, location, safety_assess_result, longitude, latitude FROM xian_reservoir_list
<where>
id = #{id} AND is_delete = 0
</where>
</select>
</mapper>
@@ -21,3 +21,4 @@ init:
store-points: 'xian:init:data:base-points:store-points' store-points: 'xian:init:data:base-points:store-points'
school: 'xian:init:data:base-points:school' school: 'xian:init:data:base-points:school'
bridge: 'xian:init:data:base-points:bridge' bridge: 'xian:init:data:base-points:bridge'
reservoir: 'xian:init:data:base-points:reservoir'