diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/controller/StationOperationController.java b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/controller/StationOperationController.java index 9908f657..ebd261f0 100644 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/controller/StationOperationController.java +++ b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/controller/StationOperationController.java @@ -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; + } } diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/entity/StationOperation.java b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/entity/StationOperation.java index 9e1a0764..d562f278 100644 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/entity/StationOperation.java +++ b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/entity/StationOperation.java @@ -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; } diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/mapper/GardsNuclearfacilityMapper.java b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/mapper/GardsNuclearfacilityMapper.java deleted file mode 100644 index 1760bd15..00000000 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/mapper/GardsNuclearfacilityMapper.java +++ /dev/null @@ -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 { -} diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/mapper/GardsStationsMapper.java b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/mapper/GardsStationsMapper.java deleted file mode 100644 index c62547f0..00000000 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/mapper/GardsStationsMapper.java +++ /dev/null @@ -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 { -} diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/IStationOperationService.java b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/IStationOperationService.java index 9f06b2c1..d0d2d96d 100644 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/IStationOperationService.java +++ b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/IStationOperationService.java @@ -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 { List findList(String status); + Result findInfo(String stationId, String type); } diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/impl/StationOperationServiceImpl.java b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/impl/StationOperationServiceImpl.java index 3559dd2c..691cacf9 100644 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/impl/StationOperationServiceImpl.java +++ b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/impl/StationOperationServiceImpl.java @@ -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 implements IStationOperationService { @Autowired - private GardsStationsMapper gardsStationsMapper; - @Autowired - private GardsNuclearfacilityMapper gardsNuclearfacilityMapper; + private RedisUtil redisUtil; @Override public List findList(String status) { //声明结果集合 List result = new LinkedList<>(); //查询全部台站信息 - List 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 stationInfoMap = (HashMap) redisUtil.get("stationInfoMap"); //查询全部核设施信息 - List 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 nuclearFacilityMap = (HashMap) redisUtil.get("nuclearFacilityMap"); + //遍历台站信息 + if (CollectionUtils.isNotEmpty(stationInfoMap)){ + for (Map.Entry 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 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 findStations(){ - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - List gardsStations = gardsStationsMapper.selectList(queryWrapper); - return gardsStations; - } - - private List findNuclearfacilities(){ - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - List gardsNuclearfacilities = gardsNuclearfacilityMapper.selectList(queryWrapper); - return gardsNuclearfacilities; + @Override + public Result findInfo(String stationId, String type) { + Result result = new Result(); + if (type.equals("IMS STATION")){ + HashMap stationInfoMap = (HashMap) 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 nuclearFacilityMap = (HashMap) 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; } } diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/impl/SysUserFocusStationServiceImpl.java b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/impl/SysUserFocusStationServiceImpl.java index d59eef98..00df0993 100644 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/impl/SysUserFocusStationServiceImpl.java +++ b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/impl/SysUserFocusStationServiceImpl.java @@ -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; diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/entity/GardsNuclearfacility.java b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/system/entity/GardsNuclearfacility.java similarity index 98% rename from jeecg-module-station-operation/src/main/java/org/jeecg/modules/entity/GardsNuclearfacility.java rename to jeecg-module-station-operation/src/main/java/org/jeecg/modules/system/entity/GardsNuclearfacility.java index 69fe25bc..65ab2de4 100644 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/entity/GardsNuclearfacility.java +++ b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/system/entity/GardsNuclearfacility.java @@ -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; diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/entity/GardsStations.java b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/system/entity/GardsStations.java similarity index 97% rename from jeecg-module-station-operation/src/main/java/org/jeecg/modules/entity/GardsStations.java rename to jeecg-module-station-operation/src/main/java/org/jeecg/modules/system/entity/GardsStations.java index f9ee9213..898e238d 100644 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/entity/GardsStations.java +++ b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/system/entity/GardsStations.java @@ -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; diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsDetectorsService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsDetectorsService.java index b028bc24..e84b088f 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsDetectorsService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsDetectorsService.java @@ -55,6 +55,6 @@ public interface IGardsDetectorsService extends IService { * 查询全部监测器信息 * @return */ - List findDetectors(); + void findDetectors(); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsNuclearfacilityService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsNuclearfacilityService.java index 1e59bbaf..e009ae4b 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsNuclearfacilityService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsNuclearfacilityService.java @@ -58,4 +58,8 @@ public interface IGardsNuclearfacilityService extends IService findDetectors(){ - List gardsDetectors = this.baseMapper.selectList(new LambdaQueryWrapper<>()); - HashMap 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 = this.baseMapper.selectList(new LambdaQueryWrapper<>()); + Map detectorsMap = gardsDetectors.stream().collect(Collectors.toMap(GardsDetectors::getDetectorId, GardsDetectors::getDetectorCode)); + redisUtil.set("detectorsMap",detectorsMap); } } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsNuclearfacilityServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsNuclearfacilityServiceImpl.java index ad191c68..692c52e9 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsNuclearfacilityServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsNuclearfacilityServiceImpl.java @@ -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 implements IGardsNuclearfacilityService { + @Autowired + private RedisUtil redisUtil; + @Override public Result> findPage(QueryRequest queryRequest, GardsNuclearfacility gardsNuclearfacility) { Result> result = new Result<>(); @@ -76,6 +82,7 @@ public class GardsNuclearfacilityServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); + List gardsNuclearfacilities = this.baseMapper.selectList(queryWrapper); + HashMap nuclearFacilityMap = new HashMap<>(); + for (GardsNuclearfacility gardsNuclearfacility:gardsNuclearfacilities) { + nuclearFacilityMap.put(String.valueOf(gardsNuclearfacility.getFacilityId()), gardsNuclearfacility); + } + redisUtil.set("nuclearFacilityMap",nuclearFacilityMap); + } + + } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsStationsServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsStationsServiceImpl.java index 7d749187..ba908b3b 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsStationsServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsStationsServiceImpl.java @@ -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 getGardsStations() { + if (redisUtil.hasKey("stationMap")){ + redisUtil.del("stationMap"); + } + if (redisUtil.hasKey("stationInfoMap")) { + redisUtil.del("stationInfoMap"); + } List gardsStations = this.baseMapper.selectList(new LambdaQueryWrapper<>()); - HashMap map = new HashMap<>(); + Map stationMap = gardsStations.stream().collect(Collectors.toMap(GardsStations::getStationId, GardsStations::getStationCode)); + HashMap 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; } } diff --git a/jeecg-server-cloud/jeecg-system-cloud-start/src/main/java/org/jeecg/JeecgSystemCloudApplication.java b/jeecg-server-cloud/jeecg-system-cloud-start/src/main/java/org/jeecg/JeecgSystemCloudApplication.java index 27965275..ae50f174 100644 --- a/jeecg-server-cloud/jeecg-system-cloud-start/src/main/java/org/jeecg/JeecgSystemCloudApplication.java +++ b/jeecg-server-cloud/jeecg-system-cloud-start/src/main/java/org/jeecg/JeecgSystemCloudApplication.java @@ -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(); } } \ No newline at end of file