123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- package com.miniframe.bisiness.system;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Map;
- import com.alibaba.nacos.shaded.com.google.gson.JsonArray;
- import com.alibaba.nacos.shaded.com.google.gson.JsonObject;
- import com.miniframe.aftercure.ActionMsg;
- import com.miniframe.aftercure.SliceMsg;
- import com.miniframe.constant.MFConstant;
- import com.miniframe.core.ExecProcessFlow;
- import com.miniframe.core.exception.BusinessException;
- import com.miniframe.core.ext.UtilTools;
- import com.miniframe.generate.business.system.model.AFT001BaseModel;
- import com.miniframe.model.system.*;
- import com.miniframe.model.system.dao.*;
- import com.miniframe.service.mq.CaeMQ;
- import com.miniframe.spring.mq.MFMqUtils;
- import com.miniframe.tools.XIFileUtils;
- import com.miniframe.tools.XiJsonUtil;
- import org.json.JSONObject;
- /**
- * 基础系统,“后处理消息发送”逻辑处理(重新生成不覆盖)。
- */
- public class AFT001Service extends AFT001BaseModel implements ExecProcessFlow {
-
- private static final long serialVersionUID = -7051358269847459502L;
-
- /**
- * 基础系统,“后处理消息发送”业务核心处理
- */
- public void transExecute() throws Exception {
- String usrId =this.getA_systemhead().getUserId();
- String solverConfigId =getA_aft001().getSolverConfigId();
- String proId =getA_aft001().getPid();
- String paramJson =getA_aft001().getParamJson();
- String action =getA_aft001().getAction();
- String step=getA_aft001().getStep();
- String scalarName =getA_aft001().getScalarName();
- String level =getA_aft001().getLevel();
- String range0 =getA_aft001().getRange0();
- String range1 =getA_aft001().getRange1();
- AdiSolverConfigMapper configMapper = UtilTools.getBean(AdiSolverConfigMapper.class);
- AdiSolverConfig config= configMapper.selectByPrimaryKey(solverConfigId);
- if(config==null){
- throw new BusinessException("EB4000011");
- }
- AdiSolverMapper solverMapper = UtilTools.getBean(AdiSolverMapper.class);
- AdiSolver solver = solverMapper.selectByPrimaryKey(config.getSolverid());
- if(solver==null){
- throw new BusinessException("EB4000011");
- }
- ActionMsg msg =new ActionMsg();
- msg.setUsrId(usrId);
- msg.setSolverConfigid(solverConfigId);
- msg.setProId(proId);
- msg.setAction(action);
- if(action.equals("init")){
- msg.setParamJson(paramJson);
- }else if(action.equals("loaddata")){
- if(solver.getSolverModel().equals("HCFDLab")){
- AdiModelingMapper modelingMapper = UtilTools.getBean(AdiModelingMapper.class);
- AdiModelingSQLBuilder sb = new AdiModelingSQLBuilder();
- AdiModelingSQLBuilder.Criteria sc =sb.createCriteria();
- sc.andPidEqualTo(proId);
- List<AdiModeling> modelings =modelingMapper.selectByExample(sb);
- if(modelings.isEmpty()){
- throw new BusinessException("EB4000008");
- }else{
- AdiModeling modeling = modelings.get(0);
- SysFileMapper fileMapper = UtilTools.getBean(SysFileMapper.class);
- SysFile file =fileMapper.selectByPrimaryKey(modeling.getGridFile());
- if(file==null){
- throw new BusinessException("EB4000012");
- }
- JSONObject obj = new JSONObject();
- obj.put("filePath",XIFileUtils.getRootPathStr()+ MFConstant.separator+file.getFilepath());
- obj.put("fileType",modeling.getGridFileType().toLowerCase());
- msg.setParamJson(obj.toString());
- }
- }else if(solver.getSolverModel().equals("FEMLab(结构力学)")){
- AdiModelingMapper modelingMapper = UtilTools.getBean(AdiModelingMapper.class);
- AdiModelingSQLBuilder sb = new AdiModelingSQLBuilder();
- AdiModelingSQLBuilder.Criteria sc =sb.createCriteria();
- sc.andPidEqualTo(proId);
- List<AdiModeling> modelings =modelingMapper.selectByExample(sb);
- if(modelings.isEmpty()){
- throw new BusinessException("EB4000008");
- }else{
- AdiModeling modeling = modelings.get(0);
- SysFileMapper fileMapper = UtilTools.getBean(SysFileMapper.class);
- SysFile file =fileMapper.selectByPrimaryKey(modeling.getVtkFile());
- if(file==null){
- throw new BusinessException("EB4000012");
- }
- JSONObject obj = new JSONObject();
- obj.put("filePath",XIFileUtils.getRootPathStr()+ MFConstant.separator+file.getFilepath());
- obj.put("fileType",modeling.getGridFileType().toLowerCase());
- msg.setParamJson(obj.toString());
- }
- }
- }else if(action.equals("zoomout")){//缩小
- }else if(action.equals("zoomin")){//放大
- }else if(action.equals("AlignToPlusAxisX")){//正x轴对齐
- }else if(action.equals("AlignToPlusAxisY")){//正y轴对齐
- }else if(action.equals("AlignToPlusAxisZ")){//正z轴对齐
- }else if(action.equals("AlignToMinusAxisX")){//负x轴对齐
- }else if(action.equals("AlignToMinusAxisY")){//负y轴对齐
- }else if(action.equals("AlignToMinusAxisZ")){//负z轴对齐
- }else if(action.equals("TransformToIsometric")){//等距视图显示
- }else if(action.equals("ResultImport")){
- if(this.getA_aft001().getIsVolume()=="1"){
- JSONObject obj = new JSONObject();
- obj.put("filePath","/cephfs/Postprocess_Binary");
- obj.put("fileType","binary");
- obj.put("fileName","whole_part1.plt,whole_part2.plt,whole_part3.plt");
- msg.setParamJson(obj.toString());
- }else{
- JSONObject obj = new JSONObject();
- obj.put("filePath","/cephfs/Postprocess_Binary");
- obj.put("fileType","binary");
- obj.put("fileName","whole_part4.plt,whole_part5.plt,whole_part6.plt");
- msg.setParamJson(obj.toString());
- }
- }else if(action.equals("ContourDisplay")){
- JSONObject obj = new JSONObject();
- obj.put("level",level);
- obj.put("range",range0+","+range1);
- obj.put("scalarName",scalarName);
- msg.setParamJson(obj.toString());
- }else if(action.equals("LineDisplay")){
- JSONObject obj = new JSONObject();
- obj.put("level",level);
- obj.put("range",range0+","+range1);
- obj.put("scalarName",scalarName);
- msg.setParamJson(obj.toString());
- }else if(action.equals("VectorDisplay")){
- if(this.getA_aft001().getScaleFactor()==null
- ||"".equals(this.getA_aft001().getScaleFactor())||
- this.getA_aft001().getDataU()==null
- ||"".equals(this.getA_aft001().getDataU())||
- this.getA_aft001().getDataV()==null
- ||"".equals(this.getA_aft001().getDataV())||
- this.getA_aft001().getDataW()==null
- ||"".equals(this.getA_aft001().getDataW())
- ){
- throw new BusinessException("EB4000013");
- }
- JSONObject obj = new JSONObject();
- obj.put("scaleFactor",this.getA_aft001().getScaleFactor());
- obj.put("dataU",this.getA_aft001().getDataU());
- obj.put("dataV",this.getA_aft001().getDataV());
- obj.put("dataW",this.getA_aft001().getDataW());
- msg.setParamJson(obj.toString());
- }else if(action.equals("SolidSurfaceDisplay")){
- String r =this.getA_aft001().getR();
- String g =this.getA_aft001().getG();
- String b =this.getA_aft001().getB();
- String transparency=this.getA_aft001().getTransparency();
- String showHideState=this.getA_aft001().getShowHideState();
- if(r==null || "".equals(r)
- ||g==null || "".equals(g)
- ||b==null || "".equals(b)
- ||transparency==null || "".equals(transparency)
- ||showHideState==null || "".equals(showHideState)
- ){
- throw new BusinessException("EB4000013");
- }
- JSONObject obj = new JSONObject();
- obj.put("r",r);
- obj.put("g",g);
- obj.put("b",b);
- obj.put("transparency",transparency);
- obj.put("showHideState","1".equals(showHideState)?true:false);
- msg.setParamJson(obj.toString());
- }else if(action.equals("SliceDisplayAdd")){
- JSONObject obj = new JSONObject();
- obj.put("index","1");
- msg.setParamJson(obj.toString());
- }else if(action.equals("SliceDisplayUpdate")){
- }else if(action.equals("SliceDisplayDel")){
- JSONObject obj = new JSONObject();
- obj.put("index","1");
- msg.setParamJson(obj.toString());
- }else if(action.equals("SliceDisplayApple")){
- List<SliceMsg> b =new ArrayList<>();
- for (int i = 0; i <2 ; i++) {
- b.add( inib(i));
- }
- String t= XiJsonUtil.objectToJson(b);
- msg.setParamJson(t);
- }
- System.out.println(XiJsonUtil.objectToJson(msg));
- MFMqUtils.get(CaeMQ.class).sendCaein(XiJsonUtil.objectToJson(msg));
- }
- private static SliceMsg inib(int id) {
- SliceMsg b= new SliceMsg();
- b.setIndex(id);
- b.setLevel(2);
- b.setNormalx(12.0);
- b.setNormaly(2.0);
- b.setNormalz(3.0);
- b.setPositionx(0.23);
- return b;
- }
- /**
- * 基础系统,“后处理消息发送”业务前处理
- */
- 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();
- }
- }
|