|
|
@@ -3,8 +3,12 @@ package com.uas.sso.sso.backend.config;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.uas.sso.common.util.HttpUtil;
|
|
|
+import com.uas.sso.dao.SyncLogDao;
|
|
|
import com.uas.sso.entity.App;
|
|
|
+import com.uas.sso.entity.SyncLog;
|
|
|
import com.uas.sso.entity.User;
|
|
|
+import com.uas.sso.logging.LoggerManager;
|
|
|
+import com.uas.sso.logging.SyncBufferedLogger;
|
|
|
import com.uas.sso.sso.backend.util.JacksonUtils;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
@@ -14,6 +18,7 @@ import java.util.concurrent.ExecutorService;
|
|
|
import org.apache.log4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.util.Assert;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
@@ -30,9 +35,12 @@ public class SyncThreadPool {
|
|
|
|
|
|
private final ExecutorService executorService;
|
|
|
|
|
|
+ private final SyncLogDao syncLogDao;
|
|
|
+
|
|
|
@Autowired
|
|
|
- public SyncThreadPool(ExecutorService executorService) {
|
|
|
+ public SyncThreadPool(ExecutorService executorService, SyncLogDao syncLogDao) {
|
|
|
this.executorService = executorService;
|
|
|
+ this.syncLogDao = syncLogDao;
|
|
|
}
|
|
|
|
|
|
public void transferDataToOtherPlatforms(String type, List<App> appList, JSONObject data, String message) {
|
|
|
@@ -75,13 +83,16 @@ public class SyncThreadPool {
|
|
|
|
|
|
HttpUtil.ResponseWrap res = HttpUtil.doPost(url, data, 30000);
|
|
|
if (!res.isSuccess()) {
|
|
|
+ logError(appId, message + ", 同步信息失败", JSON.toJSONString(data), res.getContent());
|
|
|
logger.error(String.format("%s:同步信息失败, %s, %s, %s", message, appId,
|
|
|
JSON.toJSONString(data), res.getContent()));
|
|
|
} else {
|
|
|
+ logInfo(appId, message + ", 同步信息成功", JSON.toJSONString(data));
|
|
|
logger.info(String.format("%s:同步信息成功, %s, %s", message, appId,
|
|
|
JSON.toJSONString(data)));
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
+ logError(appId, message + ", 同步信息失败", JSON.toJSONString(data), e.getMessage());
|
|
|
logger.error(String.format("%s:同步信息失败, %s, %s, %s", message, appId,
|
|
|
JSON.toJSONString(data), e.getMessage()));
|
|
|
}
|
|
|
@@ -90,6 +101,16 @@ public class SyncThreadPool {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void logError(String appId, String message, String data, String errorMessage) {
|
|
|
+ SyncLog log = new SyncLog(appId, message, data, "ERROR", errorMessage);
|
|
|
+ syncLogDao.save(log);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void logInfo(String appId, String message, String data) {
|
|
|
+ SyncLog log = new SyncLog(appId, message, data, "INFO");
|
|
|
+ syncLogDao.save(log);
|
|
|
+ }
|
|
|
+
|
|
|
private List<String> getBackUrl(List<App> appList, BackAppUrl backAppUrl) {
|
|
|
List<String> urls = new ArrayList<>();
|
|
|
|