提交 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);
/**
* 公开且发布的事件信息集合
......
......@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论