diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizEngineering/controller/BizEngineeringController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizEngineering/controller/BizEngineeringController.java index 9020ff3e..a859b852 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizEngineering/controller/BizEngineeringController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizEngineering/controller/BizEngineeringController.java @@ -10,6 +10,10 @@ import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.project.baseConfig.bizEngineering.entity.BizEngineering; 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.service.IBizCmaqService; +import org.jeecg.modules.project.calculateConfig.bizWrf.entity.BizWrf; +import org.jeecg.modules.project.calculateConfig.bizWrf.service.IBizWrfService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; @@ -26,6 +30,12 @@ public class BizEngineeringController { @Autowired private IBizEngineeringService bizEngineeringService; + @Autowired + private IBizWrfService bizWrfService; + + @Autowired + private IBizCmaqService bizCmaqService; + @Value("${spring.baseHome}") private String baseHome; @@ -43,7 +53,7 @@ public class BizEngineeringController { eq(BizEngineering::getCreateBy,sysUser.getUsername()). orderByDesc(BizEngineering::getCreateTime)); if(bizEngineerings == null || bizEngineerings.isEmpty()) { - String engPath = String.format("%s%s",baseHome,sysUser.getUsername()); + String engPath = String.format("%s%s/",baseHome,sysUser.getUsername()); BizEngineering bizEngineering = new BizEngineering(); bizEngineering.setCreateBy(sysUser.getUsername()); bizEngineering.setCreateTime(new Date()); @@ -53,9 +63,9 @@ public class BizEngineeringController { bizEngineeringService.save(bizEngineering); bizEngineerings.add(bizEngineering); } - for (BizEngineering bizEngineering : bizEngineerings) { - bizEngineering.setEngineeringPath(bizEngineering.getEngineeringPath() + "/" + bizEngineering.getId()); - } +// for (BizEngineering bizEngineering : bizEngineerings) { +// bizEngineering.setEngineeringPath(bizEngineering.getEngineeringPath() + "/" + bizEngineering.getEngineeringName()); +// } return Result.OK(bizEngineerings); } @@ -70,12 +80,34 @@ public class BizEngineeringController { @ApiOperation(value="工程管理-添加", notes="工程管理-添加") //@RequiresPermissions("bizWrf:biz_wrf:add") @PostMapping(value = "/add") - public Result add(@RequestBody BizEngineering bizEngineering) { + public Result add(@RequestBody BizEngineering bizEngineering) { LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String engPath= String.format("%s%s",baseHome,sysUser.getUsername()); + String engPath = String.format("%s%s/",baseHome,sysUser.getUsername()); bizEngineering.setEngineeringPath(engPath); bizEngineeringService.save(bizEngineering); - return Result.OK("添加成功!"); + + + BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper().eq(BizWrf::getTemType, bizEngineering.getSceneType())); + bizWrf.setId(null); + bizWrf.setEngineeringId(bizEngineering.getId()); + bizWrf.setTemType(0); + bizWrf.setUpdateBy(null); + bizWrf.setUpdateTime(null); + bizWrf.setCreateBy(null); + bizWrf.setCreateTime(null); + bizWrfService.save(bizWrf); + + BizCmaq bizCmaq = bizCmaqService.getOne(new LambdaQueryWrapper().eq(BizCmaq::getTemType, bizEngineering.getSceneType())); + bizCmaq.setId(null); + bizCmaq.setEngineeringId(bizEngineering.getId()); + bizCmaq.setTemType(0); + bizCmaq.setUpdateBy(null); + bizCmaq.setUpdateTime(null); + bizCmaq.setCreateBy(null); + bizCmaq.setCreateTime(null); + bizCmaqService.save(bizCmaq); + + return Result.OK(bizEngineering); } /** @@ -86,27 +118,41 @@ public class BizEngineeringController { */ @AutoLog(value = "工程管理-编辑") @ApiOperation(value="工程管理-编辑", notes="工程管理-编辑") - //@RequiresPermissions("bizWrf:biz_wrf:add") @PutMapping(value = "/edit") public Result edit(@RequestBody BizEngineering bizEngineering) { bizEngineeringService.updateById(bizEngineering); return Result.OK("编辑成功!"); } -// /** -// * 编辑 -// * -// * @param bizEngineering -// * @return -// */ -// @AutoLog(value = "BizEngineering-编辑") -// @ApiOperation(value="BizEngineering-编辑", notes="BizEngineering-编辑") -// //@RequiresPermissions("bizWrf:biz_wrf:add") -// @PostMapping(value = "/updateStateById") -// public Result updateStateById(String id) { -// bizEngineeringService.updateById(bizEngineering); -// return Result.OK("编辑成功!"); -// } + /** + * 修改运行状态 + * + * @param bizEngineering + * @return + */ + @AutoLog(value = "工程管理-修改运行状态") + @ApiOperation(value="工程管理-修改运行状态", notes="工程管理-修改运行状态") + @PutMapping(value = "/updateRunStatus") + public Result updateRunStatus(@RequestBody BizEngineering bizEngineering) { + bizEngineeringService.updateById(bizEngineering); + return Result.OK("修改运行状态成功!"); + } + + /** + * 通过id查询 + * + * @param id + * @return + */ + @ApiOperation(value="工程管理-通过id查询", notes="工程管理-通过id查询") + @GetMapping(value = "/queryById") + public Result queryById(@RequestParam(name="id",required=true) String id) { + BizEngineering bizEngineering = bizEngineeringService.getById(id); + if(bizEngineering==null) { + return Result.error("未找到对应数据"); + } + return Result.OK(bizEngineering); + } /** * 查询最新工程 diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizEngineering/entity/BizEngineering.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizEngineering/entity/BizEngineering.java index 4ee50df5..1edc177a 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizEngineering/entity/BizEngineering.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizEngineering/entity/BizEngineering.java @@ -42,9 +42,12 @@ public class BizEngineering { * */ @ApiModelProperty(value = "工程存放地址") private String engineeringPath; - /**工程选中状态*/ - @ApiModelProperty(value = "工程选中状态") - private int engineeringState; + /**工程运行状态*/ + @ApiModelProperty(value = "工程运行状态") + private int runStatus; + /**异常时运行阶段*/ + @ApiModelProperty(value = "异常时运行阶段") + private int errorStatus; /**备注*/ @ApiModelProperty(value = "备注") private String remark; diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizEngineering/service/IBizEngineeringService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizEngineering/service/IBizEngineeringService.java index c18306ec..ede5ead9 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizEngineering/service/IBizEngineeringService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizEngineering/service/IBizEngineeringService.java @@ -1,8 +1,11 @@ package org.jeecg.modules.project.baseConfig.bizEngineering.service; import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.common.api.vo.Result; import org.jeecg.modules.project.baseConfig.bizEngineering.entity.BizEngineering; public interface IBizEngineeringService extends IService { BizEngineering getBizEngineeringByTime(); + void updateRunStatus(String engId,int status); + void updateErrorStatus(String engId,int status); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizEngineering/service/impl/BizEngineeringServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizEngineering/service/impl/BizEngineeringServiceImpl.java index 68d46f32..bf81c3b7 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizEngineering/service/impl/BizEngineeringServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizEngineering/service/impl/BizEngineeringServiceImpl.java @@ -3,12 +3,14 @@ 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.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; @@ -26,7 +28,7 @@ public class BizEngineeringServiceImpl extends ServiceImpl */ @AutoLog(value = "Gis和角色权限管理表-批量编辑") @ApiOperation(value="Gis和角色权限管理表-批量编辑", notes="Gis和角色权限管理表-批量编辑") - @RequiresPermissions("bizRole:biz_role:editBatch") @RequestMapping(value = "/editBatch", method = {RequestMethod.PUT,RequestMethod.POST}) public Result editBatch(@RequestBody List bizRoles) { for (BizRole bizRole : bizRoles) { diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/controller/BizSourceItemController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/controller/BizSourceItemController.java new file mode 100644 index 00000000..59ce7891 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/controller/BizSourceItemController.java @@ -0,0 +1,178 @@ +package org.jeecg.modules.project.baseConfig.bizSourceItem.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.bizSourceItem.entity.BizSourceItem; +import org.jeecg.modules.project.baseConfig.bizSourceItem.service.IBizSourceItemService; + +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-09-26 + * @Version: V1.0 + */ +@Api(tags="源项参数") +@RestController +@RequestMapping("/bizSourceItem/bizSourceItem") +@Slf4j +public class BizSourceItemController extends JeecgController { + @Autowired + private IBizSourceItemService bizSourceItemService; + + /** + * 分页列表查询 + * + * @param bizSourceItem + * @param pageNo + * @param pageSize + * @param req + * @return + */ + //@AutoLog(value = "源项参数-分页列表查询") + @ApiOperation(value="源项参数-分页列表查询", notes="源项参数-分页列表查询") + @GetMapping(value = "/list") + public Result> queryPageList(BizSourceItem bizSourceItem, + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, + HttpServletRequest req) { + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(bizSourceItem, req.getParameterMap()); + Page page = new Page(pageNo, pageSize); + IPage pageList = bizSourceItemService.page(page, queryWrapper); + return Result.OK(pageList); + } + + /** + * 添加 + * + * @param bizSourceItem + * @return + */ + @AutoLog(value = "源项参数-添加") + @ApiOperation(value="源项参数-添加", notes="源项参数-添加") + @RequiresPermissions("bizSourceItem:biz_source_item:add") + @PostMapping(value = "/add") + public Result add(@RequestBody BizSourceItem bizSourceItem) { + bizSourceItemService.save(bizSourceItem); + return Result.OK("添加成功!"); + } + + /** + * 编辑 + * + * @param bizSourceItem + * @return + */ + @AutoLog(value = "源项参数-编辑") + @ApiOperation(value="源项参数-编辑", notes="源项参数-编辑") + @RequiresPermissions("bizSourceItem:biz_source_item:edit") + @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) + public Result edit(@RequestBody BizSourceItem bizSourceItem) { + bizSourceItemService.updateById(bizSourceItem); + return Result.OK("编辑成功!"); + } + + /** + * 通过id删除 + * + * @param id + * @return + */ + @AutoLog(value = "源项参数-通过id删除") + @ApiOperation(value="源项参数-通过id删除", notes="源项参数-通过id删除") + @RequiresPermissions("bizSourceItem:biz_source_item:delete") + @DeleteMapping(value = "/delete") + public Result delete(@RequestParam(name="id",required=true) String id) { + bizSourceItemService.removeById(id); + return Result.OK("删除成功!"); + } + + /** + * 批量删除 + * + * @param ids + * @return + */ + @AutoLog(value = "源项参数-批量删除") + @ApiOperation(value="源项参数-批量删除", notes="源项参数-批量删除") + @RequiresPermissions("bizSourceItem:biz_source_item:deleteBatch") + @DeleteMapping(value = "/deleteBatch") + public Result deleteBatch(@RequestParam(name="ids",required=true) String ids) { + this.bizSourceItemService.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 queryById(@RequestParam(name="id",required=true) String id) { + BizSourceItem bizSourceItem = bizSourceItemService.getById(id); + if(bizSourceItem==null) { + return Result.error("未找到对应数据"); + } + return Result.OK(bizSourceItem); + } + + /** + * 导出excel + * + * @param request + * @param bizSourceItem + */ + @RequiresPermissions("bizSourceItem:biz_source_item:exportXls") + @RequestMapping(value = "/exportXls") + public ModelAndView exportXls(HttpServletRequest request, BizSourceItem bizSourceItem) { + return super.exportXls(request, bizSourceItem, BizSourceItem.class, "源项参数"); + } + + /** + * 通过excel导入数据 + * + * @param request + * @param response + * @return + */ + @RequiresPermissions("bizSourceItem:biz_source_item:importExcel") + @RequestMapping(value = "/importExcel", method = RequestMethod.POST) + public Result importExcel(HttpServletRequest request, HttpServletResponse response) { + return super.importExcel(request, response, BizSourceItem.class); + } + +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/entity/BizSourceItem.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/entity/BizSourceItem.java new file mode 100644 index 00000000..ed1f3ed2 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/entity/BizSourceItem.java @@ -0,0 +1,77 @@ +package org.jeecg.modules.project.baseConfig.bizSourceItem.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-09-26 + * @Version: V1.0 + */ +@Data +@TableName("biz_source_item") +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = false) +@ApiModel(value="biz_source_item对象", description="源项参数") +public class BizSourceItem 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 String nuclideType; + /**释放量*/ + @Excel(name = "释放量", width = 15) + @ApiModelProperty(value = "释放量") + private Double releaseAmount; + /**释放时间*/ + @Excel(name = "释放时间", width = 20, format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "释放时间") + private Date releaseTime; + /**持续时间*/ + @Excel(name = "持续时间", width = 15) + @ApiModelProperty(value = "持续时间") + private Double durationTime; + /**释放高度*/ + @Excel(name = "释放高度", width = 15) + @ApiModelProperty(value = "释放高度") + private Double releaseHeight; +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/mapper/BizSourceItemMapper.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/mapper/BizSourceItemMapper.java new file mode 100644 index 00000000..48555172 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/mapper/BizSourceItemMapper.java @@ -0,0 +1,17 @@ +package org.jeecg.modules.project.baseConfig.bizSourceItem.mapper; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; +import org.jeecg.modules.project.baseConfig.bizSourceItem.entity.BizSourceItem; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * @Description: 源项参数 + * @Author: jeecg-boot + * @Date: 2023-09-26 + * @Version: V1.0 + */ +public interface BizSourceItemMapper extends BaseMapper { + +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/mapper/xml/BizSourceItemMapper.xml b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/mapper/xml/BizSourceItemMapper.xml new file mode 100644 index 00000000..a09bfd63 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/mapper/xml/BizSourceItemMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/service/IBizSourceItemService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/service/IBizSourceItemService.java new file mode 100644 index 00000000..0b27574d --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/service/IBizSourceItemService.java @@ -0,0 +1,14 @@ +package org.jeecg.modules.project.baseConfig.bizSourceItem.service; + +import org.jeecg.modules.project.baseConfig.bizSourceItem.entity.BizSourceItem; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * @Description: 源项参数 + * @Author: jeecg-boot + * @Date: 2023-09-26 + * @Version: V1.0 + */ +public interface IBizSourceItemService extends IService { + +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/service/impl/BizSourceItemServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/service/impl/BizSourceItemServiceImpl.java new file mode 100644 index 00000000..f8fb7cf9 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/baseConfig/bizSourceItem/service/impl/BizSourceItemServiceImpl.java @@ -0,0 +1,19 @@ +package org.jeecg.modules.project.baseConfig.bizSourceItem.service.impl; + +import org.jeecg.modules.project.baseConfig.bizSourceItem.entity.BizSourceItem; +import org.jeecg.modules.project.baseConfig.bizSourceItem.mapper.BizSourceItemMapper; +import org.jeecg.modules.project.baseConfig.bizSourceItem.service.IBizSourceItemService; +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +/** + * @Description: 源项参数 + * @Author: jeecg-boot + * @Date: 2023-09-26 + * @Version: V1.0 + */ +@Service +public class BizSourceItemServiceImpl extends ServiceImpl implements IBizSourceItemService { + +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizCmaq/controller/BizCmaqController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizCmaq/controller/BizCmaqController.java index 294f3c7a..e26f7e4b 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizCmaq/controller/BizCmaqController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizCmaq/controller/BizCmaqController.java @@ -96,8 +96,8 @@ public class BizCmaqController extends JeecgController @PostMapping(value = "/add") public Result add(@RequestBody BizCmaq bizCmaq) { BizWrf wrf = bizWrfService.getOne(new LambdaQueryWrapper().eq(BizWrf::getEngineeringId,bizCmaq.getEngineeringId())); - bizCmaq.setColsN(Double.valueOf(wrf.getWe()) -3 + ""); - bizCmaq.setRowsN(Double.valueOf(wrf.getSn()) -3 + ""); + bizCmaq.setColsN(Integer.valueOf(wrf.getWe()) -3 + ""); + bizCmaq.setRowsN(Integer.valueOf(wrf.getSn()) -3 + ""); bizCmaq.setWrfLcRefLat(wrf.getRefLat()); bizCmaqService.saveOrUpdate(bizCmaq); return Result.OK("添加成功!"); @@ -180,8 +180,8 @@ public class BizCmaqController extends JeecgController } BizWrf wrf = bizWrfService.getOne(new LambdaQueryWrapper().eq(BizWrf::getEngineeringId,bizCmaq.getEngineeringId())); if(wrf != null){ - bizCmaq.setColsN(Double.valueOf(wrf.getWe()) -3 + ""); - bizCmaq.setRowsN(Double.valueOf(wrf.getSn()) -3 + ""); + bizCmaq.setColsN(Integer.valueOf(wrf.getWe()) -3 + ""); + bizCmaq.setRowsN(Integer.valueOf(wrf.getSn()) -3 + ""); bizCmaq.setWrfLcRefLat(wrf.getRefLat()); } return Result.OK(bizCmaq); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizCmaq/service/impl/BizCmaqServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizCmaq/service/impl/BizCmaqServiceImpl.java index 3d006479..5d1f0b69 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizCmaq/service/impl/BizCmaqServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizCmaq/service/impl/BizCmaqServiceImpl.java @@ -242,7 +242,7 @@ public class BizCmaqServiceImpl extends ServiceImpl impl String METCRO3DNcName = String.format("METCRO3D_d0%s_%s.nc",i+1,DateUtil.format(new Date(tmpSecs), yymdFormat)); runGeneratePy(emisBenchPath + emisBenchNcName,METCRO3DPath + METCRO3DNcName,emisBenchPath + outputNcName); - List coAndPecInfo = bizOpenfoamService.getCoAndPecInfo(wrf); + List coAndPecInfo = bizOpenfoamService.getCoAndPecInfo(wrf,engineering.getEngineeringName()); String coNcName = String.format("co_emis_d0%s_%s.nc",i+1,DateUtil.format(new Date(tmpSecs), yymdFormat)); String perNcName = String.format("emis_d0%s_%s.nc",i+1,DateUtil.format(new Date(tmpSecs), yymdFormat)); runSetvaluePy("CO",coAndPecInfo.get(0),emisBenchPath + outputNcName,emisBenchPath + coNcName,wrf.getXIndex(),wrf.getYIndex(),openfoam.getLayer()); @@ -283,7 +283,9 @@ public class BizCmaqServiceImpl extends ServiceImpl impl String ncName = "CCTM_ACONC_v532_2016_12SE1_" + sdf.format(sdf.parse(bizCmaq.getStartDate())).replace("-", "") + ".nc"; NetcdfFile ncfile = NetcdfDataset.open(targetFilePath + ncName); BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper().eq(BizWrf::getEngineeringId, bizEngineering.getId())); - String ncNameWrf = "wrfout_d01_" + bizWrf.getStartTime(); + //正式环境需要修改 +// String ncNameWrf = "wrfout_d01_" + bizWrf.getStartTime(); + String ncNameWrf = "wrfout_d01_2016-07-01_00_00_00"; NetcdfFile griddot2d = NetcdfDataset.open(targetFilePath + ncNameWrf); List>> coAllList = getNCByName(ncfile, "CO", layer); List>> no2AllList = getNCByName(ncfile, "NO2", layer); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizOpenfoam/controller/BizOpenfoamController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizOpenfoam/controller/BizOpenfoamController.java index a9d9df06..a2a68881 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizOpenfoam/controller/BizOpenfoamController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizOpenfoam/controller/BizOpenfoamController.java @@ -10,6 +10,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 org.apache.commons.lang3.StringUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.query.QueryGenerator; @@ -27,6 +28,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.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; @@ -54,10 +56,14 @@ public class BizOpenfoamController extends JeecgController().eq(BizOpenfoam::getEngineeringId,engineeringId)); - String openFoamPath = localFilePrefix + "OpenFOAM/" + openfoam.getCreateBy() + "/" + engineering.getEngineeringName(); + String openFoamPath = runOpenFOAMPath + openfoam.getCreateBy() + "/" + engineering.getEngineeringName(); String runCmd = String.format("cd %s;%s;",openFoamPath,openfoam.getFoam()); RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, runCmd); return "运行成功"; } - public double[][][] resolveOpenFoamResult(int startLine,int x,int y,int z,String openFoamPath,String param) throws IOException { - String stepFileName = bizOpenfoamService.getStepFileName(openFoamPath); + public double[][][] resolveOpenFoamResult(int startLine,int x,int y,int z,String localFilePath,String param) throws IOException { if(StringUtils.isBlank(param)){ param = "c1"; } - Path p = Paths.get( openFoamPath + "/" + stepFileName + "/" + param); + Path p = Paths.get( localFilePath + "/" + param); List lines = Files.readAllLines(p); double[][][] result = new double[x][y][z]; if(lines != null && !lines.isEmpty()) { @@ -185,12 +190,11 @@ public class BizOpenfoamController extends JeecgController().eq(BizWrf::getEngineeringId,engineeringId)); - String openFoamPath = localFilePrefix + "OpenFOAM/" + wrf.getCreateBy() + "/" + engineering.getEngineeringName(); -// String openFoamPath = "C:\\Users\\13673\\Desktop\\Nuclear\\file\\openfoam\\bak\\cylinder_U"; - String systemPath = openFoamPath + "/system/"; + String openFoamPath = runOpenFOAMPath + wrf.getCreateBy() + "/" + engineering.getEngineeringName(); + String localFilePath = localFilePrefix + wrf.getCreateBy() + "/" + engineering.getEngineeringName() + "/"; String [] hexArray = null; - List blockMeshDictFileInfos = Files.readAllLines(Paths.get(systemPath + "blockMeshDict")); + List blockMeshDictFileInfos = Files.readAllLines(Paths.get(cshTemFielPath + "blockMeshDict")); for (String info : blockMeshDictFileInfos) { if(info.indexOf("hex") > 0){ int index1 = info.indexOf("("); @@ -233,15 +237,20 @@ public class BizOpenfoamController extends JeecgController controlDicts = Files.readAllLines(controlDictPath); List result = new ArrayList<>(); for (String controlDict : controlDicts) { - if(controlDict.indexOf("application ") > 0){ + if(controlDict.indexOf("application ") >= 0){ controlDict = "application "+bizOpenfoam.getApplication()+";"; } - if(controlDict.indexOf("startTime ") > 0){ + if(controlDict.indexOf("startTime ") >= 0){ controlDict = "startTime "+bizOpenfoam.getStartTime()+";"; } - if(controlDict.indexOf("endTime ") > 0){ + if(controlDict.indexOf("endTime ") >= 0){ controlDict = "endTime "+bizOpenfoam.getEndTime()+";"; } - if(controlDict.indexOf("deltaT ") > 0){ + if(controlDict.indexOf("deltaT ") >= 0){ controlDict = "deltaT "+bizOpenfoam.getDeltat()+";"; } - if(controlDict.indexOf("writeInterval ") > 0){ + if(controlDict.indexOf("writeInterval ") >= 0){ controlDict = "writeInterval "+bizOpenfoam.getWriteinterval()+";"; } result.add(controlDict); } - FileOutputStream fileOutputStream = new FileOutputStream(controlDictFilePath); + String localFilePath = localFilePrefix + bizEngineering.getCreateBy() + "/" + bizEngineering.getEngineeringName() + "/"; + FileOutputStream fileOutputStream = new FileOutputStream(localFilePath + "controlDict"); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fileOutputStream)); for (String res : result) { bw.write(res); @@ -295,11 +306,24 @@ public class BizOpenfoamController extends JeecgController { - List getCoAndPecInfo(BizWrf wrf); + List getCoAndPecInfo(BizWrf wrf,String engineeringName); String getStepFileName(String systemPath); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizOpenfoam/service/impl/BizOpenfoamServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizOpenfoam/service/impl/BizOpenfoamServiceImpl.java index 70f45387..3f304812 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizOpenfoam/service/impl/BizOpenfoamServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizOpenfoam/service/impl/BizOpenfoamServiceImpl.java @@ -1,12 +1,12 @@ 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.baseConfig.bizEngineering.service.IBizEngineeringService; 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.springframework.beans.factory.annotation.Autowired; +import org.jeecg.modules.util.SFTPUtil; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -29,24 +29,30 @@ import java.util.regex.Pattern; @Service public class BizOpenfoamServiceImpl extends ServiceImpl implements IBizOpenfoamService { - @Value("${spring.baseHome}") - private String baseHome; - + @Value("${spring.OpenFOAM.runOpenFOAMPath}") + private String runOpenFOAMPath; + @Value("${spring.cshTemFielPath}") + private String cshTemFielPath; @Value("${spring.localFilePrefix}") private String localFilePrefix; - @Autowired - private IBizEngineeringService bizEngineeringService; + @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; @Override - public List getCoAndPecInfo(BizWrf wrf) { - BizEngineering engineering = bizEngineeringService.getById(wrf.getEngineeringId()); - String openFoamPath = localFilePrefix + "OpenFOAM/" + wrf.getCreateBy() + "/" + engineering.getEngineeringName(); - + public List getCoAndPecInfo(BizWrf wrf,String engineeringName) { + String openFoamPath = runOpenFOAMPath + wrf.getCreateBy() + "/" + engineeringName; + String localFilePath = localFilePrefix + wrf.getCreateBy() + "/" + engineeringName + "/"; String stepFileName = getStepFileName(openFoamPath); try { String [] hexArray = null; - List blockMeshDictFileInfos = Files.readAllLines(Paths.get(openFoamPath + "/system/" + "blockMeshDict")); + List blockMeshDictFileInfos = Files.readAllLines(Paths.get(cshTemFielPath + "blockMeshDict")); for (String info : blockMeshDictFileInfos) { if(info.indexOf("hex") > 0){ int index1 = info.indexOf("("); @@ -56,8 +62,15 @@ public class BizOpenfoamServiceImpl extends ServiceImpl c1Lines = Files.readAllLines(Paths.get(openFoamPath + "/" + stepFileName + "/c1")); - List c2Lines = Files.readAllLines(Paths.get(openFoamPath + "/" + stepFileName + "/c2")); + + SFTPUtil sftpUtil = new SFTPUtil(); + sftpUtil.login(username, password,ip,port); + sftpUtil.download(openFoamPath + "/" + stepFileName,"c1",localFilePath + "c1"); + sftpUtil.download(openFoamPath + "/" + stepFileName,"c2",localFilePath + "c2"); + sftpUtil.logout(); + + List c1Lines = Files.readAllLines(Paths.get(localFilePath + "/c1")); + List c2Lines = Files.readAllLines(Paths.get(localFilePath + "/c2")); List c1Values = new ArrayList<>(); List c2Values = new ArrayList<>(); for (int i = 22; i < count; i++) { @@ -76,7 +89,7 @@ public class BizOpenfoamServiceImpl extends ServiceImpl folderNames = getFolderNames(systemPath); + String [] folderNames = RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, String.format("cd %s;ls",systemPath)).split("\\n"); List stepFileNames = new ArrayList<>(); for (String folderName : folderNames) { if(isNumeric(folderName)){ @@ -85,10 +98,6 @@ public class BizOpenfoamServiceImpl extends ServiceImpl { public void saveWpsFile(BizWrf bizWrf,String engineeringName){ String allRunPath = baseHome + bizWrf.getCreateBy() + "/" + engineeringName + "/"; - String localFilePath = localFilePrefix + "/" + bizWrf.getCreateBy() + "/" + engineeringName + "/"; + String localFilePath = localFilePrefix + bizWrf.getCreateBy() + "/" + engineeringName + "/"; String fileName = "namelist.wps"; try { String startStr = ""; @@ -199,7 +199,7 @@ public class BizWrfController extends JeecgController { public void saveInputFile(BizWrf bizWrf,String engineeringName){ String allRunPath = baseHome + bizWrf.getCreateBy() + "/" + engineeringName + "/"; - String localFilePath = localFilePrefix + "/" + bizWrf.getCreateBy() + "/" + engineeringName + "/"; + String localFilePath = localFilePrefix + bizWrf.getCreateBy() + "/" + engineeringName + "/"; try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss"); Calendar startCal = Calendar.getInstance(); @@ -288,6 +288,18 @@ public class BizWrfController extends JeecgController { } } + /** + * 获取程序运行路径 + * + * @return + */ + @GetMapping(value = "/getAllRunPath") + public String getAllRunPath(String engineeringId) { + BizEngineering engineering = bizEngineeringService.getById(engineeringId); + String allRunPath = baseHome + engineering.getCreateBy() + "/" + engineering.getEngineeringName() + "/"; + return allRunPath; + } + /** * 运行WPS * @@ -298,7 +310,7 @@ public class BizWrfController extends JeecgController { BizEngineering engineering = bizEngineeringService.getById(engineeringId); BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper().eq(BizWrf::getEngineeringId,engineering.getId())); String allRunPath = baseHome + bizWrf.getCreateBy() + "/" + engineering.getEngineeringName() + "/"; - String localFilePath = localFilePrefix + "/" + bizWrf.getCreateBy() + "/" + engineering.getEngineeringName() + "/"; + String localFilePath = localFilePrefix + bizWrf.getCreateBy() + "/" + engineering.getEngineeringName() + "/"; String format = "yyyy-MM-dd_hh:mm:ss"; String ymdFormat = "yyyy-MM-dd"; @@ -338,11 +350,11 @@ public class BizWrfController extends JeecgController { BizEngineering engineering = bizEngineeringService.getById(engineeringId); BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper().eq(BizWrf::getEngineeringId,engineering.getId())); String allRunPath = baseHome + bizWrf.getCreateBy() + "/" + engineering.getEngineeringName() + "/"; - String localFilePath = localFilePrefix + "/" + bizWrf.getCreateBy() + "/" + engineering.getEngineeringName() + "/"; + String localFilePath = localFilePrefix + bizWrf.getCreateBy() + "/" + engineering.getEngineeringName() + "/"; 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;./wrf.exe >&wrf.log"); + RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, cdWRF + "ulimit -s unlimited;./real.exe"); + RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, cdWRF + "ulimit -s unlimited;./wrf.exe"); SFTPUtil sftpUtil = new SFTPUtil(); sftpUtil.login(username, password,ip,port); @@ -384,7 +396,7 @@ public class BizWrfController extends JeecgController { BizEngineering engineering = bizEngineeringService.getById(engineeringId); BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper().eq(BizWrf::getEngineeringId,engineering.getId())); String allRunPath = baseHome + bizWrf.getCreateBy() + "/" + engineering.getEngineeringName() + "/"; - String localFilePath = localFilePrefix + "/" + bizWrf.getCreateBy() + "/" + engineering.getEngineeringName() + "/"; + String localFilePath = localFilePrefix + bizWrf.getCreateBy() + "/" + engineering.getEngineeringName() + "/"; SFTPUtil sftpUtil = new SFTPUtil(); sftpUtil.login(username, password,ip,port); @@ -412,6 +424,7 @@ public class BizWrfController extends JeecgController { List> resultSample = new ArrayList<>(); int column = 0; BizEngineering bizEngineering = bizEngineeringService.getById(engineeringId); + String localFilePath = localFilePrefix + "/" + bizEngineering.getCreateBy() + "/" + bizEngineering.getEngineeringName() + "/"; try { // NetcdfFile ncfile = NetcdfDataset.open("C:\\Users\\13673\\Desktop\\某源\\Nuclear\\file\\wrfout_d01_2016-07-01_00_00_00"); BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper().eq(BizWrf::getEngineeringId,bizEngineering.getId())); @@ -419,8 +432,10 @@ public class BizWrfController extends JeecgController { DateTime startTime = DateUtil.parse(bizWrf.getStartTime(), format); long oneDaySecs = 60 * 60 * 24 * 1000; String newStartTime = DateUtil.format(new Date(startTime.getTime() + oneDaySecs), format); - String ncNameWrf = "wrfout_d01_" + newStartTime; - NetcdfFile ncfile = NetcdfDataset.open(localFilePrefix + ncNameWrf); + //正式环境需要修改 +// String ncNameWrf = "wrfout_d01_" + newStartTime; + String ncNameWrf = "wrfout_d01_2016-07-01_00_00_00"; + NetcdfFile ncfile = NetcdfDataset.open(localFilePath + ncNameWrf); List>> xlatAllList = getNCByName(ncfile, "XLAT",layer); List>> xlongAllList = getNCByName(ncfile, "XLONG",layer); List>> uAllList = getNCByName(ncfile, "U",layer); @@ -473,6 +488,7 @@ public class BizWrfController extends JeecgController { List> resultSample = new ArrayList<>(); int column = 0; BizEngineering bizEngineering = bizEngineeringService.getById(engineeringId); + String localFilePath = localFilePrefix + "/" + bizEngineering.getCreateBy() + "/" + bizEngineering.getEngineeringName() + "/"; try { // NetcdfFile ncfile = NetcdfDataset.open("C:\\Users\\13673\\Desktop\\某源\\Nuclear\\file\\wrfout_d01_2016-07-01_00_00_00"); BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper().eq(BizWrf::getEngineeringId,bizEngineering.getId())); @@ -480,8 +496,10 @@ public class BizWrfController extends JeecgController { DateTime startTime = DateUtil.parse(bizWrf.getStartTime(), format); long oneDaySecs = 60 * 60 * 24 * 1000; String newStartTime = DateUtil.format(new Date(startTime.getTime() + oneDaySecs), format); - String ncNameWrf = "wrfout_d01_" + newStartTime; - NetcdfFile ncfile = NetcdfDataset.open(localFilePrefix + ncNameWrf); + //正式环境需要修改 +// String ncNameWrf = "wrfout_d01_" + newStartTime; + String ncNameWrf = "wrfout_d01_2016-07-01_00_00_00"; + NetcdfFile ncfile = NetcdfDataset.open(localFilePath + ncNameWrf); List>> hgtAllList = getNCByName(ncfile, "HGT",0); List>> xlatAllList = getNCByName(ncfile, "XLAT",0); List>> xlongAllList = getNCByName(ncfile, "XLONG",0); @@ -518,6 +536,7 @@ public class BizWrfController extends JeecgController { public Result> getNCPointInfo(String engineeringId,String lon,String lat) { Map map = new HashMap<>(); BizEngineering bizEngineering = bizEngineeringService.getById(engineeringId); + String localFilePath = localFilePrefix + "/" + bizEngineering.getCreateBy() + "/" + bizEngineering.getEngineeringName() + "/"; try { BizWrf bizWrf = bizWrfService.getOne(new LambdaQueryWrapper().eq(BizWrf::getEngineeringId,bizEngineering.getId())); BizOpenfoam bizOpenFoam = bizOpenfoamService.getOne(new LambdaQueryWrapper().eq(BizOpenfoam::getEngineeringId, bizWrf.getEngineeringId())); @@ -531,8 +550,10 @@ public class BizWrfController extends JeecgController { DateTime startTime = DateUtil.parse(bizWrf.getStartTime(), format); long oneDaySecs = 60 * 60 * 24 * 1000; String newStartTime = DateUtil.format(new Date(startTime.getTime() + oneDaySecs), format); - String ncNameWrf = "wrfout_d01_" + newStartTime; - NetcdfFile ncfile = NetcdfDataset.open(localFilePrefix + ncNameWrf); + //正式环境需要修改 +// String ncNameWrf = "wrfout_d01_" + newStartTime; + String ncNameWrf = "wrfout_d01_2016-07-01_00_00_00"; + NetcdfFile ncfile = NetcdfDataset.open(localFilePath + ncNameWrf); List>> uAllList = getNCByName(ncfile, "U",0); List>> vAllList = getNCByName(ncfile, "V",0); List>> pAllList = getNCByName(ncfile, "P",0); @@ -761,5 +782,7 @@ public class BizWrfController extends JeecgController { // double latticeHeight = Math.abs(Math.round((Double.valueOf("35.50") - Double.valueOf("44.47")) / 82 * 10000) / 10000d); // double latLatticeIndex = Math.abs(Math.ceil((Double.valueOf("42.24") - Double.valueOf("44.47")) / latticeHeight)); // System.out.println(lonLatticeIndex+"-"+latLatticeIndex); +// String wmhr = RemoteExecuteCommand.runRemoteLinuxCmd("192.168.115.128", "wmhr", "123456", "cd /home/wmhr/OpenFOAM-8/run/admin/工程001/;ls"); +// System.out.println(wmhr); } } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizWrf/service/IBizWrfService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizWrf/service/IBizWrfService.java index 02deebc6..71af8cd0 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizWrf/service/IBizWrfService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizWrf/service/IBizWrfService.java @@ -1,8 +1,11 @@ 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 java.io.IOException; + /** * @Description: wrf * @Author: jeecg-boot @@ -11,4 +14,10 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface IBizWrfService extends IService { + Result runGeogrid(String allRunPath, String engineeringId)throws IOException; + Result runUngrib(String allRunPath, String engineeringId)throws IOException; + Result runMetgrid(String allRunPath, String engineeringId)throws IOException; + Result runReal(String allRunPath, String engineeringId)throws IOException; + Result runWrf(String allRunPath, String engineeringId) throws IOException; + } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizWrf/service/impl/BizWrfServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizWrf/service/impl/BizWrfServiceImpl.java index 3b8b12f5..7ab6b707 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizWrf/service/impl/BizWrfServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateConfig/bizWrf/service/impl/BizWrfServiceImpl.java @@ -1,11 +1,27 @@ package org.jeecg.modules.project.calculateConfig.bizWrf.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.common.api.vo.Result; +import org.jeecg.common.util.RemoteExecuteCommand; +import org.jeecg.modules.project.baseConfig.bizEngineering.service.IBizEngineeringService; 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.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 java.io.IOException; +import java.util.Date; + +import static java.nio.file.Files.readAllBytes; +import static java.nio.file.Paths.get; /** * @Description: wrf @@ -16,4 +32,145 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @Service public class BizWrfServiceImpl extends ServiceImpl implements IBizWrfService { + @Value("${spring.baseHome}") + private String baseHome; + @Value("${spring.localFilePrefix}") + private String localFilePrefix; + @Value("${spring.WRF.fnldataPath}") + private String fnldataPath; + + @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; + + @Autowired + private IBizEngineeringService bizEngineeringService; + + @Override + public Result runGeogrid(String allRunPath, String engineeringId) throws IOException { + String localFilePath = allRunPath.replace(baseHome, localFilePrefix); + String cdWPS = "cd " + allRunPath + "WPS;"; + RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, cdWPS + "./geogrid.exe"); + + SFTPUtil sftpUtil = new SFTPUtil(); + sftpUtil.login(username, password,ip,port); + sftpUtil.download(allRunPath + "WPS","geogrid.log",localFilePath + "geogrid.log"); + sftpUtil.logout(); + String geogridLog = new String(readAllBytes(get(localFilePath + "geogrid.log"))); + if(geogridLog.indexOf("Successful completion of program geogrid.exe") > 0){ + bizEngineeringService.updateRunStatus(engineeringId,1); + return Result.OK("geogrid执行成功"); + }else{ + bizEngineeringService.updateErrorStatus(engineeringId,1); + return Result.OK(geogridLog); + } + } + + @Override + public Result runUngrib(String allRunPath,String engineeringId) throws IOException { + BizWrf bizWrf = this.baseMapper.selectOne(new LambdaQueryWrapper().eq(BizWrf::getEngineeringId,engineeringId)); + String localFilePath = allRunPath.replace(baseHome, localFilePrefix); + String cdWPS = "cd " + allRunPath + "WPS;"; + + String format = "yyyy-MM-dd_hh:mm:ss"; + String ymdFormat = "yyyy-MM-dd"; + DateTime startTime = DateUtil.parse(bizWrf.getStartTime(), format); + DateTime endTime = DateUtil.parse(bizWrf.getEndTime(), format); + long startTimeSecs = startTime.getTime(); + long endTimeSecs = endTime.getTime(); + long oneDaySecs = 60 * 60 * 24 * 1000; + StringBuffer runLinkGrib = new StringBuffer(); + for (long tmpSecs = startTimeSecs; tmpSecs <= endTimeSecs; tmpSecs += oneDaySecs) { + runLinkGrib.append(fnldataPath).append("fnl_").append(DateUtil.format(new Date(tmpSecs), ymdFormat).replace("-","")).append("* "); + } + RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, cdWPS + "./link_grib.csh " + runLinkGrib + ";cp ungrib/Variable_Tables/Vtable.GFS Vtable"); + RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, cdWPS + "./ungrib.exe"); + + SFTPUtil sftpUtil = new SFTPUtil(); + sftpUtil.login(username, password,ip,port); + sftpUtil.download(allRunPath + "WPS","ungrib.log",localFilePath + "ungrib.log"); + sftpUtil.logout(); + String ungribLog = new String(readAllBytes(get(localFilePath + "ungrib.log"))); + if(ungribLog.indexOf("Successful completion of program ungrib.exe") > 0){ + bizEngineeringService.updateRunStatus(engineeringId,2); + return Result.OK("ungrib执行成功"); + }else{ + bizEngineeringService.updateErrorStatus(engineeringId,2); + return Result.OK(ungribLog); + } + } + + @Override + public Result runMetgrid(String allRunPath,String engineeringId) throws IOException { + String localFilePath = allRunPath.replace(baseHome, localFilePrefix); + String cdWPS = "cd " + allRunPath + "WPS;"; + RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, cdWPS + "./metgrid.exe"); + + SFTPUtil sftpUtil = new SFTPUtil(); + sftpUtil.login(username, password,ip,port); + sftpUtil.download(allRunPath + "WPS","metgrid.log",localFilePath + "metgrid.log"); + sftpUtil.logout(); + String metgridLog = new String(readAllBytes(get(localFilePath + "metgrid.log"))); + if(metgridLog.indexOf("Successful completion of program metgrid.exe") > 0){ + bizEngineeringService.updateRunStatus(engineeringId,3); + return Result.OK("metgrid执行成功"); + }else{ + bizEngineeringService.updateErrorStatus(engineeringId,3); + return Result.OK(metgridLog); + } + } + + @Override + public Result runReal(String allRunPath,String engineeringId) throws IOException { + String localFilePath = allRunPath.replace(baseHome, localFilePrefix); + String cdWRF = "cd " + allRunPath + "WRF/run;"; + RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, cdWRF + "ulimit -s unlimited;./real.exe"); + + SFTPUtil sftpUtil = new SFTPUtil(); + sftpUtil.login(username, password,ip,port); + sftpUtil.download(allRunPath + "WRF/run","rsl.out.0000",localFilePath + "rsl.out.0000"); + sftpUtil.logout(); + String realLog = new String(readAllBytes(get(localFilePath + "rsl.out.0000"))); + if(realLog.indexOf("SUCCESS COMPLETE REAL_EM INIT") > 0){ + bizEngineeringService.updateRunStatus(engineeringId,4); + return Result.OK("real执行成功"); + }else{ + bizEngineeringService.updateErrorStatus(engineeringId,4); + return Result.OK(realLog); + } + } + + @Override + public Result runWrf(String allRunPath,String engineeringId) throws IOException { + String localFilePath = allRunPath.replace(baseHome, localFilePrefix); + String cdWRF = "cd " + allRunPath + "WRF/run;"; + BizWrf bizWrf = this.baseMapper.selectOne(new LambdaQueryWrapper().eq(BizWrf::getEngineeringId,engineeringId)); + RemoteExecuteCommand.runRemoteLinuxCmd(ip, username, password, cdWRF + "ulimit -s unlimited;./wrf.exe"); + + SFTPUtil sftpUtil = new SFTPUtil(); + sftpUtil.login(username, password,ip,port); + sftpUtil.download(allRunPath + "WRF/run","rsl.out.0000",localFilePath + "rsl.out.0000"); + String wrfLog = new String(readAllBytes(get(localFilePath + "rsl.out.0000"))); + if(wrfLog.indexOf("SUCCESS COMPLETE WRF") > 0){ + String format = "yyyy-MM-dd_HH:mm:ss"; + DateTime startTime = DateUtil.parse(bizWrf.getStartTime(), format); + long oneDaySecs = 60 * 60 * 24 * 1000; + String newStartTime = DateUtil.format(new Date(startTime.getTime() + oneDaySecs), format); + String ncNameWrf = "wrfout_d01_" + newStartTime; + sftpUtil.download(allRunPath + "WRF/run/",ncNameWrf,localFilePath + ncNameWrf); + sftpUtil.logout(); + + bizEngineeringService.updateRunStatus(engineeringId,5); + return Result.OK("SUCCESS COMPLETE WRF"); + } + bizEngineeringService.updateErrorStatus(engineeringId,5); + sftpUtil.logout(); + return Result.error(wrfLog); + } + } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateResult/runProcess/controller/RunProcessController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateResult/runProcess/controller/RunProcessController.java new file mode 100644 index 00000000..32f10214 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/project/calculateResult/runProcess/controller/RunProcessController.java @@ -0,0 +1,71 @@ +package org.jeecg.modules.project.calculateResult.runProcess.controller; + +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 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.modules.project.baseConfig.bizEngineering.entity.BizEngineering; +import org.jeecg.modules.project.baseConfig.bizEngineering.service.IBizEngineeringService; +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.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 javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Arrays; + +/** +* @Description: 运行过程 +* @Author: jeecg-boot +* @Date: 2023-09-20 +* @Version: V1.0 +*/ +@Api(tags="运行过程") +@RestController +@RequestMapping("/runProcess") +@Slf4j +public class RunProcessController extends JeecgController { + + @Autowired + private IBizEngineeringService bizEngineeringService; + + @Autowired + private IBizWrfService bizWrfService; + + @Value("${spring.baseHome}") + private String baseHome; + + + /** + * 运行wrf所有程序 + * + * @param + * @return + */ + @AutoLog(value = "运行过程-运行wrf所有程序") + @ApiOperation(value="运行过程-运行wrf所有程序", notes="运行过程-运行wrf所有程序") + @GetMapping(value = "/runAllExe") + public Result runAllExe(String engineeringId) throws IOException { + BizEngineering engineering = bizEngineeringService.getById(engineeringId); + String allRunPath = baseHome + engineering.getCreateBy() + "/" + engineering.getEngineeringName() + "/"; + bizWrfService.runGeogrid(allRunPath,engineeringId); + bizWrfService.runUngrib(allRunPath,engineeringId); + bizWrfService.runMetgrid(allRunPath,engineeringId); + bizWrfService.runReal(allRunPath,engineeringId); + bizWrfService.runWrf(allRunPath,engineeringId); + return Result.OK("运行成功!"); + } +} diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml b/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml index a4053121..7574dda8 100644 --- a/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml @@ -28,6 +28,9 @@ spring: fnldataPath: /home/wmhr/Build_WRF/WPS/fnldata/ CMAQ: pythonPath: /home/wmhr/python/ + OpenFOAM: + runOpenFOAMPath: /home/wmhr/OpenFOAM-8/run/ + temFielPath: /home/wmhr/OpenFOAM-8/cylinder_U/ Linux: ip: 192.168.115.128 username: wmhr