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 com.gis.xian.vo.*;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import com.gis.xian.config.BasePointsRedisProperties;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||||
import org.springframework.context.event.EventListener;
|
import org.springframework.context.event.EventListener;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
@@ -19,7 +19,7 @@ import java.util.concurrent.Executor;
|
|||||||
/**
|
/**
|
||||||
* 初始化数据
|
* 初始化数据
|
||||||
*/
|
*/
|
||||||
//@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class InitializeData {
|
public class InitializeData {
|
||||||
|
|
||||||
@@ -63,73 +63,28 @@ public class InitializeData {
|
|||||||
@Qualifier("xianPool")
|
@Qualifier("xianPool")
|
||||||
private Executor xianPoolExecutor;
|
private Executor xianPoolExecutor;
|
||||||
|
|
||||||
@Value("${init.data.base-points.hidden-danger.all}")
|
@Resource
|
||||||
private String allBasePointsKey;
|
private BasePointsRedisProperties basePoints;
|
||||||
|
|
||||||
@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;
|
|
||||||
|
|
||||||
@EventListener(ApplicationReadyEvent.class)
|
@EventListener(ApplicationReadyEvent.class)
|
||||||
@Async("xianPool")
|
@Async("xianPool")
|
||||||
public void init() {
|
public void init() {
|
||||||
log.info("开始初始化数据");
|
log.info("开始初始化数据");
|
||||||
// 并行执行所有数据库查询和Redis写入
|
// 并行执行所有数据库查询和Redis写入
|
||||||
|
|
||||||
// 隐患点 - 总体
|
// 隐患点 - 总体
|
||||||
CompletableFuture<Void> allFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> allFuture = CompletableFuture.runAsync(() -> {
|
||||||
redisTemplate.opsForValue().set(allBasePointsKey, JSON.toJSONString(
|
redisTemplate.opsForValue().set(basePoints.getHiddenDanger().getAll(), JSON.toJSONString(
|
||||||
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
||||||
xianHiddenDangerSpotsMapper.getBasePoints(null))
|
xianHiddenDangerSpotsMapper.getBasePoints(null))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
log.info("加载隐患点信息(总体)并写入redis完成");
|
log.info("加载隐患点信息(总体)并写入redis完成");
|
||||||
}, xianPoolExecutor);
|
}, xianPoolExecutor);
|
||||||
|
|
||||||
// 隐患点 - 滑坡
|
// 隐患点 - 滑坡
|
||||||
CompletableFuture<Void> landslideFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> landslideFuture = CompletableFuture.runAsync(() -> {
|
||||||
redisTemplate.opsForValue().set(landslideKey, JSON.toJSONString(
|
redisTemplate.opsForValue().set(basePoints.getHiddenDanger().getLandslide(), JSON.toJSONString(
|
||||||
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
||||||
xianHiddenDangerSpotsMapper.getBasePoints("landslide"))
|
xianHiddenDangerSpotsMapper.getBasePoints("landslide"))
|
||||||
)
|
)
|
||||||
@@ -139,7 +94,7 @@ public class InitializeData {
|
|||||||
|
|
||||||
// 隐患点 - 崩塌
|
// 隐患点 - 崩塌
|
||||||
CompletableFuture<Void> collapseFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> collapseFuture = CompletableFuture.runAsync(() -> {
|
||||||
redisTemplate.opsForValue().set(collapseKey, JSON.toJSONString(
|
redisTemplate.opsForValue().set(basePoints.getHiddenDanger().getCollapse(), JSON.toJSONString(
|
||||||
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
||||||
xianHiddenDangerSpotsMapper.getBasePoints("collapse"))
|
xianHiddenDangerSpotsMapper.getBasePoints("collapse"))
|
||||||
)
|
)
|
||||||
@@ -150,27 +105,27 @@ public class InitializeData {
|
|||||||
|
|
||||||
// 隐患点 - 泥石流
|
// 隐患点 - 泥石流
|
||||||
CompletableFuture<Void> debrisFlowFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> debrisFlowFuture = CompletableFuture.runAsync(() -> {
|
||||||
redisTemplate.opsForValue().set(debrisFlowKey, JSON.toJSONString(
|
redisTemplate.opsForValue().set(basePoints.getHiddenDanger().getDebrisFlow(), JSON.toJSONString(
|
||||||
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
||||||
xianHiddenDangerSpotsMapper.getBasePoints("debris_flow"))
|
xianHiddenDangerSpotsMapper.getBasePoints("debris_flow"))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
log.info("加载隐患点信息(泥石流)并写入redis完成");
|
log.info("加载隐患点信息(泥石流)并写入redis完成");
|
||||||
}, xianPoolExecutor);
|
}, xianPoolExecutor);
|
||||||
|
|
||||||
// 隐患点 - 山洪
|
// 隐患点 - 山洪
|
||||||
CompletableFuture<Void> flashFloodFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> flashFloodFuture = CompletableFuture.runAsync(() -> {
|
||||||
redisTemplate.opsForValue().set(flashFloodKey, JSON.toJSONString(
|
redisTemplate.opsForValue().set(basePoints.getHiddenDanger().getFlashFlood(), JSON.toJSONString(
|
||||||
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
||||||
xianHiddenDangerSpotsMapper.getBasePoints("flash_flood"))
|
xianHiddenDangerSpotsMapper.getBasePoints("flash_flood"))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
log.info("加载隐患点信息(山洪)并写入redis完成");
|
log.info("加载隐患点信息(山洪)并写入redis完成");
|
||||||
}, xianPoolExecutor);
|
}, xianPoolExecutor);
|
||||||
|
|
||||||
// 隐患点 - 内涝
|
// 隐患点 - 内涝
|
||||||
CompletableFuture<Void> waterLoggingFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> waterLoggingFuture = CompletableFuture.runAsync(() -> {
|
||||||
redisTemplate.opsForValue().set(waterLoggingKey, JSON.toJSONString(
|
redisTemplate.opsForValue().set(basePoints.getHiddenDanger().getWaterLogging(), JSON.toJSONString(
|
||||||
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
XianHiddenDangerSpotsBasePointVo.entity2Vo(
|
||||||
xianHiddenDangerSpotsMapper.getBasePoints("water_logging"))
|
xianHiddenDangerSpotsMapper.getBasePoints("water_logging"))
|
||||||
)
|
)
|
||||||
@@ -179,7 +134,7 @@ public class InitializeData {
|
|||||||
}, xianPoolExecutor);
|
}, xianPoolExecutor);
|
||||||
|
|
||||||
CompletableFuture<Void> riskFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> riskFuture = CompletableFuture.runAsync(() -> {
|
||||||
redisTemplate.opsForValue().set(riskBasePointsKey, JSON.toJSONString(
|
redisTemplate.opsForValue().set(basePoints.getRisk(), JSON.toJSONString(
|
||||||
XianRiskSpotsBasePointVo.entity2Vo(
|
XianRiskSpotsBasePointVo.entity2Vo(
|
||||||
xianRiskSpotsMapper.getBasePoints())
|
xianRiskSpotsMapper.getBasePoints())
|
||||||
)
|
)
|
||||||
@@ -188,7 +143,7 @@ public class InitializeData {
|
|||||||
}, xianPoolExecutor);
|
}, xianPoolExecutor);
|
||||||
|
|
||||||
CompletableFuture<Void> hospitalsFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> hospitalsFuture = CompletableFuture.runAsync(() -> {
|
||||||
redisTemplate.opsForValue().set(hospitalsBasePointsKey, JSON.toJSONString(
|
redisTemplate.opsForValue().set(basePoints.getHospitals(), JSON.toJSONString(
|
||||||
XianHospitalsBasePointVo.entity2Vo(
|
XianHospitalsBasePointVo.entity2Vo(
|
||||||
xianHospitalsMapper.getBasePoints())
|
xianHospitalsMapper.getBasePoints())
|
||||||
)
|
)
|
||||||
@@ -197,7 +152,7 @@ public class InitializeData {
|
|||||||
}, xianPoolExecutor);
|
}, xianPoolExecutor);
|
||||||
|
|
||||||
CompletableFuture<Void> dangerousSourceFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> dangerousSourceFuture = CompletableFuture.runAsync(() -> {
|
||||||
redisTemplate.opsForValue().set(dangerousSourceBasePointsKey, JSON.toJSONString(
|
redisTemplate.opsForValue().set(basePoints.getDangerousSource(), JSON.toJSONString(
|
||||||
XianDangerousSourceBasePointVo.entity2Vo(
|
XianDangerousSourceBasePointVo.entity2Vo(
|
||||||
xianDangerousSourceMapper.getBasePoints())
|
xianDangerousSourceMapper.getBasePoints())
|
||||||
)
|
)
|
||||||
@@ -206,7 +161,7 @@ public class InitializeData {
|
|||||||
}, xianPoolExecutor);
|
}, xianPoolExecutor);
|
||||||
|
|
||||||
CompletableFuture<Void> emergencyShelterFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> emergencyShelterFuture = CompletableFuture.runAsync(() -> {
|
||||||
redisTemplate.opsForValue().set(emergencyShelterBasePointsKey, JSON.toJSONString(
|
redisTemplate.opsForValue().set(basePoints.getEmergencyShelter(), JSON.toJSONString(
|
||||||
XianEmergencyShelterBasePointVo.entity2Vo(
|
XianEmergencyShelterBasePointVo.entity2Vo(
|
||||||
xianEmergencyShelterMapper.getBasePoints())
|
xianEmergencyShelterMapper.getBasePoints())
|
||||||
)
|
)
|
||||||
@@ -215,7 +170,7 @@ public class InitializeData {
|
|||||||
}, xianPoolExecutor);
|
}, xianPoolExecutor);
|
||||||
|
|
||||||
CompletableFuture<Void> firefighterFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> firefighterFuture = CompletableFuture.runAsync(() -> {
|
||||||
redisTemplate.opsForValue().set(firefighterBasePointsKey, JSON.toJSONString(
|
redisTemplate.opsForValue().set(basePoints.getFirefighter(), JSON.toJSONString(
|
||||||
XianFirefighterBasePointVo.entity2Vo(
|
XianFirefighterBasePointVo.entity2Vo(
|
||||||
xianFirefighterMapper.getBasePoints())
|
xianFirefighterMapper.getBasePoints())
|
||||||
)
|
)
|
||||||
@@ -224,7 +179,7 @@ public class InitializeData {
|
|||||||
}, xianPoolExecutor);
|
}, xianPoolExecutor);
|
||||||
|
|
||||||
CompletableFuture<Void> storePointsFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> storePointsFuture = CompletableFuture.runAsync(() -> {
|
||||||
redisTemplate.opsForValue().set(storePointsBasePointsKey, JSON.toJSONString(
|
redisTemplate.opsForValue().set(basePoints.getStorePoints(), JSON.toJSONString(
|
||||||
XianStorePointsBasePointVo.entity2Vo(
|
XianStorePointsBasePointVo.entity2Vo(
|
||||||
xianStorePointsMapper.getBasePoints())
|
xianStorePointsMapper.getBasePoints())
|
||||||
)
|
)
|
||||||
@@ -233,7 +188,7 @@ public class InitializeData {
|
|||||||
}, xianPoolExecutor);
|
}, xianPoolExecutor);
|
||||||
|
|
||||||
CompletableFuture<Void> schoolFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> schoolFuture = CompletableFuture.runAsync(() -> {
|
||||||
redisTemplate.opsForValue().set(schoolBasePointsKey, JSON.toJSONString(
|
redisTemplate.opsForValue().set(basePoints.getSchool(), JSON.toJSONString(
|
||||||
XianSchoolBasePointVo.entity2Vo(
|
XianSchoolBasePointVo.entity2Vo(
|
||||||
xianSchoolMapper.getBasePoints())
|
xianSchoolMapper.getBasePoints())
|
||||||
)
|
)
|
||||||
@@ -242,7 +197,7 @@ public class InitializeData {
|
|||||||
}, xianPoolExecutor);
|
}, xianPoolExecutor);
|
||||||
|
|
||||||
CompletableFuture<Void> bridgeFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> bridgeFuture = CompletableFuture.runAsync(() -> {
|
||||||
redisTemplate.opsForValue().set(bridgeBasePointsKey, JSON.toJSONString(
|
redisTemplate.opsForValue().set(basePoints.getBridge(), JSON.toJSONString(
|
||||||
XianBridgeBasePointVo.entity2Vo(
|
XianBridgeBasePointVo.entity2Vo(
|
||||||
xianBridgeMapper.getBasePoints())
|
xianBridgeMapper.getBasePoints())
|
||||||
)
|
)
|
||||||
@@ -251,7 +206,7 @@ public class InitializeData {
|
|||||||
}, xianPoolExecutor);
|
}, xianPoolExecutor);
|
||||||
|
|
||||||
CompletableFuture<Void> reservoirFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> reservoirFuture = CompletableFuture.runAsync(() -> {
|
||||||
redisTemplate.opsForValue().set(reservoirBasePointsKey, JSON.toJSONString(
|
redisTemplate.opsForValue().set(basePoints.getReservoir(), JSON.toJSONString(
|
||||||
XianReservoirListBasePointVo.entity2Vo(
|
XianReservoirListBasePointVo.entity2Vo(
|
||||||
xianReservoirListMapper.getBasePoints())
|
xianReservoirListMapper.getBasePoints())
|
||||||
)
|
)
|
||||||
@@ -260,7 +215,7 @@ public class InitializeData {
|
|||||||
}, xianPoolExecutor);
|
}, xianPoolExecutor);
|
||||||
|
|
||||||
CompletableFuture<Void> subwayFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> subwayFuture = CompletableFuture.runAsync(() -> {
|
||||||
redisTemplate.opsForValue().set(subwayBasePointsKey, JSON.toJSONString(
|
redisTemplate.opsForValue().set(basePoints.getSubway(), JSON.toJSONString(
|
||||||
XianSubwayStationsBasePointVo.entity2Vo(
|
XianSubwayStationsBasePointVo.entity2Vo(
|
||||||
xianSubwayStationsMapper.getBasePoints())
|
xianSubwayStationsMapper.getBasePoints())
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user