提交 a34f4958 作者: 925993793@qq.com

调试问题修改

上级 a540eacb
...@@ -73,6 +73,8 @@ public class EventAnalysisController { ...@@ -73,6 +73,8 @@ public class EventAnalysisController {
private EventAnalysisVersionRecordService eventAnalysisVersionRecordService; private EventAnalysisVersionRecordService eventAnalysisVersionRecordService;
@Autowired @Autowired
private CommonService commonService; private CommonService commonService;
@Autowired
private IEventService eventService;
/** /**
...@@ -115,9 +117,14 @@ public class EventAnalysisController { ...@@ -115,9 +117,14 @@ public class EventAnalysisController {
* @date 2024/1/24 * @date 2024/1/24
*/ */
@GetMapping("/total") @GetMapping("/total")
public Result<?> totalAndMax(@RequestParam String eventId, @RequestParam String startTime, public Result<?> totalAndMax(@RequestParam String eventId,
@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime, @RequestParam(required = false) String endTime,
@RequestParam(defaultValue = "1") Integer type) { @RequestParam(defaultValue = "1") Integer type) {
Event event = eventService.getById(eventId);
if (StringUtils.isEmpty(startTime)) {
startTime = DateUtil.formatDateTime(event.getStartTime());
}
Map<String, String> map = esStatisticsService.totalAndMax(eventId, null, null, type); Map<String, String> map = esStatisticsService.totalAndMax(eventId, null, null, type);
if (StringUtils.isEmpty(endTime)) { if (StringUtils.isEmpty(endTime)) {
endTime = DateUtil.now(); endTime = DateUtil.now();
......
...@@ -21,7 +21,7 @@ public enum AnalysisColumnEnum { ...@@ -21,7 +21,7 @@ public enum AnalysisColumnEnum {
IMPACT_ASSESSMENT(5, "影响评估", "array", 1), IMPACT_ASSESSMENT(5, "影响评估", "array", 1),
MEASURE_SUGGEST(6, "举措建议", "array", 1), MEASURE_SUGGEST(6, "应对建议", "array", 1),
KNOWLEDGE_ENTRY(7, "知识词条", "array", 1), KNOWLEDGE_ENTRY(7, "知识词条", "array", 1),
......
...@@ -386,7 +386,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -386,7 +386,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
event.setFirstOpenTime(now); event.setFirstOpenTime(now);
Date endTime = event.getEndTime(); Date endTime = event.getEndTime();
if (endTime == null) { if (endTime == null) {
endTime = cn.hutool.core.date.DateUtil.offsetWeek(now, 3); endTime = cn.hutool.core.date.DateUtil.offsetWeek(addEventParam.getStartTime(), 3);
} }
event.setEndTime(endTime); event.setEndTime(endTime);
//事件专题的默认分析规则参数-必填 //事件专题的默认分析规则参数-必填
......
...@@ -9,12 +9,14 @@ import com.zzsn.event.service.AnalysisService; ...@@ -9,12 +9,14 @@ import com.zzsn.event.service.AnalysisService;
import com.zzsn.event.service.IEventService; import com.zzsn.event.service.IEventService;
import com.zzsn.event.util.DateUtil; import com.zzsn.event.util.DateUtil;
import com.zzsn.event.util.RedisUtil; import com.zzsn.event.util.RedisUtil;
import com.zzsn.event.vo.CoOccurrenceVO;
import com.zzsn.event.vo.PropagationPathVo; import com.zzsn.event.vo.PropagationPathVo;
import com.zzsn.event.vo.SubjectKafkaVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils; 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.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -40,9 +42,6 @@ public class AnalysisTask { ...@@ -40,9 +42,6 @@ public class AnalysisTask {
@Autowired @Autowired
private AnalysisService analysisService; private AnalysisService analysisService;
@Value("${scheduling.yjzxEnable:false}")
Boolean yjzxEnable;
/** /**
* 重新生成事件分析(版本) * 重新生成事件分析(版本)
...@@ -111,4 +110,38 @@ public class AnalysisTask { ...@@ -111,4 +110,38 @@ public class AnalysisTask {
}); });
} }
} }
/**
* 定时缓存热词共现关系数据
* 每天凌晨0点10分执行一次
*/
@Scheduled(cron = "0 10 0 * * ?")
public void co_occurrence() {
Date today = new Date();
Date deadlineDate = DateUtil.addDate(today, -1);
List<SubjectKafkaVo> events = eventService.eventSubjectList();
for (SubjectKafkaVo event : events) {
CompletableFuture.runAsync(() -> {
String eventId = event.getId();
String key = Constants.SUBJECT_ANALYSIS_PRE + Constants.CO_OCCURRENCE + eventId;
Date timeDisable = event.getTimeDisable();
if (timeDisable != null && deadlineDate.compareTo(timeDisable) > 0) {
Object cacheObject = redisUtil.get(key);
if (cacheObject == null) {
List<CoOccurrenceVO> occurrenceList = analysisService.coOccurrence(eventId, null, null);
if (CollectionUtils.isNotEmpty(occurrenceList)) {
redisUtil.set(key, occurrenceList);
log.info("专题-{},热词共现关系数据【永久】缓存成功!", event.getSubjectName());
}
}
} else {
List<CoOccurrenceVO> occurrenceList = analysisService.coOccurrence(eventId, null, null);
if (CollectionUtils.isNotEmpty(occurrenceList)) {
redisUtil.set(key, occurrenceList, 3600 * 24);
log.info("专题-{},热词共现关系数据缓存成功!", event.getSubjectName());
}
}
});
}
}
} }
package com.zzsn.event.task;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.es.EsService;
import com.zzsn.event.service.AnalysisService;
import com.zzsn.event.service.IEventService;
import com.zzsn.event.util.DateUtil;
import com.zzsn.event.util.RedisUtil;
import com.zzsn.event.vo.CoOccurrenceVO;
import com.zzsn.event.vo.SubjectKafkaVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CompletableFuture;
/**
* 热词共现数据缓存
*
* @author lkg
* @date 2025/7/22
*/
@Slf4j
@Component
public class CoOccurrenceTask {
@Autowired
private IEventService eventService;
@Autowired
private RedisUtil redisUtil;
@Autowired
private AnalysisService analysisService;
@Autowired
private EsService esService;
/**
* 定时缓存热词共现关系数据
* 每天凌晨1点执行一次
*/
@Scheduled(cron = "0 0 1 * * ?")
public void co_occurrence() {
Date today = new Date();
Date deadlineDate = DateUtil.addDate(today, -1);
List<SubjectKafkaVo> events = eventService.eventSubjectList();
for (SubjectKafkaVo event : events) {
CompletableFuture.runAsync(() -> {
String eventId = event.getId();
String key = Constants.SUBJECT_ANALYSIS_PRE + Constants.CO_OCCURRENCE + eventId;
Date timeDisable = event.getTimeDisable();
int count = esService.count(eventId, null, null);
if (count > 0) {
if (timeDisable != null && deadlineDate.compareTo(timeDisable) > 0) {
Object cacheObject = redisUtil.get(key);
if (cacheObject == null) {
List<CoOccurrenceVO> occurrenceList = analysisService.coOccurrence(eventId, null, null);
if (CollectionUtils.isNotEmpty(occurrenceList)) {
redisUtil.set(key, occurrenceList);
log.info("专题-{},热词共现关系数据【永久】缓存成功!", event.getSubjectName());
}
}
} else {
List<CoOccurrenceVO> occurrenceList = analysisService.coOccurrence(eventId, null, null);
if (CollectionUtils.isNotEmpty(occurrenceList)) {
redisUtil.set(key, occurrenceList, 3600 * 24);
log.info("专题-{},热词共现关系数据缓存成功!", event.getSubjectName());
}
}
}
});
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论