提交 6851fa2e 作者: 925993793@qq.com

自定义专题配置编辑/校验bug处理、代码优化

上级 211401d8
......@@ -80,7 +80,6 @@ public class Constants {
public static final String KEY_WORDS_TO_REDIS_PREFIX = "KEY_WORDS_TO_REDIS::";
//关键词采集通道
public static final String KEY_WORDS_COLLECT_TOPIC = "eventKeyWordsInfo";
public static final String EVENT_SUBJECT_MODEL = "eventSubjectModel";
/**获取真正的来源*/
public static String getRealOrigin(String origin){
......@@ -101,7 +100,8 @@ public class Constants {
return origin;
}
public static final String HISTORY_DATE_QUEUE = "HISTORY_DATE_QUEUE:";
public static final String HISTORY_SUBJECT_DATE_QUEUE = "HISTORY_DATE_QUEUE:";
public static final String HISTORY_EVENT_DATE_QUEUE = "HISTORY_EVENT_DATE_QUEUE:";
//obs 文件浏览地址 前部分
public static final String OBS_FILE_PATH_URL_PREFIX = "http://obs.ciglobal.cn/";
......
......@@ -21,6 +21,7 @@ import com.zzsn.event.xxljob.service.IXxlJobInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.*;
......@@ -37,7 +38,7 @@ import java.util.concurrent.CompletableFuture;
* @date 2024/5/7
*/
@RestController
@RequestMapping("/manage")
@RequestMapping("/plat/manage")
public class PlatEventManageController {
......@@ -52,6 +53,8 @@ public class PlatEventManageController {
@Resource
private KafkaTemplate<String, String> kafkaTemplate;
@Value("${kafka.topic.event.run:}")
private String EVENT_MODEL_KAFKA_CHANNEL;
/**
* 分页列表-新平台管理
......@@ -99,7 +102,7 @@ public class PlatEventManageController {
iXxlJobInfoService.keyWordsInsert(redisKeywordDTO);
//为了立即响应,关键词新增时放入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO));
kafkaTemplate.send(Constants.EVENT_SUBJECT_MODEL, event.getEventCode());
kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
});
return Result.OK();
......@@ -240,7 +243,7 @@ public class PlatEventManageController {
iXxlJobInfoService.update(Wrappers.<XxlJobInfo>lambdaUpdate().eq(XxlJobInfo::getInfoSourceCode, keywordsVO.getWordsCode())
.set(XxlJobInfo::getTriggerStatus, status));
if (1 == status) {
kafkaTemplate.send(Constants.EVENT_SUBJECT_MODEL, event.getEventCode());
kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
}
});
}
......
......@@ -20,6 +20,7 @@ import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*;
import com.zzsn.event.vo.es.DisplayInfo;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
......@@ -265,6 +266,10 @@ public class InformationController {
public Result<?> add(@RequestBody JSONObject jsonObject) {
UserVo userVo = UserUtil.getLoginUser();
DisplayInfo displayInfo = JSON.parseObject(JSON.toJSONString(jsonObject.get("data")), DisplayInfo.class);
String contentWithTag = displayInfo.getContentWithTag();
if (StringUtils.isNotBlank(contentWithTag)) {
displayInfo.setContent(Jsoup.parse(contentWithTag).text());
}
Integer category = (Integer) jsonObject.get("category");
boolean modelFlag = pythonUtil.judgeDuplicate(displayInfo.getId(), displayInfo.getTitle(), displayInfo.getContent(), displayInfo.getSourceAddress(), displayInfo.getSubjectId());
if (modelFlag) {
......
......@@ -8,7 +8,6 @@ import com.zzsn.event.service.ISubjectTypeMapService;
import com.zzsn.event.service.ISubjectTypeService;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.tree.TreeUtil;
import com.zzsn.event.util.user.AuthUtil;
import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.SubjectTreeVO;
......
......@@ -21,6 +21,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
......@@ -32,7 +33,7 @@ import java.util.List;
import java.util.concurrent.CompletableFuture;
/**
*
* 第三方(研究中心)调用
*
* @author lkg
* @date 2024/10/12
......@@ -63,8 +64,11 @@ public class EventApi {
@Autowired
private EventRegionMapService eventRegionMapService;
@Value("${kafka.topic.event.run:}")
private String EVENT_MODEL_KAFKA_CHANNEL;
/**
* 新增事件(页面简化版)
* 新增事件
*
* @param addEventVO 事件信息
* @author lkg
......@@ -90,7 +94,7 @@ public class EventApi {
iXxlJobInfoService.keyWordsInsert(redisKeywordDTO);
//为了立即响应,关键词新增时放入一个首次录入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO));
kafkaTemplate.send(Constants.EVENT_SUBJECT_MODEL, event.getEventCode());
kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
});
return Result.OK(event);
} else {
......
......@@ -75,6 +75,8 @@ public class EventDataController {
@Value("${translate.url:}")
private String TRANSLATE_URL;
@Value("${kafka.topic.event.run:}")
private String EVENT_MODEL_KAFKA_CHANNEL;
private static final String prefix = "http://obs.ciglobal.cn/";
......@@ -185,7 +187,7 @@ public class EventDataController {
iXxlJobInfoService.keyWordsInsert(redisKeywordDTO);
//为了立即响应,关键词新增时放入一个首次录入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO));
kafkaTemplate.send(Constants.EVENT_SUBJECT_MODEL, event.getEventCode());
kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
});
return Result.OK();
} else {
......@@ -300,9 +302,6 @@ public class EventDataController {
*/
@GetMapping(value = "/articleDetail")
public Result<?> articleDetail(@RequestParam(required = false) String index, @RequestParam String id) {
if (StringUtils.isEmpty(index)) {
index = Constants.SUBJECT_INDEX;
}
SubjectDataVo subjectDataVo = esService.queryInfo(index, id);
return Result.OK(subjectDataVo);
}
......
......@@ -10,14 +10,11 @@ import com.zzsn.event.entity.Event;
import com.zzsn.event.entity.KeyWords;
import com.zzsn.event.service.IEventService;
import com.zzsn.event.service.IKeyWordsService;
import com.zzsn.event.service.ISubjectInfoSourceMapService;
import com.zzsn.event.service.LabelEntityService;
import com.zzsn.event.util.RedisUtil;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*;
import com.zzsn.event.xxljob.entity.XxlJobInfo;
import com.zzsn.event.xxljob.service.IXxlJobInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -43,7 +40,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Api(tags = "事件后台管理")
@RestController
@RequestMapping("/plat/manage")
@RequestMapping("/manage")
public class EventManageController {
@Autowired
......@@ -61,8 +58,9 @@ public class EventManageController {
@Resource
private KafkaTemplate<String, String> kafkaTemplate;
@Value(("${serviceProject.url:}"))
private String SERVICE_PROJECT_URL;
@Value("${kafka.topic.event.run:}")
private String EVENT_MODEL_KAFKA_CHANNEL;
/**
* 分页列表-后台管理
......@@ -142,6 +140,7 @@ public class EventManageController {
CompletableFuture.runAsync(() -> {
//插入xxlJob
iXxlJobInfoService.eventInsert(event);
//-------------关键词采集相关,需优化,采集那边说目前搜索引擎效果也不好,先这样。
//关键词入缓存
KeyWordsDTO redisKeywordDTO = new KeyWordsDTO();
BeanUtils.copyProperties(keyWords, redisKeywordDTO);
......@@ -153,8 +152,8 @@ public class EventManageController {
iXxlJobInfoService.keyWordsInsert(redisKeywordDTO);
//为了立即响应,关键词新增时放入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO));
kafkaTemplate.send(Constants.EVENT_SUBJECT_MODEL, event.getEventCode());
//----------------------------------------------------------------------------------------------
kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
});
return Result.OK();
} else {
......@@ -163,6 +162,19 @@ public class EventManageController {
}
/**
* 事件配置校验
*
* @param addEventParam 参数
* @author lkg
* @date 2025/2/5
*/
@PostMapping("/configVerification")
public Result<?> configVerification(@RequestBody AddEventParam addEventParam){
Boolean verification = eventService.configVerification(addEventParam);
return Result.OK(verification);
}
/**
* 1.3 编辑
*
* @param addEventParam
......@@ -207,12 +219,12 @@ public class EventManageController {
*/
@GetMapping("/enable")
public Result<?> enable(@RequestParam String eventId) {
updateStatus(eventId, 1);
eventService.updateStatus(eventId, 1);
return Result.OK();
}
/**
*
*
*
* @param eventId 事件id
* @author lkg
......@@ -220,24 +232,22 @@ public class EventManageController {
*/
@GetMapping("/disable")
public Result<?> disable(@RequestParam String eventId) {
updateStatus(eventId, 0);
eventService.updateStatus(eventId, 0);
return Result.OK();
}
private void updateStatus(String eventId, Integer status) {
eventService.update(Wrappers.<Event>lambdaUpdate().eq(Event::getId, eventId).set(Event::getStatus, status));
CompletableFuture.runAsync(() -> {
Event event = eventService.getById(eventId);
iXxlJobInfoService.update(Wrappers.<XxlJobInfo>lambdaUpdate().eq(XxlJobInfo::getInfoSourceCode, event.getEventCode())
.set(XxlJobInfo::getTriggerStatus, status));
//关键词
KeywordsVO keywordsVO = keyWordsService.keywordInfoByEventId(eventId);
iXxlJobInfoService.update(Wrappers.<XxlJobInfo>lambdaUpdate().eq(XxlJobInfo::getInfoSourceCode, keywordsVO.getWordsCode())
.set(XxlJobInfo::getTriggerStatus, status));
if (1==status){
kafkaTemplate.send(Constants.EVENT_SUBJECT_MODEL, event.getEventCode());
}
});
/**
* 清空专题数据
*
* @param subjectId 专题id
* @author lkg
* @date 2025/2/6
*/
@GetMapping("/clearData")
public Result<?> clearData(String subjectId){
eventService.clearSubjectData(subjectId);
return Result.OK("正在清空数据");
}
/**
......@@ -321,5 +331,4 @@ public class EventManageController {
List<ModelVO> modelVOS = eventService.modelList();
return Result.OK(modelVOS);
}
}
......@@ -26,129 +26,205 @@ import java.util.List;
@TableName("event")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="event对象", description="事件")
@ApiModel(value = "event对象", description = "事件")
public class Event {
/**ID*/
/**
* ID
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "ID")
private String id;
/**编码*/
/**
* 编码
*/
@Excel(name = "编码", width = 15)
@ApiModelProperty(value = "编码")
private String eventCode;
/**名称*/
/**
* 名称
*/
@Excel(name = "名称", width = 15)
@ApiModelProperty(value = "名称")
private String eventName;
/**图标*/
/**
* 图标
*/
@Excel(name = "图标", width = 15)
@ApiModelProperty(value = "图标")
private String eventIcon;
/**事件类型*/
/**
* 事件类型
*/
@Excel(name = "事件类型", width = 15)
@ApiModelProperty(value = "事件类型")
private String eventType;
/**开始时间*/
/**
* 开始时间
*/
@Excel(name = "开始时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "开始时间")
private Date startTime;
/**结束时间*/
/**
* 结束时间
*/
@Excel(name = "结束时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "结束时间")
private Date endTime;
/**标签*/
/**
* 标签
*/
@Excel(name = "标签", width = 15)
@ApiModelProperty(value = "标签")
private String eventLabel;
/**是否公开*/
/**
* 是否公开
*/
@Excel(name = "是否公开", width = 15)
@ApiModelProperty(value = "是否公开")
private Integer facePublic;
/**事件描述*/
/**
* 事件描述
*/
@Excel(name = "事件描述", width = 15)
@ApiModelProperty(value = "事件描述")
private String eventDescribe;
/**创建人id*/
/**
* 创建人id
*/
@Excel(name = "创建人id", width = 15)
@ApiModelProperty(value = "创建人id")
private String createBy;
/**创建时间*/
/**
* 创建时间
*/
@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**修改时间*/
/**
* 修改时间
*/
@Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "修改时间")
private Date updateTime;
/**修改人id*/
/**
* 修改人id
*/
@Excel(name = "修改人id", width = 15)
@ApiModelProperty(value = "修改人id")
private String updateBy;
/**状态(0-禁用;1-启用)*/
private Integer status=1;
/**
* 状态(0-禁用;1-启用)
*/
private Integer status = 1;
/**
* 专题最近一次分析时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date analysisTime;
/**
* 分析事件脉络-最新资讯的时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date eventTime;
/**划分专题库*/
/**
* 划分专题库
*/
@ApiModelProperty(value = "划分专题库")
private String library;
/**定时单位(1分;2小时;3日;4月)*/
/**
* 定时单位(1分;2小时;3日;4月)
*/
@ApiModelProperty(value = "定时单位")
private String unit;
/**定时数值*/
/**
* 定时数值
*/
@ApiModelProperty(value = "定时数值")
private Integer space;
/**cron表达式*/
/**
* cron表达式
*/
@ApiModelProperty(value = "cron表达式")
private String cron;
/**是否提取热词*/
/**
* 是否提取热词
*/
@ApiModelProperty(value = "是否提取热词")
private String ynExtractHotWords;
/**事件专题增量分析规则*/
/**
* 事件专题增量分析规则
*/
@ApiModelProperty(value = "事件专题增量分析规则")
private Integer increAnaRule;
/**事件专题总量分析规则*/
/**
* 事件专题总量分析规则
*/
@ApiModelProperty(value = "事件专题总量分析规则")
private Integer totalAnaRule;
/**事件专题时间间隔分析规则(天)*/
/**
* 事件专题时间间隔分析规则(天)
*/
@ApiModelProperty(value = "事件专题时间间隔分析规则(天)")
private Integer timeAnaRule;
/**总热度*/
/**
* 总热度
*/
private Integer totalHot;
/**媒体热度*/
/**
* 媒体热度
*/
private Integer mediaHot;
/**微信热度*/
/**
* 微信热度
*/
private Integer wechatHot;
/**其他热度*/
/**
* 其他热度
*/
private Integer otherHot;
/**发布状态(0-未发布;1-已发布)*/
/**
* 发布状态(0-未发布;1-已发布)
*/
private Integer publishStatus;
/**关联事件*/
/**
* 关联事件
*/
private String relationEvents;
/**发布时间*/
/**
* 发布时间
*/
private String publishDate;
/**排序号*/
/**
* 排序号
*/
private Integer sortOrder;
/**事件创建方式(1-用户直接创建;2-基于挖掘的事件创建)*/
/**
* 事件创建方式(1-用户直接创建;2-基于挖掘的事件创建)
*/
private Integer category;
/**
* 是否开启采集(1-是;0-否)
*/
private Integer ynCollect;
/**
* 第一次开启时间
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date firstOpenTime;
/**关键词信息*/
/**
* 关键词信息
*/
@TableField(exist = false)
private KeyWords keyWords;
......
......@@ -299,6 +299,9 @@ public class EsService {
public SubjectDataVo queryInfo(String index, String id) {
SubjectDataVo subjectDataVo = new SubjectDataVo();
try {
if (StringUtils.isBlank(index)) {
index = Constants.SUBJECT_INDEX;
}
SearchRequest searchRequest = new SearchRequest(index);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.size(1);
......
......@@ -40,7 +40,7 @@
IFNULL(r.id, false) as hasReport
from event t
inner join event_category c on t.event_type = c.id
inner join subject_type_map stm on t.id = stm.subject_id
left join subject_type_map stm on t.id = stm.subject_id
inner join project_subject_map psm on t.id = psm.subject_id
left join event_analysis_report r on t.id = r.event_id
where t.id = #{eventId}
......
......@@ -123,7 +123,25 @@ public interface IEventService extends IService<Event> {
void deleteMain(String id);
void updateStatus(String eventId, Integer status);
/**
* 事件配置校验
*
* @param addEventParam 参数
* @author lkg
* @date 2025/2/5
*/
Boolean configVerification(AddEventParam addEventParam);
/**
* 清空事件数据
*
* @param eventId 事件id
* @author lkg
* @date 2025/2/6
*/
void clearSubjectData(String eventId);
/**
* 公开且发布的事件信息集合
......
package com.zzsn.event.service.impl;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -18,6 +20,8 @@ import com.zzsn.event.util.tree.TreeUtil;
import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*;
import com.zzsn.event.xxljob.entity.XxlJobInfo;
import com.zzsn.event.xxljob.service.IXxlJobInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -40,11 +44,16 @@ import org.elasticsearch.search.sort.SortOrder;
import org.jsoup.Jsoup;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.IOException;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
......@@ -86,12 +95,23 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
private SubjectAnalysisService subjectAnalysisService;
@Autowired
private EventAnalysisReportService eventAnalysisReportService;
@Autowired
private IXxlJobInfoService iXxlJobInfoService;
@Autowired
private CommonService commonService;
@Resource
private RestHighLevelClient client;
@Resource
private KafkaTemplate<String, String> kafkaTemplate;
@Autowired
private CommonService commonService;
private RedisUtil redisUtil;
@Autowired
private PythonUtil pythonUtil;
@Autowired
private EsOpUtil esOpUtil;
@Value("${kafka.topic.event.run:}")
private String EVENT_MODEL_KAFKA_CHANNEL;
@Override
public List<SubjectKafkaVo> progressList(Date disableDate) {
......@@ -135,7 +155,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
}
@Override
public IPage<EventFrontVO> frontAllPageList(String projectId,String eventId, String eventName, String eventType, String labelField, String labelName, String order, String orderType, Integer pageNo, Integer pageSize) {
public IPage<EventFrontVO> frontAllPageList(String projectId, String eventId, String eventName, String eventType, String labelField, String labelName, String order, String orderType, Integer pageNo, Integer pageSize) {
int offset = (pageNo - 1) * pageSize;
Integer type = null;
if (StringUtils.isNotEmpty(labelField) && labelField.equals("event_label")) {
......@@ -148,7 +168,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
}
//获取当前登录人信息
UserVo currentUser = UserUtil.getLoginUser();
List<EventFrontVO> pageList = baseMapper.frontAllPageList(projectId, currentUser.getUsername(), eventId,eventName, eventTypes, labelField, labelName, type, order, orderType, offset, pageSize);
List<EventFrontVO> pageList = baseMapper.frontAllPageList(projectId, currentUser.getUsername(), eventId, eventName, eventTypes, labelField, labelName, type, order, orderType, offset, pageSize);
if (CollectionUtils.isNotEmpty(pageList)) {
Map<String, String> map = getFirstMap(pageList);
if (MapUtil.isNotEmpty(map)) {
......@@ -164,7 +184,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
}
}
//获取总条数
Integer count = baseMapper.frontAllCount(projectId, currentUser.getUsername(), eventId,eventName, eventTypes, labelField, labelName, type);
Integer count = baseMapper.frontAllCount(projectId, currentUser.getUsername(), eventId, eventName, eventTypes, labelField, labelName, type);
IPage<EventFrontVO> pageData = new Page<>(pageNo, pageSize, count);
pageData.setRecords(pageList);
return pageData;
......@@ -223,13 +243,13 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
}
@Override
public List<EventTopVO> topEventList(String projectId, String createBy,String startTime, String endTime, Integer type, Integer pageSize) {
return baseMapper.topEventList(projectId,createBy,startTime, endTime, type, 0, pageSize);
public List<EventTopVO> topEventList(String projectId, String createBy, String startTime, String endTime, Integer type, Integer pageSize) {
return baseMapper.topEventList(projectId, createBy, startTime, endTime, type, 0, pageSize);
}
@Override
public List<EventRegionVO> listByRegion(String projectId, String createBy,Integer type, String name) {
return baseMapper.listByRegion(projectId,createBy,type, name);
public List<EventRegionVO> listByRegion(String projectId, String createBy, Integer type, String name) {
return baseMapper.listByRegion(projectId, createBy, type, name);
}
private Map<String, String> getFirstMap(List<EventFrontVO> pageList) {
......@@ -314,23 +334,26 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
@Override
@Transactional
public void updateMain(AddEventParam addEventParam) {
Event subject = new Event();
BeanUtils.copyProperties(addEventParam, subject);
String eventId = subject.getId();
baseMapper.updateById(subject);
Event oldEvent = this.getById(addEventParam.getId());
Event event = new Event();
BeanUtils.copyProperties(addEventParam, event);
String eventId = event.getId();
baseMapper.updateById(event);
CompletableFuture.runAsync(() -> {
//专题-类别、项目的绑定关系处理
//删除专题-类别绑定关系
iSubjectTypeMapService.deleteBySubjectId(subject.getId());
iSubjectTypeMapService.deleteBySubjectId(event.getId());
//删除专题-项目的绑定关系
iProjectSubjectMapService.deleteBySubjectId(subject.getId());
saveMapMain(subject, addEventParam);
iProjectSubjectMapService.deleteBySubjectId(event.getId());
saveMapMain(event, addEventParam);
//地域关系处理
LambdaQueryWrapper<EventRegionMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(EventRegionMap::getEventId, eventId);
eventRegionMapService.remove(queryWrapper);
List<RegionVO> regionList = addEventParam.getRegionList();
addRegionMap(eventId, regionList);
//修改redis缓存,,用于向事件里补充数据
updateRedisCache(event, oldEvent);
});
}
......@@ -356,13 +379,83 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
//删除事件-搜索引擎关系
subjectSearchEnginesMapService.remove(Wrappers.<SubjectSearchEnginesMap>lambdaQuery().eq(SubjectSearchEnginesMap::getSubjectId, id));
//删除事件 观点分析、事件脉络数据
subjectAnalysisService.remove(Wrappers.<SubjectAnalysis>lambdaQuery().eq(SubjectAnalysis::getSubjectId,id));
subjectAnalysisService.remove(Wrappers.<SubjectAnalysis>lambdaQuery().eq(SubjectAnalysis::getSubjectId, id));
//删除事件 分析报告数据
eventAnalysisReportService.delete(id);
});
}
@Override
public Boolean configVerification(AddEventParam addEventParam) {
String eventId = addEventParam.getId();
EventVO eventDetail = queryInfo(eventId);
Date firstOpenTime = eventDetail.getFirstOpenTime();
if (firstOpenTime == null) {
return true;
} else {
//判断时间是否变化--只需判断开始时间,若范围缩小则校验不通过
if (addEventParam.getStartTime().after(DateUtil.stringToDate(eventDetail.getStartTime(), "yyyy-MM-dd HH:mm:ss"))) {
return false;
}
//判断关键词是否变化
KeywordsVO keywordsOld = eventDetail.getKeywordsVO();
KeywordsVO keywordsNew = addEventParam.getKeywordsVO();
boolean keywordsChange = !keywordsOld.getKeyword().equals(keywordsNew.getKeyword());
boolean exclusionWordChange;
if (StringUtils.isEmpty(keywordsOld.getExclusionWord())) {
exclusionWordChange = StringUtils.isNotEmpty(keywordsNew.getExclusionWord());
} else {
if (StringUtils.isEmpty(keywordsNew.getExclusionWord())) {
exclusionWordChange = true;
} else {
exclusionWordChange = !keywordsNew.getExclusionWord().equals(keywordsOld.getExclusionWord());
}
}
return !keywordsChange && !exclusionWordChange;
}
}
@Override
public void updateStatus(String eventId, Integer status) {
Event event = this.getById(eventId);
LambdaUpdateWrapper<Event> updateWrapper = Wrappers.lambdaUpdate();
updateWrapper.set(Event::getStatus, status).eq(Event::getId, eventId);
if (status == 1 && event.getFirstOpenTime() == null) {
//判断是否第一次启用
updateWrapper.set(Event::getFirstOpenTime, new Date());
}
this.update(updateWrapper);
CompletableFuture.runAsync(() -> {
iXxlJobInfoService.update(Wrappers.<XxlJobInfo>lambdaUpdate().eq(XxlJobInfo::getInfoSourceCode, event.getEventCode())
.set(XxlJobInfo::getTriggerStatus, status));
//关键词
KeywordsVO keywordsVO = keyWordsService.keywordInfoByEventId(eventId);
iXxlJobInfoService.update(Wrappers.<XxlJobInfo>lambdaUpdate().eq(XxlJobInfo::getInfoSourceCode, keywordsVO.getWordsCode())
.set(XxlJobInfo::getTriggerStatus, status));
if (1 == status) {
kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
}
});
}
@Override
public void clearSubjectData(String eventId) {
LambdaUpdateWrapper<Event> updateWrapper = Wrappers.lambdaUpdate();
updateWrapper.eq(Event::getId, eventId)
.set(Event::getStatus, 0)
.set(Event::getFirstOpenTime, null);
this.update(updateWrapper);
CompletableFuture.runAsync(() -> {
//调用python接口
pythonUtil.clearDuplicateHistory(eventId);
//清空专题数据
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
boolQuery.must(QueryBuilders.termQuery("subjectId.keyword", eventId));
esOpUtil.docDeleteByQuery(Constants.SUBJECT_INDEX, boolQuery);
});
}
@Override
public List<ModelVO> modelList() {
return baseMapper.modelList();
}
......@@ -378,8 +471,8 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
}
@Override
public List<EventExcelVO> frontAllList(String projectId, String createBy, List<String> eventIdList,String eventName,
String eventType, String labelField,String labelName, Integer size) {
public List<EventExcelVO> frontAllList(String projectId, String createBy, List<String> eventIdList, String eventName,
String eventType, String labelField, String labelName, Integer size) {
Integer type = null;
if (StringUtils.isNotEmpty(labelField) && labelField.equals("event_label")) {
type = 1;
......@@ -389,12 +482,12 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
List<Node> nodes = eventCategoryService.categoryList();
eventTypes = TreeUtil.belowList(nodes, eventType, true);
}
return baseMapper.frontAllList(projectId,createBy,eventIdList,eventName,eventTypes,labelField,labelName,type, size);
return baseMapper.frontAllList(projectId, createBy, eventIdList, eventName, eventTypes, labelField, labelName, type, size);
}
@Override
public List<EventExcelVO> frontOwnerList(String projectId, String createBy, List<String> eventIdList,String eventName,
String eventType, String labelField,String labelName, Integer size) {
public List<EventExcelVO> frontOwnerList(String projectId, String createBy, List<String> eventIdList, String eventName,
String eventType, String labelField, String labelName, Integer size) {
Integer type = null;
if (StringUtils.isNotEmpty(labelField) && labelField.equals("event_label")) {
type = 1;
......@@ -404,7 +497,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
List<Node> nodes = eventCategoryService.categoryList();
eventTypes = TreeUtil.belowList(nodes, eventType, true);
}
return baseMapper.frontOwnerList(projectId,createBy,eventIdList,eventName,eventTypes,labelField,labelName,type, size);
return baseMapper.frontOwnerList(projectId, createBy, eventIdList, eventName, eventTypes, labelField, labelName, type, size);
}
......@@ -512,10 +605,10 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
long t1 = System.currentTimeMillis();
Map<String, Integer> keyWordsNumMap = commonService.bindKeyWordsCountList(idList).stream().collect(Collectors.toMap(SubjectPage::getId, SubjectPage::getKeyWordsNum));
long t2 = System.currentTimeMillis();
log.info("关键词数量查询耗时==={}",t2-t1);
log.info("关键词数量查询耗时==={}", t2 - t1);
Map<String, List<SubjectSourceVO>> collect = commonService.bindSourceList(idList).stream().collect(Collectors.groupingBy(SubjectSourceVO::getSubjectId));
long t3 = System.currentTimeMillis();
log.info("信息源数量查询耗时==={}",t3-t2);
log.info("信息源数量查询耗时==={}", t3 - t2);
for (Map.Entry<String, List<SubjectSourceVO>> entry : collect.entrySet()) {
String subjectId = entry.getKey();
List<SubjectSourceVO> value = entry.getValue();
......@@ -523,7 +616,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
}
long t4 = System.currentTimeMillis();
Map<String, Integer> subjectInfoCountMap = subjectInfoCountMap(idList, null);
log.info("资讯数量查询耗时==={}",System.currentTimeMillis()-t4);
log.info("资讯数量查询耗时==={}", System.currentTimeMillis() - t4);
for (EventNewPlatVO newPlatVO : pageList) {
int keyWordsNum = null == keyWordsNumMap.get(newPlatVO.getId()) ? 0 : keyWordsNumMap.get(newPlatVO.getId());
int infoSourceNum = null == infoSourceNumMap.get(newPlatVO.getId()) ? 0 : infoSourceNumMap.get(newPlatVO.getId());
......@@ -535,4 +628,34 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
}
}
}
/**
* 修改事件时间缓存,用于补充数据(只有启用过的事件才会起作用)
*
* @param event 新事件信息
* @param oldEvent 旧事件信息
* @author lkg
* @date 2025/2/7
*/
private void updateRedisCache(Event event, Event oldEvent) {
Date firstOpenTime = oldEvent.getFirstOpenTime();
if (firstOpenTime != null) {
Date oldTimeEnable = oldEvent.getStartTime();
LocalDate oldStart = oldTimeEnable.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
Date timeEnable = event.getStartTime();
List<String> newDateList = new ArrayList<>();
LocalDate start = timeEnable.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
if (start.isBefore(oldStart)) {
for (LocalDate date = start; date.isBefore(oldStart); date = date.plusDays(1)) {
// 在这里处理每一天的逻辑
//格式化date成字符串
String format = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
newDateList.add(format);
}
}
if (CollectionUtils.isNotEmpty(newDateList)) {
redisUtil.rpushMultipleValues(Constants.HISTORY_EVENT_DATE_QUEUE + event.getEventCode(), newDateList.toArray(new String[0]));
}
}
}
}
......@@ -662,7 +662,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
String format = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
dateList.add(format);
}
redisUtil.rpushMultipleValues(Constants.HISTORY_DATE_QUEUE + subject.getSubjectCode(), dateList.toArray(new String[0]));
redisUtil.rpushMultipleValues(Constants.HISTORY_SUBJECT_DATE_QUEUE + subject.getSubjectCode(), dateList.toArray(new String[0]));
}
/**
......@@ -717,7 +717,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
}
}
if (CollectionUtils.isNotEmpty(newDateList)) {
redisUtil.rpushMultipleValues(Constants.HISTORY_DATE_QUEUE + subject.getSubjectCode(), newDateList.toArray(new String[0]));
redisUtil.rpushMultipleValues(Constants.HISTORY_SUBJECT_DATE_QUEUE + subject.getSubjectCode(), newDateList.toArray(new String[0]));
}
}
}
......
......@@ -3,6 +3,7 @@ package com.zzsn.event.vo;
import com.zzsn.event.entity.EventTag;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
......@@ -54,6 +55,7 @@ public class EventVO {
private String projectId;
/**排序号*/
private Integer sortOrder;
private Date firstOpenTime;
/**是否生成分析报告*/
......
......@@ -153,6 +153,8 @@ kafka:
topic:
subject:
run: subjectModelTest
event:
run: eventSubjectModelTest
clb:
subject:
default:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论