diff --git a/src/main/java/com/gis/xian/controller/XianSubwayStationsController.java b/src/main/java/com/gis/xian/controller/XianSubwayStationsController.java new file mode 100644 index 0000000..a1faa8e --- /dev/null +++ b/src/main/java/com/gis/xian/controller/XianSubwayStationsController.java @@ -0,0 +1,28 @@ +package com.gis.xian.controller; + +import com.gis.xian.domain.ApiResponse; +import com.gis.xian.vo.XianSubwayStationsBasePointVo; +import com.gis.xian.vo.XianSubwayStationsPointDetailVo; +import com.gis.xian.service.XianSubwayStationsService; +import jakarta.annotation.Resource; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("/subway") +public class XianSubwayStationsController extends BaseController{ + + @Resource + private XianSubwayStationsService xianSubwayStationsService; + + @GetMapping("/base-points") + public ApiResponse> getBasePoints() { + return ApiResponse.ok(xianSubwayStationsService.getBasePoints()); + } + + @GetMapping("/point-detail/{id}") + public ApiResponse getPointDetailById(@PathVariable String id) { + return ApiResponse.ok(xianSubwayStationsService.getPointDetailById(Long.parseLong(id))); + } +} diff --git a/src/main/java/com/gis/xian/entity/XianSubwayStations.java b/src/main/java/com/gis/xian/entity/XianSubwayStations.java new file mode 100644 index 0000000..bb22697 --- /dev/null +++ b/src/main/java/com/gis/xian/entity/XianSubwayStations.java @@ -0,0 +1,137 @@ +package com.gis.xian.entity; + +import lombok.Data; + +/** + * 西安地铁站点有属性 + * @TableName xian_subway_stations + */ +@Data +public class XianSubwayStations { + /** + * ID + */ + private Long id; + + /** + * 站点名称 + */ + private String stationName; + + /** + * 地铁线路 + */ + private String line; + + /** + * 地铁站点名称 + */ + private String pointName; + + /** + * 参照积水点 + */ + private String referToTheWaterAccumulationPoint; + + /** + * 积水深度 + */ + private String depthOfAccumulatedWater; + + /** + * 核算后积水深度 + */ + private String accumulatedWaterAfterAccounting; + + /** + * 站点防水物资 + */ + private String pointOtherDefenses; + + /** + * 经度 + */ + private Double lon; + + /** + * 纬度 + */ + private Double lat; + + /** + * 站点经纬度 + */ + private Object point; + + /** + * 逻辑删除标识,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; + } + XianSubwayStations other = (XianSubwayStations) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getStationName() == null ? other.getStationName() == null : this.getStationName().equals(other.getStationName())) + && (this.getLine() == null ? other.getLine() == null : this.getLine().equals(other.getLine())) + && (this.getPointName() == null ? other.getPointName() == null : this.getPointName().equals(other.getPointName())) + && (this.getReferToTheWaterAccumulationPoint() == null ? other.getReferToTheWaterAccumulationPoint() == null : this.getReferToTheWaterAccumulationPoint().equals(other.getReferToTheWaterAccumulationPoint())) + && (this.getDepthOfAccumulatedWater() == null ? other.getDepthOfAccumulatedWater() == null : this.getDepthOfAccumulatedWater().equals(other.getDepthOfAccumulatedWater())) + && (this.getAccumulatedWaterAfterAccounting() == null ? other.getAccumulatedWaterAfterAccounting() == null : this.getAccumulatedWaterAfterAccounting().equals(other.getAccumulatedWaterAfterAccounting())) + && (this.getPointOtherDefenses() == null ? other.getPointOtherDefenses() == null : this.getPointOtherDefenses().equals(other.getPointOtherDefenses())) + && (this.getLon() == null ? other.getLon() == null : this.getLon().equals(other.getLon())) + && (this.getLat() == null ? other.getLat() == null : this.getLat().equals(other.getLat())) + && (this.getPoint() == null ? other.getPoint() == null : this.getPoint().equals(other.getPoint())) + && (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 + ((getStationName() == null) ? 0 : getStationName().hashCode()); + result = prime * result + ((getLine() == null) ? 0 : getLine().hashCode()); + result = prime * result + ((getPointName() == null) ? 0 : getPointName().hashCode()); + result = prime * result + ((getReferToTheWaterAccumulationPoint() == null) ? 0 : getReferToTheWaterAccumulationPoint().hashCode()); + result = prime * result + ((getDepthOfAccumulatedWater() == null) ? 0 : getDepthOfAccumulatedWater().hashCode()); + result = prime * result + ((getAccumulatedWaterAfterAccounting() == null) ? 0 : getAccumulatedWaterAfterAccounting().hashCode()); + result = prime * result + ((getPointOtherDefenses() == null) ? 0 : getPointOtherDefenses().hashCode()); + result = prime * result + ((getLon() == null) ? 0 : getLon().hashCode()); + result = prime * result + ((getLat() == null) ? 0 : getLat().hashCode()); + result = prime * result + ((getPoint() == null) ? 0 : getPoint().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(", stationName=").append(stationName); + sb.append(", line=").append(line); + sb.append(", pointName=").append(pointName); + sb.append(", referToTheWaterAccumulationPoint=").append(referToTheWaterAccumulationPoint); + sb.append(", depthOfAccumulatedWater=").append(depthOfAccumulatedWater); + sb.append(", accumulatedWaterAfterAccounting=").append(accumulatedWaterAfterAccounting); + sb.append(", pointOtherDefenses=").append(pointOtherDefenses); + sb.append(", lon=").append(lon); + sb.append(", lat=").append(lat); + sb.append(", point=").append(point); + 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/XianSubwayStationsMapper.java b/src/main/java/com/gis/xian/mapper/XianSubwayStationsMapper.java new file mode 100644 index 0000000..066fc87 --- /dev/null +++ b/src/main/java/com/gis/xian/mapper/XianSubwayStationsMapper.java @@ -0,0 +1,26 @@ +package com.gis.xian.mapper; + +import com.gis.xian.entity.XianSubwayStations; + +import java.util.List; + +/** +* @author strong +* @description 针对表【xian_subway_stations(西安地铁站点有属性)】的数据库操作Mapper +* @createDate 2026-04-27 14:52:32 +* @Entity com.gis.xian.entity.XianSubwayStations +*/ +public interface XianSubwayStationsMapper { + /** + * 获取所有地铁站点基础点 + * @return 基础点列表 + */ + List getBasePoints(); + + /** + * 根据id获取地铁站点详情 + * @param id 站点id + * @return 站点详情 + */ + XianSubwayStations getPointDetailById(Long id); +} diff --git a/src/main/java/com/gis/xian/service/XianSubwayStationsService.java b/src/main/java/com/gis/xian/service/XianSubwayStationsService.java new file mode 100644 index 0000000..edc6e75 --- /dev/null +++ b/src/main/java/com/gis/xian/service/XianSubwayStationsService.java @@ -0,0 +1,22 @@ +package com.gis.xian.service; + +import com.gis.xian.vo.XianSubwayStationsBasePointVo; +import com.gis.xian.vo.XianSubwayStationsPointDetailVo; + +import java.util.List; + +public interface XianSubwayStationsService { + + /** + * 获取所有地铁站点基础点 + * @return 基础点列表 + */ + List getBasePoints(); + + /** + * 根据id获取地铁站点详情 + * @param id 站点id + * @return 站点详情 + */ + XianSubwayStationsPointDetailVo getPointDetailById(Long id); +} diff --git a/src/main/java/com/gis/xian/service/impl/IXianSubwayStationsServiceImpl.java b/src/main/java/com/gis/xian/service/impl/IXianSubwayStationsServiceImpl.java new file mode 100644 index 0000000..4d3565e --- /dev/null +++ b/src/main/java/com/gis/xian/service/impl/IXianSubwayStationsServiceImpl.java @@ -0,0 +1,46 @@ +package com.gis.xian.service.impl; + +import com.alibaba.fastjson2.JSON; +import com.gis.xian.entity.XianSubwayStations; +import com.gis.xian.vo.XianSubwayStationsBasePointVo; +import com.gis.xian.vo.XianSubwayStationsPointDetailVo; +import com.gis.xian.mapper.XianSubwayStationsMapper; +import com.gis.xian.service.XianSubwayStationsService; +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 IXianSubwayStationsServiceImpl implements XianSubwayStationsService { + + @Resource + private RedisTemplate redisTemplate; + + @Resource + private XianSubwayStationsMapper xianSubwayStationsMapper; + + @Value("${init.data.base-points.subway}") + private String subwayBasePointsKey; + + @Override + public List getBasePoints() { + // 从redis中读取基础点信息 + Object data = redisTemplate.opsForValue().get(subwayBasePointsKey); + + if (data == null) { + List basePoints = XianSubwayStationsBasePointVo.entity2Vo(xianSubwayStationsMapper.getBasePoints()); + redisTemplate.opsForValue().set(subwayBasePointsKey, JSON.toJSONString(basePoints)); + return basePoints; + } + + return JSON.parseArray(data.toString(), XianSubwayStationsBasePointVo.class); + } + + @Override + public XianSubwayStationsPointDetailVo getPointDetailById(Long id) { + return XianSubwayStationsPointDetailVo.entity2Vo(xianSubwayStationsMapper.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 e5cbbb9..3ccc3fb 100644 --- a/src/main/java/com/gis/xian/task/InitializeData.java +++ b/src/main/java/com/gis/xian/task/InitializeData.java @@ -52,6 +52,9 @@ public class InitializeData { @Resource private XianReservoirListMapper xianReservoirListMapper; + @Resource + private XianSubwayStationsMapper xianSubwayStationsMapper; + @Resource RedisTemplate redisTemplate; @@ -88,6 +91,9 @@ public class InitializeData { @Value("${init.data.base-points.reservoir}") private String reservoirBasePointsKey; + @Value("${init.data.base-points.subway}") + private String subwayBasePointsKey; + @EventListener(ApplicationReadyEvent.class) @Async("xianPool") public void init() { @@ -192,11 +198,20 @@ public class InitializeData { log.info("加载水库基本信息写入redis完成"); }); + CompletableFuture subwayFuture = CompletableFuture.runAsync(() -> { + redisTemplate.opsForValue().set(subwayBasePointsKey, JSON.toJSONString( + XianSubwayStationsBasePointVo.entity2Vo( + xianSubwayStationsMapper.getBasePoints()) + ) + ); + log.info("加载地铁站点基本信息写入redis完成"); + }); + // 等待所有任务完成 CompletableFuture.allOf( rainstormFuture, earthquakeFuture, riskFuture, hospitalsFuture, dangerousSourceFuture, emergencyShelterFuture, firefighterFuture, storePointsFuture, schoolFuture, - bridgeFuture, reservoirFuture + bridgeFuture, reservoirFuture, subwayFuture ).join(); log.info("初始化数据完成"); diff --git a/src/main/java/com/gis/xian/vo/XianSubwayStationsBasePointVo.java b/src/main/java/com/gis/xian/vo/XianSubwayStationsBasePointVo.java new file mode 100644 index 0000000..ed8ba99 --- /dev/null +++ b/src/main/java/com/gis/xian/vo/XianSubwayStationsBasePointVo.java @@ -0,0 +1,66 @@ +package com.gis.xian.vo; + +import com.gis.xian.entity.XianSubwayStations; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * 地铁站点-基本点信息 + * @TableName xian_subway_stations + */ +@Data +public class XianSubwayStationsBasePointVo { + /** + * id + */ + private Long id; + + /** + * 站点名称 + */ + private String stationName; + + /** + * 经度 + */ + private Double lon; + + /** + * 纬度 + */ + private Double lat; + + public static XianSubwayStationsBasePointVo entity2Vo(XianSubwayStations entity) { + XianSubwayStationsBasePointVo vo = new XianSubwayStationsBasePointVo(); + vo.setId(entity.getId()); + vo.setStationName(entity.getStationName()); + vo.setLon(entity.getLon()); + vo.setLat(entity.getLat()); + return vo; + } + + public static List entity2Vo(List entityList) { + List voList = new ArrayList<>(); + for (XianSubwayStations 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; + XianSubwayStationsBasePointVo that = (XianSubwayStationsBasePointVo) o; + return Objects.equals(id, that.id) && Objects.equals(stationName, that.stationName) + && Objects.equals(lon, that.lon) && Objects.equals(lat, that.lat); + } + + @Override + public int hashCode() { + return Objects.hash(id, stationName, lon, lat); + } +} diff --git a/src/main/java/com/gis/xian/vo/XianSubwayStationsPointDetailVo.java b/src/main/java/com/gis/xian/vo/XianSubwayStationsPointDetailVo.java new file mode 100644 index 0000000..3fb9119 --- /dev/null +++ b/src/main/java/com/gis/xian/vo/XianSubwayStationsPointDetailVo.java @@ -0,0 +1,88 @@ +package com.gis.xian.vo; + +import com.gis.xian.entity.XianSubwayStations; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * 地铁站点-详细信息 + * @TableName xian_subway_stations + */ +@Data +public class XianSubwayStationsPointDetailVo { + /** + * id + */ + private Long id; + + /** + * 站点名称(地铁站名称) + */ + private String stationName; + + /** + * 参照积水点 + */ + private String referToTheWaterAccumulationPoint; + + /** + * 积水深度 + */ + private String depthOfAccumulatedWater; + + /** + * 核算后积水深度 + */ + private String accumulatedWaterAfterAccounting; + + /** + * 经度 + */ + private Double lon; + + /** + * 纬度 + */ + private Double lat; + + public static XianSubwayStationsPointDetailVo entity2Vo(XianSubwayStations entity) { + XianSubwayStationsPointDetailVo vo = new XianSubwayStationsPointDetailVo(); + vo.setId(entity.getId()); + vo.setStationName(entity.getStationName()); + vo.setReferToTheWaterAccumulationPoint(entity.getReferToTheWaterAccumulationPoint()); + vo.setDepthOfAccumulatedWater(entity.getDepthOfAccumulatedWater()); + vo.setAccumulatedWaterAfterAccounting(entity.getAccumulatedWaterAfterAccounting()); + vo.setLon(entity.getLon()); + vo.setLat(entity.getLat()); + return vo; + } + + public static List entity2Vo(List entityList) { + List voList = new ArrayList<>(); + for (XianSubwayStations 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; + XianSubwayStationsPointDetailVo that = (XianSubwayStationsPointDetailVo) o; + return Objects.equals(id, that.id) && Objects.equals(stationName, that.stationName) + && Objects.equals(referToTheWaterAccumulationPoint, that.referToTheWaterAccumulationPoint) + && Objects.equals(depthOfAccumulatedWater, that.depthOfAccumulatedWater) + && Objects.equals(accumulatedWaterAfterAccounting, that.accumulatedWaterAfterAccounting) + && Objects.equals(lon, that.lon) && Objects.equals(lat, that.lat); + } + + @Override + public int hashCode() { + return Objects.hash(id, stationName, referToTheWaterAccumulationPoint, depthOfAccumulatedWater, + accumulatedWaterAfterAccounting, lon, lat); + } +} diff --git a/src/main/resources/com/gis/xian/mapper/XianSubwayStationsMapper.xml b/src/main/resources/com/gis/xian/mapper/XianSubwayStationsMapper.xml new file mode 100644 index 0000000..0fce145 --- /dev/null +++ b/src/main/resources/com/gis/xian/mapper/XianSubwayStationsMapper.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + id,station_name,line,point_name,refer_to_the_water_accumulation_point,depth_of_accumulated_water, + accumulated_water_after_accounting,point_other_defenses,lon,lat,point, + is_delete + + + + + + + + diff --git a/src/main/resources/config/redis/redis-key.yml b/src/main/resources/config/redis/redis-key.yml index 5bcec2a..6ef49da 100644 --- a/src/main/resources/config/redis/redis-key.yml +++ b/src/main/resources/config/redis/redis-key.yml @@ -21,4 +21,5 @@ init: store-points: 'xian:init:data:base-points:store-points' school: 'xian:init:data:base-points:school' bridge: 'xian:init:data:base-points:bridge' - reservoir: 'xian:init:data:base-points:reservoir' \ No newline at end of file + reservoir: 'xian:init:data:base-points:reservoir' + subway: 'xian:init:data:base-points:subway' \ No newline at end of file