|
@@ -18,8 +18,6 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.util.*;
|
|
|
-import java.util.regex.Matcher;
|
|
|
-import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* 初始化
|
|
@@ -318,12 +316,12 @@ public class MainFactoryApplication {
|
|
|
logSourceList.addAll(logSourceMap.get(currentTime));
|
|
|
logSourceMap.remove(currentTime);
|
|
|
}
|
|
|
-
|
|
|
/*批量写日志*/
|
|
|
- if (logErrorList.size() ==0 &&logSourceList.size() ==0&& logSuccessList.size()==0 ) return;
|
|
|
- MyDbHelper myDbHelper = ObjectMap.getordropMyDbHelper(AppConfig.getSystemParams(AppConfig.REMOTE_DB_CONNECT));
|
|
|
- if (Objects.nonNull(myDbHelper.getErrorMessage())) {
|
|
|
+ if (logErrorList.size() == 0 && logSourceList.size() == 0 && logSuccessList.size() == 0) return;
|
|
|
+ MyDbHelper myDbHelper = getDbHelper();
|
|
|
+ if (Objects.isNull(myDbHelper)){
|
|
|
System.out.println("获取远程数据库失败:写入日志失败");
|
|
|
+ return;
|
|
|
}
|
|
|
try {
|
|
|
if (logSuccessList.size() > 0) myDbHelper.JDBCBatch(INSERT_SQL, logSuccessList, null);
|
|
@@ -335,4 +333,17 @@ public class MainFactoryApplication {
|
|
|
System.out.println("日志记录异常" + LogUtils.getException(e));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private MyDbHelper baseDbHelper;
|
|
|
+
|
|
|
+ public MyDbHelper getDbHelper() {
|
|
|
+ if (Objects.isNull(baseDbHelper)) {
|
|
|
+ baseDbHelper = new MyDbHelper(AppConfig.getSystemParams(AppConfig.REMOTE_DB_CONNECT));//获取底座数据库对象
|
|
|
+ if (Objects.nonNull(baseDbHelper.getErrorMessage())) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return baseDbHelper;
|
|
|
+
|
|
|
+ }
|
|
|
}
|