|
@@ -1,5 +1,6 @@
|
|
package com.miniframe.template;
|
|
package com.miniframe.template;
|
|
|
|
|
|
|
|
+import com.miniframe.core.exception.BusinessException;
|
|
import com.miniframe.core.ext.UtilTools;
|
|
import com.miniframe.core.ext.UtilTools;
|
|
import com.miniframe.model.system.*;
|
|
import com.miniframe.model.system.*;
|
|
import com.miniframe.model.system.dao.*;
|
|
import com.miniframe.model.system.dao.*;
|
|
@@ -8,6 +9,7 @@ import com.miniframe.tools.XIIniFileUtils;
|
|
import freemarker.template.Configuration;
|
|
import freemarker.template.Configuration;
|
|
import freemarker.template.Template;
|
|
import freemarker.template.Template;
|
|
import freemarker.template.TemplateException;
|
|
import freemarker.template.TemplateException;
|
|
|
|
+import tk.mybatis.mapper.util.StringUtil;
|
|
|
|
|
|
import java.io.FileWriter;
|
|
import java.io.FileWriter;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
@@ -15,11 +17,10 @@ import java.io.StringWriter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
public class TemplateGenerator {
|
|
public class TemplateGenerator {
|
|
- public static final String BPATH="/cephfs/disaster";
|
|
|
|
|
|
+ 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 {
|
|
|
|
|
|
+ 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);
|
|
Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
// 设置模板所在目录
|
|
// 设置模板所在目录
|
|
cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
|
|
cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
|
|
@@ -28,33 +29,33 @@ public class TemplateGenerator {
|
|
// 定义数据模型(Map)
|
|
// 定义数据模型(Map)
|
|
Map<String, Object> dataModel = new HashMap<>();
|
|
Map<String, Object> dataModel = new HashMap<>();
|
|
//几何文件路径
|
|
//几何文件路径
|
|
- dataModel.put("geoFilePath", BPATH+"/"+aid+"/"+jid+"/Geometry");
|
|
|
|
|
|
+ dataModel.put("geoFilePath", BPATH + "/" + aid + "/" + jid + "/Geometry");
|
|
//initFile 文件路径
|
|
//initFile 文件路径
|
|
- dataModel.put("initFilePath", BPATH+"/"+aid+"/"+jid+"/water"+"/"+"water.init");
|
|
|
|
|
|
+ dataModel.put("initFilePath", BPATH + "/" + aid + "/" + jid + "/water" + "/" + "water.init");
|
|
|
|
|
|
//midPath
|
|
//midPath
|
|
- dataModel.put("midPath", BPATH+"/"+aid+"/"+jid+"/water"+"/mid");
|
|
|
|
|
|
+ dataModel.put("midPath", BPATH + "/" + aid + "/" + jid + "/water" + "/mid");
|
|
//monitorPath
|
|
//monitorPath
|
|
- dataModel.put("monitorPath",BPATH+"/"+aid+"/"+jid+"/monitor.in");
|
|
|
|
|
|
+ dataModel.put("monitorPath", BPATH + "/" + aid + "/" + jid + "/monitor.in");
|
|
//outPath
|
|
//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();
|
|
|
|
|
|
+ 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();
|
|
DSourceSQLBuilder.Criteria dssc = dss.createCriteria();
|
|
dssc.andAidEqualTo(aid);
|
|
dssc.andAidEqualTo(aid);
|
|
// dssc.andSTypeEqualTo("Fire");
|
|
// dssc.andSTypeEqualTo("Fire");
|
|
- List<DSource> dources =dsm.selectByExample(dss);
|
|
|
|
|
|
+ List<DSource> dources = dsm.selectByExample(dss);
|
|
//waterSourcenum 灾源数量
|
|
//waterSourcenum 灾源数量
|
|
dataModel.put("waterSourcenum", dources.size());
|
|
dataModel.put("waterSourcenum", dources.size());
|
|
//边界
|
|
//边界
|
|
DBoundaryMapper dBoundaryMapper = UtilTools.getBean(DBoundaryMapper.class);
|
|
DBoundaryMapper dBoundaryMapper = UtilTools.getBean(DBoundaryMapper.class);
|
|
- DBoundarySQLBuilder sb =new DBoundarySQLBuilder();
|
|
|
|
|
|
+ DBoundarySQLBuilder sb = new DBoundarySQLBuilder();
|
|
DBoundarySQLBuilder.Criteria sc = sb.createCriteria();
|
|
DBoundarySQLBuilder.Criteria sc = sb.createCriteria();
|
|
sc.andAidEqualTo(aid);
|
|
sc.andAidEqualTo(aid);
|
|
List<DBoundary> boundaries = dBoundaryMapper.selectByExample(sb);
|
|
List<DBoundary> boundaries = dBoundaryMapper.selectByExample(sb);
|
|
@@ -67,12 +68,12 @@ public class TemplateGenerator {
|
|
template.process(dataModel, writer);
|
|
template.process(dataModel, writer);
|
|
mkDirs(aid, jid, "/water");
|
|
mkDirs(aid, jid, "/water");
|
|
|
|
|
|
- FileWriter fileWriter =new FileWriter(BPATH+"/"+aid+"/"+jid+"/"+"/water"+"/water.control");
|
|
|
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/" + "/water" + "/water.control");
|
|
fileWriter.write(writer.toString());
|
|
fileWriter.write(writer.toString());
|
|
fileWriter.close();
|
|
fileWriter.close();
|
|
}
|
|
}
|
|
|
|
|
|
- public static void createWaterRunsh(Integer aid,Integer jid) throws IOException, TemplateException {
|
|
|
|
|
|
+ public static void createWaterRunsh(Integer aid, Integer jid) throws IOException, TemplateException {
|
|
Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
// 设置模板所在目录
|
|
// 设置模板所在目录
|
|
cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
|
|
cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
|
|
@@ -81,16 +82,17 @@ public class TemplateGenerator {
|
|
// 定义数据模型(Map)
|
|
// 定义数据模型(Map)
|
|
Map<String, Object> dataModel = new HashMap<>();
|
|
Map<String, Object> dataModel = new HashMap<>();
|
|
//几何文件路径
|
|
//几何文件路径
|
|
- dataModel.put("waterControlPath", BPATH+"/"+aid+"/"+jid+"/water"+"/water.control");
|
|
|
|
|
|
+ dataModel.put("waterControlPath", BPATH + "/" + aid + "/" + jid + "/water" + "/water.control");
|
|
// 将数据模型传入模板进行处理
|
|
// 将数据模型传入模板进行处理
|
|
StringWriter writer = new StringWriter();
|
|
StringWriter writer = new StringWriter();
|
|
template.process(dataModel, writer);
|
|
template.process(dataModel, writer);
|
|
- FileWriter fileWriter =new FileWriter(BPATH+"/"+aid+"/"+jid+"/water"+"/"+"runWater.sh");
|
|
|
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/water" + "/" + "runWater.sh");
|
|
fileWriter.write(writer.toString());
|
|
fileWriter.write(writer.toString());
|
|
fileWriter.close();
|
|
fileWriter.close();
|
|
}
|
|
}
|
|
- public static void createWaterInit(Integer aid,Integer jid) throws IOException, TemplateException {
|
|
|
|
- FireInitVo vo =new FireInitVo();
|
|
|
|
|
|
+
|
|
|
|
+ public static void createWaterInit(Integer aid, Integer jid) throws IOException, TemplateException {
|
|
|
|
+ FireInitVo vo = new FireInitVo();
|
|
//TODO 这个版本不需要传感器数据
|
|
//TODO 这个版本不需要传感器数据
|
|
// DNodeValMapper dnvm= UtilTools.getBean(DNodeValMapper.class);
|
|
// DNodeValMapper dnvm= UtilTools.getBean(DNodeValMapper.class);
|
|
// DNodeValSQLBuilder dns = new DNodeValSQLBuilder();
|
|
// DNodeValSQLBuilder dns = new DNodeValSQLBuilder();
|
|
@@ -99,24 +101,24 @@ public class TemplateGenerator {
|
|
// List<DNodeVal> nodeVals=dnvm.selectByExample(dns);
|
|
// List<DNodeVal> nodeVals=dnvm.selectByExample(dns);
|
|
// vo.setNodeVals(nodeVals);
|
|
// vo.setNodeVals(nodeVals);
|
|
|
|
|
|
- DSourceMapper dsm =UtilTools.getBean(DSourceMapper.class);
|
|
|
|
- DSourceSQLBuilder dss= new DSourceSQLBuilder();
|
|
|
|
|
|
+ DSourceMapper dsm = UtilTools.getBean(DSourceMapper.class);
|
|
|
|
+ DSourceSQLBuilder dss = new DSourceSQLBuilder();
|
|
DSourceSQLBuilder.Criteria dssc = dss.createCriteria();
|
|
DSourceSQLBuilder.Criteria dssc = dss.createCriteria();
|
|
dssc.andAidEqualTo(aid);
|
|
dssc.andAidEqualTo(aid);
|
|
// dssc.andSTypeEqualTo("Water");
|
|
// dssc.andSTypeEqualTo("Water");
|
|
- List<DSource> dources =dsm.selectByExample(dss);
|
|
|
|
|
|
+ List<DSource> dources = dsm.selectByExample(dss);
|
|
|
|
|
|
|
|
|
|
- DSourceValMapper dsvm =UtilTools.getBean(DSourceValMapper.class);
|
|
|
|
- DSourceValSQLBuilder dsvs =new DSourceValSQLBuilder();
|
|
|
|
|
|
+ DSourceValMapper dsvm = UtilTools.getBean(DSourceValMapper.class);
|
|
|
|
+ DSourceValSQLBuilder dsvs = new DSourceValSQLBuilder();
|
|
|
|
|
|
- List<DSourceVo> dourceVos = new ArrayList<>();
|
|
|
|
- for (DSource ds:dources) {
|
|
|
|
|
|
+ List<DSourceVo> dourceVos = new ArrayList<>();
|
|
|
|
+ for (DSource ds : dources) {
|
|
DSourceValSQLBuilder.Criteria dsvc = dsvs.createCriteria();
|
|
DSourceValSQLBuilder.Criteria dsvc = dsvs.createCriteria();
|
|
dsvc.andSidEqualTo(ds.getId());
|
|
dsvc.andSidEqualTo(ds.getId());
|
|
List<DSourceVal> dSourceVals = dsvm.selectByExample(dsvs);
|
|
List<DSourceVal> dSourceVals = dsvm.selectByExample(dsvs);
|
|
|
|
|
|
- DSourceVo dsourcevo =new DSourceVo();
|
|
|
|
|
|
+ DSourceVo dsourcevo = new DSourceVo();
|
|
dsourcevo.setDsource(ds);
|
|
dsourcevo.setDsource(ds);
|
|
dsourcevo.setDsourceVals(dSourceVals);
|
|
dsourcevo.setDsourceVals(dSourceVals);
|
|
dourceVos.add(dsourcevo);
|
|
dourceVos.add(dsourcevo);
|
|
@@ -126,7 +128,7 @@ public class TemplateGenerator {
|
|
|
|
|
|
//边界
|
|
//边界
|
|
DBoundaryMapper dBoundaryMapper = UtilTools.getBean(DBoundaryMapper.class);
|
|
DBoundaryMapper dBoundaryMapper = UtilTools.getBean(DBoundaryMapper.class);
|
|
- DBoundarySQLBuilder sb =new DBoundarySQLBuilder();
|
|
|
|
|
|
+ DBoundarySQLBuilder sb = new DBoundarySQLBuilder();
|
|
DBoundarySQLBuilder.Criteria sc = sb.createCriteria();
|
|
DBoundarySQLBuilder.Criteria sc = sb.createCriteria();
|
|
sc.andAidEqualTo(aid);
|
|
sc.andAidEqualTo(aid);
|
|
List<DBoundary> boundaries = dBoundaryMapper.selectByExample(sb);
|
|
List<DBoundary> boundaries = dBoundaryMapper.selectByExample(sb);
|
|
@@ -149,7 +151,7 @@ public class TemplateGenerator {
|
|
// 输出结果到控制台或保存为文件
|
|
// 输出结果到控制台或保存为文件
|
|
// System.out.println(writer.toString());
|
|
// System.out.println(writer.toString());
|
|
|
|
|
|
- FileWriter fileWriter =new FileWriter(BPATH+"/"+aid+"/"+jid+"/water"+"/"+"water.init");
|
|
|
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/water" + "/" + "water.init");
|
|
fileWriter.write(writer.toString());
|
|
fileWriter.write(writer.toString());
|
|
fileWriter.close();
|
|
fileWriter.close();
|
|
}
|
|
}
|
|
@@ -157,7 +159,7 @@ public class TemplateGenerator {
|
|
/**
|
|
/**
|
|
* 生成几何文件
|
|
* 生成几何文件
|
|
*/
|
|
*/
|
|
- public static void createGeometry(Integer aid,Integer jid) throws IOException, TemplateException {
|
|
|
|
|
|
+ public static void createGeometry(Integer aid, Integer jid) throws IOException, TemplateException {
|
|
Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
// 设置模板所在目录
|
|
// 设置模板所在目录
|
|
cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
|
|
cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
|
|
@@ -166,7 +168,7 @@ public class TemplateGenerator {
|
|
// 定义数据模型(Map)
|
|
// 定义数据模型(Map)
|
|
Map<String, Object> dataModel = new HashMap<>();
|
|
Map<String, Object> dataModel = new HashMap<>();
|
|
|
|
|
|
- DNodeMapper nodeMapper =UtilTools.getBean(DNodeMapper.class);
|
|
|
|
|
|
+ DNodeMapper nodeMapper = UtilTools.getBean(DNodeMapper.class);
|
|
List<DNode> nodes = nodeMapper.selectAll();
|
|
List<DNode> nodes = nodeMapper.selectAll();
|
|
Collections.sort(nodes, (n1, n2) -> n1.getId().compareTo(n2.getId()));
|
|
Collections.sort(nodes, (n1, n2) -> n1.getId().compareTo(n2.getId()));
|
|
|
|
|
|
@@ -176,8 +178,8 @@ public class TemplateGenerator {
|
|
//节点
|
|
//节点
|
|
dataModel.put("nodes", nodes);
|
|
dataModel.put("nodes", nodes);
|
|
|
|
|
|
- DPipeMapper pipeMapper =UtilTools.getBean(DPipeMapper.class);
|
|
|
|
- List<DPipe> pipes =pipeMapper.selectAll();
|
|
|
|
|
|
+ DPipeMapper pipeMapper = UtilTools.getBean(DPipeMapper.class);
|
|
|
|
+ List<DPipe> pipes = pipeMapper.selectAll();
|
|
Collections.sort(pipes, (n1, n2) -> n1.getId().compareTo(n2.getId()));
|
|
Collections.sort(pipes, (n1, n2) -> n1.getId().compareTo(n2.getId()));
|
|
//管道数量
|
|
//管道数量
|
|
dataModel.put("pipenum", pipes.size());
|
|
dataModel.put("pipenum", pipes.size());
|
|
@@ -188,7 +190,7 @@ public class TemplateGenerator {
|
|
StringWriter writer = new StringWriter();
|
|
StringWriter writer = new StringWriter();
|
|
template.process(dataModel, writer);
|
|
template.process(dataModel, writer);
|
|
mkDirs(aid, jid, "/fire");
|
|
mkDirs(aid, jid, "/fire");
|
|
- FileWriter fileWriter =new FileWriter(BPATH+"/"+aid+"/"+jid+"/Geometry");
|
|
|
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/Geometry");
|
|
fileWriter.write(writer.toString());
|
|
fileWriter.write(writer.toString());
|
|
fileWriter.close();
|
|
fileWriter.close();
|
|
}
|
|
}
|
|
@@ -202,10 +204,21 @@ public class TemplateGenerator {
|
|
XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/out");
|
|
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");
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 生成监测点文件
|
|
* 生成监测点文件
|
|
*/
|
|
*/
|
|
- public static void createMonitor(Integer aid,Integer jid) throws IOException, TemplateException {
|
|
|
|
|
|
+ public static void createMonitor(Integer aid, Integer jid) throws IOException, TemplateException {
|
|
Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
// 设置模板所在目录
|
|
// 设置模板所在目录
|
|
cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
|
|
cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
|
|
@@ -215,7 +228,7 @@ public class TemplateGenerator {
|
|
Map<String, Object> dataModel = new HashMap<>();
|
|
Map<String, Object> dataModel = new HashMap<>();
|
|
|
|
|
|
DChecknodeMapper checknodeMapper = UtilTools.getBean(DChecknodeMapper.class);
|
|
DChecknodeMapper checknodeMapper = UtilTools.getBean(DChecknodeMapper.class);
|
|
- List<DChecknode> monitors=checknodeMapper.selectAll();
|
|
|
|
|
|
+ List<DChecknode> monitors = checknodeMapper.selectAll();
|
|
Collections.sort(monitors, (n1, n2) -> n1.getId().compareTo(n2.getId()));
|
|
Collections.sort(monitors, (n1, n2) -> n1.getId().compareTo(n2.getId()));
|
|
dataModel.put("monnum", monitors.size());
|
|
dataModel.put("monnum", monitors.size());
|
|
//管道
|
|
//管道
|
|
@@ -225,13 +238,14 @@ public class TemplateGenerator {
|
|
StringWriter writer = new StringWriter();
|
|
StringWriter writer = new StringWriter();
|
|
template.process(dataModel, writer);
|
|
template.process(dataModel, writer);
|
|
mkDirs(aid, jid, "/fire");
|
|
mkDirs(aid, jid, "/fire");
|
|
- FileWriter fileWriter =new FileWriter(BPATH+"/"+aid+"/"+jid+"/monitor.in");
|
|
|
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/monitor.in");
|
|
fileWriter.write(writer.toString());
|
|
fileWriter.write(writer.toString());
|
|
fileWriter.close();
|
|
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 {
|
|
|
|
|
|
+
|
|
|
|
+ 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);
|
|
Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
// 设置模板所在目录
|
|
// 设置模板所在目录
|
|
cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
|
|
cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
|
|
@@ -240,67 +254,67 @@ public class TemplateGenerator {
|
|
// 定义数据模型(Map)
|
|
// 定义数据模型(Map)
|
|
Map<String, Object> dataModel = new HashMap<>();
|
|
Map<String, Object> dataModel = new HashMap<>();
|
|
//几何文件路径
|
|
//几何文件路径
|
|
- dataModel.put("geoFilePath", BPATH+"/"+aid+"/"+jid+"/Geometry");
|
|
|
|
|
|
+ dataModel.put("geoFilePath", BPATH + "/" + aid + "/" + jid + "/Geometry");
|
|
//fireinit 文件路径
|
|
//fireinit 文件路径
|
|
- dataModel.put("initFilePath", BPATH+"/"+aid+"/"+jid+"/fire"+"/"+"Fire.init");
|
|
|
|
|
|
+ dataModel.put("initFilePath", BPATH + "/" + aid + "/" + jid + "/fire" + "/" + "Fire.init");
|
|
//fireInteractionPath 阀门文件路径
|
|
//fireInteractionPath 阀门文件路径
|
|
dataModel.put("fireInteractionPath", "/home/disaster/fire/Fire.interaction");
|
|
dataModel.put("fireInteractionPath", "/home/disaster/fire/Fire.interaction");
|
|
//midPath
|
|
//midPath
|
|
- dataModel.put("monitorPath", BPATH+"/"+aid+"/"+jid+"/monitor.in");
|
|
|
|
|
|
+ dataModel.put("monitorPath", BPATH + "/" + aid + "/" + jid + "/monitor.in");
|
|
//midPath
|
|
//midPath
|
|
- dataModel.put("midPath", BPATH+"/"+aid+"/"+jid+"/fire"+"/mid");
|
|
|
|
|
|
+ dataModel.put("midPath", BPATH + "/" + aid + "/" + jid + "/fire" + "/mid");
|
|
//outPath
|
|
//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);
|
|
|
|
|
|
+ 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();
|
|
|
|
|
|
+ DSourceMapper dsm = UtilTools.getBean(DSourceMapper.class);
|
|
|
|
+ DSourceSQLBuilder dss = new DSourceSQLBuilder();
|
|
DSourceSQLBuilder.Criteria dssc = dss.createCriteria();
|
|
DSourceSQLBuilder.Criteria dssc = dss.createCriteria();
|
|
dssc.andAidEqualTo(aid);
|
|
dssc.andAidEqualTo(aid);
|
|
// dssc.andSTypeEqualTo("Fire");
|
|
// dssc.andSTypeEqualTo("Fire");
|
|
- List<DSource> dources =dsm.selectByExample(dss);
|
|
|
|
|
|
+ List<DSource> dources = dsm.selectByExample(dss);
|
|
//fireSourceNum 灾源数量
|
|
//fireSourceNum 灾源数量
|
|
dataModel.put("fireSourceNum", dources.size());
|
|
dataModel.put("fireSourceNum", dources.size());
|
|
//边界
|
|
//边界
|
|
DBoundaryMapper dBoundaryMapper = UtilTools.getBean(DBoundaryMapper.class);
|
|
DBoundaryMapper dBoundaryMapper = UtilTools.getBean(DBoundaryMapper.class);
|
|
- DBoundarySQLBuilder sb =new DBoundarySQLBuilder();
|
|
|
|
|
|
+ DBoundarySQLBuilder sb = new DBoundarySQLBuilder();
|
|
DBoundarySQLBuilder.Criteria sc = sb.createCriteria();
|
|
DBoundarySQLBuilder.Criteria sc = sb.createCriteria();
|
|
sc.andAidEqualTo(aid);
|
|
sc.andAidEqualTo(aid);
|
|
List<DBoundary> boundaries = dBoundaryMapper.selectByExample(sb);
|
|
List<DBoundary> boundaries = dBoundaryMapper.selectByExample(sb);
|
|
//边界数量
|
|
//边界数量
|
|
dataModel.put("boundarynum", boundaries.size());
|
|
dataModel.put("boundarynum", boundaries.size());
|
|
//物理量
|
|
//物理量
|
|
- String[] codes =cocodes.split(",");
|
|
|
|
- List<String> concodeList =new ArrayList<>();
|
|
|
|
- for (String concode:codes
|
|
|
|
- ) {
|
|
|
|
|
|
+ String[] codes = cocodes.split(",");
|
|
|
|
+ List<String> concodeList = new ArrayList<>();
|
|
|
|
+ for (String concode : codes
|
|
|
|
+ ) {
|
|
concodeList.add(concode);
|
|
concodeList.add(concode);
|
|
}
|
|
}
|
|
- DConMapper conMapper=UtilTools.getBean(DConMapper.class);
|
|
|
|
- DConSQLBuilder consb =new DConSQLBuilder();
|
|
|
|
|
|
+ DConMapper conMapper = UtilTools.getBean(DConMapper.class);
|
|
|
|
+ DConSQLBuilder consb = new DConSQLBuilder();
|
|
DConSQLBuilder.Criteria consc = consb.createCriteria();
|
|
DConSQLBuilder.Criteria consc = consb.createCriteria();
|
|
consc.andCodeIn(concodeList);
|
|
consc.andCodeIn(concodeList);
|
|
- List<DCon> cons = conMapper.selectByExample(consb);
|
|
|
|
- dataModel.put("conNum",cons.size());
|
|
|
|
- dataModel.put("cons",cons);
|
|
|
|
|
|
+ List<DCon> cons = conMapper.selectByExample(consb);
|
|
|
|
+ dataModel.put("conNum", cons.size());
|
|
|
|
+ dataModel.put("cons", cons);
|
|
|
|
|
|
// 将数据模型传入模板进行处理
|
|
// 将数据模型传入模板进行处理
|
|
StringWriter writer = new StringWriter();
|
|
StringWriter writer = new StringWriter();
|
|
template.process(dataModel, writer);
|
|
template.process(dataModel, writer);
|
|
mkDirs(aid, jid, "/fire");
|
|
mkDirs(aid, jid, "/fire");
|
|
|
|
|
|
- FileWriter fileWriter =new FileWriter(BPATH+"/"+aid+"/"+jid+"/"+"/fire"+"/Fire.control");
|
|
|
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/" + "/fire" + "/Fire.control");
|
|
fileWriter.write(writer.toString());
|
|
fileWriter.write(writer.toString());
|
|
fileWriter.close();
|
|
fileWriter.close();
|
|
}
|
|
}
|
|
- public static void createFireRunsh(Integer aid,Integer jid) throws IOException, TemplateException {
|
|
|
|
|
|
+
|
|
|
|
+ public static void createFireRunsh(Integer aid, Integer jid) throws IOException, TemplateException {
|
|
Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
// 设置模板所在目录
|
|
// 设置模板所在目录
|
|
cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
|
|
cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
|
|
@@ -309,17 +323,17 @@ public class TemplateGenerator {
|
|
// 定义数据模型(Map)
|
|
// 定义数据模型(Map)
|
|
Map<String, Object> dataModel = new HashMap<>();
|
|
Map<String, Object> dataModel = new HashMap<>();
|
|
//几何文件路径
|
|
//几何文件路径
|
|
- dataModel.put("firecontrolPath", BPATH+"/"+aid+"/"+jid+"/fire"+"/Fire.control");
|
|
|
|
|
|
+ dataModel.put("firecontrolPath", BPATH + "/" + aid + "/" + jid + "/fire" + "/Fire.control");
|
|
// 将数据模型传入模板进行处理
|
|
// 将数据模型传入模板进行处理
|
|
StringWriter writer = new StringWriter();
|
|
StringWriter writer = new StringWriter();
|
|
template.process(dataModel, writer);
|
|
template.process(dataModel, writer);
|
|
- FileWriter fileWriter =new FileWriter(BPATH+"/"+aid+"/"+jid+"/fire"+"/"+"runFile.sh");
|
|
|
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/fire" + "/" + "runFile.sh");
|
|
fileWriter.write(writer.toString());
|
|
fileWriter.write(writer.toString());
|
|
fileWriter.close();
|
|
fileWriter.close();
|
|
}
|
|
}
|
|
|
|
|
|
- public static void createFireInit(Integer aid,Integer jid) throws IOException, TemplateException {
|
|
|
|
- FireInitVo vo =new FireInitVo();
|
|
|
|
|
|
+ public static void createFireInit(Integer aid, Integer jid) throws IOException, TemplateException {
|
|
|
|
+ FireInitVo vo = new FireInitVo();
|
|
|
|
|
|
//TODO 求解器暂时不需要此数据
|
|
//TODO 求解器暂时不需要此数据
|
|
// DNodeValMapper dnvm= UtilTools.getBean(DNodeValMapper.class);
|
|
// DNodeValMapper dnvm= UtilTools.getBean(DNodeValMapper.class);
|
|
@@ -329,34 +343,34 @@ public class TemplateGenerator {
|
|
// List<DNodeVal> nodeVals=dnvm.selectByExample(dns);
|
|
// List<DNodeVal> nodeVals=dnvm.selectByExample(dns);
|
|
// vo.setNodeVals(nodeVals);
|
|
// vo.setNodeVals(nodeVals);
|
|
|
|
|
|
- DSourceMapper dsm =UtilTools.getBean(DSourceMapper.class);
|
|
|
|
- DSourceSQLBuilder dss= new DSourceSQLBuilder();
|
|
|
|
|
|
+ DSourceMapper dsm = UtilTools.getBean(DSourceMapper.class);
|
|
|
|
+ DSourceSQLBuilder dss = new DSourceSQLBuilder();
|
|
DSourceSQLBuilder.Criteria dssc = dss.createCriteria();
|
|
DSourceSQLBuilder.Criteria dssc = dss.createCriteria();
|
|
dssc.andAidEqualTo(aid);
|
|
dssc.andAidEqualTo(aid);
|
|
// dssc.andSTypeEqualTo("Fire");
|
|
// dssc.andSTypeEqualTo("Fire");
|
|
- List<DSource> dources =dsm.selectByExample(dss);
|
|
|
|
|
|
+ List<DSource> dources = dsm.selectByExample(dss);
|
|
|
|
|
|
|
|
|
|
- DSourceValMapper dsvm =UtilTools.getBean(DSourceValMapper.class);
|
|
|
|
- DSourceValSQLBuilder dsvs =new DSourceValSQLBuilder();
|
|
|
|
|
|
+ DSourceValMapper dsvm = UtilTools.getBean(DSourceValMapper.class);
|
|
|
|
+ DSourceValSQLBuilder dsvs = new DSourceValSQLBuilder();
|
|
|
|
|
|
- List<DSourceVo> dourceVos = new ArrayList<>();
|
|
|
|
- for (DSource ds:dources) {
|
|
|
|
|
|
+ List<DSourceVo> dourceVos = new ArrayList<>();
|
|
|
|
+ for (DSource ds : dources) {
|
|
DSourceValSQLBuilder.Criteria dsvc = dsvs.createCriteria();
|
|
DSourceValSQLBuilder.Criteria dsvc = dsvs.createCriteria();
|
|
dsvc.andSidEqualTo(ds.getId());
|
|
dsvc.andSidEqualTo(ds.getId());
|
|
List<DSourceVal> dSourceVals = dsvm.selectByExample(dsvs);
|
|
List<DSourceVal> dSourceVals = dsvm.selectByExample(dsvs);
|
|
|
|
|
|
- DSourceVo dsourcevo =new DSourceVo();
|
|
|
|
|
|
+ DSourceVo dsourcevo = new DSourceVo();
|
|
dsourcevo.setDsource(ds);
|
|
dsourcevo.setDsource(ds);
|
|
dsourcevo.setDsourceVals(dSourceVals);
|
|
dsourcevo.setDsourceVals(dSourceVals);
|
|
dourceVos.add(dsourcevo);
|
|
dourceVos.add(dsourcevo);
|
|
dsvs.clear();
|
|
dsvs.clear();
|
|
}
|
|
}
|
|
- vo.setDourceVos(dourceVos);
|
|
|
|
|
|
+ vo.setDourceVos(dourceVos);
|
|
|
|
|
|
//边界
|
|
//边界
|
|
DBoundaryMapper dBoundaryMapper = UtilTools.getBean(DBoundaryMapper.class);
|
|
DBoundaryMapper dBoundaryMapper = UtilTools.getBean(DBoundaryMapper.class);
|
|
- DBoundarySQLBuilder sb =new DBoundarySQLBuilder();
|
|
|
|
|
|
+ DBoundarySQLBuilder sb = new DBoundarySQLBuilder();
|
|
DBoundarySQLBuilder.Criteria sc = sb.createCriteria();
|
|
DBoundarySQLBuilder.Criteria sc = sb.createCriteria();
|
|
sc.andAidEqualTo(aid);
|
|
sc.andAidEqualTo(aid);
|
|
List<DBoundary> boundaries = dBoundaryMapper.selectByExample(sb);
|
|
List<DBoundary> boundaries = dBoundaryMapper.selectByExample(sb);
|
|
@@ -380,7 +394,7 @@ public class TemplateGenerator {
|
|
// 输出结果到控制台或保存为文件
|
|
// 输出结果到控制台或保存为文件
|
|
// System.out.println(writer.toString());
|
|
// System.out.println(writer.toString());
|
|
|
|
|
|
- FileWriter fileWriter =new FileWriter(BPATH+"/"+aid+"/"+jid+"/fire"+"/"+"Fire.init");
|
|
|
|
|
|
+ FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/fire" + "/" + "Fire.init");
|
|
fileWriter.write(writer.toString());
|
|
fileWriter.write(writer.toString());
|
|
fileWriter.close();
|
|
fileWriter.close();
|
|
}
|
|
}
|
|
@@ -393,4 +407,139 @@ public class TemplateGenerator {
|
|
System.out.println(myFloat); // 输出: 123.46
|
|
System.out.println(myFloat); // 输出: 123.46
|
|
System.out.println(formattedString); // 输出: 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(TemplateGenerator.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(TemplateGenerator.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);
|
|
|
|
+ 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, String bfname) throws IOException, TemplateException {
|
|
|
|
+ Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
|
|
+ // 设置模板所在目录
|
|
|
|
+ cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
|
|
|
|
+ // 获取模板对象
|
|
|
|
+ Template template = cfg.getTemplate("mashGasRunsh.ftl");
|
|
|
|
+ // 定义数据模型(Map)
|
|
|
|
+ Map<String, Object> dataModel = new HashMap<>();
|
|
|
|
+ dataModel.put("bfname", bfname);
|
|
|
|
+ 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();
|
|
|
|
+ }
|
|
}
|
|
}
|