D00008Service.java 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package com.miniframe.bisiness.system;
  2. import java.io.BufferedReader;
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5. import java.io.InputStreamReader;
  6. import java.util.Map;
  7. import java.util.concurrent.CompletableFuture;
  8. import java.util.concurrent.ExecutorService;
  9. import java.util.concurrent.Executors;
  10. import com.miniframe.core.ExecProcessFlow;
  11. import com.miniframe.generate.business.system.model.D00008BaseModel;
  12. import com.miniframe.template.TemplateGenerator;
  13. import lombok.SneakyThrows;
  14. /**
  15. * 基础系统,“灾情演练”逻辑处理(重新生成不覆盖)。
  16. */
  17. public class D00008Service extends D00008BaseModel implements ExecProcessFlow {
  18. private static final long serialVersionUID = -7051358269847459502L;
  19. /**
  20. * 基础系统,“灾情演练”业务核心处理
  21. */
  22. public void transExecute() throws Exception {
  23. String stype =this.getA_d00008().getStype();
  24. Integer aid =this.getA_d00008().getAid();
  25. if(stype.equals("Fire")){
  26. TemplateGenerator.createFireControl(aid);
  27. TemplateGenerator.createFireRunsh(aid);
  28. TemplateGenerator.createFireInit(aid);
  29. exeFier(aid);
  30. }
  31. }
  32. //异步执行
  33. @SneakyThrows
  34. public void exeFier(Integer aid) throws Exception{
  35. CompletableFuture<Void> cf = CompletableFuture.supplyAsync(()->{
  36. try {
  37. Runtime runtime = Runtime.getRuntime();
  38. Process p =null;
  39. p= runtime.exec("sh "+TemplateGenerator.BPATH+"/"+aid+"/fire"+"/"+"runFile.sh");
  40. InputStream fis = p.getInputStream();
  41. InputStreamReader isr = new InputStreamReader(fis);
  42. BufferedReader br = new BufferedReader(isr);
  43. String line = null;
  44. while ((line = br.readLine()) != null) {
  45. System.out.println(line);
  46. }
  47. } catch (IOException e) {
  48. e.printStackTrace();
  49. }
  50. return null;
  51. });
  52. }
  53. /**
  54. *
  55. *
  56. *
  57. *
  58. * 基础系统,“灾情演练”业务前处理
  59. */
  60. public void preTransFlow() throws Exception {
  61. this.validater();
  62. }
  63. /**
  64. * 基础系统,“灾情演练”业务后处理
  65. */
  66. public void afterTransFlow() throws Exception {
  67. }
  68. /**
  69. * 基础系统,“灾情演练”逻辑入口处理方法
  70. */
  71. @SuppressWarnings("rawtypes")
  72. @Override
  73. public Map execute(Map vars) throws Exception {
  74. this.setTransMap(vars);
  75. preTransFlow();// 执行业务开始的规则检查和校验
  76. transExecute();// 执行核心业务段
  77. afterTransFlow();// 执行核心逻辑完成后的收尾逻辑
  78. return this.getTransMap();
  79. }
  80. }