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 modelings =modelingMapper.selectByExample(sb); if(modelings.isEmpty()){ throw new BusinessException("EB4000015"); }else{ AdiModeling modeling = modelings.get(0); SysFileMapper fileMapper = UtilTools.getBean(SysFileMapper.class); SysFile file =fileMapper.selectByPrimaryKey(modeling.getGridFile()); if(file==null){ throw new BusinessException("EB4000015"); } 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 modelings =modelingMapper.selectByExample(sb); if(modelings.isEmpty()){ throw new BusinessException("EB4000015"); }else{ AdiModeling modeling = modelings.get(0); SysFileMapper fileMapper = UtilTools.getBean(SysFileMapper.class); SysFile file =fileMapper.selectByPrimaryKey(modeling.getVtkFile()); if(file==null){ throw new BusinessException("EB4000015"); } 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")){ String index = this.getA_aft001().getIndex(); JSONObject obj = new JSONObject(); obj.put("index",index); msg.setParamJson(obj.toString()); }else if(action.equals("SliceDisplayUpdate")){ }else if(action.equals("SliceDisplayDel")){ String index = this.getA_aft001().getIndex(); JSONObject obj = new JSONObject(); obj.put("index",index); msg.setParamJson(obj.toString()); }else if(action.equals("SliceDisplayApply")){ try { List list = XiJsonUtil.jsonToList(paramJson,SliceMsg.class); msg.setParamJson(paramJson); System.out.println(XiJsonUtil.objectToJson(list)); }catch (Exception e){ throw new BusinessException("EB4000014"); } } MFMqUtils.get(CaeMQ.class).sendCaein(XiJsonUtil.objectToJson(msg)); } /** * 基础系统,“后处理消息发送”业务前处理 */ 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(); } }