mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-10 19:36:50 +08:00
提交修改
This commit is contained in:
@@ -23,11 +23,6 @@
|
||||
<artifactId>xboe-core</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xboe</groupId>
|
||||
<artifactId>xboe-module-event</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.boe</groupId>
|
||||
<artifactId>httpsdk</artifactId>
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.xboe.stat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.api.TokenProxy;
|
||||
import com.xboe.core.event.IEventDataSender;
|
||||
import com.xboe.core.utils.OkHttpUtil;
|
||||
import com.xboe.standard.BaseConstant;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 事件数据发送实现,如果是云环境,只需要修改此类的实现就可以了
|
||||
* @author seastar
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class EventDataSender implements IEventDataSender{
|
||||
|
||||
@Autowired
|
||||
private OkHttpUtil okHttpUtil;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Override
|
||||
public void send(String title, String eventKey, String content, String objId, String objType, String objInfo,
|
||||
String aid, String aname,String author) {
|
||||
String statBaseUrl=SysConstant.getConfigValue("xboe.stat.base.url");
|
||||
if(StringUtils.isBlank(statBaseUrl)) {
|
||||
log.error("发送事件失败:未配置【xboe.stat.base.url】的值");
|
||||
return;
|
||||
}
|
||||
String urlPre="/xboe/m/stat/event/send";
|
||||
//案例同步不需要token
|
||||
if(eventKey.equals("SyncCase")) {
|
||||
urlPre ="/inner/stat/event/send";
|
||||
}
|
||||
|
||||
final String url = statBaseUrl + urlPre;
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("title", title);
|
||||
params.put("source", "all");
|
||||
params.put("content", content);
|
||||
params.put("objId", objId);
|
||||
params.put("key", eventKey);
|
||||
params.put("objType", objType);
|
||||
params.put("objInfo", objInfo);
|
||||
params.put("aid", aid);
|
||||
params.put("aname", aname);
|
||||
params.put("parameters","");
|
||||
String token = TokenProxy.getToken(request);
|
||||
//最后采用异常发送,不影响当前进程
|
||||
|
||||
new Thread(()->{
|
||||
try {
|
||||
ObjectMapper mapper=new ObjectMapper();
|
||||
String json =mapper.writeValueAsString(params);
|
||||
//String[] headers=new String[] {"token",token};
|
||||
String[] headers=new String[] {BaseConstant.HTTP_ACCESS_TOKEN,token};
|
||||
|
||||
String responseStr = okHttpUtil.doPostJson(url, json,headers);
|
||||
if(responseStr.indexOf("\"status\":200")==-1) {
|
||||
log.error("发送事件失败:"+responseStr);
|
||||
log.info("【发送的token】"+headers[0]+": "+headers[1]);
|
||||
}
|
||||
}catch(Exception e) {
|
||||
log.error("发送事件错误",e);
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -13,6 +13,9 @@ logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
|
||||
## xboe config
|
||||
xboe.api.cross_filter=true
|
||||
|
||||
## 案例同步发事件的接口
|
||||
xboe.stat.base.url=http://127.0.0.1:9090
|
||||
|
||||
|
||||
## 案例接口配置,init 是否需要初始化
|
||||
xboe.case.sync.init=true
|
||||
|
||||
@@ -12,6 +12,9 @@ logging.level.org.hibernate.SQL=ERROR
|
||||
## xboe config
|
||||
xboe.api.cross_filter=true
|
||||
|
||||
## 案例同步发事件的接口
|
||||
xboe.stat.base.url=https://u.boe.com/statApi
|
||||
|
||||
|
||||
## 案例接口配置
|
||||
## 案例接口配置,init 是否需要初始化
|
||||
|
||||
@@ -14,6 +14,9 @@ logging.level.org.hibernate.SQL=ERROR
|
||||
## xboe config
|
||||
xboe.api.cross_filter=true
|
||||
|
||||
## 案例同步发事件的接口
|
||||
xboe.stat.base.url=https://u.boe.com/statApi
|
||||
|
||||
|
||||
## 案例接口配置
|
||||
## 案例接口配置,init 是否需要初始化
|
||||
|
||||
@@ -12,6 +12,9 @@ spring.datasource.password=ENC(MaC28GJw2JcbH8Lil0CrqSDTYxX49FJ0rxcmHH2pX0k=)
|
||||
## xboe config
|
||||
xboe.api.cross_filter=true
|
||||
|
||||
## 案例同步发事件的接口
|
||||
xboe.stat.base.url=https://u-pre.boe.com/statApi
|
||||
|
||||
|
||||
## 案例接口配置
|
||||
## 案例接口配置,init 是否需要初始化
|
||||
|
||||
Reference in New Issue
Block a user