huangxingxing 1 жил өмнө
parent
commit
0114ee3b2c

+ 38 - 15
src/main/java/com/miniframe/bisiness/system/D00008Service.java

@@ -127,6 +127,7 @@ public class D00008Service extends D00008BaseModel implements ExecProcessFlow {
 				TemplateGenerator.createGasInit(aid,jid,gas.getId());
 				TemplateGenerator.createGassRunsh(aid,jid,gas.getId());
 				//文件迁移
+				//网格文件
 				SysFileMapper sysFileMapper = UtilTools.getBean(SysFileMapper.class);
 				SysFile gf = sysFileMapper.selectByPrimaryKey(gas.getGfid());
 				if (gf == null) {
@@ -134,20 +135,16 @@ public class D00008Service extends D00008BaseModel implements ExecProcessFlow {
 				}
 				cpFile(XIFileUtils.getRootPathStr() + MFConstant.separator + gf.getFilepath()
 						,TemplateGenerator.BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gas.getId() + "/"+gf.getFilename());
+				//边界
 				SysFile bf = sysFileMapper.selectByPrimaryKey(gas.getBfid());
 				if (bf == null) {
 					throw new BusinessException("EB3100021");
 				}
 				cpFile(XIFileUtils.getRootPathStr() + MFConstant.separator + bf.getFilepath()
 						,TemplateGenerator.BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gas.getId() + "/"+bf.getFilename());
-				//网格文件
-				//执行文件
-//				cpGssExe(TemplateGenerator.BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gas.getId() );
 
-				cpFile("/home/disaster/gas/bin/gas_mod.Lewis_2"
-					,TemplateGenerator.BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gas.getId() + "/gas_mod.Lewis_2");
-				cpFile("/home/disaster/gas/bin/reac_mod.fluent_CH4_Air_5x1"
-						,TemplateGenerator.BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gas.getId() + "/reac_mod.fluent_CH4_Air_5x1");
+				//执行文件
+				exeGass(aid,jid,gas.getId());
 			}
 
 		}
@@ -230,14 +227,6 @@ public class D00008Service extends D00008BaseModel implements ExecProcessFlow {
 		}
 	}
 
-	public void cpGssExe(String gassDir) throws IOException {
-		Runtime runtime = Runtime.getRuntime();
-		Process p =null;
-		String shell ="cp -f /home/disaster/gas/bin/* "+ gassDir;
-		System.out.println(shell);
-		runtime.exec(shell);
-	}
-
 	public void cpFile(String file1Path,String file2Path) throws IOException {
 		Runtime runtime = Runtime.getRuntime();
 		Process p =null;
@@ -392,6 +381,40 @@ public class D00008Service extends D00008BaseModel implements ExecProcessFlow {
 
 	}
 
+	//异步执行
+	@SneakyThrows
+	public void exeGass(Integer aid, Integer jid, Integer gid) throws Exception{
+
+		CompletableFuture<Void> cf = CompletableFuture.supplyAsync(()->{
+			try {
+				Runtime runtime = Runtime.getRuntime();
+				Process p =null;
+				LogService.addLog(aid,jid,"Gas","求解——————————————————开始");
+				p= runtime.exec("sh "+TemplateGenerator.BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gid + "/run.sh");
+				InputStream fis = p.getInputStream();
+				InputStreamReader isr = new InputStreamReader(fis);
+				BufferedReader br = new BufferedReader(isr);
+				String line = null;
+				while ((line = br.readLine()) != null) {
+					LogService.addLog(aid,jid,"Gas",line);
+					System.out.println(line);
+				}
+				//监测点数据保存
+				saveMonitorValue(aid,jid);
+				//路径保存
+				saveWayValue(aid,jid);
+				LogService.addLog(aid,jid,"Gas","求解——————————————————成功");
+				JobSucces(jid);
+			} catch (IOException | BusinessException e) {
+				LogService.addLog(aid,jid,"Fire","求解——————————————————失败");
+				e.printStackTrace();
+				JobError(jid);
+			}
+			return null;
+		});
+
+	}
+
 
 	public void saveWayValue(Integer aid,Integer jid) throws FileNotFoundException, BusinessException {
 		DAccidentMapper accidentDao  = UtilTools.getBean(DAccidentMapper.class);

+ 1 - 0
src/main/resources/templates/mashGasRunsh.ftl

@@ -1,3 +1,4 @@
+cd /home/disaster/gas/bin
 export PATH="/home/disaster/gas/mpich2/bin:/home/disaster/gas/bin:$PATH"
 ./couple --proc=1d-3d --path=${casepath} --input-1d=${gascontrol}
 ./convert_input --path=${casepath}