|
@@ -186,12 +186,12 @@ public class TemplateGenerator2 {
|
|
|
/**
|
|
|
* 生成几何文件
|
|
|
*/
|
|
|
- public static void createGeometry(Integer aid, Integer jid) throws IOException, TemplateException {
|
|
|
+ public static void createGeometry(Integer aid, Integer jid) throws IOException, TemplateException, BusinessException {
|
|
|
Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
|
|
|
// 设置模板所在目录
|
|
|
cfg.setClassForTemplateLoading(TemplateGenerator2.class, "/templates");
|
|
|
// 获取模板对象
|
|
|
- Template template = cfg.getTemplate("geometry.ftl");
|
|
|
+ Template template = cfg.getTemplate("geometry2.ftl");
|
|
|
// 定义数据模型(Map)
|
|
|
Map<String, Object> dataModel = new HashMap<>();
|
|
|
|
|
@@ -208,10 +208,19 @@ public class TemplateGenerator2 {
|
|
|
DPipeMapper pipeMapper = UtilTools.getBean(DPipeMapper.class);
|
|
|
List<DPipe> pipes = pipeMapper.selectAll();
|
|
|
Collections.sort(pipes, (n1, n2) -> n1.getId().compareTo(n2.getId()));
|
|
|
+
|
|
|
+ List<DPipeVo> vos =new ArrayList<>();
|
|
|
+ for (DPipe pipe:pipes) {
|
|
|
+ DPipeVo vo = new DPipeVo();
|
|
|
+ vo.setdPipe(pipe);
|
|
|
+ vo.setEnName(getNnameById(pipe.getEnid()));
|
|
|
+ vo.setSnName(getNnameById(pipe.getSnid()));
|
|
|
+ vos.add(vo);
|
|
|
+ }
|
|
|
//管道数量
|
|
|
dataModel.put("pipenum", pipes.size());
|
|
|
//管道
|
|
|
- dataModel.put("pipes", pipes);
|
|
|
+ dataModel.put("pipes", vos);
|
|
|
|
|
|
// 将数据模型传入模板进行处理
|
|
|
StringWriter writer = new StringWriter();
|
|
@@ -222,6 +231,16 @@ public class TemplateGenerator2 {
|
|
|
fileWriter.close();
|
|
|
}
|
|
|
|
|
|
+ public static String getNnameById(Integer nid) throws BusinessException {
|
|
|
+ DNodeMapper nodeMapper = UtilTools.getBean(DNodeMapper.class);
|
|
|
+ DNode node = nodeMapper.selectByPrimaryKey(nid);
|
|
|
+ if(node ==null){
|
|
|
+ throw new BusinessException("EB3000001");
|
|
|
+ }
|
|
|
+ return node.getName();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private static void mkDirs(Integer aid, Integer jid, String s) {
|
|
|
XIFileUtils.mkdir(BPATH);
|
|
|
XIFileUtils.mkdir(BPATH + "/" + aid);
|