This commit is contained in:
hky 2023-10-12 16:17:46 +08:00
parent efb44660d2
commit 3e401eafad
24 changed files with 735 additions and 219 deletions

View File

@ -1,4 +1,4 @@
package org.jeecg.modules.project.baseAPI.service;
package org.jeecg.modules.project.baseAPI.calculateAPI.service;
import java.io.IOException;

View File

@ -1,9 +1,9 @@
package org.jeecg.modules.project.baseAPI.service.impl;
package org.jeecg.modules.project.baseAPI.calculateAPI.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.modules.project.baseAPI.service.IBizBaseAPIService;
import org.jeecg.modules.project.baseAPI.calculateAPI.service.IBizBaseAPIService;
import org.jeecg.modules.project.baseConfig.bizEngineering.entity.BizEngineering;
import org.jeecg.modules.project.baseConfig.bizEngineering.service.IBizEngineeringService;
import org.jeecg.modules.project.calculateConfig.bizWrf.entity.BizWrf;

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.util;
package org.jeecg.modules.project.baseAPI.sftpAPI;
import com.jcraft.jsch.*;
import org.springframework.beans.factory.annotation.Value;
import java.io.*;
import java.util.ArrayList;
@ -13,16 +14,18 @@ public class SFTPUtil {
private ChannelSftp sftp;
private Session session;
// SFTP 登录用户名
// private String username = "xiongzheng";
//SFTP 登录密码
// private String password = "512109";
@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 String privateKey;
//SFTP 服务器地址IP地址
// private String host = "192.168.8.114";
//SFTP 端口
// private int port = 22;
/**

View File

@ -20,7 +20,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.project.baseAPI.service.IBizBaseAPIService;
import org.jeecg.modules.project.baseAPI.calculateAPI.service.IBizBaseAPIService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

View File

@ -5,7 +5,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.vo.LoginUser;

View File

@ -3,14 +3,12 @@ package org.jeecg.modules.project.baseConfig.bizEngineering.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.project.baseConfig.bizEngineering.entity.BizEngineering;
import org.jeecg.modules.project.baseConfig.bizEngineering.mapper.BizEngineeringMapper;
import org.jeecg.modules.project.baseConfig.bizEngineering.service.IBizEngineeringService;
import org.jeecg.modules.project.calculateConfig.bizCmaq.entity.BizCmaq;
import org.jeecg.modules.project.calculateConfig.bizCmaq.mapper.BizCmaqMapper;
import org.jeecg.modules.project.calculateConfig.bizCmaq.service.IBizCmaqService;
import org.jeecg.modules.project.calculateConfig.bizConfigChemistry.entity.BizConfigChemistry;
import org.jeecg.modules.project.calculateConfig.bizConfigChemistry.service.IBizConfigChemistryService;
import org.jeecg.modules.project.calculateConfig.bizConfigFacility.entity.BizConfigFacility;
@ -23,7 +21,6 @@ import org.jeecg.modules.project.calculateConfig.bizOpenfoam.entity.BizOpenfoam;
import org.jeecg.modules.project.calculateConfig.bizOpenfoam.service.IBizOpenfoamService;
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.project.calculateResult.bizResultDiffuse.entity.BizResultDiffuse;
import org.jeecg.modules.project.calculateResult.bizResultDiffuse.service.IBizResultDiffuseService;
import org.jeecg.modules.project.calculateResult.bizResultDosage.entity.BizResultDosage;
@ -35,7 +32,6 @@ import org.jeecg.modules.project.calculateResult.bizResultSourceItem.service.IBi
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Date;
import java.util.List;

View File

@ -0,0 +1,178 @@
package org.jeecg.modules.project.baseConfig.bizModeLink.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.project.baseConfig.bizModeLink.entity.BizModeLink;
import org.jeecg.modules.project.baseConfig.bizModeLink.service.IBizModeLinkService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description: 模型链路选择
* @Author: jeecg-boot
* @Date: 2023-10-12
* @Version: V1.0
*/
@Api(tags="模型链路选择")
@RestController
@RequestMapping("/bizModeLink/bizModeLink")
@Slf4j
public class BizModeLinkController extends JeecgController<BizModeLink, IBizModeLinkService> {
@Autowired
private IBizModeLinkService bizModeLinkService;
/**
* 分页列表查询
*
* @param bizModeLink
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "模型链路选择-分页列表查询")
@ApiOperation(value="模型链路选择-分页列表查询", notes="模型链路选择-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<BizModeLink>> queryPageList(BizModeLink bizModeLink,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<BizModeLink> queryWrapper = QueryGenerator.initQueryWrapper(bizModeLink, req.getParameterMap());
Page<BizModeLink> page = new Page<BizModeLink>(pageNo, pageSize);
IPage<BizModeLink> pageList = bizModeLinkService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param bizModeLink
* @return
*/
@AutoLog(value = "模型链路选择-添加")
@ApiOperation(value="模型链路选择-添加", notes="模型链路选择-添加")
@RequiresPermissions("bizModeLink:biz_mode_link:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody BizModeLink bizModeLink) {
bizModeLinkService.save(bizModeLink);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param bizModeLink
* @return
*/
@AutoLog(value = "模型链路选择-编辑")
@ApiOperation(value="模型链路选择-编辑", notes="模型链路选择-编辑")
@RequiresPermissions("bizModeLink:biz_mode_link:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody BizModeLink bizModeLink) {
bizModeLinkService.updateById(bizModeLink);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "模型链路选择-通过id删除")
@ApiOperation(value="模型链路选择-通过id删除", notes="模型链路选择-通过id删除")
@RequiresPermissions("bizModeLink:biz_mode_link:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
bizModeLinkService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "模型链路选择-批量删除")
@ApiOperation(value="模型链路选择-批量删除", notes="模型链路选择-批量删除")
@RequiresPermissions("bizModeLink:biz_mode_link:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.bizModeLinkService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "模型链路选择-通过id查询")
@ApiOperation(value="模型链路选择-通过id查询", notes="模型链路选择-通过id查询")
@GetMapping(value = "/queryById")
public Result<BizModeLink> queryById(@RequestParam(name="id",required=true) String id) {
BizModeLink bizModeLink = bizModeLinkService.getById(id);
if(bizModeLink==null) {
return Result.error("未找到对应数据");
}
return Result.OK(bizModeLink);
}
/**
* 导出excel
*
* @param request
* @param bizModeLink
*/
@RequiresPermissions("bizModeLink:biz_mode_link:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, BizModeLink bizModeLink) {
return super.exportXls(request, bizModeLink, BizModeLink.class, "模型链路选择");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequiresPermissions("bizModeLink:biz_mode_link:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, BizModeLink.class);
}
}

View File

@ -0,0 +1,63 @@
package org.jeecg.modules.project.baseConfig.bizModeLink.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: 模型链路选择
* @Author: jeecg-boot
* @Date: 2023-10-12
* @Version: V1.0
*/
@Data
@TableName("biz_mode_link")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="biz_mode_link对象", description="模型链路选择")
public class BizModeLink implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private String id;
/**创建人*/
@ApiModelProperty(value = "创建人")
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private Date createTime;
/**更新人*/
@ApiModelProperty(value = "更新人")
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private Date updateTime;
/**模式类型*/
@Excel(name = "模式类型", width = 15)
@ApiModelProperty(value = "模式类型")
private Integer modeType;
/**模式方案id*/
@Excel(name = "模式方案id", width = 15)
@ApiModelProperty(value = "模式方案id")
private String modeId;
}

View File

@ -0,0 +1,17 @@
package org.jeecg.modules.project.baseConfig.bizModeLink.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.project.baseConfig.bizModeLink.entity.BizModeLink;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 模型链路选择
* @Author: jeecg-boot
* @Date: 2023-10-12
* @Version: V1.0
*/
public interface BizModeLinkMapper extends BaseMapper<BizModeLink> {
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.project.baseConfig.bizModeLink.mapper.BizModeLinkMapper">
</mapper>

View File

@ -0,0 +1,14 @@
package org.jeecg.modules.project.baseConfig.bizModeLink.service;
import org.jeecg.modules.project.baseConfig.bizModeLink.entity.BizModeLink;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: 模型链路选择
* @Author: jeecg-boot
* @Date: 2023-10-12
* @Version: V1.0
*/
public interface IBizModeLinkService extends IService<BizModeLink> {
}

View File

@ -0,0 +1,19 @@
package org.jeecg.modules.project.baseConfig.bizModeLink.service.impl;
import org.jeecg.modules.project.baseConfig.bizModeLink.entity.BizModeLink;
import org.jeecg.modules.project.baseConfig.bizModeLink.mapper.BizModeLinkMapper;
import org.jeecg.modules.project.baseConfig.bizModeLink.service.IBizModeLinkService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 模型链路选择
* @Author: jeecg-boot
* @Date: 2023-10-12
* @Version: V1.0
*/
@Service
public class BizModeLinkServiceImpl extends ServiceImpl<BizModeLinkMapper, BizModeLink> implements IBizModeLinkService {
}

View File

@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xkcoding.http.util.StringUtil;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.project.calculateConfig.bizCmaq.entity.BizCmaq;
@ -226,6 +227,31 @@ public class BizCmaqController extends JeecgController<BizCmaq, IBizCmaqService>
return Result.OK(bizCmaq);
}
/**
* 通过类型查询模板
*
* @return
*/
//@AutoLog(value = "cmaq-通过类型查询模板")
@ApiOperation(value="cmaq-通过类型查询模板", notes="cmaq-通过类型查询模板")
@GetMapping(value = "/getCmaqTem")
public Result<BizCmaq> getWrfTem(Integer temType,Integer sceneType,Integer modeType,String modeSchemeName) {
LambdaQueryWrapper<BizCmaq> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(BizCmaq::getTemType,temType);
lambdaQueryWrapper.eq(BizCmaq::getSceneType,sceneType);
lambdaQueryWrapper.eq(BizCmaq::getModeType,modeType);
if(StringUtil.isNotEmpty(modeSchemeName)){
lambdaQueryWrapper.eq(BizCmaq::getModeSchemeName,modeSchemeName);
}
List<BizCmaq> bizCmaqs = bizCmaqService.list(lambdaQueryWrapper);
if(bizCmaqs == null || bizCmaqs.isEmpty()) {
return Result.error("未找到对应数据");
}
return Result.OK(bizCmaqs.get(0));
}
/**
* 导出excel
*

View File

@ -204,6 +204,14 @@ public class BizCmaq implements Serializable {
@ApiModelProperty(value = "engineeringId")
private String engineeringId;
@Excel(name = "temType", width = 15)
@ApiModelProperty(value = "temType")
@ApiModelProperty(value = "temType(0:模板,1:非模板)")
private int temType;
@Excel(name = "sceneType", width = 15)
@ApiModelProperty(value = "sceneType(1:核,2:设施,3:化学,4:泄露)")
private int sceneType;
@Excel(name = "sceneType", width = 15)
@ApiModelProperty(value = "modeType(1:源项模拟,2:气象参数,3:扩散模拟,4:后果评估,5:辅助决策)")
private int modeType;
@Excel(name = "sceneType", width = 15)
private String modeSchemeName;
}

View File

@ -14,7 +14,7 @@ import org.jeecg.modules.project.baseConfig.bizEngineering.service.IBizEngineeri
import org.jeecg.modules.project.calculateConfig.bizOpenfoam.entity.BizOpenfoam;
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.project.baseAPI.sftpAPI.SFTPUtil;
import org.springframework.beans.factory.annotation.Value;
import org.jeecg.modules.project.calculateConfig.bizWrf.entity.BizWrf;
import org.jeecg.modules.project.calculateConfig.bizWrf.mapper.BizWrfMapper;
@ -22,8 +22,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import ucar.ma2.Array;
import ucar.ma2.Index;
import ucar.nc2.NetcdfFile;
import ucar.nc2.Variable;
import ucar.nc2.dataset.NetcdfDataset;

View File

@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletRequest;
import cn.hutool.core.io.FileUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jcraft.jsch.SftpException;
import com.xkcoding.http.util.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
@ -28,7 +29,7 @@ import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.project.calculateConfig.bizWrf.entity.BizWrf;
import org.jeecg.modules.project.calculateConfig.bizWrf.mapper.BizWrfMapper;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.util.SFTPUtil;
import org.jeecg.modules.project.baseAPI.sftpAPI.SFTPUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
@ -142,6 +143,31 @@ public class BizOpenfoamController extends JeecgController<BizOpenfoam, IBizOpen
return Result.OK(bizOpenfoam);
}
/**
* 通过类型查询模板
*
* @return
*/
//@AutoLog(value = "cmaq-通过类型查询模板")
@ApiOperation(value="cmaq-通过类型查询模板", notes="cmaq-通过类型查询模板")
@GetMapping(value = "/getCmaqTem")
public Result<BizOpenfoam> getWrfTem(Integer temType, Integer sceneType, Integer modeType, String modeSchemeName) {
LambdaQueryWrapper<BizOpenfoam> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(BizOpenfoam::getTemType,temType);
lambdaQueryWrapper.eq(BizOpenfoam::getSceneType,sceneType);
lambdaQueryWrapper.eq(BizOpenfoam::getModeType,modeType);
if(StringUtil.isNotEmpty(modeSchemeName)){
lambdaQueryWrapper.eq(BizOpenfoam::getModeSchemeName,modeSchemeName);
}
List<BizOpenfoam> bizOpenfoams = bizOpenfoamService.list(lambdaQueryWrapper);
if(bizOpenfoams == null || bizOpenfoams.isEmpty()) {
return Result.error("未找到对应数据");
}
return Result.OK(bizOpenfoams.get(0));
}
/**
* 运行
*

View File

@ -96,4 +96,15 @@ public class BizOpenfoam implements Serializable {
@Excel(name = "engineeringId", width = 15)
@ApiModelProperty(value = "engineeringId")
private String engineeringId;
@Excel(name = "temType", width = 15)
@ApiModelProperty(value = "temType(0:模板,1:非模板)")
private int temType;
@Excel(name = "sceneType", width = 15)
@ApiModelProperty(value = "sceneType(1:核,2:设施,3:化学,4:泄露)")
private int sceneType;
@Excel(name = "sceneType", width = 15)
@ApiModelProperty(value = "modeType(1:源项模拟,2:气象参数,3:扩散模拟,4:后果评估,5:辅助决策)")
private int modeType;
@Excel(name = "sceneType", width = 15)
private String modeSchemeName;
}

View File

@ -1,12 +1,11 @@
package org.jeecg.modules.project.calculateConfig.bizOpenfoam.service.impl;
import org.jeecg.common.util.RemoteExecuteCommand;
import org.jeecg.modules.project.baseConfig.bizEngineering.entity.BizEngineering;
import org.jeecg.modules.project.calculateConfig.bizOpenfoam.entity.BizOpenfoam;
import org.jeecg.modules.project.calculateConfig.bizOpenfoam.mapper.BizOpenfoamMapper;
import org.jeecg.modules.project.calculateConfig.bizOpenfoam.service.IBizOpenfoamService;
import org.jeecg.modules.project.calculateConfig.bizWrf.entity.BizWrf;
import org.jeecg.modules.util.SFTPUtil;
import org.jeecg.modules.project.baseAPI.sftpAPI.SFTPUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

View File

@ -2,7 +2,6 @@ package org.jeecg.modules.project.calculateConfig.bizWrf.controller;
import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@ -10,10 +9,9 @@ import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jcraft.jsch.SftpException;
import com.xkcoding.http.util.StringUtil;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.RemoteExecuteCommand;
@ -31,7 +29,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.util.NcUtil;
import org.jeecg.modules.util.SFTPUtil;
import org.jeecg.modules.project.baseAPI.sftpAPI.SFTPUtil;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -40,8 +38,6 @@ import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import ucar.ma2.Array;
import ucar.ma2.Index;
import ucar.nc2.NetcdfFile;
import ucar.nc2.Variable;
import ucar.nc2.dataset.NetcdfDataset;
@ -73,10 +69,6 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
private String baseHome;
@Value("${spring.localFilePrefix}")
private String localFilePrefix;
@Value("${spring.cshTemFielPath}")
private String cshTemFielPath;
@Value("${spring.WRF.geog_data_path}")
private String geog_data_path;
@Value("${spring.WRF.fnldataPath}")
private String fnldataPath;
@Value("${spring.Linux.ip}")
@ -138,157 +130,12 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
bizWrf.setWe(String.format("%.0f",(Math.ceil(we))));
bizWrf.setTemType(0);
bizWrfService.saveOrUpdate(bizWrf);
BizEngineering engineering = bizEngineeringService.getById(bizWrf.getEngineeringId());
String newAllRunPath = String.format("%s%s/%s/", baseHome, bizWrf.getCreateBy(),engineering.getEngineeringName());
RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, String.format("rm -rf %s",newAllRunPath));
RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, String.format("mkdir %s",baseHome + bizWrf.getCreateBy()));
String runCmd = String.format("cp -r %sAll_Run %s", baseHome, newAllRunPath);
RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, runCmd);
saveWpsFile(bizWrf,engineering.getEngineeringName());
saveInputFile(bizWrf,engineering.getEngineeringName());
return Result.OK("添加成功!");
}
public void saveWpsFile(BizWrf bizWrf,String engineeringName){
String allRunPath = baseHome + bizWrf.getCreateBy() + "/" + engineeringName + "/";
String localFilePath = localFilePrefix + bizWrf.getCreateBy() + "/" + engineeringName + "/";
String fileName = "namelist.wps";
try {
String startStr = "";
String endStr = "";
if (ObjectUtil.isNotEmpty(bizWrf.getMaxDom())){
Integer max = bizWrf.getMaxDom();
for (int i = 0; i < max; i++) {
startStr += String.format("'%s',",bizWrf.getStartTime());
endStr += String.format("'%s',",bizWrf.getEndTime());
}
}else {
startStr = String.format("'%s',",bizWrf.getStartData());
endStr = String.format("'%s',",bizWrf.getEndData());
}
String data = new String(readAllBytes(get(cshTemFielPath + "namelistTem.wps")));
data = data.replace("#{wrf_core}", bizWrf.getWrfCore())
.replace("#{max_dom}", bizWrf.getMaxDom()+"")
.replace("#{start_date}", startStr)
.replace("#{end_date}", endStr)
.replace("#{parent_grid_ratio}", bizWrf.getParentGridRatio())
.replace("#{i_parent_start}", bizWrf.getParentStartI())
.replace("#{j_parent_start}", bizWrf.getParentStartJ())
.replace("#{e_we}", bizWrf.getWe())
.replace("#{e_sn}", bizWrf.getSn())
.replace("#{geog_data_res}", bizWrf.getGeogDataRes())
.replace("#{dx}", bizWrf.getDx())
.replace("#{dy}", bizWrf.getDy())
.replace("#{map_proj}", bizWrf.getMapProj())
.replace("#{ref_lat}", bizWrf.getRefLat())
.replace("#{ref_lon}", bizWrf.getRefLon())
.replace("#{truelat1}", bizWrf.getTruelat1())
.replace("#{truelat2}", bizWrf.getTruelat2())
.replace("#{stand_lon}", bizWrf.getStandLon())
.replace("#{geog_data_path}", geog_data_path)
.replace("#{opt_output_from_metgrid_path}",allRunPath+"WRF/run");
// todo sftp 上传
FileUtil.writeString(data, localFilePath + fileName, "UTF-8");
sftpUpload(localFilePath + fileName, allRunPath + "WPS", fileName);
} catch (Exception e) {
e.printStackTrace();
}
}
public void saveInputFile(BizWrf bizWrf,String engineeringName){
String allRunPath = baseHome + bizWrf.getCreateBy() + "/" + engineeringName + "/";
String localFilePath = localFilePrefix + bizWrf.getCreateBy() + "/" + engineeringName + "/";
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
Calendar startCal = Calendar.getInstance();
startCal.setTime(sdf.parse(bizWrf.getStartTime()));
Calendar endCal = Calendar.getInstance();
endCal.setTime(sdf.parse(bizWrf.getEndTime()));
String startYear = "";
String startMonth = "";
String startDay = "";
String startHour = "";
String endYear = "";
String endMonth = "";
String endDay = "";
String endHour = "";
String inputFromFile = "";
String historyInterval = "";
String framesPerOutfile = "";
if (ObjectUtil.isNotEmpty(bizWrf.getMaxDom())){
Integer max = bizWrf.getMaxDom();
for (int i = 0; i < max; i++) {
startYear += String.format("%s,",startCal.get(Calendar.YEAR));
startMonth += String.format("%s,",String.format("%0" + 2 + "d", startCal.get(Calendar.MONTH)+1));
startDay += String.format("%s,",String.format("%0" + 2 + "d", startCal.get(Calendar.DATE)));
startHour += String.format("%s,",String.format("%0" + 2 + "d", startCal.get(Calendar.HOUR_OF_DAY)));
endYear += String.format("%s,",startCal.get(Calendar.YEAR));
endMonth += String.format("%s,",String.format("%0" + 2 + "d", endCal.get(Calendar.MONTH)+1));
endDay += String.format("%s,",String.format("%0" + 2 + "d", endCal.get(Calendar.DATE)));
endHour += String.format("%s,",String.format("%0" + 2 + "d", endCal.get(Calendar.HOUR_OF_DAY)));
inputFromFile += ".true.,";
historyInterval += "60,";
framesPerOutfile += "24,";
}
}else {
startYear = String.format("%s,",startCal.get(Calendar.YEAR));
startMonth = String.format("%s,",String.format("%0" + 2 + "d", startCal.get(Calendar.MONTH)+1));
startDay = String.format("%s,",String.format("%0" + 2 + "d", startCal.get(Calendar.DATE)));
startHour = String.format("%s,",String.format("%0" + 2 + "d", startCal.get(Calendar.HOUR_OF_DAY)));
endYear = String.format("%s,",startCal.get(Calendar.YEAR));
endMonth = String.format("%s,",String.format("%0" + 2 + "d", endCal.get(Calendar.MONTH)+1));
endDay = String.format("%s,",String.format("%0" + 2 + "d", endCal.get(Calendar.DATE)));
endHour = String.format("%s,",String.format("%0" + 2 + "d", endCal.get(Calendar.HOUR_OF_DAY)));
inputFromFile += ".true.,";
historyInterval += "60,";
framesPerOutfile += "24,";
}
String fileName = "namelist.input";
String data = new String(readAllBytes(get(cshTemFielPath + "namelistTem.input")));
data = data.replace("#{run_days}", bizWrf.getRunDays())
.replace("#{run_hours}", bizWrf.getRunHours())
.replace("#{run_minutes}", bizWrf.getRunMinutes())
.replace("#{run_seconds}", bizWrf.getRunSeconds())
.replace("#{start_year}", startYear)
.replace("#{start_month}", startMonth)
.replace("#{start_day}", startDay)
.replace("#{start_hour}", startHour)
.replace("#{end_year}", endYear)
.replace("#{end_month}", endMonth)
.replace("#{end_day}", endDay)
.replace("#{end_hour}", endHour)
.replace("#{input_from_file}", inputFromFile)
.replace("#{history_interval}", historyInterval)
.replace("#{frames_per_outfile}", framesPerOutfile)
.replace("#{time_step}", bizWrf.getTimeStep())
.replace("#{max_dom}", bizWrf.getMaxDom()+"")
.replace("#{e_we}", bizWrf.getWe())
.replace("#{e_sn}", bizWrf.getSn())
.replace("#{e_vert}", bizWrf.getVert())
.replace("#{dx}", bizWrf.getDx())
.replace("#{dy}", bizWrf.getDy())
.replace("#{i_parent_start}", bizWrf.getParentStartI())
.replace("#{j_parent_start}", bizWrf.getParentStartJ())
.replace("#{parent_grid_ratio}", bizWrf.getParentGridRatio());
// todo sftp 上传
FileUtil.writeString(data, localFilePath + fileName, "UTF-8");
sftpUpload(localFilePath + fileName, allRunPath + "WRF/run", fileName);
} catch (ParseException e) {
e.printStackTrace();
} catch (SftpException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 获取程序运行路径
*
@ -665,19 +512,28 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
}
/**
* 通过temType查询模板
* 通过类型查询模板
*
* @return
*/
//@AutoLog(value = "wrf-通过temType查询模板")
@ApiOperation(value="wrf-通过temType查询模板", notes="wrf-通过temType查询模板")
//@AutoLog(value = "wrf-通过类型查询模板")
@ApiOperation(value="wrf-通过类型查询模板", notes="wrf-通过类型查询模板")
@GetMapping(value = "/getWrfTem")
public Result<BizWrf> getWrfTem(Integer temType) {
BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper<BizWrf>().eq(BizWrf::getTemType,temType));
if(bizWrf==null) {
public Result<BizWrf> getWrfTem(Integer temType,Integer sceneType,Integer modeType,String modeSchemeName) {
LambdaQueryWrapper<BizWrf> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(BizWrf::getTemType,temType);
lambdaQueryWrapper.eq(BizWrf::getSceneType,sceneType);
lambdaQueryWrapper.eq(BizWrf::getModeType,modeType);
if(StringUtil.isNotEmpty(modeSchemeName)){
lambdaQueryWrapper.eq(BizWrf::getModeSchemeName,modeSchemeName);
}
List<BizWrf> bizWrfs = bizWrfService.list(lambdaQueryWrapper);
if(bizWrfs == null || bizWrfs.isEmpty()) {
return Result.error("未找到对应数据");
}
return Result.OK(bizWrf);
return Result.OK(bizWrfs.get(0));
}
/**
@ -719,14 +575,6 @@ public class BizWrfController extends JeecgController<BizWrf, IBizWrfService> {
return super.importExcel(request, response, BizWrf.class);
}
public void sftpUpload(String file,String cshFilePath,String fileName) throws FileNotFoundException, SftpException {
SFTPUtil sftpUtil = new SFTPUtil();
sftpUtil.login(username, password,ip,port);
InputStream inputStream = new FileInputStream(file);
sftpUtil.upload(cshFilePath,fileName,inputStream);
sftpUtil.logout();
}
public static void main(String[] args) throws ParseException {
// double latticeWidth = Math.abs(Math.round((Double.valueOf("-89.28") - Double.valueOf("-104.88")) / 102 * 10000) / 10000d);
// double lonLatticeIndex = Math.abs(Math.ceil((Double.valueOf("-91.54") - Double.valueOf("-104.88")) / latticeWidth));

View File

@ -171,8 +171,16 @@ public class BizWrf implements Serializable {
@ApiModelProperty(value = "yIndex")
private int yIndex;
@Excel(name = "temType", width = 15)
@ApiModelProperty(value = "temType(模板:0,核:1,设施:2,化学:3,泄露:4)")
@ApiModelProperty(value = "temType(0:模板,1:非模板)")
private int temType;
@Excel(name = "sceneType", width = 15)
@ApiModelProperty(value = "sceneType(1:核,2:设施,3:化学,4:泄露)")
private int sceneType;
@Excel(name = "sceneType", width = 15)
@ApiModelProperty(value = "modeType(1:源项模拟,2:气象参数,3:扩散模拟,4:后果评估,5:辅助决策)")
private int modeType;
@Excel(name = "sceneType", width = 15)
private String modeSchemeName;
/*
add 23/01/10

View File

@ -3,10 +3,8 @@ package org.jeecg.modules.project.calculateConfig.bizWrf.service;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.project.calculateConfig.bizWrf.entity.BizWrf;
import com.baomidou.mybatisplus.extension.service.IService;
import ucar.nc2.NetcdfFile;
import java.io.IOException;
import java.util.List;
/**
* @Description: wrf

View File

@ -9,22 +9,15 @@ import org.jeecg.modules.project.baseConfig.bizEngineering.service.IBizEngineeri
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.SFTPUtil;
import org.jeecg.modules.project.baseAPI.sftpAPI.SFTPUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
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.Date;
import java.util.List;
import static java.nio.file.Files.readAllBytes;
import static java.nio.file.Paths.get;

View File

@ -2,19 +2,19 @@ package org.jeecg.modules.project.calculateResult.runProcess.controller;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jcraft.jsch.SftpException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.RemoteExecuteCommand;
import org.jeecg.modules.constants.EnginConstants;
import org.jeecg.modules.project.baseAPI.sftpAPI.IBizSftpAPIService;
import org.jeecg.modules.project.baseConfig.bizEngineering.entity.BizEngineering;
import org.jeecg.modules.project.baseConfig.bizEngineering.service.IBizEngineeringService;
import org.jeecg.modules.project.calculateConfig.bizWrf.entity.BizWrf;
@ -23,23 +23,21 @@ import org.jeecg.modules.project.calculateResult.bizResultDiffuse.entity.BizResu
import org.jeecg.modules.project.calculateResult.bizResultDiffuse.service.IBizResultDiffuseService;
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.project.baseAPI.sftpAPI.SFTPUtil;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import ucar.nc2.NetcdfFile;
import ucar.nc2.dataset.NetcdfDataset;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@ -66,10 +64,17 @@ public class RunProcessController extends JeecgController<BizResultDiffuse, IBiz
@Autowired
private IBizWrfService bizWrfService;
@Autowired
private IBizSftpAPIService bizSftpAPIService;
@Value("${spring.baseHome}")
private String baseHome;
@Value("${spring.localFilePrefix}")
private String localFilePrefix;
@Value("${spring.cshTemFielPath}")
private String cshTemFielPath;
@Value("${spring.WRF.geog_data_path}")
private String geog_data_path;
@Value("${spring.Linux.ip}")
private String ip;
@ -92,6 +97,16 @@ public class RunProcessController extends JeecgController<BizResultDiffuse, IBiz
@GetMapping(value = "/runAllExe")
public Result<String> runAllExe(String engineeringId) throws IOException {
BizEngineering engineering = bizEngineeringService.getById(engineeringId);
BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper<BizWrf>().eq(BizWrf::getEngineeringId,engineering));
String newAllRunPath = String.format("%s%s/%s/", baseHome, bizWrf.getCreateBy(),engineering.getEngineeringName());
RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, String.format("rm -rf %s",newAllRunPath));
RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, String.format("mkdir %s",baseHome + bizWrf.getCreateBy()));
String runCmd = String.format("cp -r %sAll_Run %s", baseHome, newAllRunPath);
RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, runCmd);
saveWpsFile(bizWrf,engineering.getEngineeringName());
saveInputFile(bizWrf,engineering.getEngineeringName());
String allRunPath = baseHome + engineering.getCreateBy() + "/" + engineering.getEngineeringName() + "/";
bizWrfService.runGeogrid(allRunPath,engineeringId);
bizWrfService.runUngrib(allRunPath,engineeringId);
@ -101,6 +116,141 @@ public class RunProcessController extends JeecgController<BizResultDiffuse, IBiz
return Result.OK("运行成功!");
}
public void saveWpsFile(BizWrf bizWrf,String engineeringName){
String allRunPath = baseHome + bizWrf.getCreateBy() + "/" + engineeringName + "/";
String localFilePath = localFilePrefix + bizWrf.getCreateBy() + "/" + engineeringName + "/";
String fileName = "namelist.wps";
try {
String startStr = "";
String endStr = "";
if (ObjectUtil.isNotEmpty(bizWrf.getMaxDom())){
Integer max = bizWrf.getMaxDom();
for (int i = 0; i < max; i++) {
startStr += String.format("'%s',",bizWrf.getStartTime());
endStr += String.format("'%s',",bizWrf.getEndTime());
}
}else {
startStr = String.format("'%s',",bizWrf.getStartData());
endStr = String.format("'%s',",bizWrf.getEndData());
}
String data = new String(readAllBytes(get(cshTemFielPath + "namelistTem.wps")));
data = data.replace("#{wrf_core}", bizWrf.getWrfCore())
.replace("#{max_dom}", bizWrf.getMaxDom()+"")
.replace("#{start_date}", startStr)
.replace("#{end_date}", endStr)
.replace("#{parent_grid_ratio}", bizWrf.getParentGridRatio())
.replace("#{i_parent_start}", bizWrf.getParentStartI())
.replace("#{j_parent_start}", bizWrf.getParentStartJ())
.replace("#{e_we}", bizWrf.getWe())
.replace("#{e_sn}", bizWrf.getSn())
.replace("#{geog_data_res}", bizWrf.getGeogDataRes())
.replace("#{dx}", bizWrf.getDx())
.replace("#{dy}", bizWrf.getDy())
.replace("#{map_proj}", bizWrf.getMapProj())
.replace("#{ref_lat}", bizWrf.getRefLat())
.replace("#{ref_lon}", bizWrf.getRefLon())
.replace("#{truelat1}", bizWrf.getTruelat1())
.replace("#{truelat2}", bizWrf.getTruelat2())
.replace("#{stand_lon}", bizWrf.getStandLon())
.replace("#{geog_data_path}", geog_data_path)
.replace("#{opt_output_from_metgrid_path}",allRunPath+"WRF/run");
// todo sftp 上传
FileUtil.writeString(data, localFilePath + fileName, "UTF-8");
bizSftpAPIService.sftpUpload(localFilePath + fileName, allRunPath + "WPS", fileName);
} catch (Exception e) {
e.printStackTrace();
}
}
public void saveInputFile(BizWrf bizWrf,String engineeringName){
String allRunPath = baseHome + bizWrf.getCreateBy() + "/" + engineeringName + "/";
String localFilePath = localFilePrefix + bizWrf.getCreateBy() + "/" + engineeringName + "/";
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
Calendar startCal = Calendar.getInstance();
startCal.setTime(sdf.parse(bizWrf.getStartTime()));
Calendar endCal = Calendar.getInstance();
endCal.setTime(sdf.parse(bizWrf.getEndTime()));
String startYear = "";
String startMonth = "";
String startDay = "";
String startHour = "";
String endYear = "";
String endMonth = "";
String endDay = "";
String endHour = "";
String inputFromFile = "";
String historyInterval = "";
String framesPerOutfile = "";
if (ObjectUtil.isNotEmpty(bizWrf.getMaxDom())){
Integer max = bizWrf.getMaxDom();
for (int i = 0; i < max; i++) {
startYear += String.format("%s,",startCal.get(Calendar.YEAR));
startMonth += String.format("%s,",String.format("%0" + 2 + "d", startCal.get(Calendar.MONTH)+1));
startDay += String.format("%s,",String.format("%0" + 2 + "d", startCal.get(Calendar.DATE)));
startHour += String.format("%s,",String.format("%0" + 2 + "d", startCal.get(Calendar.HOUR_OF_DAY)));
endYear += String.format("%s,",startCal.get(Calendar.YEAR));
endMonth += String.format("%s,",String.format("%0" + 2 + "d", endCal.get(Calendar.MONTH)+1));
endDay += String.format("%s,",String.format("%0" + 2 + "d", endCal.get(Calendar.DATE)));
endHour += String.format("%s,",String.format("%0" + 2 + "d", endCal.get(Calendar.HOUR_OF_DAY)));
inputFromFile += ".true.,";
historyInterval += "60,";
framesPerOutfile += "24,";
}
}else {
startYear = String.format("%s,",startCal.get(Calendar.YEAR));
startMonth = String.format("%s,",String.format("%0" + 2 + "d", startCal.get(Calendar.MONTH)+1));
startDay = String.format("%s,",String.format("%0" + 2 + "d", startCal.get(Calendar.DATE)));
startHour = String.format("%s,",String.format("%0" + 2 + "d", startCal.get(Calendar.HOUR_OF_DAY)));
endYear = String.format("%s,",startCal.get(Calendar.YEAR));
endMonth = String.format("%s,",String.format("%0" + 2 + "d", endCal.get(Calendar.MONTH)+1));
endDay = String.format("%s,",String.format("%0" + 2 + "d", endCal.get(Calendar.DATE)));
endHour = String.format("%s,",String.format("%0" + 2 + "d", endCal.get(Calendar.HOUR_OF_DAY)));
inputFromFile += ".true.,";
historyInterval += "60,";
framesPerOutfile += "24,";
}
String fileName = "namelist.input";
String data = new String(readAllBytes(get(cshTemFielPath + "namelistTem.input")));
data = data.replace("#{run_days}", bizWrf.getRunDays())
.replace("#{run_hours}", bizWrf.getRunHours())
.replace("#{run_minutes}", bizWrf.getRunMinutes())
.replace("#{run_seconds}", bizWrf.getRunSeconds())
.replace("#{start_year}", startYear)
.replace("#{start_month}", startMonth)
.replace("#{start_day}", startDay)
.replace("#{start_hour}", startHour)
.replace("#{end_year}", endYear)
.replace("#{end_month}", endMonth)
.replace("#{end_day}", endDay)
.replace("#{end_hour}", endHour)
.replace("#{input_from_file}", inputFromFile)
.replace("#{history_interval}", historyInterval)
.replace("#{frames_per_outfile}", framesPerOutfile)
.replace("#{time_step}", bizWrf.getTimeStep())
.replace("#{max_dom}", bizWrf.getMaxDom()+"")
.replace("#{e_we}", bizWrf.getWe())
.replace("#{e_sn}", bizWrf.getSn())
.replace("#{e_vert}", bizWrf.getVert())
.replace("#{dx}", bizWrf.getDx())
.replace("#{dy}", bizWrf.getDy())
.replace("#{i_parent_start}", bizWrf.getParentStartI())
.replace("#{j_parent_start}", bizWrf.getParentStartJ())
.replace("#{parent_grid_ratio}", bizWrf.getParentGridRatio());
// todo sftp 上传
FileUtil.writeString(data, localFilePath + fileName, "UTF-8");
bizSftpAPIService.sftpUpload(localFilePath + fileName, allRunPath + "WRF/run", fileName);
} catch (ParseException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 查询工程运行进度
*

View File

@ -0,0 +1,157 @@
package org.jeecg.modules.util;
import org.apache.commons.math3.analysis.interpolation.SplineInterpolator;
import org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction;
import java.util.Arrays;
import java.util.Date;
import java.util.Random;
public class InterpolationSearch {
private static final Random r=new Random();
private static final int ARRAY_SIZE=1000;
private static Integer[] list=new Integer[ARRAY_SIZE];
// public static void main(String[] args) {
// InterpolationSearch interpolationSearch=new InterpolationSearch();
// //生成数组中有序的元素
// for(int i=0;i<ARRAY_SIZE;i++) {
// list[i]=i+1;//interpolationSearch.generatorRand(1,ARRAY_SIZE*10);
//
// }
// Arrays.sort(list);
// //输出数组长度
// System.out.println("有序数组长度:"+ARRAY_SIZE);
// //随机生成需要查询的数值
// int searchVal=list[r.nextInt(ARRAY_SIZE)];
// int count;
// long startTime,endTime;
// System.out.println("--------------插值查寻法--------------------");
// //开始时间
//
// startTime=new Date().getTime();
// //调用插值法查找
// count=interpolationSearch.insertValueSearch(list,searchVal);
// //结束时间
// endTime=new Date().getTime();
// System.out.println("算法运行时间:"+(endTime-startTime)+"ms");
// //输出查询值和查询次数
// System.out.println("searchVal:"+searchVal+", count:"+count);
//
// System.out.println("--------------二分查寻法--------------------");
// //开始时间
// startTime=new Date().getTime();
// //调用二分法查找
// count=interpolationSearch.binarySearch(list,searchVal);
// //结束时间
// endTime=new Date().getTime();
// System.out.println("算法运行时间:"+(endTime-startTime)+"ms");
// //输出查询值和查询次数
// System.out.println("searchVal:"+searchVal+", count:"+count);
//
// }
/**
* 随机数生产
* @param start
* @param end
* @return
*/
public int generatorRand(int start,int end) {
int randVal;
randVal=r.nextInt(end-start)+start;
return randVal;
}
/**
* 插值查寻法
* 算法的运行时间为O(logn);
* @param arr
* @param searchVal
* @return
*/
public int insertValueSearch(Integer[] arr,int searchVal) {
//初始化查询次数下界low上界high
int count=0,low =0,high=arr.length-1;
int mid,guess,temVal=0;
while(low<=high) {
/**
*1自适应选择
*2乘上1.0转为double类型,在进行除运算可避免整数除以整数后只保留整数的情况
*3 mid=low+(searchVal-arr[low])*(high-low)/(arr[high]-arr[low]);这种写法(searchVal-arr[low])*(high-low)计算可能会溢出Integer
*/
mid=low+(int)((searchVal-arr[low])*1.0/(arr[high]-arr[low])*(high-low));
guess=arr[mid];
System.out.println("guess:"+guess);
count++;
//找到值
if(guess==searchVal) {
System.out.println("下标:"+mid );
return count;
}
//定界
if(guess>searchVal) {
high=mid-1;
}else {
low=mid+1;
}
}
return -1;
}
/**
* 二分查寻法
* 算法的运行时间为O(logn);
* @param arr
* @param searchVal
* @return
*/
public int binarySearch(Integer[] arr,int searchVal) {
//初始化查询次数下界low上界high
int count=0,low =0,high=arr.length-1;
int mid,guess;
while(low<=high) {
//对半查找
//mid=low+(int)(0.5*(high-low));
mid=(low+high)/2;
guess=arr[mid];
System.out.println("guess:"+guess);
count++;
//找到值
if(guess==searchVal) {
System.out.println("下标:"+mid );
return count;
}
//定界
if(guess>searchVal) {
high=mid-1;
}else {
low=mid+1;
}
}
return -1;
}
public static void main(String[] args) {
double [] x = new double[]{10,50,60};
double [] y = new double[]{10,50,51};
// lagrangeInterpolation(x,y,20);
System.out.println(lagrangeInterpolation(x,y,5));
}
public static double lagrangeInterpolation(double[] x, double[] y, double xi) {
double result = 0;
for (int i = 0; i < x.length; i++) {
double term = y[i];
for (int j = 0; j < x.length; j++) {
if (j != i) {
term *= (xi - x[j]) / (x[i] - x[j]);
}
}
result += term;
}
return result;
}
}