C00005Service.java 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. package com.miniframe.bisiness.system;
  2. import java.util.HashMap;
  3. import java.util.List;
  4. import java.util.Map;
  5. import java.util.concurrent.ExecutorService;
  6. import java.util.concurrent.Executors;
  7. import com.miniframe.core.ExecProcessFlow;
  8. import com.miniframe.core.IniFileReader;
  9. import com.miniframe.core.exception.BusinessException;
  10. import com.miniframe.core.ext.UtilTools;
  11. import com.miniframe.generate.business.system.model.C00005BaseModel;
  12. import com.miniframe.model.system.*;
  13. import com.miniframe.model.system.dao.AdiModelingMapper;
  14. import com.miniframe.model.system.dao.AdiProjectMapper;
  15. import com.miniframe.model.system.dao.AdiSolverConfigMapper;
  16. import com.miniframe.model.system.dao.AdiSolverMapper;
  17. import com.miniframe.solverconfig.fem.FEMOrder;
  18. import com.miniframe.solverconfig.fem.FEMParam;
  19. import com.miniframe.solverconfig.fem.FEMPath;
  20. import com.miniframe.solverconfig.hcfd.HcfdExe;
  21. import com.miniframe.solverconfig.hcfd.HcfdParam;
  22. import com.miniframe.solverconfig.hcfd.HcfdPath;
  23. import com.miniframe.solverjob.AdiSolverJobService;
  24. import com.miniframe.tools.XiJsonUtil;
  25. import com.miniframe.tools.ali.HttpUtils;
  26. import org.apache.http.HttpResponse;
  27. /**
  28. * 基础系统,“求解”逻辑处理(重新生成不覆盖)。
  29. */
  30. public class C00005Service extends C00005BaseModel implements ExecProcessFlow {
  31. private static final long serialVersionUID = -7051358269847459502L;
  32. /**
  33. * 基础系统,“求解”业务核心处理
  34. */
  35. public void transExecute() throws Exception {
  36. String solverConfigId = getA_c00005().getSolverConfigId();
  37. String uid =getA_systemhead().getUserId();
  38. AdiSolverConfigMapper configMapper = UtilTools.getBean(AdiSolverConfigMapper.class);
  39. AdiSolverConfig config = configMapper.selectByPrimaryKey(solverConfigId);
  40. if(null==config){
  41. throw new BusinessException("EB4000007");
  42. }
  43. AdiSolverMapper solverMapper = UtilTools.getBean(AdiSolverMapper.class);
  44. AdiSolver solver = solverMapper.selectByPrimaryKey(config.getSolverid());
  45. if(null==solver){
  46. throw new BusinessException("EB4000009");
  47. }
  48. AdiProjectMapper projectMapper = UtilTools.getBean(AdiProjectMapper.class);
  49. AdiProject project = projectMapper.selectByPrimaryKey(config.getPid());
  50. if(null==project){
  51. throw new BusinessException("EB4000008");
  52. }
  53. AdiModelingMapper modelingMapper = UtilTools.getBean(AdiModelingMapper.class);
  54. AdiModelingSQLBuilder modelingsb = new AdiModelingSQLBuilder();
  55. AdiModelingSQLBuilder.Criteria modelingsc = modelingsb.createCriteria();
  56. modelingsc.andPidEqualTo(project.getId());
  57. List<AdiModeling> modelingList = modelingMapper.selectByExample(modelingsb);
  58. if(null==modelingList||modelingList.isEmpty()){
  59. throw new BusinessException("EB4000010");
  60. }
  61. AdiModeling modeling = modelingList.get(0);
  62. AdiSolverJob job =AdiSolverJobService.createJob(config);//创建执行任务
  63. /**
  64. * 删除上次创建的索引日志数据
  65. */
  66. delEsIndex(project.getId());
  67. if(solver.getCompany().equals("ADI.SimWork")&& solver.getSolverModel().equals("HCFDLab")){
  68. HcfdParam param = XiJsonUtil.jsonToPojo(config.getParameterObj(),HcfdParam.class);
  69. HcfdExe.CreateMpbcFile(null,config);
  70. HcfdExe.CreateNmlFile(null,config);
  71. HcfdPath.hcfdCreatPath(modeling,config,job);
  72. String vfred="";
  73. String afred="";
  74. vfred=param.getNmlParam().getVolume_animation_freq().toString();
  75. afred=param.getNmlParam().getAnimation_freq().toString();
  76. String url="http://localhost:8082/solverres";//TODO 通过资源数据获取IP
  77. System.out.println(url);
  78. httpExeJob(job,"hcfd",url,vfred,afred,null);
  79. }
  80. if(solver.getCompany().equals("ADI.SimWork")&& solver.getSolverModel().equals("FEMLab(结构力学)")){
  81. FEMParam param =XiJsonUtil.jsonToPojo(config.getParameterObj(),FEMParam.class);
  82. FEMOrder.CreateAnalysisFile(null,config);
  83. FEMPath.femCreatePath(modeling,config,job);
  84. String url="http://192.168.0.108:8082/solverres";//TODO 通过资源数据获取IP
  85. System.out.println(url);
  86. httpExeJob(job,"fem",url,null,null,null);
  87. }
  88. }
  89. /**
  90. * 执行前 删除上次创建的索引日志数据
  91. */
  92. private void delEsIndex(String proId) throws Exception {
  93. String host = "http://192.168.0.131:8031/del";
  94. String path ="";
  95. String method="";
  96. Map<String, String> headers = new HashMap<>();
  97. Map<String, String> querys= new HashMap<>();
  98. Map<String, String> bodys= new HashMap<>();
  99. bodys.put("projectId", proId);
  100. HttpResponse response= HttpUtils.doPost(host,path,method,headers,querys,bodys);
  101. }
  102. /**
  103. * onespace
  104. * @param job
  105. * @param url
  106. * @param vfred
  107. * @param afred
  108. * @throws Exception
  109. */
  110. private void httpExeJob(AdiSolverJob job,String projectType,String url,String vfred,String afred ,String resources) throws Exception {
  111. String path ="";
  112. String method="";
  113. Map<String, String> headers = new HashMap<>();
  114. Map<String, String> querys= new HashMap<>();
  115. Map<String, String> bodys= new HashMap<>();
  116. bodys.put("jobId", job.getId());
  117. bodys.put("projectType", projectType);
  118. bodys.put("jobOrder", "");
  119. bodys.put("projectId", job.getPid());
  120. bodys.put("orderType", "");
  121. bodys.put("vfreq", vfred);
  122. bodys.put("afreq", afred);
  123. bodys.put("resources", resources);
  124. //异步执行 求解
  125. ExecutorService cachedThreadPool = Executors.newCachedThreadPool();
  126. cachedThreadPool.execute(new Runnable() {
  127. @Override
  128. public void run() {
  129. try {
  130. HttpResponse response= HttpUtils.doPost(url,path,method,headers,querys,bodys);
  131. } catch (Exception exception) {
  132. exception.printStackTrace();
  133. }
  134. }
  135. });
  136. }
  137. /**
  138. * 基础系统,“求解”业务前处理
  139. */
  140. public void preTransFlow() throws Exception {
  141. this.validater();
  142. }
  143. /**
  144. * 基础系统,“求解”业务后处理
  145. */
  146. public void afterTransFlow() throws Exception {
  147. }
  148. /**
  149. * 基础系统,“求解”逻辑入口处理方法
  150. */
  151. @SuppressWarnings("rawtypes")
  152. @Override
  153. public Map execute(Map vars) throws Exception {
  154. this.setTransMap(vars);
  155. preTransFlow();// 执行业务开始的规则检查和校验
  156. transExecute();// 执行核心业务段
  157. afterTransFlow();// 执行核心逻辑完成后的收尾逻辑
  158. return this.getTransMap();
  159. }
  160. }