|
|
@@ -66,7 +66,7 @@ public class TemplateParser {
|
|
|
* @return 替换后的模版内容
|
|
|
* @throws SQLException
|
|
|
*/
|
|
|
- public String replaceParameters(@NotEmpty("content") String content, List<GlobalParameter> globalParameters,
|
|
|
+ private String replaceParameters(@NotEmpty("content") String content, List<GlobalParameter> globalParameters,
|
|
|
@NotEmpty("needSingleQuote") Boolean needSingleQuote, @NotEmpty("jdbc") NewbieJdbcSupport jdbc) throws SQLException {
|
|
|
if (CollectionUtils.isEmpty(globalParameters)) {
|
|
|
return content;
|
|
|
@@ -122,6 +122,8 @@ public class TemplateParser {
|
|
|
* 模版内容
|
|
|
* @param title
|
|
|
* 标题
|
|
|
+ * @param globalParameters
|
|
|
+ * 公共参数
|
|
|
* @param jdbc
|
|
|
* NewbieJdbcSupport 对象
|
|
|
* @return 解析后的 json 数据
|
|
|
@@ -131,13 +133,17 @@ public class TemplateParser {
|
|
|
* @throws SQLException
|
|
|
* @throws IllegalStateException
|
|
|
*/
|
|
|
- public String parseXml(@NotEmpty("content") String content, String title, @NotEmpty("jdbc") NewbieJdbcSupport jdbc)
|
|
|
+ public String parseXml(@NotEmpty("content") String content, String title,List<GlobalParameter> globalParameters, @NotEmpty("jdbc") NewbieJdbcSupport jdbc)
|
|
|
throws DocumentException, TransformerException, IOException, IllegalStateException, SQLException {
|
|
|
content = processSql(content);
|
|
|
- content = processForm(content, jdbc);
|
|
|
- content = processGrid(content, jdbc);
|
|
|
- content = processBarAndLine(content, jdbc);
|
|
|
- content = processPie(content, jdbc);
|
|
|
+ // 替换标题中的公共参数
|
|
|
+ if (!com.uas.kanban.util.StringUtils.isEmpty(title)) {
|
|
|
+ title = replaceParameters(title, globalParameters, false,jdbc);
|
|
|
+ }
|
|
|
+ content = processForm(content, jdbc, globalParameters);
|
|
|
+ content = processGrid(content, jdbc, globalParameters);
|
|
|
+ content = processBarAndLine(content, jdbc, globalParameters);
|
|
|
+ content = processPie(content, jdbc, globalParameters);
|
|
|
content = finalProcess(content, title);
|
|
|
return TranslateHelper.xmlToJson(content);
|
|
|
}
|
|
|
@@ -171,13 +177,15 @@ public class TemplateParser {
|
|
|
* 模版内容
|
|
|
* @param jdbc
|
|
|
* NewbieJdbcSupport 对象
|
|
|
+ * @param globalParameters
|
|
|
+ * 公共参数
|
|
|
* @return 解析后的模版内容
|
|
|
* @throws DocumentException
|
|
|
* @throws SQLException
|
|
|
* @throws IllegalStateException
|
|
|
*/
|
|
|
@SuppressWarnings("unchecked")
|
|
|
- private String processForm(@NotEmpty("content") String content, @NotEmpty("jdbc") NewbieJdbcSupport jdbc)
|
|
|
+ private String processForm(@NotEmpty("content") String content, @NotEmpty("jdbc") NewbieJdbcSupport jdbc, List<GlobalParameter> globalParameters)
|
|
|
throws DocumentException, IllegalStateException, SQLException {
|
|
|
Document document = getDocument(content);
|
|
|
// 获取 form 组件
|
|
|
@@ -185,6 +193,7 @@ public class TemplateParser {
|
|
|
for (Element element : elements) {
|
|
|
// 执行 sql ,获取数据
|
|
|
String sql = element.attribute("sql").getText();
|
|
|
+ sql = replaceParameters(sql, globalParameters, true,jdbc);
|
|
|
// 获取 field 节点
|
|
|
List<Element> fieldElements = element.elements("field");
|
|
|
if (CollectionUtils.isEmpty(fieldElements)) {
|
|
|
@@ -212,13 +221,15 @@ public class TemplateParser {
|
|
|
* 模版内容
|
|
|
* @param jdbc
|
|
|
* NewbieJdbcSupport 对象
|
|
|
+ * @param globalParameters
|
|
|
+ * 公共参数
|
|
|
* @return 解析后的模版内容
|
|
|
* @throws DocumentException
|
|
|
* @throws SQLException
|
|
|
* @throws IllegalStateException
|
|
|
*/
|
|
|
@SuppressWarnings("unchecked")
|
|
|
- private String processGrid(@NotEmpty("content") String content, @NotEmpty("jdbc") NewbieJdbcSupport jdbc)
|
|
|
+ private String processGrid(@NotEmpty("content") String content, @NotEmpty("jdbc") NewbieJdbcSupport jdbc, List<GlobalParameter> globalParameters)
|
|
|
throws DocumentException, IllegalStateException, SQLException {
|
|
|
Document document = getDocument(content);
|
|
|
// 获取 form 组件
|
|
|
@@ -226,6 +237,7 @@ public class TemplateParser {
|
|
|
for (Element element : elements) {
|
|
|
// 执行 sql ,获取数据
|
|
|
String sql = element.attribute("sql").getText();
|
|
|
+ sql = replaceParameters(sql, globalParameters, true,jdbc);
|
|
|
// 获取 field 节点
|
|
|
List<Element> fieldElements = element.elements("field");
|
|
|
if (CollectionUtils.isEmpty(fieldElements)) {
|
|
|
@@ -267,13 +279,15 @@ public class TemplateParser {
|
|
|
* 模版内容
|
|
|
* @param jdbc
|
|
|
* NewbieJdbcSupport 对象
|
|
|
+ * @param globalParameters
|
|
|
+ * 公共参数
|
|
|
* @return 解析后的模版内容
|
|
|
* @throws DocumentException
|
|
|
* @throws SQLException
|
|
|
* @throws IllegalStateException
|
|
|
*/
|
|
|
@SuppressWarnings("unchecked")
|
|
|
- private String processBarAndLine(@NotEmpty("content") String content, @NotEmpty("jdbc") NewbieJdbcSupport jdbc)
|
|
|
+ private String processBarAndLine(@NotEmpty("content") String content, @NotEmpty("jdbc") NewbieJdbcSupport jdbc, List<GlobalParameter> globalParameters)
|
|
|
throws DocumentException, IllegalStateException, SQLException {
|
|
|
Document document = getDocument(content);
|
|
|
// 获取 bar 和 line 组件
|
|
|
@@ -281,6 +295,7 @@ public class TemplateParser {
|
|
|
for (Element element : elements) {
|
|
|
// 执行 sql ,获取数据
|
|
|
String sql = element.attribute("sql").getText();
|
|
|
+ sql = replaceParameters(sql, globalParameters, true,jdbc);
|
|
|
checkCount(jdbc.getDataSource().getConnection(), sql);
|
|
|
Map<String, List<Object>> map = convert(jdbc.listMap(sql));
|
|
|
if (CollectionUtils.isEmpty(map)) {
|
|
|
@@ -328,13 +343,15 @@ public class TemplateParser {
|
|
|
* 模版内容
|
|
|
* @param jdbc
|
|
|
* NewbieJdbcSupport 对象
|
|
|
+ * @param globalParameters
|
|
|
+ * 公共参数
|
|
|
* @return 解析后的模版内容
|
|
|
* @throws DocumentException
|
|
|
* @throws SQLException
|
|
|
* @throws IllegalStateException
|
|
|
*/
|
|
|
@SuppressWarnings("unchecked")
|
|
|
- private String processPie(@NotEmpty("content") String content, @NotEmpty("jdbc") NewbieJdbcSupport jdbc)
|
|
|
+ private String processPie(@NotEmpty("content") String content, @NotEmpty("jdbc") NewbieJdbcSupport jdbc, List<GlobalParameter> globalParameters)
|
|
|
throws DocumentException, IllegalStateException, SQLException {
|
|
|
Document document = getDocument(content);
|
|
|
// 获取 bar 和 line 组件
|
|
|
@@ -342,6 +359,7 @@ public class TemplateParser {
|
|
|
for (Element element : elements) {
|
|
|
// 执行 sql ,获取数据
|
|
|
String sql = element.attribute("sql").getText();
|
|
|
+ sql = replaceParameters(sql, globalParameters, true,jdbc);
|
|
|
checkCount(jdbc.getDataSource().getConnection(), sql);
|
|
|
List<Map<String, Object>> listMap = jdbc.listMap(sql);
|
|
|
if (CollectionUtils.isEmpty(listMap)) {
|