MET、SOH普文件去重
This commit is contained in:
parent
2d96fbe7d0
commit
9e65ca7493
|
@ -9,6 +9,7 @@ import org.jeecg.common.util.DateUtils;
|
|||
import org.jeecg.common.util.NumberFormatUtil;
|
||||
import org.jeecg.modules.base.entity.configuration.GardsStations;
|
||||
import org.jeecg.modules.base.entity.original.GardsMetData;
|
||||
import org.jeecg.modules.base.entity.original.GardsSohData;
|
||||
import org.jeecg.modules.file.FileOperation;
|
||||
import org.jeecg.modules.mapper.GardsMetDataMapper;
|
||||
import org.jeecg.modules.mapper.GardsStationsMapper;
|
||||
|
@ -22,6 +23,7 @@ import org.springframework.util.CollectionUtils;
|
|||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 处理气象谱
|
||||
|
@ -36,6 +38,7 @@ public class MetSpectrumServiceImpl extends ServiceImpl<GardsMetDataMapper, Gard
|
|||
|
||||
/**
|
||||
* 保存气象谱数据
|
||||
*
|
||||
* @param struct
|
||||
* @param fileName
|
||||
* @return
|
||||
|
@ -43,33 +46,42 @@ public class MetSpectrumServiceImpl extends ServiceImpl<GardsMetDataMapper, Gard
|
|||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public List<GardsMetData> create(MetSpectrumStruct struct,String fileName) throws Exception{
|
||||
Assert.notNull(struct.station_code,"此次解析结构体中的台站“台站代码”为空");
|
||||
public List<GardsMetData> create(MetSpectrumStruct struct, String fileName) throws Exception {
|
||||
Assert.notNull(struct.station_code, "此次解析结构体中的台站“台站代码”为空");
|
||||
|
||||
//校验台站是否存在,不存在则报异常
|
||||
final GardsStations station = stationsService.check(struct.station_code,fileName);
|
||||
final GardsStations station = stationsService.check(struct.station_code, fileName);
|
||||
List<GardsMetData> list = Lists.newArrayList();
|
||||
if(struct.record_count > 0){
|
||||
for(int i=0;i<struct.record_count;i++){
|
||||
GardsMetData metData = new GardsMetData();
|
||||
metData.setStationId(station.getStationId());
|
||||
metData.setStationCode(struct.station_code);
|
||||
metData.setStartTime(DateUtils.parseDate(struct.met_start_date.get(i)+" "+struct.met_start_time.get(i)));
|
||||
metData.setEndTime(DateUtils.parseDate(struct.met_end_date.get(i)+" "+struct.met_end_time.get(i)));
|
||||
metData.setAveHumidity(numberFormatUtil.DoubleLimit(struct.humidity.get(i)));
|
||||
metData.setAvgtemperature(numberFormatUtil.DoubleLimit(struct.average_outside_temperature.get(i)));
|
||||
metData.setAvePressure(numberFormatUtil.DoubleLimit(struct.average_barometric_reading.get(i)));
|
||||
metData.setAveWindDir(numberFormatUtil.DoubleLimit(struct.average_wind_direction.get(i)));
|
||||
metData.setAveWindSpeed(numberFormatUtil.DoubleLimit(struct.average_wind_speed.get(i)));
|
||||
metData.setRainfall(numberFormatUtil.DoubleLimit(struct.rainfall.get(i)));
|
||||
metData.setInputFileName(FileOperation.separatorConvert(fileName));
|
||||
metData.setModdate(new Date());
|
||||
list.add(metData);
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(list)){
|
||||
list.forEach(metData->{
|
||||
this.save(metData);
|
||||
});
|
||||
if (struct.record_count > 0) {
|
||||
String finalFileName = FileOperation.separatorConvert(fileName);
|
||||
LambdaQueryWrapper<GardsMetData> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.select(GardsMetData::getMetId);
|
||||
queryWrapper.eq(GardsMetData::getInputFileName, finalFileName);
|
||||
GardsMetData metDataOne= this.getOne(queryWrapper,false);
|
||||
if (Objects.isNull(metDataOne)) {
|
||||
|
||||
for (int i = 0; i < struct.record_count; i++) {
|
||||
GardsMetData metData = new GardsMetData();
|
||||
metData.setStationId(station.getStationId());
|
||||
metData.setStationCode(struct.station_code);
|
||||
metData.setStartTime(DateUtils.parseDate(struct.met_start_date.get(i) + " " + struct.met_start_time.get(i)));
|
||||
metData.setEndTime(DateUtils.parseDate(struct.met_end_date.get(i) + " " + struct.met_end_time.get(i)));
|
||||
metData.setAveHumidity(numberFormatUtil.DoubleLimit(struct.humidity.get(i)));
|
||||
metData.setAvgtemperature(numberFormatUtil.DoubleLimit(struct.average_outside_temperature.get(i)));
|
||||
metData.setAvePressure(numberFormatUtil.DoubleLimit(struct.average_barometric_reading.get(i)));
|
||||
metData.setAveWindDir(numberFormatUtil.DoubleLimit(struct.average_wind_direction.get(i)));
|
||||
metData.setAveWindSpeed(numberFormatUtil.DoubleLimit(struct.average_wind_speed.get(i)));
|
||||
metData.setRainfall(numberFormatUtil.DoubleLimit(struct.rainfall.get(i)));
|
||||
metData.setInputFileName(FileOperation.separatorConvert(fileName));
|
||||
metData.setModdate(new Date());
|
||||
list.add(metData);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
list.forEach(metData -> {
|
||||
this.save(metData);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.dynamic.datasource.annotation.DS;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.val;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.NumberFormatUtil;
|
||||
|
@ -22,6 +23,7 @@ import org.springframework.util.Assert;
|
|||
import org.springframework.util.CollectionUtils;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 健康谱数据处理
|
||||
|
@ -55,23 +57,29 @@ public class SOHSpectrumServiceImpl extends ServiceImpl<GardsSohDataMapper, Gard
|
|||
|
||||
List<GardsSohData> list = Lists.newArrayList();
|
||||
if(struct.af_record_count > 0){
|
||||
for(int i=0;i<struct.af_record_count;i++){
|
||||
GardsSohData sohData = new GardsSohData();
|
||||
sohData.setStationId(station.getStationId());
|
||||
sohData.setStationCode(struct.station_code);
|
||||
sohData.setStartTime(DateUtils.parseDate(struct.af_start_date.get(i)+" "+struct.af_start_time.get(i)));
|
||||
sohData.setTime(numberFormatUtil.DoubleLimit(struct.af_interval_duration.get(i).doubleValue()));
|
||||
sohData.setAvgflowrate(numberFormatUtil.DoubleLimit(struct.average_flow_rate.get(i)));
|
||||
sohData.setFlowratedev(numberFormatUtil.DoubleLimit(struct.flow_rate_standard_deviation.get(i)));
|
||||
sohData.setInputFileName(FileOperation.separatorConvert(fileName));
|
||||
sohData.setDetectorId(detector.getDetectorId());
|
||||
sohData.setModdate(new Date());
|
||||
list.add(sohData);
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(list)){
|
||||
list.forEach(sohData->{
|
||||
this.save(sohData);
|
||||
});
|
||||
String finalFileName = FileOperation.separatorConvert(fileName);
|
||||
LambdaQueryWrapper<GardsSohData> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(GardsSohData::getInputFileName,finalFileName);
|
||||
GardsSohData sohDataOne= this.getOne(queryWrapper,false);
|
||||
if(Objects.isNull(sohDataOne)){
|
||||
for(int i=0;i<struct.af_record_count;i++){
|
||||
GardsSohData sohData = new GardsSohData();
|
||||
sohData.setStationId(station.getStationId());
|
||||
sohData.setStationCode(struct.station_code);
|
||||
sohData.setStartTime(DateUtils.parseDate(struct.af_start_date.get(i)+" "+struct.af_start_time.get(i)));
|
||||
sohData.setTime(numberFormatUtil.DoubleLimit(struct.af_interval_duration.get(i).doubleValue()));
|
||||
sohData.setAvgflowrate(numberFormatUtil.DoubleLimit(struct.average_flow_rate.get(i)));
|
||||
sohData.setFlowratedev(numberFormatUtil.DoubleLimit(struct.flow_rate_standard_deviation.get(i)));
|
||||
sohData.setInputFileName(FileOperation.separatorConvert(fileName));
|
||||
sohData.setDetectorId(detector.getDetectorId());
|
||||
sohData.setModdate(new Date());
|
||||
list.add(sohData);
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(list)){
|
||||
list.forEach(sohData->{
|
||||
this.save(sohData);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
|
|
@ -79,14 +79,14 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
HashMap<String, Object> nuclearFacilityMap = (HashMap<String, Object>) redisUtil.get("nuclearFacilityMap");
|
||||
List<StationOperation> stationList = new LinkedList<>();
|
||||
//遍历台站信息
|
||||
if (CollectionUtils.isNotEmpty(stationInfoMap)){
|
||||
for (Map.Entry<String, Object> gardsStations:stationInfoMap.entrySet()) {
|
||||
GardsStations gardsStation = (GardsStations)gardsStations.getValue();
|
||||
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(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());
|
||||
|
@ -98,10 +98,10 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
}
|
||||
}
|
||||
List<StationOperation> nuclearFacilityList = new LinkedList<>();
|
||||
if (CollectionUtils.isNotEmpty(nuclearFacilityMap)){
|
||||
if (CollectionUtils.isNotEmpty(nuclearFacilityMap)) {
|
||||
//遍历核设施信息
|
||||
for (Map.Entry<String, Object> nuclearfacilities:nuclearFacilityMap.entrySet()) {
|
||||
GardsNuclearfacility nuclearfacility = (GardsNuclearfacility)nuclearfacilities.getValue();
|
||||
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());
|
||||
|
@ -120,12 +120,12 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
result.addAll(stationList);
|
||||
result.addAll(nuclearFacilityList);
|
||||
//如果状态不为空
|
||||
if (StringUtils.isNotBlank(status)){
|
||||
result = result.stream().filter(item-> 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;
|
||||
}
|
||||
|
@ -133,30 +133,30 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
@Override
|
||||
public Result findInfo(String stationId, String type) {
|
||||
Result result = new Result();
|
||||
if (type.equals("IMS STATION(P)") || type.equals("IMS STATION(G)") || type.equals("NRL")){
|
||||
if (type.equals("IMS STATION(P)") || type.equals("IMS STATION(G)") || type.equals("NRL")) {
|
||||
HashMap<String, GardsStations> stationInfoMap = (HashMap<String, GardsStations>) 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<String, GardsNuclearfacility> nuclearFacilityMap = (HashMap<String, GardsNuclearfacility>) 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;
|
||||
|
@ -168,47 +168,47 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
//声明一个数组存储城市编码信息以及台站信息
|
||||
List<StationTree> stationTreeList = new LinkedList<>();
|
||||
//查询台站信息接口
|
||||
HashMap<String, Object> stationMap = (HashMap<String, Object>)redisUtil.get("stationInfoMap");
|
||||
if (CollectionUtils.isNotEmpty(stationMap)){
|
||||
HashMap<String, Object> stationMap = (HashMap<String, Object>) redisUtil.get("stationInfoMap");
|
||||
if (CollectionUtils.isNotEmpty(stationMap)) {
|
||||
//遍历台站信息存储进数组
|
||||
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();
|
||||
gardsStationsList.add(entryValue);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(gardsStationsList)){
|
||||
if (CollectionUtils.isNotEmpty(gardsStationsList)) {
|
||||
//过滤出所有的台站城市编码
|
||||
List<Object> 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<Object> 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<Object> 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<GardsStations> 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<GardsStations> 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);
|
||||
|
@ -242,26 +242,26 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
result.error500("Please pass in radius");
|
||||
}
|
||||
try {
|
||||
if (CollectionUtils.isNotEmpty(stationIds)){
|
||||
if (CollectionUtils.isNotEmpty(stationIds)) {
|
||||
//查询全部台站信息
|
||||
HashMap<String, Object> stationInfoMap = (HashMap<String, Object>) redisUtil.get("stationInfoMap");
|
||||
//查询全部核设施信息
|
||||
HashMap<String, GardsNuclearfacility> nuclearFacilityMap = (HashMap<String, GardsNuclearfacility>) redisUtil.get("nuclearFacilityMap");
|
||||
if (CollectionUtils.isNotEmpty(nuclearFacilityMap)){
|
||||
if (CollectionUtils.isNotEmpty(nuclearFacilityMap)) {
|
||||
//声明一个集合存储转换经纬度后的核设施数据
|
||||
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();
|
||||
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);
|
||||
}
|
||||
|
@ -269,8 +269,8 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
facilityInfoValue.setLongitude(lon);
|
||||
nuclearPoints.add(point);
|
||||
}
|
||||
for (String stationId:stationIds) {
|
||||
GardsStations point = (GardsStations)stationInfoMap.get(stationId);
|
||||
for (String stationId : stationIds) {
|
||||
GardsStations point = (GardsStations) stationInfoMap.get(stationId);
|
||||
stationsList.add(point);
|
||||
//声明一个数组存储对应的核设施经纬度信息
|
||||
List<Point> nuclearFacilityPoints = deepCopy(nuclearPoints);
|
||||
|
@ -296,34 +296,34 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
Rectangle rectangle = getRectangle(radius, longitudeD, latitudeD);
|
||||
// 2.获取位置在正方形内的所有设备 判断核设施的经纬度是否为空 不为空 判断经纬度是否在正方形的最大最小范围内 如果在则过滤出来继续使用否则弃用
|
||||
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.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);
|
||||
}
|
||||
}
|
||||
|
@ -396,8 +396,8 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
//调用接口获取数据库中对应缓存配置信息默认值
|
||||
if (Objects.isNull(cacheTime) || cacheTime <= 0) {
|
||||
List<Map<String, String>> 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));
|
||||
}
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
//根据缓存日期 得到开始查询时间
|
||||
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<>();
|
||||
if (CollectionUtils.isNotEmpty(stationDataMap)) {
|
||||
|
@ -417,12 +417,12 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
//读取探测器的数据集合
|
||||
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();
|
||||
//遍历探测器数组
|
||||
for (Map<String, DetectorData> detectorDataMap:detectorValue) {
|
||||
for (String key :detectorDataMap.keySet()) {
|
||||
for (Map<String, DetectorData> detectorDataMap : detectorValue) {
|
||||
for (String key : detectorDataMap.keySet()) {
|
||||
DetectorData detectorData = detectorDataMap.get(key);
|
||||
List<DataInfoVo> dataList = detectorData.getDataList();
|
||||
//通过流过滤出数据的开始时间戳在用户统计的开始时间戳之后的数据
|
||||
|
@ -450,18 +450,18 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
}
|
||||
stationIds = stationIds.stream().distinct().collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(stationIds)) {
|
||||
for (String stationId:stationIds) {
|
||||
for (String stationId : stationIds) {
|
||||
StationData stationData = stationDataMap.get(stationId);
|
||||
if (Objects.nonNull(stationData)) {
|
||||
//读取探测器的数据集合
|
||||
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();
|
||||
//遍历探测器数组
|
||||
for (Map<String, DetectorData> detectorDataMap:detectorValue) {
|
||||
for (String key :detectorDataMap.keySet()) {
|
||||
for (Map<String, DetectorData> detectorDataMap : detectorValue) {
|
||||
for (String key : detectorDataMap.keySet()) {
|
||||
DetectorData detectorData = detectorDataMap.get(key);
|
||||
List<DataInfoVo> dataList = detectorData.getDataList();
|
||||
//通过流过滤出数据的开始时间戳在用户统计的开始时间戳之后的数据
|
||||
|
@ -499,7 +499,7 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
result.error500("Station Code cannot be null");
|
||||
return result;
|
||||
}
|
||||
if (Objects.isNull(startDate)){
|
||||
if (Objects.isNull(startDate)) {
|
||||
result.error500("The start time cannot be empty");
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user