|
|
@@ -1,25 +1,12 @@
|
|
|
package com.uas.kanban.support;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStream;
|
|
|
-import java.io.StringReader;
|
|
|
-import java.sql.Connection;
|
|
|
-import java.sql.PreparedStatement;
|
|
|
-import java.sql.ResultSet;
|
|
|
-import java.sql.SQLException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Map.Entry;
|
|
|
-import java.util.Set;
|
|
|
-import java.util.regex.Matcher;
|
|
|
-import java.util.regex.Pattern;
|
|
|
-
|
|
|
-import javax.xml.transform.TransformerException;
|
|
|
-
|
|
|
+import com.uas.kanban.annotation.NotEmpty;
|
|
|
+import com.uas.kanban.model.GlobalParameter;
|
|
|
import com.uas.kanban.model.Type;
|
|
|
+import com.uas.kanban.util.ArrayUtils;
|
|
|
+import com.uas.kanban.util.CollectionUtils;
|
|
|
+import com.uas.kanban.util.StringUtils;
|
|
|
+import me.chyxion.jdbc.NewbieJdbcSupport;
|
|
|
import org.dom4j.Attribute;
|
|
|
import org.dom4j.Document;
|
|
|
import org.dom4j.DocumentException;
|
|
|
@@ -30,13 +17,18 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import com.alibaba.druid.util.StringUtils;
|
|
|
-import com.uas.kanban.annotation.NotEmpty;
|
|
|
-import com.uas.kanban.model.GlobalParameter;
|
|
|
-import com.uas.kanban.util.ArrayUtils;
|
|
|
-import com.uas.kanban.util.CollectionUtils;
|
|
|
-
|
|
|
-import me.chyxion.jdbc.NewbieJdbcSupport;
|
|
|
+import javax.xml.transform.TransformerException;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.io.StringReader;
|
|
|
+import java.sql.Connection;
|
|
|
+import java.sql.PreparedStatement;
|
|
|
+import java.sql.ResultSet;
|
|
|
+import java.sql.SQLException;
|
|
|
+import java.util.*;
|
|
|
+import java.util.Map.Entry;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* @author sunyj
|
|
|
@@ -194,6 +186,9 @@ public class TemplateParser {
|
|
|
for (Element element : elements) {
|
|
|
// 执行 sql ,获取数据
|
|
|
String sql = element.attribute("sql").getText();
|
|
|
+ if(StringUtils.isEmpty(sql)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
sql = replaceParameters(sql, globalParameters, true,jdbc);
|
|
|
// 获取 field 节点
|
|
|
List<Element> fieldElements = element.elements("field");
|
|
|
@@ -238,6 +233,9 @@ public class TemplateParser {
|
|
|
for (Element element : elements) {
|
|
|
// 执行 sql ,获取数据
|
|
|
String sql = element.attribute("sql").getText();
|
|
|
+ if(StringUtils.isEmpty(sql)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
sql = replaceParameters(sql, globalParameters, true,jdbc);
|
|
|
// 获取 field 节点
|
|
|
List<Element> fieldElements = element.elements("field");
|
|
|
@@ -296,6 +294,9 @@ public class TemplateParser {
|
|
|
for (Element element : elements) {
|
|
|
// 执行 sql ,获取数据
|
|
|
String sql = element.attribute("sql").getText();
|
|
|
+ if(StringUtils.isEmpty(sql)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
sql = replaceParameters(sql, globalParameters, true,jdbc);
|
|
|
checkCount(jdbc.getDataSource().getConnection(), sql);
|
|
|
Map<String, List<Object>> map = convert(jdbc.listMap(sql));
|
|
|
@@ -360,6 +361,9 @@ public class TemplateParser {
|
|
|
for (Element element : elements) {
|
|
|
// 执行 sql ,获取数据
|
|
|
String sql = element.attribute("sql").getText();
|
|
|
+ if(StringUtils.isEmpty(sql)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
sql = replaceParameters(sql, globalParameters, true,jdbc);
|
|
|
checkCount(jdbc.getDataSource().getConnection(), sql);
|
|
|
List<Map<String, Object>> listMap = jdbc.listMap(sql);
|
|
|
@@ -440,7 +444,7 @@ public class TemplateParser {
|
|
|
int end = matcher.end(1);
|
|
|
sql = sql.substring(0, start) + "select count(1) from" + sql.substring(end);
|
|
|
} else {
|
|
|
- throw new IllegalStateException("sql 解析错误:未发现第一个 from");
|
|
|
+ throw new IllegalStateException("sql 解析错误:未发现第一个 from:" + sql);
|
|
|
}
|
|
|
} else {
|
|
|
sql = "select count(1) from (" + sql + ")";
|