格式化代码
This commit is contained in:
parent
029891c686
commit
0fd138b175
|
@ -82,14 +82,14 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
||||||
HashMap<String, Object> nuclearFacilityMap = (HashMap<String, Object>) redisUtil.get("nuclearFacilityMap");
|
HashMap<String, Object> nuclearFacilityMap = (HashMap<String, Object>) redisUtil.get("nuclearFacilityMap");
|
||||||
List<StationOperation> stationList = new LinkedList<>();
|
List<StationOperation> stationList = new LinkedList<>();
|
||||||
//遍历台站信息
|
//遍历台站信息
|
||||||
if (CollectionUtils.isNotEmpty(stationInfoMap)){
|
if (CollectionUtils.isNotEmpty(stationInfoMap)) {
|
||||||
for (Map.Entry<String, Object> gardsStations:stationInfoMap.entrySet()) {
|
for (Map.Entry<String, Object> gardsStations : stationInfoMap.entrySet()) {
|
||||||
GardsStations gardsStation = (GardsStations)gardsStations.getValue();
|
GardsStations gardsStation = (GardsStations) gardsStations.getValue();
|
||||||
StationOperation stationOperation = new StationOperation();
|
StationOperation stationOperation = new StationOperation();
|
||||||
stationOperation.setStationId(gardsStation.getStationId());
|
stationOperation.setStationId(gardsStation.getStationId());
|
||||||
stationOperation.setStationName(gardsStation.getStationCode());
|
stationOperation.setStationName(gardsStation.getStationCode());
|
||||||
stationOperation.setStationType(stationTypeUtil.getStationType(gardsStation.getStationId(), gardsStation.getCategory()));
|
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.setLon(String.valueOf(gardsStation.getLon()));
|
||||||
stationOperation.setLat(String.valueOf(gardsStation.getLat()));
|
stationOperation.setLat(String.valueOf(gardsStation.getLat()));
|
||||||
stationOperation.setStatus(gardsStation.getStatus());
|
stationOperation.setStatus(gardsStation.getStatus());
|
||||||
|
@ -101,10 +101,10 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<StationOperation> nuclearFacilityList = new LinkedList<>();
|
List<StationOperation> nuclearFacilityList = new LinkedList<>();
|
||||||
if (CollectionUtils.isNotEmpty(nuclearFacilityMap)){
|
if (CollectionUtils.isNotEmpty(nuclearFacilityMap)) {
|
||||||
//遍历核设施信息
|
//遍历核设施信息
|
||||||
for (Map.Entry<String, Object> nuclearfacilities:nuclearFacilityMap.entrySet()) {
|
for (Map.Entry<String, Object> nuclearfacilities : nuclearFacilityMap.entrySet()) {
|
||||||
GardsNuclearfacility nuclearfacility = (GardsNuclearfacility)nuclearfacilities.getValue();
|
GardsNuclearfacility nuclearfacility = (GardsNuclearfacility) nuclearfacilities.getValue();
|
||||||
StationOperation stationOperation = new StationOperation();
|
StationOperation stationOperation = new StationOperation();
|
||||||
stationOperation.setStationId(nuclearfacility.getFacilityId());
|
stationOperation.setStationId(nuclearfacility.getFacilityId());
|
||||||
stationOperation.setStationName(nuclearfacility.getFacilityName());
|
stationOperation.setStationName(nuclearfacility.getFacilityName());
|
||||||
|
@ -123,12 +123,12 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
||||||
result.addAll(stationList);
|
result.addAll(stationList);
|
||||||
result.addAll(nuclearFacilityList);
|
result.addAll(nuclearFacilityList);
|
||||||
//如果状态不为空
|
//如果状态不为空
|
||||||
if (StringUtils.isNotBlank(status)){
|
if (StringUtils.isNotBlank(status)) {
|
||||||
result = result.stream().filter(item-> StringUtils.isNotBlank(item.getStatus()) && item.getStatus().equalsIgnoreCase(status)).collect(Collectors.toList());
|
result = result.stream().filter(item -> StringUtils.isNotBlank(item.getStatus()) && item.getStatus().equalsIgnoreCase(status)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
//如果类型不为空
|
//如果类型不为空
|
||||||
if (StringUtils.isNotBlank(stationType)){
|
if (StringUtils.isNotBlank(stationType)) {
|
||||||
result = result.stream().filter(item-> StringUtils.isNotBlank(item.getStationType()) && item.getStationType().equalsIgnoreCase(stationType)).collect(Collectors.toList());
|
result = result.stream().filter(item -> StringUtils.isNotBlank(item.getStationType()) && item.getStationType().equalsIgnoreCase(stationType)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -137,30 +137,30 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
||||||
public Result findInfo(String stationId, String type) {
|
public Result findInfo(String stationId, String type) {
|
||||||
Result result = new Result();
|
Result result = new Result();
|
||||||
List<String> stationTypes = stationType.getTypes().stream().map(StationType::getName).collect(Collectors.toList());
|
List<String> stationTypes = stationType.getTypes().stream().map(StationType::getName).collect(Collectors.toList());
|
||||||
if (stationTypes.contains(type)){
|
if (stationTypes.contains(type)) {
|
||||||
HashMap<String, GardsStations> stationInfoMap = (HashMap<String, GardsStations>) redisUtil.get("stationInfoMap");
|
HashMap<String, GardsStations> stationInfoMap = (HashMap<String, GardsStations>) redisUtil.get("stationInfoMap");
|
||||||
GardsStations stations = stationInfoMap.get(stationId);
|
GardsStations stations = stationInfoMap.get(stationId);
|
||||||
if (Objects.nonNull(stations)){
|
if (Objects.nonNull(stations)) {
|
||||||
result.setResult(stations);
|
result.setResult(stations);
|
||||||
result.setSuccess(true);
|
result.setSuccess(true);
|
||||||
}else {
|
} else {
|
||||||
result.error500("The corresponding information under the station does not exist");
|
result.error500("The corresponding information under the station does not exist");
|
||||||
}
|
}
|
||||||
}else if(type.equals("Nuclear Facility")){
|
} else if (type.equals("Nuclear Facility")) {
|
||||||
HashMap<String, GardsNuclearfacility> nuclearFacilityMap = (HashMap<String, GardsNuclearfacility>) redisUtil.get("nuclearFacilityMap");
|
HashMap<String, GardsNuclearfacility> nuclearFacilityMap = (HashMap<String, GardsNuclearfacility>) redisUtil.get("nuclearFacilityMap");
|
||||||
//从缓存的核设施map中获取对应的核设施信息
|
//从缓存的核设施map中获取对应的核设施信息
|
||||||
GardsNuclearfacility nuclearfacility = nuclearFacilityMap.get(stationId);
|
GardsNuclearfacility nuclearfacility = nuclearFacilityMap.get(stationId);
|
||||||
if (Objects.nonNull(nuclearfacility)){
|
if (Objects.nonNull(nuclearfacility)) {
|
||||||
String longitude = nuclearfacility.getLongitude();
|
String longitude = nuclearfacility.getLongitude();
|
||||||
String latitude = nuclearfacility.getLatitude();
|
String latitude = nuclearfacility.getLatitude();
|
||||||
nuclearfacility.setLongitude(PointUtil.calculate(latitude));
|
nuclearfacility.setLongitude(PointUtil.calculate(latitude));
|
||||||
nuclearfacility.setLatitude(PointUtil.calculate(longitude));
|
nuclearfacility.setLatitude(PointUtil.calculate(longitude));
|
||||||
result.setResult(nuclearfacility);
|
result.setResult(nuclearfacility);
|
||||||
result.setSuccess(true);
|
result.setSuccess(true);
|
||||||
}else {
|
} else {
|
||||||
result.error500("The corresponding information does not exist in the nuclear facility");
|
result.error500("The corresponding information does not exist in the nuclear facility");
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
result.error500("The current type does not exist");
|
result.error500("The current type does not exist");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -172,47 +172,47 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
||||||
//声明一个数组存储城市编码信息以及台站信息
|
//声明一个数组存储城市编码信息以及台站信息
|
||||||
List<StationTree> stationTreeList = new LinkedList<>();
|
List<StationTree> stationTreeList = new LinkedList<>();
|
||||||
//查询台站信息接口
|
//查询台站信息接口
|
||||||
HashMap<String, Object> stationMap = (HashMap<String, Object>)redisUtil.get("stationInfoMap");
|
HashMap<String, Object> stationMap = (HashMap<String, Object>) redisUtil.get("stationInfoMap");
|
||||||
if (CollectionUtils.isNotEmpty(stationMap)){
|
if (CollectionUtils.isNotEmpty(stationMap)) {
|
||||||
//遍历台站信息存储进数组
|
//遍历台站信息存储进数组
|
||||||
List<GardsStations> gardsStationsList = new ArrayList<>();
|
List<GardsStations> gardsStationsList = new ArrayList<>();
|
||||||
for (Map.Entry<String, Object> entry:stationMap.entrySet()) {
|
for (Map.Entry<String, Object> entry : stationMap.entrySet()) {
|
||||||
GardsStations entryValue = (GardsStations) entry.getValue();
|
GardsStations entryValue = (GardsStations) entry.getValue();
|
||||||
gardsStationsList.add(entryValue);
|
gardsStationsList.add(entryValue);
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(gardsStationsList)){
|
if (CollectionUtils.isNotEmpty(gardsStationsList)) {
|
||||||
//过滤出所有的台站城市编码
|
//过滤出所有的台站城市编码
|
||||||
List<Object> countryCodes = gardsStationsList.stream().map(GardsStations::getCountryCode).distinct().sorted().collect(Collectors.toList());
|
List<Object> countryCodes = gardsStationsList.stream().map(GardsStations::getCountryCode).distinct().sorted().collect(Collectors.toList());
|
||||||
if (CollectionUtils.isNotEmpty(countryCodes)){
|
if (CollectionUtils.isNotEmpty(countryCodes)) {
|
||||||
for (int i=0; i<3; i++){
|
for (int i = 0; i < 3; i++) {
|
||||||
//树形结构子级 用于存储城市及城市下的台站信息
|
//树形结构子级 用于存储城市及城市下的台站信息
|
||||||
List<Object> stationChildTreeList = new LinkedList<>();
|
List<Object> stationChildTreeList = new LinkedList<>();
|
||||||
StationTree stationTree = new StationTree();
|
StationTree stationTree = new StationTree();
|
||||||
stationTree.setStationId(i);
|
stationTree.setStationId(i);
|
||||||
if (i == 0){
|
if (i == 0) {
|
||||||
stationTree.setCode("Particulate Station");
|
stationTree.setCode("Particulate Station");
|
||||||
}else if (i == 1){
|
} else if (i == 1) {
|
||||||
stationTree.setCode("Noble Gas Station");
|
stationTree.setCode("Noble Gas Station");
|
||||||
}else if (i == 2){
|
} else if (i == 2) {
|
||||||
stationTree.setCode("NRL");
|
stationTree.setCode("NRL");
|
||||||
}
|
}
|
||||||
for (Object countryCode:countryCodes) {
|
for (Object countryCode : countryCodes) {
|
||||||
//用于存储城市下对应的台站信息
|
//用于存储城市下对应的台站信息
|
||||||
List<Object> stations = new LinkedList<>();
|
List<Object> stations = new LinkedList<>();
|
||||||
String country = String.valueOf(countryCode);
|
String country = String.valueOf(countryCode);
|
||||||
//声明一个数组存储城市编码对应的数组信息
|
//声明一个数组存储城市编码对应的数组信息
|
||||||
StationTree stationChildTree = new StationTree();
|
StationTree stationChildTree = new StationTree();
|
||||||
stationChildTree.setStationId(countryCodes.indexOf(countryCode)+1);
|
stationChildTree.setStationId(countryCodes.indexOf(countryCode) + 1);
|
||||||
stationChildTree.setCode(country);
|
stationChildTree.setCode(country);
|
||||||
List<GardsStations> stationsList = gardsStationsList.stream().filter(station-> station.getCountryCode().equals(countryCode)).collect(Collectors.toList());
|
List<GardsStations> stationsList = gardsStationsList.stream().filter(station -> station.getCountryCode().equals(countryCode)).collect(Collectors.toList());
|
||||||
if (i == 0){
|
if (i == 0) {
|
||||||
stationsList = stationsList.stream().filter(item-> item.getStationId()<=200).sorted(Comparator.comparing(GardsStations::getStationId)).collect(Collectors.toList());
|
stationsList = stationsList.stream().filter(item -> item.getStationId() <= 200).sorted(Comparator.comparing(GardsStations::getStationId)).collect(Collectors.toList());
|
||||||
stations.addAll(stationsList);
|
stations.addAll(stationsList);
|
||||||
}else if(i == 1){
|
} else if (i == 1) {
|
||||||
stationsList = stationsList.stream().filter(item-> item.getStationId()>200 && item.getStationId()<=300).sorted(Comparator.comparing(GardsStations::getStationId)).collect(Collectors.toList());
|
stationsList = stationsList.stream().filter(item -> item.getStationId() > 200 && item.getStationId() <= 300).sorted(Comparator.comparing(GardsStations::getStationId)).collect(Collectors.toList());
|
||||||
stations.addAll(stationsList);
|
stations.addAll(stationsList);
|
||||||
}else if(i == 2){
|
} else if (i == 2) {
|
||||||
stationsList = stationsList.stream().filter(item-> item.getStationId()>300).sorted(Comparator.comparing(GardsStations::getStationId)).collect(Collectors.toList());
|
stationsList = stationsList.stream().filter(item -> item.getStationId() > 300).sorted(Comparator.comparing(GardsStations::getStationId)).collect(Collectors.toList());
|
||||||
stations.addAll(stationsList);
|
stations.addAll(stationsList);
|
||||||
}
|
}
|
||||||
stationChildTree.setChildren(stations);
|
stationChildTree.setChildren(stations);
|
||||||
|
@ -246,26 +246,26 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
||||||
result.error500("Please pass in radius");
|
result.error500("Please pass in radius");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (CollectionUtils.isNotEmpty(stationIds)){
|
if (CollectionUtils.isNotEmpty(stationIds)) {
|
||||||
//查询全部台站信息
|
//查询全部台站信息
|
||||||
HashMap<String, Object> stationInfoMap = (HashMap<String, Object>) redisUtil.get("stationInfoMap");
|
HashMap<String, Object> stationInfoMap = (HashMap<String, Object>) redisUtil.get("stationInfoMap");
|
||||||
//查询全部核设施信息
|
//查询全部核设施信息
|
||||||
HashMap<String, GardsNuclearfacility> nuclearFacilityMap = (HashMap<String, GardsNuclearfacility>) redisUtil.get("nuclearFacilityMap");
|
HashMap<String, GardsNuclearfacility> nuclearFacilityMap = (HashMap<String, GardsNuclearfacility>) redisUtil.get("nuclearFacilityMap");
|
||||||
if (CollectionUtils.isNotEmpty(nuclearFacilityMap)){
|
if (CollectionUtils.isNotEmpty(nuclearFacilityMap)) {
|
||||||
//声明一个集合存储转换经纬度后的核设施数据
|
//声明一个集合存储转换经纬度后的核设施数据
|
||||||
List<Point> nuclearPoints = new ArrayList<>();
|
List<Point> nuclearPoints = new ArrayList<>();
|
||||||
for (Map.Entry<String,GardsNuclearfacility> nuclearFacilityInfo:nuclearFacilityMap.entrySet()) {
|
for (Map.Entry<String, GardsNuclearfacility> nuclearFacilityInfo : nuclearFacilityMap.entrySet()) {
|
||||||
GardsNuclearfacility facilityInfoValue = nuclearFacilityInfo.getValue();
|
GardsNuclearfacility facilityInfoValue = nuclearFacilityInfo.getValue();
|
||||||
Point point = new Point();
|
Point point = new Point();
|
||||||
point.setNuclearFacilityId(String.valueOf(facilityInfoValue.getFacilityId()));
|
point.setNuclearFacilityId(String.valueOf(facilityInfoValue.getFacilityId()));
|
||||||
point.setNuclearFacilityName(facilityInfoValue.getFacilityName());
|
point.setNuclearFacilityName(facilityInfoValue.getFacilityName());
|
||||||
String lon = "";
|
String lon = "";
|
||||||
String lat = "";
|
String lat = "";
|
||||||
if (StringUtils.isNotBlank(facilityInfoValue.getLongitude())){
|
if (StringUtils.isNotBlank(facilityInfoValue.getLongitude())) {
|
||||||
lat = PointUtil.calculate(facilityInfoValue.getLongitude());
|
lat = PointUtil.calculate(facilityInfoValue.getLongitude());
|
||||||
point.setLat(lat);
|
point.setLat(lat);
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(facilityInfoValue.getLatitude())){
|
if (StringUtils.isNotBlank(facilityInfoValue.getLatitude())) {
|
||||||
lon = PointUtil.calculate(facilityInfoValue.getLatitude());
|
lon = PointUtil.calculate(facilityInfoValue.getLatitude());
|
||||||
point.setLon(lon);
|
point.setLon(lon);
|
||||||
}
|
}
|
||||||
|
@ -273,8 +273,8 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
||||||
facilityInfoValue.setLongitude(lon);
|
facilityInfoValue.setLongitude(lon);
|
||||||
nuclearPoints.add(point);
|
nuclearPoints.add(point);
|
||||||
}
|
}
|
||||||
for (String stationId:stationIds) {
|
for (String stationId : stationIds) {
|
||||||
GardsStations point = (GardsStations)stationInfoMap.get(stationId);
|
GardsStations point = (GardsStations) stationInfoMap.get(stationId);
|
||||||
stationsList.add(point);
|
stationsList.add(point);
|
||||||
//声明一个数组存储对应的核设施经纬度信息
|
//声明一个数组存储对应的核设施经纬度信息
|
||||||
List<Point> nuclearFacilityPoints = deepCopy(nuclearPoints);
|
List<Point> nuclearFacilityPoints = deepCopy(nuclearPoints);
|
||||||
|
@ -300,34 +300,34 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
||||||
Rectangle rectangle = getRectangle(radius, longitudeD, latitudeD);
|
Rectangle rectangle = getRectangle(radius, longitudeD, latitudeD);
|
||||||
// 2.获取位置在正方形内的所有设备 判断核设施的经纬度是否为空 不为空 判断经纬度是否在正方形的最大最小范围内 如果在则过滤出来继续使用否则弃用
|
// 2.获取位置在正方形内的所有设备 判断核设施的经纬度是否为空 不为空 判断经纬度是否在正方形的最大最小范围内 如果在则过滤出来继续使用否则弃用
|
||||||
if (rectangle.getMaxX() > rectangle.getMinX() && rectangle.getMaxY() > rectangle.getMinY()) {
|
if (rectangle.getMaxX() > rectangle.getMinX() && rectangle.getMaxY() > rectangle.getMinY()) {
|
||||||
nuclearFacilityPoints = nuclearFacilityPoints.stream().filter(item-> StringUtils.isNotBlank(item.getLon()) && StringUtils.isNotBlank(item.getLat()) &&
|
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.getLon()) >= rectangle.getMinX() && Double.valueOf(item.getLon()) <= rectangle.getMaxX())
|
||||||
&& (Double.valueOf(item.getLat())>=rectangle.getMinY() && Double.valueOf(item.getLat())<= rectangle.getMaxY())).collect(Collectors.toList());
|
&& (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()) {
|
} else if (rectangle.getMaxX() < rectangle.getMinX() && rectangle.getMaxY() > rectangle.getMinY()) {
|
||||||
nuclearFacilityPoints = nuclearFacilityPoints.stream().filter(item-> StringUtils.isNotBlank(item.getLon()) && StringUtils.isNotBlank(item.getLat()) &&
|
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.getLon()) >= rectangle.getMaxX() && Double.valueOf(item.getLon()) <= rectangle.getMinX())
|
||||||
&& (Double.valueOf(item.getLat())>=rectangle.getMinY() && Double.valueOf(item.getLat())<= rectangle.getMaxY())).collect(Collectors.toList());
|
&& (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()) {
|
} else if (rectangle.getMaxX() > rectangle.getMinX() && rectangle.getMaxY() < rectangle.getMinY()) {
|
||||||
nuclearFacilityPoints = nuclearFacilityPoints.stream().filter(item-> StringUtils.isNotBlank(item.getLon()) && StringUtils.isNotBlank(item.getLat()) &&
|
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.getLon()) >= rectangle.getMinX() && Double.valueOf(item.getLon()) <= rectangle.getMaxX())
|
||||||
&& (Double.valueOf(item.getLat())>=rectangle.getMaxY() && Double.valueOf(item.getLat())<= rectangle.getMinY())).collect(Collectors.toList());
|
&& (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()) {
|
} else if (rectangle.getMaxX() < rectangle.getMinX() && rectangle.getMaxY() < rectangle.getMinY()) {
|
||||||
nuclearFacilityPoints = nuclearFacilityPoints.stream().filter(item-> StringUtils.isNotBlank(item.getLon()) && StringUtils.isNotBlank(item.getLat()) &&
|
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.getLon()) >= rectangle.getMaxX() && Double.valueOf(item.getLon()) <= rectangle.getMinX())
|
||||||
&& (Double.valueOf(item.getLat())>=rectangle.getMaxY() && Double.valueOf(item.getLat())<= rectangle.getMinY())).collect(Collectors.toList());
|
&& (Double.valueOf(item.getLat()) >= rectangle.getMaxY() && Double.valueOf(item.getLat()) <= rectangle.getMinY())).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
//遍历在正方形范围内的数据 根据点的经纬度信息以及圆心的经纬度信息 计算出两者之间的距离 与 半径进行比较 <=半径则说明点在范围内,否则点超出半径范围
|
//遍历在正方形范围内的数据 根据点的经纬度信息以及圆心的经纬度信息 计算出两者之间的距离 与 半径进行比较 <=半径则说明点在范围内,否则点超出半径范围
|
||||||
nuclearFacilityPoints = nuclearFacilityPoints.stream()
|
nuclearFacilityPoints = nuclearFacilityPoints.stream()
|
||||||
.filter(equ -> getDistance(Double.valueOf(equ.getLon()), Double.valueOf(equ.getLat()), longitudeD, latitudeD) <= radius).collect(Collectors.toList());
|
.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()));
|
stationsList.add(nuclearFacilityMap.get(p.getNuclearFacilityId()));
|
||||||
//计算点与圆心间的距离信息
|
//计算点与圆心间的距离信息
|
||||||
double radiusR = getDistance(Double.valueOf(p.getLon()), Double.valueOf(p.getLat()), longitudeD, latitudeD);
|
double radiusR = getDistance(Double.valueOf(p.getLon()), Double.valueOf(p.getLat()), longitudeD, latitudeD);
|
||||||
p.setRadius(String.valueOf(radiusR));
|
p.setRadius(String.valueOf(radiusR));
|
||||||
p.setStationName(stationName);
|
p.setStationName(stationName);
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(nuclearFacilityPoints)){
|
if (CollectionUtils.isNotEmpty(nuclearFacilityPoints)) {
|
||||||
resultList.add(nuclearFacilityPoints);
|
resultList.add(nuclearFacilityPoints);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -400,8 +400,8 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
||||||
//调用接口获取数据库中对应缓存配置信息默认值
|
//调用接口获取数据库中对应缓存配置信息默认值
|
||||||
if (Objects.isNull(cacheTime) || cacheTime <= 0) {
|
if (Objects.isNull(cacheTime) || cacheTime <= 0) {
|
||||||
List<Map<String, String>> cacheList = cacheTimeService.findCacheTime();
|
List<Map<String, String>> cacheList = cacheTimeService.findCacheTime();
|
||||||
for (int i=0; i< cacheList.size(); i++){
|
for (int i = 0; i < cacheList.size(); i++) {
|
||||||
if ( StringUtils.isNotBlank(cacheList.get(i).get(CacheName.cacheTime)) ){
|
if (StringUtils.isNotBlank(cacheList.get(i).get(CacheName.cacheTime))) {
|
||||||
cacheTime = Double.valueOf(cacheList.get(i).get(CacheName.cacheTime));
|
cacheTime = Double.valueOf(cacheList.get(i).get(CacheName.cacheTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -411,7 +411,7 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
||||||
//根据缓存日期 得到开始查询时间
|
//根据缓存日期 得到开始查询时间
|
||||||
LocalDateTime startDate = endDate.minusDays(cacheTime.intValue());
|
LocalDateTime startDate = endDate.minusDays(cacheTime.intValue());
|
||||||
//获取到开始时间的秒数
|
//获取到开始时间的秒数
|
||||||
long startMill = startDate.toInstant(ZoneOffset.UTC).toEpochMilli()/1000;
|
long startMill = startDate.toInstant(ZoneOffset.UTC).toEpochMilli() / 1000;
|
||||||
//过滤出当前用户关注的台站信息
|
//过滤出当前用户关注的台站信息
|
||||||
List<StationData> stationDataList = new LinkedList<>();
|
List<StationData> stationDataList = new LinkedList<>();
|
||||||
if (CollectionUtils.isNotEmpty(stationDataMap)) {
|
if (CollectionUtils.isNotEmpty(stationDataMap)) {
|
||||||
|
@ -421,12 +421,12 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
||||||
//读取探测器的数据集合
|
//读取探测器的数据集合
|
||||||
Map<String, List<Map<String, DetectorData>>> detectors = stationData.getDetectors();
|
Map<String, List<Map<String, DetectorData>>> detectors = stationData.getDetectors();
|
||||||
//遍历探测器的集合
|
//遍历探测器的集合
|
||||||
for (Map.Entry<String, List<Map<String, DetectorData>>> detector:detectors.entrySet()) {
|
for (Map.Entry<String, List<Map<String, DetectorData>>> detector : detectors.entrySet()) {
|
||||||
//获取探测器对应的数组
|
//获取探测器对应的数组
|
||||||
List<Map<String, DetectorData>> detectorValue = detector.getValue();
|
List<Map<String, DetectorData>> detectorValue = detector.getValue();
|
||||||
//遍历探测器数组
|
//遍历探测器数组
|
||||||
for (Map<String, DetectorData> detectorDataMap:detectorValue) {
|
for (Map<String, DetectorData> detectorDataMap : detectorValue) {
|
||||||
for (String key :detectorDataMap.keySet()) {
|
for (String key : detectorDataMap.keySet()) {
|
||||||
DetectorData detectorData = detectorDataMap.get(key);
|
DetectorData detectorData = detectorDataMap.get(key);
|
||||||
List<DataInfoVo> dataList = detectorData.getDataList();
|
List<DataInfoVo> dataList = detectorData.getDataList();
|
||||||
//通过流过滤出数据的开始时间戳在用户统计的开始时间戳之后的数据
|
//通过流过滤出数据的开始时间戳在用户统计的开始时间戳之后的数据
|
||||||
|
@ -454,18 +454,18 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
||||||
}
|
}
|
||||||
stationIds = stationIds.stream().distinct().collect(Collectors.toList());
|
stationIds = stationIds.stream().distinct().collect(Collectors.toList());
|
||||||
if (CollectionUtils.isNotEmpty(stationIds)) {
|
if (CollectionUtils.isNotEmpty(stationIds)) {
|
||||||
for (String stationId:stationIds) {
|
for (String stationId : stationIds) {
|
||||||
StationData stationData = stationDataMap.get(stationId);
|
StationData stationData = stationDataMap.get(stationId);
|
||||||
if (Objects.nonNull(stationData)) {
|
if (Objects.nonNull(stationData)) {
|
||||||
//读取探测器的数据集合
|
//读取探测器的数据集合
|
||||||
Map<String, List<Map<String, DetectorData>>> detectors = stationData.getDetectors();
|
Map<String, List<Map<String, DetectorData>>> detectors = stationData.getDetectors();
|
||||||
//遍历探测器的集合
|
//遍历探测器的集合
|
||||||
for (Map.Entry<String, List<Map<String, DetectorData>>> detector:detectors.entrySet()) {
|
for (Map.Entry<String, List<Map<String, DetectorData>>> detector : detectors.entrySet()) {
|
||||||
//获取探测器对应的数组
|
//获取探测器对应的数组
|
||||||
List<Map<String, DetectorData>> detectorValue = detector.getValue();
|
List<Map<String, DetectorData>> detectorValue = detector.getValue();
|
||||||
//遍历探测器数组
|
//遍历探测器数组
|
||||||
for (Map<String, DetectorData> detectorDataMap:detectorValue) {
|
for (Map<String, DetectorData> detectorDataMap : detectorValue) {
|
||||||
for (String key :detectorDataMap.keySet()) {
|
for (String key : detectorDataMap.keySet()) {
|
||||||
DetectorData detectorData = detectorDataMap.get(key);
|
DetectorData detectorData = detectorDataMap.get(key);
|
||||||
List<DataInfoVo> dataList = detectorData.getDataList();
|
List<DataInfoVo> dataList = detectorData.getDataList();
|
||||||
//通过流过滤出数据的开始时间戳在用户统计的开始时间戳之后的数据
|
//通过流过滤出数据的开始时间戳在用户统计的开始时间戳之后的数据
|
||||||
|
@ -503,7 +503,7 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
||||||
result.error500("Station Code cannot be null");
|
result.error500("Station Code cannot be null");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (Objects.isNull(startDate)){
|
if (Objects.isNull(startDate)) {
|
||||||
result.error500("The start time cannot be empty");
|
result.error500("The start time cannot be empty");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user