fix:1.修改播放数据返回格式
This commit is contained in:
parent
56afd228bb
commit
e3fe064509
|
|
@ -72,17 +72,25 @@ public class CacheWeatherDataJob extends Thread {
|
|||
startTime = startTime.plusHours(6);
|
||||
}
|
||||
}
|
||||
LambdaQueryWrapper<WeatherData> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(WeatherData::getDataSource,this.dataType);
|
||||
queryWrapper.eq(StrUtil.isNotBlank(timeBatch),WeatherData::getTimeBatch,timeBatch);
|
||||
queryWrapper.eq(WeatherData::getDataStartTime,startTime);
|
||||
WeatherData weatherData = weatherDataService.getOne(queryWrapper);
|
||||
if(Objects.nonNull(weatherData)){
|
||||
weatherResultVO = weatherDataService.processWeatherData(weatherTypeEnum.getKey(),weatherData);
|
||||
if(Objects.nonNull(weatherResultVO)){
|
||||
String time = startTime.format(DateTimeFormatter.ofPattern("yyyyMMddHH"));
|
||||
WeatherDataSourceEnum dataSourceEnum = WeatherDataSourceEnum.getInfoByKey(dataType);
|
||||
this.writeWeatherJson(cacheVariablePath,time,timeBatch,dataSourceEnum.getValue(),weatherTypeEnum.getValue(),JSONObject.toJSONString(weatherResultVO));
|
||||
WeatherDataSourceEnum dataSourceEnum = WeatherDataSourceEnum.getInfoByKey(dataType);
|
||||
Path directory = Paths.get(cacheVariablePath).resolve(dataSourceEnum.getValue()).resolve(weatherTypeEnum.getValue());
|
||||
if(StrUtil.isNotBlank(timeBatch)){
|
||||
directory = directory.resolve(timeBatch);
|
||||
}
|
||||
Files.createDirectories(directory);
|
||||
String time = startTime.format(DateTimeFormatter.ofPattern("yyyyMMddHH"));
|
||||
Path target = directory.resolve(time + ".json.gz");
|
||||
if(!Files.exists(target)){
|
||||
LambdaQueryWrapper<WeatherData> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(WeatherData::getDataSource,this.dataType);
|
||||
queryWrapper.eq(StrUtil.isNotBlank(timeBatch),WeatherData::getTimeBatch,timeBatch);
|
||||
queryWrapper.eq(WeatherData::getDataStartTime,startTime);
|
||||
WeatherData weatherData = weatherDataService.getOne(queryWrapper);
|
||||
if(Objects.nonNull(weatherData)){
|
||||
weatherResultVO = weatherDataService.processWeatherData(weatherTypeEnum.getKey(),weatherData);
|
||||
if(Objects.nonNull(weatherResultVO)){
|
||||
this.writeWeatherJson(target,directory,time,JSONObject.toJSONString(weatherResultVO));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -95,34 +103,18 @@ public class CacheWeatherDataJob extends Thread {
|
|||
|
||||
/**
|
||||
* 把气象数据生成json文件
|
||||
* @param cacheVariablePath
|
||||
* @param time
|
||||
* @param timeBatch
|
||||
* @param dataType
|
||||
* @param variable
|
||||
* @param target
|
||||
* @param directory
|
||||
* @param json
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeWeatherJson(
|
||||
String cacheVariablePath,
|
||||
Path target,
|
||||
Path directory,
|
||||
String time,
|
||||
String timeBatch,
|
||||
String dataType,
|
||||
String variable,
|
||||
String json) throws IOException {
|
||||
|
||||
if (!time.matches("\\d{10}")) {
|
||||
throw new IllegalArgumentException("时间必须为yyyyMMddHH格式");
|
||||
}
|
||||
Path directory = Paths.get(cacheVariablePath).resolve(dataType).resolve(variable);
|
||||
if(StrUtil.isNotBlank(timeBatch)){
|
||||
directory = directory.resolve(timeBatch);
|
||||
}
|
||||
Files.createDirectories(directory);
|
||||
|
||||
Path target = directory.resolve(time + ".json.gz");
|
||||
Path temporary = directory.resolve(time + ".json.gz.tmp");
|
||||
|
||||
try (OutputStream output = Files.newOutputStream(temporary);
|
||||
GZIPOutputStream gzip = new GZIPOutputStream(output)) {
|
||||
gzip.write(json.getBytes(StandardCharsets.UTF_8));
|
||||
|
|
|
|||
|
|
@ -74,10 +74,7 @@ public class WeatherDataServiceImpl extends ServiceImpl<WeatherDataMapper, Weath
|
|||
String time = startTime.format(DateTimeFormatter.ofPattern("yyyyMMddHH"));
|
||||
Path targetFile = directory.resolve(time + ".json.gz");
|
||||
if (!Files.exists(targetFile)) {
|
||||
res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
res.setContentType("text/plain;charset=UTF-8");
|
||||
res.getWriter().write(time+"气象数据不存在");
|
||||
res.flushBuffer();
|
||||
throw new RuntimeException(time+"气象数据不存在");
|
||||
}else {
|
||||
long fileSize = Files.size(targetFile);
|
||||
res.setStatus(HttpServletResponse.SC_OK);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.jeecg.vo;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -18,7 +19,9 @@ public class WeatherResultVO {
|
|||
private double minLong;
|
||||
private int sn;
|
||||
private int we;
|
||||
@JSONField(name = "xspeed")
|
||||
private double xSpeed ;
|
||||
@JSONField(name = "yspeed")
|
||||
private double ySpeed;
|
||||
private List<List<Double>> dataList;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user