From 0fd138b17548249eb317e56c511e36d170e9ab40 Mon Sep 17 00:00:00 2001 From: duwenyuan <15600000461@163.com> Date: Tue, 15 Jul 2025 17:30:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/StationOperationServiceImpl.java | 136 +++++++++--------- 1 file changed, 68 insertions(+), 68 deletions(-) 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 cbe350f0..9bf27ab3 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 @@ -82,14 +82,14 @@ public class StationOperationServiceImpl extends ServiceImpl nuclearFacilityMap = (HashMap) redisUtil.get("nuclearFacilityMap"); List stationList = new LinkedList<>(); //遍历台站信息 - if (CollectionUtils.isNotEmpty(stationInfoMap)){ - for (Map.Entry gardsStations:stationInfoMap.entrySet()) { - GardsStations gardsStation = (GardsStations)gardsStations.getValue(); + 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(stationTypeUtil.getStationType(gardsStation.getStationId(), gardsStation.getCategory())); - stationOperation.setAltitude(Objects.isNull(gardsStation.getElevation())?"--":gardsStation.getElevation()+"m"); + stationOperation.setAltitude(Objects.isNull(gardsStation.getElevation()) ? "--" : gardsStation.getElevation() + "m"); stationOperation.setLon(String.valueOf(gardsStation.getLon())); stationOperation.setLat(String.valueOf(gardsStation.getLat())); stationOperation.setStatus(gardsStation.getStatus()); @@ -101,10 +101,10 @@ public class StationOperationServiceImpl extends ServiceImpl nuclearFacilityList = new LinkedList<>(); - if (CollectionUtils.isNotEmpty(nuclearFacilityMap)){ + if (CollectionUtils.isNotEmpty(nuclearFacilityMap)) { //遍历核设施信息 - for (Map.Entry nuclearfacilities:nuclearFacilityMap.entrySet()) { - GardsNuclearfacility nuclearfacility = (GardsNuclearfacility)nuclearfacilities.getValue(); + for (Map.Entry nuclearfacilities : nuclearFacilityMap.entrySet()) { + GardsNuclearfacility nuclearfacility = (GardsNuclearfacility) nuclearfacilities.getValue(); StationOperation stationOperation = new StationOperation(); stationOperation.setStationId(nuclearfacility.getFacilityId()); stationOperation.setStationName(nuclearfacility.getFacilityName()); @@ -123,12 +123,12 @@ public class StationOperationServiceImpl extends ServiceImpl StringUtils.isNotBlank(item.getStatus()) && item.getStatus().equalsIgnoreCase(status)).collect(Collectors.toList()); + if (StringUtils.isNotBlank(status)) { + result = result.stream().filter(item -> StringUtils.isNotBlank(item.getStatus()) && item.getStatus().equalsIgnoreCase(status)).collect(Collectors.toList()); } //如果类型不为空 - if (StringUtils.isNotBlank(stationType)){ - result = result.stream().filter(item-> StringUtils.isNotBlank(item.getStationType()) && item.getStationType().equalsIgnoreCase(stationType)).collect(Collectors.toList()); + if (StringUtils.isNotBlank(stationType)) { + result = result.stream().filter(item -> StringUtils.isNotBlank(item.getStationType()) && item.getStationType().equalsIgnoreCase(stationType)).collect(Collectors.toList()); } return result; } @@ -137,30 +137,30 @@ public class StationOperationServiceImpl extends ServiceImpl stationTypes = stationType.getTypes().stream().map(StationType::getName).collect(Collectors.toList()); - if (stationTypes.contains(type)){ + if (stationTypes.contains(type)) { HashMap stationInfoMap = (HashMap) redisUtil.get("stationInfoMap"); GardsStations stations = stationInfoMap.get(stationId); - if (Objects.nonNull(stations)){ + if (Objects.nonNull(stations)) { result.setResult(stations); result.setSuccess(true); - }else { + } else { result.error500("The corresponding information under the station does not exist"); } - }else if(type.equals("Nuclear Facility")){ + } else if (type.equals("Nuclear Facility")) { HashMap nuclearFacilityMap = (HashMap) redisUtil.get("nuclearFacilityMap"); //从缓存的核设施map中获取对应的核设施信息 GardsNuclearfacility nuclearfacility = nuclearFacilityMap.get(stationId); - if (Objects.nonNull(nuclearfacility)){ + if (Objects.nonNull(nuclearfacility)) { String longitude = nuclearfacility.getLongitude(); String latitude = nuclearfacility.getLatitude(); nuclearfacility.setLongitude(PointUtil.calculate(latitude)); nuclearfacility.setLatitude(PointUtil.calculate(longitude)); result.setResult(nuclearfacility); result.setSuccess(true); - }else { + } else { result.error500("The corresponding information does not exist in the nuclear facility"); } - }else { + } else { result.error500("The current type does not exist"); } return result; @@ -172,47 +172,47 @@ public class StationOperationServiceImpl extends ServiceImpl stationTreeList = new LinkedList<>(); //查询台站信息接口 - HashMap stationMap = (HashMap)redisUtil.get("stationInfoMap"); - if (CollectionUtils.isNotEmpty(stationMap)){ + HashMap stationMap = (HashMap) redisUtil.get("stationInfoMap"); + if (CollectionUtils.isNotEmpty(stationMap)) { //遍历台站信息存储进数组 List gardsStationsList = new ArrayList<>(); - for (Map.Entry entry:stationMap.entrySet()) { + for (Map.Entry entry : stationMap.entrySet()) { GardsStations entryValue = (GardsStations) entry.getValue(); gardsStationsList.add(entryValue); } - if (CollectionUtils.isNotEmpty(gardsStationsList)){ + if (CollectionUtils.isNotEmpty(gardsStationsList)) { //过滤出所有的台站城市编码 List countryCodes = gardsStationsList.stream().map(GardsStations::getCountryCode).distinct().sorted().collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(countryCodes)){ - for (int i=0; i<3; i++){ + if (CollectionUtils.isNotEmpty(countryCodes)) { + for (int i = 0; i < 3; i++) { //树形结构子级 用于存储城市及城市下的台站信息 List stationChildTreeList = new LinkedList<>(); StationTree stationTree = new StationTree(); stationTree.setStationId(i); - if (i == 0){ + if (i == 0) { stationTree.setCode("Particulate Station"); - }else if (i == 1){ + } else if (i == 1) { stationTree.setCode("Noble Gas Station"); - }else if (i == 2){ + } else if (i == 2) { stationTree.setCode("NRL"); } - for (Object countryCode:countryCodes) { + for (Object countryCode : countryCodes) { //用于存储城市下对应的台站信息 List stations = new LinkedList<>(); String country = String.valueOf(countryCode); //声明一个数组存储城市编码对应的数组信息 StationTree stationChildTree = new StationTree(); - stationChildTree.setStationId(countryCodes.indexOf(countryCode)+1); + stationChildTree.setStationId(countryCodes.indexOf(countryCode) + 1); stationChildTree.setCode(country); - List stationsList = gardsStationsList.stream().filter(station-> station.getCountryCode().equals(countryCode)).collect(Collectors.toList()); - if (i == 0){ - stationsList = stationsList.stream().filter(item-> item.getStationId()<=200).sorted(Comparator.comparing(GardsStations::getStationId)).collect(Collectors.toList()); + List stationsList = gardsStationsList.stream().filter(station -> station.getCountryCode().equals(countryCode)).collect(Collectors.toList()); + if (i == 0) { + stationsList = stationsList.stream().filter(item -> item.getStationId() <= 200).sorted(Comparator.comparing(GardsStations::getStationId)).collect(Collectors.toList()); stations.addAll(stationsList); - }else if(i == 1){ - stationsList = stationsList.stream().filter(item-> item.getStationId()>200 && item.getStationId()<=300).sorted(Comparator.comparing(GardsStations::getStationId)).collect(Collectors.toList()); + } else if (i == 1) { + stationsList = stationsList.stream().filter(item -> item.getStationId() > 200 && item.getStationId() <= 300).sorted(Comparator.comparing(GardsStations::getStationId)).collect(Collectors.toList()); stations.addAll(stationsList); - }else if(i == 2){ - stationsList = stationsList.stream().filter(item-> item.getStationId()>300).sorted(Comparator.comparing(GardsStations::getStationId)).collect(Collectors.toList()); + } else if (i == 2) { + stationsList = stationsList.stream().filter(item -> item.getStationId() > 300).sorted(Comparator.comparing(GardsStations::getStationId)).collect(Collectors.toList()); stations.addAll(stationsList); } stationChildTree.setChildren(stations); @@ -246,26 +246,26 @@ public class StationOperationServiceImpl extends ServiceImpl stationInfoMap = (HashMap) redisUtil.get("stationInfoMap"); //查询全部核设施信息 HashMap nuclearFacilityMap = (HashMap) redisUtil.get("nuclearFacilityMap"); - if (CollectionUtils.isNotEmpty(nuclearFacilityMap)){ + if (CollectionUtils.isNotEmpty(nuclearFacilityMap)) { //声明一个集合存储转换经纬度后的核设施数据 List nuclearPoints = new ArrayList<>(); - for (Map.Entry nuclearFacilityInfo:nuclearFacilityMap.entrySet()) { + for (Map.Entry nuclearFacilityInfo : nuclearFacilityMap.entrySet()) { GardsNuclearfacility facilityInfoValue = nuclearFacilityInfo.getValue(); Point point = new Point(); point.setNuclearFacilityId(String.valueOf(facilityInfoValue.getFacilityId())); point.setNuclearFacilityName(facilityInfoValue.getFacilityName()); String lon = ""; String lat = ""; - if (StringUtils.isNotBlank(facilityInfoValue.getLongitude())){ + if (StringUtils.isNotBlank(facilityInfoValue.getLongitude())) { lat = PointUtil.calculate(facilityInfoValue.getLongitude()); point.setLat(lat); } - if (StringUtils.isNotBlank(facilityInfoValue.getLatitude())){ + if (StringUtils.isNotBlank(facilityInfoValue.getLatitude())) { lon = PointUtil.calculate(facilityInfoValue.getLatitude()); point.setLon(lon); } @@ -273,8 +273,8 @@ public class StationOperationServiceImpl extends ServiceImpl nuclearFacilityPoints = deepCopy(nuclearPoints); @@ -300,34 +300,34 @@ public class StationOperationServiceImpl extends ServiceImpl rectangle.getMinX() && rectangle.getMaxY() > rectangle.getMinY()) { - nuclearFacilityPoints = nuclearFacilityPoints.stream().filter(item-> StringUtils.isNotBlank(item.getLon()) && StringUtils.isNotBlank(item.getLat()) && - (Double.valueOf(item.getLon())>=rectangle.getMinX() && Double.valueOf(item.getLon())<= rectangle.getMaxX()) - && (Double.valueOf(item.getLat())>=rectangle.getMinY() && Double.valueOf(item.getLat())<= rectangle.getMaxY())).collect(Collectors.toList()); + nuclearFacilityPoints = nuclearFacilityPoints.stream().filter(item -> StringUtils.isNotBlank(item.getLon()) && StringUtils.isNotBlank(item.getLat()) && + (Double.valueOf(item.getLon()) >= rectangle.getMinX() && Double.valueOf(item.getLon()) <= rectangle.getMaxX()) + && (Double.valueOf(item.getLat()) >= rectangle.getMinY() && Double.valueOf(item.getLat()) <= rectangle.getMaxY())).collect(Collectors.toList()); } else if (rectangle.getMaxX() < rectangle.getMinX() && rectangle.getMaxY() > rectangle.getMinY()) { - nuclearFacilityPoints = nuclearFacilityPoints.stream().filter(item-> StringUtils.isNotBlank(item.getLon()) && StringUtils.isNotBlank(item.getLat()) && - (Double.valueOf(item.getLon())>=rectangle.getMaxX() && Double.valueOf(item.getLon())<= rectangle.getMinX()) - && (Double.valueOf(item.getLat())>=rectangle.getMinY() && Double.valueOf(item.getLat())<= rectangle.getMaxY())).collect(Collectors.toList()); + nuclearFacilityPoints = nuclearFacilityPoints.stream().filter(item -> StringUtils.isNotBlank(item.getLon()) && StringUtils.isNotBlank(item.getLat()) && + (Double.valueOf(item.getLon()) >= rectangle.getMaxX() && Double.valueOf(item.getLon()) <= rectangle.getMinX()) + && (Double.valueOf(item.getLat()) >= rectangle.getMinY() && Double.valueOf(item.getLat()) <= rectangle.getMaxY())).collect(Collectors.toList()); } else if (rectangle.getMaxX() > rectangle.getMinX() && rectangle.getMaxY() < rectangle.getMinY()) { - nuclearFacilityPoints = nuclearFacilityPoints.stream().filter(item-> StringUtils.isNotBlank(item.getLon()) && StringUtils.isNotBlank(item.getLat()) && - (Double.valueOf(item.getLon())>=rectangle.getMinX() && Double.valueOf(item.getLon())<= rectangle.getMaxX()) - && (Double.valueOf(item.getLat())>=rectangle.getMaxY() && Double.valueOf(item.getLat())<= rectangle.getMinY())).collect(Collectors.toList()); + nuclearFacilityPoints = nuclearFacilityPoints.stream().filter(item -> StringUtils.isNotBlank(item.getLon()) && StringUtils.isNotBlank(item.getLat()) && + (Double.valueOf(item.getLon()) >= rectangle.getMinX() && Double.valueOf(item.getLon()) <= rectangle.getMaxX()) + && (Double.valueOf(item.getLat()) >= rectangle.getMaxY() && Double.valueOf(item.getLat()) <= rectangle.getMinY())).collect(Collectors.toList()); } else if (rectangle.getMaxX() < rectangle.getMinX() && rectangle.getMaxY() < rectangle.getMinY()) { - nuclearFacilityPoints = nuclearFacilityPoints.stream().filter(item-> StringUtils.isNotBlank(item.getLon()) && StringUtils.isNotBlank(item.getLat()) && - (Double.valueOf(item.getLon())>=rectangle.getMaxX() && Double.valueOf(item.getLon())<= rectangle.getMinX()) - && (Double.valueOf(item.getLat())>=rectangle.getMaxY() && Double.valueOf(item.getLat())<= rectangle.getMinY())).collect(Collectors.toList()); + nuclearFacilityPoints = nuclearFacilityPoints.stream().filter(item -> StringUtils.isNotBlank(item.getLon()) && StringUtils.isNotBlank(item.getLat()) && + (Double.valueOf(item.getLon()) >= rectangle.getMaxX() && Double.valueOf(item.getLon()) <= rectangle.getMinX()) + && (Double.valueOf(item.getLat()) >= rectangle.getMaxY() && Double.valueOf(item.getLat()) <= rectangle.getMinY())).collect(Collectors.toList()); } //遍历在正方形范围内的数据 根据点的经纬度信息以及圆心的经纬度信息 计算出两者之间的距离 与 半径进行比较 <=半径则说明点在范围内,否则点超出半径范围 nuclearFacilityPoints = nuclearFacilityPoints.stream() .filter(equ -> getDistance(Double.valueOf(equ.getLon()), Double.valueOf(equ.getLat()), longitudeD, latitudeD) <= radius).collect(Collectors.toList()); //在范围内的点信息 计算点与圆心间的半径距离返回信息 - for (Point p:nuclearFacilityPoints) { + for (Point p : nuclearFacilityPoints) { stationsList.add(nuclearFacilityMap.get(p.getNuclearFacilityId())); //计算点与圆心间的距离信息 double radiusR = getDistance(Double.valueOf(p.getLon()), Double.valueOf(p.getLat()), longitudeD, latitudeD); p.setRadius(String.valueOf(radiusR)); p.setStationName(stationName); } - if (CollectionUtils.isNotEmpty(nuclearFacilityPoints)){ + if (CollectionUtils.isNotEmpty(nuclearFacilityPoints)) { resultList.add(nuclearFacilityPoints); } } @@ -400,8 +400,8 @@ public class StationOperationServiceImpl extends ServiceImpl> cacheList = cacheTimeService.findCacheTime(); - for (int i=0; i< cacheList.size(); i++){ - if ( StringUtils.isNotBlank(cacheList.get(i).get(CacheName.cacheTime)) ){ + for (int i = 0; i < cacheList.size(); i++) { + if (StringUtils.isNotBlank(cacheList.get(i).get(CacheName.cacheTime))) { cacheTime = Double.valueOf(cacheList.get(i).get(CacheName.cacheTime)); } } @@ -411,7 +411,7 @@ public class StationOperationServiceImpl extends ServiceImpl stationDataList = new LinkedList<>(); if (CollectionUtils.isNotEmpty(stationDataMap)) { @@ -421,12 +421,12 @@ public class StationOperationServiceImpl extends ServiceImpl>> detectors = stationData.getDetectors(); //遍历探测器的集合 - for (Map.Entry>> detector:detectors.entrySet()) { + for (Map.Entry>> detector : detectors.entrySet()) { //获取探测器对应的数组 List> detectorValue = detector.getValue(); //遍历探测器数组 - for (Map detectorDataMap:detectorValue) { - for (String key :detectorDataMap.keySet()) { + for (Map detectorDataMap : detectorValue) { + for (String key : detectorDataMap.keySet()) { DetectorData detectorData = detectorDataMap.get(key); List dataList = detectorData.getDataList(); //通过流过滤出数据的开始时间戳在用户统计的开始时间戳之后的数据 @@ -454,18 +454,18 @@ public class StationOperationServiceImpl extends ServiceImpl>> detectors = stationData.getDetectors(); //遍历探测器的集合 - for (Map.Entry>> detector:detectors.entrySet()) { + for (Map.Entry>> detector : detectors.entrySet()) { //获取探测器对应的数组 List> detectorValue = detector.getValue(); //遍历探测器数组 - for (Map detectorDataMap:detectorValue) { - for (String key :detectorDataMap.keySet()) { + for (Map detectorDataMap : detectorValue) { + for (String key : detectorDataMap.keySet()) { DetectorData detectorData = detectorDataMap.get(key); List dataList = detectorData.getDataList(); //通过流过滤出数据的开始时间戳在用户统计的开始时间戳之后的数据 @@ -503,7 +503,7 @@ public class StationOperationServiceImpl extends ServiceImpl