风速廓线查询;调整预警信号查询时间范围

refactor
shiyi 8 months ago
parent 17a35e9ab2
commit 0e9ce60318

@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.htfp.weather.download.gfs.GfsDataConfig;
import com.htfp.weather.utils.JSONUtils;
import com.htfp.weather.utils.MeteoUtils;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
@ -18,6 +19,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.NoSuchFileException;
import java.util.Arrays;
import java.util.List;
@Data @Component @Slf4j
@ -51,6 +53,7 @@ public class TableConfig {
public double[] latList;
@JsonIgnore
public int[] pressureList;
public int[] pressureHeightList;
@JsonIgnore
public int[] heightList;
// @JsonIgnore
@ -136,6 +139,8 @@ public class TableConfig {
private void initLevList() {
pressureList = dataConfig.getPressureLevels();
// NOTE 2024/7/4: 气压对应的海拔高度,注意不是离地高度
pressureHeightList = Arrays.stream(pressureList).map(x-> (int) MeteoUtils.pressure2Elevation(x)).toArray();
heightList = dataConfig.getHeightLevels();
// this.levSize = Math.max(pressureList.length, heightList.length);
}

@ -33,7 +33,7 @@ import java.util.stream.Collectors;
/**
* @Author : shiyi
* @Date : 2024/1/22 13:53
* @Description :
* @Description : ,
*/
@Slf4j @Component
@DependsOn({"tableStoreConf", "tableConfig"})
@ -132,14 +132,15 @@ public class GfsDataFetcher extends BaseTableOperation {
}
/**
*
* @param variable
* @param iLat
* @param iLon
* @return {@link Array}
*
* @param variableNameList
* @param targetTime
* @param latitude
* @param longitude
* @return {@link GridDataSet}
* @throws Exception
*/
public Array getProfileByVariableAndPressure(String variableName, OffsetDateTime targetTime, double latitude, double longitude) throws Exception {
public GridDataSet getProfileByPressure(List<String> variableNameList, OffsetDateTime targetTime, double latitude, double longitude) throws Exception {
lastGridDataSetMeta = getLastGridDataSetMeta();
GridDataFetcher fetcher = tableStoreGrid.getDataFetcher(lastGridDataSetMeta);
int iTime = getTargetTimeIndex(targetTime);
@ -148,25 +149,27 @@ public class GfsDataFetcher extends BaseTableOperation {
int[] origin = new int[]{iTime, 0, iLat, iLon};
int[] shape = new int[]{1,tableConfig.levSize, 1, 1};
// TODO 2024/6/17:
fetcher.setVariablesToGet(Collections.singletonList(variableName));
fetcher.setVariablesToGet(variableNameList);
fetcher.setOriginShape(origin, shape);
GridDataSet gridDataSet = fetcher.fetch();
Array array = gridDataSet.getVariable(variableName).toArray();
return array;
return fetcher.fetch();
}
public GridDataSet getProfileByPressure(List<String> variableNameList, OffsetDateTime targetTime, double latitude, double longitude) throws Exception {
/**获取变量随近地面高度的分布(目前只针对风速风向)*/
public GridDataSet getProfileByNearSurfaceHeight(List<String> variableNameList, OffsetDateTime targetTime, double latitude, double longitude) throws Exception {
lastGridDataSetMeta = getLastGridDataSetMeta();
GridDataFetcher fetcher = tableStoreGrid.getDataFetcher(lastGridDataSetMeta);
int iTime = getTargetTimeIndex(targetTime);
int iLat= getLatitudeIndex(latitude);
int iLon = getLongitudeIndex(longitude);
int[] origin = new int[]{iTime, 0, iLat, iLon};
int[] shape = new int[]{1,tableConfig.levSize, 1, 1};
//TODO NOTE 2024/7/4: 目前仅有风速支持近地面多个高度, 且只有102030405080100这7个高度2m高度只针对temp和humiditync文件本身高度坐标就有很多种难以统一到数据库中
int[] shape = new int[]{1,tableConfig.heightList.length - 1, 1, 1}; // heightList.length - 1 去掉2m高度
// TODO 2024/6/17:
fetcher.setVariablesToGet(variableNameList);
fetcher.setOriginShape(origin, shape);
return fetcher.fetch();
}
/**
*
* @param dataSetId ID

@ -78,13 +78,16 @@ public class MeteoUtils {
}
}
// public static double pressure2Height(double pressure) {
//
// }
//
// public static double height2Pressure(double pressure) {
//
// }
/**
*
* @param currentPressure hPa
* @return
*/
public static double pressure2Elevation(double currentPressure) {
double referencePressure = 101.325; // 参考大气压单位kPa
return 44330 * (1 - Math.pow(currentPressure/10. / referencePressure, 1 / 5.255));
}
/**
* @param array (kg/m^2/s)
* @return mm/h

@ -37,11 +37,14 @@ public class SurfaceWeatherController {
double lat = position2D.getLatitude();
double lon = position2D.getLongitude();
log.info("[data-server] 地面实时气象信息查询 start: param={}", position2D);
NowWeatherStatus nowWeatherStatus = surfaceDataService.getNowSurfaceWeatherStatus(lat, lon);
nowWeatherStatus.setLatitude(lat);
nowWeatherStatus.setLongitude(lon);
log.info("[data-server] 地面实时气象信息查询 end");
return Result.success(nowWeatherStatus);
try {
NowWeatherStatus nowWeatherStatus = surfaceDataService.getNowSurfaceWeatherStatus(lat, lon);
nowWeatherStatus.setLatitude(lat);
nowWeatherStatus.setLongitude(lon);
return Result.success(nowWeatherStatus);
} finally {
log.info("[data-server] 地面实时气象信息查询 end");
}
}
@PostMapping("/querySurfaceForecast")
@ -49,11 +52,14 @@ public class SurfaceWeatherController {
double lat = position2D.getLatitude();
double lon = position2D.getLongitude();
log.info("[data-server] 地面24小时预报结果查询 start: param={}", position2D);
TimeSeriesDataset forecastSeries = surfaceDataService.getForecastSeries(lat, lon);
forecastSeries.setLatitude(lat);
forecastSeries.setLongitude(lon);
log.info("[data-server] 地面24小时预报结果查询");
return Result.success(forecastSeries);
try {
TimeSeriesDataset forecastSeries = surfaceDataService.getForecastSeries(lat, lon);
forecastSeries.setLatitude(lat);
forecastSeries.setLongitude(lon);
return Result.success(forecastSeries);
} finally {
log.info("[data-server] 地面24小时预报结果查询");
}
}
@PostMapping ("/queryWeatherWarning")
@ -61,10 +67,13 @@ public class SurfaceWeatherController {
double lat = position2D.getLatitude();
double lon = position2D.getLongitude();
log.info("[data-server] 地面气象预警信息查询 start: param={}", position2D);
// List<SurfaceWeatherWarning> warning = surfaceDataService.getSurfaceWarning(lat, lon);
List<SurfaceWeatherWarning> warning = cmaService.getSurfaceWarning(lat, lon);
log.info("[data-server] 地面气象预警信息查询 end");
return Result.success(warning);
try {
// List<SurfaceWeatherWarning> warning = surfaceDataService.getSurfaceWarning(lat, lon);
List<SurfaceWeatherWarning> warning = cmaService.getSurfaceWarning(lat, lon);
return Result.success(warning);
} finally {
log.info("[data-server] 地面气象预警信息查询 end");
}
}
}

@ -101,10 +101,13 @@ public class UpperWeatherController {
String variableName = profileRequest.getVariableName();
double latitude = profileRequest.getLatitude();
double longitude = profileRequest.getLongitude();
log.info("[data-server] 高度廓线查询 start: param={}", profileRequest);
ProfileResponse profileResponse = gfsDataService.getProfileByVariableAndPressure(variableName, utcDateTime, latitude, longitude);
log.info("[data-server] 高度廓线查询 end");
return Result.success(profileResponse);
try {
log.info("[data-server] 高度廓线(气压坐标)查询 start: param={}", profileRequest);
ProfileResponse profileResponse = gfsDataService.getProfileByVariableAndPressure(variableName, utcDateTime, latitude, longitude);
return Result.success(profileResponse);
} finally {
log.info("[data-server] 高度廓线(气压坐标)查询 end");
}
}
/**查询全部变量随气压的分布*/
@ -114,12 +117,45 @@ public class UpperWeatherController {
OffsetDateTime utcDateTime = DateTimeUtils.getUTCDateTime(time);
double latitude = profileRequest.getLatitude();
double longitude = profileRequest.getLongitude();
log.info("[data-server] 高度廓线查询 start: param={}", profileRequest);
ProfileDataset profile = gfsDataService.getProfileByPressure(utcDateTime, latitude, longitude);
log.info("[data-server] 高度廓线查询 end");
return Result.success(profile);
try {
log.info("[data-server] 高度廓线(气压坐标)查询 start: param={}", profileRequest);
ProfileDataset profile = gfsDataService.getProfileByPressure(utcDateTime, latitude, longitude);
return Result.success(profile);
} finally {
log.info("[data-server] 高度廓线(气压坐标)查询 end");
}
}
/**查询全部近地面变量随高度的分布*/
@RequestMapping("/queryProfileByVariableAndNearSurfaceHeight")
public Result queryProfileByVariableAndNearSurfaceHeight(@Validated @RequestBody ProfileRequest profileRequest) {
OffsetDateTime time = OffsetDateTime.parse(profileRequest.getTime());
OffsetDateTime utcDateTime = DateTimeUtils.getUTCDateTime(time);
String variableName = profileRequest.getVariableName();
double latitude = profileRequest.getLatitude();
double longitude = profileRequest.getLongitude();
try {
log.info("[data-server] 高度廓线(近地面高度坐标)查询 start: param={}", profileRequest);
ProfileResponse profile = gfsDataService.getProfileByVariableAndNearSurfaceHeight(variableName, utcDateTime, latitude, longitude);
return Result.success(profile);
} finally {
log.info("[data-server] 高度廓线(近地面高度坐标)查询 end");
}
}
/**查询全部近地面变量随高度的分布*/
@RequestMapping("/queryProfileByNearSurfaceHeight")
public Result queryProfileByNearSurfaceHeight(@Validated @RequestBody ProfileRequest profileRequest) {
OffsetDateTime time = OffsetDateTime.parse(profileRequest.getTime());
OffsetDateTime utcDateTime = DateTimeUtils.getUTCDateTime(time);
double latitude = profileRequest.getLatitude();
double longitude = profileRequest.getLongitude();
try {
log.info("[data-server] 高度廓线(近地面高度坐标)查询 start: param={}", profileRequest);
ProfileDataset profile = gfsDataService.getProfileByNearSurfaceHeight(utcDateTime, latitude, longitude);
return Result.success(profile);
} finally {
log.info("[data-server] 高度廓线(近地面高度坐标)查询 end");
}
}
@PostMapping("/queryPlaneGrid")
public Result queryPlaneGrid(@Validated @RequestBody PlaneRequest planeRequest) {
planeRequest.valid();

@ -1,9 +1,10 @@
package com.htfp.weather.web.pojo.cma;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
@Data @JsonIgnoreProperties(ignoreUnknown = true)
public class AddressComponent {
private String address;
@ -29,4 +30,5 @@ public class AddressComponent {
private int poiDistance;
@JsonProperty("address_distance")
private int addressDistance;
private String info;
}

@ -1,7 +1,9 @@
package com.htfp.weather.web.pojo.request;
import com.htfp.weather.download.gfs.GfsVariableIsobaricEnum;
import com.htfp.weather.info.Constant;
import com.htfp.weather.web.valid.DateTimeStr;
import com.htfp.weather.web.valid.EnumValid;
import lombok.Data;
import javax.validation.constraints.Max;
@ -18,7 +20,7 @@ public class ProfileRequest {
@NotNull(message = "时间不能为空")
@DateTimeStr(message = "时间格式错误")
String time;
@EnumValid(enumClass = GfsVariableIsobaricEnum.class, usedField = "getNameInApi", message = "变量不存在")
String variableName;
@NotNull(message = "纬度 (latitude) 不能为空")

@ -1,9 +0,0 @@
package com.htfp.weather.web.pojo.response;
/**
* @Author : shiyi
* @Date : 2024/6/6 15:24
* @Description :
*/
public class MultiPointResponse {
}

@ -1,5 +1,6 @@
package com.htfp.weather.web.pojo.response;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
/**
@ -7,7 +8,7 @@ import lombok.Data;
* @Date : 2024/1/24 11:28
* @Description :
*/
@Data
@Data @JsonInclude(JsonInclude.Include.NON_NULL)
public class NowWeatherStatus {
String time; // 数据时间,北京时
String weatherText; // 天气状况

@ -1,5 +1,7 @@
package com.htfp.weather.web.pojo.response;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.util.ArrayList;
@ -9,10 +11,10 @@ import java.util.ArrayList;
* @Date : 2024/5/8 15:19
* @Description : 线
*/
@Data
@Data @JsonInclude(JsonInclude.Include.NON_NULL)
public class ProfileDataset {
int[] pressureLevels;
// int[ pressureHeight;
int[] heightLevel;
double latitude;
double longitude;
float[] temp;

@ -1,5 +1,6 @@
package com.htfp.weather.web.pojo.response;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.Getter;
@ -8,17 +9,11 @@ import lombok.Getter;
* @Date : 2024/5/8 15:19
* @Description : 线
*/
@Data
@Data @JsonInclude(JsonInclude.Include.NON_NULL)
public class ProfileResponse {
int[] pressureLevels;
// int[ pressureHeight;
int[] heightLevels;
double latitude;
double longitude;
float[] values;
public ProfileResponse(int[] pressureLevels, float[] values) {
this.pressureLevels = pressureLevels;
// this.pressureHeight = pressureHeight;
this.values = values;
}
}

@ -1,6 +1,7 @@
package com.htfp.weather.web.pojo.response;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
/**
@ -8,7 +9,7 @@ import lombok.Data;
* @Date : 2024/4/17 15:44
* @Description :
*/
@Data
@Data @JsonInclude(JsonInclude.Include.NON_NULL)
public class SurfaceWeatherWarning {
String pubTime;
String endTime;

@ -1,17 +0,0 @@
package com.htfp.weather.web.pojo.response;
import lombok.Data;
import java.util.List;
/**
* @Author : shiyi
* @Date : 2024/1/24 13:38
* @Description :
*/
@Data
public class TimeSeries <T> {
String name;
List<String> time;
List<T> values;
}

@ -1,5 +1,6 @@
package com.htfp.weather.web.pojo.response;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.sql.Time;
@ -11,7 +12,7 @@ import java.util.List;
* @Date : 2024/1/24 13:46
* @Description :
*/
@Data
@Data @JsonInclude(JsonInclude.Include.NON_NULL)
public class TimeSeriesDataset {
List<String> time;
Double latitude;

@ -20,7 +20,7 @@ import com.htfp.weather.web.exception.AppException;
import com.htfp.weather.web.exception.ErrorCode;
import com.htfp.weather.web.pojo.response.*;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.checkerframework.checker.units.qual.A;
import org.springframework.stereotype.Service;
import ucar.ma2.Array;
import ucar.ma2.Index4D;
@ -125,8 +125,10 @@ public class GfsDataServiceImpl implements IDataService {
nowWeatherStatus.setLatitude(latitude);
nowWeatherStatus.setLongitude(longitude);
return nowWeatherStatus;
} catch (Exception e) {
throw new RuntimeException(e);
} catch (AppException e) {
throw e;
}catch (Exception e) {
throw new AppException(ErrorCode.TABLESTORE_QUERY_ERROR, e.getMessage());
}
}
@ -162,8 +164,10 @@ public class GfsDataServiceImpl implements IDataService {
nowWeatherStatusList.add(nowWeatherStatus);
}
return nowWeatherStatusList;
} catch (Exception e) {
throw new RuntimeException(e);
} catch (AppException e) {
throw e;
}catch (Exception e) {
throw new AppException(ErrorCode.TABLESTORE_QUERY_ERROR, e.getMessage());
}
}
@ -189,8 +193,10 @@ public class GfsDataServiceImpl implements IDataService {
);
final GfsLevelsEnum levelFlag = GfsLevelsEnum.getByCode(level);
return buildTimeSeriesDatasetInTargetPoint(gridDataSet, level, latitude, longitude, levelFlag);
} catch (Exception e) {
throw new RuntimeException(e);
} catch (AppException e) {
throw e;
}catch (Exception e) {
throw new AppException(ErrorCode.TABLESTORE_QUERY_ERROR, e.getMessage());
}
}
@ -223,8 +229,10 @@ public class GfsDataServiceImpl implements IDataService {
timeSeriesDatasetList.add(timeSeriesDataset);
}
return timeSeriesDatasetList;
} catch (Exception e) {
throw new RuntimeException(e);
} catch (AppException e) {
throw e;
}catch (Exception e) {
throw new AppException(ErrorCode.TABLESTORE_QUERY_ERROR, e.getMessage());
}
}
@ -243,22 +251,29 @@ public class GfsDataServiceImpl implements IDataService {
throw new AppException(ErrorCode.VALIDATE_ERROR, variableName + "变量在数据库中不存在");
}
try {
int[] pressureLevels = tableConfig.getPressureList();
Array array = gfsDataFetcher.getProfileByVariableAndPressure(targetVariable, targetTime, latitude, longitude);
float[] values = (float[]) array.copyTo1DJavaArray();
ProfileResponse profileResponse = new ProfileResponse(pressureLevels, values);
GridDataSet gridDataSet = gfsDataFetcher.getProfileByPressure(Collections.singletonList(targetVariable), targetTime, latitude, longitude);
float[] values = (float[]) gridDataSet.getVariables().get(targetVariable).toArray().copyTo1DJavaArray();
ProfileResponse profileResponse = new ProfileResponse();
profileResponse.setPressureLevels(tableConfig.getPressureList());
profileResponse.setHeightLevels(tableConfig.getPressureHeightList());
profileResponse.setValues(values);
profileResponse.setLatitude(latitude);
profileResponse.setLongitude(longitude);
return profileResponse;
} catch (Exception e) {
} catch (AppException e) {
throw e;
}catch (Exception e) {
throw new AppException(ErrorCode.TABLESTORE_QUERY_ERROR, e.getMessage());
}
}
/** 获取全部变量随气压变化的廓线 (推荐) */
public ProfileDataset getProfileByPressure(OffsetDateTime targetTime, double latitude, double longitude) {
try {
List<String> variableNames = getVariableNamesInDatabase(GfsLevelsEnum.UPPER.getCode());
GfsLevelsEnum levelFlag = GfsLevelsEnum.UPPER;
List<String> variableNames = getVariableNamesInDatabase(levelFlag.getCode());
GridDataSet gridDataSet = gfsDataFetcher.getProfileByPressure(variableNames, targetTime, latitude, longitude);
ProfileDataset profile = buildProfileDataset(gridDataSet, GfsLevelsEnum.UPPER);
ProfileDataset profile = buildProfileDataset(gridDataSet, levelFlag);
profile.setLatitude(latitude);
profile.setLongitude(longitude);
return profile;
@ -269,6 +284,48 @@ public class GfsDataServiceImpl implements IDataService {
}
}
/** 获取指定变量随高度变化的廓线, 目前只支持风速风向*/
public ProfileResponse getProfileByVariableAndNearSurfaceHeight(String variableName, OffsetDateTime targetTime, double latitude, double longitude) {
String targetVariable = GfsVariableHeightEnum.getGfsVariableName(variableName);
if (targetVariable == null) {
throw new AppException(ErrorCode.VALIDATE_ERROR, variableName + "变量在数据库中不存在");
}
try {
int[] heightLevels = tableConfig.getHeightList();
GridDataSet gridDataSet = gfsDataFetcher.getProfileByNearSurfaceHeight(Collections.singletonList(targetVariable), targetTime, latitude, longitude);
float[] values = (float[]) gridDataSet.getVariables().get(targetVariable).toArray().copyTo1DJavaArray();
ProfileResponse profileResponse = new ProfileResponse();
profileResponse.setValues(values);
profileResponse.setHeightLevels(Arrays.copyOfRange(heightLevels, 1, heightLevels.length));
profileResponse.setLatitude(latitude);
profileResponse.setLongitude(longitude);
return profileResponse;
} catch (AppException e) {
throw e;
}catch (Exception e) {
throw new AppException(ErrorCode.TABLESTORE_QUERY_ERROR, e.getMessage());
}
}
/** 获取全部变量随高度变化的廓线, 目前只支持风速风向*/
public ProfileDataset getProfileByNearSurfaceHeight(OffsetDateTime targetTime, double latitude, double longitude) {
try {
GfsLevelsEnum levelFlag = GfsLevelsEnum.SURFACE;
List<String> variableNames = new ArrayList<>();
variableNames.add(GfsVariableHeightEnum.getGfsVariableName("windSpeed"));
variableNames.add(GfsVariableHeightEnum.getGfsVariableName("wind360"));
GridDataSet gridDataSet = gfsDataFetcher.getProfileByNearSurfaceHeight(variableNames, targetTime, latitude, longitude);
ProfileDataset profile = buildProfileDataset(gridDataSet, levelFlag);
profile.setHeightLevel(Arrays.copyOfRange(tableConfig.getHeightList(), 1, tableConfig.getHeightList().length));
profile.setLatitude(latitude);
profile.setLongitude(longitude);
return profile;
} catch (AppException e) {
throw e;
} catch (Exception e) {
throw new AppException(ErrorCode.TABLESTORE_QUERY_ERROR, e.getMessage());
}
}
/**
*
@ -305,8 +362,10 @@ public class GfsDataServiceImpl implements IDataService {
variableNames, timeRange, levRange, latRange, lonRange
).getVariable(targetVariable).toArray();
return buildPlane(array, minLat, maxLat, minLon, maxLon);
} catch (Exception e) {
throw new RuntimeException(e);
} catch (AppException e) {
throw e;
}catch (Exception e) {
throw new AppException(ErrorCode.TABLESTORE_QUERY_ERROR, e.getMessage());
}
}
@ -499,7 +558,12 @@ public class GfsDataServiceImpl implements IDataService {
throw new AppException(ErrorCode.RESPONSE_DATA_BUILD_ERROR);
}
}
result.setPressureLevels(tableConfig.getPressureList());
if (levelFlag == GfsLevelsEnum.UPPER) {
result.setPressureLevels(tableConfig.getPressureList());
result.setHeightLevel(tableConfig.getPressureHeightList());
} else {
result.setHeightLevel(tableConfig.getHeightList());
}
return result;
}

@ -5,6 +5,7 @@ import com.htfp.weather.utils.DateTimeUtils;
import com.htfp.weather.utils.JSONUtils;
import com.htfp.weather.web.exception.AppException;
import com.htfp.weather.web.exception.ErrorCode;
import com.htfp.weather.web.pojo.cma.AddressComponent;
import com.htfp.weather.web.pojo.cma.AntiGeoCodeResponse;
import com.htfp.weather.web.pojo.cma.CmaWarning;
import com.htfp.weather.web.pojo.response.NowWeatherStatus;
@ -78,14 +79,17 @@ public class CmaServiceImpl implements ISurfaceDataService{
params.put("type", "geocode");
params.put("tk", keyOfTianDiTu);
AntiGeoCodeResponse antiGeoCodeResponse = sendGet(url, params, AntiGeoCodeResponse.class);
if (!"ok".equals(antiGeoCodeResponse.getMsg())) {
if (antiGeoCodeResponse.getResult() == null){
throw new AppException(ErrorCode.TIANDITU_REQUEST_ERROR, "获取行政区划信息失败:" + antiGeoCodeResponse.getMsg());
}
String countyCode = antiGeoCodeResponse.getResult().getAddressComponent().getCountyCode();
if (StringUtils.isNotEmpty(countyCode)) {
return countyCode.substring(countyCode.length()-6);
AddressComponent addressComponent = antiGeoCodeResponse.getResult().getAddressComponent();
String countyCode = addressComponent.getCountyCode();
if (StringUtils.isEmpty(countyCode)) {
String info;
info = addressComponent.getInfo();
throw new AppException(ErrorCode.TIANDITU_DATA_PARSE_ERROR, "获取行政区代码失败:" + info);
} else {
throw new AppException(ErrorCode.TIANDITU_DATA_PARSE_ERROR, "获取行政区代码失败:" + antiGeoCodeResponse.getMsg());
return countyCode.substring(countyCode.length()-6);
}
}
/**
@ -101,9 +105,9 @@ public class CmaServiceImpl implements ISurfaceDataService{
* @param countyCode */
public void updateCmaWarning(String countyCode) {
String url = "https://data.cma.cn/dataGis/disasterWarning/getWarningDataByCnty";
// 2小时前24小时后
OffsetDateTime startTime = DateTimeUtils.offsetDateTimeToSystemZone(OffsetDateTime.now()).minusHours(2);
OffsetDateTime endTime = startTime.plusHours(24);
// 6小时前12小时后
OffsetDateTime startTime = DateTimeUtils.offsetDateTimeToSystemZone(OffsetDateTime.now()).minusHours(6);
OffsetDateTime endTime = startTime.plusHours(12);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd+HH:mm:ss");
HashMap<String, String> params = new HashMap<>();
params.put("startTime", startTime.format(formatter));

@ -138,7 +138,9 @@ public class HeFengServiceImpl implements ISurfaceDataService {
for (int i = 0; i < hourly.size(); i++) {
HeFengForecastHour heFengForecastHour = hourly.get(i);
processHeFengData(heFengForecastHour);
timeSeriesDataset.getTime().add(heFengForecastHour.getFxTime());
timeSeriesDataset.getTime().add(
DateTimeUtils.offsetDateTimeToSystemZone(OffsetDateTime.parse(heFengForecastHour.getFxTime())).format(Constant.API_TIME_FORMATTER)
);
timeSeriesDataset.getTemp()[i] = heFengForecastHour.getTemp();
timeSeriesDataset.getWindSpeed()[i] = heFengForecastHour.getWindSpeed();
timeSeriesDataset.getWind360()[i] = heFengForecastHour.getWind360();

Loading…
Cancel
Save