|
@@ -1,5 +1,6 @@
|
|
package org.bfkj;
|
|
package org.bfkj;
|
|
|
|
|
|
|
|
+import com.ibm.disthub2.impl.client.BaseConfig;
|
|
import org.bfkj.application.DataProcess;
|
|
import org.bfkj.application.DataProcess;
|
|
import org.bfkj.application.ServiceInputControl;
|
|
import org.bfkj.application.ServiceInputControl;
|
|
import org.bfkj.config.*;
|
|
import org.bfkj.config.*;
|
|
@@ -8,6 +9,7 @@ import org.bfkj.utils.MapTools;
|
|
import org.bfkj.utils.MyDbHelper;
|
|
import org.bfkj.utils.MyDbHelper;
|
|
import org.bfkj.utils.ScheduleUtil;
|
|
import org.bfkj.utils.ScheduleUtil;
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.boot.SpringApplication;
|
|
import org.springframework.boot.SpringApplication;
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|
@@ -27,18 +29,20 @@ import java.util.*;
|
|
@EnableScheduling
|
|
@EnableScheduling
|
|
public class MainFactoryApplication implements InitializingBean {
|
|
public class MainFactoryApplication implements InitializingBean {
|
|
|
|
|
|
|
|
+
|
|
|
|
+ @Value("${baseConfig.sourceData:true}")
|
|
|
|
+ private String sourceData;
|
|
|
|
+
|
|
private final String INSERT_SQL = "INSERT INTO log_success ( success, location, logContent, createtime, serviceId, workId, event, iNDataContent, outDataContent, calculationLocation, dataObjectId) 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 ERROR_SQL = "INSERT INTO log_error ( success, location, logContent, createtime, serviceId, workId, event, iNDataContent, outDataContent, calculationLocation, dataObjectId) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
|
|
|
private RemoteDB remoteDB;
|
|
private RemoteDB remoteDB;
|
|
private RemoteLogDB remoteLogDB;
|
|
private RemoteLogDB remoteLogDB;
|
|
|
|
|
|
- private final BaseConfig baseConfig;
|
|
|
|
|
|
|
|
- public MainFactoryApplication(RemoteDB remoteDB, RemoteLogDB remoteLogDB, BaseConfig baseConfig) {
|
|
|
|
|
|
+ public MainFactoryApplication(RemoteDB remoteDB, RemoteLogDB remoteLogDB) {
|
|
this.remoteDB = remoteDB;
|
|
this.remoteDB = remoteDB;
|
|
this.remoteLogDB = remoteLogDB;
|
|
this.remoteLogDB = remoteLogDB;
|
|
- this.baseConfig = baseConfig;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/*服务初始化: 启动服务*/
|
|
/*服务初始化: 启动服务*/
|
|
@@ -249,7 +253,9 @@ public class MainFactoryApplication implements InitializingBean {
|
|
Map<String, List<Object>> logSuccessMap = LogUtils.logSuccessMapList;
|
|
Map<String, List<Object>> logSuccessMap = LogUtils.logSuccessMapList;
|
|
Map<String, List<Object>> logErrorMap = LogUtils.logErrorMapList;
|
|
Map<String, List<Object>> logErrorMap = LogUtils.logErrorMapList;
|
|
/*批量写日志*/
|
|
/*批量写日志*/
|
|
- if (logSuccessMap.size() == 0 && logErrorMap.size() == 0) return;
|
|
|
|
|
|
+ if (logSuccessMap.size() == 0 && logErrorMap.size() == 0) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
long current = System.currentTimeMillis();
|
|
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<>();
|
|
List<Object> logSuccessList = new ArrayList<>();
|
|
@@ -270,8 +276,12 @@ public class MainFactoryApplication implements InitializingBean {
|
|
}
|
|
}
|
|
|
|
|
|
try {
|
|
try {
|
|
- if (logSuccessList.size() > 0) logDbHelper.JDBCBatch(INSERT_SQL, logSuccessList, null);
|
|
|
|
- if (logErrorList.size() > 0) logDbHelper.JDBCBatch(ERROR_SQL, logErrorList, null);
|
|
|
|
|
|
+ if (logSuccessList.size() > 0) {
|
|
|
|
+ logDbHelper.JDBCBatch(INSERT_SQL, logSuccessList, null);
|
|
|
|
+ }
|
|
|
|
+ if (logErrorList.size() > 0) {
|
|
|
|
+ logDbHelper.JDBCBatch(ERROR_SQL, logErrorList, null);
|
|
|
|
+ }
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
System.out.println("日志记录异常" + LogUtils.getException(e));
|
|
System.out.println("日志记录异常" + LogUtils.getException(e));
|
|
}
|
|
}
|
|
@@ -289,7 +299,7 @@ public class MainFactoryApplication implements InitializingBean {
|
|
maplogDB.put("driver-class-name", maplogDB.get("driverClassName"));
|
|
maplogDB.put("driver-class-name", maplogDB.get("driverClassName"));
|
|
AppConfig.REMOTE_DB_LOG_CONNECT = MapTools.objToJSONStr(maplogDB);
|
|
AppConfig.REMOTE_DB_LOG_CONNECT = MapTools.objToJSONStr(maplogDB);
|
|
AppConfig.serviceURL = remoteDB.getServiceURL();
|
|
AppConfig.serviceURL = remoteDB.getServiceURL();
|
|
- AppConfig.SOURCE_DATA = baseConfig.getSourceData();
|
|
|
|
|
|
+ AppConfig.SOURCE_DATA = sourceData;
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
System.out.println("配置文件中,连接数据库信息错误");
|
|
System.out.println("配置文件中,连接数据库信息错误");
|