feat:启动时向redis中缓存台站,探测器信息
This commit is contained in:
parent
bcb2b6b7ed
commit
f404f4f365
|
@ -5,6 +5,7 @@ import io.swagger.annotations.Api;
|
|||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.modules.system.entity.GardsSampleData;
|
||||
import org.jeecg.modules.system.service.IGardsSampleDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -13,6 +14,8 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("gardsSampleData")
|
||||
@Api(value = "DATA BASE管理", tags = "DATA BASE管理")
|
||||
|
@ -20,6 +23,8 @@ public class GardsSampleDataController {
|
|||
|
||||
@Autowired
|
||||
private IGardsSampleDataService gardsSampleDataService;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@GetMapping("findPage")
|
||||
@ApiOperation(value = "分页查询DATA_BASE数据", notes = "分页查询DATA_BASE数据")
|
||||
|
@ -28,6 +33,20 @@ public class GardsSampleDataController {
|
|||
return result;
|
||||
}
|
||||
|
||||
@GetMapping("findStations")
|
||||
@ApiOperation(value = "查询台站相关信息", notes = "查询台站相关信息")
|
||||
public Map<Integer, String> findStations(){
|
||||
Map<Integer, String> stationMap = (Map<Integer, String>)redisUtil.get("stationMap");
|
||||
return stationMap;
|
||||
}
|
||||
|
||||
@GetMapping("findDetectors")
|
||||
@ApiOperation(value = "查询台站相关信息", notes = "查询台站相关信息")
|
||||
public Map<Integer, String> findDetectors(){
|
||||
Map<Integer, String> detectorsMap = (Map<Integer, String>)redisUtil.get("detectorsMap");
|
||||
return detectorsMap;
|
||||
}
|
||||
|
||||
@DeleteMapping("deleteById")
|
||||
@ApiOperation(value = "删除DATA_BASE数据", notes = "删除DATA_BASE数据")
|
||||
public Result deleteById(Integer sampleId){
|
||||
|
|
|
@ -138,6 +138,13 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
|
|||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public List<GardsDetectors> findDetectors(){
|
||||
List<GardsDetectors> gardsDetectors = this.baseMapper.selectList(new LambdaQueryWrapper<>());
|
||||
HashMap<Integer, String> map = new HashMap<>();
|
||||
if (CollectionUtils.isNotEmpty(gardsDetectors)){
|
||||
for (GardsDetectors detectors:gardsDetectors) {
|
||||
map.put(detectors.getDetectorId(),detectors.getDetectorCode());
|
||||
}
|
||||
}
|
||||
redisUtil.set("detectorsMap",map);
|
||||
return gardsDetectors;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.jeecg.modules.system.service.impl;
|
|||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
@ -155,11 +156,12 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
|
|||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public List<GardsStations> getGardsStations() {
|
||||
LambdaQueryWrapper<GardsStations> queryWrapper = new LambdaQueryWrapper<>();
|
||||
List<GardsStations> gardsStations = this.baseMapper.selectList(queryWrapper);
|
||||
List<GardsStations> gardsStations = this.baseMapper.selectList(new LambdaQueryWrapper<>());
|
||||
HashMap<Integer, String> map = new HashMap<>();
|
||||
for (GardsStations station:gardsStations) {
|
||||
map.put(station.getStationId(),station.getStationCode());
|
||||
if (CollectionUtils.isNotEmpty(gardsStations)){
|
||||
for (GardsStations station:gardsStations) {
|
||||
map.put(station.getStationId(),station.getStationCode());
|
||||
}
|
||||
}
|
||||
redisUtil.set("stationMap",map);
|
||||
return gardsStations;
|
||||
|
|
|
@ -4,6 +4,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.jeecg.common.base.BaseMap;
|
||||
import org.jeecg.common.constant.GlobalConstants;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.service.IGardsDetectorsService;
|
||||
import org.jeecg.modules.system.service.IGardsStationsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
|
@ -33,6 +35,11 @@ public class JeecgSystemCloudApplication extends SpringBootServletInitializer im
|
|||
|
||||
@Autowired
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
@Autowired
|
||||
private IGardsStationsService gardsStationsService;
|
||||
@Autowired
|
||||
private IGardsDetectorsService gardsDetectorsService;
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(JeecgSystemCloudApplication.class);
|
||||
|
@ -65,5 +72,9 @@ public class JeecgSystemCloudApplication extends SpringBootServletInitializer im
|
|||
params.put(GlobalConstants.HANDLER_NAME, GlobalConstants.LODER_ROUDER_HANDLER);
|
||||
//刷新网关
|
||||
redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, params);
|
||||
//触发缓存一下台站信息
|
||||
gardsStationsService.getGardsStations();
|
||||
//触发缓存一下探测器信息
|
||||
gardsDetectorsService.findDetectors();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user