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

传播路径查询优化

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