地铁站

This commit is contained in:
zhuangzhuang2000
2026-04-27 15:05:13 +08:00
parent 0289f84fc2
commit d81cf76a03
10 changed files with 475 additions and 2 deletions
@@ -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<List<XianSubwayStationsBasePointVo>> getBasePoints() {
return ApiResponse.ok(xianSubwayStationsService.getBasePoints());
}
@GetMapping("/point-detail/{id}")
public ApiResponse<XianSubwayStationsPointDetailVo> getPointDetailById(@PathVariable String id) {
return ApiResponse.ok(xianSubwayStationsService.getPointDetailById(Long.parseLong(id)));
}
}
@@ -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();
}
}
@@ -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<XianSubwayStations> getBasePoints();
/**
* 根据id获取地铁站点详情
* @param id 站点id
* @return 站点详情
*/
XianSubwayStations getPointDetailById(Long id);
}
@@ -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<XianSubwayStationsBasePointVo> getBasePoints();
/**
* 根据id获取地铁站点详情
* @param id 站点id
* @return 站点详情
*/
XianSubwayStationsPointDetailVo getPointDetailById(Long id);
}
@@ -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<String, Object> redisTemplate;
@Resource
private XianSubwayStationsMapper xianSubwayStationsMapper;
@Value("${init.data.base-points.subway}")
private String subwayBasePointsKey;
@Override
public List<XianSubwayStationsBasePointVo> getBasePoints() {
// 从redis中读取基础点信息
Object data = redisTemplate.opsForValue().get(subwayBasePointsKey);
if (data == null) {
List<XianSubwayStationsBasePointVo> 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));
}
}
@@ -52,6 +52,9 @@ public class InitializeData {
@Resource
private XianReservoirListMapper xianReservoirListMapper;
@Resource
private XianSubwayStationsMapper xianSubwayStationsMapper;
@Resource
RedisTemplate<String, Object> 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<Void> 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("初始化数据完成");
@@ -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<XianSubwayStationsBasePointVo> entity2Vo(List<XianSubwayStations> entityList) {
List<XianSubwayStationsBasePointVo> 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);
}
}
@@ -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<XianSubwayStationsPointDetailVo> entity2Vo(List<XianSubwayStations> entityList) {
List<XianSubwayStationsPointDetailVo> 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);
}
}
@@ -0,0 +1,44 @@
<?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.XianSubwayStationsMapper">
<resultMap id="BaseResultMap" type="com.gis.xian.entity.XianSubwayStations">
<id property="id" column="id" />
<result property="stationName" column="station_name" />
<result property="line" column="line" />
<result property="pointName" column="point_name" />
<result property="referToTheWaterAccumulationPoint" column="refer_to_the_water_accumulation_point" />
<result property="depthOfAccumulatedWater" column="depth_of_accumulated_water" />
<result property="accumulatedWaterAfterAccounting" column="accumulated_water_after_accounting" />
<result property="pointOtherDefenses" column="point_other_defenses" />
<result property="lon" column="lon" />
<result property="lat" column="lat" />
<result property="point" column="point" />
<result property="isDelete" column="is_delete" />
</resultMap>
<sql id="Base_Column_List">
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
</sql>
<!-- 获取所有地铁站点基础点 -->
<select id="getBasePoints" resultMap="BaseResultMap">
SELECT id, station_name, lon, lat FROM xian_subway_stations
<where>
is_delete = 0
</where>
</select>
<!-- 根据id获取地铁站点详情 -->
<select id="getPointDetailById" resultMap="BaseResultMap">
SELECT id, station_name, refer_to_the_water_accumulation_point, depth_of_accumulated_water,
accumulated_water_after_accounting, lon, lat FROM xian_subway_stations
<where>
id = #{id} AND is_delete = 0
</where>
</select>
</mapper>
@@ -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'
reservoir: 'xian:init:data:base-points:reservoir'
subway: 'xian:init:data:base-points:subway'