|
|
|
@ -8,6 +8,8 @@ import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
import com.jfinal.plugin.druid.DruidPlugin;
|
|
|
|
|
import org.jsoup.Jsoup;
|
|
|
|
|
import org.jsoup.nodes.Document;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.*;
|
|
|
|
@ -16,6 +18,28 @@ import java.util.*;
|
|
|
|
|
public class XT_GenerateMenu {
|
|
|
|
|
//用途:根据Excel为湘潭项目生成菜单
|
|
|
|
|
//办法:用Navicat Prenium的导入功能,将Excel导入到Mysql中,然后针对表进行读取
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
* delete CRLF; delete empty line ;delete blank lines
|
|
|
|
|
*
|
|
|
|
|
* @param input
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private static String deleteCRLFOnce(String input) {
|
|
|
|
|
return input.replaceAll("((\r\n)|\n)[\\s\t ]*(\\1)+", "$1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* delete CRLF; delete empty line ;delete blank lines
|
|
|
|
|
*
|
|
|
|
|
* @param input
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static String deleteCRLF(String input) {
|
|
|
|
|
input = deleteCRLFOnce(input);
|
|
|
|
|
return deleteCRLFOnce(input);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws IOException {
|
|
|
|
|
//1、配置数据库
|
|
|
|
|
PropKit.use("application.properties");
|
|
|
|
@ -56,12 +80,21 @@ public class XT_GenerateMenu {
|
|
|
|
|
}
|
|
|
|
|
//一级名称
|
|
|
|
|
rt1 = t1.replace("{{level_1_name}}", level_1_name).replace("{{level_2_content}}", rt2);
|
|
|
|
|
result = result + "\n" + rt1;
|
|
|
|
|
if (result.length() > 0) result = result + "\n" + rt1;
|
|
|
|
|
else result = rt1;
|
|
|
|
|
}
|
|
|
|
|
//删除空行
|
|
|
|
|
result = deleteCRLF(result);
|
|
|
|
|
//格式化html
|
|
|
|
|
try {
|
|
|
|
|
Document doc = Jsoup.parseBodyFragment(result);
|
|
|
|
|
result = doc.body().html();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
//保存
|
|
|
|
|
FileWriter writer = new FileWriter("c:\\菜单.html");
|
|
|
|
|
writer.write(result);
|
|
|
|
|
|
|
|
|
|
System.out.println("恭喜,菜单成功生成!");
|
|
|
|
|
}
|
|
|
|
|
}
|