From 59c16d2a5b1d46e5ed88e43a2065ec39fe649bcf Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期一, 30 九月 2024 11:31:17 +0800 Subject: [PATCH] 1 --- src/main/java/com/se/simu/service/SimuService.java | 89 +++++++++++++++++++++++++++++++------------- 1 files changed, 62 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/se/simu/service/SimuService.java b/src/main/java/com/se/simu/service/SimuService.java index 800414f..76451c1 100644 --- a/src/main/java/com/se/simu/service/SimuService.java +++ b/src/main/java/com/se/simu/service/SimuService.java @@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.se.simu.config.PropertiesConfig; +import com.se.simu.domain.dto.GeDb; import com.se.simu.domain.po.DataPo; import com.se.simu.domain.po.SimuPo; import com.se.simu.domain.vo.CreateSimuVo; @@ -17,7 +19,6 @@ import com.se.simu.mapper.SimuMapper; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -37,17 +38,20 @@ @Service @SuppressWarnings("ALL") public class SimuService { - @Value("${sys.path.in}") - String inPath; - - @Value("${sys.path.out}") - String outPath; - @Resource SimuMapper simuMapper; @Resource + PropertiesConfig config; + + @Resource GedbService gedbService; + + @Resource + UwService uwService; + + @Resource + ResultService resultService; /** * 鑾峰彇 @@ -97,8 +101,8 @@ DataPo dp = JSONUtil.toBean(po.getData(), DataPo.class); if (null == dp) continue; - delDir(inPath + File.separator + dp.getInPath()); - delDir(outPath + File.separator + dp.getOutPath()); + delDir(config.getInPath() + File.separator + dp.getInPath()); + delDir(config.getOutPath() + File.separator + dp.getOutPath()); } catch (Exception ex) { log.error(ex.getMessage(), ex); } @@ -121,12 +125,20 @@ return simuMapper.selectMaxId(); } + public SimuPo getSimuByPid(Integer pid) { + QueryWrapper<SimuPo> wrapper = new QueryWrapper<>(); + wrapper.eq("id", pid); + wrapper.last("limit 1"); + + return simuMapper.selectOne(wrapper); + } + public boolean create(CreateSimuVo vo) { DataPo data = BeanUtil.copyProperties(vo, DataPo.class); - SimuPo simu = new SimuPo(vo.getNum(), vo.getName(), JSONUtil.toJsonStr(data), 0, vo.getBak()); - data.setPath(vo.getName(), vo.getName()); initPath(data); + + SimuPo simu = new SimuPo(vo.getNum(), vo.getPid(), vo.getName(), JSONUtil.toJsonStr(data), 0, vo.getBak()); int rows = simuMapper.insert(simu); if (rows > 0) { @@ -137,15 +149,16 @@ } private void initPath(DataPo data) { - createDir(inPath + File.separator + data.getInPath()); - createDir(outPath + File.separator + data.getOutPath()); + createDir(config.getInPath() + File.separator + data.getInPath()); + createDir(config.getOutPath() + File.separator + data.getOutPath()); } private void createDir(String path) { - File dir = new File(path); - if (!dir.exists() || !dir.isDirectory()) { - dir.mkdirs(); + File f = new File(path); + if (f.exists() && f.isDirectory()) { + FileUtil.del(f); } + f.mkdirs(); } private void asyncCall(SimuPo simu) { @@ -154,30 +167,52 @@ @Override @SneakyThrows public void run() { - scope(simu); + cope(simu); } }); executor.shutdown(); } /** - * 澶勭悊锛岀姸鎬侊細0-鍒涘缓浠跨湡锛�1-杩炴帴GEDB搴擄紝2-涓嬭浇绌洪棿鏁版嵁锛�3-涓嬭浇楂樼▼鏁版嵁锛�4-妯℃嫙鍐呮稘浠跨湡锛�5-澶勭悊浠跨湡鏁版嵁锛�10-瀹屾垚锛�-10-鍑洪敊 + * 澶勭悊鏁版嵁锛岀姸鎬佹爣璇嗭細 + * 0-鍒涘缓浠跨湡浠诲姟锛�1-杩炴帴GEDB搴擄紝2-涓嬭浇绌洪棿鏁版嵁锛�3-涓嬭浇楂樼▼鏁版嵁锛� + * 4-鐢熸垚闄嶉洦鏂囦欢锛�5-鐢熸垚閰嶇疆鏂囦欢锛�6-妯℃嫙鍐呮稘浠跨湡锛�7-澶勭悊姘翠綅鏂囦欢锛� + * 8-澶勭悊鎺掓按鏂囦欢锛�9-澶勭悊浠跨湡缁撴灉锛�10-瀹屾垚锛�-10-鍑洪敊 */ - private void scope(SimuPo simu) { + private void cope(SimuPo simu) { try { DataPo data = JSONUtil.toBean(simu.getData(), DataPo.class); + update(simu, 1, null); + String token = gedbService.getToken(); + GeDb db = gedbService.connectGedb(token, data); + simu.setData(JSONUtil.toJsonStr(data)); - //boolean flag = tifService.splitTif(dsd); - //update(simu, flag ? 2 : 20, flag ? null : "鍒囧垎鏁版嵁鍑洪敊"); - //if (!flag) return; + update(simu, 2, null); + gedbService.copeVectors(token, data, db); - //flag = aiService.sendRequest(task.getDataType(), dsd.getDataTime()); - //update(simu, flag ? 3 : 20, flag ? null : "璇嗗埆鏁版嵁鍑洪敊"); - //if (!flag) return; + update(simu, 3, null); + gedbService.copeDem(token, data); - //flag = geoJsonService.processResults(task, dsd); - //update(simu, flag ? 10 : 20, flag ? "鎵ц瀹屾垚" : "澶勭悊缁撴灉鍑洪敊"); + update(simu, 4, null); + uwService.createRainFile(); + + update(simu, 5, null); + uwService.createConfig(data); + + update(simu, 6, null); + uwService.callExe(data); + + update(simu, 7, null); + uwService.copeWaterFiles(); + + update(simu, 8, null); + uwService.copeDrainFiles(); + + update(simu, 9, null); + resultService.process(); + + //update(simu, 10, "瀹屾垚"); } catch (Exception ex) { log.error(ex.getMessage(), ex); update(simu, -10, ex.getMessage()); -- Gitblit v1.9.3