package com.miniframe.bisiness.system; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import com.miniframe.core.ExecProcessFlow; import com.miniframe.generate.business.system.model.D00008BaseModel; import com.miniframe.template.TemplateGenerator; import lombok.SneakyThrows; /** * 基础系统,“灾情演练”逻辑处理(重新生成不覆盖)。 */ public class D00008Service extends D00008BaseModel implements ExecProcessFlow { private static final long serialVersionUID = -7051358269847459502L; /** * 基础系统,“灾情演练”业务核心处理 */ public void transExecute() throws Exception { String stype =this.getA_d00008().getStype(); Integer aid =this.getA_d00008().getAid(); if(stype.equals("Fire")){ TemplateGenerator.createFireControl(aid); TemplateGenerator.createFireRunsh(aid); TemplateGenerator.createFireInit(aid); exeFier(aid); } } //异步执行 @SneakyThrows public void exeFier(Integer aid) throws Exception{ CompletableFuture cf = CompletableFuture.supplyAsync(()->{ try { Runtime runtime = Runtime.getRuntime(); Process p =null; p= runtime.exec("sh "+TemplateGenerator.BPATH+"/"+aid+"/fire"+"/"+"runFile.sh"); InputStream fis = p.getInputStream(); InputStreamReader isr = new InputStreamReader(fis); BufferedReader br = new BufferedReader(isr); String line = null; while ((line = br.readLine()) != null) { System.out.println(line); } } catch (IOException e) { e.printStackTrace(); } return null; }); } /** * * * * * 基础系统,“灾情演练”业务前处理 */ public void preTransFlow() throws Exception { this.validater(); } /** * 基础系统,“灾情演练”业务后处理 */ public void afterTransFlow() throws Exception { } /** * 基础系统,“灾情演练”逻辑入口处理方法 */ @SuppressWarnings("rawtypes") @Override public Map execute(Map vars) throws Exception { this.setTransMap(vars); preTransFlow();// 执行业务开始的规则检查和校验 transExecute();// 执行核心业务段 afterTransFlow();// 执行核心逻辑完成后的收尾逻辑 return this.getTransMap(); } }