Эх сурвалжийг харах

启停服务 数据操作方法修改 安全认证消息错误修改

andy 1 жил өмнө
parent
commit
480f44a8cf

+ 291 - 292
src/main/java/com/scbfkj/uni/library/script/DatabaseScriptUtil.java

@@ -18,267 +18,15 @@ public class DatabaseScriptUtil {
     private static final Map<String, List<String>> sqlStrVarList = new HashMap<>();//SQL语句的书名号变量列表
     public static Map<String, String> sqlStrNewSQL = new HashMap<>();//SQL语句更换书名号变量后的可执行SQL
 
-    public static Map<String, Object> exec(String connectionStr, String expression, List<Map<String, Object>> args, Object event, List<String> filterColumns, List<Map<String, Object>> filterLines, Pageable pageable) throws Exception {
 
-        if (Objects.isNull(event) || !StringUtils.hasText(event.toString())) {
-            throw new RuntimeException("执行编号不能为空");
-        }
-        event = event.toString();
-        expression = expression.replaceAll("\\s*(\\r)?\\n\\s*", " ").trim();
-        boolean isTableName = !expression.contains(" ");
-
-        if (Objects.isNull(filterColumns)) filterColumns = new ArrayList<>();
+    public static String getFilterLinesWhereSql(List<Map<String, Object>> filterLines) {
         if (Objects.isNull(filterLines)) filterLines = new ArrayList<>();
         String filterLineWhereStr = null;
         for (Object f : filterLines) {
             Map<String, Object> it = ((Map<String, Object>) f);
             filterLineWhereStr = " %s %s %s %s %s %s %s %s ".formatted(filterLineWhereStr, it.getOrDefault("left", ""), it.get("column"), it.get("comparator"), Objects.equals(it.get("comparator"), " is null ") ? "" : "?", !Objects.equals(it.get("comparator"), " is null ") ? " " : it.get("value"), it.getOrDefault("right", ""), it.getOrDefault("connector", ""));
         }
-
-//        只有表名
-        if (isTableName) {
-            List<String> valueNames = null;
-            List<String> filterNames = null;
-
-            List<String> allColumns = DataBase.getColumnsByTableName(connectionStr, expression);
-
-//            查询
-            if (Objects.equals("0", event)) {
-                Map<String, Object> argMap = Objects.isNull(args) || args.isEmpty() ? new HashMap<>() : args.get(0);
-
-                Object filter = argMap.getOrDefault("filter", argMap);
-                Map map = new HashMap<>();
-                if (filter instanceof ArrayNode f) {
-                    map = ((Map<?, ?>) f.get(0));
-                } else if (filter instanceof List<?> f) {
-                    map = ((Map<?, ?>) f.get(0));
-
-                } else if (filter instanceof Map<?, ?> f) {
-                    map = f;
-                }
-
-                String whereStr = "";
-                List<Object[]> values = new ArrayList<>();
-                if (map.containsKey("column") && map.containsKey("comparator")) {
-
-                    ArrayList<Object> objects = new ArrayList<>();
-                    for (Map<String, Object> it : args) {
-                        filter = it.getOrDefault("filter", it);
-                        if (filter instanceof ArrayNode f) {
-                            map = ((Map<?, ?>) f.get(0));
-                        } else if (filter instanceof List<?> f) {
-                            map = ((Map<?, ?>) f.get(0));
-
-                        } else if (filter instanceof Map<?, ?> f) {
-                            map = f;
-                        }
-                        Object comparator = map.get("comparator");
-                        whereStr = " %s %s %s %s %s %s %s ".formatted(whereStr, map.getOrDefault("left", ""), map.get("column"), comparator, Objects.equals(comparator, " is null ") ? " " : "?", map.getOrDefault("right", ""), map.getOrDefault("connector", ""));
-                        if (!Objects.equals(comparator, " is null ")) {
-                            objects.add(map.get("value"));
-                        }
-                    }
-                    expression = "select %s from %s where %s and %s".formatted(String.join(",", allColumns), expression, Objects.isNull(filterLineWhereStr) ? " 1=1 " : filterLineWhereStr, whereStr.trim().isEmpty() ? " 1=? " : whereStr);
-                    if (whereStr.trim().isEmpty()) {
-                        values.add(new Object[]{1});
-                    } else {
-                        values.add(objects.toArray());
-                    }
-                } else {
-                    filterNames = map.keySet().stream().toList();
-
-                    expression = "select %s from %s where   %s  %s".formatted(String.join(",", allColumns), expression, Objects.isNull(filterLineWhereStr) ? " 1=1 " : filterLineWhereStr,
-                            filterNames.isEmpty() ?
-                                    "" : (" and " +
-                                    filterNames.stream().map("%s = ?"::formatted).collect(Collectors.joining(" and "))));
-
-                    for (Map<String, Object> arg : args) {
-                        Map<String, Object> o1 = ((Map<String, Object>) arg.getOrDefault("filter", arg));
-                        values.add(filterNames.stream().map(o1::get).toArray());
-                    }
-                }
-
-                if (!filterColumns.isEmpty()) {
-                    expression = "select %s from (%s) as T".formatted(String.join(",", filterColumns), expression);
-                }
-                if (pageable != null) {
-                    expression = "%s limit %d,%d ".formatted(expression, pageable.page * pageable.pageSize, pageable.pageSize);
-                }
-                List<Map<String, Object>> result = DataBase.queryBatch(connectionStr, expression, values);
-                return UniReturnUtil.success(result);
-//                更新或新增
-            } else if (Objects.equals("6", event)) {
-                Map<String, Object> map = args.get(0);
-                Map<String, Object> filter = ((Map<String, Object>) map.get("filter"));
-                filterNames = filter.keySet().stream().toList();
-
-                List<Map<String, Object>> insertValues = new ArrayList<>();
-                List<Map<String, Object>> updateValues = new ArrayList<>();
-
-                String sql = "select count(1) as existscount from %s where %s".formatted(expression, filterNames.stream().map("%s = ?"::formatted).collect(Collectors.joining(" and ")));
-                for (Map<String, Object> arg : args) {
-
-                    Map<String, Object> where = ((Map<String, Object>) arg.get("filter"));
-                    Object[] objects = filterNames.stream().map(where::get).toArray();
-                    if (exists(connectionStr, sql, objects)) {
-                        updateValues.add(arg);
-                    } else {
-                        insertValues.add(arg);
-                    }
-                }
-                Map<String, Object> insertResult = null;
-                if (!insertValues.isEmpty())
-                    insertResult = exec(connectionStr, expression, insertValues, "1", filterColumns, filterLines, null);
-                Map<String, Object> updateResult = null;
-                if (!updateValues.isEmpty())
-                    updateResult = exec(connectionStr, expression, updateValues, "2", filterColumns, filterLines, null);
-
-                Map<String, Object> finalInsertResult = insertResult;
-                Map<String, Object> finalUpdateResult = updateResult;
-                HashMap<Object, Object> data = new HashMap<>();
-                data.put("insert", finalInsertResult);
-                data.put("update", finalUpdateResult);
-
-                return UniReturnUtil.success(data);
-            } else {
-//                新增
-                if (Objects.equals("1", event)) {
-                    Map<String, Object> value = args.get(0);
-                    Object valueObj = value.getOrDefault("value", value);
-                    Map map = null;
-                    if (valueObj instanceof ArrayNode v) {
-                        map = ((Map<?, ?>) v.get(0));
-                    } else if (valueObj instanceof List<?> v) {
-                        map = ((Map<?, ?>) v.get(0));
-
-                    } else if (valueObj instanceof Map<?, ?> v) {
-                        map = v;
-                    }
-//                    Map<String, Object> value = ((Map<String, Object>) map.getOrDefault("value", map));
-                    valueNames = map.keySet().stream().toList();
-                    expression = "insert into %s ( %s) values(%s)".formatted(expression, String.join(",", valueNames), valueNames.stream().map(it -> "?").collect(Collectors.joining(",")));
-//                    更新
-                } else if (Objects.equals("2", event)) {
-                    Map<String, Object> map = args.get(0);
-                    Map<String, Object> value = ((Map<String, Object>) map.get("value"));
-                    valueNames = value.keySet().stream().toList();
-                    Map<String, Object> filter = ((Map<String, Object>) map.get("filter"));
-                    filterNames = filter.keySet().stream().toList();
-
-                    expression = "update %s set %s where %s and %s".formatted(expression, valueNames.stream().map("%s = ?"::formatted).collect(Collectors.joining(",")), filterNames.stream().map("%s = ?"::formatted).collect(Collectors.joining(" and ")), Objects.isNull(filterLineWhereStr) ? " 1=1 " : filterLineWhereStr);
-//                    删除
-                } else if (Objects.equals("3", event)) {
-
-
-                    Map<String, Object> argMap = args.get(0);
-                    Object filter = argMap.getOrDefault("filter", argMap);
-                    Map map = null;
-                    if (filter instanceof ArrayNode f) {
-                        map = ((Map<?, ?>) f.get(0));
-                    } else if (filter instanceof List<?> f) {
-                        map = ((Map<?, ?>) f.get(0));
-
-                    } else if (filter instanceof Map<?, ?> f) {
-                        map = f;
-                    }
-                    filterNames = map.keySet().stream().toList();
-                    expression = "delete from %s where %s and  %s".formatted(expression, filterNames.stream().map("%s = ?"::formatted).collect(Collectors.joining(" and ")), Objects.isNull(filterLineWhereStr) ? " 1=1 " : filterLineWhereStr);
-                } else if (Objects.equals("7", event)) {
-//                    先删除
-                    exec(connectionStr, expression, args, "3", filterColumns, filterLines, pageable);
-//                    再新增
-                    return exec(connectionStr, expression, args, "1", filterColumns, filterLines, pageable);
-
-                }
-                List<Object[]> values = new ArrayList<>();
-//                按照名称 和过滤条件取值
-                final List<String> finalFilterColumns = filterColumns;
-                for (Map<String, Object> arg : args) {
-                    List<Object> objects = new ArrayList<>();
-                    if (Objects.nonNull(valueNames)) {
-                        Map<String, Object> o1 = ((Map<String, Object>) arg.getOrDefault("value", arg));
-                        objects.addAll(valueNames.stream().map(it -> {
-
-//                            新增 更新 对列过滤
-                            if (finalFilterColumns.contains(it) || finalFilterColumns.isEmpty()) {
-                                return o1.get(it);
-                            } else {
-                                return null;
-                            }
-                        }).toList());
-                    }
-                    if (Objects.nonNull(filterNames)) {
-                        Map<String, Object> o1 = ((Map<String, Object>) arg.getOrDefault("filter", arg));
-                        objects.addAll(filterNames.stream().map(o1::get).toList());
-                    }
-                    values.add(objects.toArray());
-                }
-                int[] ints = DataBase.updateBatch(connectionStr, expression, values);
-                return UniReturnUtil.success(ints);
-            }
-
-//         目前只支持查询
-        } else if (expression.contains("《whereStr》")) {
-
-            String whereStr = " ";//初始化条件字符串
-            List<Object> dbFilter = new ArrayList<>();//初始化条件执行参数
-            Map<String, Object> map = args.get(0);
-            Object filter = map.get("filter");
-            if (filter instanceof List filterList && !filterList.isEmpty()) {//如果存在上传的条件参数或者存在行权限
-                Map<String, Object> filterMap = (Map<String, Object>) filterList.get(0);
-                if (filterMap.containsKey("column")) {
-                    for (Object f : filterList) {
-                        Map<String, Object> it = ((Map<String, Object>) f);
-                        whereStr = " %s %s %s %s %s %s %s".formatted(whereStr, it.getOrDefault("left", ""), it.get("column"), it.get("comparator"), Objects.equals(it.get("comparator"), " is null ") ? "" : "?", it.getOrDefault("right", ""), it.getOrDefault("connector", ""));
-                        if (!Objects.equals(it.get("comparator"), " is null ")) {
-                            dbFilter.add(it.get("value"));
-                        }
-                    }
-                } else {
-                    List<Map.Entry<String, Object>> list = filterMap.entrySet().stream().toList();
-                    whereStr += list.stream().map("%s = ?"::formatted).collect(Collectors.joining(" and "));
-                    dbFilter.addAll(list.stream().map(Map.Entry::getValue).toList());
-                }
-            } else if (filter instanceof Map<?, ?> filterMap && !filterMap.isEmpty()) {
-                List<? extends Map.Entry<?, ?>> list = filterMap.entrySet().stream().toList();
-                whereStr += list.stream().map(it -> "%s = ?".formatted(it.getKey())).collect(Collectors.joining(" and "));
-                dbFilter.addAll(list.stream().map(Map.Entry::getValue).toList());
-            }
-            whereStr = " %s and  %s".formatted(whereStr, Objects.isNull(filterLineWhereStr) ? " 1=1 " : filterLineWhereStr);
-            String sql = expression.replaceAll("《whereStr》", " " + whereStr);
-
-            if (!filterColumns.isEmpty()) {
-                sql = "select %s from (%s) as T".formatted(String.join(",", filterColumns), sql);
-            }
-
-            if (pageable != null && !sql.contains(" limit ")) {
-                sql = "%s limit %d,%d ".formatted(sql, pageable.page * pageable.pageSize, pageable.pageSize);
-            }
-            List<Map<String, Object>> queryResult = DataBase.queryBatch(connectionStr, sql, Collections.singletonList(dbFilter.toArray()));
-            return UniReturnUtil.success(queryResult);
-
-        } else {
-            if (Objects.equals(event, "0")) {
-                List<Map<String, Object>> queryResult = query(connectionStr, expression, args, filterColumns, filterLines, pageable);
-                return UniReturnUtil.success(queryResult);
-            } else if (Objects.equals(event, "1")) {
-                if (sqlStrVarList.containsKey(expression)) {
-                    getSQLVarList(expression);
-                }
-                List<String> names = sqlStrVarList.get(expression);
-                String sql = sqlStrNewSQL.get(expression);
-                int[] updateResult = DataBase.updateBatch(connectionStr, sql, args.stream().map(it -> names.stream().map(it::get).toArray()).toList());
-                return UniReturnUtil.success(updateResult);
-            } else {
-                if (sqlStrVarList.containsKey(expression)) {
-                    getSQLVarList(expression);
-                }
-                List<String> names = sqlStrVarList.get(expression);
-                String sql = " %s  and %s".formatted(sqlStrNewSQL.get(expression), Objects.isNull(filterLineWhereStr) ? " 1=1 " : filterLineWhereStr);
-                int[] updateResult = DataBase.updateBatch(connectionStr, sql, args.stream().map(it -> names.stream().map(it::get).toArray()).toList());
-                return UniReturnUtil.success(updateResult);
-            }
-        }
+        return filterLineWhereStr;
     }
 
     public static List<String> getSQLVarList(String sqlStr) {
@@ -369,11 +117,84 @@ public class DatabaseScriptUtil {
         if (Objects.nonNull(filterLinesTemp))
             filterLines = DataFormatUtil.toList(filterLinesTemp).stream().map(it -> ((Map<String, Object>) it)).toList();
         Object event = args.get("event");
-        Pageable pageable = null;
-        if ("0".equals(event)) {
-            pageable = pageable(args);
+        Pageable pageable = pageable(args);
+
+
+        if (Objects.isNull(event) || !StringUtils.hasText(event.toString())) {
+            throw new RuntimeException("执行编号不能为空");
+        }
+        event = event.toString();
+
+        if (Objects.isNull(filterColumns)) filterColumns = new ArrayList<>();
+
+        String filterLineWhereStr = getFilterLinesWhereSql(filterLines);
+
+        String connectionStr = datasourceId;
+        if (Pattern.compile("^\\d+$").matcher(connectionStr.trim()).matches()) {
+            connectionStr = queryConnectionStr(connectionStr.trim());
+        }
+
+        if (expression.contains("《whereStr》")) {
+
+            String whereStr = " ";//初始化条件字符串
+            List<Object> dbFilter = new ArrayList<>();//初始化条件执行参数
+            Map<String, Object> map = dataContent.get(0);
+            Object filter = map.get("filter");
+            if (filter instanceof List filterList && !filterList.isEmpty()) {//如果存在上传的条件参数或者存在行权限
+                Map<String, Object> filterMap = (Map<String, Object>) filterList.get(0);
+                if (filterMap.containsKey("column")) {
+                    for (Object f : filterList) {
+                        Map<String, Object> it = ((Map<String, Object>) f);
+                        whereStr = " %s %s %s %s %s %s %s".formatted(whereStr, it.getOrDefault("left", ""), it.get("column"), it.get("comparator"), Objects.equals(it.get("comparator"), " is null ") ? "" : "?", it.getOrDefault("right", ""), it.getOrDefault("connector", ""));
+                        if (!Objects.equals(it.get("comparator"), " is null ")) {
+                            dbFilter.add(it.get("value"));
+                        }
+                    }
+                } else {
+                    List<Map.Entry<String, Object>> list = filterMap.entrySet().stream().toList();
+                    whereStr += list.stream().map("%s = ?"::formatted).collect(Collectors.joining(" and "));
+                    dbFilter.addAll(list.stream().map(Map.Entry::getValue).toList());
+                }
+            } else if (filter instanceof Map<?, ?> filterMap && !filterMap.isEmpty()) {
+                List<? extends Map.Entry<?, ?>> list = filterMap.entrySet().stream().toList();
+                whereStr += list.stream().map(it -> "%s = ?".formatted(it.getKey())).collect(Collectors.joining(" and "));
+                dbFilter.addAll(list.stream().map(Map.Entry::getValue).toList());
+            }
+            whereStr = " %s and  %s".formatted(whereStr.trim().isEmpty() ? " 1=1 " : whereStr, Objects.isNull(filterLineWhereStr) ? " 1=1 " : filterLineWhereStr);
+            String sql = expression.replaceAll("《whereStr》", " " + whereStr);
+
+            if (!filterColumns.isEmpty()) {
+                sql = "select %s from (%s) as T".formatted(String.join(",", filterColumns), sql);
+            }
+
+            if (pageable != null && !sql.contains(" limit ")) {
+                sql = "%s limit %d,%d ".formatted(sql, pageable.page * pageable.pageSize, pageable.pageSize);
+            }
+            List<Map<String, Object>> queryResult = DataBase.queryBatch(connectionStr, sql, Collections.singletonList(dbFilter.toArray()));
+            return UniReturnUtil.success(queryResult);
+
+        } else {
+            if (Objects.equals(event, "0")) {
+                List<Map<String, Object>> queryResult = query(connectionStr, expression, dataContent, filterColumns, filterLines, pageable);
+                return UniReturnUtil.success(queryResult);
+            } else if (Objects.equals(event, "1")) {
+                if (sqlStrVarList.containsKey(expression)) {
+                    getSQLVarList(expression);
+                }
+                List<String> names = sqlStrVarList.get(expression);
+                String sql = sqlStrNewSQL.get(expression);
+                int[] updateResult = DataBase.updateBatch(connectionStr, sql, dataContent.stream().map(it -> names.stream().map(it::get).toArray()).toList());
+                return UniReturnUtil.success(updateResult);
+            } else {
+                if (sqlStrVarList.containsKey(expression)) {
+                    getSQLVarList(expression);
+                }
+                List<String> names = sqlStrVarList.get(expression);
+                String sql = " %s  and %s".formatted(sqlStrNewSQL.get(expression), Objects.isNull(filterLineWhereStr) ? " 1=1 " : filterLineWhereStr);
+                int[] updateResult = DataBase.updateBatch(connectionStr, sql, dataContent.stream().map(it -> names.stream().map(it::get).toArray()).toList());
+                return UniReturnUtil.success(updateResult);
+            }
         }
-        return exec(queryConnectionStr(datasourceId), expression, dataContent, event, filterColumns, filterLines, pageable);
     }
 
     public static Map<String, Object> execByTableName(String datasourceId, String table, Map<String, Object> args) throws Exception {
@@ -387,47 +208,221 @@ public class DatabaseScriptUtil {
         if (Objects.nonNull(filterLinesTemp))
             filterLines = DataFormatUtil.toList(filterLinesTemp).stream().map(it -> ((Map<String, Object>) it)).toList();
         Object event = args.get("event");
-        Pageable pageable = null;
-        if ("0".equals(event)) {
-            pageable = pageable(args);
+        Pageable pageable = pageable(args);
+
+
+        if (Objects.isNull(event) || !StringUtils.hasText(event.toString())) {
+            throw new RuntimeException("执行编号不能为空");
+        }
+        event = event.toString();
+        String expression = table;
+
+        if (Objects.isNull(filterColumns)) filterColumns = new ArrayList<>();
+
+        String filterLineWhereStr = getFilterLinesWhereSql(filterLines);
+
+        String connectionStr = datasourceId;
+        if (Pattern.compile("^\\d+$").matcher(connectionStr.trim()).matches()) {
+            connectionStr = queryConnectionStr(connectionStr.trim());
+        }
+        List<String> valueNames = null;
+        List<String> filterNames = null;
+
+        List<String> allColumns = DataBase.getColumnsByTableName(connectionStr, expression);
+
+//            查询
+        if (Objects.equals("0", event)) {
+            Map<String, Object> argMap = Objects.isNull(args) || args.isEmpty() ? new HashMap<>() : dataContent.get(0);
+
+            Object filter = argMap.getOrDefault("filter", argMap);
+            Map map = new HashMap<>();
+            if (filter instanceof ArrayNode f) {
+                map = ((Map<?, ?>) f.get(0));
+            } else if (filter instanceof List<?> f) {
+                map = ((Map<?, ?>) f.get(0));
+
+            } else if (filter instanceof Map<?, ?> f) {
+                map = f;
+            }
+
+            String whereStr = "";
+            List<Object[]> values = new ArrayList<>();
+            if (map.containsKey("column") && map.containsKey("comparator")) {
+
+                ArrayList<Object> objects = new ArrayList<>();
+                for (Map<String, Object> it : dataContent) {
+                    filter = it.getOrDefault("filter", it);
+                    if (filter instanceof ArrayNode f) {
+                        map = ((Map<?, ?>) f.get(0));
+                    } else if (filter instanceof List<?> f) {
+                        map = ((Map<?, ?>) f.get(0));
+
+                    } else if (filter instanceof Map<?, ?> f) {
+                        map = f;
+                    }
+                    Object comparator = map.get("comparator");
+                    whereStr = " %s %s %s %s %s %s %s ".formatted(whereStr, map.getOrDefault("left", ""), map.get("column"), comparator, Objects.equals(comparator, " is null ") ? " " : "?", map.getOrDefault("right", ""), map.getOrDefault("connector", ""));
+                    if (!Objects.equals(comparator, " is null ")) {
+                        objects.add(map.get("value"));
+                    }
+                }
+                expression = "select %s from %s where %s and %s".formatted(String.join(",", allColumns), expression, Objects.isNull(filterLineWhereStr) ? " 1=1 " : filterLineWhereStr, whereStr.trim().isEmpty() ? " 1=? " : whereStr);
+                if (whereStr.trim().isEmpty()) {
+                    values.add(new Object[]{1});
+                } else {
+                    values.add(objects.toArray());
+                }
+            } else {
+                filterNames = map.keySet().stream().toList();
+
+                expression = "select %s from %s where   %s  %s".formatted(String.join(",", allColumns), expression, Objects.isNull(filterLineWhereStr) ? " 1=1 " : filterLineWhereStr,
+                        filterNames.isEmpty() ?
+                                "" : (" and " +
+                                filterNames.stream().map("%s = ?"::formatted).collect(Collectors.joining(" and "))));
+
+                for (Map<String, Object> arg : dataContent) {
+                    Map<String, Object> o1 = ((Map<String, Object>) arg.getOrDefault("filter", arg));
+                    values.add(filterNames.stream().map(o1::get).toArray());
+                }
+            }
+
+            if (!filterColumns.isEmpty()) {
+                expression = "select %s from (%s) as T".formatted(String.join(",", filterColumns), expression);
+            }
+            if (pageable != null) {
+                expression = "%s limit %d,%d ".formatted(expression, pageable.page * pageable.pageSize, pageable.pageSize);
+            }
+            List<Map<String, Object>> result = DataBase.queryBatch(connectionStr, expression, values);
+            return UniReturnUtil.success(result);
+//                更新或新增
+        } else if (Objects.equals("6", event)) {
+            Map<String, Object> map = dataContent.get(0);
+            Map<String, Object> filter = ((Map<String, Object>) map.get("filter"));
+            filterNames = filter.keySet().stream().toList();
+
+            List<Map<String, Object>> insertValues = new ArrayList<>();
+            List<Map<String, Object>> updateValues = new ArrayList<>();
+
+            String sql = "select count(1) as existscount from %s where %s".formatted(expression, filterNames.stream().map("%s = ?"::formatted).collect(Collectors.joining(" and ")));
+            for (Map<String, Object> arg : dataContent) {
+
+                Map<String, Object> where = ((Map<String, Object>) arg.get("filter"));
+                Object[] objects = filterNames.stream().map(where::get).toArray();
+                if (exists(connectionStr, sql, objects)) {
+                    updateValues.add(arg);
+                } else {
+                    insertValues.add(arg);
+                }
+            }
+            Map<String, Object> insertResult = null;
+
+            if (!insertValues.isEmpty()) {
+                HashMap<String, Object> insertArgs = new HashMap<>(args);
+                insertArgs.put("event", "1");
+                insertArgs.put("datacontent", insertValues);
+                insertResult = execByTableName(connectionStr, expression, insertArgs);
+            }
+            Map<String, Object> updateResult = null;
+            if (!updateValues.isEmpty()) {
+
+                HashMap<String, Object> updateArgs = new HashMap<>(args);
+                updateArgs.put("event", "1");
+                updateArgs.put("datacontent", updateValues);
+                updateResult = execByTableName(connectionStr, expression, updateArgs);
+            }
+
+            Map<String, Object> finalInsertResult = insertResult;
+            Map<String, Object> finalUpdateResult = updateResult;
+            HashMap<Object, Object> data = new HashMap<>();
+            data.put("insert", finalInsertResult);
+            data.put("update", finalUpdateResult);
+
+            return UniReturnUtil.success(data);
+        } else {
+//                新增
+            if (Objects.equals("1", event)) {
+                Map<String, Object> value = dataContent.get(0);
+                Object valueObj = value.getOrDefault("value", value);
+                Map map = null;
+                if (valueObj instanceof ArrayNode v) {
+                    map = ((Map<?, ?>) v.get(0));
+                } else if (valueObj instanceof List<?> v) {
+                    map = ((Map<?, ?>) v.get(0));
+
+                } else if (valueObj instanceof Map<?, ?> v) {
+                    map = v;
+                }
+//                    Map<String, Object> value = ((Map<String, Object>) map.getOrDefault("value", map));
+                valueNames = map.keySet().stream().toList();
+                expression = "insert into %s ( %s) values(%s)".formatted(expression, String.join(",", valueNames), valueNames.stream().map(it -> "?").collect(Collectors.joining(",")));
+//                    更新
+            } else if (Objects.equals("2", event)) {
+                Map<String, Object> map = dataContent.get(0);
+                Map<String, Object> value = ((Map<String, Object>) map.get("value"));
+                valueNames = value.keySet().stream().toList();
+                Map<String, Object> filter = ((Map<String, Object>) map.get("filter"));
+                filterNames = filter.keySet().stream().toList();
+
+                expression = "update %s set %s where %s and %s".formatted(expression, valueNames.stream().map("%s = ?"::formatted).collect(Collectors.joining(",")), filterNames.stream().map("%s = ?"::formatted).collect(Collectors.joining(" and ")), Objects.isNull(filterLineWhereStr) ? " 1=1 " : filterLineWhereStr);
+//                    删除
+            } else if (Objects.equals("3", event)) {
+
+
+                Map<String, Object> argMap = dataContent.get(0);
+                Object filter = argMap.getOrDefault("filter", argMap);
+                Map map = null;
+                if (filter instanceof ArrayNode f) {
+                    map = ((Map<?, ?>) f.get(0));
+                } else if (filter instanceof List<?> f) {
+                    map = ((Map<?, ?>) f.get(0));
+
+                } else if (filter instanceof Map<?, ?> f) {
+                    map = f;
+                }
+                filterNames = map.keySet().stream().toList();
+                expression = "delete from %s where %s and  %s".formatted(expression, filterNames.stream().map("%s = ?"::formatted).collect(Collectors.joining(" and ")), Objects.isNull(filterLineWhereStr) ? " 1=1 " : filterLineWhereStr);
+            } else if (Objects.equals("7", event)) {
+//                    先删除
+                args.put("event", "3");
+                execByTableName(datasourceId, table, args);
+//                    再新增
+                args.put("event", "1");
+                return execByTableName(datasourceId, table, args);
+            }
+            List<Object[]> values = new ArrayList<>();
+//                按照名称 和过滤条件取值
+            final List<String> finalFilterColumns = filterColumns;
+            for (Map<String, Object> arg : dataContent) {
+                List<Object> objects = new ArrayList<>();
+                if (Objects.nonNull(valueNames)) {
+                    Map<String, Object> o1 = ((Map<String, Object>) arg.getOrDefault("value", arg));
+                    objects.addAll(valueNames.stream().map(it -> {
+
+//                            新增 更新 对列过滤
+                        if (finalFilterColumns.contains(it) || finalFilterColumns.isEmpty()) {
+                            return o1.get(it);
+                        } else {
+                            return null;
+                        }
+                    }).toList());
+                }
+                if (Objects.nonNull(filterNames)) {
+                    Map<String, Object> o1 = ((Map<String, Object>) arg.getOrDefault("filter", arg));
+                    objects.addAll(filterNames.stream().map(o1::get).toList());
+                }
+                values.add(objects.toArray());
+            }
+            int[] ints = DataBase.updateBatch(connectionStr, expression, values);
+            return UniReturnUtil.success(ints);
         }
-        return exec(queryConnectionStr(datasourceId), table, dataContent, event, filterColumns, filterLines, pageable);
     }
 
     public static Map<String, Object> execByDynamicSql(String datasourceId, String expression, Map<String, Object> args) throws Exception {
-        List<Map<String, Object>> dataContent = DataFormatUtil.toList(args.get("datacontent")).stream().map(it -> ((Map<String, Object>) it)).toList();
-        Object filterColumnsTemp = args.get("filterColumns");
-        List<String> filterColumns = null;
-        if (Objects.nonNull(filterColumnsTemp))
-            filterColumns = DataFormatUtil.toList(filterColumnsTemp).stream().map(it -> it.toString()).toList();
-        Object filterLinesTemp = args.get("filterLines");
-        List<Map<String, Object>> filterLines = null;
-        if (Objects.nonNull(filterLinesTemp))
-            filterLines = DataFormatUtil.toList(filterLinesTemp).stream().map(it -> ((Map<String, Object>) it)).toList();
-        Object event = args.get("event");
-        Pageable pageable = null;
-        if ("0".equals(event)) {
-            pageable = pageable(args);
-        }
-        return exec(queryConnectionStr(datasourceId), expression, dataContent, event, filterColumns, filterLines, pageable);
+        return execBySql(datasourceId, expression, args);
     }
 
     public static Map<String, Object> execByDynamicTableName(String datasourceId, String table, Map<String, Object> args) throws Exception {
-        List<Map<String, Object>> dataContent = DataFormatUtil.toList(args.get("datacontent")).stream().map(it -> ((Map<String, Object>) it)).toList();
-        Object filterColumnsTemp = args.get("filterColumns");
-        List<String> filterColumns = null;
-        if (Objects.nonNull(filterColumnsTemp))
-            filterColumns = DataFormatUtil.toList(filterColumnsTemp).stream().map(it -> it.toString()).toList();
-        Object filterLinesTemp = args.get("filterLines");
-        List<Map<String, Object>> filterLines = null;
-        if (Objects.nonNull(filterLinesTemp))
-            filterLines = DataFormatUtil.toList(filterLinesTemp).stream().map(it -> ((Map<String, Object>) it)).toList();
-        Object event = args.get("event");
-        Pageable pageable = null;
-        if ("0".equals(event)) {
-            pageable = pageable(args);
-        }
-        return exec(queryConnectionStr(datasourceId), table, dataContent, event, filterColumns, filterLines, pageable);
+        return execByTableName(datasourceId, table, args);
     }
 
     public static String queryConnectionStr(String datasourceId) throws Exception {
@@ -457,6 +452,10 @@ public class DatabaseScriptUtil {
         Object size = args.get("size");
         Long pageNumber = 0L;
         Long pageSizeNumber = 0L;
+        Object event = args.get("event");
+        if (event == null || !event.toString().equals("0")) {
+            return null;
+        }
 
         if (Objects.nonNull(page)) {
             pageNumber = Long.parseLong(page.toString()) - 1;

+ 27 - 21
src/main/java/com/scbfkj/uni/process/DataBase.java

@@ -13,12 +13,12 @@ import java.util.*;
 
 public class DataBase {
 
-    public final static Map<String, Map<String, Object>> cacheDatas = new Hashtable<>();
-    public final static Map<String, HikariPool> dataSourcePools = new HashMap<>();
+    public static final Map<String, Map<String, Object>> cacheDatas = new Hashtable<>();
+    public static final Map<String, HikariPool> dataSourcePools = new HashMap<>();
     private static final Map<String, List<String>> columns = new HashMap<>();
     private static List<Map<String, Object>> cacheConfigList = new ArrayList<>();
 
-    public synchronized static List<Map<String, Object>> queryBatch(String connectionStr, String sql, List<Object[]> argsList) throws Exception {
+    public static synchronized List<Map<String, Object>> queryBatch(String connectionStr, String sql, List<Object[]> argsList) throws Exception {
 
 //        缓存数据 connectionStr + sql
 
@@ -208,33 +208,39 @@ public class DataBase {
         }
     }
 
-    public static int exec(String connectionStr, String sql) throws Exception {
+    public static boolean exec(String connectionStr, String sql) throws Exception {
         HikariPool dataSourcePool = getDataSourcePool(connectionStr);
         try (Connection connection = dataSourcePool.getConnection();
              PreparedStatement preparedStatement = connection.prepareStatement(sql)
         ) {
-            int i = preparedStatement.executeUpdate();
+            boolean result;
             try {
+                result = preparedStatement.execute();
                 connection.commit();
             } catch (Exception e) {
                 connection.rollback();
                 throw e;
             }
-            return i;
+            return result;
         }
     }
 
-    public static boolean update(String connectionStr, String sql, Object... args) throws Exception {
-        HikariPool dataSourcePool = getDataSourcePool(connectionStr);
-        try (Connection connection = dataSourcePool.getConnection();
-             PreparedStatement preparedStatement = connection.prepareStatement(sql)
-        ) {
-            for (int i = 0; i < args.length; i++) {
-                preparedStatement.setObject(i + 1, args[i]);
+    public static int update(String connectionStr, String sql, Object... args) throws Exception {
+
+        if (sql.trim().startsWith("insert")) {
+            return insertReturnKeys(connectionStr, sql, args);
+        } else {
+            HikariPool dataSourcePool = getDataSourcePool(connectionStr);
+            try (Connection connection = dataSourcePool.getConnection();
+                 PreparedStatement preparedStatement = connection.prepareStatement(sql)
+            ) {
+                for (int i = 0; i < args.length; i++) {
+                    preparedStatement.setObject(i + 1, args[i]);
+                }
+                preparedStatement.execute();
+                connection.commit();
+                return preparedStatement.getUpdateCount();
             }
-            preparedStatement.execute();
-            connection.commit();
-            return preparedStatement.getUpdateCount() > 0;
         }
     }
 
@@ -320,13 +326,13 @@ public class DataBase {
         return names;
     }
 
-    public static List<String> getColumnsByTableName(String connection, String tabelName) throws SQLException {
-        if (columns.containsKey(connection + tabelName)) {
-            return columns.get(connection + tabelName);
+    public static List<String> getColumnsByTableName(String connection, String tableName) throws SQLException {
+        if (columns.containsKey(connection + tableName)) {
+            return columns.get(connection + tableName);
         }
         ResultSet resultSet;
         try (Connection conn = getDataSourcePool(connection).getConnection();
-             PreparedStatement preparedStatement = conn.prepareStatement("select * from %s limit 0,1".formatted(tabelName))) {
+             PreparedStatement preparedStatement = conn.prepareStatement("select * from %s limit 0,1".formatted(tableName))) {
             resultSet = preparedStatement.executeQuery();
         } catch (Exception e) {
             throw new RuntimeException(e);
@@ -336,7 +342,7 @@ public class DataBase {
         for (int i = 0; i < metaData.getColumnCount(); i++) {
             names.add(metaData.getColumnName(i + 1));
         }
-        columns.put(connection + tabelName, names);
+        columns.put(connection + tableName, names);
         return names;
     }
 

+ 13 - 8
src/main/java/com/scbfkj/uni/service/ControlService.java

@@ -27,7 +27,7 @@ public class ControlService {
 //        查询服务类型为主动采集的服务
 
         try {
-            List<Map<String, Object>> serviceInfos = DataBase.query(Config.getCenterConnectionStr(), SERVICEINFO_WHERE_CONTAINERCODE, Config.getContainerCode());
+            List<Map<String, Object>> serviceInfos = DataBase.query(Config.getCenterConnectionStr(), SERVICEINFO_WHERE_CONTAINERCODE, containerCode);
 //        循环启动
 
             Map<String, List<Map<String, Object>>> results = serviceInfos.stream()
@@ -43,7 +43,7 @@ public class ControlService {
 
 //        查询服务类型为主动采集的服务
         try {
-            List<Map<String, Object>> serviceInfos = DataBase.query(Config.getCenterConnectionStr(), SERVICEINFO_WHERE_CONTAINERCODE, Config.getContainerCode());
+            List<Map<String, Object>> serviceInfos = DataBase.query(Config.getCenterConnectionStr(), SERVICEINFO_WHERE_CONTAINERCODE, containerCode);
             Map<String, List<Map<String, Object>>> results = serviceInfos.stream()
                     .map(it -> start(it.get(SERVICE_ID).toString(), containerCode))
                     .collect(Collectors.groupingBy(it -> it.get(CODE).toString()));
@@ -67,7 +67,7 @@ public class ControlService {
                 return UniReturnUtil.fail("服务%s没有配置".formatted(serviceId));
             }
             Map<String, Object> serviceInfo = serviceInfoList.get(0);
-            Object taskType = serviceInfo.get("tasktype");
+            String taskType = serviceInfo.getOrDefault("tasktype", "0").toString();
             updateServiceState(serviceId, containerCode, "1");
             if (Objects.equals(taskType, "0")) {
 //            设置服务状态为运行中
@@ -110,14 +110,19 @@ public class ControlService {
     private static void updateServiceState(String serviceId, String containerCode, String state) throws Exception {
         if (Objects.equals(state, "1")) {
 
-            List<Map<String, Object>> mapList = DataBase.query(Config.getCenterConnectionStr(), "select runstate,servicestateid from servicestate where starttime is not null and  serviceid=? and containercode=?", serviceId, containerCode);
+            List<Map<String, Object>> mapList = DataBase.query(Config.getCenterConnectionStr(), "select runstate,servicestateid from servicestate where stoptime is  null and  serviceid=? and containercode=?", serviceId, containerCode);
             if (mapList.isEmpty()) {
 
-                DataBase.update(Config.getCenterConnectionStr(), "insert into  servicestate(serviceid,starttime,containercode,runstate,workpath) values (?,?,?,'1',?)",
+                List<Map<String, Object>> result = DataBase.query(Config.getCenterConnectionStr(), "select servicename from serviceinfo where serviceid=?", serviceId);
+                Object servicename = result.isEmpty() ? null : result.get(0).get("servicename");
+                result = DataBase.query(Config.getCenterConnectionStr(), "select containerid from container where containercode=?", containerCode);
+                Object containerid = result.isEmpty() ? null : result.get(0).get("containerid");
+
+                DataBase.update(Config.getCenterConnectionStr(), "insert into  servicestate(serviceid,starttime,containercode,runstate,workpath,servicename,containerid) values (?,?,?,'1',?,?,?)",
                         serviceId,
                         DataFormatUtil.toString(LocalDateTime.now()),
-                        Config.getContainerCode(),
-                        new File(".").getAbsolutePath());
+                        containerCode,
+                        new File(".").getAbsolutePath(), servicename, containerid);
             } else {
                 String serviceStateId = mapList.get(0).get("servicestateid").toString();
                 DataBase.update(Config.getCenterConnectionStr(), "update servicestate set starttime=?,runstate='1',workpath = ? where  servicestateid = ? and containercode =?",
@@ -126,7 +131,7 @@ public class ControlService {
                         serviceStateId, containerCode);
             }
         } else {
-            List<Map<String, Object>> mapList = DataBase.query(Config.getCenterConnectionStr(), "select servicestateid, runstate from servicestate where stoptime is null and  serviceid=? and containercode=? order by servicestateid desc", serviceId, containerCode);
+            List<Map<String, Object>> mapList = DataBase.query(Config.getCenterConnectionStr(), "select servicestateid, runstate from servicestate where stoptime is  null and  serviceid=? and containercode=? order by servicestateid desc", serviceId, containerCode);
 
             if (!mapList.isEmpty()) {
                 String serviceStateId = mapList.get(0).get("servicestateid").toString();

+ 8 - 1
src/main/java/com/scbfkj/uni/service/DataProcessService.java

@@ -353,7 +353,14 @@ public class DataProcessService {
             case "3", "DB" -> {
                 // 下放到Database中处理数据
                 // 参数表达式顺序是 数据源连接字符串(String.$.datasource.connectset),sql表达式(String.$.algorithm.computingexpression),需要操作的值(List.$.args[1].returnData),执行编号(String.$.algorithm.executionnumber)
-                return DatabaseScriptUtil.exec(DataFormatUtil.toString(parameters.get(0)), DataFormatUtil.toString(parameters.get(1)), ((List<Map<String, Object>>) parameters.get(2)), parameters.get(3), (List<String>) parameters.get(4), (List<Map<String, Object>>) parameters.get(5), null);
+                String expression = DataFormatUtil.toString(parameters.get(1));
+                expression = expression.replaceAll("\\s*(\\r)?\\n\\s*", " ").trim();
+                boolean isTableName = !expression.contains(" ");
+                if (isTableName) {
+                    return DatabaseScriptUtil.execByTableName(DataFormatUtil.toString(parameters.get(0)), expression, (Map<String, Object>) parameters.get(2));
+                } else {
+                    return DatabaseScriptUtil.execBySql(DataFormatUtil.toString(parameters.get(0)), expression, (Map<String, Object>) parameters.get(2));
+                }
             }
             default -> {
                 return UniReturnUtil.fail("算法类型不支持");

+ 5 - 5
src/main/java/com/scbfkj/uni/service/LoggerService.java

@@ -138,10 +138,10 @@ public class LoggerService {
                                 case "DB" -> {
                                     parameters.add(connectionStr);
                                     parameters.add(targetName);
-                                    parameters.add(datacontentStream.map(DataFormatUtil::toMap).map(dataContent -> ((Map<String, Object>) dataContent)).toList());
-                                    parameters.add("1");
-                                    parameters.add(null);
-                                    parameters.add(null);
+                                    parameters.add(new HashMap<>() {{
+                                        put("datacontent", datacontentStream.map(DataFormatUtil::toMap).map(dataContent -> ((Map<String, Object>) dataContent)).toList());
+                                        put("event", "1");
+                                    }});
                                     DataProcessService.processByAlgorithm("3", parameters);
                                 }
                             }
@@ -175,7 +175,7 @@ public class LoggerService {
         logsFiles.stream().filter(f -> errorFileNames.stream().filter(Objects::nonNull).noneMatch(errorFileName -> errorFileName.contains(f.getName()))).forEach(f -> {
             String connectionStr = CONNECTION.formatted(DIR + f.getName());
             try {
-                DataBase.exec(connectionStr, "delete  from logs");
+                DataBase.update(connectionStr, "delete  from logs");
                 HikariPool hikariPool = DataBase.dataSourcePools.remove(connectionStr);
                 if (Objects.nonNull(hikariPool)) hikariPool.shutdown();
 //                删除文件一直不成功 怀疑是数据库连接导致文件被使用导致一直删除不成功

+ 8 - 5
src/main/java/com/scbfkj/uni/service/SecurityService.java

@@ -128,9 +128,9 @@ public class SecurityService {
         Map<String, Object> data = new HashMap<>();
         try {
             String update = "update appconnectlog set expiretime=? where apptoken =? and requestip =? and appid=?";
-            boolean updateRow = DataBase.update(Config.getSecurityConnectionStr(), update, expiresTime, appToken, RequestUtil.getIpAddr(), appid);
+            int updateRow = DataBase.update(Config.getSecurityConnectionStr(), update, expiresTime, appToken, RequestUtil.getIpAddr(), appid);
 
-            if (updateRow) {
+            if (updateRow > 0) {
                 data.put("expirestime", DataFormatUtil.toString(expiresTime));
                 data.put("token", appToken);
                 return UniReturnUtil.success(data);
@@ -433,6 +433,9 @@ public class SecurityService {
     public Map<String, Object> permission() throws Exception {
         String userId = RequestUtil.getUserId();
         Map<String, Object> userInfo = RequestUtil.getUserInfo();
+        if (userInfo == null || userInfo.isEmpty()) {
+            return UniReturnUtil.fail("用户没有登录,或者用户令牌已过期");
+        }
         Object usergroupid = userInfo.get("usergroupid");
         List<Map<String, Object>> permission;
         if (Objects.equals("0", usergroupid.toString())) {
@@ -584,8 +587,8 @@ public class SecurityService {
                 update  userloginlog set
                        lastheartbeat = ?
                 where isexpires=0 and usertoken=? and sessionid=?""";
-        boolean updated = DataBase.update(Config.getSecurityConnectionStr(), updateSql, LocalDateTime.now(), userToken, sessionId);
-        if (updated) {
+        int updated = DataBase.update(Config.getSecurityConnectionStr(), updateSql, LocalDateTime.now(), userToken, sessionId);
+        if (updated > 0) {
             return UniReturnUtil.success("成功");
         } else {
             return UniReturnUtil.fail("失败");
@@ -612,7 +615,7 @@ public class SecurityService {
                   and sessionid = ?
                   and appid = ?
                   and requestip = ?""";
-        return DataBase.update(Config.getSecurityConnectionStr(), deleteSql, code, sessionId, appid, requestIp);
+        return DataBase.update(Config.getSecurityConnectionStr(), deleteSql, code, sessionId, appid, requestIp) > 0;
     }
 
 }

+ 2 - 1
src/main/resources/application.properties

@@ -5,4 +5,5 @@ server.port=9500
 app.container.code=dev
 spring.profiles.default=${ACTIVE:default}
 app.enable-flyway=false
-app.enable-reset-config=false
+app.enable-reset-config=false
+app.security.enable=true

+ 0 - 44
src/test/java/com/scbfkj/uni/library/script/DatabaseScriptUtilTest.java

@@ -1,44 +0,0 @@
-package com.scbfkj.uni.library.script;
-
-import com.scbfkj.uni.library.UniReturnUtil;
-import org.junit.jupiter.api.Test;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-//@SpringBootTest
-class DatabaseScriptUtilTest {
-
-    String x = """
-                        {
-              "url": "http://127.0.0.1:8080",
-              "method": "POST",
-              "header": {
-                "key1": ["value1","value2"],
-                "key2":"value"
-              },
-              "body": {
-                "key": "value"
-              },
-              "params": {
-                "key": "value"
-              }
-            }""";
-
-    @Test
-    void exec() throws Exception {
-        Map<String, Object> exec = DatabaseScriptUtil.exec("""
-                                {
-                  "jdbcUrl": "jdbc:mysql://127.0.0.1:3306/test",
-                  "username": "root",
-                  "password": "123@bigdata",
-                  "driverClassName": "com.mysql.cj.jdbc.Driver"
-                }
-                                """, "select * from interfacelog where  interfacelogid > 《id》", Collections.singletonList(new HashMap<>() {{
-            put("id", 1);
-        }}), "0", null, null, new DatabaseScriptUtil.Pageable(1L, 10L));
-        System.out.println(UniReturnUtil.success(new ArrayList<>()));
-    }
-}

+ 0 - 125
src/test/java/com/scbfkj/uni/process/DataBaseTest.java

@@ -1,125 +0,0 @@
-package com.scbfkj.uni.process;
-
-import com.scbfkj.uni.library.DataFormatUtil;
-import org.junit.jupiter.api.Test;
-
-import java.util.*;
-
-import static com.scbfkj.uni.library.script.DatabaseScriptUtil.exec;
-
-class DataBaseTest {
-    public static String tableName = "log_error";
-    static String connectionStr = """
-                            {
-              "jdbcUrl": "jdbc:mysql://120.26.64.82:3306/mid_log",
-              "username": "root",
-              "password": "123@bigdata",
-              "driverClassName": "com.mysql.cj.jdbc.Driver"
-            }""";
-    static List<Map<String, Object>> insert = Collections.singletonList(new HashMap<>() {{
-        put("filter", new HashMap<>() {{
-            put("id", 15);
-        }});
-        put("value", new HashMap<>() {{
-            put("id", 15);
-        }});
-    }});
-
-    static List<Map<String, Object>> update = Collections.singletonList(new HashMap<>() {{
-        put("filter", new HashMap<>() {{
-            put("id", 15);
-        }});
-        put("value", new HashMap<>() {{
-            put("serviceid", 999);
-            put("id", 15);
-        }});
-    }});
-
-    static List<Map<String, Object>> insertOrupdate = new ArrayList<>() {{
-        add(new HashMap<>() {{
-            put("filter", new HashMap<>() {{
-                put("id", 15);
-            }});
-            put("value", new HashMap<>() {{
-                put("serviceid", 1000);
-                put("id", 15);
-            }});
-        }});
-        add(new HashMap<>() {{
-            put("filter", new HashMap<>() {{
-                put("id", 16);
-            }});
-            put("value", new HashMap<>() {{
-                put("serviceid", 1000);
-                put("id", 16);
-            }});
-        }});
-    }};
-    static List<String> filterColumns = new ArrayList<>() {{
-        add("id");
-        add("serviceid");
-    }};
-    static List<Map<String, Object>> filterLines = new ArrayList<Map<String, Object>>() {{
-        add(new HashMap<>() {{
-            put("left", "(");
-            put("column", "id");
-            put("comparator", "=");
-            put("value", 15);
-            put("right", ")");
-        }});
-    }};
-
-    @Test
-    void testExec() throws Exception {
-
-
-        Map<String, Object> exec = exec(connectionStr, tableName, insert, "3", filterColumns, filterLines, null);
-        System.out.println(DataFormatUtil.toString(exec));
-        exec = exec(connectionStr, tableName, insert, "1", filterColumns, filterLines, null);
-        System.out.println(DataFormatUtil.toString(exec));
-        exec = exec(connectionStr, tableName, insert, "0", filterColumns, filterLines, null);
-        System.out.println(DataFormatUtil.toString(exec));
-        exec = exec(connectionStr, tableName, update, "2", filterColumns, filterLines, null);
-        System.out.println(DataFormatUtil.toString(exec));
-        exec = exec(connectionStr, tableName, update, "0", filterColumns, filterLines, null);
-        System.out.println(DataFormatUtil.toString(exec));
-        exec = exec(connectionStr, tableName, insertOrupdate, "6", filterColumns, filterLines, null);
-        System.out.println(DataFormatUtil.toString(exec));
-        exec = exec(connectionStr, tableName, insertOrupdate, "0", filterColumns, filterLines, null);
-        System.out.println(DataFormatUtil.toString(exec));
-    }
-
-    @Test
-    void testWhereStr() throws Exception {
-        Map<String, Object> exec = exec(connectionStr, "select * from %s where 《whereStr》".formatted(tableName), insert, "0", filterColumns, filterLines, null);
-        System.out.println(DataFormatUtil.toString(exec));
-    }
-
-    @Test
-    void testBookTitleSymbol() throws Exception {
-        Map<String, Object> exec = exec(connectionStr, "select * from %s where id=《id》".formatted(tableName), insert, "0", filterColumns, filterLines, null);
-        System.out.println(DataFormatUtil.toString(exec));
-    }
-
-    @Test
-    void testBookTitleSymbol2() throws Exception {
-        Map<String, Object> exec = exec(connectionStr, "select * from %s where id=《id》".formatted(tableName), insert.stream().map(it -> ((Map<String, Object>) it.get("filter"))).toList(), "0", filterColumns, filterLines, null);
-        System.out.println(DataFormatUtil.toString(exec));
-    }
-
-    @Test
-    void testFilter() throws Exception {
-        Map<String, Object> exec = exec(connectionStr, "select * from %s where 《whereStr》".formatted(tableName), List.of(new HashMap<>() {{
-            put("filter", new ArrayList<Map<String, Object>>() {{
-                add(new HashMap<>() {{
-                    put("left", "(");
-                    put("column", "id");
-                    put("comparator", "=");
-                    put("value", 15);
-                    put("right", ")");
-                }});
-            }});
-        }}), "0", filterColumns, filterLines, null);
-        System.out.println(DataFormatUtil.toString(exec));
-    }
-}