线上wrf-cmaq完成调试

This commit is contained in:
hekaiyu 2026-01-13 14:25:40 +08:00
parent aca2e0983c
commit a022fc1d9a
6 changed files with 29 additions and 34 deletions

View File

@ -151,31 +151,27 @@ public class BaseAPIServiceImpl implements BaseAPIService {
return (lat >= minLat && lat <= maxLat && lon >= minLon && lon <= maxLon); 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 @Override
public String buildEngineeringFilePath(String modelPath, String createBy, String engineeringName) { public String buildEngineeringFilePath(String modelPath, String createBy, String engineeringName) {
return eventServerProperties.getBaseHome() + return eventServerProperties.getBaseHome() +
// File.separator + File.separator +
"/" +
modelPath + modelPath +
// File.separator + File.separator +
"/" +
createBy + createBy +
// File.separator + File.separator +
"/" +
engineeringName + engineeringName +
"/"; File.separator;
// File.separator;
} }
// @Override
// public String buildEngineeringFilePath(String modelPath, String createBy, String engineeringName) {
// return eventServerProperties.getBaseHome() +
// "/" +
// modelPath +
// "/" +
// createBy +
// "/" +
// engineeringName +
// "/";
// }
} }

View File

@ -133,7 +133,7 @@ public class CmaqServiceImpl extends ServiceImpl<CmaqMapper, Cmaq> implements Cm
public Result<String> genMcipTxtFile(String mcipPath, String emisPath, Cmaq cmaq, String sDate, Double lon, Double lat) { public Result<String> genMcipTxtFile(String mcipPath, String emisPath, Cmaq cmaq, String sDate, Double lon, Double lat) {
try { try {
List<String> gridDescFileValue = Files.readAllLines(get("E:\\wm\\resultFile\\" + "GRIDDESC.d03")); List<String> gridDescFileValue = Files.readAllLines(get(mcipPath + "GRIDDESC.d03"));
List<String> fileValues = Arrays.stream(gridDescFileValue.get(5).split(" ")).filter(s -> StringUtils.isNotBlank(s)).collect(Collectors.toList()); List<String> fileValues = Arrays.stream(gridDescFileValue.get(5).split(" ")).filter(s -> StringUtils.isNotBlank(s)).collect(Collectors.toList());
List<String> domainValues = new ArrayList<>(); List<String> domainValues = new ArrayList<>();
@ -172,8 +172,7 @@ public class CmaqServiceImpl extends ServiceImpl<CmaqMapper, Cmaq> implements Cm
public boolean getFileExists(String filePath){ public boolean getFileExists(String filePath){
String cmdResult = RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(), String cmdResult = RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
"ls " + filePath); "ls " + filePath);
boolean succesfully = cmdResult.indexOf("没有那个文件或目录") < 0; return !cmdResult.contains("没有那个文件或目录") || !cmdResult.contains("No such file or directory");
return succesfully;
} }
@Override @Override

View File

@ -64,8 +64,8 @@ public class EngineeringServiceImpl extends ServiceImpl<EngineeringMapper, Engin
@Override @Override
public void initDir(Engineering engineering){ public void initDir(Engineering engineering){
// String baseHome = eventServerProperties.getBaseHome() + File.separator; String baseHome = eventServerProperties.getBaseHome() + File.separator;
String baseHome = eventServerProperties.getBaseHome() + "/"; // String baseHome = eventServerProperties.getBaseHome() + "/";
String ip = eventServerProperties.getIp(); String ip = eventServerProperties.getIp();
String username = eventServerProperties.getUsername(); String username = eventServerProperties.getUsername();
String password = eventServerProperties.getPassword(); String password = eventServerProperties.getPassword();

View File

@ -53,7 +53,7 @@ public class RunProcessController {
bizEngineering.setEventType(paramVO.getEventType()); bizEngineering.setEventType(paramVO.getEventType());
bizEngineering.setEnginStatus(2); bizEngineering.setEnginStatus(2);
engineeringService.updateById(bizEngineering); engineeringService.updateById(bizEngineering);
// engineeringService.initDir(bizEngineering); engineeringService.initDir(bizEngineering);
wrfService.updateWrfInfo(paramVO); wrfService.updateWrfInfo(paramVO);
cmaqService.updateCmaqInfo(paramVO); cmaqService.updateCmaqInfo(paramVO);
runProcessService.runAllExe(paramVO); runProcessService.runAllExe(paramVO);

View File

@ -17,6 +17,6 @@ public interface WrfService extends IService<Wrf> {
Result<String> updateWrfInfo(RunProcessParamVO paramVO); Result<String> updateWrfInfo(RunProcessParamVO paramVO);
String genWpsShell(String scriptsPath, String fileName, Wrf wrf) throws IOException; String genWpsShell(String scriptsPath, String fileName, Wrf wrf) throws IOException;
Result<String> runAllWrf(String engId, String scriptsPath, String resultFilePath) throws IOException; Result<String> runAllWrf(String engId, String scriptsPath, String workDirPath) throws IOException;
} }

View File

@ -115,9 +115,9 @@ public class WrfServiceImpl extends ServiceImpl<WrfMapper, Wrf> implements WrfSe
} }
@Override @Override
public Result<String> runAllWrf(String engId, String scriptsPath, String resultFilePath) throws IOException { public Result<String> runAllWrf(String engId, String scriptsPath, String workDirPath) throws IOException {
String cdShRunPath = "cd " + scriptsPath + ";"; String cdShRunPath = "cd " + scriptsPath + ";";
boolean wpsSuccess = runProjectWps(cdShRunPath + "source ~/.bash_profile;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", workDirPath);
if (!wpsSuccess){ if (!wpsSuccess){
return Result.error("WPS模块运行异常请查看日志信息"); return Result.error("WPS模块运行异常请查看日志信息");
} }
@ -125,25 +125,25 @@ public class WrfServiceImpl extends ServiceImpl<WrfMapper, Wrf> implements WrfSe
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(), RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(),
runPyPath(scriptsPath, "update_num_metgrid_levels.py", null)); runPyPath(scriptsPath, "update_num_metgrid_levels.py", null));
boolean wrfSuccess = runProjectWrf(cdShRunPath + "source ~/.bash_profile;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", workDirPath);
if (!wrfSuccess){ if (!wrfSuccess){
return Result.error("WRF模块运行异常请查看日志信息"); return Result.error("WRF模块运行异常请查看日志信息");
} }
return Result.ok(); return Result.ok();
} }
public boolean runProjectWps(String cmdString,String resultFilePath) throws IOException { public boolean runProjectWps(String cmdString,String workDirPath) throws IOException {
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(), cmdString); RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(), cmdString);
String metgridLog = new String(readAllBytes(get(resultFilePath + EventConstants.WRF_DIR+ "/metgrid.log"))); String metgridLog = new String(readAllBytes(get(workDirPath + EventConstants.WRF_DIR+ "/metgrid.log")));
if(metgridLog.indexOf("Successful completion of program metgrid.exe") > 0){ if(metgridLog.indexOf("Successful completion of program metgrid.exe") > 0){
return true; return true;
} }
return false; return false;
} }
public boolean runProjectWrf(String cmdString,String resultFilePath) throws IOException { public boolean runProjectWrf(String cmdString,String workDirPath) throws IOException {
RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(), cmdString); RemoteExecuteCommand.runRemoteLinuxCmd(eventServerProperties.getIp(), eventServerProperties.getUsername(), eventServerProperties.getPassword(), cmdString);
String wrfLog = new String(readAllBytes(get(resultFilePath + EventConstants.WRF_DIR + "/rsl.out.0000"))); String wrfLog = new String(readAllBytes(get(workDirPath + EventConstants.WRF_DIR + "/rsl.out.0000")));
if(wrfLog.indexOf("SUCCESS COMPLETE WRF") > 0){ if(wrfLog.indexOf("SUCCESS COMPLETE WRF") > 0){
return true; return true;
} }