redis单独配置
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package com.gis.xian.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 基础信息点 Redis Key 配置属性
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "init.data.base-points")
|
||||
public class BasePointsRedisProperties {
|
||||
|
||||
private HiddenDanger hiddenDanger;
|
||||
private String risk;
|
||||
private String hospitals;
|
||||
private String dangerousSource;
|
||||
private String emergencyShelter;
|
||||
private String firefighter;
|
||||
private String storePoints;
|
||||
private String school;
|
||||
private String bridge;
|
||||
private String reservoir;
|
||||
private String subway;
|
||||
|
||||
@Data
|
||||
public static class HiddenDanger {
|
||||
private String all;
|
||||
private String landslide;
|
||||
private String collapse;
|
||||
private String debrisFlow;
|
||||
private String flashFlood;
|
||||
private String waterLogging;
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@ import com.gis.xian.mapper.*;
|
||||
import com.gis.xian.vo.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.gis.xian.config.BasePointsRedisProperties;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
@@ -19,7 +19,7 @@ import java.util.concurrent.Executor;
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
//@Component
|
||||
@Component
|
||||
@Slf4j
|
||||
public class InitializeData {
|
||||
|
||||
@@ -63,53 +63,8 @@ public class InitializeData {
|
||||
@Qualifier("xianPool")
|
||||
private Executor xianPoolExecutor;
|
||||
|
||||
@Value("${init.data.base-points.hidden-danger.all}")
|
||||
private String allBasePointsKey;
|
||||
|
||||
@Value("${init.data.base-points.hidden-danger.landslide}")
|
||||
private String landslideKey;
|
||||
|
||||
@Value("${init.data.base-points.hidden-danger.collapse}")
|
||||
private String collapseKey;
|
||||
|
||||
@Value("${init.data.base-points.hidden-danger.debris-flow}")
|
||||
private String debrisFlowKey;
|
||||
|
||||
@Value("${init.data.base-points.hidden-danger.flash-flood}")
|
||||
private String flashFloodKey;
|
||||
|
||||
@Value("${init.data.base-points.hidden-danger.water-logging}")
|
||||
private String waterLoggingKey;
|
||||
|
||||
@Value("${init.data.base-points.risk}")
|
||||
private String riskBasePointsKey;
|
||||
|
||||
@Value("${init.data.base-points.hospitals}")
|
||||
private String hospitalsBasePointsKey;
|
||||
|
||||
@Value("${init.data.base-points.dangerous-source}")
|
||||
private String dangerousSourceBasePointsKey;
|
||||
|
||||
@Value("${init.data.base-points.emergency-shelter}")
|
||||
private String emergencyShelterBasePointsKey;
|
||||
|
||||
@Value("${init.data.base-points.firefighter}")
|
||||
private String firefighterBasePointsKey;
|
||||
|
||||
@Value("${init.data.base-points.store-points}")
|
||||
private String storePointsBasePointsKey;
|
||||
|
||||
@Value("${init.data.base-points.school}")
|
||||
private String schoolBasePointsKey;
|
||||
|
||||
@Value("${init.data.base-points.bridge}")
|
||||
private String bridgeBasePointsKey;
|
||||
|
||||
@Value("${init.data.base-points.reservoir}")
|
||||
private String reservoirBasePointsKey;
|
||||
|
||||
@Value("${init.data.base-points.subway}")
|
||||
private String subwayBasePointsKey;
|
||||
@Resource
|
||||
private BasePointsRedisProperties basePoints;
|
||||
|
||||
@EventListener(ApplicationReadyEvent.class)
|
||||
@Async("xianPool")
|
||||
@@ -119,7 +74,7 @@ public class InitializeData {
|
||||
|
||||
// 隐患点 - 总体
|
||||
CompletableFuture<Void> allFuture = CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.opsForValue().set(allBasePointsKey, JSON.toJSONString(
|
||||
redisTemplate.opsForValue().set(basePoints.getHiddenDanger().getAll(), JSON.toJSONString(
|
||||
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
||||
xianHiddenDangerSpotsMapper.getBasePoints(null))
|
||||
)
|
||||
@@ -129,7 +84,7 @@ public class InitializeData {
|
||||
|
||||
// 隐患点 - 滑坡
|
||||
CompletableFuture<Void> landslideFuture = CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.opsForValue().set(landslideKey, JSON.toJSONString(
|
||||
redisTemplate.opsForValue().set(basePoints.getHiddenDanger().getLandslide(), JSON.toJSONString(
|
||||
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
||||
xianHiddenDangerSpotsMapper.getBasePoints("landslide"))
|
||||
)
|
||||
@@ -139,7 +94,7 @@ public class InitializeData {
|
||||
|
||||
// 隐患点 - 崩塌
|
||||
CompletableFuture<Void> collapseFuture = CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.opsForValue().set(collapseKey, JSON.toJSONString(
|
||||
redisTemplate.opsForValue().set(basePoints.getHiddenDanger().getCollapse(), JSON.toJSONString(
|
||||
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
||||
xianHiddenDangerSpotsMapper.getBasePoints("collapse"))
|
||||
)
|
||||
@@ -150,7 +105,7 @@ public class InitializeData {
|
||||
|
||||
// 隐患点 - 泥石流
|
||||
CompletableFuture<Void> debrisFlowFuture = CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.opsForValue().set(debrisFlowKey, JSON.toJSONString(
|
||||
redisTemplate.opsForValue().set(basePoints.getHiddenDanger().getDebrisFlow(), JSON.toJSONString(
|
||||
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
||||
xianHiddenDangerSpotsMapper.getBasePoints("debris_flow"))
|
||||
)
|
||||
@@ -160,7 +115,7 @@ public class InitializeData {
|
||||
|
||||
// 隐患点 - 山洪
|
||||
CompletableFuture<Void> flashFloodFuture = CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.opsForValue().set(flashFloodKey, JSON.toJSONString(
|
||||
redisTemplate.opsForValue().set(basePoints.getHiddenDanger().getFlashFlood(), JSON.toJSONString(
|
||||
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
||||
xianHiddenDangerSpotsMapper.getBasePoints("flash_flood"))
|
||||
)
|
||||
@@ -170,7 +125,7 @@ public class InitializeData {
|
||||
|
||||
// 隐患点 - 内涝
|
||||
CompletableFuture<Void> waterLoggingFuture = CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.opsForValue().set(waterLoggingKey, JSON.toJSONString(
|
||||
redisTemplate.opsForValue().set(basePoints.getHiddenDanger().getWaterLogging(), JSON.toJSONString(
|
||||
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
||||
xianHiddenDangerSpotsMapper.getBasePoints("water_logging"))
|
||||
)
|
||||
@@ -179,7 +134,7 @@ public class InitializeData {
|
||||
}, xianPoolExecutor);
|
||||
|
||||
CompletableFuture<Void> riskFuture = CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.opsForValue().set(riskBasePointsKey, JSON.toJSONString(
|
||||
redisTemplate.opsForValue().set(basePoints.getRisk(), JSON.toJSONString(
|
||||
XianRiskSpotsBasePointVo.entity2Vo(
|
||||
xianRiskSpotsMapper.getBasePoints())
|
||||
)
|
||||
@@ -188,7 +143,7 @@ public class InitializeData {
|
||||
}, xianPoolExecutor);
|
||||
|
||||
CompletableFuture<Void> hospitalsFuture = CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.opsForValue().set(hospitalsBasePointsKey, JSON.toJSONString(
|
||||
redisTemplate.opsForValue().set(basePoints.getHospitals(), JSON.toJSONString(
|
||||
XianHospitalsBasePointVo.entity2Vo(
|
||||
xianHospitalsMapper.getBasePoints())
|
||||
)
|
||||
@@ -197,7 +152,7 @@ public class InitializeData {
|
||||
}, xianPoolExecutor);
|
||||
|
||||
CompletableFuture<Void> dangerousSourceFuture = CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.opsForValue().set(dangerousSourceBasePointsKey, JSON.toJSONString(
|
||||
redisTemplate.opsForValue().set(basePoints.getDangerousSource(), JSON.toJSONString(
|
||||
XianDangerousSourceBasePointVo.entity2Vo(
|
||||
xianDangerousSourceMapper.getBasePoints())
|
||||
)
|
||||
@@ -206,7 +161,7 @@ public class InitializeData {
|
||||
}, xianPoolExecutor);
|
||||
|
||||
CompletableFuture<Void> emergencyShelterFuture = CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.opsForValue().set(emergencyShelterBasePointsKey, JSON.toJSONString(
|
||||
redisTemplate.opsForValue().set(basePoints.getEmergencyShelter(), JSON.toJSONString(
|
||||
XianEmergencyShelterBasePointVo.entity2Vo(
|
||||
xianEmergencyShelterMapper.getBasePoints())
|
||||
)
|
||||
@@ -215,7 +170,7 @@ public class InitializeData {
|
||||
}, xianPoolExecutor);
|
||||
|
||||
CompletableFuture<Void> firefighterFuture = CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.opsForValue().set(firefighterBasePointsKey, JSON.toJSONString(
|
||||
redisTemplate.opsForValue().set(basePoints.getFirefighter(), JSON.toJSONString(
|
||||
XianFirefighterBasePointVo.entity2Vo(
|
||||
xianFirefighterMapper.getBasePoints())
|
||||
)
|
||||
@@ -224,7 +179,7 @@ public class InitializeData {
|
||||
}, xianPoolExecutor);
|
||||
|
||||
CompletableFuture<Void> storePointsFuture = CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.opsForValue().set(storePointsBasePointsKey, JSON.toJSONString(
|
||||
redisTemplate.opsForValue().set(basePoints.getStorePoints(), JSON.toJSONString(
|
||||
XianStorePointsBasePointVo.entity2Vo(
|
||||
xianStorePointsMapper.getBasePoints())
|
||||
)
|
||||
@@ -233,7 +188,7 @@ public class InitializeData {
|
||||
}, xianPoolExecutor);
|
||||
|
||||
CompletableFuture<Void> schoolFuture = CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.opsForValue().set(schoolBasePointsKey, JSON.toJSONString(
|
||||
redisTemplate.opsForValue().set(basePoints.getSchool(), JSON.toJSONString(
|
||||
XianSchoolBasePointVo.entity2Vo(
|
||||
xianSchoolMapper.getBasePoints())
|
||||
)
|
||||
@@ -242,7 +197,7 @@ public class InitializeData {
|
||||
}, xianPoolExecutor);
|
||||
|
||||
CompletableFuture<Void> bridgeFuture = CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.opsForValue().set(bridgeBasePointsKey, JSON.toJSONString(
|
||||
redisTemplate.opsForValue().set(basePoints.getBridge(), JSON.toJSONString(
|
||||
XianBridgeBasePointVo.entity2Vo(
|
||||
xianBridgeMapper.getBasePoints())
|
||||
)
|
||||
@@ -251,7 +206,7 @@ public class InitializeData {
|
||||
}, xianPoolExecutor);
|
||||
|
||||
CompletableFuture<Void> reservoirFuture = CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.opsForValue().set(reservoirBasePointsKey, JSON.toJSONString(
|
||||
redisTemplate.opsForValue().set(basePoints.getReservoir(), JSON.toJSONString(
|
||||
XianReservoirListBasePointVo.entity2Vo(
|
||||
xianReservoirListMapper.getBasePoints())
|
||||
)
|
||||
@@ -260,7 +215,7 @@ public class InitializeData {
|
||||
}, xianPoolExecutor);
|
||||
|
||||
CompletableFuture<Void> subwayFuture = CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.opsForValue().set(subwayBasePointsKey, JSON.toJSONString(
|
||||
redisTemplate.opsForValue().set(basePoints.getSubway(), JSON.toJSONString(
|
||||
XianSubwayStationsBasePointVo.entity2Vo(
|
||||
xianSubwayStationsMapper.getBasePoints())
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user