避难所
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package com.gis.xian.controller;
|
||||
|
||||
import com.gis.xian.domain.ApiResponse;
|
||||
import com.gis.xian.vo.XianEmergencyShelterBasePointVo;
|
||||
import com.gis.xian.vo.XianEmergencyShelterPointDetailVo;
|
||||
import com.gis.xian.service.XianEmergencyShelterService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/emergency-shelter")
|
||||
public class XianEmergencyShelterController extends BaseController{
|
||||
|
||||
@Resource
|
||||
private XianEmergencyShelterService xianEmergencyShelterService;
|
||||
|
||||
@GetMapping("/base-points")
|
||||
public ApiResponse<List<XianEmergencyShelterBasePointVo>> getBasePoints() {
|
||||
return ApiResponse.ok(xianEmergencyShelterService.getBasePoints());
|
||||
}
|
||||
|
||||
@GetMapping("/point-detail/{id}")
|
||||
public ApiResponse<XianEmergencyShelterPointDetailVo> getPointDetailById(@PathVariable String id) {
|
||||
return ApiResponse.ok(xianEmergencyShelterService.getPointDetailById(Long.parseLong(id)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package com.gis.xian.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 应急避难所
|
||||
* @TableName xian_emergency_shelter
|
||||
*/
|
||||
@Data
|
||||
public class XianEmergencyShelter {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 避难所时间
|
||||
*/
|
||||
private String year;
|
||||
|
||||
/**
|
||||
* 避难所区县
|
||||
*/
|
||||
private String district;
|
||||
|
||||
/**
|
||||
* 避难所名字
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 避难所地址
|
||||
*/
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 避难所类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 避难所性质
|
||||
*/
|
||||
private String constructionCategory;
|
||||
|
||||
/**
|
||||
* 占地面积
|
||||
*/
|
||||
private String coverArea;
|
||||
|
||||
/**
|
||||
* 有效占地面积
|
||||
*/
|
||||
private String effectiveRefugeArea;
|
||||
|
||||
/**
|
||||
* 有效容纳人数
|
||||
*/
|
||||
private String effectiveNumberOfRefugees;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
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;
|
||||
}
|
||||
XianEmergencyShelter other = (XianEmergencyShelter) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getYear() == null ? other.getYear() == null : this.getYear().equals(other.getYear()))
|
||||
&& (this.getDistrict() == null ? other.getDistrict() == null : this.getDistrict().equals(other.getDistrict()))
|
||||
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
|
||||
&& (this.getAddress() == null ? other.getAddress() == null : this.getAddress().equals(other.getAddress()))
|
||||
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
|
||||
&& (this.getConstructionCategory() == null ? other.getConstructionCategory() == null : this.getConstructionCategory().equals(other.getConstructionCategory()))
|
||||
&& (this.getCoverArea() == null ? other.getCoverArea() == null : this.getCoverArea().equals(other.getCoverArea()))
|
||||
&& (this.getEffectiveRefugeArea() == null ? other.getEffectiveRefugeArea() == null : this.getEffectiveRefugeArea().equals(other.getEffectiveRefugeArea()))
|
||||
&& (this.getEffectiveNumberOfRefugees() == null ? other.getEffectiveNumberOfRefugees() == null : this.getEffectiveNumberOfRefugees().equals(other.getEffectiveNumberOfRefugees()))
|
||||
&& (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 + ((getYear() == null) ? 0 : getYear().hashCode());
|
||||
result = prime * result + ((getDistrict() == null) ? 0 : getDistrict().hashCode());
|
||||
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
|
||||
result = prime * result + ((getAddress() == null) ? 0 : getAddress().hashCode());
|
||||
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
|
||||
result = prime * result + ((getConstructionCategory() == null) ? 0 : getConstructionCategory().hashCode());
|
||||
result = prime * result + ((getCoverArea() == null) ? 0 : getCoverArea().hashCode());
|
||||
result = prime * result + ((getEffectiveRefugeArea() == null) ? 0 : getEffectiveRefugeArea().hashCode());
|
||||
result = prime * result + ((getEffectiveNumberOfRefugees() == null) ? 0 : getEffectiveNumberOfRefugees().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(", year=").append(year);
|
||||
sb.append(", district=").append(district);
|
||||
sb.append(", name=").append(name);
|
||||
sb.append(", address=").append(address);
|
||||
sb.append(", type=").append(type);
|
||||
sb.append(", constructionCategory=").append(constructionCategory);
|
||||
sb.append(", coverArea=").append(coverArea);
|
||||
sb.append(", effectiveRefugeArea=").append(effectiveRefugeArea);
|
||||
sb.append(", effectiveNumberOfRefugees=").append(effectiveNumberOfRefugees);
|
||||
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,30 @@
|
||||
package com.gis.xian.mapper;
|
||||
|
||||
import com.gis.xian.entity.XianEmergencyShelter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wzy
|
||||
* @description 针对表【xian_emergency_shelter(应急避难所)】的数据库操作Mapper
|
||||
* @createDate 2026-04-18 19:39:01
|
||||
* @Entity com.gis.xian.entity.XianEmergencyShelter
|
||||
*/
|
||||
public interface XianEmergencyShelterMapper {
|
||||
/**
|
||||
* 获取所有应急避难所基础点
|
||||
* @return 基础点列表
|
||||
*/
|
||||
List<XianEmergencyShelter> getBasePoints();
|
||||
|
||||
/**
|
||||
* 根据id获取应急避难所详情
|
||||
* @param id 应急避难所id
|
||||
* @return 应急避难所详情
|
||||
*/
|
||||
XianEmergencyShelter getPointDetailById(Long id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.gis.xian.service;
|
||||
|
||||
import com.gis.xian.vo.XianEmergencyShelterBasePointVo;
|
||||
import com.gis.xian.vo.XianEmergencyShelterPointDetailVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface XianEmergencyShelterService {
|
||||
|
||||
/**
|
||||
* 获取所有应急避难所基础点
|
||||
* @return 基础点列表
|
||||
*/
|
||||
List<XianEmergencyShelterBasePointVo> getBasePoints();
|
||||
|
||||
/**
|
||||
* 根据id获取应急避难所详情
|
||||
* @param id 应急避难所id
|
||||
* @return 应急避难所详情
|
||||
*/
|
||||
XianEmergencyShelterPointDetailVo getPointDetailById(Long id);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.gis.xian.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.gis.xian.entity.XianEmergencyShelter;
|
||||
import com.gis.xian.vo.XianEmergencyShelterBasePointVo;
|
||||
import com.gis.xian.vo.XianEmergencyShelterPointDetailVo;
|
||||
import com.gis.xian.mapper.XianEmergencyShelterMapper;
|
||||
import com.gis.xian.service.XianEmergencyShelterService;
|
||||
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 IXianEmergencyShelterServiceImpl implements XianEmergencyShelterService {
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@Resource
|
||||
private XianEmergencyShelterMapper xianEmergencyShelterMapper;
|
||||
|
||||
@Value("${init.data.base-points.emergency-shelter}")
|
||||
private String emergencyShelterBasePointsKey;
|
||||
|
||||
@Override
|
||||
public List<XianEmergencyShelterBasePointVo> getBasePoints() {
|
||||
// 从redis中读取基础点信息
|
||||
Object data = redisTemplate.opsForValue().get(emergencyShelterBasePointsKey);
|
||||
|
||||
if (data == null) {
|
||||
List<XianEmergencyShelterBasePointVo> basePoints = XianEmergencyShelterBasePointVo.entity2Vo(xianEmergencyShelterMapper.getBasePoints());
|
||||
redisTemplate.opsForValue().set(emergencyShelterBasePointsKey, JSON.toJSONString(basePoints));
|
||||
return basePoints;
|
||||
}
|
||||
|
||||
return JSON.parseArray(data.toString(), XianEmergencyShelterBasePointVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XianEmergencyShelterPointDetailVo getPointDetailById(Long id) {
|
||||
return XianEmergencyShelterPointDetailVo.entity2Vo(xianEmergencyShelterMapper.getPointDetailById(id));
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,12 @@ 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.XianHiddenDangerSpotsMapper;
|
||||
import com.gis.xian.mapper.XianHospitalsMapper;
|
||||
import com.gis.xian.mapper.XianRiskSpotsMapper;
|
||||
import com.gis.xian.vo.XianDangerousSourceBasePointVo;
|
||||
import com.gis.xian.vo.XianEmergencyShelterBasePointVo;
|
||||
import com.gis.xian.vo.XianHiddenDangerSpotsBasePointVo;
|
||||
import com.gis.xian.vo.XianHospitalsBasePointVo;
|
||||
import com.gis.xian.vo.XianRiskSpotsBasePointVo;
|
||||
@@ -37,6 +39,9 @@ public class InitializeData {
|
||||
@Resource
|
||||
private XianDangerousSourceMapper xianDangerousSourceMapper;
|
||||
|
||||
@Resource
|
||||
private XianEmergencyShelterMapper xianEmergencyShelterMapper;
|
||||
|
||||
@Resource
|
||||
RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@@ -55,6 +60,9 @@ public class InitializeData {
|
||||
@Value("${init.data.base-points.dangerous-source}")
|
||||
private String dangerousSourceBasePointsKey;
|
||||
|
||||
@Value("${init.data.base-points.emergency-shelter}")
|
||||
private String emergencyShelterBasePointsKey;
|
||||
|
||||
@PostConstruct
|
||||
@Async("xianPool")
|
||||
public void init() {
|
||||
@@ -92,6 +100,13 @@ public class InitializeData {
|
||||
xianDangerousSourceMapper.getBasePoints())
|
||||
)
|
||||
);
|
||||
|
||||
// 加载应急避难所基本信息写入redis
|
||||
redisTemplate.opsForValue().set(emergencyShelterBasePointsKey, JSON.toJSONString(
|
||||
XianEmergencyShelterBasePointVo.entity2Vo(
|
||||
xianEmergencyShelterMapper.getBasePoints())
|
||||
)
|
||||
);
|
||||
log.info("初始化数据完成");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.gis.xian.vo;
|
||||
|
||||
import com.gis.xian.entity.XianEmergencyShelter;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 应急避难所-基本点信息
|
||||
* @TableName xian_emergency_shelter
|
||||
*/
|
||||
@Data
|
||||
public class XianEmergencyShelterBasePointVo {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private Double lon;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private Double lat;
|
||||
|
||||
public static XianEmergencyShelterBasePointVo entity2Vo(XianEmergencyShelter entity) {
|
||||
XianEmergencyShelterBasePointVo vo = new XianEmergencyShelterBasePointVo();
|
||||
vo.setId(entity.getId());
|
||||
vo.setLon(entity.getLon() != null ? entity.getLon().doubleValue() : null);
|
||||
vo.setLat(entity.getLat() != null ? entity.getLat().doubleValue() : null);
|
||||
return vo;
|
||||
}
|
||||
|
||||
public static List<XianEmergencyShelterBasePointVo> entity2Vo(List<XianEmergencyShelter> entityList) {
|
||||
List<XianEmergencyShelterBasePointVo> voList = new ArrayList<>();
|
||||
for (XianEmergencyShelter 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;
|
||||
XianEmergencyShelterBasePointVo that = (XianEmergencyShelterBasePointVo) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(lon, that.lon) && Objects.equals(lat, that.lat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, lon, lat);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.gis.xian.vo;
|
||||
|
||||
import com.gis.xian.entity.XianEmergencyShelter;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 应急避难所-详细信息
|
||||
* @TableName xian_emergency_shelter
|
||||
*/
|
||||
@Data
|
||||
public class XianEmergencyShelterPointDetailVo {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 避难所名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 避难所类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 避难所地址
|
||||
*/
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private Double lon;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private Double lat;
|
||||
|
||||
/**
|
||||
* 可容纳最大人数
|
||||
*/
|
||||
private String effectiveNumberOfRefugees;
|
||||
|
||||
public static XianEmergencyShelterPointDetailVo entity2Vo(XianEmergencyShelter entity) {
|
||||
XianEmergencyShelterPointDetailVo vo = new XianEmergencyShelterPointDetailVo();
|
||||
vo.setId(entity.getId());
|
||||
vo.setName(entity.getName());
|
||||
vo.setType(entity.getType());
|
||||
vo.setAddress(entity.getAddress());
|
||||
vo.setLon(entity.getLon() != null ? entity.getLon().doubleValue() : null);
|
||||
vo.setLat(entity.getLat() != null ? entity.getLat().doubleValue() : null);
|
||||
vo.setEffectiveNumberOfRefugees(entity.getEffectiveNumberOfRefugees());
|
||||
return vo;
|
||||
}
|
||||
|
||||
public static List<XianEmergencyShelterPointDetailVo> entity2Vo(List<XianEmergencyShelter> entityList) {
|
||||
List<XianEmergencyShelterPointDetailVo> voList = new ArrayList<>();
|
||||
for (XianEmergencyShelter 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;
|
||||
XianEmergencyShelterPointDetailVo that = (XianEmergencyShelterPointDetailVo) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(name, that.name)
|
||||
&& Objects.equals(type, that.type) && Objects.equals(address, that.address)
|
||||
&& Objects.equals(lon, that.lon) && Objects.equals(lat, that.lat)
|
||||
&& Objects.equals(effectiveNumberOfRefugees, that.effectiveNumberOfRefugees);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name, type, address, lon, lat, effectiveNumberOfRefugees);
|
||||
}
|
||||
}
|
||||
@@ -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.XianEmergencyShelterMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.gis.xian.entity.XianEmergencyShelter">
|
||||
<id property="id" column="id" />
|
||||
<result property="year" column="year" />
|
||||
<result property="district" column="district" />
|
||||
<result property="name" column="name" />
|
||||
<result property="address" column="address" />
|
||||
<result property="type" column="type" />
|
||||
<result property="constructionCategory" column="construction_category" />
|
||||
<result property="coverArea" column="cover_area" />
|
||||
<result property="effectiveRefugeArea" column="effective_refuge_area" />
|
||||
<result property="effectiveNumberOfRefugees" column="effective_number_of_refugees" />
|
||||
<result property="lon" column="lon" />
|
||||
<result property="lat" column="lat" />
|
||||
<result property="point" column="point" />
|
||||
<result property="isDelete" column="is_delete" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 获取所有应急避难所基础点 -->
|
||||
<select id="getBasePoints" resultMap="BaseResultMap">
|
||||
SELECT id, lon, lat FROM xian_emergency_shelter
|
||||
<where>
|
||||
is_delete = 0
|
||||
<!-- 确定落在西安境内 -->
|
||||
AND ST_Within(point, (SELECT geom FROM xian_district WHERE id = 1))
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 根据id获取应急避难所详情 -->
|
||||
<select id="getPointDetailById" resultMap="BaseResultMap">
|
||||
SELECT id, name, type, address, lon, lat, effective_number_of_refugees FROM xian_emergency_shelter
|
||||
<where>
|
||||
id = #{id} AND is_delete = 0
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -15,4 +15,5 @@ init:
|
||||
earthquake: 'xian:init:data:base-points:hidden-danger:earthquake'
|
||||
risk: 'xian:init:data:base-points:risk'
|
||||
hospitals: 'xian:init:data:base-points:hospitals'
|
||||
dangerous-source: 'xian:init:data:base-points:dangerous-source'
|
||||
dangerous-source: 'xian:init:data:base-points:dangerous-source'
|
||||
emergency-shelter: 'xian:init:data:base-points:emergency-shelter'
|
||||
Reference in New Issue
Block a user