AFT001Service.java 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. package com.miniframe.bisiness.system;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import java.util.Map;
  5. import com.alibaba.nacos.shaded.com.google.gson.JsonArray;
  6. import com.alibaba.nacos.shaded.com.google.gson.JsonObject;
  7. import com.miniframe.aftercure.ActionMsg;
  8. import com.miniframe.aftercure.SliceMsg;
  9. import com.miniframe.constant.MFConstant;
  10. import com.miniframe.core.ExecProcessFlow;
  11. import com.miniframe.core.exception.BusinessException;
  12. import com.miniframe.core.ext.UtilTools;
  13. import com.miniframe.generate.business.system.model.AFT001BaseModel;
  14. import com.miniframe.model.system.*;
  15. import com.miniframe.model.system.dao.*;
  16. import com.miniframe.service.mq.CaeMQ;
  17. import com.miniframe.spring.mq.MFMqUtils;
  18. import com.miniframe.tools.XIFileUtils;
  19. import com.miniframe.tools.XiJsonUtil;
  20. import org.json.JSONObject;
  21. /**
  22. * 基础系统,“后处理消息发送”逻辑处理(重新生成不覆盖)。
  23. */
  24. public class AFT001Service extends AFT001BaseModel implements ExecProcessFlow {
  25. private static final long serialVersionUID = -7051358269847459502L;
  26. /**
  27. * 基础系统,“后处理消息发送”业务核心处理
  28. */
  29. public void transExecute() throws Exception {
  30. String usrId =this.getA_systemhead().getUserId();
  31. String solverConfigId =getA_aft001().getSolverConfigId();
  32. String proId =getA_aft001().getPid();
  33. String paramJson =getA_aft001().getParamJson();
  34. String action =getA_aft001().getAction();
  35. String step=getA_aft001().getStep();
  36. String scalarName =getA_aft001().getScalarName();
  37. String level =getA_aft001().getLevel();
  38. String range0 =getA_aft001().getRange0();
  39. String range1 =getA_aft001().getRange1();
  40. AdiSolverConfigMapper configMapper = UtilTools.getBean(AdiSolverConfigMapper.class);
  41. AdiSolverConfig config= configMapper.selectByPrimaryKey(solverConfigId);
  42. if(config==null){
  43. throw new BusinessException("EB4000011");
  44. }
  45. AdiSolverMapper solverMapper = UtilTools.getBean(AdiSolverMapper.class);
  46. AdiSolver solver = solverMapper.selectByPrimaryKey(config.getSolverid());
  47. if(solver==null){
  48. throw new BusinessException("EB4000011");
  49. }
  50. ActionMsg msg =new ActionMsg();
  51. msg.setUsrId(usrId);
  52. msg.setSolverConfigid(solverConfigId);
  53. msg.setProId(proId);
  54. msg.setAction(action);
  55. if(action.equals("init")){
  56. msg.setParamJson(paramJson);
  57. }else if(action.equals("loaddata")){
  58. if(solver.getSolverModel().equals("HCFDLab")){
  59. AdiModelingMapper modelingMapper = UtilTools.getBean(AdiModelingMapper.class);
  60. AdiModelingSQLBuilder sb = new AdiModelingSQLBuilder();
  61. AdiModelingSQLBuilder.Criteria sc =sb.createCriteria();
  62. sc.andPidEqualTo(proId);
  63. List<AdiModeling> modelings =modelingMapper.selectByExample(sb);
  64. if(modelings.isEmpty()){
  65. throw new BusinessException("EB4000008");
  66. }else{
  67. AdiModeling modeling = modelings.get(0);
  68. SysFileMapper fileMapper = UtilTools.getBean(SysFileMapper.class);
  69. SysFile file =fileMapper.selectByPrimaryKey(modeling.getGridFile());
  70. if(file==null){
  71. throw new BusinessException("EB4000012");
  72. }
  73. JSONObject obj = new JSONObject();
  74. obj.put("filePath",XIFileUtils.getRootPathStr()+ MFConstant.separator+file.getFilepath());
  75. obj.put("fileType",modeling.getGridFileType().toLowerCase());
  76. msg.setParamJson(obj.toString());
  77. }
  78. }else if(solver.getSolverModel().equals("FEMLab(结构力学)")){
  79. AdiModelingMapper modelingMapper = UtilTools.getBean(AdiModelingMapper.class);
  80. AdiModelingSQLBuilder sb = new AdiModelingSQLBuilder();
  81. AdiModelingSQLBuilder.Criteria sc =sb.createCriteria();
  82. sc.andPidEqualTo(proId);
  83. List<AdiModeling> modelings =modelingMapper.selectByExample(sb);
  84. if(modelings.isEmpty()){
  85. throw new BusinessException("EB4000008");
  86. }else{
  87. AdiModeling modeling = modelings.get(0);
  88. SysFileMapper fileMapper = UtilTools.getBean(SysFileMapper.class);
  89. SysFile file =fileMapper.selectByPrimaryKey(modeling.getVtkFile());
  90. if(file==null){
  91. throw new BusinessException("EB4000012");
  92. }
  93. JSONObject obj = new JSONObject();
  94. obj.put("filePath",XIFileUtils.getRootPathStr()+ MFConstant.separator+file.getFilepath());
  95. obj.put("fileType",modeling.getGridFileType().toLowerCase());
  96. msg.setParamJson(obj.toString());
  97. }
  98. }
  99. }else if(action.equals("zoomout")){//缩小
  100. }else if(action.equals("zoomin")){//放大
  101. }else if(action.equals("AlignToPlusAxisX")){//正x轴对齐
  102. }else if(action.equals("AlignToPlusAxisY")){//正y轴对齐
  103. }else if(action.equals("AlignToPlusAxisZ")){//正z轴对齐
  104. }else if(action.equals("AlignToMinusAxisX")){//负x轴对齐
  105. }else if(action.equals("AlignToMinusAxisY")){//负y轴对齐
  106. }else if(action.equals("AlignToMinusAxisZ")){//负z轴对齐
  107. }else if(action.equals("TransformToIsometric")){//等距视图显示
  108. }else if(action.equals("ResultImport")){
  109. if(this.getA_aft001().getIsVolume()=="1"){
  110. JSONObject obj = new JSONObject();
  111. obj.put("filePath","/cephfs/Postprocess_Binary");
  112. obj.put("fileType","binary");
  113. obj.put("fileName","whole_part1.plt,whole_part2.plt,whole_part3.plt");
  114. msg.setParamJson(obj.toString());
  115. }else{
  116. JSONObject obj = new JSONObject();
  117. obj.put("filePath","/cephfs/Postprocess_Binary");
  118. obj.put("fileType","binary");
  119. obj.put("fileName","whole_part4.plt,whole_part5.plt,whole_part6.plt");
  120. msg.setParamJson(obj.toString());
  121. }
  122. }else if(action.equals("ContourDisplay")){
  123. JSONObject obj = new JSONObject();
  124. obj.put("level",level);
  125. obj.put("range",range0+","+range1);
  126. obj.put("scalarName",scalarName);
  127. msg.setParamJson(obj.toString());
  128. }else if(action.equals("LineDisplay")){
  129. JSONObject obj = new JSONObject();
  130. obj.put("level",level);
  131. obj.put("range",range0+","+range1);
  132. obj.put("scalarName",scalarName);
  133. msg.setParamJson(obj.toString());
  134. }else if(action.equals("VectorDisplay")){
  135. if(this.getA_aft001().getScaleFactor()==null
  136. ||"".equals(this.getA_aft001().getScaleFactor())||
  137. this.getA_aft001().getDataU()==null
  138. ||"".equals(this.getA_aft001().getDataU())||
  139. this.getA_aft001().getDataV()==null
  140. ||"".equals(this.getA_aft001().getDataV())||
  141. this.getA_aft001().getDataW()==null
  142. ||"".equals(this.getA_aft001().getDataW())
  143. ){
  144. throw new BusinessException("EB4000013");
  145. }
  146. JSONObject obj = new JSONObject();
  147. obj.put("scaleFactor",this.getA_aft001().getScaleFactor());
  148. obj.put("dataU",this.getA_aft001().getDataU());
  149. obj.put("dataV",this.getA_aft001().getDataV());
  150. obj.put("dataW",this.getA_aft001().getDataW());
  151. msg.setParamJson(obj.toString());
  152. }else if(action.equals("SolidSurfaceDisplay")){
  153. String r =this.getA_aft001().getR();
  154. String g =this.getA_aft001().getG();
  155. String b =this.getA_aft001().getB();
  156. String transparency=this.getA_aft001().getTransparency();
  157. String showHideState=this.getA_aft001().getShowHideState();
  158. if(r==null || "".equals(r)
  159. ||g==null || "".equals(g)
  160. ||b==null || "".equals(b)
  161. ||transparency==null || "".equals(transparency)
  162. ||showHideState==null || "".equals(showHideState)
  163. ){
  164. throw new BusinessException("EB4000013");
  165. }
  166. JSONObject obj = new JSONObject();
  167. obj.put("r",r);
  168. obj.put("g",g);
  169. obj.put("b",b);
  170. obj.put("transparency",transparency);
  171. obj.put("showHideState","1".equals(showHideState)?true:false);
  172. msg.setParamJson(obj.toString());
  173. }else if(action.equals("SliceDisplayAdd")){
  174. JSONObject obj = new JSONObject();
  175. obj.put("index","1");
  176. msg.setParamJson(obj.toString());
  177. }else if(action.equals("SliceDisplayUpdate")){
  178. }else if(action.equals("SliceDisplayDel")){
  179. JSONObject obj = new JSONObject();
  180. obj.put("index","1");
  181. msg.setParamJson(obj.toString());
  182. }else if(action.equals("SliceDisplayApple")){
  183. List<SliceMsg> b =new ArrayList<>();
  184. for (int i = 0; i <2 ; i++) {
  185. b.add( inib(i));
  186. }
  187. String t= XiJsonUtil.objectToJson(b);
  188. msg.setParamJson(t);
  189. }
  190. System.out.println(XiJsonUtil.objectToJson(msg));
  191. MFMqUtils.get(CaeMQ.class).sendCaein(XiJsonUtil.objectToJson(msg));
  192. }
  193. private static SliceMsg inib(int id) {
  194. SliceMsg b= new SliceMsg();
  195. b.setIndex(id);
  196. b.setLevel(2);
  197. b.setNormalx(12.0);
  198. b.setNormaly(2.0);
  199. b.setNormalz(3.0);
  200. b.setPositionx(0.23);
  201. return b;
  202. }
  203. /**
  204. * 基础系统,“后处理消息发送”业务前处理
  205. */
  206. public void preTransFlow() throws Exception {
  207. this.validater();
  208. }
  209. /**
  210. * 基础系统,“后处理消息发送”业务后处理
  211. */
  212. public void afterTransFlow() throws Exception {
  213. }
  214. /**
  215. * 基础系统,“后处理消息发送”逻辑入口处理方法
  216. */
  217. @SuppressWarnings("rawtypes")
  218. @Override
  219. public Map execute(Map vars) throws Exception {
  220. this.setTransMap(vars);
  221. preTransFlow();// 执行业务开始的规则检查和校验
  222. transExecute();// 执行核心业务段
  223. afterTransFlow();// 执行核心逻辑完成后的收尾逻辑
  224. return this.getTransMap();
  225. }
  226. }