|
@@ -18,6 +18,8 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.util.*;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* 初始化
|
|
@@ -27,9 +29,9 @@ import java.util.*;
|
|
|
@EnableScheduling
|
|
|
public class MainFactoryApplication {
|
|
|
|
|
|
- private final String INSERT_SQL = "INSERT INTO log_success ( success, location, logContent, createtime, serviceId, workId, event, iNDataContent, outDataContent, calculationLocation, dataObjectId) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
- private final String ERROR_SQL = "INSERT INTO log_error ( success, location, logContent, createtime, serviceId, workId, event, iNDataContent, outDataContent, calculationLocation, dataObjectId) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
- private final String FULL_DATA_SQL = "INSERT INTO log_fulldata ( dataObjectId, FULL_DATA_SQL) VALUES (?,?)";
|
|
|
+ private final String INSERT_SQL = "INSERT INTO log_success ( success, location, logContent, createtime, serviceId, workId, event, iNDataContent, outDataContent, calculationLocation, dataObjectId) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
+ private final String ERROR_SQL = "INSERT INTO log_error ( success, location, logContent, createtime, serviceId, workId, event, iNDataContent, outDataContent, calculationLocation, dataObjectId) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
+ private final String FULL_DATA_SQL = "INSERT INTO log_fulldata ( dataObjectId, FULL_DATA_SQL) VALUES (?,?)";
|
|
|
|
|
|
/*服务初始化: 启动服务*/
|
|
|
public static void main(String[] args) {
|
|
@@ -296,21 +298,21 @@ public class MainFactoryApplication {
|
|
|
public void batchLog() {
|
|
|
Map<String, List<Object>> logSuccessMap = LogUtils.logSuccessMapList;
|
|
|
long current = System.currentTimeMillis();
|
|
|
- List<String> successList = logSuccessMap.keySet().stream().filter(key -> Long.parseLong(key) < current ).toList();
|
|
|
+ List<String> successList = logSuccessMap.keySet().stream().filter(key -> Long.parseLong(key) < current).toList();
|
|
|
List<Object> logSuccessList = new ArrayList<>();
|
|
|
for (String currentTime : successList) {
|
|
|
logSuccessList.addAll(logSuccessMap.get(currentTime));
|
|
|
logSuccessMap.remove(currentTime);
|
|
|
}
|
|
|
Map<String, List<Object>> logErrorMap = LogUtils.logErrorMapList;
|
|
|
- List<String> errorList = logErrorMap.keySet().stream().filter(key -> Long.parseLong(key) < current ).toList();
|
|
|
+ List<String> errorList = logErrorMap.keySet().stream().filter(key -> Long.parseLong(key) < current).toList();
|
|
|
List<Object> logErrorList = new ArrayList<>();
|
|
|
for (String currentTime : errorList) {
|
|
|
logErrorList.addAll(logErrorMap.get(currentTime));
|
|
|
logErrorMap.remove(currentTime);
|
|
|
}
|
|
|
Map<String, List<Object>> logSourceMap = LogUtils.sourceMapList;
|
|
|
- List<String> sourceList = logSourceMap.keySet().stream().filter(key -> Long.parseLong(key) < current ).toList();
|
|
|
+ List<String> sourceList = logSourceMap.keySet().stream().filter(key -> Long.parseLong(key) < current).toList();
|
|
|
List<Object> logSourceList = new ArrayList<>();
|
|
|
for (String currentTime : sourceList) {
|
|
|
logSourceList.addAll(logSourceMap.get(currentTime));
|
|
@@ -322,13 +324,11 @@ public class MainFactoryApplication {
|
|
|
if (Objects.nonNull(myDbHelper.getErrorMessage())) {
|
|
|
System.out.println("获取远程数据库失败:写入日志失败");
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
try {
|
|
|
- if (logSuccessList.size() > 0) myDbHelper.JDBCBatch(INSERT_SQL, logSuccessList,null);
|
|
|
- if (logErrorList.size() > 0) myDbHelper.JDBCBatch(ERROR_SQL, logErrorList,null);
|
|
|
+ if (logSuccessList.size() > 0) myDbHelper.JDBCBatch(INSERT_SQL, logSuccessList, null);
|
|
|
+ if (logErrorList.size() > 0) myDbHelper.JDBCBatch(ERROR_SQL, logErrorList, null);
|
|
|
if (logSourceList.size() > 0) {
|
|
|
- myDbHelper.JDBCBatch(FULL_DATA_SQL, logSourceList,null);
|
|
|
+ myDbHelper.JDBCBatch(FULL_DATA_SQL, logSourceList, null);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
System.out.println("日志记录异常" + LogUtils.getException(e));
|