| | |
| | | package com.se.simu.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.se.simu.config.PropertiesConfig; |
| | | import com.se.simu.domain.dto.GeDb; |
| | |
| | | import com.se.simu.domain.vo.R; |
| | | import com.se.simu.domain.vo.SimuVo; |
| | | import com.se.simu.service.*; |
| | | import com.se.simu.utils.ShpToolUtils; |
| | | import io.swagger.annotations.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | // todo: 解析范围文件 根据不同的的格式文件进行不同的解析,获取需要计算的范围值 |
| | | // 上传格式:.shp/.tiff/.img/.geojson |
| | | // 重新给vo赋值 |
| | | // 1 读取shp文件,获取范围值 |
| | | JSONObject jsonObject = ShpToolUtils.readShp(floodFile); |
| | | // 2 获取jsonObject中的范围值 |
| | | vo.setMinx(jsonObject.getDouble("minX")); |
| | | vo.setMaxx(jsonObject.getDouble("maxX")); |
| | | vo.setMiny(jsonObject.getDouble("minY")); |
| | | vo.setMaxy(jsonObject.getDouble("maxY")); |
| | | } catch (Exception e) { |
| | | log.error("解析范围文件失败"); |
| | | if (null == vo.getMinx() || null == vo.getMiny() || null == vo.getMaxx() || null == vo.getMaxy()) { |
| | | return fail("解析范围文件失败!选择范围不能为空,请重新选择文件!", false); |
| | | } |
| | | } |
| | | |
| | | String stationFile = vo.getStationFile(); |
| | | log.info("站点文件shp地址:{}", floodFile); |
| | | |
| | | |
| | | String stationRainFile = vo.getStationRainFile(); |
| | | log.info("站点雨量CSV文件地址:{}", floodFile); |
| | | // TODO: 2024/12/24 根据这些文件的地址,获取文件内容,创建仿真视图 |
| | |
| | | if (null == vo.getDuration() || vo.getDuration() < 1 || vo.getDuration() > 10080) { |
| | | return fail("仿真时长不能为空,且取值在1~10080之间"); |
| | | } |
| | | if (null == vo.getMinx() || null == vo.getMiny() || null == vo.getMaxx() || null == vo.getMaxy()) { |
| | | return fail("选择范围不能为空", false); |
| | | } |
| | | if (null == vo.getPid() || vo.getPid() < 0) { |
| | | vo.setPid(0); |
| | | } |
| | | if (null == vo.getNum() || vo.getNum() < 1) { |
| | | vo.setNum(simuService.getMaxId() + 1); |
| | | } |
| | | if (null == vo.getPid() || vo.getPid() < 0) { |
| | | vo.setPid(0); |
| | | } |
| | | if (null == vo.getStartTime()) { |
| | | vo.setStartTime(new Date()); |
| | | } |
| | | // 防汛作业 |
| | | if (vo.getPid() > 0) { |
| | | SimuPo pp = simuService.getSimuByPid(vo.getPid()); |
| | | if (null == pp) { |
| | |
| | | return fail("防汛范围不能为空", false); |
| | | } |
| | | } |
| | | // 开始模拟计算 |
| | | boolean flag = simuFilesService.createByfiles(vo); |
| | | return success(flag, flag ? "成功" : "失败"); |
| | | } catch (Exception ex) { |