合并冗余文件路径字段

This commit is contained in:
hky 2023-09-16 11:14:46 +08:00
parent 1328d1f5b8
commit dc03b4f020
6 changed files with 66 additions and 73 deletions

View File

@ -64,16 +64,13 @@ public class BizCmaqServiceImpl extends ServiceImpl<BizCmaqMapper, BizCmaq> impl
@Value("${spring.baseHome}") @Value("${spring.baseHome}")
private String baseHome; private String baseHome;
@Value("${spring.CMAQ.cmaqLocalShellHome}") @Value("${spring.localFilePrefix}")
private String cmaqLocalShellHome; private String localFilePrefix;
@Value("${spring.CMAQ.outputLocalPath}") @Value("${spring.cshTemFielPath}")
private String outputLocalPath;
@Value("${spring.CMAQ.cshTemFielPath}")
private String cshTemFielPath; private String cshTemFielPath;
@Value("${spring.CMAQ.pythonPath}") @Value("${spring.CMAQ.pythonPath}")
private String pythonPath; private String pythonPath;
@Value("${spring.WRF.wrfLocalPrefix}")
private String wrfLocalPrefix;
@Value("${spring.Linux.ip}") @Value("${spring.Linux.ip}")
private String ip; private String ip;
@Value("${spring.Linux.username}") @Value("${spring.Linux.username}")
@ -83,7 +80,7 @@ public class BizCmaqServiceImpl extends ServiceImpl<BizCmaqMapper, BizCmaq> impl
@Value("${spring.Linux.port}") @Value("${spring.Linux.port}")
private Integer port; private Integer port;
private String genMcipsShell(String allRunPath, String startTime, String endTime,Integer domain,String ncols,String nrows) throws IOException, SftpException { private String genMcipsShell(String allRunPath, String targetFilePath, String startTime, String endTime,Integer domain,String ncols,String nrows) throws IOException, SftpException {
String fileName = "all_run_mcip.csh"; String fileName = "all_run_mcip.csh";
String data = new String(readAllBytes(get(cshTemFielPath + "all_run_mcip_tem.csh"))); String data = new String(readAllBytes(get(cshTemFielPath + "all_run_mcip_tem.csh")));
data = data data = data
@ -93,19 +90,17 @@ public class BizCmaqServiceImpl extends ServiceImpl<BizCmaqMapper, BizCmaq> impl
.replace("#{domain}", domain+"") .replace("#{domain}", domain+"")
.replace("#{NCOLS_ARR}", ncols) .replace("#{NCOLS_ARR}", ncols)
.replace("#{NROWS_ARR}", nrows); .replace("#{NROWS_ARR}", nrows);
String targetFilePath = cmaqLocalShellHome + "MCIP/" + fileName;
FileUtil.writeString(data, targetFilePath, "UTF-8"); FileUtil.writeString(data, targetFilePath, "UTF-8");
sftpUpload(targetFilePath,allRunPath + "CMAQ/PREP/mcip/scripts/", fileName); sftpUpload(targetFilePath,allRunPath + "CMAQ/PREP/mcip/scripts/", fileName);
return fileName; return fileName;
} }
public String genIconShell(String allRunPath,String startTime,String endTime,Integer domain){ public String genIconShell(String allRunPath, String targetFilePath, String startTime,String endTime,Integer domain){
String fileName = "all_run_icon.csh"; String fileName = "all_run_icon.csh";
try { try {
String data = new String(readAllBytes(get(cshTemFielPath + "all_run_icon_tem.csh"))); String data = new String(readAllBytes(get(cshTemFielPath + "all_run_icon_tem.csh")));
data = data.replace("#{RUN_PATH}", allRunPath).replace("#{START_DATE}", startTime).replace("#{END_DATE}", endTime).replace("#{domain}", domain+""); data = data.replace("#{RUN_PATH}", allRunPath).replace("#{START_DATE}", startTime).replace("#{END_DATE}", endTime).replace("#{domain}", domain+"");
// todo sftp 上传 // todo sftp 上传
String targetFilePath = cmaqLocalShellHome + "ICON/" + fileName;
FileUtil.writeString(data, targetFilePath, "UTF-8"); FileUtil.writeString(data, targetFilePath, "UTF-8");
sftpUpload(targetFilePath,allRunPath + "CMAQ/PREP/icon/scripts/", fileName); sftpUpload(targetFilePath,allRunPath + "CMAQ/PREP/icon/scripts/", fileName);
} catch (Exception e) { } catch (Exception e) {
@ -114,13 +109,12 @@ public class BizCmaqServiceImpl extends ServiceImpl<BizCmaqMapper, BizCmaq> impl
return fileName; return fileName;
} }
public String genBconShell(String allRunPath,String startTime,String endTime,Integer domain) { public String genBconShell(String allRunPath, String targetFilePath, String startTime,String endTime,Integer domain) {
String fileName = "all_run_bcon.csh"; String fileName = "all_run_bcon.csh";
try { try {
String data = new String(readAllBytes(get(cshTemFielPath + "all_run_bcon_tem.csh"))); String data = new String(readAllBytes(get(cshTemFielPath + "all_run_bcon_tem.csh")));
data = data.replace("#{RUN_PATH}", allRunPath).replace("#{START_DATE}", startTime).replace("#{END_DATE}", endTime).replace("#{domain}", domain + ""); data = data.replace("#{RUN_PATH}", allRunPath).replace("#{START_DATE}", startTime).replace("#{END_DATE}", endTime).replace("#{domain}", domain + "");
// todo sftp 上传 // todo sftp 上传
String targetFilePath = cmaqLocalShellHome + "BCON/" + fileName;
FileUtil.writeString(data, targetFilePath, "UTF-8"); FileUtil.writeString(data, targetFilePath, "UTF-8");
sftpUpload(targetFilePath, allRunPath + "CMAQ/PREP/bcon/scripts/", fileName); sftpUpload(targetFilePath, allRunPath + "CMAQ/PREP/bcon/scripts/", fileName);
} catch (Exception e) { } catch (Exception e) {
@ -129,14 +123,13 @@ public class BizCmaqServiceImpl extends ServiceImpl<BizCmaqMapper, BizCmaq> impl
return fileName; return fileName;
} }
public String genCctmShell(String allRunPath, String startDate, String endDate, String stTime, String nSteps, String tStep) { public String genCctmShell(String allRunPath,String targetFilePath, String startDate, String endDate, String stTime, String nSteps, String tStep) {
String fileName = "run_cctm_2016.csh"; String fileName = "run_cctm_2016.csh";
try { try {
String data = new String(readAllBytes(get(cshTemFielPath + "run_cctm_2016_tem.csh"))); String data = new String(readAllBytes(get(cshTemFielPath + "run_cctm_2016_tem.csh")));
data = data.replace("#{START_DATE}", startDate).replace("#{END_DATE}", endDate).replace("#{STTIME}", stTime) data = data.replace("#{START_DATE}", startDate).replace("#{END_DATE}", endDate).replace("#{STTIME}", stTime)
.replace("#{NSTEPS}", nSteps).replace("#{TSTEP}", tStep); .replace("#{NSTEPS}", nSteps).replace("#{TSTEP}", tStep);
// todo sftp 上传 // todo sftp 上传
String targetFilePath = cmaqLocalShellHome + "CCTM/" + fileName;
FileUtil.writeString(data, targetFilePath, "UTF-8"); FileUtil.writeString(data, targetFilePath, "UTF-8");
sftpUpload(targetFilePath,allRunPath + "CMAQ/CCTM/scripts/",fileName); sftpUpload(targetFilePath,allRunPath + "CMAQ/CCTM/scripts/",fileName);
} catch (Exception e) { } catch (Exception e) {
@ -151,9 +144,11 @@ public class BizCmaqServiceImpl extends ServiceImpl<BizCmaqMapper, BizCmaq> impl
BizWrf wrf = bizWrfMapper.selectOne(new LambdaQueryWrapper<BizWrf>().eq(BizWrf::getEngineeringId,engineeringId)); BizWrf wrf = bizWrfMapper.selectOne(new LambdaQueryWrapper<BizWrf>().eq(BizWrf::getEngineeringId,engineeringId));
String allRunPath = baseHome + wrf.getCreateBy() + wrf.getEngineeringId() + "/" + wrf.getTimeStamp() + "/"; String allRunPath = baseHome + wrf.getCreateBy() + wrf.getEngineeringId() + "/" + wrf.getTimeStamp() + "/";
String targetFilePath = localFilePrefix + wrf.getCreateBy() + wrf.getEngineeringId() + "/" + "MCIP/";
try { try {
// todo step1 mcip // todo step1 mcip
String mcipFileName = genMcipsShell(allRunPath,wrf.getStartTime().substring(0, 10),wrf.getEndTime().substring(0, 10),wrf.getMaxDom(),cmaq.getColsN(),cmaq.getRowsN()); String mcipFileName = genMcipsShell(allRunPath,targetFilePath,wrf.getStartTime().substring(0, 10),wrf.getEndTime().substring(0, 10),wrf.getMaxDom(),cmaq.getColsN(),cmaq.getRowsN());
// todo 执行mcip.csh // todo 执行mcip.csh
runCmd(allRunPath + "CMAQ/","PREP/mcip",mcipFileName); runCmd(allRunPath + "CMAQ/","PREP/mcip",mcipFileName);
} catch (Exception e) { } catch (Exception e) {
@ -166,9 +161,10 @@ public class BizCmaqServiceImpl extends ServiceImpl<BizCmaqMapper, BizCmaq> impl
public boolean runIconShell(String engineeringId) { public boolean runIconShell(String engineeringId) {
BizWrf wrf = bizWrfMapper.selectOne(new LambdaQueryWrapper<BizWrf>().eq(BizWrf::getEngineeringId,engineeringId)); BizWrf wrf = bizWrfMapper.selectOne(new LambdaQueryWrapper<BizWrf>().eq(BizWrf::getEngineeringId,engineeringId));
String allRunPath = baseHome + wrf.getCreateBy() + wrf.getEngineeringId() + "/" + wrf.getTimeStamp() + "/"; String allRunPath = baseHome + wrf.getCreateBy() + wrf.getEngineeringId() + "/" + wrf.getTimeStamp() + "/";
String targetFilePath = localFilePrefix + wrf.getCreateBy() + wrf.getEngineeringId() + "/" + "ICON/";
try { try {
// todo step2 icon // todo step2 icon
String iconFileName = genIconShell(allRunPath,wrf.getStartTime().substring(0, 10),wrf.getEndTime().substring(0, 10),wrf.getMaxDom()); String iconFileName = genIconShell(allRunPath,targetFilePath,wrf.getStartTime().substring(0, 10),wrf.getEndTime().substring(0, 10),wrf.getMaxDom());
// todo 执行icon.csh // todo 执行icon.csh
runCmd(allRunPath + "CMAQ/","PREP/icon",iconFileName); runCmd(allRunPath + "CMAQ/","PREP/icon",iconFileName);
} catch (Exception e) { } catch (Exception e) {
@ -181,9 +177,10 @@ public class BizCmaqServiceImpl extends ServiceImpl<BizCmaqMapper, BizCmaq> impl
public boolean runBconShell(String engineeringId) { public boolean runBconShell(String engineeringId) {
BizWrf wrf = bizWrfMapper.selectOne(new LambdaQueryWrapper<BizWrf>().eq(BizWrf::getEngineeringId,engineeringId)); BizWrf wrf = bizWrfMapper.selectOne(new LambdaQueryWrapper<BizWrf>().eq(BizWrf::getEngineeringId,engineeringId));
String allRunPath = baseHome + wrf.getCreateBy() + wrf.getEngineeringId() + "/" + wrf.getTimeStamp() + "/"; String allRunPath = baseHome + wrf.getCreateBy() + wrf.getEngineeringId() + "/" + wrf.getTimeStamp() + "/";
String targetFilePath = localFilePrefix + wrf.getCreateBy() + wrf.getEngineeringId() + "/" + "BCON/";
try { try {
// todo step2 bcon // todo step2 bcon
String iconFileName = genBconShell(allRunPath,wrf.getStartTime().substring(0, 10),wrf.getEndTime().substring(0, 10),wrf.getMaxDom()); String iconFileName = genBconShell(allRunPath,targetFilePath,wrf.getStartTime().substring(0, 10),wrf.getEndTime().substring(0, 10),wrf.getMaxDom());
// todo 执行bcon.csh // todo 执行bcon.csh
runCmd(allRunPath + "CMAQ/","PREP/bcon",iconFileName); runCmd(allRunPath + "CMAQ/","PREP/bcon",iconFileName);
} catch (Exception e) { } catch (Exception e) {
@ -210,6 +207,7 @@ public class BizCmaqServiceImpl extends ServiceImpl<BizCmaqMapper, BizCmaq> impl
BizCmaq cmaq = getOne(new LambdaQueryWrapper<BizCmaq>().eq(BizCmaq::getEngineeringId,engineeringId)); BizCmaq cmaq = getOne(new LambdaQueryWrapper<BizCmaq>().eq(BizCmaq::getEngineeringId,engineeringId));
BizOpenfoam openfoam = bizOpenfoamService.getOne(new LambdaQueryWrapper<BizOpenfoam>().eq(BizOpenfoam::getEngineeringId, engineeringId)); BizOpenfoam openfoam = bizOpenfoamService.getOne(new LambdaQueryWrapper<BizOpenfoam>().eq(BizOpenfoam::getEngineeringId, engineeringId));
String allRunPath = baseHome + wrf.getCreateBy() + wrf.getEngineeringId() + "/" + wrf.getTimeStamp() + "/"; String allRunPath = baseHome + wrf.getCreateBy() + wrf.getEngineeringId() + "/" + wrf.getTimeStamp() + "/";
String targetFilePath = localFilePrefix + wrf.getCreateBy() + wrf.getEngineeringId() + "/" + "CCTM/";
String ymdFormat = "yyyy-MM-dd"; String ymdFormat = "yyyy-MM-dd";
String yymdFormat = "yyMMdd"; String yymdFormat = "yyMMdd";
@ -248,14 +246,14 @@ public class BizCmaqServiceImpl extends ServiceImpl<BizCmaqMapper, BizCmaq> impl
} }
try { try {
// todo step2 cctm // todo step2 cctm
String cctmFileName = genCctmShell(allRunPath,newStartTime,newEndTime,cmaq.getSttime(), cmaq.getNsteps(), cmaq.getTstep()); String cctmFileName = genCctmShell(allRunPath,targetFilePath,newStartTime,newEndTime,cmaq.getSttime(), cmaq.getNsteps(), cmaq.getTstep());
// todo 执行cctm.csh // todo 执行cctm.csh
runCmd(allRunPath + "CMAQ/","CCTM",cctmFileName); runCmd(allRunPath + "CMAQ/","CCTM",cctmFileName);
String ncName = "CCTM_ACONC_v532_2016_12SE1_"+newStartTime.replace("-","")+".nc"; String ncName = "CCTM_ACONC_v532_2016_12SE1_"+newStartTime.replace("-","")+".nc";
String ncLocalName = "CCTM_ACONC_v532_2016_12SE1_"+DateUtil.format(new Date(startTimeSecs), ymdFormat).replace("-","")+".nc"; String ncLocalName = "CCTM_ACONC_v532_2016_12SE1_"+DateUtil.format(new Date(startTimeSecs), ymdFormat).replace("-","")+".nc";
SFTPUtil sftpUtil = new SFTPUtil(); SFTPUtil sftpUtil = new SFTPUtil();
sftpUtil.login(username, password,ip,port); sftpUtil.login(username, password,ip,port);
sftpUtil.download(allRunPath + "CMAQ/data/output/v532_2016_12SE1/",ncName,outputLocalPath + ncLocalName); sftpUtil.download(allRunPath + "CMAQ/data/output/v532_2016_12SE1/",ncName,localFilePrefix + ncLocalName);
sftpUtil.logout(); sftpUtil.logout();
} catch (Exception e) { } catch (Exception e) {
return false; return false;
@ -275,10 +273,10 @@ public class BizCmaqServiceImpl extends ServiceImpl<BizCmaqMapper, BizCmaq> impl
NetcdfFile griddot2d = NetcdfDataset.open("C:\\Users\\13673\\Desktop\\某源\\Nuclear\\file\\wrfout_d01_2016-07-01_00_00_00"); NetcdfFile griddot2d = NetcdfDataset.open("C:\\Users\\13673\\Desktop\\某源\\Nuclear\\file\\wrfout_d01_2016-07-01_00_00_00");
NetcdfFile ncfile = NetcdfDataset.open("C:\\Users\\13673\\Desktop\\某源\\Nuclear\\file\\CCTM_ACONC_v532_2016_12SE1_20160701.nc"); NetcdfFile ncfile = NetcdfDataset.open("C:\\Users\\13673\\Desktop\\某源\\Nuclear\\file\\CCTM_ACONC_v532_2016_12SE1_20160701.nc");
// String ncName = "CCTM_ACONC_v532_2016_12SE1_" + sdf.format(sdf.parse(bizCmaq.getStartDate())).replace("-", "") + ".nc"; // String ncName = "CCTM_ACONC_v532_2016_12SE1_" + sdf.format(sdf.parse(bizCmaq.getStartDate())).replace("-", "") + ".nc";
// NetcdfFile ncfile = NetcdfDataset.open(outputLocalPath + ncName); // NetcdfFile ncfile = NetcdfDataset.open(localFilePrefix + ncName);
// BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper<BizWrf>().eq(BizWrf::getEngineeringId, bizEngineeringByState.getId())); // BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper<BizWrf>().eq(BizWrf::getEngineeringId, bizEngineeringByState.getId()));
// String ncNameWrf = "wrfout_d01_" + bizWrf.getStartTime(); // String ncNameWrf = "wrfout_d01_" + bizWrf.getStartTime();
// NetcdfFile griddot2d = NetcdfDataset.open(wrfLocalPrefix + ncNameWrf); // NetcdfFile griddot2d = NetcdfDataset.open(localFilePrefix + ncNameWrf);
List<List<List<Double>>> coAllList = getNCByName(ncfile, "CO", layer); List<List<List<Double>>> coAllList = getNCByName(ncfile, "CO", layer);
List<List<List<Double>>> no2AllList = getNCByName(ncfile, "NO2", layer); List<List<List<Double>>> no2AllList = getNCByName(ncfile, "NO2", layer);
List<List<List<Double>>> no3AllList = getNCByName(ncfile, "NO3", layer); List<List<List<Double>>> no3AllList = getNCByName(ncfile, "NO3", layer);
@ -332,7 +330,7 @@ public class BizCmaqServiceImpl extends ServiceImpl<BizCmaqMapper, BizCmaq> impl
String newStartTime = DateUtil.format(new Date(startTimeSecs + oneDaySecs), ymdFormat); String newStartTime = DateUtil.format(new Date(startTimeSecs + oneDaySecs), ymdFormat);
String ncName = "CCTM_ACONC_v532_2016_12SE1_" + newStartTime.replace("-", "") + ".nc"; String ncName = "CCTM_ACONC_v532_2016_12SE1_" + newStartTime.replace("-", "") + ".nc";
try { try {
NetcdfFile ncfile = NetcdfDataset.open(outputLocalPath + ncName); NetcdfFile ncfile = NetcdfDataset.open(localFilePrefix + ncName);
List<Variable> variables = ncfile.getVariables(); List<Variable> variables = ncfile.getVariables();
variables.forEach(li ->{ variables.forEach(li ->{
variableNames.add(li.getShortName()); variableNames.add(li.getShortName());

View File

@ -80,7 +80,7 @@ public class BizOpenfoamController extends JeecgController<BizOpenfoam, IBizOpen
@Value("${spring.baseHome}") @Value("${spring.baseHome}")
private String baseHome; private String baseHome;
@Value("${spring.CMAQ.cshTemFielPath}") @Value("${spring.cshTemFielPath}")
private String cshTemFielPath; private String cshTemFielPath;
@Value("${spring.Linux.ip}") @Value("${spring.Linux.ip}")
private String ip; private String ip;

View File

@ -41,14 +41,14 @@ public class BizUpdateFileController extends JeecgController<BizUploadFile, BizU
@Autowired @Autowired
private BizUploadFileService bizUploadFileService; private BizUploadFileService bizUploadFileService;
@Value("${spring.WRF.wpsLocalPrefix}") @Value("${spring.localFilePrefix}")
private String wpsLocalPrefix; private String localFilePrefix;
@PostMapping(value = "/uploadFile") @PostMapping(value = "/uploadFile")
public boolean uploadFile(@RequestParam String relevanceId, @RequestParam Integer type, @RequestParam List<MultipartFile> files) { public boolean uploadFile(@RequestParam String relevanceId, @RequestParam Integer type, @RequestParam List<MultipartFile> files) {
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
try{ try{
// String localFilePrefix = wpsLocalPrefix + loginUser.getUsername() + "/" + relevanceId + "/"; // String localFilePrefix = localFilePrefix + loginUser.getUsername() + "/" + relevanceId + "/";
String localFilePrefix = "D:\\upload\\" + loginUser.getUsername() + "/" + relevanceId + "/"; String localFilePrefix = "D:\\upload\\" + loginUser.getUsername() + "/" + relevanceId + "/";
if (!FileUtil.exist(localFilePrefix)) { if (!FileUtil.exist(localFilePrefix)) {
FileUtil.mkdir(localFilePrefix); FileUtil.mkdir(localFilePrefix);

View File

@ -19,8 +19,8 @@ import java.util.List;
@Service @Service
public class BizUploadFileServiceImpl extends ServiceImpl<BizUploadFileMapper, BizUploadFile> implements BizUploadFileService { public class BizUploadFileServiceImpl extends ServiceImpl<BizUploadFileMapper, BizUploadFile> implements BizUploadFileService {
@Value("${spring.WRF.wpsLocalPrefix}") @Value("${spring.localFilePrefix}")
private String wpsLocalPrefix; private String localFilePrefix;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -39,13 +39,13 @@ public class BizUploadFileServiceImpl extends ServiceImpl<BizUploadFileMapper, B
bizUploadFile.setFilePath(dbDir); bizUploadFile.setFilePath(dbDir);
// 全路径 // 全路径
String descDir = ""; String descDir = "";
wpsLocalPrefix = "D:\\upload\\"; localFilePrefix = "D:\\upload\\";
if(type == 1){ if(type == 1){
descDir = wpsLocalPrefix + userName + "/" + relevanceId; descDir = localFilePrefix + userName + "/" + relevanceId;
}else if (type == 1){ }else if (type == 1){
descDir = wpsLocalPrefix + userName + "/" + relevanceId; descDir = localFilePrefix + userName + "/" + relevanceId;
}else{ }else{
descDir = wpsLocalPrefix + userName + "/" + relevanceId; descDir = localFilePrefix + userName + "/" + relevanceId;
} }
bizUploadFile.setFileFullPath(descDir); bizUploadFile.setFileFullPath(descDir);
//删除之前导入的相同类型数据 //删除之前导入的相同类型数据

View File

@ -86,11 +86,9 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
@Value("${spring.baseHome}") @Value("${spring.baseHome}")
private String baseHome; private String baseHome;
@Value("${spring.WRF.wpsLocalPrefix}") @Value("${spring.localFilePrefix}")
private String wpsLocalPrefix; private String localFilePrefix;
@Value("${spring.WRF.wrfLocalPrefix}") @Value("${spring.cshTemFielPath}")
private String wrfLocalPrefix;
@Value("${spring.CMAQ.cshTemFielPath}")
private String cshTemFielPath; private String cshTemFielPath;
@Value("${spring.WRF.geog_data_path}") @Value("${spring.WRF.geog_data_path}")
private String geog_data_path; private String geog_data_path;
@ -172,7 +170,7 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
public void saveWpsFile(BizWrf bizWrf){ public void saveWpsFile(BizWrf bizWrf){
String allRunPath = baseHome + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/" + bizWrf.getTimeStamp() + "/"; String allRunPath = baseHome + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/" + bizWrf.getTimeStamp() + "/";
String localFilePrefix = wpsLocalPrefix + "/" + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/"; String localFilePath = localFilePrefix + "/" + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/";
String fileName = "namelist.wps"; String fileName = "namelist.wps";
try { try {
String startStr = ""; String startStr = "";
@ -209,8 +207,8 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
.replace("#{geog_data_path}", geog_data_path) .replace("#{geog_data_path}", geog_data_path)
.replace("#{opt_output_from_metgrid_path}",allRunPath+"WRF/run"); .replace("#{opt_output_from_metgrid_path}",allRunPath+"WRF/run");
// todo sftp 上传 // todo sftp 上传
FileUtil.writeString(data, localFilePrefix + fileName, "UTF-8"); FileUtil.writeString(data, localFilePath + fileName, "UTF-8");
sftpUpload(localFilePrefix + fileName, allRunPath + "WPS", fileName); sftpUpload(localFilePath + fileName, allRunPath + "WPS", fileName);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -218,7 +216,7 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
public void saveInputFile(BizWrf bizWrf){ public void saveInputFile(BizWrf bizWrf){
String allRunPath = baseHome + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/" + bizWrf.getTimeStamp() + "/"; String allRunPath = baseHome + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/" + bizWrf.getTimeStamp() + "/";
String localFilePrefix = wpsLocalPrefix + "/" + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/"; String localFilePath = localFilePrefix + "/" + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/";
try { try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
Calendar startCal = Calendar.getInstance(); Calendar startCal = Calendar.getInstance();
@ -294,8 +292,8 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
.replace("#{j_parent_start}", bizWrf.getParentStartJ()) .replace("#{j_parent_start}", bizWrf.getParentStartJ())
.replace("#{parent_grid_ratio}", bizWrf.getParentGridRatio()); .replace("#{parent_grid_ratio}", bizWrf.getParentGridRatio());
// todo sftp 上传 // todo sftp 上传
FileUtil.writeString(data, localFilePrefix + fileName, "UTF-8"); FileUtil.writeString(data, localFilePath + fileName, "UTF-8");
sftpUpload(localFilePrefix + fileName, allRunPath + "WRF/run", fileName); sftpUpload(localFilePath + fileName, allRunPath + "WRF/run", fileName);
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} catch (SftpException e) { } catch (SftpException e) {
@ -317,7 +315,7 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
String engineeringId = bizEngineeringService.getBizEngineeringByState().getId(); String engineeringId = bizEngineeringService.getBizEngineeringByState().getId();
BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper<BizWrf>().eq(BizWrf::getEngineeringId,engineeringId)); BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper<BizWrf>().eq(BizWrf::getEngineeringId,engineeringId));
String allRunPath = baseHome + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/" + bizWrf.getTimeStamp() + "/"; String allRunPath = baseHome + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/" + bizWrf.getTimeStamp() + "/";
String localFilePrefix = wpsLocalPrefix + "/" + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/"; String localFilePath = localFilePrefix + "/" + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/";
String format = "yyyy-MM-dd_hh:mm:ss"; String format = "yyyy-MM-dd_hh:mm:ss";
String ymdFormat = "yyyy-MM-dd"; String ymdFormat = "yyyy-MM-dd";
@ -338,9 +336,9 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, cdWPS + "./metgrid.exe"); RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, cdWPS + "./metgrid.exe");
SFTPUtil sftpUtil = new SFTPUtil(); SFTPUtil sftpUtil = new SFTPUtil();
sftpUtil.login(username, password,ip,port); sftpUtil.login(username, password,ip,port);
sftpUtil.download(allRunPath + "WPS","metgrid.log",localFilePrefix + "metgrid.log"); sftpUtil.download(allRunPath + "WPS","metgrid.log",localFilePath + "metgrid.log");
sftpUtil.logout(); sftpUtil.logout();
String metgridLog = new String(readAllBytes(get(localFilePrefix + "metgrid.log"))); String metgridLog = new String(readAllBytes(get(localFilePath + "metgrid.log")));
if(metgridLog.indexOf("Successful completion of program metgrid.exe") > 0){ if(metgridLog.indexOf("Successful completion of program metgrid.exe") > 0){
return Result.OK(metgridLog); return Result.OK(metgridLog);
} }
@ -357,7 +355,7 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
String engineeringId = bizEngineeringService.getBizEngineeringByState().getId(); String engineeringId = bizEngineeringService.getBizEngineeringByState().getId();
BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper<BizWrf>().eq(BizWrf::getEngineeringId,engineeringId)); BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper<BizWrf>().eq(BizWrf::getEngineeringId,engineeringId));
String allRunPath = baseHome + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/" + bizWrf.getTimeStamp() + "/"; String allRunPath = baseHome + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/" + bizWrf.getTimeStamp() + "/";
String localFilePrefix = wpsLocalPrefix + "/" + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/"; String localFilePath = localFilePrefix + "/" + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/";
String cdWRF = "cd " + allRunPath + "WRF/run;"; String cdWRF = "cd " + allRunPath + "WRF/run;";
RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, cdWRF + "ulimit -s unlimited;./real.exe >&real.log"); RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, cdWRF + "ulimit -s unlimited;./real.exe >&real.log");
@ -365,17 +363,17 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
SFTPUtil sftpUtil = new SFTPUtil(); SFTPUtil sftpUtil = new SFTPUtil();
sftpUtil.login(username, password,ip,port); sftpUtil.login(username, password,ip,port);
sftpUtil.download(allRunPath + "WRF/run","wrf.log",localFilePrefix + "wrf.log"); sftpUtil.download(allRunPath + "WRF/run","wrf.log",localFilePath + "wrf.log");
String wrfLog = new String(readAllBytes(get(localFilePrefix + "wrf.log"))); String wrfLog = new String(readAllBytes(get(localFilePath + "wrf.log")));
// sftpUtil.download(allRunPath + "WRF/run","rsl.out.0000",localFilePrefix + "rsl.out.0000"); // sftpUtil.download(allRunPath + "WRF/run","rsl.out.0000",localFilePath + "rsl.out.0000");
// String wrfLog = new String(readAllBytes(get(localFilePrefix + "rsl.out.0000"))); // String wrfLog = new String(readAllBytes(get(localFilePath + "rsl.out.0000")));
if(wrfLog.indexOf("SUCCESS COMPLETE WRF") > 0){ if(wrfLog.indexOf("SUCCESS COMPLETE WRF") > 0){
String format = "yyyy-MM-dd_HH:mm:ss"; String format = "yyyy-MM-dd_HH:mm:ss";
DateTime startTime = DateUtil.parse(bizWrf.getStartTime(), format); DateTime startTime = DateUtil.parse(bizWrf.getStartTime(), format);
long oneDaySecs = 60 * 60 * 24 * 1000; long oneDaySecs = 60 * 60 * 24 * 1000;
String newStartTime = DateUtil.format(new Date(startTime.getTime() + oneDaySecs), format); String newStartTime = DateUtil.format(new Date(startTime.getTime() + oneDaySecs), format);
String ncNameWrf = "wrfout_d01_" + newStartTime; String ncNameWrf = "wrfout_d01_" + newStartTime;
sftpUtil.download(allRunPath + "WRF/run/",ncNameWrf,localFilePrefix + ncNameWrf); sftpUtil.download(allRunPath + "WRF/run/",ncNameWrf,localFilePath + ncNameWrf);
sftpUtil.logout(); sftpUtil.logout();
return Result.OK("SUCCESS COMPLETE WRF"); return Result.OK("SUCCESS COMPLETE WRF");
}else{ }else{
@ -386,7 +384,7 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
// long oneDaySecs = 60 * 60 * 24 * 1000; // long oneDaySecs = 60 * 60 * 24 * 1000;
// String newStartTime = DateUtil.format(new Date(startTime.getTime() + oneDaySecs), format); // String newStartTime = DateUtil.format(new Date(startTime.getTime() + oneDaySecs), format);
// String ncNameWrf = "wrfout_d01_" + newStartTime; // String ncNameWrf = "wrfout_d01_" + newStartTime;
// sftpUtil.download(allRunPath + "WRF/run/",ncNameWrf,wrfLocalPrefix + ncNameWrf); // sftpUtil.download(allRunPath + "WRF/run/",ncNameWrf,localFilePrefix + ncNameWrf);
// sftpUtil.logout(); // sftpUtil.logout();
// return Result.OK("SUCCESS COMPLETE WRF"); // return Result.OK("SUCCESS COMPLETE WRF");
return Result.error(wrfLog); return Result.error(wrfLog);
@ -403,14 +401,14 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
String engineeringId = bizEngineeringService.getBizEngineeringByState().getId(); String engineeringId = bizEngineeringService.getBizEngineeringByState().getId();
BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper<BizWrf>().eq(BizWrf::getEngineeringId,engineeringId)); BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper<BizWrf>().eq(BizWrf::getEngineeringId,engineeringId));
String allRunPath = baseHome + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/" + bizWrf.getTimeStamp() + "/"; String allRunPath = baseHome + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/" + bizWrf.getTimeStamp() + "/";
String localFilePrefix = wpsLocalPrefix + "/" + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/"; String localFilePath = localFilePrefix + "/" + bizWrf.getCreateBy() + bizWrf.getEngineeringId() + "/";
SFTPUtil sftpUtil = new SFTPUtil(); SFTPUtil sftpUtil = new SFTPUtil();
sftpUtil.login(username, password,ip,port); sftpUtil.login(username, password,ip,port);
// sftpUtil.download(allRunPath + "WRF/run/","rsl.out.0000",wrfLocalPrefix + "rsl.out.0000"); // sftpUtil.download(allRunPath + "WRF/run/","rsl.out.0000",localFilePrefix + "rsl.out.0000");
sftpUtil.download(allRunPath + "WRF/run","wrf.log",localFilePrefix + "wrf.log"); sftpUtil.download(allRunPath + "WRF/run","wrf.log",localFilePath + "wrf.log");
sftpUtil.logout(); sftpUtil.logout();
String wrfLog = new String(readAllBytes(get(localFilePrefix + "wrf.log"))); String wrfLog = new String(readAllBytes(get(localFilePath + "wrf.log")));
// String wrfLog = new String(readAllBytes(get("C:\\Users\\13673\\Desktop\\Nuclear\\file\\wrf.log"))); // String wrfLog = new String(readAllBytes(get("C:\\Users\\13673\\Desktop\\Nuclear\\file\\wrf.log")));
return Result.OK(wrfLog); return Result.OK(wrfLog);
}catch (Exception e){ }catch (Exception e){
@ -438,7 +436,7 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
// long oneDaySecs = 60 * 60 * 24 * 1000; // long oneDaySecs = 60 * 60 * 24 * 1000;
// String newStartTime = DateUtil.format(new Date(startTime.getTime() + oneDaySecs), format); // String newStartTime = DateUtil.format(new Date(startTime.getTime() + oneDaySecs), format);
// String ncNameWrf = "wrfout_d01_" + newStartTime; // String ncNameWrf = "wrfout_d01_" + newStartTime;
// NetcdfFile ncfile = NetcdfDataset.open(wrfLocalPrefix + ncNameWrf); // NetcdfFile ncfile = NetcdfDataset.open(localFilePrefix + ncNameWrf);
List<List<List<Double>>> xlatAllList = getNCByName(ncfile, "XLAT",layer); List<List<List<Double>>> xlatAllList = getNCByName(ncfile, "XLAT",layer);
List<List<List<Double>>> xlongAllList = getNCByName(ncfile, "XLONG",layer); List<List<List<Double>>> xlongAllList = getNCByName(ncfile, "XLONG",layer);
List<List<List<Double>>> uAllList = getNCByName(ncfile, "U",layer); List<List<List<Double>>> uAllList = getNCByName(ncfile, "U",layer);
@ -499,7 +497,7 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
// long oneDaySecs = 60 * 60 * 24 * 1000; // long oneDaySecs = 60 * 60 * 24 * 1000;
// String newStartTime = DateUtil.format(new Date(startTime.getTime() + oneDaySecs), format); // String newStartTime = DateUtil.format(new Date(startTime.getTime() + oneDaySecs), format);
// String ncNameWrf = "wrfout_d01_" + newStartTime; // String ncNameWrf = "wrfout_d01_" + newStartTime;
// NetcdfFile ncfile = NetcdfDataset.open(wrfLocalPrefix + ncNameWrf); // NetcdfFile ncfile = NetcdfDataset.open(localFilePrefix + ncNameWrf);
List<List<List<Double>>> hgtAllList = getNCByName(ncfile, "HGT",0); List<List<List<Double>>> hgtAllList = getNCByName(ncfile, "HGT",0);
List<List<List<Double>>> xlatAllList = getNCByName(ncfile, "XLAT",0); List<List<List<Double>>> xlatAllList = getNCByName(ncfile, "XLAT",0);
List<List<List<Double>>> xlongAllList = getNCByName(ncfile, "XLONG",0); List<List<List<Double>>> xlongAllList = getNCByName(ncfile, "XLONG",0);
@ -550,7 +548,7 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
long oneDaySecs = 60 * 60 * 24 * 1000; long oneDaySecs = 60 * 60 * 24 * 1000;
String newStartTime = DateUtil.format(new Date(startTime.getTime() + oneDaySecs), format); String newStartTime = DateUtil.format(new Date(startTime.getTime() + oneDaySecs), format);
String ncNameWrf = "wrfout_d01_" + newStartTime; String ncNameWrf = "wrfout_d01_" + newStartTime;
NetcdfFile ncfile = NetcdfDataset.open(wrfLocalPrefix + ncNameWrf); NetcdfFile ncfile = NetcdfDataset.open(localFilePrefix + ncNameWrf);
List<List<List<Double>>> uAllList = getNCByName(ncfile, "U",0); List<List<List<Double>>> uAllList = getNCByName(ncfile, "U",0);
List<List<List<Double>>> vAllList = getNCByName(ncfile, "V",0); List<List<List<Double>>> vAllList = getNCByName(ncfile, "V",0);
List<List<List<Double>>> pAllList = getNCByName(ncfile, "P",0); List<List<List<Double>>> pAllList = getNCByName(ncfile, "P",0);

View File

@ -20,21 +20,18 @@ management:
include: metrics,httptrace include: metrics,httptrace
spring: spring:
baseHome: /home/openfoam/ baseHome: /home/wmhr/
cshTemFielPath: /home/wmhr/java/tem/
localFilePrefix: /home/wmhr/java/file/
WRF: WRF:
wpsLocalPrefix: /home/openfoam/java/file/ geog_data_path: /home/wmhr/Build_WRF/WPS_GEOG
wrfLocalPrefix: /home/openfoam/java/file/ fnldataPath: /home/wmhr/Build_WRF/WPS/fnldata/
geog_data_path: /home/openfoam/Build_WRF/WPS_GEOG
fnldataPath: /home/openfoam/Build_WRF/WPS/fnldata/
CMAQ: CMAQ:
cmaqLocalShellHome: /home/openfoam/java/file/ pythonPath: /home/wmhr/python/
outputLocalPath: /home/openfoam/java/file/
cshTemFielPath: /home/openfoam/java/tem/
pythonPath: /home/openfoam/python/
Linux: Linux:
ip: 127.0.0.1 ip: 192.168.115.128
username: openfoam username: wmhr
password: root password: 123456
port: 22 port: 22
servlet: servlet:
multipart: multipart: