|  | @@ -4,6 +4,7 @@ import com.miniframe.core.ext.UtilTools;
 | 
											
												
													
														|  |  import com.miniframe.mdo.service.LogService;
 |  |  import com.miniframe.mdo.service.LogService;
 | 
											
												
													
														|  |  import com.miniframe.model.mdo.*;
 |  |  import com.miniframe.model.mdo.*;
 | 
											
												
													
														|  |  import com.miniframe.model.mdo.dao.*;
 |  |  import com.miniframe.model.mdo.dao.*;
 | 
											
												
													
														|  | 
 |  | +import com.miniframe.modo.temp.cpacs.*;
 | 
											
												
													
														|  |  import com.miniframe.modo.temp.problem.*;
 |  |  import com.miniframe.modo.temp.problem.*;
 | 
											
												
													
														|  |  import freemarker.template.Configuration;
 |  |  import freemarker.template.Configuration;
 | 
											
												
													
														|  |  import freemarker.template.Template;
 |  |  import freemarker.template.Template;
 | 
											
										
											
												
													
														|  | @@ -14,6 +15,7 @@ import java.io.FileWriter;
 | 
											
												
													
														|  |  import java.io.IOException;
 |  |  import java.io.IOException;
 | 
											
												
													
														|  |  import java.io.StringWriter;
 |  |  import java.io.StringWriter;
 | 
											
												
													
														|  |  import java.util.*;
 |  |  import java.util.*;
 | 
											
												
													
														|  | 
 |  | +import java.util.stream.Collectors;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  public class TemplateGenerator {
 |  |  public class TemplateGenerator {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -90,17 +92,165 @@ public class TemplateGenerator {
 | 
											
												
													
														|  |       * TODO 创建 cpacsxml
 |  |       * TODO 创建 cpacsxml
 | 
											
												
													
														|  |       * @return
 |  |       * @return
 | 
											
												
													
														|  |       */
 |  |       */
 | 
											
												
													
														|  | -    public static String createcCpacsXml(String pid){
 |  | 
 | 
											
												
													
														|  | 
 |  | +    public static String createcCpacsXml(String pid)  {
 | 
											
												
													
														|  | 
 |  | +        try {
 | 
											
												
													
														|  | 
 |  | +            Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
 | 
											
												
													
														|  | 
 |  | +            // 设置模板所在目录
 | 
											
												
													
														|  | 
 |  | +            cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
 | 
											
												
													
														|  | 
 |  | +            // 获取模板对象
 | 
											
												
													
														|  | 
 |  | +            Template template = cfg.getTemplate("cpacs.ftl");
 | 
											
												
													
														|  | 
 |  | +            // 定义数据模型(Map)
 | 
											
												
													
														|  | 
 |  | +            Map<String, Object> dataModel = new HashMap<>();
 | 
											
												
													
														|  | 
 |  | +            CpacsVo vo = new CpacsVo();
 | 
											
												
													
														|  | 
 |  | +            HeaderVo header =new HeaderVo();
 | 
											
												
													
														|  | 
 |  | +            header.setName(pid);
 | 
											
												
													
														|  | 
 |  | +            header.setTimestamp(new Date());
 | 
											
												
													
														|  | 
 |  | +            vo.setHeader(header);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        return "";
 |  | 
 | 
											
												
													
														|  | 
 |  | +            MdoProXfoil xfoil = findXfoil(pid);
 | 
											
												
													
														|  | 
 |  | +            vo.setXfoil(xfoil);
 | 
											
												
													
														|  | 
 |  | +            MdoProAdflow adflow = findAdflow(pid);
 | 
											
												
													
														|  | 
 |  | +            vo.setAdflow(adflow);
 | 
											
												
													
														|  | 
 |  | +            //不用生成
 | 
											
												
													
														|  | 
 |  | +            if(xfoil==null&& adflow==null){
 | 
											
												
													
														|  | 
 |  | +                return "";
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +            List<MdoProInoutPara> xInoutList = findMdoProInoutParas(pid, xfoil.getId());
 | 
											
												
													
														|  | 
 |  | +            XfoilInVo xinvo = new XfoilInVo();
 | 
											
												
													
														|  | 
 |  | +            // alpha mach reynolds
 | 
											
												
													
														|  | 
 |  | +            xinvo.setAlpha(getValByParaListAndCode(xInoutList,"alpha"));
 | 
											
												
													
														|  | 
 |  | +            xinvo.setMach(getValByParaListAndCode(xInoutList,"alpha"));
 | 
											
												
													
														|  | 
 |  | +            xinvo.setReynolds(getValByParaListAndCode(xInoutList,"reynolds"));
 | 
											
												
													
														|  | 
 |  | +            vo.setXinvo(xinvo);
 | 
											
												
													
														|  | 
 |  | +            XfoilOutVo xoutvo = new XfoilOutVo();
 | 
											
												
													
														|  | 
 |  | +            xoutvo.setCl(getValByParaListAndCode(xInoutList,"cl"));
 | 
											
												
													
														|  | 
 |  | +            xoutvo.setCd(getValByParaListAndCode(xInoutList,"cd"));
 | 
											
												
													
														|  | 
 |  | +            xoutvo.setCdp(getValByParaListAndCode(xInoutList,"cdp"));
 | 
											
												
													
														|  | 
 |  | +            xoutvo.setCm(getValByParaListAndCode(xInoutList,"cm"));
 | 
											
												
													
														|  | 
 |  | +            xoutvo.setXtr_upper(getValByParaListAndCode(xInoutList,"xtr_upper"));
 | 
											
												
													
														|  | 
 |  | +            xoutvo.setXtr_lower(getValByParaListAndCode(xInoutList,"xtr_lower"));
 | 
											
												
													
														|  | 
 |  | +            vo.setXoutvo(xoutvo);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            List<MdoProInoutPara> adInoutList = findMdoProInoutParas(pid, adflow.getId());
 | 
											
												
													
														|  | 
 |  | +            AdflowInVo adinvo = new AdflowInVo();
 | 
											
												
													
														|  | 
 |  | +            adinvo.setMode(getValByParaListAndCode(adInoutList,"mode"));
 | 
											
												
													
														|  | 
 |  | +            adinvo.setAlpha(getValByParaListAndCode(adInoutList,"alpha"));
 | 
											
												
													
														|  | 
 |  | +            adinvo.setMach(getValByParaListAndCode(adInoutList,"mach"));
 | 
											
												
													
														|  | 
 |  | +            adinvo.setReynolds(getValByParaListAndCode(adInoutList,"reynolds"));
 | 
											
												
													
														|  | 
 |  | +            adinvo.setTemperature(getValByParaListAndCode(adInoutList,"temperature"));
 | 
											
												
													
														|  | 
 |  | +            adinvo.setReynoldsLength(getValByParaListAndCode(adInoutList,"reynoldsLength"));
 | 
											
												
													
														|  | 
 |  | +            vo.setAdinvo(adinvo);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            AdflowOutVo adoutvo = new AdflowOutVo();
 | 
											
												
													
														|  | 
 |  | +            adoutvo.setCl(getValByParaListAndCode(adInoutList,"cl"));
 | 
											
												
													
														|  | 
 |  | +            adoutvo.setCd(getValByParaListAndCode(adInoutList,"cd"));
 | 
											
												
													
														|  | 
 |  | +            adoutvo.setCmz(getValByParaListAndCode(adInoutList,"cmz"));
 | 
											
												
													
														|  | 
 |  | +            vo.setAdoutvo(adoutvo);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            MdoProCst cst = findCst(pid);
 | 
											
												
													
														|  | 
 |  | +            vo.setCst(cst);
 | 
											
												
													
														|  | 
 |  | +            MdoProFfd ffd = getFfd(pid);
 | 
											
												
													
														|  | 
 |  | +            vo.setFfd(ffd);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            dataModel.put("vo",vo);
 | 
											
												
													
														|  | 
 |  | +            //dataModel.put("geoFilePath", BPATH + "/" + aid + "/" + jid + "/Geometry");
 | 
											
												
													
														|  | 
 |  | +            // 将数据模型传入模板进行处理
 | 
											
												
													
														|  | 
 |  | +            StringWriter writer = new StringWriter();
 | 
											
												
													
														|  | 
 |  | +            template.process(dataModel, writer);
 | 
											
												
													
														|  | 
 |  | +            FileWriter fileWriter = new FileWriter(LogService.BPATH + "/" + pid + "/in/cpacs.xml");
 | 
											
												
													
														|  | 
 |  | +            fileWriter.write(writer.toString());
 | 
											
												
													
														|  | 
 |  | +            fileWriter.close();
 | 
											
												
													
														|  | 
 |  | +            return  LogService.BPATH + "/" + pid + "/in/cpacs.xml";
 | 
											
												
													
														|  | 
 |  | +        }catch (Exception e){
 | 
											
												
													
														|  | 
 |  | +            return null;
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private static List<MdoProInoutPara> findMdoProInoutParas(String pid, String fatherid) {
 | 
											
												
													
														|  | 
 |  | +        MdoProInoutParaMapper xdao = UtilTools.getBean(MdoProInoutParaMapper.class);
 | 
											
												
													
														|  | 
 |  | +        MdoProInoutParaSQLBuilder xsb  = new MdoProInoutParaSQLBuilder();
 | 
											
												
													
														|  | 
 |  | +        MdoProInoutParaSQLBuilder.Criteria xsc =xsb.createCriteria();
 | 
											
												
													
														|  | 
 |  | +        xsc.andPidEqualTo(pid);
 | 
											
												
													
														|  | 
 |  | +        xsc.andFatheridEqualTo(fatherid);
 | 
											
												
													
														|  | 
 |  | +        List<MdoProInoutPara> inList = xdao.selectByExample(xsb);
 | 
											
												
													
														|  | 
 |  | +        return inList;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private static String getValByParaListAndCode(List<MdoProInoutPara> inList,String code) {
 | 
											
												
													
														|  | 
 |  | +        String value ="0";
 | 
											
												
													
														|  | 
 |  | +        List<MdoProInoutPara> tList = inList.stream().filter(x ->{
 | 
											
												
													
														|  | 
 |  | +            return code.equals(x.getCode());
 | 
											
												
													
														|  | 
 |  | +        }).collect(Collectors.toList());
 | 
											
												
													
														|  | 
 |  | +        if(tList!=null&&!tList.isEmpty()){
 | 
											
												
													
														|  | 
 |  | +            value = tList.get(0).getValue();
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        return value;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private static MdoProFfd getFfd(String pid) {
 | 
											
												
													
														|  | 
 |  | +        MdoProFfdMapper xdao = UtilTools.getBean(MdoProFfdMapper.class);
 | 
											
												
													
														|  | 
 |  | +        MdoProFfdSQLBuilder xsb  = new MdoProFfdSQLBuilder();
 | 
											
												
													
														|  | 
 |  | +        MdoProFfdSQLBuilder.Criteria xsc =xsb.createCriteria();
 | 
											
												
													
														|  | 
 |  | +        xsc.andPidEqualTo(pid);
 | 
											
												
													
														|  | 
 |  | +        xsc.andCheckedEqualTo(1);
 | 
											
												
													
														|  | 
 |  | +        List<MdoProFfd> xList = xdao.selectByExample(xsb);
 | 
											
												
													
														|  | 
 |  | +        MdoProFfd ffd =null;
 | 
											
												
													
														|  | 
 |  | +        if(xList!=null&&xList.isEmpty()){
 | 
											
												
													
														|  | 
 |  | +            ffd=xList.get(0);
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        return ffd;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private static MdoProCst findCst(String pid) {
 | 
											
												
													
														|  | 
 |  | +        MdoProCstMapper xdao = UtilTools.getBean(MdoProCstMapper.class);
 | 
											
												
													
														|  | 
 |  | +        MdoProCstSQLBuilder xsb  = new MdoProCstSQLBuilder();
 | 
											
												
													
														|  | 
 |  | +        MdoProCstSQLBuilder.Criteria xsc =xsb.createCriteria();
 | 
											
												
													
														|  | 
 |  | +        xsc.andPidEqualTo(pid);
 | 
											
												
													
														|  | 
 |  | +        xsc.andCheckedEqualTo(1);
 | 
											
												
													
														|  | 
 |  | +        List<MdoProCst> xList = xdao.selectByExample(xsb);
 | 
											
												
													
														|  | 
 |  | +        MdoProCst cst =null;
 | 
											
												
													
														|  | 
 |  | +        if(xList!=null&&xList.isEmpty()){
 | 
											
												
													
														|  | 
 |  | +            cst=xList.get(0);
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        return cst;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private static MdoProAdflow findAdflow(String pid) {
 | 
											
												
													
														|  | 
 |  | +        MdoProAdflowMapper xdao = UtilTools.getBean(MdoProAdflowMapper.class);
 | 
											
												
													
														|  | 
 |  | +        MdoProAdflowSQLBuilder xsb  = new MdoProAdflowSQLBuilder();
 | 
											
												
													
														|  | 
 |  | +        MdoProAdflowSQLBuilder.Criteria xsc =xsb.createCriteria();
 | 
											
												
													
														|  | 
 |  | +        xsc.andPidEqualTo(pid);
 | 
											
												
													
														|  | 
 |  | +        xsc.andCheckedEqualTo(1);
 | 
											
												
													
														|  | 
 |  | +        List<MdoProAdflow> xList = xdao.selectByExample(xsb);
 | 
											
												
													
														|  | 
 |  | +        MdoProAdflow adflow =null;
 | 
											
												
													
														|  | 
 |  | +        if(xList!=null&&xList.isEmpty()){
 | 
											
												
													
														|  | 
 |  | +            adflow=xList.get(0);
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        return adflow;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private static MdoProXfoil findXfoil(String pid) {
 | 
											
												
													
														|  | 
 |  | +        MdoProXfoilMapper xdao = UtilTools.getBean(MdoProXfoilMapper.class);
 | 
											
												
													
														|  | 
 |  | +        MdoProXfoilSQLBuilder xsb  = new MdoProXfoilSQLBuilder();
 | 
											
												
													
														|  | 
 |  | +        MdoProXfoilSQLBuilder.Criteria xsc =xsb.createCriteria();
 | 
											
												
													
														|  | 
 |  | +        xsc.andPidEqualTo(pid);
 | 
											
												
													
														|  | 
 |  | +        xsc.andCheckedEqualTo(1);
 | 
											
												
													
														|  | 
 |  | +        List<MdoProXfoil> xList = xdao.selectByExample(xsb);
 | 
											
												
													
														|  | 
 |  | +        MdoProXfoil xfoil =null;
 | 
											
												
													
														|  | 
 |  | +        if(xList!=null&&xList.isEmpty()){
 | 
											
												
													
														|  | 
 |  | +            xfoil=xList.get(0);
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        return xfoil;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      /**
 |  |      /**
 | 
											
												
													
														|  |       * TODO 创建 workflowXml
 |  |       * TODO 创建 workflowXml
 | 
											
												
													
														|  |       * @return
 |  |       * @return
 | 
											
												
													
														|  |       */
 |  |       */
 | 
											
												
													
														|  |      public static String createcWorkflowXml(String pid){
 |  |      public static String createcWorkflowXml(String pid){
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        return "";
 |  | 
 | 
											
												
													
														|  | 
 |  | +        return null;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      /**
 |  |      /**
 |