diff --git a/src/main/java/com/gis/xian/controller/XianReservoirListController.java b/src/main/java/com/gis/xian/controller/XianReservoirListController.java new file mode 100644 index 0000000..39b8bff --- /dev/null +++ b/src/main/java/com/gis/xian/controller/XianReservoirListController.java @@ -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> getBasePoints() { + return ApiResponse.ok(xianReservoirListService.getBasePoints()); + } + + @GetMapping("/point-detail/{id}") + public ApiResponse getPointDetailById(@PathVariable String id) { + return ApiResponse.ok(xianReservoirListService.getPointDetailById(Long.parseLong(id))); + } +} diff --git a/src/main/java/com/gis/xian/entity/XianReservoirList.java b/src/main/java/com/gis/xian/entity/XianReservoirList.java new file mode 100644 index 0000000..7b3d157 --- /dev/null +++ b/src/main/java/com/gis/xian/entity/XianReservoirList.java @@ -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(); + } +} \ No newline at end of file diff --git a/src/main/java/com/gis/xian/mapper/XianReservoirListMapper.java b/src/main/java/com/gis/xian/mapper/XianReservoirListMapper.java new file mode 100644 index 0000000..4d26968 --- /dev/null +++ b/src/main/java/com/gis/xian/mapper/XianReservoirListMapper.java @@ -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 getBasePoints(); + + /** + * 根据id获取水库详情 + * @param id 水库id + * @return 水库详情 + */ + XianReservoirList getPointDetailById(Long id); +} diff --git a/src/main/java/com/gis/xian/service/XianReservoirListService.java b/src/main/java/com/gis/xian/service/XianReservoirListService.java new file mode 100644 index 0000000..f9d3c3c --- /dev/null +++ b/src/main/java/com/gis/xian/service/XianReservoirListService.java @@ -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 getBasePoints(); + + /** + * 根据id获取水库详情 + * @param id 水库id + * @return 水库详情 + */ + XianReservoirListPointDetailVo getPointDetailById(Long id); +} diff --git a/src/main/java/com/gis/xian/service/impl/IXianReservoirListServiceImpl.java b/src/main/java/com/gis/xian/service/impl/IXianReservoirListServiceImpl.java new file mode 100644 index 0000000..d62ec88 --- /dev/null +++ b/src/main/java/com/gis/xian/service/impl/IXianReservoirListServiceImpl.java @@ -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 redisTemplate; + + @Resource + private XianReservoirListMapper xianReservoirListMapper; + + @Value("${init.data.base-points.reservoir}") + private String reservoirBasePointsKey; + + @Override + public List getBasePoints() { + // 从redis中读取基础点信息 + Object data = redisTemplate.opsForValue().get(reservoirBasePointsKey); + + if (data == null) { + List 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)); + } +} diff --git a/src/main/java/com/gis/xian/task/InitializeData.java b/src/main/java/com/gis/xian/task/InitializeData.java index c6ac0a2..e5cbbb9 100644 --- a/src/main/java/com/gis/xian/task/InitializeData.java +++ b/src/main/java/com/gis/xian/task/InitializeData.java @@ -49,6 +49,9 @@ public class InitializeData { @Resource private XianBridgeMapper xianBridgeMapper; + @Resource + private XianReservoirListMapper xianReservoirListMapper; + @Resource RedisTemplate redisTemplate; @@ -82,6 +85,9 @@ public class InitializeData { @Value("${init.data.base-points.bridge}") private String bridgeBasePointsKey; + @Value("${init.data.base-points.reservoir}") + private String reservoirBasePointsKey; + @EventListener(ApplicationReadyEvent.class) @Async("xianPool") public void init() { @@ -177,11 +183,20 @@ public class InitializeData { log.info("加载桥梁基本信息写入redis完成"); }); + CompletableFuture reservoirFuture = CompletableFuture.runAsync(() -> { + redisTemplate.opsForValue().set(reservoirBasePointsKey, JSON.toJSONString( + XianReservoirListBasePointVo.entity2Vo( + xianReservoirListMapper.getBasePoints()) + ) + ); + log.info("加载水库基本信息写入redis完成"); + }); + // 等待所有任务完成 CompletableFuture.allOf( rainstormFuture, earthquakeFuture, riskFuture, hospitalsFuture, dangerousSourceFuture, emergencyShelterFuture, firefighterFuture, storePointsFuture, schoolFuture, - bridgeFuture + bridgeFuture, reservoirFuture ).join(); log.info("初始化数据完成"); diff --git a/src/main/java/com/gis/xian/vo/XianReservoirListBasePointVo.java b/src/main/java/com/gis/xian/vo/XianReservoirListBasePointVo.java new file mode 100644 index 0000000..61320dd --- /dev/null +++ b/src/main/java/com/gis/xian/vo/XianReservoirListBasePointVo.java @@ -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 entity2Vo(List entityList) { + List 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); + } +} diff --git a/src/main/java/com/gis/xian/vo/XianReservoirListPointDetailVo.java b/src/main/java/com/gis/xian/vo/XianReservoirListPointDetailVo.java new file mode 100644 index 0000000..3fb9194 --- /dev/null +++ b/src/main/java/com/gis/xian/vo/XianReservoirListPointDetailVo.java @@ -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 entity2Vo(List entityList) { + List 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); + } +} diff --git a/src/main/resources/com/gis/xian/mapper/XianReservoirListMapper.xml b/src/main/resources/com/gis/xian/mapper/XianReservoirListMapper.xml new file mode 100644 index 0000000..34af4d3 --- /dev/null +++ b/src/main/resources/com/gis/xian/mapper/XianReservoirListMapper.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/redis/redis-key.yml b/src/main/resources/config/redis/redis-key.yml index d50b0e9..5bcec2a 100644 --- a/src/main/resources/config/redis/redis-key.yml +++ b/src/main/resources/config/redis/redis-key.yml @@ -20,4 +20,5 @@ init: firefighter: 'xian:init:data:base-points:firefighter' store-points: 'xian:init:data:base-points:store-points' school: 'xian:init:data:base-points:school' - bridge: 'xian:init:data:base-points:bridge' \ No newline at end of file + bridge: 'xian:init:data:base-points:bridge' + reservoir: 'xian:init:data:base-points:reservoir' \ No newline at end of file