|
@@ -0,0 +1,579 @@
|
|
|
+package com.miniframe.template;
|
|
|
+
|
|
|
+import com.miniframe.core.exception.BusinessException;
|
|
|
+import com.miniframe.core.ext.UtilTools;
|
|
|
+import com.miniframe.model.system.*;
|
|
|
+import com.miniframe.model.system.dao.*;
|
|
|
+import com.miniframe.tools.XIFileUtils;
|
|
|
+import freemarker.template.Configuration;
|
|
|
+import freemarker.template.Template;
|
|
|
+import freemarker.template.TemplateException;
|
|
|
+import tk.mybatis.mapper.util.StringUtil;
|
|
|
+
|
|
|
+import java.io.FileWriter;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.StringWriter;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+public class TemplateGenerator2 {
|
|
|
+ public static final String BPATH = "/cephfs/disaster";
|
|
|
+
|
|
|
+ public static void createWaterControl(Integer aid, Integer jid, String totaltime, String dt, String dx, String reportstep, String interactionstep) throws IOException, TemplateException {
|
|
|
+ Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
|
+ // 设置模板所在目录
|
|
|
+ cfg.setClassForTemplateLoading(TemplateGenerator2.class, "/templates");
|
|
|
+ // 获取模板对象
|
|
|
+ Template template = cfg.getTemplate("water2Control.ftl");
|
|
|
+ // 定义数据模型(Map)
|
|
|
+ Map<String, Object> dataModel = new HashMap<>();
|
|
|
+ //几何文件路径
|
|
|
+ dataModel.put("geoFilePath", BPATH + "/" + aid + "/" + jid + "/Geometry");
|
|
|
+ //initFile 文件路径
|
|
|
+ dataModel.put("initFilePath", BPATH + "/" + aid + "/" + jid + "/water" + "/" + "water.init");
|
|
|
+
|
|
|
+ //midPath
|
|
|
+ dataModel.put("midPath", BPATH + "/" + aid + "/" + jid + "/water" + "/mid");
|
|
|
+ //monitorPath
|
|
|
+ dataModel.put("monitorPath", BPATH + "/" + aid + "/" + jid + "/monitor.in");
|
|
|
+ //outPath
|
|
|
+ dataModel.put("outPath", BPATH + "/" + aid + "/" + jid + "/water" + "/out");
|
|
|
+ dataModel.put("totaltime", totaltime);
|
|
|
+ dataModel.put("dt", dt);
|
|
|
+ dataModel.put("dx", dx);
|
|
|
+ dataModel.put("reportstep", reportstep);
|
|
|
+ dataModel.put("interactionstep", interactionstep);
|
|
|
+
|
|
|
+ DSourceMapper dsm = UtilTools.getBean(DSourceMapper.class);
|
|
|
+ DSourceSQLBuilder dss = new DSourceSQLBuilder();
|
|
|
+ DSourceSQLBuilder.Criteria dssc = dss.createCriteria();
|
|
|
+ dssc.andAidEqualTo(aid);
|
|
|
+// dssc.andSTypeEqualTo("Fire");
|
|
|
+ List<DSource> dources = dsm.selectByExample(dss);
|
|
|
+ //waterSourcenum 灾源数量
|
|
|
+ dataModel.put("waterSourcenum", dources.size());
|
|
|
+ //边界
|
|
|
+ DBoundaryMapper dBoundaryMapper = UtilTools.getBean(DBoundaryMapper.class);
|
|
|
+ DBoundarySQLBuilder sb = new DBoundarySQLBuilder();
|
|
|
+ DBoundarySQLBuilder.Criteria sc = sb.createCriteria();
|
|
|
+ sc.andAidEqualTo(aid);
|
|
|
+ List<DBoundary> boundaries = dBoundaryMapper.selectByExample(sb);
|
|
|
+ //边界数量
|
|
|
+ dataModel.put("boundarynum", boundaries.size());
|
|
|
+
|
|
|
+
|
|
|
+ // 将数据模型传入模板进行处理
|
|
|
+ StringWriter writer = new StringWriter();
|
|
|
+ template.process(dataModel, writer);
|
|
|
+ mkDirs(aid, jid, "/water");
|
|
|
+
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/" + "/water" + "/water.control");
|
|
|
+ fileWriter.write(writer.toString());
|
|
|
+ fileWriter.close();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void createWaterRunsh(Integer aid, Integer jid) throws IOException, TemplateException {
|
|
|
+ Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
|
+ // 设置模板所在目录
|
|
|
+ cfg.setClassForTemplateLoading(TemplateGenerator2.class, "/templates");
|
|
|
+ // 获取模板对象
|
|
|
+ Template template = cfg.getTemplate("waterRunsh.ftl");
|
|
|
+ // 定义数据模型(Map)
|
|
|
+ Map<String, Object> dataModel = new HashMap<>();
|
|
|
+ //几何文件路径
|
|
|
+ dataModel.put("waterControlPath", BPATH + "/" + aid + "/" + jid + "/water" + "/water.control");
|
|
|
+ //几何文件路径
|
|
|
+ dataModel.put("waterEscapeControlPath", BPATH + "/" + aid + "/" + jid + "/water" + "/waterEscape.control");
|
|
|
+ // 将数据模型传入模板进行处理
|
|
|
+ StringWriter writer = new StringWriter();
|
|
|
+ template.process(dataModel, writer);
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/water" + "/" + "runWater.sh");
|
|
|
+ fileWriter.write(writer.toString());
|
|
|
+ fileWriter.close();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void createWaterInit(Integer aid, Integer jid) throws IOException, TemplateException {
|
|
|
+ FireInitVo vo = new FireInitVo();
|
|
|
+ //TODO 这个版本不需要传感器数据
|
|
|
+// DNodeValMapper dnvm= UtilTools.getBean(DNodeValMapper.class);
|
|
|
+// DNodeValSQLBuilder dns = new DNodeValSQLBuilder();
|
|
|
+// DNodeValSQLBuilder.Criteria dnsc= dns.createCriteria();
|
|
|
+// dnsc.andAidEqualTo(aid);
|
|
|
+// List<DNodeVal> nodeVals=dnvm.selectByExample(dns);
|
|
|
+// vo.setNodeVals(nodeVals);
|
|
|
+
|
|
|
+ DSourceMapper dsm = UtilTools.getBean(DSourceMapper.class);
|
|
|
+ DSourceSQLBuilder dss = new DSourceSQLBuilder();
|
|
|
+ DSourceSQLBuilder.Criteria dssc = dss.createCriteria();
|
|
|
+ dssc.andAidEqualTo(aid);
|
|
|
+// dssc.andSTypeEqualTo("Water");
|
|
|
+ List<DSource> dources = dsm.selectByExample(dss);
|
|
|
+
|
|
|
+
|
|
|
+ DSourceValMapper dsvm = UtilTools.getBean(DSourceValMapper.class);
|
|
|
+ DSourceValSQLBuilder dsvs = new DSourceValSQLBuilder();
|
|
|
+
|
|
|
+ List<DSourceVo> dourceVos = new ArrayList<>();
|
|
|
+ for (DSource ds : dources) {
|
|
|
+ DSourceValSQLBuilder.Criteria dsvc = dsvs.createCriteria();
|
|
|
+ dsvc.andSidEqualTo(ds.getId());
|
|
|
+ List<DSourceVal> dSourceVals = dsvm.selectByExample(dsvs);
|
|
|
+
|
|
|
+ DSourceVo dsourcevo = new DSourceVo();
|
|
|
+ dsourcevo.setDsource(ds);
|
|
|
+ dsourcevo.setDsourceVals(dSourceVals);
|
|
|
+ dourceVos.add(dsourcevo);
|
|
|
+ dsvs.clear();
|
|
|
+ }
|
|
|
+ vo.setDourceVos(dourceVos);
|
|
|
+
|
|
|
+ //边界
|
|
|
+ DBoundaryMapper dBoundaryMapper = UtilTools.getBean(DBoundaryMapper.class);
|
|
|
+ DBoundarySQLBuilder sb = new DBoundarySQLBuilder();
|
|
|
+ DBoundarySQLBuilder.Criteria sc = sb.createCriteria();
|
|
|
+ sc.andAidEqualTo(aid);
|
|
|
+ List<DBoundary> boundaries = dBoundaryMapper.selectByExample(sb);
|
|
|
+
|
|
|
+ Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
|
+ // 设置模板所在目录
|
|
|
+ cfg.setClassForTemplateLoading(TemplateGenerator2.class, "/templates");
|
|
|
+ // 获取模板对象
|
|
|
+ Template template = cfg.getTemplate("waterInit.ftl");
|
|
|
+ // 定义数据模型(Map)
|
|
|
+ Map<String, Object> dataModel = new HashMap<>();
|
|
|
+ //几何文件路径
|
|
|
+ dataModel.put("vo", vo);
|
|
|
+ //边界
|
|
|
+ dataModel.put("boundaries", boundaries);
|
|
|
+
|
|
|
+ // 将数据模型传入模板进行处理
|
|
|
+ StringWriter writer = new StringWriter();
|
|
|
+ template.process(dataModel, writer);
|
|
|
+ // 输出结果到控制台或保存为文件
|
|
|
+// System.out.println(writer.toString());
|
|
|
+
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/water" + "/" + "water.init");
|
|
|
+ fileWriter.write(writer.toString());
|
|
|
+ fileWriter.close();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void createWaterEsccapeControl(Integer aid, Integer jid) throws IOException, TemplateException {
|
|
|
+ Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
|
+ // 设置模板所在目录
|
|
|
+ cfg.setClassForTemplateLoading(TemplateGenerator2.class, "/templates");
|
|
|
+ // 获取模板对象
|
|
|
+ Template template = cfg.getTemplate("water2EscapeControl.ftl");
|
|
|
+ // 定义数据模型(Map)
|
|
|
+ Map<String, Object> dataModel = new HashMap<>();
|
|
|
+ //几何文件路径
|
|
|
+ dataModel.put("geoFilePath", BPATH + "/" + aid + "/" + jid + "/Geometry");
|
|
|
+ //initFile 文件路径
|
|
|
+ dataModel.put("initFilePath", BPATH + "/" + aid + "/" + jid + "/water" + "/" + "water.init");
|
|
|
+ //midPath
|
|
|
+ dataModel.put("midPath", BPATH + "/" + aid + "/" + jid + "/water" + "/mid");
|
|
|
+ //monitorPath
|
|
|
+ dataModel.put("monitorPath", BPATH + "/" + aid + "/" + jid + "/monitor.in");
|
|
|
+
|
|
|
+ // 将数据模型传入模板进行处理
|
|
|
+ StringWriter writer = new StringWriter();
|
|
|
+ template.process(dataModel, writer);
|
|
|
+ mkDirs(aid, jid, "/water");
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/" + "/water" + "/waterEscape.control");
|
|
|
+ fileWriter.write(writer.toString());
|
|
|
+ fileWriter.close();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成几何文件
|
|
|
+ */
|
|
|
+ public static void createGeometry(Integer aid, Integer jid) throws IOException, TemplateException {
|
|
|
+ Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
|
+ // 设置模板所在目录
|
|
|
+ cfg.setClassForTemplateLoading(TemplateGenerator2.class, "/templates");
|
|
|
+ // 获取模板对象
|
|
|
+ Template template = cfg.getTemplate("geometry.ftl");
|
|
|
+ // 定义数据模型(Map)
|
|
|
+ Map<String, Object> dataModel = new HashMap<>();
|
|
|
+
|
|
|
+ DNodeMapper nodeMapper = UtilTools.getBean(DNodeMapper.class);
|
|
|
+ List<DNode> nodes = nodeMapper.selectAll();
|
|
|
+ Collections.sort(nodes, (n1, n2) -> n1.getId().compareTo(n2.getId()));
|
|
|
+
|
|
|
+
|
|
|
+ //节点数量
|
|
|
+ dataModel.put("nodenum", nodes.size());
|
|
|
+ //节点
|
|
|
+ dataModel.put("nodes", nodes);
|
|
|
+
|
|
|
+ DPipeMapper pipeMapper = UtilTools.getBean(DPipeMapper.class);
|
|
|
+ List<DPipe> pipes = pipeMapper.selectAll();
|
|
|
+ Collections.sort(pipes, (n1, n2) -> n1.getId().compareTo(n2.getId()));
|
|
|
+ //管道数量
|
|
|
+ dataModel.put("pipenum", pipes.size());
|
|
|
+ //管道
|
|
|
+ dataModel.put("pipes", pipes);
|
|
|
+
|
|
|
+ // 将数据模型传入模板进行处理
|
|
|
+ StringWriter writer = new StringWriter();
|
|
|
+ template.process(dataModel, writer);
|
|
|
+ mkDirs(aid, jid, "/fire");
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/Geometry");
|
|
|
+ fileWriter.write(writer.toString());
|
|
|
+ fileWriter.close();
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void mkDirs(Integer aid, Integer jid, String s) {
|
|
|
+ XIFileUtils.mkdir(BPATH);
|
|
|
+ XIFileUtils.mkdir(BPATH + "/" + aid);
|
|
|
+ XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid);
|
|
|
+ XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s);
|
|
|
+ XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/mid");
|
|
|
+ XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/out");
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void mkGassDirs(Integer aid, Integer jid, Integer gid) {
|
|
|
+ String s = "/gas";
|
|
|
+ XIFileUtils.mkdir(BPATH);
|
|
|
+ XIFileUtils.mkdir(BPATH + "/" + aid);
|
|
|
+ XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid);
|
|
|
+ XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s);
|
|
|
+ XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" + gid);
|
|
|
+ XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" + gid + "/mid");
|
|
|
+ XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" + gid + "/out");
|
|
|
+ XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" + gid + "/case");
|
|
|
+ XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" + gid + "/data_mnt");
|
|
|
+ XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" + gid + "/data_rst");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成监测点文件
|
|
|
+ */
|
|
|
+ public static void createMonitor(Integer aid, Integer jid) throws IOException, TemplateException {
|
|
|
+ Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
|
+ // 设置模板所在目录
|
|
|
+ cfg.setClassForTemplateLoading(TemplateGenerator2.class, "/templates");
|
|
|
+ // 获取模板对象
|
|
|
+ Template template = cfg.getTemplate("monitor.ftl");
|
|
|
+ // 定义数据模型(Map)
|
|
|
+ Map<String, Object> dataModel = new HashMap<>();
|
|
|
+
|
|
|
+ DChecknodeMapper checknodeMapper = UtilTools.getBean(DChecknodeMapper.class);
|
|
|
+ List<DChecknode> monitors = checknodeMapper.selectAll();
|
|
|
+ Collections.sort(monitors, (n1, n2) -> n1.getId().compareTo(n2.getId()));
|
|
|
+ dataModel.put("monnum", monitors.size());
|
|
|
+ //管道
|
|
|
+ dataModel.put("monitors", monitors);
|
|
|
+
|
|
|
+ // 将数据模型传入模板进行处理
|
|
|
+ StringWriter writer = new StringWriter();
|
|
|
+ template.process(dataModel, writer);
|
|
|
+ mkDirs(aid, jid, "/fire");
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/monitor.in");
|
|
|
+ fileWriter.write(writer.toString());
|
|
|
+ fileWriter.close();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void createFireControl(Integer aid, Integer jid, String totaltime,
|
|
|
+ String dt, String dx, String reportstep, String interactionstep,
|
|
|
+ String cocodes) throws IOException, TemplateException {
|
|
|
+ Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
|
+ // 设置模板所在目录
|
|
|
+ cfg.setClassForTemplateLoading(TemplateGenerator2.class, "/templates");
|
|
|
+ // 获取模板对象
|
|
|
+ Template template = cfg.getTemplate("fireControl.ftl");
|
|
|
+ // 定义数据模型(Map)
|
|
|
+ Map<String, Object> dataModel = new HashMap<>();
|
|
|
+ //几何文件路径
|
|
|
+ dataModel.put("geoFilePath", BPATH + "/" + aid + "/" + jid + "/Geometry");
|
|
|
+ //fireinit 文件路径
|
|
|
+ dataModel.put("initFilePath", BPATH + "/" + aid + "/" + jid + "/fire" + "/" + "Fire.init");
|
|
|
+ //fireInteractionPath 阀门文件路径
|
|
|
+ dataModel.put("fireInteractionPath", "/home/disaster/fire/Fire.interaction");
|
|
|
+ //midPath
|
|
|
+ dataModel.put("monitorPath", BPATH + "/" + aid + "/" + jid + "/monitor.in");
|
|
|
+ //midPath
|
|
|
+ dataModel.put("midPath", BPATH + "/" + aid + "/" + jid + "/fire" + "/mid");
|
|
|
+ //outPath
|
|
|
+ dataModel.put("outPath", BPATH + "/" + aid + "/" + jid + "/fire" + "/out");
|
|
|
+
|
|
|
+ dataModel.put("totaltime", totaltime);
|
|
|
+ dataModel.put("dt", dt);
|
|
|
+ dataModel.put("dx", dx);
|
|
|
+ dataModel.put("reportstep", reportstep);
|
|
|
+ dataModel.put("interactionstep", interactionstep);
|
|
|
+
|
|
|
+
|
|
|
+ DSourceMapper dsm = UtilTools.getBean(DSourceMapper.class);
|
|
|
+ DSourceSQLBuilder dss = new DSourceSQLBuilder();
|
|
|
+ DSourceSQLBuilder.Criteria dssc = dss.createCriteria();
|
|
|
+ dssc.andAidEqualTo(aid);
|
|
|
+// dssc.andSTypeEqualTo("Fire");
|
|
|
+ List<DSource> dources = dsm.selectByExample(dss);
|
|
|
+ //fireSourceNum 灾源数量
|
|
|
+ dataModel.put("fireSourceNum", dources.size());
|
|
|
+ //边界
|
|
|
+ DBoundaryMapper dBoundaryMapper = UtilTools.getBean(DBoundaryMapper.class);
|
|
|
+ DBoundarySQLBuilder sb = new DBoundarySQLBuilder();
|
|
|
+ DBoundarySQLBuilder.Criteria sc = sb.createCriteria();
|
|
|
+ sc.andAidEqualTo(aid);
|
|
|
+ List<DBoundary> boundaries = dBoundaryMapper.selectByExample(sb);
|
|
|
+ //边界数量
|
|
|
+ dataModel.put("boundarynum", boundaries.size());
|
|
|
+ //物理量
|
|
|
+ String[] codes = cocodes.split(",");
|
|
|
+ List<String> concodeList = new ArrayList<>();
|
|
|
+ for (String concode : codes
|
|
|
+ ) {
|
|
|
+ concodeList.add(concode);
|
|
|
+ }
|
|
|
+ DConMapper conMapper = UtilTools.getBean(DConMapper.class);
|
|
|
+ DConSQLBuilder consb = new DConSQLBuilder();
|
|
|
+ DConSQLBuilder.Criteria consc = consb.createCriteria();
|
|
|
+ consc.andCodeIn(concodeList);
|
|
|
+ List<DCon> cons = conMapper.selectByExample(consb);
|
|
|
+ dataModel.put("conNum", cons.size());
|
|
|
+ dataModel.put("cons", cons);
|
|
|
+
|
|
|
+ // 将数据模型传入模板进行处理
|
|
|
+ StringWriter writer = new StringWriter();
|
|
|
+ template.process(dataModel, writer);
|
|
|
+ mkDirs(aid, jid, "/fire");
|
|
|
+
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/" + "/fire" + "/Fire.control");
|
|
|
+ fileWriter.write(writer.toString());
|
|
|
+ fileWriter.close();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void createFireRunsh(Integer aid, Integer jid) throws IOException, TemplateException {
|
|
|
+ Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
|
+ // 设置模板所在目录
|
|
|
+ cfg.setClassForTemplateLoading(TemplateGenerator2.class, "/templates");
|
|
|
+ // 获取模板对象
|
|
|
+ Template template = cfg.getTemplate("fireRunsh.ftl");
|
|
|
+ // 定义数据模型(Map)
|
|
|
+ Map<String, Object> dataModel = new HashMap<>();
|
|
|
+ //几何文件路径
|
|
|
+ dataModel.put("firecontrolPath", BPATH + "/" + aid + "/" + jid + "/fire" + "/Fire.control");
|
|
|
+ // 将数据模型传入模板进行处理
|
|
|
+ StringWriter writer = new StringWriter();
|
|
|
+ template.process(dataModel, writer);
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/fire" + "/" + "runFile.sh");
|
|
|
+ fileWriter.write(writer.toString());
|
|
|
+ fileWriter.close();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void createFireInit(Integer aid, Integer jid) throws IOException, TemplateException {
|
|
|
+ FireInitVo vo = new FireInitVo();
|
|
|
+
|
|
|
+ //TODO 求解器暂时不需要此数据
|
|
|
+// DNodeValMapper dnvm= UtilTools.getBean(DNodeValMapper.class);
|
|
|
+// DNodeValSQLBuilder dns = new DNodeValSQLBuilder();
|
|
|
+// DNodeValSQLBuilder.Criteria dnsc= dns.createCriteria();
|
|
|
+// dnsc.andAidEqualTo(aid);
|
|
|
+// List<DNodeVal> nodeVals=dnvm.selectByExample(dns);
|
|
|
+// vo.setNodeVals(nodeVals);
|
|
|
+
|
|
|
+ DSourceMapper dsm = UtilTools.getBean(DSourceMapper.class);
|
|
|
+ DSourceSQLBuilder dss = new DSourceSQLBuilder();
|
|
|
+ DSourceSQLBuilder.Criteria dssc = dss.createCriteria();
|
|
|
+ dssc.andAidEqualTo(aid);
|
|
|
+// dssc.andSTypeEqualTo("Fire");
|
|
|
+ List<DSource> dources = dsm.selectByExample(dss);
|
|
|
+
|
|
|
+
|
|
|
+ DSourceValMapper dsvm = UtilTools.getBean(DSourceValMapper.class);
|
|
|
+ DSourceValSQLBuilder dsvs = new DSourceValSQLBuilder();
|
|
|
+
|
|
|
+ List<DSourceVo> dourceVos = new ArrayList<>();
|
|
|
+ for (DSource ds : dources) {
|
|
|
+ DSourceValSQLBuilder.Criteria dsvc = dsvs.createCriteria();
|
|
|
+ dsvc.andSidEqualTo(ds.getId());
|
|
|
+ List<DSourceVal> dSourceVals = dsvm.selectByExample(dsvs);
|
|
|
+
|
|
|
+ DSourceVo dsourcevo = new DSourceVo();
|
|
|
+ dsourcevo.setDsource(ds);
|
|
|
+ dsourcevo.setDsourceVals(dSourceVals);
|
|
|
+ dourceVos.add(dsourcevo);
|
|
|
+ dsvs.clear();
|
|
|
+ }
|
|
|
+ vo.setDourceVos(dourceVos);
|
|
|
+
|
|
|
+ //边界
|
|
|
+ DBoundaryMapper dBoundaryMapper = UtilTools.getBean(DBoundaryMapper.class);
|
|
|
+ DBoundarySQLBuilder sb = new DBoundarySQLBuilder();
|
|
|
+ DBoundarySQLBuilder.Criteria sc = sb.createCriteria();
|
|
|
+ sc.andAidEqualTo(aid);
|
|
|
+ List<DBoundary> boundaries = dBoundaryMapper.selectByExample(sb);
|
|
|
+
|
|
|
+
|
|
|
+ Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
|
+ // 设置模板所在目录
|
|
|
+ cfg.setClassForTemplateLoading(TemplateGenerator2.class, "/templates");
|
|
|
+ // 获取模板对象
|
|
|
+ Template template = cfg.getTemplate("fireInit.ftl");
|
|
|
+ // 定义数据模型(Map)
|
|
|
+ Map<String, Object> dataModel = new HashMap<>();
|
|
|
+ //几何文件路径
|
|
|
+ dataModel.put("vo", vo);
|
|
|
+ //边界
|
|
|
+ dataModel.put("boundaries", boundaries);
|
|
|
+
|
|
|
+ // 将数据模型传入模板进行处理
|
|
|
+ StringWriter writer = new StringWriter();
|
|
|
+ template.process(dataModel, writer);
|
|
|
+ // 输出结果到控制台或保存为文件
|
|
|
+// System.out.println(writer.toString());
|
|
|
+
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/fire" + "/" + "Fire.init");
|
|
|
+ fileWriter.write(writer.toString());
|
|
|
+ fileWriter.close();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) throws Exception {
|
|
|
+// TemplateGenerator.createWaterRunsh(5);
|
|
|
+
|
|
|
+ float myFloat = 495545.603f;
|
|
|
+ String formattedString = String.format("%.32f", myFloat);
|
|
|
+ System.out.println(myFloat); // 输出: 123.46
|
|
|
+ System.out.println(formattedString); // 输出: 123.46
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void createGasControl(Integer aid, Integer jid, Integer gid, String totaltime,
|
|
|
+ String dt, String dx, String reportstep, String interactionstep,
|
|
|
+ String cocodes) throws IOException, TemplateException {
|
|
|
+
|
|
|
+ Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
|
+ // 设置模板所在目录
|
|
|
+ cfg.setClassForTemplateLoading(TemplateGenerator2.class, "/templates");
|
|
|
+ // 获取模板对象
|
|
|
+ Template template = cfg.getTemplate("mashGasControl.ftl");
|
|
|
+ // 定义数据模型(Map)
|
|
|
+ Map<String, Object> dataModel = new HashMap<>();
|
|
|
+ //几何文件路径
|
|
|
+ dataModel.put("geoFilePath", BPATH + "/" + aid + "/" + jid + "/Geometry");
|
|
|
+ //fireinit 文件路径
|
|
|
+ dataModel.put("initFilePath", BPATH + "/" + aid + "/" + jid + "/gas" + "/" + gid + "/" + "MashGas.init");
|
|
|
+ //midPath
|
|
|
+ dataModel.put("monitorPath", BPATH + "/" + aid + "/" + jid + "/monitor.in");
|
|
|
+ //midPath
|
|
|
+ dataModel.put("midPath", BPATH + "/" + aid + "/" + jid + "/gas" + "/" + gid + "/mid");
|
|
|
+ //outPath
|
|
|
+ dataModel.put("outPath", BPATH + "/" + aid + "/" + jid + "/gas" + "/" + gid + "/out");
|
|
|
+ //CPUS
|
|
|
+ dataModel.put("cups", 1);
|
|
|
+ dataModel.put("totaltime", totaltime);
|
|
|
+ dataModel.put("dt", dt);
|
|
|
+ dataModel.put("dx", dx);
|
|
|
+ dataModel.put("reportstep", reportstep);
|
|
|
+ dataModel.put("interactionstep", interactionstep);
|
|
|
+ //TODO
|
|
|
+ dataModel.put("boundarynum", 3);
|
|
|
+ //TODO
|
|
|
+ dataModel.put("mashgasnumber", 1);
|
|
|
+
|
|
|
+ //fireInteractionPath 阀门文件路径
|
|
|
+ dataModel.put("fireInteractionPath", "/home/disaster/fire/Fire.interaction");
|
|
|
+
|
|
|
+ //物理量
|
|
|
+ if (StringUtil.isEmpty(cocodes)) {
|
|
|
+ dataModel.put("conNum", 0);
|
|
|
+ dataModel.put("cons", new ArrayList<>());
|
|
|
+ } else {
|
|
|
+ String[] codes = cocodes.split(",");
|
|
|
+ List<String> concodeList = new ArrayList<>();
|
|
|
+ for (String concode : codes
|
|
|
+ ) {
|
|
|
+ concodeList.add(concode);
|
|
|
+ }
|
|
|
+ DConMapper conMapper = UtilTools.getBean(DConMapper.class);
|
|
|
+ DConSQLBuilder consb = new DConSQLBuilder();
|
|
|
+ DConSQLBuilder.Criteria consc = consb.createCriteria();
|
|
|
+ consc.andCodeIn(concodeList);
|
|
|
+ List<DCon> cons = conMapper.selectByExample(consb);
|
|
|
+ dataModel.put("conNum", cons.size());
|
|
|
+ dataModel.put("cons", cons);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 将数据模型传入模板进行处理
|
|
|
+ StringWriter writer = new StringWriter();
|
|
|
+ template.process(dataModel, writer);
|
|
|
+ mkGassDirs(aid, jid, gid);
|
|
|
+
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gid + "/MashGas.control");
|
|
|
+ fileWriter.write(writer.toString());
|
|
|
+ fileWriter.close();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static void createGasInit(Integer aid, Integer jid, Integer gid) throws IOException, TemplateException, BusinessException {
|
|
|
+
|
|
|
+ Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
|
+ // 设置模板所在目录
|
|
|
+ cfg.setClassForTemplateLoading(TemplateGenerator2.class, "/templates");
|
|
|
+ // 获取模板对象
|
|
|
+ Template template = cfg.getTemplate("mashGasInit.ftl");
|
|
|
+ // 定义数据模型(Map)
|
|
|
+ Map<String, Object> dataModel = new HashMap<>();
|
|
|
+
|
|
|
+ DGasBlastAreaMapper blastMapper = UtilTools.getBean(DGasBlastAreaMapper.class);
|
|
|
+ DGasBlastAreaSQLBuilder blastSb = new DGasBlastAreaSQLBuilder();
|
|
|
+ DGasBlastAreaSQLBuilder.Criteria blastSc = blastSb.createCriteria();
|
|
|
+ blastSc.andGidEqualTo(gid);
|
|
|
+
|
|
|
+ List<DGasBlastArea> blastList = blastMapper.selectByExample(blastSb);
|
|
|
+ if (blastList.isEmpty()) {
|
|
|
+ throw new BusinessException("EB3100023");
|
|
|
+ }
|
|
|
+ //TODO boundaries 没有数据
|
|
|
+ dataModel.put("boundaries", new ArrayList<>());
|
|
|
+ dataModel.put("blastnum", blastList.size());
|
|
|
+ dataModel.put("blastList", blastList);
|
|
|
+ DGasGatherAreaMapper gatherMapper = UtilTools.getBean(DGasGatherAreaMapper.class);
|
|
|
+ DGasGatherAreaSQLBuilder gatherSb = new DGasGatherAreaSQLBuilder();
|
|
|
+ DGasGatherAreaSQLBuilder.Criteria gatherSc = gatherSb.createCriteria();
|
|
|
+ gatherSc.andGidEqualTo(gid);
|
|
|
+ gatherSb.setOrderByClause("id ASC");
|
|
|
+ List<DGasGatherArea> gatherList = gatherMapper.selectByExample(gatherSb);
|
|
|
+ if (gatherList.isEmpty()) {
|
|
|
+ throw new BusinessException("EB3100024");
|
|
|
+ }
|
|
|
+ dataModel.put("gathernum", gatherList.size());
|
|
|
+ dataModel.put("gatherList", gatherList);
|
|
|
+
|
|
|
+ DGasMapper gasMapper = UtilTools.getBean(DGasMapper.class);
|
|
|
+ DGas gas = gasMapper.selectByPrimaryKey(gid);
|
|
|
+ dataModel.put("gas", gas);
|
|
|
+ // 将数据模型传入模板进行处理
|
|
|
+ StringWriter writer = new StringWriter();
|
|
|
+ template.process(dataModel, writer);
|
|
|
+ mkGassDirs(aid, jid, gid);
|
|
|
+
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gid + "/MashGas.init");
|
|
|
+ fileWriter.write(writer.toString());
|
|
|
+ fileWriter.close();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void createGassRunsh(Integer aid, Integer jid, Integer gid) throws IOException, TemplateException {
|
|
|
+ Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
|
+ // 设置模板所在目录
|
|
|
+ cfg.setClassForTemplateLoading(TemplateGenerator2.class, "/templates");
|
|
|
+ // 获取模板对象
|
|
|
+ Template template = cfg.getTemplate("mashGasRunsh.ftl");
|
|
|
+ // 定义数据模型(Map)
|
|
|
+ Map<String, Object> dataModel = new HashMap<>();
|
|
|
+ dataModel.put("casepath", BPATH + "/" + aid + "/" + jid + "/gas" + "/" + gid + "/case");
|
|
|
+ dataModel.put("gascontrol", BPATH + "/" + aid + "/" + jid + "/gas" + "/" + gid + "/MashGas.control");
|
|
|
+ // 将数据模型传入模板进行处理
|
|
|
+ StringWriter writer = new StringWriter();
|
|
|
+ template.process(dataModel, writer);
|
|
|
+ mkGassDirs(aid, jid, gid);
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gid + "/run.sh");
|
|
|
+ fileWriter.write(writer.toString());
|
|
|
+
|
|
|
+ fileWriter.close();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|