Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
760927900a
|
|
@ -6,9 +6,9 @@ public class EventConstants {
|
|||
public static final String SOURCE_DATA_NAME = "sourceData.txt";
|
||||
public static final String GK_NAME = "combined_factors.xlsx";
|
||||
|
||||
public static final String WRF_DIR = "wrf";
|
||||
public static final String CONC_DIR = "cctm";
|
||||
public static final String METCRO3D_DIR = "mcip";
|
||||
public static final String WRF_DIR = "WRF";
|
||||
public static final String CONC_DIR = "CCTM";
|
||||
public static final String METCRO3D_DIR = "MCIP";
|
||||
public static final String EMIS_DIR = "data/emis/d03";
|
||||
|
||||
public static final String MERGE_RESULTS = "merge_results_to_nc.py";
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ import ch.ethz.ssh2.StreamGobbler;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -157,7 +159,7 @@ public class RemoteExecuteCommand {
|
|||
|
||||
//远程连接并执行单条linux命令
|
||||
public static String runRemoteLinuxCmd(String linux_ip,String linux_username,String password, String cmd) {
|
||||
System.out.println("cmdString:" + cmd);
|
||||
System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + " cmdString:" + cmd);
|
||||
//执行的命令返回结果
|
||||
String executeResult = "";
|
||||
if(StringUtils.isNotBlank(cmd) && StringUtils.isNotBlank(linux_ip) && StringUtils.isNotBlank(linux_username) && StringUtils.isNotBlank(password)){
|
||||
|
|
|
|||
|
|
@ -151,15 +151,31 @@ public class BaseAPIServiceImpl implements BaseAPIService {
|
|||
return (lat >= minLat && lat <= maxLat && lon >= minLon && lon <= maxLon);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public String buildEngineeringFilePath(String modelPath, String createBy, String engineeringName) {
|
||||
// return eventServerProperties.getBaseHome() +
|
||||
// File.separator +
|
||||
// modelPath +
|
||||
// File.separator +
|
||||
// createBy +
|
||||
// File.separator +
|
||||
// engineeringName +
|
||||
// File.separator;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String buildEngineeringFilePath(String modelPath, String createBy, String engineeringName) {
|
||||
return eventServerProperties.getBaseHome() +
|
||||
File.separator +
|
||||
// File.separator +
|
||||
"/" +
|
||||
modelPath +
|
||||
File.separator +
|
||||
// File.separator +
|
||||
"/" +
|
||||
createBy +
|
||||
File.separator +
|
||||
// File.separator +
|
||||
"/" +
|
||||
engineeringName +
|
||||
File.separator;
|
||||
"/";
|
||||
// File.separator;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@ public class SFTPUtil {
|
|||
//私钥
|
||||
private String privateKey;
|
||||
|
||||
// bizSftpAPIService.download(mcipPath,"GRIDDESC.d03",targetFilePath + "GRIDDESC.d03");
|
||||
|
||||
/**
|
||||
* 构造基于密码认证的sftp对象
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ package org.jeecg.baseAPI.sftpAPI;
|
|||
* @Date: 2023-09-20
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IBizSftpAPIService {
|
||||
public interface SftpAPIService {
|
||||
|
||||
/**
|
||||
* sftp上传文件
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
package org.jeecg.baseAPI.sftpAPI.impl;
|
||||
|
||||
|
||||
import org.jeecg.baseAPI.sftpAPI.IBizSftpAPIService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.jeecg.baseAPI.sftpAPI.SftpAPIService;
|
||||
import org.jeecg.baseAPI.sftpAPI.SFTPUtil;
|
||||
import org.jeecg.common.properties.EventServerProperties;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -16,22 +18,16 @@ import java.io.InputStream;
|
|||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class BizSftpAPIServiceImpl implements IBizSftpAPIService {
|
||||
@RequiredArgsConstructor
|
||||
public class SftpAPIServiceImpl implements SftpAPIService {
|
||||
|
||||
@Value("${spring.Linux.ip}")
|
||||
private String ip;
|
||||
@Value("${spring.Linux.username}")
|
||||
private String username;
|
||||
@Value("${spring.Linux.password}")
|
||||
private String password;
|
||||
@Value("${spring.Linux.port}")
|
||||
private Integer port;
|
||||
private final EventServerProperties eventServerProperties;
|
||||
|
||||
@Override
|
||||
public void sftpUpload(String file, String cshFilePath, String fileName) {
|
||||
try{
|
||||
SFTPUtil sftpUtil = new SFTPUtil();
|
||||
sftpUtil.login(username, password,ip,port);
|
||||
sftpUtil.login(eventServerProperties.getUsername(), eventServerProperties.getPassword(), eventServerProperties.getIp(), eventServerProperties.getPort());
|
||||
InputStream inputStream = new FileInputStream(file);
|
||||
sftpUtil.upload(cshFilePath,fileName,inputStream);
|
||||
sftpUtil.logout();
|
||||
|
|
@ -45,7 +41,7 @@ public class BizSftpAPIServiceImpl implements IBizSftpAPIService {
|
|||
public void download(String directory, String downloadFile, String saveFile) {
|
||||
try{
|
||||
SFTPUtil sftpUtil = new SFTPUtil();
|
||||
sftpUtil.login(username, password,ip,port);
|
||||
sftpUtil.login(eventServerProperties.getUsername(), eventServerProperties.getPassword(), eventServerProperties.getIp(), eventServerProperties.getPort());
|
||||
sftpUtil.download(directory,downloadFile,saveFile);
|
||||
sftpUtil.logout();
|
||||
}catch (Exception e){
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package org.jeecg.sync.controller;
|
||||
package org.jeecg.cmaq.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.sync.service.CmaqService;
|
||||
import org.jeecg.cmaq.service.CmaqService;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
package org.jeecg.sync.service;
|
||||
package org.jeecg.cmaq.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.entity.Cmaq;
|
||||
import org.jeecg.modules.base.entity.Engineering;
|
||||
import org.jeecg.modules.base.entity.Wrf;
|
||||
import org.jeecg.runProcess.VO.RunProcessParamVO;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -15,6 +16,7 @@ import org.jeecg.modules.base.entity.Wrf;
|
|||
*/
|
||||
public interface CmaqService extends IService<Cmaq> {
|
||||
|
||||
Result<String> updateCmaqInfo(RunProcessParamVO paramVO);
|
||||
Result<String> runAllCmaq(Engineering engineering, Wrf wrf);
|
||||
Cmaq getCmaqTem(Integer sceneType);
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package org.jeecg.sync.service.impl;
|
||||
package org.jeecg.cmaq.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
|
@ -11,24 +11,19 @@ import org.jeecg.baseAPI.service.BaseAPIService;
|
|||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.properties.EventServerProperties;
|
||||
import org.jeecg.common.util.RemoteExecuteCommand;
|
||||
import org.jeecg.engineering.service.EngineeringService;
|
||||
import org.jeecg.modules.base.entity.Engineering;
|
||||
import org.jeecg.modules.base.entity.Wrf;
|
||||
import org.jeecg.modules.base.mapper.WrfMapper;
|
||||
import org.jeecg.sync.service.CmaqService;
|
||||
import org.jeecg.cmaq.service.CmaqService;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.modules.base.entity.Cmaq;
|
||||
import org.jeecg.modules.base.mapper.CmaqMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.jeecg.runProcess.VO.RunProcessParamVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.nio.file.Paths.get;
|
||||
|
|
@ -51,103 +46,84 @@ public class CmaqServiceImpl extends ServiceImpl<CmaqMapper, Cmaq> implements Cm
|
|||
Cmaq cmaq = this.baseMapper.selectOne(new LambdaQueryWrapper<Cmaq>().eq(Cmaq::getEnginId,engineering.getId()));
|
||||
//各种路径前缀
|
||||
String allRunPath = baseAPIService.buildEngineeringFilePath("" ,engineering.getCreateBy(), engineering.getEngineeringName());
|
||||
String targetFilePath = baseAPIService.buildEngineeringFilePath(eventServerProperties.getResultFilePrefix() ,engineering.getCreateBy(), engineering.getEngineeringName());
|
||||
// String targetFilePath = localFilePrefix + engineering.getCreateBy() + "/" + engineering.getEngineeringName() + "/";
|
||||
String workdirPath = allRunPath + "workdir/";
|
||||
String mcipPath = allRunPath + "workdir/MCIP/";
|
||||
String scriptsPath = allRunPath + "scripts/";
|
||||
String emisPath = allRunPath + "scripts/emis/";
|
||||
String shRunPath = "cd " + allRunPath + "scripts/;";
|
||||
|
||||
//运行mcip程序
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
shRunPath + "chmod +x run_project_mcip.sh;./run_project_mcip.sh");
|
||||
|
||||
//将mcip文件拷贝到指定目录
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
"cp -rf " + allRunPath + "scripts/mcip/* " + mcipPath);
|
||||
|
||||
//下载mcip结果文件
|
||||
File griddescFile = new File(targetFilePath + "GRIDDESC.d03");
|
||||
boolean mcipSuccesfully = griddescFile.exists();
|
||||
shRunPath + "source ~/.bash_profile;chmod +x run_project_mcip.sh;./run_project_mcip.sh");
|
||||
boolean mcipSuccesfully = getFileExists(mcipPath + "GRIDDESC.d03");
|
||||
if(!mcipSuccesfully){
|
||||
return Result.error("MCIP运行失败,请查看日志信息!");
|
||||
}
|
||||
|
||||
String sDate = wrf.getStartTime().substring(0, 10).replace("-","");
|
||||
//生成McipTxt文件
|
||||
genMcipTxtFile(targetFilePath, cmaq, wrf.getRefLon(), wrf.getRefLat());
|
||||
genMcipTxtFile(mcipPath,emisPath, cmaq, sDate, wrf.getRefLon(), wrf.getRefLat());
|
||||
|
||||
//运行部分脚本
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
runPyPath(mcipPath ,"ocean_base.py",""));
|
||||
// RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(), runPyPath(mcipPath ,"ocean_update.py",""));
|
||||
runPyPath(scriptsPath ,"ocean_base.py",""));
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
runPyPath(mcipPath ,"emis_base_sf6.py",""));
|
||||
runPyPath(scriptsPath ,"emis_base_sf6.py",""));
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
runPyPath(mcipPath ,"1exportZF.py",""));
|
||||
|
||||
String sDate = wrf.getStartTime().substring(0, 10).replace("-","");
|
||||
//工程总运行天数
|
||||
Integer sumDay = Integer.valueOf(wrf.getAnalogTime()) / 24;
|
||||
String metcr03dName= "METCRO3D_d03_" + sDate;
|
||||
List<String> locMetValues = new ArrayList<>();
|
||||
locMetValues.add("latitude=" + wrf.getRefLat());
|
||||
locMetValues.add("lontitude=" + wrf.getRefLon());
|
||||
locMetValues.add("mcip=" + metcr03dName);
|
||||
FileUtil.writeLines(locMetValues, targetFilePath + "loc_met.txt", "UTF-8");
|
||||
|
||||
runPyPath(emisPath ,"1exportZF.py",""));
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
runPyPath(mcipPath ,"2generateMultiPointEmis_icupdate_v1.py","emis"));
|
||||
|
||||
runPyPath(emisPath ,"2generateMultiPointEmis_icupdate_v1.py","emis"));
|
||||
String multipointemisParam = sDate + " multipointemis.nc";
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
runPyPath(mcipPath ,"emis_update_emis_ic.py",multipointemisParam));
|
||||
runPyPath(emisPath ,"emis_update_emis_ic.py",multipointemisParam));
|
||||
|
||||
boolean emisSuccesfully = getFileExists(mcipPath + "multipointemis.nc");
|
||||
boolean emisSuccesfully = getFileExists(emisPath + "multipointemis.nc");
|
||||
if(!emisSuccesfully){
|
||||
return Result.error("EMIS运行失败,请查看日志信息!");
|
||||
}
|
||||
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
shRunPath + "chmod +x run_project_icon.sh;./run_project_icon.sh");
|
||||
shRunPath + "source ~/.bash_profile;chmod +x run_project_icon.sh;./run_project_icon.sh");
|
||||
boolean iconSuccesfully = getFileExists(allRunPath + "workdir/ICON/icon_d03_*");
|
||||
if(!iconSuccesfully){
|
||||
return Result.error("ICON运行失败,请查看日志信息!");
|
||||
}
|
||||
|
||||
//ICON执行完成后,修改ICON结果文件的内容
|
||||
String iconFilePath = workdirPath + "ICON/icon_d03_" + sDate;
|
||||
String asijParam = String.format("icon ASIJ %s %s_ASIJ",iconFilePath,iconFilePath);
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
runPyPath(mcipPath, "2generateMultiPointEmis_icupdate_v1.py",asijParam));
|
||||
// String iconFilePath = workdirPath + "ICON/icon_d03_" + sDate;
|
||||
// String asijParam = String.format("icon ASIJ %s %s_ASIJ",iconFilePath,iconFilePath);
|
||||
// RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
// runPyPath(emisPath, "2generateMultiPointEmis_icupdate_v1.py",asijParam));
|
||||
//
|
||||
// RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
// "rm -rf " + iconFilePath);
|
||||
//
|
||||
// String coParam = String.format("icon CO %s_ASIJ %s",iconFilePath,iconFilePath);
|
||||
// RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
// runPyPath(emisPath, "2generateMultiPointEmis_icupdate_v1.py",coParam));
|
||||
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
"rm -rf " + iconFilePath);
|
||||
|
||||
String coParam = String.format("icon CO %s_ASIJ %s",iconFilePath,iconFilePath);
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
runPyPath(mcipPath, "2generateMultiPointEmis_icupdate_v1.py",coParam));
|
||||
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
shRunPath + "chmod +x run_project_bcon.sh;./run_project_bcon.sh");
|
||||
shRunPath + "source ~/.bash_profile;chmod +x run_project_bcon.sh;./run_project_bcon.sh");
|
||||
boolean bconSuccesfully = getFileExists(allRunPath + "workdir/BCON/bcon_d03_*");
|
||||
if(!bconSuccesfully){
|
||||
return Result.error("BCON运行失败,请查看日志信息!");
|
||||
}
|
||||
|
||||
//BCON执行完成后,修改BCON结果文件的内容
|
||||
String bconFilePath = workdirPath + "BCON/bcon_d03_" + sDate;
|
||||
String asijBconParam = String.format("bcon ASIJ %s %s_ASIJ",bconFilePath,bconFilePath);
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
runPyPath(mcipPath, "2generateMultiPointEmis_icupdate_v1.py",asijBconParam));
|
||||
// String bconFilePath = workdirPath + "BCON/bcon_d03_" + sDate;
|
||||
// String asijBconParam = String.format("bcon ASIJ %s %s_ASIJ",bconFilePath,bconFilePath);
|
||||
// RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
// runPyPath(emisPath, "2generateMultiPointEmis_icupdate_v1.py",asijBconParam));
|
||||
//
|
||||
// RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
// "rm -rf " + bconFilePath);
|
||||
|
||||
// String coBconParam = String.format("bcon CO %s_ASIJ %s",bconFilePath,bconFilePath);
|
||||
// RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
// runPyPath(emisPath, "2generateMultiPointEmis_icupdate_v1.py",coBconParam));
|
||||
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
"rm -rf " + bconFilePath);
|
||||
|
||||
String coBconParam = String.format("bcon CO %s_ASIJ %s",bconFilePath,bconFilePath);
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
runPyPath(mcipPath, "2generateMultiPointEmis_icupdate_v1.py",coBconParam));
|
||||
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
shRunPath + "chmod +x run_project_cctm.sh;./run_project_cctm.sh");
|
||||
shRunPath + "source ~/.bash_profile;chmod +x run_project_cctm.sh;./run_project_cctm.sh");
|
||||
boolean cctmSuccesfully = getFileExists(allRunPath + "workdir/CCTM/CCTM.ACONC.d03.*");
|
||||
if(!cctmSuccesfully){
|
||||
return Result.error("CCTM运行失败,请查看日志信息!");
|
||||
|
|
@ -155,9 +131,9 @@ public class CmaqServiceImpl extends ServiceImpl<CmaqMapper, Cmaq> implements Cm
|
|||
return Result.ok("CMAQ运行成功!");
|
||||
}
|
||||
|
||||
public Result<String> genMcipTxtFile(String targetFilePath, Cmaq cmaq, Double lon, Double lat) {
|
||||
public Result<String> genMcipTxtFile(String mcipPath, String emisPath, Cmaq cmaq, String sDate, Double lon, Double lat) {
|
||||
try {
|
||||
List<String> gridDescFileValue = Files.readAllLines(get(targetFilePath + "GRIDDESC.d03"));
|
||||
List<String> gridDescFileValue = Files.readAllLines(get("E:\\wm\\resultFile\\" + "GRIDDESC.d03"));
|
||||
List<String> fileValues = Arrays.stream(gridDescFileValue.get(5).split(" ")).filter(s -> StringUtils.isNotBlank(s)).collect(Collectors.toList());
|
||||
|
||||
List<String> domainValues = new ArrayList<>();
|
||||
|
|
@ -166,14 +142,22 @@ public class CmaqServiceImpl extends ServiceImpl<CmaqMapper, Cmaq> implements Cm
|
|||
domainValues.add("domainCols=" + fileValues.get(5));
|
||||
domainValues.add("domainRows=" + fileValues.get(6));
|
||||
domainValues.add("domainCell=" + String.format("%.0f",Double.valueOf(fileValues.get(3))));
|
||||
FileUtil.writeLines(domainValues, targetFilePath + "domain.txt", "UTF-8");
|
||||
FileUtil.writeLines(domainValues, emisPath + "domain.txt", "UTF-8");
|
||||
|
||||
List<String> pointSourceValues = new ArrayList<>();
|
||||
pointSourceValues.add("latitude\tlontitude");
|
||||
pointSourceValues.add(lon + "\t" + lat);
|
||||
pointSourceValues.add(lat + "\t" + lon);
|
||||
pointSourceValues.add("No\tdy\tdx\tshour\tehour");
|
||||
pointSourceValues.add(String.format("%s\t%s\t%s\t%s\t%s",1,0,0,cmaq.getEmisShour(),cmaq.getEmisEhour()));
|
||||
FileUtil.writeLines(pointSourceValues, targetFilePath + "pointsource.txt", "UTF-8");
|
||||
FileUtil.writeLines(pointSourceValues, emisPath + "pointsource.txt", "UTF-8");
|
||||
|
||||
String metcr03dName= "METCRO3D_d03_" + sDate;
|
||||
List<String> locMetValues = new ArrayList<>();
|
||||
locMetValues.add("latitude=" + lat);
|
||||
locMetValues.add("lontitude=" + lon);
|
||||
locMetValues.add("mcip=" + mcipPath + metcr03dName);
|
||||
locMetValues.add("dot=" + mcipPath + metcr03dName);
|
||||
FileUtil.writeLines(locMetValues, emisPath + "loc_met.txt", "UTF-8");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return Result.error("生成Txt文件异常!");
|
||||
|
|
@ -182,7 +166,7 @@ public class CmaqServiceImpl extends ServiceImpl<CmaqMapper, Cmaq> implements Cm
|
|||
}
|
||||
|
||||
public String runPyPath(String allRunPath,String pyFileName,String param){
|
||||
return String.format("cd %s;chmod +x %s;%srtm/bin/python3 %s %s", allRunPath, pyFileName, eventServerProperties.getPythonPath(), pyFileName, param);
|
||||
return String.format("cd %s;chmod +x %s;%s/python3 %s %s", allRunPath, pyFileName, eventServerProperties.getPythonPath(), pyFileName, param);
|
||||
}
|
||||
|
||||
public boolean getFileExists(String filePath){
|
||||
|
|
@ -192,6 +176,14 @@ public class CmaqServiceImpl extends ServiceImpl<CmaqMapper, Cmaq> implements Cm
|
|||
return succesfully;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> updateCmaqInfo(RunProcessParamVO paramVO) {
|
||||
Cmaq cmaq = this.baseMapper.selectOne(new LambdaQueryWrapper<Cmaq>().eq(Cmaq::getEnginId, paramVO.getEnginId()));
|
||||
BeanUtil.copyProperties(paramVO, cmaq);
|
||||
this.baseMapper.updateById(cmaq);
|
||||
return Result.OK("修改成功!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cmaq getCmaqTem(Integer sceneType) {
|
||||
LambdaQueryWrapper<Cmaq> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
|
|
@ -64,14 +64,15 @@ public class EngineeringServiceImpl extends ServiceImpl<EngineeringMapper, Engin
|
|||
|
||||
@Override
|
||||
public void initDir(Engineering engineering){
|
||||
String baseHome = eventServerProperties.getBaseHome() + File.separator;
|
||||
// String baseHome = eventServerProperties.getBaseHome() + File.separator;
|
||||
String baseHome = eventServerProperties.getBaseHome() + "/";
|
||||
String ip = eventServerProperties.getIp();
|
||||
String username = eventServerProperties.getUsername();
|
||||
String password = eventServerProperties.getPassword();
|
||||
String newAllRunPath = String.format("%s%s/%s/", baseHome, engineering.getCreateBy(),engineering.getEngineeringName());
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, String.format("rm -rf %s",newAllRunPath));
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, String.format("mkdir %s",baseHome + engineering.getCreateBy()));
|
||||
String runCmd = String.format("cp -rf %sAll_Run %s", baseHome, newAllRunPath);
|
||||
String runCmd = String.format("cp -rf %sAll_run %s", baseHome, newAllRunPath);
|
||||
RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, runCmd);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,4 +15,9 @@ public class RunProcessParamVO {
|
|||
private Double refLon;
|
||||
/**纬度*/
|
||||
private Double refLat;
|
||||
|
||||
|
||||
//cmaq参数
|
||||
private Integer emisShour;
|
||||
private Integer emisEhour;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package org.jeecg.runProcess.controller;
|
|||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.sync.service.CmaqService;
|
||||
import org.jeecg.cmaq.service.CmaqService;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.engineering.service.EngineeringService;
|
||||
|
|
@ -53,19 +53,10 @@ public class RunProcessController {
|
|||
bizEngineering.setEventType(paramVO.getEventType());
|
||||
bizEngineering.setEnginStatus(2);
|
||||
engineeringService.updateById(bizEngineering);
|
||||
|
||||
engineeringService.initDir(bizEngineering);
|
||||
|
||||
// engineeringService.initDir(bizEngineering);
|
||||
wrfService.updateWrfInfo(paramVO);
|
||||
// bizCmaqService.updateCmaqInfo(engineeringId);
|
||||
cmaqService.updateCmaqInfo(paramVO);
|
||||
runProcessService.runAllExe(paramVO);
|
||||
|
||||
return Result.OK("运行成功!");
|
||||
}
|
||||
|
||||
@PostMapping(value = "/runTest")
|
||||
public Result<String> runTest(String engineeringId) {
|
||||
runProcessService.runTest(engineeringId);
|
||||
return Result.OK("运行成功!");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,5 @@ import org.jeecg.runProcess.VO.RunProcessParamVO;
|
|||
import java.util.Map;
|
||||
|
||||
public interface RunProcessService {
|
||||
public void runTest(String engineeringId);
|
||||
Result<String> runAllExe(RunProcessParamVO paramVO);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package org.jeecg.runProcess.service.impl;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.jeecg.baseAPI.service.BaseAPIService;
|
||||
import org.jeecg.sync.service.CmaqService;
|
||||
import org.jeecg.cmaq.service.CmaqService;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.EventConstants;
|
||||
import org.jeecg.common.properties.EventServerProperties;
|
||||
|
|
@ -36,19 +36,6 @@ public class RunProcessServiceImpl implements RunProcessService {
|
|||
private final EventServerProperties eventServerProperties;
|
||||
private final EventTypeService eventTypeService;
|
||||
|
||||
@Override
|
||||
public void runTest(String engineeringId){
|
||||
Engineering engineering = engineeringService.getById(engineeringId);
|
||||
Wrf wrf = wrfService.getOne(new LambdaQueryWrapper<Wrf>().eq(Wrf::getEnginId,engineeringId));
|
||||
//各种路径前缀
|
||||
String allRunPath = baseAPIService.buildEngineeringFilePath("" ,engineering.getCreateBy(), engineering.getEngineeringName());
|
||||
String resultFilePath = baseAPIService.buildEngineeringFilePath(eventServerProperties.getResultFilePrefix() ,engineering.getCreateBy(), engineering.getEngineeringName());
|
||||
//生成CMAQ脚本
|
||||
genMcipRunShell(allRunPath, resultFilePath, wrf);
|
||||
//运行CMAQ程序
|
||||
Result<String> cmaqResult = cmaqService.runAllCmaq(engineering, wrf);
|
||||
System.out.println();
|
||||
}
|
||||
@Override
|
||||
public Result<String> runAllExe(RunProcessParamVO paramVO){
|
||||
try{
|
||||
|
|
@ -60,7 +47,6 @@ public class RunProcessServiceImpl implements RunProcessService {
|
|||
String allRunPath = baseAPIService.buildEngineeringFilePath("" ,engineering.getCreateBy(), engineering.getEngineeringName());
|
||||
String resultFilePath = baseAPIService.buildEngineeringFilePath(eventServerProperties.getResultFilePrefix() ,engineering.getCreateBy(), engineering.getEngineeringName());
|
||||
String workDirPath = allRunPath + "workdir/";
|
||||
String mcipPath = allRunPath + "workdir/MCIP/";
|
||||
String scriptsPath = allRunPath + "scripts/";
|
||||
|
||||
//生成WRF脚本
|
||||
|
|
@ -71,7 +57,7 @@ public class RunProcessServiceImpl implements RunProcessService {
|
|||
return wrfResult;
|
||||
}
|
||||
//生成CMAQ脚本
|
||||
genMcipRunShell(allRunPath, resultFilePath, wrf);
|
||||
genMcipRunShell(allRunPath, scriptsPath, wrf);
|
||||
//运行CMAQ程序
|
||||
Result<String> cmaqResult = cmaqService.runAllCmaq(engineering, wrf);
|
||||
if(!cmaqResult.isSuccess()){
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public class WrfServiceImpl extends ServiceImpl<WrfMapper, Wrf> implements WrfSe
|
|||
@Override
|
||||
public Result<String> runAllWrf(String engId, String scriptsPath, String resultFilePath) throws IOException {
|
||||
String cdShRunPath = "cd " + scriptsPath + ";";
|
||||
boolean wpsSuccess = runProjectWps(cdShRunPath + "chmod +x run_project_wps.sh;./run_project_wps.sh", resultFilePath);
|
||||
boolean wpsSuccess = runProjectWps(cdShRunPath + "source ~/.bash_profile;chmod +x run_project_wps.sh;./run_project_wps.sh", resultFilePath);
|
||||
if (!wpsSuccess){
|
||||
return Result.error("WPS模块运行异常,请查看日志信息!");
|
||||
}
|
||||
|
|
@ -125,7 +125,7 @@ public class WrfServiceImpl extends ServiceImpl<WrfMapper, Wrf> implements WrfSe
|
|||
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
|
||||
runPyPath(scriptsPath, "update_num_metgrid_levels.py", null));
|
||||
|
||||
boolean wrfSuccess = runProjectWrf(cdShRunPath + "chmod +x run_project_wrf.sh;./run_project_wrf.sh", resultFilePath);
|
||||
boolean wrfSuccess = runProjectWrf(cdShRunPath + "source ~/.bash_profile;chmod +x run_project_wrf.sh;./run_project_wrf.sh", resultFilePath);
|
||||
if (!wrfSuccess){
|
||||
return Result.error("WRF模块运行异常,请查看日志信息!");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
package org.jeecg.sync.controller;
|
||||
package org.jeecg.cmaq.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.sync.feign.SyncFeignClient;
|
||||
import org.jeecg.cmaq.feign.SyncFeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.jeecg.sync.feign;
|
||||
package org.jeecg.cmaq.feign;
|
||||
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
Loading…
Reference in New Issue
Block a user