Commit d11ca8a5 authored by yanzg's avatar yanzg

Excel导出功能

parent 729ff3b7
...@@ -432,6 +432,31 @@ public abstract class BaseDaoSql { ...@@ -432,6 +432,31 @@ public abstract class BaseDaoSql {
return sql; return sql;
} }
/**
* 处理代码片段替换
*
* @param sql 代码片段
* @param codeMap 替换内容
* @return Sql语句值
*/
protected String handleCodeRepalce(String sql, Map<String, List<String>> codeMap) {
// 正则表达式匹配代码片段,并根据代码片段获取数组进行增加
String regex = "\\{.*?\\}";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(sql);
// 寻找到的代码片段 不包含分括号
while (m.find()) {
String name = m.group();
List<String> codes = codeMap.containsKey(name) ? codeMap.get(name) : new ArrayList<>();
String code = String.format(" %s ", String.join(" ", codes));
sql = sql.replace(name, code);
}
sql = sql.replaceAll("\\s+", "\\s");
return sql;
}
/** /**
* 代码片段处理 * 代码片段处理
* *
...@@ -476,22 +501,7 @@ public abstract class BaseDaoSql { ...@@ -476,22 +501,7 @@ public abstract class BaseDaoSql {
} }
} }
// 正则表达式匹配代码片段,并根据代码片段获取数组进行增加 sql = handleCodeRepalce(sql, codeMap);
{
String regex = "\\{.*?\\}";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(sql);
// 寻找到的代码片段 不包含分括号
while (m.find()) {
String name = m.group();
List<String> codes = codeMap.containsKey(name) ? codeMap.get(name) : new ArrayList<>();
String code = String.format(" %s ", String.join(" ", codes));
sql = sql.replace(name, code);
}
}
sql = sql.replaceAll("\\s+", "\\s");
return sql; return sql;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment