核设施新增查询全部信息,存入redis的接口

台站,探测器,核设施新增,修改,删除操作成功后更新redis数据
系统启动类增加存储核设施接口
修改台站运行管理下查询台站信息,核设施全部信息接口
台站运行管理新增查询台站详情信息接口
This commit is contained in:
qiaoqinzheng 2023-05-29 14:34:26 +08:00
parent 2ff56f704f
commit f2c26efebc
15 changed files with 162 additions and 85 deletions

View File

@ -2,6 +2,7 @@ package org.jeecg.modules.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.entity.StationOperation;
import org.jeecg.modules.service.IStationOperationService;
import org.springframework.beans.factory.annotation.Autowired;
@ -26,5 +27,11 @@ public class StationOperationController {
return result;
}
@GetMapping("findInfo")
@ApiOperation(value = "查询台站/核设施详情信息", notes = "查询台站/核设施详情信息")
public Result findInfo(String stationId, String type){
Result result = stationOperationService.findInfo(stationId, type);
return result;
}
}

View File

@ -7,20 +7,44 @@ import java.io.Serializable;
@Data
public class StationOperation implements Serializable {
/**
* 台站/核设施id
*/
private Integer stationId;
/**
* 台站/核设施名称
*/
private String stationName;
/**
* 台站/核设施类型
*/
private String stationType;
/**
* 海拔
*/
private String altitude;
/**
* 经度
*/
private String lon;
/**
* 纬度
*/
private String lat;
/**
* 状态
*/
private String status;
/**
* 标记
*/
private String signal;
}

View File

@ -1,7 +0,0 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.entity.GardsNuclearfacility;
public interface GardsNuclearfacilityMapper extends BaseMapper<GardsNuclearfacility> {
}

View File

@ -1,7 +0,0 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.entity.GardsStations;
public interface GardsStationsMapper extends BaseMapper<GardsStations> {
}

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.entity.StationOperation;
import java.util.List;
@ -9,5 +10,6 @@ public interface IStationOperationService extends IService<StationOperation> {
List<StationOperation> findList(String status);
Result findInfo(String stationId, String type);
}

View File

@ -1,83 +1,98 @@
package org.jeecg.modules.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.entity.GardsNuclearfacility;
import org.jeecg.modules.entity.GardsStations;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.system.entity.GardsNuclearfacility;
import org.jeecg.modules.system.entity.GardsStations;
import org.jeecg.modules.entity.StationOperation;
import org.jeecg.modules.mapper.GardsNuclearfacilityMapper;
import org.jeecg.modules.mapper.GardsStationsMapper;
import org.jeecg.modules.mapper.StationOperationMapper;
import org.jeecg.modules.service.IStationOperationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
@Service("stationOperationService")
@DS("ora")
public class StationOperationServiceImpl extends ServiceImpl<StationOperationMapper, StationOperation> implements IStationOperationService {
@Autowired
private GardsStationsMapper gardsStationsMapper;
@Autowired
private GardsNuclearfacilityMapper gardsNuclearfacilityMapper;
private RedisUtil redisUtil;
@Override
public List<StationOperation> findList(String status) {
//声明结果集合
List<StationOperation> result = new LinkedList<>();
//查询全部台站信息
List<GardsStations> stations = this.findStations();
for (GardsStations gardsStation:stations) {
StationOperation stationOperation = new StationOperation();
stationOperation.setStationId(gardsStation.getStationId());
stationOperation.setStationName(gardsStation.getStationCode());
stationOperation.setStationType("IMS STATION");
stationOperation.setAltitude(Objects.isNull(gardsStation.getElevation())?"":gardsStation.getElevation()+"");
stationOperation.setLon(String.valueOf(gardsStation.getLon()));
stationOperation.setLat(String.valueOf(gardsStation.getLat()));
stationOperation.setStatus(gardsStation.getStatus());
result.add(stationOperation);
}
HashMap<String, Object> stationInfoMap = (HashMap<String, Object>) redisUtil.get("stationInfoMap");
//查询全部核设施信息
List<GardsNuclearfacility> nuclearfacilities = this.findNuclearfacilities();
for (GardsNuclearfacility nuclearfacility:nuclearfacilities) {
StationOperation stationOperation = new StationOperation();
stationOperation.setStationId(nuclearfacility.getFacilityId());
stationOperation.setStationName(nuclearfacility.getFacilityName());
stationOperation.setStationType("Nuclear Facility");
stationOperation.setAltitude("--");
stationOperation.setLon(nuclearfacility.getLongitude());
stationOperation.setLat(nuclearfacility.getLatitude());
stationOperation.setStatus(nuclearfacility.getStatus());
result.add(stationOperation);
HashMap<String, Object> nuclearFacilityMap = (HashMap<String, Object>) redisUtil.get("nuclearFacilityMap");
//遍历台站信息
if (CollectionUtils.isNotEmpty(stationInfoMap)){
for (Map.Entry<String, Object> gardsStations:stationInfoMap.entrySet()) {
GardsStations gardsStation = (GardsStations)gardsStations.getValue();
StationOperation stationOperation = new StationOperation();
stationOperation.setStationId(gardsStation.getStationId());
stationOperation.setStationName(gardsStation.getStationCode());
stationOperation.setStationType("IMS STATION");
stationOperation.setAltitude(Objects.isNull(gardsStation.getElevation())?"":gardsStation.getElevation()+"");
stationOperation.setLon(String.valueOf(gardsStation.getLon()));
stationOperation.setLat(String.valueOf(gardsStation.getLat()));
stationOperation.setStatus(gardsStation.getStatus());
result.add(stationOperation);
}
}
//如果状态不为空
if (CollectionUtils.isNotEmpty(nuclearFacilityMap)){
//遍历核设施信息
for (Map.Entry<String, Object> nuclearfacilities:nuclearFacilityMap.entrySet()) {
GardsNuclearfacility nuclearfacility = (GardsNuclearfacility)nuclearfacilities.getValue();
StationOperation stationOperation = new StationOperation();
stationOperation.setStationId(nuclearfacility.getFacilityId());
stationOperation.setStationName(nuclearfacility.getFacilityName());
stationOperation.setStationType("Nuclear Facility");
stationOperation.setAltitude("--");
stationOperation.setLon(nuclearfacility.getLongitude());
stationOperation.setLat(nuclearfacility.getLatitude());
stationOperation.setStatus(nuclearfacility.getStatus());
result.add(stationOperation);
}
}
//如果类型不为空
if (StringUtils.isNotBlank(status)){
result = result.stream().filter(item-> item.getStatus().equals(status)).collect(Collectors.toList());
result = result.stream().filter(item-> StringUtils.isNotBlank(item.getStatus())&&item.getStatus().equalsIgnoreCase(status)).collect(Collectors.toList());
}
return result;
}
/**
* 查询全部台站信息
* @return
*/
private List<GardsStations> findStations(){
LambdaQueryWrapper<GardsStations> queryWrapper = new LambdaQueryWrapper<>();
List<GardsStations> gardsStations = gardsStationsMapper.selectList(queryWrapper);
return gardsStations;
}
private List<GardsNuclearfacility> findNuclearfacilities(){
LambdaQueryWrapper<GardsNuclearfacility> queryWrapper = new LambdaQueryWrapper<>();
List<GardsNuclearfacility> gardsNuclearfacilities = gardsNuclearfacilityMapper.selectList(queryWrapper);
return gardsNuclearfacilities;
@Override
public Result findInfo(String stationId, String type) {
Result result = new Result();
if (type.equals("IMS STATION")){
HashMap<String, GardsStations> stationInfoMap = (HashMap<String, GardsStations>) redisUtil.get("stationInfoMap");
GardsStations stations = stationInfoMap.get(stationId);
if (Objects.nonNull(stations)){
result.setResult(stations);
result.setSuccess(true);
}else {
result.error500("台站下对应信息不存在");
}
}else if(type.equals("Nuclear Facility")){
HashMap<String, GardsNuclearfacility> nuclearFacilityMap = (HashMap<String, GardsNuclearfacility>) redisUtil.get("nuclearFacilityMap");
GardsNuclearfacility nuclearfacility = nuclearFacilityMap.get(stationId);
if (Objects.nonNull(nuclearfacility)){
result.setResult(nuclearfacility);
result.setSuccess(true);
}else {
result.error500("核设施下对应信息不存在");
}
}else {
result.error500("当前类型不存在");
}
return result;
}
}

View File

@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.modules.entity.GardsStations;
import org.jeecg.modules.entity.SysUser;
import org.jeecg.modules.entity.SysUserFocusStation;
import org.jeecg.modules.mapper.SysUserFocusStationMapper;

View File

@ -1,4 +1,4 @@
package org.jeecg.modules.entity;
package org.jeecg.modules.system.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

View File

@ -1,4 +1,4 @@
package org.jeecg.modules.entity;
package org.jeecg.modules.system.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

View File

@ -55,6 +55,6 @@ public interface IGardsDetectorsService extends IService<GardsDetectors> {
* 查询全部监测器信息
* @return
*/
List<GardsDetectors> findDetectors();
void findDetectors();
}

View File

@ -58,4 +58,8 @@ public interface IGardsNuclearfacilityService extends IService<GardsNuclearfacil
*/
Result deleteById(Integer id);
/**
* 查询全部核设施信息
*/
void findNuclearFacility();
}

View File

@ -24,10 +24,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
@Service("gardsDetectorsService")
@DS("ora")
@ -98,6 +96,7 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
}
this.baseMapper.insert(gardsDetectors);
result.success("新增成功");
this.findDetectors();
return result;
}
@ -124,6 +123,7 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
detectorsQueryWrapper.eq(GardsDetectors::getDetectorId, gardsDetectors.getDetectorId());
this.baseMapper.update(gardsDetectors, detectorsQueryWrapper);
result.success("修改成功");
this.findDetectors();
return result;
}
@ -134,20 +134,18 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
queryWrapper.eq(GardsDetectors::getDetectorId, id);
this.baseMapper.delete(queryWrapper);
result.success("删除成功");
this.findDetectors();
return result;
}
@Override
@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());
}
public void findDetectors(){
if (redisUtil.hasKey("detectorsMap")){
redisUtil.del("detectorsMap");
}
redisUtil.set("detectorsMap",map);
return gardsDetectors;
List<GardsDetectors> gardsDetectors = this.baseMapper.selectList(new LambdaQueryWrapper<>());
Map<Integer, String> detectorsMap = gardsDetectors.stream().collect(Collectors.toMap(GardsDetectors::getDetectorId, GardsDetectors::getDetectorCode));
redisUtil.set("detectorsMap",detectorsMap);
}
}

View File

@ -9,12 +9,15 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.GardsNuclearfacility;
import org.jeecg.modules.system.mapper.GardsNuclearfacilityMapper;
import org.jeecg.modules.system.service.IGardsNuclearfacilityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@ -23,6 +26,9 @@ import java.util.stream.Collectors;
@DS("ora")
public class GardsNuclearfacilityServiceImpl extends ServiceImpl<GardsNuclearfacilityMapper, GardsNuclearfacility> implements IGardsNuclearfacilityService {
@Autowired
private RedisUtil redisUtil;
@Override
public Result<IPage<GardsNuclearfacility>> findPage(QueryRequest queryRequest, GardsNuclearfacility gardsNuclearfacility) {
Result<IPage<GardsNuclearfacility>> result = new Result<>();
@ -76,6 +82,7 @@ public class GardsNuclearfacilityServiceImpl extends ServiceImpl<GardsNuclearfac
}
this.baseMapper.insert(gardsNuclearfacility);
result.success("新增成功");
this.findNuclearFacility();
return result;
}
@ -103,6 +110,7 @@ public class GardsNuclearfacilityServiceImpl extends ServiceImpl<GardsNuclearfac
nuclearfacilityQueryWrapper.eq(GardsNuclearfacility::getFacilityId, gardsNuclearfacility.getFacilityId());
this.baseMapper.update(gardsNuclearfacility, nuclearfacilityQueryWrapper);
result.success("修改成功");
this.findNuclearFacility();
return result;
}
@ -114,7 +122,23 @@ public class GardsNuclearfacilityServiceImpl extends ServiceImpl<GardsNuclearfac
queryWrapper.eq(GardsNuclearfacility::getFacilityId, id);
this.baseMapper.delete(queryWrapper);
result.success("删除成功");
this.findNuclearFacility();
return result;
}
@Override
public void findNuclearFacility() {
if (redisUtil.hasKey("nuclearFacilityMap")){
redisUtil.del("nuclearFacilityMap");
}
LambdaQueryWrapper<GardsNuclearfacility> queryWrapper = new LambdaQueryWrapper<>();
List<GardsNuclearfacility> gardsNuclearfacilities = this.baseMapper.selectList(queryWrapper);
HashMap<String, Object> nuclearFacilityMap = new HashMap<>();
for (GardsNuclearfacility gardsNuclearfacility:gardsNuclearfacilities) {
nuclearFacilityMap.put(String.valueOf(gardsNuclearfacility.getFacilityId()), gardsNuclearfacility);
}
redisUtil.set("nuclearFacilityMap",nuclearFacilityMap);
}
}

View File

@ -21,7 +21,9 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@Service("gardsStationsService")
@DS("ora")
@ -100,6 +102,7 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
this.baseMapper.insert(gardsStations);
result.setSuccess(true);
result.success("新增成功");
this.getGardsStations();
return result;
}
@ -133,6 +136,7 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
this.baseMapper.update(gardsStations, stationsQueryWrapper);
result.setSuccess(true);
result.success("修改成功");
this.getGardsStations();
return result;
}
@ -149,6 +153,7 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
this.baseMapper.delete(wrapper);
result.setSuccess(true);
result.success("删除成功");
this.getGardsStations();
return result;
}
@ -159,14 +164,22 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public List<GardsStations> getGardsStations() {
if (redisUtil.hasKey("stationMap")){
redisUtil.del("stationMap");
}
if (redisUtil.hasKey("stationInfoMap")) {
redisUtil.del("stationInfoMap");
}
List<GardsStations> gardsStations = this.baseMapper.selectList(new LambdaQueryWrapper<>());
HashMap<Integer, String> map = new HashMap<>();
Map<Integer, String> stationMap = gardsStations.stream().collect(Collectors.toMap(GardsStations::getStationId, GardsStations::getStationCode));
HashMap<Integer, Object> stationInfoMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(gardsStations)){
for (GardsStations station:gardsStations) {
map.put(station.getStationId(),station.getStationCode());
stationInfoMap.put(station.getStationId(),station);
}
}
redisUtil.set("stationMap",map);
redisUtil.set("stationMap",stationMap);
redisUtil.set("stationInfoMap",stationInfoMap);
return gardsStations;
}
}

View File

@ -5,6 +5,7 @@ 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.IGardsNuclearfacilityService;
import org.jeecg.modules.system.service.IGardsStationsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
@ -39,6 +40,8 @@ public class JeecgSystemCloudApplication extends SpringBootServletInitializer im
private IGardsStationsService gardsStationsService;
@Autowired
private IGardsDetectorsService gardsDetectorsService;
@Autowired
private IGardsNuclearfacilityService gardsNuclearfacilityService;
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
@ -76,5 +79,7 @@ public class JeecgSystemCloudApplication extends SpringBootServletInitializer im
gardsStationsService.getGardsStations();
//触发缓存一下探测器信息
gardsDetectorsService.findDetectors();
//触发缓存一下核设施信息
gardsNuclearfacilityService.findNuclearFacility();
}
}