Browse Source

update_17

andy 1 year ago
parent
commit
0e205bb1d8

+ 33 - 15
src/main/java/com/scbfkj/uni/api/LogAop.java

@@ -1,8 +1,10 @@
 package com.scbfkj.uni.api;
 
+import com.scbfkj.uni.library.DataFormatUtil;
 import com.scbfkj.uni.library.RequestUtil;
 import com.scbfkj.uni.library.UniReturnUtil;
 import com.scbfkj.uni.process.DataBase;
+import com.scbfkj.uni.service.LoggerService;
 import com.scbfkj.uni.service.SecurityService;
 import com.scbfkj.uni.system.Config;
 import jakarta.annotation.Resource;
@@ -15,6 +17,7 @@ import org.springframework.stereotype.Component;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
 
+import java.time.LocalDateTime;
 import java.util.*;
 
 @Component
@@ -30,8 +33,7 @@ public class LogAop {
 
     @Around(value = "within( com.scbfkj.uni.api.*Api)")
     public ResponseEntity<Map<String, Object>> invokeAround(ProceedingJoinPoint joinPoint) {
-//        当前时间戳
-        long beforeTime = System.currentTimeMillis();
+        LocalDateTime requestTime = LocalDateTime.now();
 
         ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
 //            前端需求添加header
@@ -40,12 +42,15 @@ public class LogAop {
 //        }
         HttpServletRequest request = requestAttributes.getRequest();
 
-        try {
-
 //        请求
-            String uri = request.getRequestURI();
+        String uri = request.getRequestURI();
 //        请求参数
-            Object[] args = joinPoint.getArgs();
+        Object[] args = joinPoint.getArgs();
+        Object returnData = null;
+        String message = null;
+
+        try {
+
             if (Config.securityEnable) {
                 if (Objects.isNull(apiInfos) || apiInfos.isEmpty()) {
                     apiInfos = DataBase.query(Config.securityConnectionStr, "select * from apiinfo", new ArrayList<>() {{
@@ -87,20 +92,33 @@ public class LogAop {
                     }
                 }
             }
-            return ((ResponseEntity<Map<String, Object>>) joinPoint.proceed(args));
+            returnData = joinPoint.proceed(args);
+            return ((ResponseEntity<Map<String, Object>>) returnData);
         } catch (Throwable e) {
-            if(Config.debug) {
+            if (Config.debug) {
                 e.printStackTrace();
             }
 //            错误异常消息
-            return ResponseEntity.ok(UniReturnUtil.fail(e.getMessage()));
+            message = UniReturnUtil.getMessage(e);
+            return ResponseEntity.ok(UniReturnUtil.fail(message));
         } finally {
-            //        执行后时间戳
-            long afterTime = System.currentTimeMillis();
-//        执行时间
-            long execTime = afterTime - beforeTime;
-            System.out.println("执行时长:" + execTime);
-//            todo 写日志
+            Object finalReturnData = returnData;
+            LoggerService.log("interfacelog", new HashMap<>() {{
+                put("requesttime", requestTime);
+                put("requestpath", uri);
+                put("requestdata", DataFormatUtil.toString(args));
+                put("sessionid", RequestUtil.getSessionId());
+                put("returndata", DataFormatUtil.toString(finalReturnData));
+                try {
+                    put("applicationid", RequestUtil.getAppId());
+                } catch (Exception e) {
+                    if (Config.debug) {
+                        e.printStackTrace();
+                    } else {
+                        System.out.println(UniReturnUtil.getMessage(e));
+                    }
+                }
+            }});
         }
     }
 }

+ 17 - 3
src/main/java/com/scbfkj/uni/library/DataFormatUtil.java

@@ -8,6 +8,10 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
 import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
 
 import java.time.LocalDate;
 import java.time.LocalDateTime;
@@ -21,7 +25,16 @@ public final class DataFormatUtil {
 
     static {
         objectMapper.registerModule(new Jdk8Module());
-        objectMapper.registerModule(new JavaTimeModule());
+        //为jackjson注册序列化提供能力的对象
+        JavaTimeModule javaTimeModule = new JavaTimeModule();
+//系列化时间格式化
+        javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+        javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+//反序列化时间格式化
+        javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+        javaTimeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+
+        objectMapper.registerModule(javaTimeModule);
         objectMapper.setSerializationInclusion(JsonInclude.Include.ALWAYS);
     }
 
@@ -45,8 +58,8 @@ public final class DataFormatUtil {
         return objectMapper.readValue(source, ArrayNode.class);
     }
 
-    public static String toString(Object source)  {
-        if(Objects.isNull(source)) return null;
+    public static String toString(Object source) {
+        if (Objects.isNull(source)) return null;
         if (source instanceof String || source instanceof Number)
             return source.toString();
         if (source instanceof LocalDate result) {
@@ -103,6 +116,7 @@ public final class DataFormatUtil {
         }
         return Collections.singletonList(value);
     }
+
     public static Object[] toArray(Object value) {
         if (Objects.isNull(value)) return null;
 

+ 1 - 1
src/main/java/com/scbfkj/uni/library/UniReturnUtil.java

@@ -58,7 +58,7 @@ public class UniReturnUtil {
         return result;
     }
 
-    public static String getMessage(Exception e){
+    public static String getMessage(Throwable e){
         String detailMessage = Arrays.stream(e.getStackTrace()).limit(5).map(it -> "%s.%s:%s".formatted(it.getClassName(), it.getMethodName(), it.getLineNumber())).collect(Collectors.joining("\n"));
         return "异常消息:%s\n 错误详情:%s".formatted(e.getMessage(),detailMessage);
     }

+ 6 - 1
src/main/java/com/scbfkj/uni/library/script/JavaScriptEngineUtil.java

@@ -16,6 +16,7 @@ import java.lang.reflect.Method;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.time.LocalDateTime;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
@@ -140,7 +141,11 @@ public class JavaScriptEngineUtil {
                 try {
                     javaRefPool.returnObject(key, javaApply);
                 } catch (Exception e) {
-                    LoggerService.logSystemError(LocalDateTime.now(), null, UniReturnUtil.getMessage(e));
+                    LoggerService.log("systemerror",new HashMap<>(){{
+                        put("occurrencetime", LocalDateTime.now());
+                        put("occurrenceaddress",null);
+                        put("detailedmessage",UniReturnUtil.getMessage(e));
+                    }});
                 }
             }
         }

+ 6 - 1
src/main/java/com/scbfkj/uni/library/script/JsScriptEngineUtil.java

@@ -13,6 +13,7 @@ import org.graalvm.polyglot.Source;
 import org.graalvm.polyglot.Value;
 
 import java.time.LocalDateTime;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
 
@@ -61,7 +62,11 @@ public final class JsScriptEngineUtil {
                 try {
                     scriptPool.returnObject(script, function);
                 } catch (Exception e) {
-                    LoggerService.logSystemError(LocalDateTime.now(), null, UniReturnUtil.getMessage(e));
+                    LoggerService.log("systemerror",new HashMap<>(){{
+                        put("occurrencetime",LocalDateTime.now());
+                        put("occurrenceaddress",null);
+                        put("detailedmessage",UniReturnUtil.getMessage(e));
+                    }});
                 }
             }
         }

+ 13 - 11
src/main/java/com/scbfkj/uni/process/DataBase.java

@@ -15,7 +15,7 @@ import java.util.*;
 public class DataBase {
 
     private final static Map<String, Map<String, Object>> cacheDatas = new HashMap<>();
-    private  static List<Map<String, Object>> cacheConfigList = new ArrayList<>();
+    private static List<Map<String, Object>> cacheConfigList = new ArrayList<>();
     public final static Map<String, HikariPool> dataSourcePools = new HashMap<>();
 
 
@@ -51,9 +51,9 @@ public class DataBase {
             }
         }).toList();
 
-            String querySql = "select * from datacache where 1=?";
-        if ( !Objects.equals(querySql,sql)) {
-            cacheConfigList=  query(Config.centerConnectionStr,querySql,Collections.singletonList(new Object[]{1}));
+        String querySql = "select * from datacache where 1=?";
+        if (!Objects.equals(querySql, sql)) {
+            cacheConfigList = query(Config.centerConnectionStr, querySql, Collections.singletonList(new Object[]{1}));
         }
         cacheConfigList.stream().filter(it -> Objects.equals(it.get("querysql"), sql) && Objects.equals(it.get("connectset"), connectionStr)).findFirst().ifPresent(it -> {
             Object o = it.get("effectiveduration");
@@ -111,11 +111,10 @@ public class DataBase {
     }
 
 
-
     public static List<Map<String, Object>> query(String connectionStr, String sql, List<Map<String, Object>> argsList, List<String> filterColumns, List<Map<String, Object>> filterLines) throws Exception {
 
         sql = sql.replaceAll("(\\r)?\\n", " ");
-        String filterLineWhereStr =null;
+        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(
@@ -124,13 +123,13 @@ public class DataBase {
                     it.get("column"),
                     it.get("comparator"),
                     Objects.equals(it.get("comparator"), " is null ") ? "" : "?",
-                    !Objects.equals(it.get("comparator"), " is null ")?" ":it.get("value"),
+                    !Objects.equals(it.get("comparator"), " is null ") ? " " : it.get("value"),
                     it.getOrDefault("right", ""),
                     it.getOrDefault("connector", "")
             );
         }
-        if (Objects.nonNull(filterLineWhereStr) ) {
-            sql = " %s %s and %s ".formatted(sql, sql.contains(" where ") ? " 1 = 1" : " where ", Objects.isNull(filterLineWhereStr)?" 1=1 ":filterLineWhereStr);
+        if (Objects.nonNull(filterLineWhereStr)) {
+            sql = " %s %s and %s ".formatted(sql, sql.contains(" where ") ? " 1 = 1" : " where ", Objects.isNull(filterLineWhereStr) ? " 1=1 " : filterLineWhereStr);
         }
         if (Objects.nonNull(filterColumns) && !filterColumns.isEmpty()) {
             sql = "select %s from ( %s ) T".formatted(String.join(",", filterColumns), sql);
@@ -162,7 +161,7 @@ public class DataBase {
         } else {
             for (Map<String, Object> map : argsList) {
                 List<Object> args = new ArrayList<>();
-                map= ((Map<String,Object>) map.getOrDefault("filter", map));
+                map = ((Map<String, Object>) map.getOrDefault("filter", map));
                 for (String name : names) {
                     args.add(map.get(name));
                 }
@@ -184,7 +183,10 @@ public class DataBase {
         JsonNode password = jsonNode.get("password");
         JsonNode driverClassName = jsonNode.get("driverClassName");
         HikariPool dataSourcePool = createDataSourcePool(jdbcUrl.asText(), Objects.isNull(username) ? null : username.asText(), Objects.isNull(password) ? null : password.asText(), Objects.isNull(driverClassName) ? null : driverClassName.asText(), connectionStr);
-        dataSourcePools.put(connectionStr, dataSourcePool);
+        JsonNode enableCache = jsonNode.get("enableCache");
+        if (Objects.isNull(enableCache) || !enableCache.asBoolean()) {
+            dataSourcePools.put(connectionStr, dataSourcePool);
+        }
         return dataSourcePool;
     }
 

+ 18 - 10
src/main/java/com/scbfkj/uni/service/DataProcessService.java

@@ -146,16 +146,24 @@ public class DataProcessService {
         } finally {
 //                    不管成功还是失败都记录日志
             if (Config.debug || Objects.nonNull(serviceInfo) && Objects.equals("1", serviceInfo.get("enablelog"))) {
-                LoggerService.logService(
-                        startDateTime,
-                        serviceId,
-                        DataFormatUtil.toString(resource),
-                        DataFormatUtil.toString(preResource),
-                        LocalDateTime.now(),
-                        Objects.nonNull(message) ? "-1" : "0",
-                        message,
-                        lifecycleid
-                );
+                String target="servicelog";
+                if(Objects.nonNull(message)){
+                    target="serviceerrlog";
+                }
+                LocalDateTime finalStartDateTime = startDateTime;
+                String finalServiceId = serviceId;
+                String finalMessage = message;
+                String finalLifecycleid = lifecycleid;
+                LoggerService.log(target,new HashMap<>(){{
+                    put("begintime", finalStartDateTime);
+                    put("endtime",LocalDateTime.now());
+                    put("serviceid", finalServiceId);
+                    put("resource",DataFormatUtil.toString(resource));
+                    put("prepesource",DataFormatUtil.toString(preResource));
+                    put("returnmessage", finalMessage);
+                    put("lifecycleid", finalLifecycleid);
+                }});
+
             }
         }
 

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

@@ -1,237 +1,58 @@
 package com.scbfkj.uni.service;
 
-import com.jayway.jsonpath.JsonPath;
 import com.scbfkj.uni.library.DataFormatUtil;
 import com.scbfkj.uni.library.UniReturnUtil;
-import com.scbfkj.uni.library.script.DatabaseScriptUtil;
 import com.scbfkj.uni.process.DataBase;
-import com.scbfkj.uni.process.Elasticsearch;
-import com.scbfkj.uni.process.Kafka;
 import com.scbfkj.uni.system.Config;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.stereotype.Component;
-import org.springframework.util.FileCopyUtils;
 
 import java.io.File;
-import java.io.FileNotFoundException;
-import java.sql.*;
-import java.time.LocalDateTime;
-import java.util.*;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
 
-@Component
 public class LoggerService {
 
-
-    private static Map<String, Integer> flag = new HashMap<>();
-
-
-    //写日志方法:log()--提供给程序内部使用
-    //用户操作日志
-    public static void logUser(LocalDateTime requestTime, String requestIP, String requestPath
-            , String requestData, String sessionID, LocalDateTime returnDate
-            , String returnData, String returnCode, String returnMessage
-            , String dataObjectID, String applicationID, String userID) {
-        //调用工具类的获取雪花编号getUniqueNumber(时间戳+当前容器编号+0)
-        //打开雪花编号对应的临时Sqlite(日志文件夹下)
-        //写入数据
-    }
-
-    //接口日志
-    public static void logInterface(LocalDateTime requestTime, String requestIP, String requestPath
-            , String requestData, String sessionID, LocalDateTime returnDate
-            , String returnData, String returnCode, String returnMessage
-            , String dataObjectID, String applicationID) {
-        //
-        //调用工具类的获取雪花编号getUniqueNumber(时间戳+当前容器编号+0)
-        //打开雪花编号对应的临时Sqlite(日志文件夹下)
-        //写入数据
-    }
-
-    /**
-     * @param beginTime     算法开始时间
-     * @param serviceID     服务id
-     * @param resource      算法数据历史
-     * @param preResource   前置算法
-     * @param endTime       算法结束时间
-     * @param returnCode    算法结果成功失败编号
-     * @param returnMessage 算法失败错误消息
-     * @param dataObjectID  数据声明周期
-     */
-    //服务日志
-    public static void logService(LocalDateTime beginTime, String serviceID, String resource, String preResource,
-                                  LocalDateTime endTime,
-                                  String returnCode, String returnMessage
-            , String dataObjectID) {
-        //调用工具类的获取雪花编号getUniqueNumber(时间戳+当前容器编号+0)
-        //打开雪花编号对应的临时Sqlite(日志文件夹下)
-        //写入数据
-
-        try {
-            String tableName = "servicelog";
-            String connectionStr = getTimeConnection();
-            if (!Objects.equals(returnCode, "0")) {
-                tableName = "serviceerrlog";
+    private static final String connection = """
+            {
+              "jdbcUrl": "jdbc:sqlite:%s",
+              "driverClassName": "org.sqlite.JDBC",
+              "enableCache":false
+            }
+            """;
+
+    private final static Set<Long> fileNames = new HashSet<>();
+    private static final String dbFileName = "logs/%s.sqlite";
+
+    public static void log(String target, Map<String, Object> data) {
+        long filename = System.currentTimeMillis() / Config.splitCount;
+
+        String filePath = dbFileName.formatted( filename);
+        String connectionStr = connection.formatted(filePath);
+        synchronized (fileNames) {
+            if (!fileNames.contains(filename)) {
+                if (!new File(filePath).exists()) {
+                    try {
+                        DataBase.exec(connectionStr, """
+                                create table logs
+                                (
+                                    logid         Integer
+                                        primary key autoincrement,
+                                    target     TEXT,
+                                    datacontent      TEXT
+                                )""");
+                    } catch (Exception e) {
+                        System.out.println(UniReturnUtil.getMessage(e));
+                    }
+                }
+                fileNames.add(filename);
+                fileNames.removeIf(it -> it + 1000 < filename);
             }
-            insertLog(connectionStr,
-                    "insert into %s ('begintime','endtime','serviceid','resource','preresource','returncode','returnmessage','lifecycleid') values (?,?,?,?,?,?,?,?,?)".formatted(tableName),
-                    List.of(beginTime, endTime, serviceID, resource, preResource, returnCode, returnMessage, dataObjectID));
-        } catch (Exception e) {
-            e.printStackTrace();
-            System.out.println(UniReturnUtil.getMessage(e));
         }
-    }
-
-    //系统异常日志
-    public static void logSystemError(LocalDateTime occurrenceTime, String occurrenceAddress
-            , String detailedMessage) {
-        //调用工具类的获取雪花编号getUniqueNumber(时间戳+当前容器编号+0)
-        //打开雪花编号对应的临时Sqlite(日志文件夹下)
-        //写入数据
-
         try {
-            String tableName = "systemerrlog";
-            String connectionStr = getTimeConnection();
-            insertLog(connectionStr,
-                    "insert into %s ('occurrenceTime','occurrenceAddress','detailedMessage') values (?,?,?)".formatted(tableName),
-                    List.of(occurrenceTime, occurrenceAddress, detailedMessage));
+            DataBase.updateBatch(connectionStr, "insert into logs (target,datacontent) values(?,?)", Collections.singletonList(new Object[]{target, DataFormatUtil.toString(data)}));
         } catch (Exception e) {
             System.out.println(UniReturnUtil.getMessage(e));
         }
     }
-
-    private synchronized static String getTimeConnection() throws Exception {
-        long timeMillis = System.currentTimeMillis();
-        long name = timeMillis / Config.splitCount;
-
-
-        String fileName = "logs" + File.separator + name + ".sqlite";
-        File file = new File(fileName);
-        HashMap<String, Object> connectionMap = new HashMap<>();
-
-        connectionMap.put("jdbcUrl", "jdbc:sqlite:" + file.getPath());
-        connectionMap.put("driverClassName", "org.sqlite.JDBC");
-        String newConnection = DataFormatUtil.toString(connectionMap);
-        if (!file.exists()) {
-            ClassPathResource resource = new ClassPathResource("template.sqlite");
-            File template = resource.getFile();
-            FileCopyUtils.copy(template, file);
-        }
-        return newConnection;
-    }
-//
-//    /**
-//     * 读取日志并发送到目标存储介质,最后删除已经发送成功的日志
-//     *
-//     * @param fileName
-//     * @return
-//     */
-//    private static void apply(String fileName) {
-//        String newConnection = logConnection.replace("log_", fileName);
-//        String tableName = fileName.substring(fileName.lastIndexOf("_") + 1);
-//        try {
-//            List<Map<String, Object>> result = DataBase.query(newConnection, "select * from %s where 1=?".formatted(tableName), Collections.singletonList(new Object[]{1}));
-//            if (result.isEmpty()) {
-//                if (!flag.containsKey(fileName)) {
-//                    flag.put(fileName, 0);
-//                }
-//                int value = flag.get(fileName) + 1;
-//                if (value > 10) {
-//                    new File("logs" + File.separator + fileName).delete();
-//                    flag.remove(fileName);
-//                    return;
-//                } else {
-//                    flag.put(fileName, value);
-//
-//                }
-//
-//            } else {
-//                if (!flag.containsKey(fileName)) {
-//                    flag.put(fileName, 0);
-//                }
-//                flag.put(fileName, 0);
-//            }
-////           删除成功的日志
-//            if (!result.isEmpty()) {
-//                for (String target : Config.targets) {
-//                    Object type = JsonPath.read(target, "$.type");
-//                    if (Objects.isNull(type)) throw new RuntimeException("日志输出目标类型没有配置");
-//                    switch (type.toString()) {
-//                        case "DB" -> {
-//                            DatabaseScriptUtil.exec(target, tableName, result, "1", null, null);
-//                        }
-//                        case "KAFKA" -> {
-//                            Kafka.sendMessage(target, tableName, result.stream().map(DataFormatUtil::toString).toList());
-//                        }
-//                        case "ES" -> {
-//                            Elasticsearch.send(target, tableName, result);
-//                        }
-//                    }
-//                }
-//                DatabaseScriptUtil.exec(newConnection, tableName, result.stream().map(it -> (Map<String, Object>) new HashMap<String, Object>() {{
-//                    put("logid", it.get("logid"));
-//                }}).toList(), "3", null, null);
-//            }
-//        } catch (Exception e) {
-//            System.out.println(UniReturnUtil.getMessage(e));
-//        }
-//
-//    }
-//
-//    public static void sendLog() throws FileNotFoundException {
-//        File logDir = new File("logs");
-//        if (logDir.exists()) {
-//            if (logDir.isDirectory()) {
-//                File[] files = logDir.listFiles();
-//
-//
-//                List<File> logs = new ArrayList<>();
-//                if (files != null) {
-//                    logs = Arrays.stream(files).toList();
-//                }
-//                logs.parallelStream().forEach(it -> {
-//                    String fileName = it.getName();
-//                    apply(fileName);
-//                });
-//
-//            } else {
-//                throw new FileNotFoundException("logs 不是文件夹");
-//            }
-//        } else {
-//            throw new FileNotFoundException("日志目录没有找到");
-//        }
-//    }
-
-    private static void insertLog(String connection, String sql, List<Object> args) {
-        try (
-                Connection connect = createConnection(connection);
-                PreparedStatement preparedStatement = connect.prepareStatement(sql)) {
-            for (int i = 0; i < args.size(); i++) {
-                preparedStatement.setObject(i + 1, args.get(i));
-            }
-            preparedStatement.executeUpdate();
-        } catch (SQLException | ClassNotFoundException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    private List<Map<String, Object>> query(String connection, String sql) {
-        try (
-                Connection connect = createConnection(connection);
-                PreparedStatement preparedStatement = connect.prepareStatement(sql)) {
-
-            ResultSet resultSet = preparedStatement.executeQuery();
-            return DataBase.getResult(connection, sql, resultSet);
-        } catch (SQLException | ClassNotFoundException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    private static Connection createConnection(String connection) throws SQLException, ClassNotFoundException {
-        Map<?, ?> map = DataFormatUtil.toMap(connection);
-        String jdbcUrl = DataFormatUtil.toString(map.get("jdbcUrl"));
-        String driverClassName = DataFormatUtil.toString(map.get("driverClassName"));
-        Class.forName(driverClassName);
-        Driver driver = DriverManager.getDriver(jdbcUrl);
-        return driver.connect(jdbcUrl, new Properties());
-    }
 }

+ 2 - 2
src/main/java/com/scbfkj/uni/system/Config.java

@@ -21,8 +21,8 @@ public class Config {
 
     public static List<String> targets = new ArrayList<>();
 
-//    本地日志缓存分片
-    public static int splitCount=1000;
+//    本地日志缓存分片 10分钟
+    public static int splitCount=600000;
 
 
 

+ 5 - 1
src/main/java/com/scbfkj/uni/system/SystemInit.java

@@ -10,6 +10,7 @@ import org.springframework.stereotype.Component;
 
 import java.io.*;
 import java.time.LocalDateTime;
+import java.util.HashMap;
 import java.util.List;
 
 
@@ -58,7 +59,10 @@ public class SystemInit {
 //                System.out.println(exception.getMessage());
 //            }
 //        }, "* * * * * *");
-        LoggerService.logSystemError(LocalDateTime.now(), "", "");
+//        LoggerService.logSystemError(LocalDateTime.now(), "", "");
+        LoggerService.log("systemerror",new HashMap<>(){{
+            put("occurrencetime",LocalDateTime.now());
+        }});
 
     }