|  | @@ -5,19 +5,24 @@ import com.miniframe.model.system.*;
 | 
	
		
			
				|  |  |  import com.miniframe.model.system.dao.DNodeValMapper;
 | 
	
		
			
				|  |  |  import com.miniframe.model.system.dao.DSourceMapper;
 | 
	
		
			
				|  |  |  import com.miniframe.model.system.dao.DSourceValMapper;
 | 
	
		
			
				|  |  | +import com.miniframe.tools.XIFileUtils;
 | 
	
		
			
				|  |  | +import com.miniframe.tools.XIIniFileUtils;
 | 
	
		
			
				|  |  |  import freemarker.template.Configuration;
 | 
	
		
			
				|  |  |  import freemarker.template.Template;
 | 
	
		
			
				|  |  |  import freemarker.template.TemplateException;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import java.io.FileWriter;
 | 
	
		
			
				|  |  |  import java.io.IOException;
 | 
	
		
			
				|  |  |  import java.io.StringWriter;
 | 
	
		
			
				|  |  | +import java.util.ArrayList;
 | 
	
		
			
				|  |  |  import java.util.HashMap;
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  |  import java.util.Map;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  public class TemplateGenerator {
 | 
	
		
			
				|  |  | +    public static final String BPATH="/cephfs/disaster";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    public static void createFireControl() throws IOException, TemplateException {
 | 
	
		
			
				|  |  | +    public static void createFireControl(Integer aid) throws IOException, TemplateException {
 | 
	
		
			
				|  |  |          Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
 | 
	
		
			
				|  |  |          // 设置模板所在目录
 | 
	
		
			
				|  |  |          cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
 | 
	
	
		
			
				|  | @@ -28,22 +33,35 @@ public class TemplateGenerator {
 | 
	
		
			
				|  |  |          //几何文件路径
 | 
	
		
			
				|  |  |          dataModel.put("geoFilePath", "/home/disaster/fire/Geometry");
 | 
	
		
			
				|  |  |          //fireinit 文件路径
 | 
	
		
			
				|  |  | -        dataModel.put("initFilePath", "/home/disaster/fire/Fire1.init");
 | 
	
		
			
				|  |  | +        dataModel.put("initFilePath", BPATH+"/"+aid+"/"+"Fire.init");
 | 
	
		
			
				|  |  |          //fireInteractionPath 阀门文件路径
 | 
	
		
			
				|  |  |          dataModel.put("fireInteractionPath", "/home/disaster/fire/Fire.interaction");
 | 
	
		
			
				|  |  |          //midPath
 | 
	
		
			
				|  |  | -        dataModel.put("midPath", "/home/disaster/fire/mid");
 | 
	
		
			
				|  |  | +        dataModel.put("midPath", BPATH+"/"+aid+"/mid");
 | 
	
		
			
				|  |  |          //outPath
 | 
	
		
			
				|  |  | -        dataModel.put("outPath", "/home/disaster/fire/out");
 | 
	
		
			
				|  |  | +        dataModel.put("outPath", BPATH+"/"+aid+"/out");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        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", 2);
 | 
	
		
			
				|  |  | +        dataModel.put("fireSourceNum", dources.size());
 | 
	
		
			
				|  |  |          // 将数据模型传入模板进行处理
 | 
	
		
			
				|  |  |          StringWriter writer = new StringWriter();
 | 
	
		
			
				|  |  |          template.process(dataModel, writer);
 | 
	
		
			
				|  |  | -        // 输出结果到控制台或保存为文件
 | 
	
		
			
				|  |  | -        System.out.println(writer.toString());
 | 
	
		
			
				|  |  | +        XIFileUtils.mkdir(BPATH);
 | 
	
		
			
				|  |  | +        XIFileUtils.mkdir(BPATH+"/"+aid);
 | 
	
		
			
				|  |  | +        XIFileUtils.mkdir(BPATH+"/"+aid+"/mid");
 | 
	
		
			
				|  |  | +        XIFileUtils.mkdir(BPATH+"/"+aid+"/out");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        FileWriter fileWriter =new FileWriter(BPATH+"/"+aid+"/"+"Fire.control");
 | 
	
		
			
				|  |  | +        fileWriter.write(writer.toString());
 | 
	
		
			
				|  |  | +        fileWriter.close();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    public static void createFireRunsh() throws IOException, TemplateException {
 | 
	
		
			
				|  |  | +    public static void createFireRunsh(Integer aid) throws IOException, TemplateException {
 | 
	
		
			
				|  |  |          Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
 | 
	
		
			
				|  |  |          // 设置模板所在目录
 | 
	
		
			
				|  |  |          cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
 | 
	
	
		
			
				|  | @@ -52,12 +70,13 @@ public class TemplateGenerator {
 | 
	
		
			
				|  |  |          // 定义数据模型(Map)
 | 
	
		
			
				|  |  |          Map<String, Object> dataModel = new HashMap<>();
 | 
	
		
			
				|  |  |          //几何文件路径
 | 
	
		
			
				|  |  | -        dataModel.put("firecontrolPath", "/home/disaster/fire/Fire.control");
 | 
	
		
			
				|  |  | +        dataModel.put("firecontrolPath", BPATH+"/"+aid+"/Fire.control");
 | 
	
		
			
				|  |  |          // 将数据模型传入模板进行处理
 | 
	
		
			
				|  |  |          StringWriter writer = new StringWriter();
 | 
	
		
			
				|  |  |          template.process(dataModel, writer);
 | 
	
		
			
				|  |  | -        // 输出结果到控制台或保存为文件
 | 
	
		
			
				|  |  | -        System.out.println(writer.toString());
 | 
	
		
			
				|  |  | +        FileWriter fileWriter =new FileWriter(BPATH+"/"+aid+"/"+"runFile.sh");
 | 
	
		
			
				|  |  | +        fileWriter.write(writer.toString());
 | 
	
		
			
				|  |  | +        fileWriter.close();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public static void createFireInit(Integer aid) throws IOException, TemplateException {
 | 
	
	
		
			
				|  | @@ -76,20 +95,24 @@ public class TemplateGenerator {
 | 
	
		
			
				|  |  |          dssc.andAidEqualTo(aid);
 | 
	
		
			
				|  |  |          dssc.andSTypeEqualTo("Fire");
 | 
	
		
			
				|  |  |          List<DSource>  dources =dsm.selectByExample(dss);
 | 
	
		
			
				|  |  | -        vo.setDources(dources);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          DSourceValMapper dsvm =UtilTools.getBean(DSourceValMapper.class);
 | 
	
		
			
				|  |  |          DSourceValSQLBuilder dsvs =new DSourceValSQLBuilder();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        Map<Integer, List<DSourceVal>> dsourceValMap =new HashMap<>();
 | 
	
		
			
				|  |  | +        List<DSourceVo>  dourceVos = new ArrayList<>();
 | 
	
		
			
				|  |  |          for (DSource ds:dources) {
 | 
	
		
			
				|  |  |              DSourceValSQLBuilder.Criteria dsvc = dsvs.createCriteria();
 | 
	
		
			
				|  |  |              dsvc.andSidEqualTo(ds.getId());
 | 
	
		
			
				|  |  |              List<DSourceVal> dSourceVals = dsvm.selectByExample(dsvs);
 | 
	
		
			
				|  |  | -            dsourceValMap.put(ds.getId(),dSourceVals);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            DSourceVo dsourcevo =new DSourceVo();
 | 
	
		
			
				|  |  | +            dsourcevo.setDsource(ds);
 | 
	
		
			
				|  |  | +            dsourcevo.setDsourceVals(dSourceVals);
 | 
	
		
			
				|  |  | +            dourceVos.add(dsourcevo);
 | 
	
		
			
				|  |  |              dsvs.clear();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        vo.setDsourceValMap(dsourceValMap);
 | 
	
		
			
				|  |  | +       vo.setDourceVos(dourceVos);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
 | 
	
	
		
			
				|  | @@ -106,10 +129,18 @@ public class TemplateGenerator {
 | 
	
		
			
				|  |  |          template.process(dataModel, writer);
 | 
	
		
			
				|  |  |          // 输出结果到控制台或保存为文件
 | 
	
		
			
				|  |  |          System.out.println(writer.toString());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        FileWriter fileWriter =new FileWriter(BPATH+"/"+aid+"/"+"Fire.init");
 | 
	
		
			
				|  |  | +        fileWriter.write(writer.toString());
 | 
	
		
			
				|  |  | +        fileWriter.close();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public static void main(String[] args) throws Exception {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -//        TemplateGenerator.createFireRunsh();
 | 
	
		
			
				|  |  | +//        TemplateGenerator.createFireControl(5);
 | 
	
		
			
				|  |  | +        XIFileUtils.mkdir(BPATH);
 | 
	
		
			
				|  |  | +        XIFileUtils.mkdir(BPATH+"/"+5);
 | 
	
		
			
				|  |  | +        XIFileUtils.mkdir(BPATH+"/"+5+"/mid");
 | 
	
		
			
				|  |  | +        XIFileUtils.mkdir(BPATH+"/"+5+"/out");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |