提交 03bb043a 作者: 925993793@qq.com

Merge branch 'event_new' into test

# Conflicts:
#	src/main/java/com/zzsn/event/controller/PlatEventManageController.java
#	src/main/java/com/zzsn/event/controller/SubjectManageController.java
#	src/main/java/com/zzsn/event/controller/yjzx/NewEventManageController.java
#	src/main/java/com/zzsn/event/service/IEventService.java
#	src/main/java/com/zzsn/event/service/impl/EventServiceImpl.java
......@@ -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/";
......
......@@ -14,6 +14,7 @@ import com.zzsn.event.entity.*;
import com.zzsn.event.es.EsService;
import com.zzsn.event.feign.api.RemoteModelService;
import com.zzsn.event.service.*;
import com.zzsn.event.service.impl.ConfigurationMessageService;
import com.zzsn.event.util.*;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.user.UserUtil;
......@@ -98,7 +99,8 @@ public class SubjectManageController {
private PythonUtil pythonUtil;
@Autowired(required = false)
private RemoteModelService remoteModelService;
@Autowired
private ConfigurationMessageService configurationMessageService;
@Value("${kafka.topic.subject.run:}")
private String SUBJECT_MODEL_KAFKA_CHANNEL;
......@@ -123,7 +125,7 @@ public class SubjectManageController {
* @date 2025/1/7
*/
@GetMapping("/dictItemList")
public Result<?> dictItemList(@RequestParam(defaultValue = "Thematic_Library") String dictCode) {
public Result<?> dictItemList(@RequestParam(defaultValue = "Thematic_Library")String dictCode){
List<SysDictItem> dictItemList = sysDictItemService.listByDictCode(dictCode);
return Result.OK(dictItemList);
}
......@@ -438,8 +440,10 @@ public class SubjectManageController {
* @return
*/
@GetMapping(value = "/bindKeyWordsList")
public Result<?> bindKeyWordsList(@RequestParam(name = "id") String id, @RequestParam(name = "bindingType", required = false) String bindingType) {
List<KeyWordsPage> bindKeyWordsList = subjectKeywordsMapService.bindKeyWordsList(id, bindingType);
public Result<?> bindKeyWordsList(@RequestParam(name = "id") String id,@RequestParam(name = "bindingType",required = false) String bindingType) {
List<KeyWordsPage> bindKeyWordsList = subjectKeywordsMapService.bindKeyWordsList(id,bindingType);
//同步配置到采集
configurationMessageService.bindKeyWordsSend(id);
return Result.OK(bindKeyWordsList);
}
......@@ -605,6 +609,7 @@ public class SubjectManageController {
}
/**
* 专题打分模型配置信息详情
*
......@@ -773,7 +778,7 @@ public class SubjectManageController {
List<String> sourceIdList = subjectSourceVO.getSourceIdList();
if (CollectionUtils.isEmpty(sourceIdList)) {
LambdaQueryWrapper<InfoSource> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.select(InfoSource::getId, InfoSource::getSiteName, InfoSource::getSiteUri)
queryWrapper.select(InfoSource::getId,InfoSource::getSiteName,InfoSource::getSiteUri)
.in(InfoSource::getWebSiteName, subjectSourceVO.getWebSiteNameList())
.groupBy(InfoSource::getId);
List<InfoSource> infoSources = infoSourceService.list(queryWrapper);
......@@ -857,7 +862,7 @@ public class SubjectManageController {
* @date 2025/1/9
*/
@PostMapping("/removeDirectInfoSource")
public Result<?> removeDirectInfoSource(@RequestBody List<SubjectBindDirectSourceVO> params) {
public Result<?> removeDirectInfoSource(@RequestBody List<SubjectBindDirectSourceVO> params){
for (SubjectBindDirectSourceVO param : params) {
String subjectId = param.getSubjectId();
String webSiteName = param.getWebSiteName();
......@@ -870,7 +875,7 @@ public class SubjectManageController {
} else {
List<String> webSiteNameList = new ArrayList<>();
webSiteNameList.add(webSiteName);
List<InfoSource> infoSources = infoSourceService.subjectBindSourceColumnList(subjectId, webSiteNameList);
List<InfoSource> infoSources = infoSourceService.subjectBindSourceColumnList(subjectId,webSiteNameList);
sourceIdList = infoSources.stream().map(InfoSource::getId).collect(Collectors.toList());
}
subjectInfoSourceMapService.remove(new LambdaQueryWrapper<SubjectInfoSourceMap>()
......@@ -917,9 +922,9 @@ public class SubjectManageController {
if (originalFilename.endsWith(".xlsx") || originalFilename.endsWith(".xls")) {
List<List<String>> dataList;
if (originalFilename.endsWith(".xls")) {
dataList = ExcelExportUtil.readExcelXls(file.getInputStream(), false, 1, 2);
dataList = ExcelExportUtil.readExcelXls(file.getInputStream(), false,1, 2);
} else {
dataList = ExcelExportUtil.readExcelXlsx(file.getInputStream(), false, 1, 2);
dataList = ExcelExportUtil.readExcelXlsx(file.getInputStream(), false,1, 2);
}
if (CollectionUtils.isNotEmpty(dataList)) {
boolean emptyFlag = false;
......@@ -1045,7 +1050,7 @@ public class SubjectManageController {
sourceIdList.add(countVO.getName());
}
LambdaQueryWrapper<InfoSource> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.select(InfoSource::getId, InfoSource::getSiteName, InfoSource::getSiteUri).in(InfoSource::getId, sourceIdList);
queryWrapper.select(InfoSource::getId,InfoSource::getSiteName,InfoSource::getSiteUri).in(InfoSource::getId,sourceIdList);
infoSources = infoSourceService.list(queryWrapper);
}
return Result.OK(infoSources);
......@@ -1194,7 +1199,7 @@ public class SubjectManageController {
String originalFilename = file.getOriginalFilename();
if (originalFilename.endsWith(".txt")) {
parseTxt(text, file);
} else if (originalFilename.endsWith(".docx")) {
} else if (originalFilename.endsWith(".docx")){
parseWordDocx(text, file);
} else if (originalFilename.endsWith(".doc")) {
parseWordDoc(text, file);
......@@ -1218,7 +1223,7 @@ public class SubjectManageController {
}
private List<StatisticsKeyWordVo> formatWordInfo(String text, List<String> wordsList) {
private List<StatisticsKeyWordVo> formatWordInfo(String text,List<String> wordsList){
List<StatisticsKeyWordVo> articleWordList = new ArrayList<>();
Map<String, Integer> hitWordsAndTimes = HanlpUtil.getHitWordsAndTimes(wordsList, text);
for (Map.Entry<String, Integer> entry : hitWordsAndTimes.entrySet()) {
......
......@@ -21,6 +21,7 @@ import com.zzsn.event.vo.*;
import com.zzsn.event.vo.es.DisplayInfo;
import org.apache.commons.collections4.CollectionUtils;
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.*;
......@@ -266,6 +267,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) {
......
package com.zzsn.event.controller.common;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
......@@ -12,6 +13,7 @@ import com.zzsn.event.entity.InfoSourceGroup;
import com.zzsn.event.service.*;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.*;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -43,6 +45,8 @@ public class RelationBindController {
private CommonService commonService;
@Autowired
private InfoSourceGroupService infoSourceGroupService;
@Autowired
private SubjectService subjectService;
/**
* 项目列表
......@@ -149,6 +153,18 @@ public class RelationBindController {
}
/**
* 专题信息源绑定新
*
* @param subjectPage
* @return
*/
@ApiOperation(value = "专题信息源绑定", notes = "专题信息源绑定")
@PostMapping(value = "/infoSourceBindNew")
public Result<?> infoSourceBindNew(@RequestBody SubjectPage subjectPage) {
return subjectService.infoSourceBindNew(subjectPage);
}
/**
* 专题/事件信息源绑定删除(专题/事件配置页)
*
* @param subjectPage 参数
......@@ -161,6 +177,38 @@ public class RelationBindController {
}
/**
* 专题信息源绑定删除
*
* @param subjectPage
* @return
*/
@ApiOperation(value = "专题信息源绑定删除", notes = "专题信息源绑定删除")
@PostMapping(value = "/deleteBindInfoSourceNew")
public Result<?> deleteBindInfoSourceNew(@RequestBody SubjectPage subjectPage) {
String subjectId = subjectPage.getId();
List<String> bindIds = subjectPage.getBindIds();
if (org.springframework.util.StringUtils.isEmpty(subjectId)) {
return Result.FAIL("专题id不能为空");
}
if (StrUtil.isBlank(subjectPage.getSourceBindType())){
return Result.FAIL("解绑类型不能为空");
}
if (StrUtil.isBlank(subjectPage.getSourceType())){
return Result.FAIL("信息源类型不能为空");
}
if(CollectionUtil.isEmpty(bindIds) && ("1".equals(subjectPage.getSourceType()) || "2".equals(subjectPage.getSourceType()))){
return Result.FAIL("解绑绑定id不能为空");
}
if(CollectionUtil.isEmpty(subjectPage.getBindLabels()) && "3".equals(subjectPage.getSourceType() )){
return Result.FAIL("解绑标签不能为空");
}
subjectService.deleteBindNew(subjectPage);
return Result.OK("删除成功!");
}
/**
* 专题/事件绑定的信息源组列表(专题/事件配置页)
*
* @param subjectId 专题/事件id
......
......@@ -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,8 +10,10 @@ 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.*;
......@@ -59,8 +61,8 @@ public class NewEventManageController {
@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;
/**
* 分页列表-后台管理
......@@ -140,6 +142,7 @@ public class NewEventManageController {
CompletableFuture.runAsync(() -> {
//插入xxlJob
iXxlJobInfoService.eventInsert(event);
//-------------关键词采集相关,需优化,采集那边说目前搜索引擎效果也不好,先这样。
//关键词入缓存
KeyWordsDTO redisKeywordDTO = new KeyWordsDTO();
BeanUtils.copyProperties(keyWords, redisKeywordDTO);
......@@ -151,8 +154,8 @@ public class NewEventManageController {
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 {
......@@ -161,6 +164,19 @@ public class NewEventManageController {
}
/**
* 事件配置校验
*
* @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
......@@ -205,12 +221,12 @@ public class NewEventManageController {
*/
@GetMapping("/enable")
public Result<?> enable(@RequestParam String eventId) {
updateStatus(eventId, 1);
eventService.updateStatus(eventId, 1);
return Result.OK();
}
/**
*
*
*
* @param eventId 事件id
* @author lkg
......@@ -218,24 +234,22 @@ public class NewEventManageController {
*/
@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("正在清空数据");
}
/**
......
......@@ -300,6 +300,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);
......
......@@ -135,6 +135,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);
List<StatisticsKeyWordVo> hotWords(String index, String id, Integer number);
/**
......
......@@ -82,4 +82,9 @@ public interface ISubjectInfoSourceMapService extends IService<SubjectInfoSource
* @date 2024/5/6
*/
List<SubjectStatisticsVo> subjectRealBindInfoSources(List<String> subjectIds);
/**
* 根据批量删除
*/
void deleteInfoSourceIds(String subjectId, List<String> infoSourceIds, Integer type);
}
......@@ -165,4 +165,8 @@ public interface SubjectService extends IService<Subject> {
void send(String subjectId, String status);
List<KeyWordsPage> bindKeyWordsListByIdsAndBindType(List<String> ids, String bindingType);
Result<?> infoSourceBindNew(SubjectPage subjectPage);
void deleteBindNew(SubjectPage subjectPage);
}
......@@ -118,6 +118,10 @@ public class ConfigurationMessageService {
private String keyWordsbindUrl;
@Value("${caiji.keyWordsEdit.url:http://1.95.79.85:8823/baseSourceInfo/api/keyword/edit}")
private String keyWordsEditUrl;
@Value("${caiji.allInfosourcebind.url:http://1.95.79.85:8823/baseSourceInfo/api/subject/infoSourceSave}")
private String allInfosourcebindUrl;
@Value("${caiji.allKeyWordsBind.url:http://1.95.79.85:8823/baseSourceInfo/api/subject/keywordSave}")
private String allKeyWordsBindUrl;
@Value("${caiji.projectCode:zzsn}")
private String projectCode;
@Value("${caiji.projectName:克虏宝}")
......@@ -322,9 +326,9 @@ public class ConfigurationMessageService {
keyWordsParam = getKeyWordsParam(byId, null, keyWords);
}
log.info("专题关键词配置通知采集{}",keyWordsParam);
log.info("专题关键词配置通知采集{}-{}",allKeyWordsBindUrl,keyWordsParam);
String post = HttpUtil.post(keyWordsbindUrl, keyWordsParam);
String post = HttpUtil.post(allKeyWordsBindUrl, keyWordsParam);
JSONObject entries = JSONUtil.parseObj(post);
//获取code状态码
Integer code = entries.getInt("code");
......@@ -353,8 +357,8 @@ public class ConfigurationMessageService {
getparam = getparam(byId, null, new ArrayList<>());
}
log.info("专题信息源配置通知采集{}",getparam);
String post = HttpUtil.post(infosourcebindUrl, getparam);
log.info("专题信息源配置通知采集{}-{}",allInfosourcebindUrl,getparam);
String post = HttpUtil.post(allInfosourcebindUrl, getparam);
JSONObject entries = JSONUtil.parseObj(post);
//获取code状态码
Integer code = entries.getInt("code");
......@@ -373,7 +377,7 @@ public class ConfigurationMessageService {
param.put("customerName",projectName);
param.put("keywordSign",byId.getId());
param.put("collectWordExp",byId.getKeyWord());
log.info("编辑关键词通知采集{}",JSONUtil.toJsonStr(param));
log.info("编辑关键词通知采集{}-{}",keyWordsEditUrl,JSONUtil.toJsonStr(param));
HttpUtil.post(keyWordsEditUrl,JSONUtil.toJsonStr(param));
}
......
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;
......@@ -20,6 +21,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;
......@@ -42,11 +45,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;
......@@ -88,14 +96,26 @@ 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;
@Autowired
private EsService esService;
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) {
......@@ -329,23 +349,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);
});
}
......@@ -378,6 +401,76 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
}
@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();
}
......@@ -724,4 +817,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]));
}
}
}
}
......@@ -58,6 +58,9 @@ public class KeyWordsServiceImpl extends ServiceImpl<KeyWordsMapper, KeyWords> i
private CodeGenerateUtil codeGenerateUtil;
@Autowired
private RedisUtil redisUtil;
@Autowired
private ConfigurationMessageService configurationMessageService;
@Resource
private KafkaTemplate<String,String> kafkaTemplate;
......@@ -168,6 +171,10 @@ public class KeyWordsServiceImpl extends ServiceImpl<KeyWordsMapper, KeyWords> i
if (StringUtils.isNotEmpty(keyWordsTypeId)) {
addMapMain(keyWords, keyWordsTypeId);
}
//通知采集更新配置
//同步配置到采集
configurationMessageService.sendEditKeyWordsConfigurationMessage(keyWords.getId());
}
@Override
......
......@@ -46,6 +46,9 @@ public class SubjectInfoSourceMapServiceImpl extends ServiceImpl<SubjectInfoSour
private InfoSourceGroupService infoSourceGroupService;
@Autowired
private ScoreModelService scoreModelService;
@Autowired
private ConfigurationMessageService configurationMessageService;
@Override
@Transactional
......@@ -60,6 +63,11 @@ public class SubjectInfoSourceMapServiceImpl extends ServiceImpl<SubjectInfoSour
}
@Override
public void deleteInfoSourceIds(String subjectId, List<String> infoSourceIds, Integer type) {
baseMapper.deleteInfoSourceIds(subjectId, infoSourceIds, type);
}
@Override
public List<String> subjectRealBindInfoSourceList(List<String> subjectIds) {
return baseMapper.subjectRealBindInfoSourceList(subjectIds);
}
......@@ -200,6 +208,9 @@ public class SubjectInfoSourceMapServiceImpl extends ServiceImpl<SubjectInfoSour
}
this.saveBatch(mapList);
//同步配置到采集
configurationMessageService.bindInfoSourceSend(subjectPage.getId());
}
@Override
......@@ -246,6 +257,8 @@ public class SubjectInfoSourceMapServiceImpl extends ServiceImpl<SubjectInfoSour
if (directionIds != null && directionIds.size() > 0) {
baseMapper.deleteInfoSourceIds(subjectPage.getId(), directionIds, BindTypeEnum.DIRECTIONA_INFO_SOURCE_GROUP.getvalue());
}
//同步配置到采集
configurationMessageService.bindInfoSourceSend(subjectPage.getId());
}
@Override
......
......@@ -63,6 +63,8 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
private ISubjectModelMapService subjectModelMapService;
@Autowired
private ScoreModelService scoreModelService;
@Autowired
private ConfigurationMessageService configurationMessageService;
@Autowired
private EsService esService;
......@@ -117,6 +119,9 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
scoreModel.setType("1");
scoreModel.setData(defaultConfig);
scoreModelService.save(scoreModel);
//同步配置到采集
configurationMessageService.bindInfoSourceSend(subjectId);
configurationMessageService.bindKeyWordsSend(subjectId);
return subject;
}
......@@ -252,6 +257,9 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
//关键词绑定
List<SearchWordVO> keywords = subjectSimpleVO.getKeywords();
modifyKeyword(subjectSimpleVO.getId(), subjectSimpleVO.getSubjectName(), keywords);
//同步配置到采集
configurationMessageService.bindInfoSourceSend(subjectSimpleVO.getId());
configurationMessageService.bindKeyWordsSend(subjectSimpleVO.getId());
}
@Override
......
package com.zzsn.event.vo;
import lombok.Data;
import java.util.List;
@Data
public class BindLabelVo {
private String labelCode ;
private String labelItemCode ;
private List<BindLabelVo> labelItems;
}
......@@ -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;
/**是否生成分析报告*/
......
......@@ -159,6 +159,22 @@ public class SubjectPage {
/**预估状态*/
private String estimateStatus;
/**
* 信息源绑定-新
* */
//id(可以是信息源组id集合,可以是信息源id集合)
private List<String> bindIds;
//信息源标签
private List<BindLabelVo> bindLabels;
//绑定类型类型(1:通用 2:定向 3:屏蔽)
private String sourceBindType;
//信息源类型(1:信息源组 2:信息源 3:标签)
private String sourceType;
/**
* 信息源绑定-新end
* */
private List<ClbModelArrange> clbModelArranges;
}
......@@ -153,6 +153,8 @@ kafka:
topic:
subject:
run: subjectModelTest
event:
run: eventSubjectModelTest
clb:
subject:
default:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论