桥梁
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package com.gis.xian.controller;
|
||||
|
||||
import com.gis.xian.domain.ApiResponse;
|
||||
import com.gis.xian.service.XianBridgeService;
|
||||
import com.gis.xian.vo.XianBridgeBasePointVo;
|
||||
import com.gis.xian.vo.XianBridgePointDetailVo;
|
||||
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("/bridge")
|
||||
public class XianBridgeController extends BaseController{
|
||||
|
||||
@Resource
|
||||
private XianBridgeService xianBridgeService;
|
||||
|
||||
@GetMapping("/base-points")
|
||||
public ApiResponse<List<XianBridgeBasePointVo>> getBasePoints() {
|
||||
return ApiResponse.ok(xianBridgeService.getBasePoints());
|
||||
}
|
||||
|
||||
@GetMapping("/point-detail/{id}")
|
||||
public ApiResponse<XianBridgePointDetailVo> getPointDetailById(@PathVariable String id) {
|
||||
return ApiResponse.ok(xianBridgeService.getPointDetailById(Long.parseLong(id)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.gis.xian.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 桥梁数据
|
||||
* @TableName xian_bridge
|
||||
*/
|
||||
@Data
|
||||
public class XianBridge {
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 区域
|
||||
*/
|
||||
private String region;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String bridgeName;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private Double lon;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private Double lat;
|
||||
|
||||
/**
|
||||
* 位置
|
||||
*/
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* 建成时间
|
||||
*/
|
||||
private String buildTime;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String bridgeType;
|
||||
|
||||
/**
|
||||
* 养护类型
|
||||
*/
|
||||
private String maintainType;
|
||||
|
||||
/**
|
||||
* 技术类型
|
||||
*/
|
||||
private String techType;
|
||||
|
||||
/**
|
||||
* 规模
|
||||
*/
|
||||
private String scale;
|
||||
|
||||
/**
|
||||
* 面积
|
||||
*/
|
||||
private Double area;
|
||||
|
||||
/**
|
||||
* 所属单位
|
||||
*/
|
||||
private String master;
|
||||
|
||||
/**
|
||||
* 养护单位
|
||||
*/
|
||||
private String maint;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String note;
|
||||
|
||||
/**
|
||||
* 位置
|
||||
*/
|
||||
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;
|
||||
}
|
||||
XianBridge other = (XianBridge) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getRegion() == null ? other.getRegion() == null : this.getRegion().equals(other.getRegion()))
|
||||
&& (this.getBridgeName() == null ? other.getBridgeName() == null : this.getBridgeName().equals(other.getBridgeName()))
|
||||
&& (this.getLon() == null ? other.getLon() == null : this.getLon().equals(other.getLon()))
|
||||
&& (this.getLat() == null ? other.getLat() == null : this.getLat().equals(other.getLat()))
|
||||
&& (this.getLocation() == null ? other.getLocation() == null : this.getLocation().equals(other.getLocation()))
|
||||
&& (this.getBuildTime() == null ? other.getBuildTime() == null : this.getBuildTime().equals(other.getBuildTime()))
|
||||
&& (this.getBridgeType() == null ? other.getBridgeType() == null : this.getBridgeType().equals(other.getBridgeType()))
|
||||
&& (this.getMaintainType() == null ? other.getMaintainType() == null : this.getMaintainType().equals(other.getMaintainType()))
|
||||
&& (this.getTechType() == null ? other.getTechType() == null : this.getTechType().equals(other.getTechType()))
|
||||
&& (this.getScale() == null ? other.getScale() == null : this.getScale().equals(other.getScale()))
|
||||
&& (this.getArea() == null ? other.getArea() == null : this.getArea().equals(other.getArea()))
|
||||
&& (this.getMaster() == null ? other.getMaster() == null : this.getMaster().equals(other.getMaster()))
|
||||
&& (this.getMaint() == null ? other.getMaint() == null : this.getMaint().equals(other.getMaint()))
|
||||
&& (this.getNote() == null ? other.getNote() == null : this.getNote().equals(other.getNote()))
|
||||
&& (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 + ((getRegion() == null) ? 0 : getRegion().hashCode());
|
||||
result = prime * result + ((getBridgeName() == null) ? 0 : getBridgeName().hashCode());
|
||||
result = prime * result + ((getLon() == null) ? 0 : getLon().hashCode());
|
||||
result = prime * result + ((getLat() == null) ? 0 : getLat().hashCode());
|
||||
result = prime * result + ((getLocation() == null) ? 0 : getLocation().hashCode());
|
||||
result = prime * result + ((getBuildTime() == null) ? 0 : getBuildTime().hashCode());
|
||||
result = prime * result + ((getBridgeType() == null) ? 0 : getBridgeType().hashCode());
|
||||
result = prime * result + ((getMaintainType() == null) ? 0 : getMaintainType().hashCode());
|
||||
result = prime * result + ((getTechType() == null) ? 0 : getTechType().hashCode());
|
||||
result = prime * result + ((getScale() == null) ? 0 : getScale().hashCode());
|
||||
result = prime * result + ((getArea() == null) ? 0 : getArea().hashCode());
|
||||
result = prime * result + ((getMaster() == null) ? 0 : getMaster().hashCode());
|
||||
result = prime * result + ((getMaint() == null) ? 0 : getMaint().hashCode());
|
||||
result = prime * result + ((getNote() == null) ? 0 : getNote().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(", region=").append(region);
|
||||
sb.append(", bridgeName=").append(bridgeName);
|
||||
sb.append(", lon=").append(lon);
|
||||
sb.append(", lat=").append(lat);
|
||||
sb.append(", location=").append(location);
|
||||
sb.append(", buildTime=").append(buildTime);
|
||||
sb.append(", bridgeType=").append(bridgeType);
|
||||
sb.append(", maintainType=").append(maintainType);
|
||||
sb.append(", techType=").append(techType);
|
||||
sb.append(", scale=").append(scale);
|
||||
sb.append(", area=").append(area);
|
||||
sb.append(", master=").append(master);
|
||||
sb.append(", maint=").append(maint);
|
||||
sb.append(", note=").append(note);
|
||||
sb.append(", point=").append(point);
|
||||
sb.append(", isDelete=").append(isDelete);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.gis.xian.mapper;
|
||||
|
||||
import com.gis.xian.entity.XianBridge;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author strong
|
||||
* @description 针对表【xian_bridge(桥梁数据)】的数据库操作Mapper
|
||||
* @createDate 2026-04-27 13:01:53
|
||||
* @Entity com.gis.xian.entity.XianBridge
|
||||
*/
|
||||
public interface XianBridgeMapper {
|
||||
/**
|
||||
* 获取所有桥梁基础点
|
||||
* @return 基础点列表
|
||||
*/
|
||||
List<XianBridge> getBasePoints();
|
||||
|
||||
/**
|
||||
* 根据id获取桥梁详情
|
||||
* @param id 桥梁id
|
||||
* @return 桥梁详情
|
||||
*/
|
||||
XianBridge getPointDetailById(Long id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.gis.xian.service;
|
||||
|
||||
import com.gis.xian.vo.XianBridgeBasePointVo;
|
||||
import com.gis.xian.vo.XianBridgePointDetailVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface XianBridgeService {
|
||||
|
||||
/**
|
||||
* 获取所有桥梁基础点
|
||||
* @return 基础点列表
|
||||
*/
|
||||
List<XianBridgeBasePointVo> getBasePoints();
|
||||
|
||||
/**
|
||||
* 根据id获取桥梁详情
|
||||
* @param id 桥梁id
|
||||
* @return 桥梁详情
|
||||
*/
|
||||
XianBridgePointDetailVo getPointDetailById(Long id);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.gis.xian.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.gis.xian.mapper.XianBridgeMapper;
|
||||
import com.gis.xian.service.XianBridgeService;
|
||||
import com.gis.xian.vo.XianBridgeBasePointVo;
|
||||
import com.gis.xian.vo.XianBridgePointDetailVo;
|
||||
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 IXianBridgeServiceImpl implements XianBridgeService {
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@Resource
|
||||
private XianBridgeMapper xianBridgeMapper;
|
||||
|
||||
@Value("${init.data.base-points.bridge}")
|
||||
private String bridgeBasePointsKey;
|
||||
|
||||
@Override
|
||||
public List<XianBridgeBasePointVo> getBasePoints() {
|
||||
// 从redis中读取基础点信息
|
||||
Object data = redisTemplate.opsForValue().get(bridgeBasePointsKey);
|
||||
|
||||
if (data == null) {
|
||||
List<XianBridgeBasePointVo> basePoints = XianBridgeBasePointVo.entity2Vo(xianBridgeMapper.getBasePoints());
|
||||
redisTemplate.opsForValue().set(bridgeBasePointsKey, JSON.toJSONString(basePoints));
|
||||
return basePoints;
|
||||
}
|
||||
|
||||
return JSON.parseArray(data.toString(), XianBridgeBasePointVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XianBridgePointDetailVo getPointDetailById(Long id) {
|
||||
return XianBridgePointDetailVo.entity2Vo(xianBridgeMapper.getPointDetailById(id));
|
||||
}
|
||||
}
|
||||
@@ -2,22 +2,8 @@ package com.gis.xian.task;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.gis.xian.enums.DisasterTypeEnum;
|
||||
import com.gis.xian.mapper.XianDangerousSourceMapper;
|
||||
import com.gis.xian.mapper.XianEmergencyShelterMapper;
|
||||
import com.gis.xian.mapper.XianFirefighterMapper;
|
||||
import com.gis.xian.mapper.XianHiddenDangerSpotsMapper;
|
||||
import com.gis.xian.mapper.XianHospitalsMapper;
|
||||
import com.gis.xian.mapper.XianRiskSpotsMapper;
|
||||
import com.gis.xian.mapper.XianSchoolMapper;
|
||||
import com.gis.xian.mapper.XianStorePointsMapper;
|
||||
import com.gis.xian.vo.XianDangerousSourceBasePointVo;
|
||||
import com.gis.xian.vo.XianEmergencyShelterBasePointVo;
|
||||
import com.gis.xian.vo.XianFirefighterBasePointVo;
|
||||
import com.gis.xian.vo.XianHiddenDangerSpotsBasePointVo;
|
||||
import com.gis.xian.vo.XianHospitalsBasePointVo;
|
||||
import com.gis.xian.vo.XianRiskSpotsBasePointVo;
|
||||
import com.gis.xian.vo.XianSchoolBasePointVo;
|
||||
import com.gis.xian.vo.XianStorePointsBasePointVo;
|
||||
import com.gis.xian.mapper.*;
|
||||
import com.gis.xian.vo.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -60,6 +46,9 @@ public class InitializeData {
|
||||
@Resource
|
||||
private XianSchoolMapper xianSchoolMapper;
|
||||
|
||||
@Resource
|
||||
private XianBridgeMapper xianBridgeMapper;
|
||||
|
||||
@Resource
|
||||
RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@@ -90,6 +79,9 @@ public class InitializeData {
|
||||
@Value("${init.data.base-points.school}")
|
||||
private String schoolBasePointsKey;
|
||||
|
||||
@Value("${init.data.base-points.bridge}")
|
||||
private String bridgeBasePointsKey;
|
||||
|
||||
@EventListener(ApplicationReadyEvent.class)
|
||||
@Async("xianPool")
|
||||
public void init() {
|
||||
@@ -176,10 +168,20 @@ public class InitializeData {
|
||||
log.info("加载学校基本信息写入redis完成");
|
||||
});
|
||||
|
||||
CompletableFuture<Void> bridgeFuture = CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.opsForValue().set(bridgeBasePointsKey, JSON.toJSONString(
|
||||
XianBridgeBasePointVo.entity2Vo(
|
||||
xianBridgeMapper.getBasePoints())
|
||||
)
|
||||
);
|
||||
log.info("加载桥梁基本信息写入redis完成");
|
||||
});
|
||||
|
||||
// 等待所有任务完成
|
||||
CompletableFuture.allOf(
|
||||
rainstormFuture, earthquakeFuture, riskFuture, hospitalsFuture,
|
||||
dangerousSourceFuture, emergencyShelterFuture, firefighterFuture, storePointsFuture, schoolFuture
|
||||
dangerousSourceFuture, emergencyShelterFuture, firefighterFuture, storePointsFuture, schoolFuture,
|
||||
bridgeFuture
|
||||
).join();
|
||||
|
||||
log.info("初始化数据完成");
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.gis.xian.vo;
|
||||
|
||||
import com.gis.xian.entity.XianBridge;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 桥梁数据
|
||||
* @TableName xian_bridge
|
||||
*/
|
||||
@Data
|
||||
public class XianBridgeBasePointVo {
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String bridgeName;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private Double lon;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private Double lat;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
XianBridgeBasePointVo that = (XianBridgeBasePointVo) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(bridgeName, that.bridgeName) && Objects.equals(lon, that.lon) && Objects.equals(lat, that.lat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, bridgeName, lon, lat);
|
||||
}
|
||||
public static XianBridgeBasePointVo entity2Vo(XianBridge entity) {
|
||||
XianBridgeBasePointVo vo = new XianBridgeBasePointVo();
|
||||
vo.setId(entity.getId());
|
||||
vo.setBridgeName(entity.getBridgeName());
|
||||
vo.setLon(entity.getLon() != null ? entity.getLon().doubleValue() : null);
|
||||
vo.setLat(entity.getLat() != null ? entity.getLat().doubleValue() : null);
|
||||
return vo;
|
||||
}
|
||||
|
||||
public static List<XianBridgeBasePointVo> entity2Vo(List<XianBridge> entityList) {
|
||||
List<XianBridgeBasePointVo> voList = new ArrayList<>();
|
||||
for (XianBridge entity : entityList) {
|
||||
voList.add(entity2Vo(entity));
|
||||
}
|
||||
return voList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.gis.xian.vo;
|
||||
|
||||
import com.gis.xian.entity.XianBridge;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 桥梁数据
|
||||
* @TableName xian_bridge
|
||||
*/
|
||||
@Data
|
||||
public class XianBridgePointDetailVo {
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String bridgeName;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private Double lon;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private Double lat;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String bridgeType;
|
||||
|
||||
/**
|
||||
* 技术类型
|
||||
*/
|
||||
private String techType;
|
||||
|
||||
|
||||
public static XianBridgePointDetailVo entity2Vo(XianBridge entity) {
|
||||
XianBridgePointDetailVo vo = new XianBridgePointDetailVo();
|
||||
vo.setId(entity.getId());
|
||||
vo.setBridgeName(entity.getBridgeName());
|
||||
vo.setLon(entity.getLon() != null ? entity.getLon().doubleValue() : null);
|
||||
vo.setLat(entity.getLat() != null ? entity.getLat().doubleValue() : null);
|
||||
vo.setBridgeType(entity.getBridgeType());
|
||||
vo.setTechType(entity.getTechType());
|
||||
return vo;
|
||||
}
|
||||
|
||||
public static List<XianBridgePointDetailVo> entity2Vo(List<XianBridge> entityList) {
|
||||
List<XianBridgePointDetailVo> voList = new ArrayList<>();
|
||||
for (XianBridge entity : entityList) {
|
||||
voList.add(entity2Vo(entity));
|
||||
}
|
||||
return voList;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
XianBridgePointDetailVo that = (XianBridgePointDetailVo) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(bridgeName, that.bridgeName) && Objects.equals(lon, that.lon) && Objects.equals(lat, that.lat) && Objects.equals(bridgeType, that.bridgeType) && Objects.equals(techType, that.techType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, bridgeName, lon, lat, bridgeType, techType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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.XianBridgeMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.gis.xian.entity.XianBridge">
|
||||
<id property="id" column="id" />
|
||||
<result property="region" column="region" />
|
||||
<result property="bridgeName" column="bridge_name" />
|
||||
<result property="lon" column="lon" />
|
||||
<result property="lat" column="lat" />
|
||||
<result property="location" column="location" />
|
||||
<result property="buildTime" column="build_time" />
|
||||
<result property="bridgeType" column="bridge_type" />
|
||||
<result property="maintainType" column="maintain_type" />
|
||||
<result property="techType" column="tech_type" />
|
||||
<result property="scale" column="scale" />
|
||||
<result property="area" column="area" />
|
||||
<result property="master" column="master" />
|
||||
<result property="maint" column="maint" />
|
||||
<result property="note" column="note" />
|
||||
<result property="point" column="point" />
|
||||
<result property="isDelete" column="is_delete" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="getBasePoints" resultMap="BaseResultMap">
|
||||
SELECT id, bridge_name, lon, lat FROM xian_bridge
|
||||
<where>
|
||||
is_delete = 0
|
||||
</where>
|
||||
</select>
|
||||
<select id="getPointDetailById" resultMap="BaseResultMap">
|
||||
SELECT id, bridge_name, lon, lat, bridge_type, tech_type FROM xian_bridge
|
||||
<where>
|
||||
id = #{id} AND is_delete = 0
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -19,4 +19,5 @@ init:
|
||||
emergency-shelter: 'xian:init:data:base-points:emergency-shelter'
|
||||
firefighter: 'xian:init:data:base-points:firefighter'
|
||||
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'
|
||||
Reference in New Issue
Block a user