fix:
1.修改天气预报删除接口逻辑,删除任务日志数据及上传的临时数据 2.修改输运模拟任务删除逻辑,删除子表及结果数据 3.按要求编写输运模拟任务导入功能
This commit is contained in:
parent
2a8c763b58
commit
16c8ef3d34
|
|
@ -9,12 +9,94 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
public enum T1hFilePrefixEnum {
|
||||
|
||||
|
||||
T2MZ(0, "t2mz"), //2米气温
|
||||
PSZ(1, "psz"), //地表气压
|
||||
RH2M(2, "rh2m"), //2米相对湿度
|
||||
VGRD10M(3, "VGRD10m"), //10米经向风
|
||||
UGRD10M(4, "UGRD10m"); //10米纬向风
|
||||
UGRD10M(4, "UGRD10m"), //10米纬向风
|
||||
U50M(5, "u50m"),
|
||||
U100M(6, "u100m"),
|
||||
V50M(7, "v50m"),
|
||||
V100M(8, "v100m"),
|
||||
H50(9, "h50"),//X百帕等压面相对于平均海平面的位势高度。单位为m
|
||||
H100(10, "h100"),
|
||||
H150(11, "h150"),
|
||||
H200(12, "h200"),
|
||||
H250(13, "h250"),
|
||||
H300(14, "h300"),
|
||||
H400(15, "h400"),
|
||||
H500(16, "h500"),
|
||||
H600(17, "h600"),
|
||||
H700(18, "h700"),
|
||||
H850(19, "h850"),
|
||||
H925(20, "h925"),
|
||||
H1000(21, "h1000"),
|
||||
OMG50(22, "omg50"),//在 X 百帕气压层中,空气微团在垂直方向的运动速度,垂直速度为正值时,表示空气向下运动(下沉气流);为负值时,表示空气向上运动(上升气流)。单位为Pa/s
|
||||
OMG100(23, "omg100"),
|
||||
OMG150(24, "omg150"),
|
||||
OMG200(25, "omg200"),
|
||||
OMG250(26, "omg250"),
|
||||
OMG300(27, "omg300"),
|
||||
OMG400(28, "omg400"),
|
||||
OMG500(29, "omg500"),
|
||||
OMG600(30, "omg600"),
|
||||
OMG700(31, "omg700"),
|
||||
OMG850(32, "omg850"),
|
||||
OMG925(33, "omg925"),
|
||||
OMG1000(34, "omg1000"),
|
||||
RH50(35, "rh50"),//在 X 百帕气压层中,空气实际水汽压与同温度下饱和水汽压的比值。单位为%
|
||||
RH100(36, "rh100"),
|
||||
RH150(37, "rh150"),
|
||||
RH200(38, "rh200"),
|
||||
RH250(39, "rh250"),
|
||||
RH300(40, "rh300"),
|
||||
RH400(41, "rh400"),
|
||||
RH500(42, "rh500"),
|
||||
RH600(43, "rh600"),
|
||||
RH700(44, "rh700"),
|
||||
RH850(45, "rh850"),
|
||||
RH925(46, "rh925"),
|
||||
RH1000(47, "rh1000"),
|
||||
T50(48,"t50"),//在 50 百帕气压层高度处的空气温度。单位为K
|
||||
T100(49,"t100"),
|
||||
T150(50,"t150"),
|
||||
T200(51,"t200"),
|
||||
T250(52,"t250"),
|
||||
T300(53,"t300"),
|
||||
T400(54,"t400"),
|
||||
T500(55,"t500"),
|
||||
T600(56,"t600"),
|
||||
T700(57,"t700"),
|
||||
T850(58,"t850"),
|
||||
T925(59,"t925"),
|
||||
T1000(60,"t1000"),
|
||||
U50(61,"u50"),//在 X 百帕气压层中,空气沿纬圈方向(东西方向)的运动速度分量,正值表示西风(气流自西向东运动),负值表示东风(气流自东向西运动)。单位为m/s
|
||||
U100(62,"u100"),
|
||||
U150(63,"u150"),
|
||||
U200(64,"u200"),
|
||||
U250(65,"u250"),
|
||||
U300(66,"u300"),
|
||||
U400(67,"u400"),
|
||||
U500(68,"u500"),
|
||||
U600(69,"u600"),
|
||||
U700(70,"u700"),
|
||||
U850(80,"u850"),
|
||||
U925(90,"u925"),
|
||||
U1000(91,"u1000"),
|
||||
V50(92,"v50"),//在 X 百帕气压层中,空气沿经圈方向(南北方向)的运动速度分量,正值表示南风(气流自南向北运动),负值表示北风(气流自北向南运动)。单位为m/s
|
||||
V100(93,"v100"),
|
||||
V150(94,"v150"),
|
||||
V200(95,"v200"),
|
||||
V250(96,"v250"),
|
||||
V300(97,"v300"),
|
||||
V400(98,"v400"),
|
||||
V500(99,"v500"),
|
||||
V600(100,"v600"),
|
||||
V700(101,"v700"),
|
||||
V850(120,"v850"),
|
||||
V925(130,"v925"),
|
||||
V1000(140,"v1000");
|
||||
|
||||
|
||||
private Integer key;
|
||||
|
||||
|
|
|
|||
|
|
@ -128,5 +128,13 @@ public class TransportSimulationProperties {
|
|||
* 反演脚本路径(和T1H气象数据有关系)
|
||||
*/
|
||||
private String t1hBackwardScriptPath;
|
||||
/**
|
||||
* 正演文件路径
|
||||
*/
|
||||
private String forwardTemplatePath;
|
||||
/**
|
||||
* 反演文件路径
|
||||
*/
|
||||
private String backwardTemplatePath;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,14 @@ package org.jeecg.controller;
|
|||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.constant.enums.TransportTaskModeEnum;
|
||||
import org.jeecg.common.properties.TransportSimulationProperties;
|
||||
import org.jeecg.common.system.query.PageRequest;
|
||||
import org.jeecg.common.validgroup.InsertGroup;
|
||||
import org.jeecg.common.validgroup.UpdateGroup;
|
||||
|
|
@ -14,10 +18,16 @@ import org.jeecg.service.TransportTaskService;
|
|||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.time.LocalDate;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Validated
|
||||
@RestController
|
||||
@RequestMapping("transportTask")
|
||||
|
|
@ -25,6 +35,7 @@ import java.util.Map;
|
|||
public class TransportTaskController {
|
||||
|
||||
private final TransportTaskService transportTaskService;
|
||||
private final TransportSimulationProperties transportSimulationProperties;
|
||||
|
||||
@AutoLog(value = "分页查询输运任务数据")
|
||||
@Operation(summary = "分页查询输运任务数据")
|
||||
|
|
@ -84,4 +95,34 @@ public class TransportTaskController {
|
|||
transportTaskService.runTask(taskId);
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
@AutoLog(value = "下载任务模版")
|
||||
@Operation(summary = "下载任务模版")
|
||||
@GetMapping("downTemplate")
|
||||
public void downTemplate(@NotNull(message = "模式类型不能为空") Integer taskMode, HttpServletResponse response){
|
||||
File file = null;
|
||||
if (TransportTaskModeEnum.BACK_FORWARD.getKey().equals(taskMode)){
|
||||
file = new File(transportSimulationProperties.getBackwardTemplatePath());
|
||||
}else if (TransportTaskModeEnum.FORWARD.getKey().equals(taskMode)){
|
||||
file = new File(transportSimulationProperties.getForwardTemplatePath());
|
||||
}
|
||||
if (!file.exists()){
|
||||
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
try (InputStream inputStream = new FileInputStream(file);
|
||||
OutputStream outputStream = response.getOutputStream()) {
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(file.getName(), "UTF-8"));
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
byte[] buffer = new byte[2048];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
outputStream.flush();
|
||||
}catch (Exception e){
|
||||
log.error("下载模版异常,原因为:{}",e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package org.jeecg.common.properties;
|
||||
package org.jeecg.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package org.jeecg.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
|
@ -12,19 +13,21 @@ import org.jeecg.common.constant.enums.TransportTaskModeEnum;
|
|||
import org.jeecg.common.constant.enums.TransportTaskStatusEnum;
|
||||
import org.jeecg.common.constant.enums.TransportTaskTypeEnum;
|
||||
import org.jeecg.common.properties.DataFusionProperties;
|
||||
import org.jeecg.common.properties.ServerProperties;
|
||||
import org.jeecg.common.properties.SystemStorageProperties;
|
||||
import org.jeecg.common.properties.TransportSimulationProperties;
|
||||
import org.jeecg.common.system.query.PageRequest;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.modules.base.entity.*;
|
||||
import org.jeecg.modules.base.mapper.*;
|
||||
import org.jeecg.properties.ServerProperties;
|
||||
import org.jeecg.service.TransportTaskService;
|
||||
import org.jeecg.task.flexparttask.AbstractTaskExec;
|
||||
import org.jeecg.task.flexparttask.BackwardTaskExec;
|
||||
import org.jeecg.task.flexparttask.ForwardTaskExec;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
|
@ -269,9 +272,26 @@ public class TransportTaskServiceImpl extends ServiceImpl<TransportTaskMapper,Tr
|
|||
if (TransportTaskModeEnum.BACK_FORWARD.getKey().equals(transportTask.getTaskMode())) {
|
||||
LambdaQueryWrapper<TransportTaskBackwardChild> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(TransportTaskBackwardChild::getTaskId,id);
|
||||
taskBackwardChildMapper.delete(queryWrapper);
|
||||
this.taskBackwardChildMapper.delete(queryWrapper);
|
||||
}else if (TransportTaskModeEnum.FORWARD.getKey().equals(transportTask.getTaskMode())){
|
||||
//删除正演的站点配置数据
|
||||
LambdaQueryWrapper<TransportTaskForwardChild> childQueryWrapper = new LambdaQueryWrapper<>();
|
||||
childQueryWrapper.eq(TransportTaskForwardChild::getTaskId,id);
|
||||
this.taskForwardChildMapper.delete(childQueryWrapper);
|
||||
//删除正演的站点释放配置数据
|
||||
LambdaQueryWrapper<TransportTaskForwardRelease> releaseQueryWrapper = new LambdaQueryWrapper<>();
|
||||
releaseQueryWrapper.eq(TransportTaskForwardRelease::getTaskId,id);
|
||||
this.taskForwardReleaseMapper.delete(releaseQueryWrapper);
|
||||
//删除正演的站点物种配置数据
|
||||
LambdaQueryWrapper<TransportTaskForwardSpecies> speciesQueryWrapper = new LambdaQueryWrapper<>();
|
||||
speciesQueryWrapper.eq(TransportTaskForwardSpecies::getTaskId,id);
|
||||
this.taskForwardSpeciesMapper.delete(speciesQueryWrapper);
|
||||
}
|
||||
this.baseMapper.deleteById(id);
|
||||
File resultDir = new File(this.simulationProperties.getOutputPath()+ File.separator + transportTask.getTaskName());
|
||||
if (!resultDir.exists()) {
|
||||
FileUtil.del(resultDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ import lombok.Setter;
|
|||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.jeecg.common.constant.enums.WeatherDataSourceEnum;
|
||||
import org.jeecg.common.properties.DataFusionProperties;
|
||||
import org.jeecg.common.properties.ServerProperties;
|
||||
import org.jeecg.common.properties.SystemStorageProperties;
|
||||
import org.jeecg.common.properties.TransportSimulationProperties;
|
||||
import org.jeecg.modules.base.entity.TransportTask;
|
||||
import org.jeecg.modules.base.entity.TransportTaskBackwardChild;
|
||||
import org.jeecg.modules.base.mapper.WeatherDataMapper;
|
||||
import org.jeecg.properties.ServerProperties;
|
||||
import org.jeecg.service.TransportTaskService;
|
||||
|
||||
import java.io.*;
|
||||
|
|
@ -199,10 +199,6 @@ public abstract class AbstractTaskExec extends Thread{
|
|||
ProgressQueue.getInstance().offer(new ProgressEvent(transportTask.getId(),line));
|
||||
}
|
||||
}
|
||||
// // 等待脚本执行完成
|
||||
// while (channel.isConnected()) {
|
||||
// Thread.sleep(1000);
|
||||
// }
|
||||
}catch(JSchException |IOException e){
|
||||
throw new RuntimeException(e);
|
||||
}finally {
|
||||
|
|
|
|||
|
|
@ -488,18 +488,23 @@ public class WeatherDataServiceImpl extends ServiceImpl<WeatherDataMapper, Weath
|
|||
@Override
|
||||
public void delete(List<String> ids) {
|
||||
List<WeatherData> weatherDatas = this.baseMapper.selectByIds(ids);
|
||||
for(WeatherData weatherData : weatherDatas) {
|
||||
//删除气象文件和生成的.gbx9、.ncx2文件
|
||||
File dataFile = new File(weatherData.getFilePath());
|
||||
if(dataFile.exists()) {
|
||||
File[] files = dataFile.getParentFile().listFiles();
|
||||
for(File file : files) {
|
||||
if(file.getName().startsWith(dataFile.getName()) || file.getName().equals(dataFile.getName())) {
|
||||
file.delete();
|
||||
}
|
||||
if (CollUtil.isNotEmpty(weatherDatas)) {
|
||||
for(WeatherData weatherData : weatherDatas) {
|
||||
//删除气象文件和生成的.gbx9、.ncx2文件
|
||||
File dataFile = new File(weatherData.getFilePath());
|
||||
if(dataFile.exists()) {
|
||||
dataFile.delete();
|
||||
}
|
||||
File gbx9File = new File(weatherData.getFilePath()+".gbx9");
|
||||
if(gbx9File.exists()) {
|
||||
gbx9File.delete();
|
||||
}
|
||||
File ncx4File = new File(weatherData.getFilePath()+".ncx4");
|
||||
if(ncx4File.exists()) {
|
||||
ncx4File.delete();
|
||||
}
|
||||
}
|
||||
this.baseMapper.deleteById(weatherData.getId());
|
||||
this.baseMapper.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package org.jeecg.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
|
|
@ -213,7 +215,29 @@ public class WeatherTaskServiceImpl extends ServiceImpl<WeatherTaskMapper, Weath
|
|||
@Transactional(rollbackFor = RuntimeException.class)
|
||||
@Override
|
||||
public void delete(List<String> ids) {
|
||||
this.baseMapper.deleteBatchIds(ids);
|
||||
List<WeatherTask> weatherTasks = this.baseMapper.selectByIds(ids);
|
||||
if(CollUtil.isNotEmpty(weatherTasks)){
|
||||
for (WeatherTask weatherTask : weatherTasks) {
|
||||
if (Objects.nonNull(weatherTask) && StrUtil.isNotBlank(weatherTask.getInputFile())){
|
||||
String inputFileParent = "";
|
||||
if (WeatherDataSourceEnum.PANGU.getKey().equals(weatherTask.getPredictionModel())){
|
||||
inputFileParent = this.systemStorageProperties.getPanguModelExecPath();
|
||||
}else if (WeatherDataSourceEnum.GRAPHCAST.getKey().equals(weatherTask.getPredictionModel())) {
|
||||
inputFileParent = this.systemStorageProperties.getGraphcastModelExecPath();
|
||||
}
|
||||
File inputFile = new File(inputFileParent+File.separator+weatherTask.getInputFile());
|
||||
if (inputFile.exists()){
|
||||
inputFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
this.baseMapper.deleteBatchIds(ids);
|
||||
//删除对应任务的运行日志
|
||||
LambdaQueryWrapper<WeatherTaskLog> logWrapper = new LambdaQueryWrapper<>();
|
||||
logWrapper.in(WeatherTaskLog::getTaskId,ids);
|
||||
this.weatherTaskLogMapper.delete(logWrapper);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user