|
@@ -95,6 +95,11 @@ public class MyDbHelper {
|
|
|
: (Objects.nonNull(calcInfo) && Objects.nonNull(calcInfo.get("event"))) ? calcInfo.get("event").toString()
|
|
|
: (Objects.nonNull(inputData) && Objects.nonNull(inputData.get("event"))) ? inputData.get("event").toString() : null;
|
|
|
|
|
|
+
|
|
|
+ if (Objects.isNull(event) && MapTools.isNotBlank(sqlStr) && sqlStr.toLowerCase().contains(") union")) {
|
|
|
+ event = Objects.toString(calcInfo.get("event"));
|
|
|
+ }
|
|
|
+
|
|
|
if (MapTools.isBlank(event) || (MapTools.isBlank(tableName) && MapTools.isBlank(sqlStr))) {
|
|
|
return processFail("generalProcess函数: 表为空且SQL为空或事件为空", null, inParams);
|
|
|
}
|
|
@@ -253,7 +258,7 @@ public class MyDbHelper {
|
|
|
|
|
|
private String standarSQLStr(String sqlStr) {
|
|
|
String newSqlStr = sqlStr;
|
|
|
- String[] sqlKeyWordList = "select,from,where,group by,limit,order by".split(",",-1);
|
|
|
+ String[] sqlKeyWordList = "select,from,where,group by,limit,order by".split(",", -1);
|
|
|
for (String sqlKeyWord : sqlKeyWordList) {
|
|
|
Pattern p = Pattern.compile(sqlKeyWord, Pattern.CASE_INSENSITIVE);
|
|
|
Matcher m = p.matcher(newSqlStr);
|
|
@@ -285,10 +290,10 @@ public class MyDbHelper {
|
|
|
HashMap<String, Object> tempMap = new HashMap<>();
|
|
|
String columnName = rsd.getColumnName(i + 1);
|
|
|
String columnLabel = rsd.getColumnLabel(i + 1);
|
|
|
- tempMap.put("columnName",Objects.isNull(columnLabel)? columnName:columnLabel);
|
|
|
+ tempMap.put("columnName", Objects.isNull(columnLabel) ? columnName : columnLabel);
|
|
|
tempMap.put("columnType", rsd.getColumnType(i + 1));
|
|
|
tempMap.put("columnTypeName", rsd.getColumnTypeName(i + 1));
|
|
|
- tempMap.put("columnLable",Objects.isNull(columnLabel)? columnName:columnLabel );
|
|
|
+ tempMap.put("columnLable", Objects.isNull(columnLabel) ? columnName : columnLabel);
|
|
|
allColumnList.add(tempMap);
|
|
|
}
|
|
|
return processSuccess(allColumnList);
|
|
@@ -387,7 +392,7 @@ public class MyDbHelper {
|
|
|
|
|
|
|
|
|
private String getTableBySql(String sqlStr) {
|
|
|
- String[] sqlSplit = sqlStr.split("\\s+",-1);
|
|
|
+ String[] sqlSplit = sqlStr.split("\\s+", -1);
|
|
|
return sqlSplit.length < 3 ? null : sqlSplit[0].equals("insert") ? (sqlSplit[2].indexOf("(") > 0 ? sqlSplit[2].substring(0, sqlSplit[2].indexOf("(")) : sqlSplit[2])
|
|
|
: sqlSplit[0].equals("update") ? sqlSplit[1]
|
|
|
: sqlSplit[0].equals("delete") ? sqlSplit[2] : null;
|
|
@@ -460,7 +465,7 @@ public class MyDbHelper {
|
|
|
Object currentVar = valueObj.get(newColumnName);
|
|
|
|
|
|
if (columnName.startsWith(":")) {
|
|
|
- String[] varSplit = Objects.isNull(currentVar) ? null : currentVar.toString().split(",",-1);
|
|
|
+ String[] varSplit = Objects.isNull(currentVar) ? null : currentVar.toString().split(",", -1);
|
|
|
if (Objects.isNull(varSplit)) {
|
|
|
newSqlStr = newSqlStr.replaceFirst(columnName.concat("?"), "?");
|
|
|
} else {
|
|
@@ -552,7 +557,6 @@ public class MyDbHelper {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
private synchronized String isExist(String tableName, String whereStr, List<Object> dbFilter) {
|
|
|
String event = "2";
|
|
|
if (!AppConfig.event6Map.containsKey(tableName)) {
|
|
@@ -565,9 +569,9 @@ public class MyDbHelper {
|
|
|
List<Map<String, Object>> isExistResult = theJdbcTemplate.queryForList("select 1 from ".concat(tableName).concat(" where ").concat(whereStr).concat(" limit 1"), dbFilter.toArray());
|
|
|
event = (isExistResult.size() == 0) ? "1" : event;
|
|
|
|
|
|
- if (tableUniqe.size() > 3000){
|
|
|
- tableUniqe.clear();
|
|
|
- }
|
|
|
+ if (tableUniqe.size() > 3000) {
|
|
|
+ tableUniqe.clear();
|
|
|
+ }
|
|
|
tableUniqe.add(oldKey);
|
|
|
} catch (Exception e) {
|
|
|
|
|
@@ -690,7 +694,7 @@ public class MyDbHelper {
|
|
|
|
|
|
|
|
|
public Map<String, Object> JDBCBatch(String sqlStr, List<Object> dbValue, Object signParam) {
|
|
|
- if ((sqlStr.startsWith("update") ||sqlStr.contains("?")) && (dbValue.size() == 0 || (dbValue.get(0) instanceof List<?> list && list.isEmpty()) )) {
|
|
|
+ if ((sqlStr.startsWith("update") || sqlStr.contains("?")) && (dbValue.size() == 0 || (dbValue.get(0) instanceof List<?> list && list.isEmpty()))) {
|
|
|
return processSuccess(null);
|
|
|
}
|
|
|
Connection connection = null;
|
|
@@ -703,7 +707,7 @@ public class MyDbHelper {
|
|
|
|
|
|
Object[] signdbValue = ((List<Object>) dbValue.get(i)).toArray();
|
|
|
for (int index = 0; index < signdbValue.length; index++) {
|
|
|
- sqlPS.setObject(index + 1,signdbValue[index]);
|
|
|
+ sqlPS.setObject(index + 1, signdbValue[index]);
|
|
|
}
|
|
|
sqlPS.addBatch();
|
|
|
if ((i + 1) % 10 == 0) {
|