提交 3c59f720 作者: 925993793@qq.com

传播路径查询优化

上级 332351ed
......@@ -14,11 +14,13 @@ import com.zzsn.event.entity.SubjectAnalysis;
import com.zzsn.event.service.*;
import com.zzsn.event.util.CalculateUtil;
import com.zzsn.event.util.HttpUtil;
import com.zzsn.event.util.RedisUtil;
import com.zzsn.event.vo.CountVO;
import com.zzsn.event.vo.PropagationPathVo;
import com.zzsn.event.vo.SubjectDataVo;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -54,6 +56,8 @@ public class EventAnalysisController {
private SubjectAnalysisService subjectAnalysisService;
@Autowired
private EsService esService;
@Autowired
private RedisUtil redisUtil;
@Value(("${serviceProject.url:}"))
private String SERVICE_PROJECT_URL;
......@@ -122,8 +126,12 @@ public class EventAnalysisController {
*/
@GetMapping("/propagationPath")
public Result<?> propagationPath(@RequestParam String eventId) {
PropagationPathVo pathVo = analysisService.propagationPath(eventId);
return Result.OK(pathVo);
String key = Constants.SUBJECT_ANALYSIS_PRE + Constants.PROPAGATION_KEY + eventId;
Object cacheObject = redisUtil.get(key);
if (ObjectUtils.isEmpty(cacheObject)) {
cacheObject = analysisService.propagationPath(eventId);
}
return Result.OK(cacheObject);
}
/**
......
......@@ -459,8 +459,10 @@ public class EsService {
List<? extends Terms.Bucket> buckets = groupOrigin.getBuckets();
for (Terms.Bucket bucket : buckets) {
String origin = bucket.getKeyAsString();
if (StringUtils.isNotEmpty(origin)) {
originList.add(origin);
}
}
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -13,11 +13,13 @@ import com.zzsn.event.util.DateUtil;
import com.zzsn.event.vo.PropagationPathVo;
import com.zzsn.event.vo.SubjectDataVo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author lkg
......@@ -106,6 +108,7 @@ public class AnalysisServiceImpl implements AnalysisService {
earlyList.forEach(e->allOriginList.add(e.getOrigin()));
for (SubjectDataVo subjectDataVo : earlyList) {
String origin = subjectDataVo.getOrigin();
if (StringUtils.isNotEmpty(origin)) {
PropagationPathVo second = new PropagationPathVo();
second.setName(origin);
secondList.add(second);
......@@ -123,6 +126,7 @@ public class AnalysisServiceImpl implements AnalysisService {
second.setChildren(lastList);
allOriginList.addAll(thirdList);
}
}
top.setChildren(secondList);
}
return top;
......
......@@ -48,7 +48,7 @@ spring:
url: jdbc:mysql://114.116.44.11:3306/clb_project?useUnicode=true&characterEncoding=utf-8&AllowPublicKeyRetrieval=True&serverTimezone=Asia/Shanghai&autoReconnect=true&rewriteBatchedStatements=true
username: ciglobal
password: qwer@9988&zzsn
# 多数据源配置
driver-class-name: com.mysql.cj.jdbc.Driver
multi-datasource1:
url: jdbc:mysql://114.116.44.11:3306/clb_xxl_job?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: ciglobal
......
......@@ -48,7 +48,7 @@ spring:
url: jdbc:mysql://114.116.44.11:3306/clb_project?useUnicode=true&characterEncoding=utf-8&AllowPublicKeyRetrieval=True&serverTimezone=Asia/Shanghai&autoReconnect=true&rewriteBatchedStatements=true
username: ciglobal
password: qwer@9988&zzsn
# 多数据源配置
driver-class-name: com.mysql.cj.jdbc.Driver
multi-datasource1:
url: jdbc:mysql://114.116.44.11:3306/clb_xxl_job?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: ciglobal
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论