提交 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);
}
}
......@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论