|  | @@ -22,6 +22,113 @@ import java.util.Map;
 | 
	
		
			
				|  |  |  public class TemplateGenerator {
 | 
	
		
			
				|  |  |      public static final String BPATH="/cephfs/disaster";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    public static void createWaterControl(Integer aid) throws IOException, TemplateException {
 | 
	
		
			
				|  |  | +        Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
 | 
	
		
			
				|  |  | +        // 设置模板所在目录
 | 
	
		
			
				|  |  | +        cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
 | 
	
		
			
				|  |  | +        // 获取模板对象
 | 
	
		
			
				|  |  | +        Template template = cfg.getTemplate("waterControl.ftl");
 | 
	
		
			
				|  |  | +        // 定义数据模型(Map)
 | 
	
		
			
				|  |  | +        Map<String, Object> dataModel = new HashMap<>();
 | 
	
		
			
				|  |  | +        //几何文件路径
 | 
	
		
			
				|  |  | +        dataModel.put("geoFilePath", "/home/disaster/Water/Geometry");
 | 
	
		
			
				|  |  | +        //initFile 文件路径
 | 
	
		
			
				|  |  | +        dataModel.put("initFilePath", BPATH+"/"+aid+"/water"+"/"+"water.init");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //midPath
 | 
	
		
			
				|  |  | +        dataModel.put("midPath", BPATH+"/"+aid+"/water"+"/mid");
 | 
	
		
			
				|  |  | +        //outPath
 | 
	
		
			
				|  |  | +        dataModel.put("outPath", BPATH+"/"+aid+"/water"+"/out");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 将数据模型传入模板进行处理
 | 
	
		
			
				|  |  | +        StringWriter writer = new StringWriter();
 | 
	
		
			
				|  |  | +        template.process(dataModel, writer);
 | 
	
		
			
				|  |  | +        XIFileUtils.mkdir(BPATH);
 | 
	
		
			
				|  |  | +        XIFileUtils.mkdir(BPATH+"/"+aid);
 | 
	
		
			
				|  |  | +        XIFileUtils.mkdir(BPATH+"/"+aid+"/water");
 | 
	
		
			
				|  |  | +        XIFileUtils.mkdir(BPATH+"/"+aid+"/water"+"/mid");
 | 
	
		
			
				|  |  | +        XIFileUtils.mkdir(BPATH+"/"+aid+"/water"+"/out");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        FileWriter fileWriter =new FileWriter(BPATH+"/"+aid+"/"+"/water"+"/water.control");
 | 
	
		
			
				|  |  | +        fileWriter.write(writer.toString());
 | 
	
		
			
				|  |  | +        fileWriter.close();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public static void createWaterRunsh(Integer aid) throws IOException, TemplateException {
 | 
	
		
			
				|  |  | +        Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
 | 
	
		
			
				|  |  | +        // 设置模板所在目录
 | 
	
		
			
				|  |  | +        cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
 | 
	
		
			
				|  |  | +        // 获取模板对象
 | 
	
		
			
				|  |  | +        Template template = cfg.getTemplate("waterRunsh.ftl");
 | 
	
		
			
				|  |  | +        // 定义数据模型(Map)
 | 
	
		
			
				|  |  | +        Map<String, Object> dataModel = new HashMap<>();
 | 
	
		
			
				|  |  | +        //几何文件路径
 | 
	
		
			
				|  |  | +        dataModel.put("waterControlPath", BPATH+"/"+aid+"/water"+"/water.control");
 | 
	
		
			
				|  |  | +        // 将数据模型传入模板进行处理
 | 
	
		
			
				|  |  | +        StringWriter writer = new StringWriter();
 | 
	
		
			
				|  |  | +        template.process(dataModel, writer);
 | 
	
		
			
				|  |  | +        FileWriter fileWriter =new FileWriter(BPATH+"/"+aid+"/water"+"/"+"runWater.sh");
 | 
	
		
			
				|  |  | +        fileWriter.write(writer.toString());
 | 
	
		
			
				|  |  | +        fileWriter.close();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    public static void createWaterInit(Integer aid) throws IOException, TemplateException {
 | 
	
		
			
				|  |  | +        FireInitVo vo =new FireInitVo();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        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);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
 | 
	
		
			
				|  |  | +        // 设置模板所在目录
 | 
	
		
			
				|  |  | +        cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
 | 
	
		
			
				|  |  | +        // 获取模板对象
 | 
	
		
			
				|  |  | +        Template template = cfg.getTemplate("waterInit.ftl");
 | 
	
		
			
				|  |  | +        // 定义数据模型(Map)
 | 
	
		
			
				|  |  | +        Map<String, Object> dataModel = new HashMap<>();
 | 
	
		
			
				|  |  | +        //几何文件路径
 | 
	
		
			
				|  |  | +        dataModel.put("vo", vo);
 | 
	
		
			
				|  |  | +        // 将数据模型传入模板进行处理
 | 
	
		
			
				|  |  | +        StringWriter writer = new StringWriter();
 | 
	
		
			
				|  |  | +        template.process(dataModel, writer);
 | 
	
		
			
				|  |  | +        // 输出结果到控制台或保存为文件
 | 
	
		
			
				|  |  | +        System.out.println(writer.toString());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        FileWriter fileWriter =new FileWriter(BPATH+"/"+aid+"/water"+"/"+"water.init");
 | 
	
		
			
				|  |  | +        fileWriter.write(writer.toString());
 | 
	
		
			
				|  |  | +        fileWriter.close();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      public static void createFireControl(Integer aid) throws IOException, TemplateException {
 | 
	
		
			
				|  |  |          Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
 | 
	
		
			
				|  |  |          // 设置模板所在目录
 | 
	
	
		
			
				|  | @@ -137,11 +244,6 @@ public class TemplateGenerator {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public static void main(String[] args) throws Exception {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -//        TemplateGenerator.createFireControl(5);
 | 
	
		
			
				|  |  | -        XIFileUtils.mkdir(BPATH);
 | 
	
		
			
				|  |  | -        XIFileUtils.mkdir(BPATH+"/"+5);
 | 
	
		
			
				|  |  | -        XIFileUtils.mkdir(BPATH+"/"+5+"/mid");
 | 
	
		
			
				|  |  | -        XIFileUtils.mkdir(BPATH+"/"+5+"/out");
 | 
	
		
			
				|  |  | +        TemplateGenerator.createWaterRunsh(5);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |