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:
@@ -32,11 +32,13 @@
|
|||||||
<artifactId>xboe-module-course</artifactId>
|
<artifactId>xboe-module-course</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.xboe</groupId>
|
<groupId>com.xboe</groupId>
|
||||||
<artifactId>xboe-module-event</artifactId>
|
<artifactId>xboe-module-event</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.xboe</groupId>
|
<groupId>com.xboe</groupId>
|
||||||
<artifactId>xboe-module-idconfig</artifactId>
|
<artifactId>xboe-module-idconfig</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();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user