9.23前后端代码提交
详情见周总结
This commit is contained in:
parent
b1a6e345ac
commit
ff0e7ceac7
|
@ -0,0 +1,18 @@
|
||||||
|
package org.jeecg.modules.project.calculateConfig.baseAPI.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.jeecg.modules.project.calculateConfig.bizConfigChemistry.entity.BizConfigChemistry;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 化爆配置表
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2023-09-20
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface IBizBaseAPIService {
|
||||||
|
|
||||||
|
int getLayerByHeight(String enginId,Integer height) throws IOException;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
package org.jeecg.modules.project.calculateConfig.baseAPI.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.jeecg.modules.project.baseConfig.bizEngineering.entity.BizEngineering;
|
||||||
|
import org.jeecg.modules.project.baseConfig.bizEngineering.service.IBizEngineeringService;
|
||||||
|
import org.jeecg.modules.project.calculateConfig.baseAPI.service.IBizBaseAPIService;
|
||||||
|
import org.jeecg.modules.project.calculateConfig.bizConfigChemistry.entity.BizConfigChemistry;
|
||||||
|
import org.jeecg.modules.project.calculateConfig.bizConfigChemistry.mapper.BizConfigChemistryMapper;
|
||||||
|
import org.jeecg.modules.project.calculateConfig.bizWrf.entity.BizWrf;
|
||||||
|
import org.jeecg.modules.project.calculateConfig.bizWrf.mapper.BizWrfMapper;
|
||||||
|
import org.jeecg.modules.project.calculateConfig.bizWrf.service.IBizWrfService;
|
||||||
|
import org.jeecg.modules.util.NcUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import ucar.nc2.NetcdfFile;
|
||||||
|
import ucar.nc2.dataset.NetcdfDataset;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 化爆配置表
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2023-09-20
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class BizBaseAPIServiceImpl implements IBizBaseAPIService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BizWrfMapper bizWrfService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBizEngineeringService bizEngineeringService;
|
||||||
|
|
||||||
|
@Value("${spring.baseHome}")
|
||||||
|
private String baseHome;
|
||||||
|
@Value("${spring.localFilePrefix}")
|
||||||
|
private String localFilePrefix;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLayerByHeight(String enginId,Integer height) throws IOException {
|
||||||
|
BizEngineering engineering = bizEngineeringService.getById(enginId);
|
||||||
|
BizWrf bizWrf = bizWrfService.selectOne(new LambdaQueryWrapper<BizWrf>().eq(BizWrf::getEngineeringId, enginId));
|
||||||
|
String localFilePath = localFilePrefix + "/" + engineering.getCreateBy() + "/" + engineering.getEngineeringName() + "/";
|
||||||
|
|
||||||
|
DateTime startTime = DateUtil.parse(bizWrf.getStartTime(), "yyyy-MM-dd_hh:mm:ss");
|
||||||
|
String metcr03dName= "METCRO3D_d01_" + DateUtil.format(new Date(startTime.getTime()), "yyMMdd")+".nc";
|
||||||
|
|
||||||
|
NetcdfFile ncfile = NetcdfDataset.open(localFilePath + metcr03dName);
|
||||||
|
NcUtil.getNCByName(ncfile,"ZF",0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,7 @@ import org.jeecg.modules.project.baseConfig.bizEngineering.entity.BizEngineering
|
||||||
import org.jeecg.modules.project.baseConfig.bizEngineering.service.IBizEngineeringService;
|
import org.jeecg.modules.project.baseConfig.bizEngineering.service.IBizEngineeringService;
|
||||||
import org.jeecg.modules.project.calculateConfig.bizOpenfoam.entity.BizOpenfoam;
|
import org.jeecg.modules.project.calculateConfig.bizOpenfoam.entity.BizOpenfoam;
|
||||||
import org.jeecg.modules.project.calculateConfig.bizOpenfoam.service.IBizOpenfoamService;
|
import org.jeecg.modules.project.calculateConfig.bizOpenfoam.service.IBizOpenfoamService;
|
||||||
|
import org.jeecg.modules.util.NcUtil;
|
||||||
import org.jeecg.modules.util.SFTPUtil;
|
import org.jeecg.modules.util.SFTPUtil;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.jeecg.modules.project.calculateConfig.bizWrf.entity.BizWrf;
|
import org.jeecg.modules.project.calculateConfig.bizWrf.entity.BizWrf;
|
||||||
|
@ -269,6 +270,8 @@ public class BizCmaqServiceImpl extends ServiceImpl<BizCmaqMapper, BizCmaq> impl
|
||||||
// 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.download(allRunPath + "CMAQ/data/output/v532_2016_12SE1/",ncName,targetFilePath + ncName);
|
sftpUtil.download(allRunPath + "CMAQ/data/output/v532_2016_12SE1/",ncName,targetFilePath + ncName);
|
||||||
}
|
}
|
||||||
|
String metcr03dName= "METCRO3D_d01_" + DateUtil.format(new Date(startTimeSecs), yymdFormat)+".nc";
|
||||||
|
sftpUtil.download(allRunPath + "CMAQ/data/input/mcip/",metcr03dName,targetFilePath + metcr03dName);
|
||||||
sftpUtil.logout();
|
sftpUtil.logout();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
bizEngineeringService.updateErrorStatus(engineeringId,9);
|
bizEngineeringService.updateErrorStatus(engineeringId,9);
|
||||||
|
@ -298,11 +301,11 @@ public class BizCmaqServiceImpl extends ServiceImpl<BizCmaqMapper, BizCmaq> impl
|
||||||
// String ncNameWrf = "wrfout_d01_" + bizWrf.getStartTime();
|
// String ncNameWrf = "wrfout_d01_" + bizWrf.getStartTime();
|
||||||
String ncNameWrf = "wrfout_d01_2016-07-01_00_00_00";
|
String ncNameWrf = "wrfout_d01_2016-07-01_00_00_00";
|
||||||
NetcdfFile griddot2d = NetcdfDataset.open(targetFilePath + ncNameWrf);
|
NetcdfFile griddot2d = NetcdfDataset.open(targetFilePath + ncNameWrf);
|
||||||
List<List<List<Double>>> coAllList = getNCByName(ncfile, "CO", layer);
|
List<List<List<Double>>> coAllList = NcUtil.getNCByName(ncfile, "CO", layer);
|
||||||
List<List<List<Double>>> no2AllList = getNCByName(ncfile, "NO2", layer);
|
List<List<List<Double>>> no2AllList = NcUtil.getNCByName(ncfile, "NO2", layer);
|
||||||
List<List<List<Double>>> no3AllList = getNCByName(ncfile, "NO3", layer);
|
List<List<List<Double>>> no3AllList = NcUtil.getNCByName(ncfile, "NO3", layer);
|
||||||
List<List<List<Double>>> xlatAllList = getNCByName(griddot2d, "XLAT", layer);
|
List<List<List<Double>>> xlatAllList = NcUtil.getNCByName(griddot2d, "XLAT", layer);
|
||||||
List<List<List<Double>>> xlongAllList = getNCByName(griddot2d, "XLONG", layer);
|
List<List<List<Double>>> xlongAllList = NcUtil.getNCByName(griddot2d, "XLONG", layer);
|
||||||
|
|
||||||
for (int l = 0; l < coAllList.size(); l++) {
|
for (int l = 0; l < coAllList.size(); l++) {
|
||||||
List<Double[]> result = new ArrayList<>();
|
List<Double[]> result = new ArrayList<>();
|
||||||
|
@ -406,72 +409,4 @@ public class BizCmaqServiceImpl extends ServiceImpl<BizCmaqMapper, BizCmaq> impl
|
||||||
sftpUtil.logout();
|
sftpUtil.logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<List<List<Double>>> getNCByName(NetcdfFile ncfile, String name,int layer){
|
|
||||||
Variable variable = ncfile.findVariable(name);
|
|
||||||
List<List<List<Double>>> resultAll = new ArrayList<>();
|
|
||||||
|
|
||||||
// 读取nc数据到数组
|
|
||||||
Array data = null;
|
|
||||||
try {
|
|
||||||
data = variable.read();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
// 获取参数和索引,其中shape的前三个参数分别是时间、纬度、经度
|
|
||||||
int[] shape = data.getShape();
|
|
||||||
Index index = data.getIndex();
|
|
||||||
|
|
||||||
// 将三维数组降维,并用String数组提取数据
|
|
||||||
// 按时间
|
|
||||||
// 按维度
|
|
||||||
if(shape.length == 3){
|
|
||||||
// 将三维数组降维,并用String数组提取数据
|
|
||||||
// 按时间
|
|
||||||
// 按维度
|
|
||||||
for (int i = 0; i < shape[0]; i++) {
|
|
||||||
List<List<Double>> resultPiece = new ArrayList<>();
|
|
||||||
for (int j = 0; j < shape[1]; j++) {
|
|
||||||
List<Double> strings = new ArrayList<>();
|
|
||||||
// 按经度
|
|
||||||
for (int k = 0; k < shape[2]; k++) {
|
|
||||||
// 按照对应索引获取数据并转换为string类型添加到数组中
|
|
||||||
Double dval = Math.round(data.getDouble(index.set(i, j, k)) * 1000) /1000d;
|
|
||||||
strings.add(dval);
|
|
||||||
}
|
|
||||||
resultPiece.add(strings);
|
|
||||||
}
|
|
||||||
resultAll.add(resultPiece);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
for (int i = 0; i < shape[0]; i++) {
|
|
||||||
List<List<Double>> resultPiece = new ArrayList<>();
|
|
||||||
for (int j = 0; j < shape[2]; j++) {
|
|
||||||
List<Double> strings = new ArrayList<>();
|
|
||||||
// 按经度
|
|
||||||
for (int k = 0; k < shape[3]; k++) {
|
|
||||||
// 按照对应索引获取数据并转换为string类型添加到数组中
|
|
||||||
Double dval = 0.0;
|
|
||||||
if(name.equals("LATD") || name.equals("LOND")){
|
|
||||||
dval = Math.round(data.getFloat(index.set(i, layer, j, k)) * 10000) /10000d;
|
|
||||||
}else{
|
|
||||||
try {
|
|
||||||
dval = Math.round(data.getDouble(index.set(i, layer, j, k)) * 10000000) /10000000d;
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
strings.add(dval);
|
|
||||||
}
|
|
||||||
resultPiece.add(strings);
|
|
||||||
}
|
|
||||||
resultAll.add(resultPiece);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return resultAll;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import org.jeecg.modules.util.NcUtil;
|
||||||
import org.jeecg.modules.util.SFTPUtil;
|
import org.jeecg.modules.util.SFTPUtil;
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -443,10 +444,10 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
|
||||||
// String ncNameWrf = "wrfout_d01_" + newStartTime;
|
// String ncNameWrf = "wrfout_d01_" + newStartTime;
|
||||||
String ncNameWrf = "wrfout_d01_2016-07-01_00_00_00";
|
String ncNameWrf = "wrfout_d01_2016-07-01_00_00_00";
|
||||||
NetcdfFile ncfile = NetcdfDataset.open(localFilePath + ncNameWrf);
|
NetcdfFile ncfile = NetcdfDataset.open(localFilePath + ncNameWrf);
|
||||||
List<List<List<Double>>> xlatAllList = getNCByName(ncfile, "XLAT",layer);
|
List<List<List<Double>>> xlatAllList = NcUtil.getNCByName(ncfile, "XLAT",layer);
|
||||||
List<List<List<Double>>> xlongAllList = getNCByName(ncfile, "XLONG",layer);
|
List<List<List<Double>>> xlongAllList = NcUtil.getNCByName(ncfile, "XLONG",layer);
|
||||||
List<List<List<Double>>> uAllList = getNCByName(ncfile, "U",layer);
|
List<List<List<Double>>> uAllList = NcUtil.getNCByName(ncfile, "U",layer);
|
||||||
List<List<List<Double>>> vAllList = getNCByName(ncfile, "V",layer);
|
List<List<List<Double>>> vAllList = NcUtil.getNCByName(ncfile, "V",layer);
|
||||||
|
|
||||||
for (int l=0; l<xlatAllList.size();l++) {
|
for (int l=0; l<xlatAllList.size();l++) {
|
||||||
List<Double[]> result = new ArrayList<>();
|
List<Double[]> result = new ArrayList<>();
|
||||||
|
@ -507,9 +508,9 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
|
||||||
// String ncNameWrf = "wrfout_d01_" + newStartTime;
|
// String ncNameWrf = "wrfout_d01_" + newStartTime;
|
||||||
String ncNameWrf = "wrfout_d01_2016-07-01_00_00_00";
|
String ncNameWrf = "wrfout_d01_2016-07-01_00_00_00";
|
||||||
NetcdfFile ncfile = NetcdfDataset.open(localFilePath + ncNameWrf);
|
NetcdfFile ncfile = NetcdfDataset.open(localFilePath + ncNameWrf);
|
||||||
List<List<List<Double>>> hgtAllList = getNCByName(ncfile, "HGT",0);
|
List<List<List<Double>>> hgtAllList = NcUtil.getNCByName(ncfile, "HGT",0);
|
||||||
List<List<List<Double>>> xlatAllList = getNCByName(ncfile, "XLAT",0);
|
List<List<List<Double>>> xlatAllList = NcUtil.getNCByName(ncfile, "XLAT",0);
|
||||||
List<List<List<Double>>> xlongAllList = getNCByName(ncfile, "XLONG",0);
|
List<List<List<Double>>> xlongAllList = NcUtil.getNCByName(ncfile, "XLONG",0);
|
||||||
for (int l=0;l<xlatAllList.size();l++) {
|
for (int l=0;l<xlatAllList.size();l++) {
|
||||||
List<Double[]> result = new ArrayList<>();
|
List<Double[]> result = new ArrayList<>();
|
||||||
for (int i = 0; i < hgtAllList.get(l).size(); i++) {
|
for (int i = 0; i < hgtAllList.get(l).size(); i++) {
|
||||||
|
@ -561,10 +562,10 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
|
||||||
// String ncNameWrf = "wrfout_d01_" + newStartTime;
|
// String ncNameWrf = "wrfout_d01_" + newStartTime;
|
||||||
String ncNameWrf = "wrfout_d01_2016-07-01_00_00_00";
|
String ncNameWrf = "wrfout_d01_2016-07-01_00_00_00";
|
||||||
NetcdfFile ncfile = NetcdfDataset.open(localFilePath + ncNameWrf);
|
NetcdfFile ncfile = NetcdfDataset.open(localFilePath + ncNameWrf);
|
||||||
List<List<List<Double>>> uAllList = getNCByName(ncfile, "U",0);
|
List<List<List<Double>>> uAllList = NcUtil.getNCByName(ncfile, "U",0);
|
||||||
List<List<List<Double>>> vAllList = getNCByName(ncfile, "V",0);
|
List<List<List<Double>>> vAllList = NcUtil.getNCByName(ncfile, "V",0);
|
||||||
List<List<List<Double>>> pAllList = getNCByName(ncfile, "P",0);
|
List<List<List<Double>>> pAllList = NcUtil.getNCByName(ncfile, "P",0);
|
||||||
List<List<List<Double>>> tAllList = getNCByName(ncfile, "T",0);
|
List<List<List<Double>>> tAllList = NcUtil.getNCByName(ncfile, "T",0);
|
||||||
|
|
||||||
Variable xlatVariable = ncfile.findVariable("XLAT");
|
Variable xlatVariable = ncfile.findVariable("XLAT");
|
||||||
//时间、纬度、经度
|
//时间、纬度、经度
|
||||||
|
@ -718,61 +719,6 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
|
||||||
return super.importExcel(request, response, BizWrf.class);
|
return super.importExcel(request, response, BizWrf.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<List<List<Double>>> getNCByName(NetcdfFile ncfile, String name,int layer){
|
|
||||||
Variable variable = ncfile.findVariable(name);
|
|
||||||
List<List<List<Double>>> resultAll = new ArrayList<>();
|
|
||||||
// 读取nc数据到数组
|
|
||||||
Array data = null;
|
|
||||||
try {
|
|
||||||
data = variable.read();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取参数和索引,其中shape的前三个参数分别是时间、纬度、经度
|
|
||||||
int[] shape = data.getShape();
|
|
||||||
Index index = data.getIndex();
|
|
||||||
|
|
||||||
if(shape.length == 3){
|
|
||||||
// 将三维数组降维,并用String数组提取数据
|
|
||||||
// 按时间
|
|
||||||
// 按维度
|
|
||||||
for (int i = 0; i < shape[0]; i++) {
|
|
||||||
List<List<Double>> resultPiece = new ArrayList<>();
|
|
||||||
for (int j = 0; j < shape[1]; j++) {
|
|
||||||
List<Double> strings = new ArrayList<>();
|
|
||||||
// 按经度
|
|
||||||
for (int k = 0; k < shape[2]; k++) {
|
|
||||||
// 按照对应索引获取数据并转换为string类型添加到数组中
|
|
||||||
Double dval = Math.round(data.getFloat(index.set(i, j, k)) * 1000) /1000d;
|
|
||||||
strings.add(dval);
|
|
||||||
}
|
|
||||||
resultPiece.add(strings);
|
|
||||||
}
|
|
||||||
resultAll.add(resultPiece);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
// 将三维数组降维,并用String数组提取数据
|
|
||||||
// 按时间
|
|
||||||
// 按维度
|
|
||||||
for (int i = 0; i < shape[0]; i++) {
|
|
||||||
List<List<Double>> resultPiece = new ArrayList<>();
|
|
||||||
for (int j = 0; j < shape[2]; j++) {
|
|
||||||
List<Double> strings = new ArrayList<>();
|
|
||||||
// 按经度
|
|
||||||
for (int k = 0; k < shape[3]; k++) {
|
|
||||||
// 按照对应索引获取数据并转换为string类型添加到数组中
|
|
||||||
Double dval = Math.round(data.getFloat(index.set(i,layer, j, k)) * 1000) /1000d;
|
|
||||||
strings.add(dval);
|
|
||||||
}
|
|
||||||
resultPiece.add(strings);
|
|
||||||
}
|
|
||||||
resultAll.add(resultPiece);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return resultAll;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sftpUpload(String file,String cshFilePath,String fileName) throws FileNotFoundException, SftpException {
|
public void sftpUpload(String file,String cshFilePath,String fileName) throws FileNotFoundException, SftpException {
|
||||||
SFTPUtil sftpUtil = new SFTPUtil();
|
SFTPUtil sftpUtil = new SFTPUtil();
|
||||||
sftpUtil.login(username, password,ip,port);
|
sftpUtil.login(username, password,ip,port);
|
||||||
|
@ -790,8 +736,7 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
|
||||||
// String wmhr = RemoteExecuteCommand.runRemoteLinuxCmd("192.168.115.128", "wmhr", "123456", "cd /home/wmhr/OpenFOAM-8/run/admin/工程001/;ls");
|
// String wmhr = RemoteExecuteCommand.runRemoteLinuxCmd("192.168.115.128", "wmhr", "123456", "cd /home/wmhr/OpenFOAM-8/run/admin/工程001/;ls");
|
||||||
// System.out.println(wmhr);
|
// System.out.println(wmhr);
|
||||||
|
|
||||||
String wmhr = RemoteExecuteCommand.runRemoteLinuxCmd("192.168.115.128", "wmhr", "123456", "ps -ef | grep vmtoolsd");
|
String wmhr = RemoteExecuteCommand.runRemoteLinuxCmd("192.168.115.128", "wmhr", "123456", "ps -ef | grep wrf.exe");
|
||||||
System.out.println(wmhr);
|
System.out.println(wmhr);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,5 @@ public interface IBizWrfService extends IService<BizWrf> {
|
||||||
Result<String> runMetgrid(String allRunPath, String engineeringId)throws IOException;
|
Result<String> runMetgrid(String allRunPath, String engineeringId)throws IOException;
|
||||||
Result<String> runReal(String allRunPath, String engineeringId)throws IOException;
|
Result<String> runReal(String allRunPath, String engineeringId)throws IOException;
|
||||||
Result<String> runWrf(String allRunPath, String engineeringId) throws IOException;
|
Result<String> runWrf(String allRunPath, String engineeringId) throws IOException;
|
||||||
List<List<List<Double>>> getNCByName(NetcdfFile ncfile, String name, int layer);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,60 +178,5 @@ public class BizWrfServiceImpl extends ServiceImpl<BizWrfMapper, BizWrf> impleme
|
||||||
sftpUtil.logout();
|
sftpUtil.logout();
|
||||||
return Result.error(wrfLog);
|
return Result.error(wrfLog);
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public List<List<List<Double>>> getNCByName(NetcdfFile ncfile, String name, int layer){
|
|
||||||
Variable variable = ncfile.findVariable(name);
|
|
||||||
List<List<List<Double>>> resultAll = new ArrayList<>();
|
|
||||||
// 读取nc数据到数组
|
|
||||||
Array data = null;
|
|
||||||
try {
|
|
||||||
data = variable.read();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取参数和索引,其中shape的前三个参数分别是时间、纬度、经度
|
|
||||||
int[] shape = data.getShape();
|
|
||||||
Index index = data.getIndex();
|
|
||||||
|
|
||||||
if(shape.length == 3){
|
|
||||||
// 将三维数组降维,并用String数组提取数据
|
|
||||||
// 按时间
|
|
||||||
// 按维度
|
|
||||||
for (int i = 0; i < shape[0]; i++) {
|
|
||||||
List<List<Double>> resultPiece = new ArrayList<>();
|
|
||||||
for (int j = 0; j < shape[1]; j++) {
|
|
||||||
List<Double> strings = new ArrayList<>();
|
|
||||||
// 按经度
|
|
||||||
for (int k = 0; k < shape[2]; k++) {
|
|
||||||
// 按照对应索引获取数据并转换为string类型添加到数组中
|
|
||||||
Double dval = Math.round(data.getFloat(index.set(i, j, k)) * 1000) /1000d;
|
|
||||||
strings.add(dval);
|
|
||||||
}
|
|
||||||
resultPiece.add(strings);
|
|
||||||
}
|
|
||||||
resultAll.add(resultPiece);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
// 将三维数组降维,并用String数组提取数据
|
|
||||||
// 按时间
|
|
||||||
// 按维度
|
|
||||||
for (int i = 0; i < shape[0]; i++) {
|
|
||||||
List<List<Double>> resultPiece = new ArrayList<>();
|
|
||||||
for (int j = 0; j < shape[2]; j++) {
|
|
||||||
List<Double> strings = new ArrayList<>();
|
|
||||||
// 按经度
|
|
||||||
for (int k = 0; k < shape[3]; k++) {
|
|
||||||
// 按照对应索引获取数据并转换为string类型添加到数组中
|
|
||||||
Double dval = Math.round(data.getFloat(index.set(i,layer, j, k)) * 1000) /1000d;
|
|
||||||
strings.add(dval);
|
|
||||||
}
|
|
||||||
resultPiece.add(strings);
|
|
||||||
}
|
|
||||||
resultAll.add(resultPiece);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return resultAll;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.jeecg.modules.project.calculateConfig.bizWrf.service.IBizWrfService;
|
||||||
import org.jeecg.modules.project.calculateResult.bizResultDiffuse.entity.BizResultDiffuse;
|
import org.jeecg.modules.project.calculateResult.bizResultDiffuse.entity.BizResultDiffuse;
|
||||||
import org.jeecg.modules.project.calculateResult.bizResultDiffuse.service.IBizResultDiffuseService;
|
import org.jeecg.modules.project.calculateResult.bizResultDiffuse.service.IBizResultDiffuseService;
|
||||||
import org.jeecg.modules.project.calculateResult.runProcess.VO.ProgressVO;
|
import org.jeecg.modules.project.calculateResult.runProcess.VO.ProgressVO;
|
||||||
|
import org.jeecg.modules.util.NcUtil;
|
||||||
import org.jeecg.modules.util.SFTPUtil;
|
import org.jeecg.modules.util.SFTPUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -150,7 +151,7 @@ public class RunProcessController extends JeecgController<BizResultDiffuse, IBiz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NetcdfFile ncfile = NetcdfDataset.open(localFilePath + ncNameWrf);
|
NetcdfFile ncfile = NetcdfDataset.open(localFilePath + ncNameWrf);
|
||||||
List<List<List<Double>>> xlatAllList = bizWrfService.getNCByName(ncfile, "XLAT",0);
|
List<List<List<Double>>> xlatAllList = NcUtil.getNCByName(ncfile, "XLAT",0);
|
||||||
percent = nowDay * 24 - 24 + xlatAllList.size() * 100 / sumHour;
|
percent = nowDay * 24 - 24 + xlatAllList.size() * 100 / sumHour;
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
progressList.set(i,100);
|
progressList.set(i,100);
|
||||||
|
@ -170,7 +171,7 @@ public class RunProcessController extends JeecgController<BizResultDiffuse, IBiz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NetcdfFile ncfile = NetcdfDataset.open(localFilePath + ncNameCmaq);
|
NetcdfFile ncfile = NetcdfDataset.open(localFilePath + ncNameCmaq);
|
||||||
List<List<List<Double>>> xlatAllList = bizWrfService.getNCByName(ncfile, "CO",0);
|
List<List<List<Double>>> xlatAllList = NcUtil.getNCByName(ncfile, "CO",0);
|
||||||
percent = nowDay * 24 - 24 + xlatAllList.size() * 100 / (sumHour -24);
|
percent = nowDay * 24 - 24 + xlatAllList.size() * 100 / (sumHour -24);
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
progressList.set(i,100);
|
progressList.set(i,100);
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
package org.jeecg.modules.util;
|
||||||
|
|
||||||
|
import ucar.ma2.Array;
|
||||||
|
import ucar.ma2.Index;
|
||||||
|
import ucar.nc2.NetcdfFile;
|
||||||
|
import ucar.nc2.Variable;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public final class NcUtil {
|
||||||
|
|
||||||
|
public static List<List<List<Double>>> getNCByName(NetcdfFile ncfile, String name, int layer){
|
||||||
|
Variable variable = ncfile.findVariable(name);
|
||||||
|
List<List<List<Double>>> resultAll = new ArrayList<>();
|
||||||
|
// 读取nc数据到数组
|
||||||
|
Array data = null;
|
||||||
|
try {
|
||||||
|
data = variable.read();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取参数和索引,其中shape的前三个参数分别是时间、纬度、经度
|
||||||
|
int[] shape = data.getShape();
|
||||||
|
Index index = data.getIndex();
|
||||||
|
|
||||||
|
if(shape.length == 3){
|
||||||
|
// 将三维数组降维,并用String数组提取数据
|
||||||
|
// 按时间
|
||||||
|
// 按维度
|
||||||
|
for (int i = 0; i < shape[0]; i++) {
|
||||||
|
List<List<Double>> resultPiece = new ArrayList<>();
|
||||||
|
for (int j = 0; j < shape[1]; j++) {
|
||||||
|
List<Double> strings = new ArrayList<>();
|
||||||
|
// 按经度
|
||||||
|
for (int k = 0; k < shape[2]; k++) {
|
||||||
|
// 按照对应索引获取数据并转换为string类型添加到数组中
|
||||||
|
Double dval = Math.round(data.getFloat(index.set(i, j, k)) * 1000) /1000d;
|
||||||
|
strings.add(dval);
|
||||||
|
}
|
||||||
|
resultPiece.add(strings);
|
||||||
|
}
|
||||||
|
resultAll.add(resultPiece);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
// 将三维数组降维,并用String数组提取数据
|
||||||
|
// 按时间
|
||||||
|
// 按维度
|
||||||
|
for (int i = 0; i < shape[0]; i++) {
|
||||||
|
List<List<Double>> resultPiece = new ArrayList<>();
|
||||||
|
for (int j = 0; j < shape[2]; j++) {
|
||||||
|
List<Double> strings = new ArrayList<>();
|
||||||
|
// 按经度
|
||||||
|
for (int k = 0; k < shape[3]; k++) {
|
||||||
|
// 按照对应索引获取数据并转换为string类型添加到数组中
|
||||||
|
Double dval = Math.round(data.getFloat(index.set(i,layer, j, k)) * 1000) /1000d;
|
||||||
|
strings.add(dval);
|
||||||
|
}
|
||||||
|
resultPiece.add(strings);
|
||||||
|
}
|
||||||
|
resultAll.add(resultPiece);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultAll;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user