提交 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 { ...@@ -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_TO_REDIS_PREFIX = "KEY_WORDS_TO_REDIS::";
//关键词采集通道 //关键词采集通道
public static final String KEY_WORDS_COLLECT_TOPIC = "eventKeyWordsInfo"; public static final String KEY_WORDS_COLLECT_TOPIC = "eventKeyWordsInfo";
public static final String EVENT_SUBJECT_MODEL = "eventSubjectModel";
/**获取真正的来源*/ /**获取真正的来源*/
public static String getRealOrigin(String origin){ public static String getRealOrigin(String origin){
...@@ -101,7 +100,8 @@ public class Constants { ...@@ -101,7 +100,8 @@ public class Constants {
return origin; 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 文件浏览地址 前部分 //obs 文件浏览地址 前部分
public static final String OBS_FILE_PATH_URL_PREFIX = "http://obs.ciglobal.cn/"; public static final String OBS_FILE_PATH_URL_PREFIX = "http://obs.ciglobal.cn/";
......
...@@ -14,6 +14,7 @@ import com.zzsn.event.entity.*; ...@@ -14,6 +14,7 @@ import com.zzsn.event.entity.*;
import com.zzsn.event.es.EsService; import com.zzsn.event.es.EsService;
import com.zzsn.event.feign.api.RemoteModelService; import com.zzsn.event.feign.api.RemoteModelService;
import com.zzsn.event.service.*; import com.zzsn.event.service.*;
import com.zzsn.event.service.impl.ConfigurationMessageService;
import com.zzsn.event.util.*; import com.zzsn.event.util.*;
import com.zzsn.event.util.tree.Node; import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.user.UserUtil; import com.zzsn.event.util.user.UserUtil;
...@@ -98,7 +99,8 @@ public class SubjectManageController { ...@@ -98,7 +99,8 @@ public class SubjectManageController {
private PythonUtil pythonUtil; private PythonUtil pythonUtil;
@Autowired(required = false) @Autowired(required = false)
private RemoteModelService remoteModelService; private RemoteModelService remoteModelService;
@Autowired
private ConfigurationMessageService configurationMessageService;
@Value("${kafka.topic.subject.run:}") @Value("${kafka.topic.subject.run:}")
private String SUBJECT_MODEL_KAFKA_CHANNEL; private String SUBJECT_MODEL_KAFKA_CHANNEL;
...@@ -123,7 +125,7 @@ public class SubjectManageController { ...@@ -123,7 +125,7 @@ public class SubjectManageController {
* @date 2025/1/7 * @date 2025/1/7
*/ */
@GetMapping("/dictItemList") @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); List<SysDictItem> dictItemList = sysDictItemService.listByDictCode(dictCode);
return Result.OK(dictItemList); return Result.OK(dictItemList);
} }
...@@ -438,8 +440,10 @@ public class SubjectManageController { ...@@ -438,8 +440,10 @@ public class SubjectManageController {
* @return * @return
*/ */
@GetMapping(value = "/bindKeyWordsList") @GetMapping(value = "/bindKeyWordsList")
public Result<?> bindKeyWordsList(@RequestParam(name = "id") String id, @RequestParam(name = "bindingType", required = false) String bindingType) { public Result<?> bindKeyWordsList(@RequestParam(name = "id") String id,@RequestParam(name = "bindingType",required = false) String bindingType) {
List<KeyWordsPage> bindKeyWordsList = subjectKeywordsMapService.bindKeyWordsList(id, bindingType); List<KeyWordsPage> bindKeyWordsList = subjectKeywordsMapService.bindKeyWordsList(id,bindingType);
//同步配置到采集
configurationMessageService.bindKeyWordsSend(id);
return Result.OK(bindKeyWordsList); return Result.OK(bindKeyWordsList);
} }
...@@ -605,6 +609,7 @@ public class SubjectManageController { ...@@ -605,6 +609,7 @@ public class SubjectManageController {
} }
/** /**
* 专题打分模型配置信息详情 * 专题打分模型配置信息详情
* *
...@@ -773,7 +778,7 @@ public class SubjectManageController { ...@@ -773,7 +778,7 @@ public class SubjectManageController {
List<String> sourceIdList = subjectSourceVO.getSourceIdList(); List<String> sourceIdList = subjectSourceVO.getSourceIdList();
if (CollectionUtils.isEmpty(sourceIdList)) { if (CollectionUtils.isEmpty(sourceIdList)) {
LambdaQueryWrapper<InfoSource> queryWrapper = Wrappers.lambdaQuery(); 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()) .in(InfoSource::getWebSiteName, subjectSourceVO.getWebSiteNameList())
.groupBy(InfoSource::getId); .groupBy(InfoSource::getId);
List<InfoSource> infoSources = infoSourceService.list(queryWrapper); List<InfoSource> infoSources = infoSourceService.list(queryWrapper);
...@@ -857,7 +862,7 @@ public class SubjectManageController { ...@@ -857,7 +862,7 @@ public class SubjectManageController {
* @date 2025/1/9 * @date 2025/1/9
*/ */
@PostMapping("/removeDirectInfoSource") @PostMapping("/removeDirectInfoSource")
public Result<?> removeDirectInfoSource(@RequestBody List<SubjectBindDirectSourceVO> params) { public Result<?> removeDirectInfoSource(@RequestBody List<SubjectBindDirectSourceVO> params){
for (SubjectBindDirectSourceVO param : params) { for (SubjectBindDirectSourceVO param : params) {
String subjectId = param.getSubjectId(); String subjectId = param.getSubjectId();
String webSiteName = param.getWebSiteName(); String webSiteName = param.getWebSiteName();
...@@ -870,7 +875,7 @@ public class SubjectManageController { ...@@ -870,7 +875,7 @@ public class SubjectManageController {
} else { } else {
List<String> webSiteNameList = new ArrayList<>(); List<String> webSiteNameList = new ArrayList<>();
webSiteNameList.add(webSiteName); 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()); sourceIdList = infoSources.stream().map(InfoSource::getId).collect(Collectors.toList());
} }
subjectInfoSourceMapService.remove(new LambdaQueryWrapper<SubjectInfoSourceMap>() subjectInfoSourceMapService.remove(new LambdaQueryWrapper<SubjectInfoSourceMap>()
...@@ -917,9 +922,9 @@ public class SubjectManageController { ...@@ -917,9 +922,9 @@ public class SubjectManageController {
if (originalFilename.endsWith(".xlsx") || originalFilename.endsWith(".xls")) { if (originalFilename.endsWith(".xlsx") || originalFilename.endsWith(".xls")) {
List<List<String>> dataList; List<List<String>> dataList;
if (originalFilename.endsWith(".xls")) { if (originalFilename.endsWith(".xls")) {
dataList = ExcelExportUtil.readExcelXls(file.getInputStream(), false, 1, 2); dataList = ExcelExportUtil.readExcelXls(file.getInputStream(), false,1, 2);
} else { } else {
dataList = ExcelExportUtil.readExcelXlsx(file.getInputStream(), false, 1, 2); dataList = ExcelExportUtil.readExcelXlsx(file.getInputStream(), false,1, 2);
} }
if (CollectionUtils.isNotEmpty(dataList)) { if (CollectionUtils.isNotEmpty(dataList)) {
boolean emptyFlag = false; boolean emptyFlag = false;
...@@ -1045,7 +1050,7 @@ public class SubjectManageController { ...@@ -1045,7 +1050,7 @@ public class SubjectManageController {
sourceIdList.add(countVO.getName()); sourceIdList.add(countVO.getName());
} }
LambdaQueryWrapper<InfoSource> queryWrapper = Wrappers.lambdaQuery(); 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); infoSources = infoSourceService.list(queryWrapper);
} }
return Result.OK(infoSources); return Result.OK(infoSources);
...@@ -1194,7 +1199,7 @@ public class SubjectManageController { ...@@ -1194,7 +1199,7 @@ public class SubjectManageController {
String originalFilename = file.getOriginalFilename(); String originalFilename = file.getOriginalFilename();
if (originalFilename.endsWith(".txt")) { if (originalFilename.endsWith(".txt")) {
parseTxt(text, file); parseTxt(text, file);
} else if (originalFilename.endsWith(".docx")) { } else if (originalFilename.endsWith(".docx")){
parseWordDocx(text, file); parseWordDocx(text, file);
} else if (originalFilename.endsWith(".doc")) { } else if (originalFilename.endsWith(".doc")) {
parseWordDoc(text, file); parseWordDoc(text, file);
...@@ -1218,7 +1223,7 @@ public class SubjectManageController { ...@@ -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<>(); List<StatisticsKeyWordVo> articleWordList = new ArrayList<>();
Map<String, Integer> hitWordsAndTimes = HanlpUtil.getHitWordsAndTimes(wordsList, text); Map<String, Integer> hitWordsAndTimes = HanlpUtil.getHitWordsAndTimes(wordsList, text);
for (Map.Entry<String, Integer> entry : hitWordsAndTimes.entrySet()) { for (Map.Entry<String, Integer> entry : hitWordsAndTimes.entrySet()) {
......
...@@ -21,6 +21,7 @@ import com.zzsn.event.vo.*; ...@@ -21,6 +21,7 @@ import com.zzsn.event.vo.*;
import com.zzsn.event.vo.es.DisplayInfo; import com.zzsn.event.vo.es.DisplayInfo;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -266,6 +267,10 @@ public class InformationController { ...@@ -266,6 +267,10 @@ public class InformationController {
public Result<?> add(@RequestBody JSONObject jsonObject) { public Result<?> add(@RequestBody JSONObject jsonObject) {
UserVo userVo = UserUtil.getLoginUser(); UserVo userVo = UserUtil.getLoginUser();
DisplayInfo displayInfo = JSON.parseObject(JSON.toJSONString(jsonObject.get("data")), DisplayInfo.class); 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"); Integer category = (Integer) jsonObject.get("category");
boolean modelFlag = pythonUtil.judgeDuplicate(displayInfo.getId(), displayInfo.getTitle(), displayInfo.getContent(), displayInfo.getSourceAddress(), displayInfo.getSubjectId()); boolean modelFlag = pythonUtil.judgeDuplicate(displayInfo.getId(), displayInfo.getTitle(), displayInfo.getContent(), displayInfo.getSourceAddress(), displayInfo.getSubjectId());
if (modelFlag) { if (modelFlag) {
......
package com.zzsn.event.controller.common; package com.zzsn.event.controller.common;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
...@@ -12,6 +13,7 @@ import com.zzsn.event.entity.InfoSourceGroup; ...@@ -12,6 +13,7 @@ import com.zzsn.event.entity.InfoSourceGroup;
import com.zzsn.event.service.*; import com.zzsn.event.service.*;
import com.zzsn.event.util.tree.Node; import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.*; import com.zzsn.event.vo.*;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -43,6 +45,8 @@ public class RelationBindController { ...@@ -43,6 +45,8 @@ public class RelationBindController {
private CommonService commonService; private CommonService commonService;
@Autowired @Autowired
private InfoSourceGroupService infoSourceGroupService; private InfoSourceGroupService infoSourceGroupService;
@Autowired
private SubjectService subjectService;
/** /**
* 项目列表 * 项目列表
...@@ -149,6 +153,18 @@ public class RelationBindController { ...@@ -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 参数 * @param subjectPage 参数
...@@ -161,6 +177,38 @@ public class RelationBindController { ...@@ -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 * @param subjectId 专题/事件id
......
...@@ -8,7 +8,6 @@ import com.zzsn.event.service.ISubjectTypeMapService; ...@@ -8,7 +8,6 @@ import com.zzsn.event.service.ISubjectTypeMapService;
import com.zzsn.event.service.ISubjectTypeService; import com.zzsn.event.service.ISubjectTypeService;
import com.zzsn.event.util.tree.Node; import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.tree.TreeUtil; 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.UserUtil;
import com.zzsn.event.util.user.UserVo; import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.SubjectTreeVO; import com.zzsn.event.vo.SubjectTreeVO;
......
...@@ -21,6 +21,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -21,6 +21,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -32,7 +33,7 @@ import java.util.List; ...@@ -32,7 +33,7 @@ import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
/** /**
* * 第三方(研究中心)调用
* *
* @author lkg * @author lkg
* @date 2024/10/12 * @date 2024/10/12
...@@ -63,8 +64,11 @@ public class EventApi { ...@@ -63,8 +64,11 @@ public class EventApi {
@Autowired @Autowired
private EventRegionMapService eventRegionMapService; private EventRegionMapService eventRegionMapService;
@Value("${kafka.topic.event.run:}")
private String EVENT_MODEL_KAFKA_CHANNEL;
/** /**
* 新增事件(页面简化版) * 新增事件
* *
* @param addEventVO 事件信息 * @param addEventVO 事件信息
* @author lkg * @author lkg
...@@ -90,7 +94,7 @@ public class EventApi { ...@@ -90,7 +94,7 @@ public class EventApi {
iXxlJobInfoService.keyWordsInsert(redisKeywordDTO); iXxlJobInfoService.keyWordsInsert(redisKeywordDTO);
//为了立即响应,关键词新增时放入一个首次录入消息队列 //为了立即响应,关键词新增时放入一个首次录入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(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); return Result.OK(event);
} else { } else {
......
...@@ -75,6 +75,8 @@ public class EventDataController { ...@@ -75,6 +75,8 @@ public class EventDataController {
@Value("${translate.url:}") @Value("${translate.url:}")
private String 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/"; private static final String prefix = "http://obs.ciglobal.cn/";
...@@ -185,7 +187,7 @@ public class EventDataController { ...@@ -185,7 +187,7 @@ public class EventDataController {
iXxlJobInfoService.keyWordsInsert(redisKeywordDTO); iXxlJobInfoService.keyWordsInsert(redisKeywordDTO);
//为了立即响应,关键词新增时放入一个首次录入消息队列 //为了立即响应,关键词新增时放入一个首次录入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(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(); return Result.OK();
} else { } else {
...@@ -300,9 +302,6 @@ public class EventDataController { ...@@ -300,9 +302,6 @@ public class EventDataController {
*/ */
@GetMapping(value = "/articleDetail") @GetMapping(value = "/articleDetail")
public Result<?> articleDetail(@RequestParam(required = false) String index, @RequestParam String id) { 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); SubjectDataVo subjectDataVo = esService.queryInfo(index, id);
return Result.OK(subjectDataVo); return Result.OK(subjectDataVo);
} }
......
...@@ -10,8 +10,10 @@ import com.zzsn.event.entity.Event; ...@@ -10,8 +10,10 @@ import com.zzsn.event.entity.Event;
import com.zzsn.event.entity.KeyWords; import com.zzsn.event.entity.KeyWords;
import com.zzsn.event.service.IEventService; import com.zzsn.event.service.IEventService;
import com.zzsn.event.service.IKeyWordsService; import com.zzsn.event.service.IKeyWordsService;
import com.zzsn.event.service.ISubjectInfoSourceMapService;
import com.zzsn.event.service.LabelEntityService; import com.zzsn.event.service.LabelEntityService;
import com.zzsn.event.util.RedisUtil; 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.UserUtil;
import com.zzsn.event.util.user.UserVo; import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*; import com.zzsn.event.vo.*;
...@@ -59,8 +61,8 @@ public class NewEventManageController { ...@@ -59,8 +61,8 @@ public class NewEventManageController {
@Resource @Resource
private KafkaTemplate<String, String> kafkaTemplate; private KafkaTemplate<String, String> kafkaTemplate;
@Value(("${serviceProject.url:}")) @Value("${kafka.topic.event.run:}")
private String SERVICE_PROJECT_URL; private String EVENT_MODEL_KAFKA_CHANNEL;
/** /**
* 分页列表-后台管理 * 分页列表-后台管理
...@@ -140,6 +142,7 @@ public class NewEventManageController { ...@@ -140,6 +142,7 @@ public class NewEventManageController {
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
//插入xxlJob //插入xxlJob
iXxlJobInfoService.eventInsert(event); iXxlJobInfoService.eventInsert(event);
//-------------关键词采集相关,需优化,采集那边说目前搜索引擎效果也不好,先这样。
//关键词入缓存 //关键词入缓存
KeyWordsDTO redisKeywordDTO = new KeyWordsDTO(); KeyWordsDTO redisKeywordDTO = new KeyWordsDTO();
BeanUtils.copyProperties(keyWords, redisKeywordDTO); BeanUtils.copyProperties(keyWords, redisKeywordDTO);
...@@ -151,8 +154,8 @@ public class NewEventManageController { ...@@ -151,8 +154,8 @@ public class NewEventManageController {
iXxlJobInfoService.keyWordsInsert(redisKeywordDTO); iXxlJobInfoService.keyWordsInsert(redisKeywordDTO);
//为了立即响应,关键词新增时放入消息队列 //为了立即响应,关键词新增时放入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(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(); return Result.OK();
} else { } else {
...@@ -161,6 +164,19 @@ public class NewEventManageController { ...@@ -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 编辑 * 1.3 编辑
* *
* @param addEventParam * @param addEventParam
...@@ -205,12 +221,12 @@ public class NewEventManageController { ...@@ -205,12 +221,12 @@ public class NewEventManageController {
*/ */
@GetMapping("/enable") @GetMapping("/enable")
public Result<?> enable(@RequestParam String eventId) { public Result<?> enable(@RequestParam String eventId) {
updateStatus(eventId, 1); eventService.updateStatus(eventId, 1);
return Result.OK(); return Result.OK();
} }
/** /**
* *
* *
* @param eventId 事件id * @param eventId 事件id
* @author lkg * @author lkg
...@@ -218,24 +234,22 @@ public class NewEventManageController { ...@@ -218,24 +234,22 @@ public class NewEventManageController {
*/ */
@GetMapping("/disable") @GetMapping("/disable")
public Result<?> disable(@RequestParam String eventId) { public Result<?> disable(@RequestParam String eventId) {
updateStatus(eventId, 0); eventService.updateStatus(eventId, 0);
return Result.OK(); 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()) * @param subjectId 专题id
.set(XxlJobInfo::getTriggerStatus, status)); * @author lkg
//关键词 * @date 2025/2/6
KeywordsVO keywordsVO = keyWordsService.keywordInfoByEventId(eventId); */
iXxlJobInfoService.update(Wrappers.<XxlJobInfo>lambdaUpdate().eq(XxlJobInfo::getInfoSourceCode, keywordsVO.getWordsCode()) @GetMapping("/clearData")
.set(XxlJobInfo::getTriggerStatus, status)); public Result<?> clearData(String subjectId){
if (1==status){ eventService.clearSubjectData(subjectId);
kafkaTemplate.send(Constants.EVENT_SUBJECT_MODEL, event.getEventCode()); return Result.OK("正在清空数据");
}
});
} }
/** /**
......
...@@ -19,163 +19,239 @@ import java.util.List; ...@@ -19,163 +19,239 @@ import java.util.List;
/** /**
* @Description: 事件 * @Description: 事件
* @Author: jeecg-boot * @Author: jeecg-boot
* @Date: 2024-03-14 * @Date: 2024-03-14
* @Version: V1.0 * @Version: V1.0
*/ */
@Data @Data
@TableName("event") @TableName("event")
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Accessors(chain = true) @Accessors(chain = true)
@ApiModel(value="event对象", description="事件") @ApiModel(value = "event对象", description = "事件")
public class Event { public class Event {
/**ID*/ /**
@TableId(type = IdType.ASSIGN_ID) * ID
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "ID") @ApiModelProperty(value = "ID")
private String id; private String id;
/**编码*/ /**
@Excel(name = "编码", width = 15) * 编码
@ApiModelProperty(value = "编码") */
private String eventCode; @Excel(name = "编码", width = 15)
/**名称*/ @ApiModelProperty(value = "编码")
@Excel(name = "名称", width = 15) private String eventCode;
/**
* 名称
*/
@Excel(name = "名称", width = 15)
@ApiModelProperty(value = "名称") @ApiModelProperty(value = "名称")
private String eventName; private String eventName;
/**图标*/ /**
@Excel(name = "图标", width = 15) * 图标
*/
@Excel(name = "图标", width = 15)
@ApiModelProperty(value = "图标") @ApiModelProperty(value = "图标")
private String eventIcon; private String eventIcon;
/**事件类型*/ /**
@Excel(name = "事件类型", width = 15) * 事件类型
*/
@Excel(name = "事件类型", width = 15)
@ApiModelProperty(value = "事件类型") @ApiModelProperty(value = "事件类型")
private String eventType; 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") @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")
@ApiModelProperty(value = "开始时间") @ApiModelProperty(value = "开始时间")
private Date startTime; 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") @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")
@ApiModelProperty(value = "结束时间") @ApiModelProperty(value = "结束时间")
private Date endTime; private Date endTime;
/**标签*/ /**
@Excel(name = "标签", width = 15) * 标签
*/
@Excel(name = "标签", width = 15)
@ApiModelProperty(value = "标签") @ApiModelProperty(value = "标签")
private String eventLabel; private String eventLabel;
/**是否公开*/ /**
@Excel(name = "是否公开", width = 15) * 是否公开
*/
@Excel(name = "是否公开", width = 15)
@ApiModelProperty(value = "是否公开") @ApiModelProperty(value = "是否公开")
private Integer facePublic; private Integer facePublic;
/**事件描述*/ /**
@Excel(name = "事件描述", width = 15) * 事件描述
*/
@Excel(name = "事件描述", width = 15)
@ApiModelProperty(value = "事件描述") @ApiModelProperty(value = "事件描述")
private String eventDescribe; private String eventDescribe;
/**创建人id*/ /**
@Excel(name = "创建人id", width = 15) * 创建人id
*/
@Excel(name = "创建人id", width = 15)
@ApiModelProperty(value = "创建人id") @ApiModelProperty(value = "创建人id")
private String createBy; 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") @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")
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
private Date createTime; 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") @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")
@ApiModelProperty(value = "修改时间") @ApiModelProperty(value = "修改时间")
private Date updateTime; private Date updateTime;
/**修改人id*/ /**
@Excel(name = "修改人id", width = 15) * 修改人id
*/
@Excel(name = "修改人id", width = 15)
@ApiModelProperty(value = "修改人id") @ApiModelProperty(value = "修改人id")
private String updateBy; private String updateBy;
/**状态(0-禁用;1-启用)*/ /**
private Integer status=1; * 状态(0-禁用;1-启用)
/** */
* 专题最近一次分析时间 private Integer status = 1;
*/ /**
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") * 专题最近一次分析时间
private Date analysisTime; */
/** @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
* 分析事件脉络-最新资讯的时间 private Date analysisTime;
*/ /**
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") * 分析事件脉络-最新资讯的时间
private Date eventTime; */
/**划分专题库*/ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "划分专题库") private Date eventTime;
private String library; /**
/**定时单位(1分;2小时;3日;4月)*/ * 划分专题库
@ApiModelProperty(value = "定时单位") */
private String unit; @ApiModelProperty(value = "划分专题库")
/**定时数值*/ private String library;
@ApiModelProperty(value = "定时数值") /**
private Integer space; * 定时单位(1分;2小时;3日;4月)
/**cron表达式*/ */
@ApiModelProperty(value = "cron表达式") @ApiModelProperty(value = "定时单位")
private String cron; private String unit;
/**是否提取热词*/ /**
@ApiModelProperty(value = "是否提取热词") * 定时数值
private String ynExtractHotWords; */
/**事件专题增量分析规则*/ @ApiModelProperty(value = "定时数值")
@ApiModelProperty(value = "事件专题增量分析规则") private Integer space;
private Integer increAnaRule; /**
/**事件专题总量分析规则*/ * cron表达式
@ApiModelProperty(value = "事件专题总量分析规则") */
private Integer totalAnaRule; @ApiModelProperty(value = "cron表达式")
/**事件专题时间间隔分析规则(天)*/ private String cron;
@ApiModelProperty(value = "事件专题时间间隔分析规则(天)") /**
private Integer timeAnaRule; * 是否提取热词
/**总热度*/ */
private Integer totalHot; @ApiModelProperty(value = "是否提取热词")
/**媒体热度*/ private String ynExtractHotWords;
private Integer mediaHot; /**
/**微信热度*/ * 事件专题增量分析规则
private Integer wechatHot; */
/**其他热度*/ @ApiModelProperty(value = "事件专题增量分析规则")
private Integer otherHot; private Integer increAnaRule;
/**发布状态(0-未发布;1-已发布)*/ /**
private Integer publishStatus; * 事件专题总量分析规则
/**关联事件*/ */
private String relationEvents; @ApiModelProperty(value = "事件专题总量分析规则")
/**发布时间*/ private Integer totalAnaRule;
private String publishDate; /**
/**排序号*/ * 事件专题时间间隔分析规则(天)
private Integer sortOrder; */
/**事件创建方式(1-用户直接创建;2-基于挖掘的事件创建)*/ @ApiModelProperty(value = "事件专题时间间隔分析规则(天)")
private Integer category; private Integer timeAnaRule;
/**
* 总热度
*/
private Integer totalHot;
/**
* 媒体热度
*/
private Integer mediaHot;
/**
* 微信热度
*/
private Integer wechatHot;
/**
* 其他热度
*/
private Integer otherHot;
/**
* 发布状态(0-未发布;1-已发布)
*/
private Integer publishStatus;
/**
* 关联事件
*/
private String relationEvents;
/**
* 发布时间
*/
private String publishDate;
/**
* 排序号
*/
private Integer sortOrder;
/**
* 事件创建方式(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; */
@TableField(exist = false)
private KeyWords keyWords;
@TableField(exist = false) @TableField(exist = false)
private String typeName; private String typeName;
@TableField(exist = false) @TableField(exist = false)
private String startDate; private String startDate;
@TableField(exist = false) @TableField(exist = false)
private String endDate; private String endDate;
@TableField(exist = false) @TableField(exist = false)
private List<Event> relatedEventList; private List<Event> relatedEventList;
@TableField(exist = false) @TableField(exist = false)
private EventTag eventTag; private EventTag eventTag;
@TableField(exist = false) @TableField(exist = false)
private String extractIndustryTag; private String extractIndustryTag;
@TableField(exist = false) @TableField(exist = false)
private String extractCompanyTag; private String extractCompanyTag;
@TableField(exist = false) @TableField(exist = false)
private String extractPersonTag; private String extractPersonTag;
@TableField(exist = false) @TableField(exist = false)
private String extractSentimentTag; private String extractSentimentTag;
@TableField(exist = false) @TableField(exist = false)
private String extractKeywordsTag; private String extractKeywordsTag;
@TableField(exist = false) @TableField(exist = false)
private String extractLocationTag; private String extractLocationTag;
@TableField(exist = false) @TableField(exist = false)
private String extractTimeTag; private String extractTimeTag;
@TableField(exist = false) @TableField(exist = false)
private String keyword; private String keyword;
} }
...@@ -300,6 +300,9 @@ public class EsService { ...@@ -300,6 +300,9 @@ public class EsService {
public SubjectDataVo queryInfo(String index, String id) { public SubjectDataVo queryInfo(String index, String id) {
SubjectDataVo subjectDataVo = new SubjectDataVo(); SubjectDataVo subjectDataVo = new SubjectDataVo();
try { try {
if (StringUtils.isBlank(index)) {
index = Constants.SUBJECT_INDEX;
}
SearchRequest searchRequest = new SearchRequest(index); SearchRequest searchRequest = new SearchRequest(index);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.size(1); searchSourceBuilder.size(1);
......
...@@ -135,6 +135,25 @@ public interface IEventService extends IService<Event> { ...@@ -135,6 +135,25 @@ public interface IEventService extends IService<Event> {
void deleteMain(String id); 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); List<StatisticsKeyWordVo> hotWords(String index, String id, Integer number);
/** /**
......
...@@ -82,4 +82,9 @@ public interface ISubjectInfoSourceMapService extends IService<SubjectInfoSource ...@@ -82,4 +82,9 @@ public interface ISubjectInfoSourceMapService extends IService<SubjectInfoSource
* @date 2024/5/6 * @date 2024/5/6
*/ */
List<SubjectStatisticsVo> subjectRealBindInfoSources(List<String> subjectIds); 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> { ...@@ -165,4 +165,8 @@ public interface SubjectService extends IService<Subject> {
void send(String subjectId, String status); void send(String subjectId, String status);
List<KeyWordsPage> bindKeyWordsListByIdsAndBindType(List<String> ids, String bindingType); List<KeyWordsPage> bindKeyWordsListByIdsAndBindType(List<String> ids, String bindingType);
Result<?> infoSourceBindNew(SubjectPage subjectPage);
void deleteBindNew(SubjectPage subjectPage);
} }
...@@ -118,6 +118,10 @@ public class ConfigurationMessageService { ...@@ -118,6 +118,10 @@ public class ConfigurationMessageService {
private String keyWordsbindUrl; private String keyWordsbindUrl;
@Value("${caiji.keyWordsEdit.url:http://1.95.79.85:8823/baseSourceInfo/api/keyword/edit}") @Value("${caiji.keyWordsEdit.url:http://1.95.79.85:8823/baseSourceInfo/api/keyword/edit}")
private String keyWordsEditUrl; 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}") @Value("${caiji.projectCode:zzsn}")
private String projectCode; private String projectCode;
@Value("${caiji.projectName:克虏宝}") @Value("${caiji.projectName:克虏宝}")
...@@ -322,9 +326,9 @@ public class ConfigurationMessageService { ...@@ -322,9 +326,9 @@ public class ConfigurationMessageService {
keyWordsParam = getKeyWordsParam(byId, null, keyWords); 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); JSONObject entries = JSONUtil.parseObj(post);
//获取code状态码 //获取code状态码
Integer code = entries.getInt("code"); Integer code = entries.getInt("code");
...@@ -353,8 +357,8 @@ public class ConfigurationMessageService { ...@@ -353,8 +357,8 @@ public class ConfigurationMessageService {
getparam = getparam(byId, null, new ArrayList<>()); getparam = getparam(byId, null, new ArrayList<>());
} }
log.info("专题信息源配置通知采集{}",getparam); log.info("专题信息源配置通知采集{}-{}",allInfosourcebindUrl,getparam);
String post = HttpUtil.post(infosourcebindUrl, getparam); String post = HttpUtil.post(allInfosourcebindUrl, getparam);
JSONObject entries = JSONUtil.parseObj(post); JSONObject entries = JSONUtil.parseObj(post);
//获取code状态码 //获取code状态码
Integer code = entries.getInt("code"); Integer code = entries.getInt("code");
...@@ -373,7 +377,7 @@ public class ConfigurationMessageService { ...@@ -373,7 +377,7 @@ public class ConfigurationMessageService {
param.put("customerName",projectName); param.put("customerName",projectName);
param.put("keywordSign",byId.getId()); param.put("keywordSign",byId.getId());
param.put("collectWordExp",byId.getKeyWord()); param.put("collectWordExp",byId.getKeyWord());
log.info("编辑关键词通知采集{}",JSONUtil.toJsonStr(param)); log.info("编辑关键词通知采集{}-{}",keyWordsEditUrl,JSONUtil.toJsonStr(param));
HttpUtil.post(keyWordsEditUrl,JSONUtil.toJsonStr(param)); HttpUtil.post(keyWordsEditUrl,JSONUtil.toJsonStr(param));
} }
......
package com.zzsn.event.service.impl; package com.zzsn.event.service.impl;
import cn.hutool.core.map.MapUtil; 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.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
...@@ -20,6 +21,8 @@ import com.zzsn.event.util.tree.TreeUtil; ...@@ -20,6 +21,8 @@ import com.zzsn.event.util.tree.TreeUtil;
import com.zzsn.event.util.user.UserUtil; import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo; import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*; 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 lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -42,11 +45,16 @@ import org.elasticsearch.search.sort.SortOrder; ...@@ -42,11 +45,16 @@ import org.elasticsearch.search.sort.SortOrder;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -88,14 +96,26 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -88,14 +96,26 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
private SubjectAnalysisService subjectAnalysisService; private SubjectAnalysisService subjectAnalysisService;
@Autowired @Autowired
private EventAnalysisReportService eventAnalysisReportService; private EventAnalysisReportService eventAnalysisReportService;
@Autowired
private IXxlJobInfoService iXxlJobInfoService;
@Autowired
private CommonService commonService;
@Resource @Resource
private RestHighLevelClient client; private RestHighLevelClient client;
@Resource
private KafkaTemplate<String, String> kafkaTemplate;
@Autowired @Autowired
private CommonService commonService; private CommonService commonService;
@Autowired @Autowired
private EsService esService; 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 @Override
public List<SubjectKafkaVo> progressList(Date disableDate) { public List<SubjectKafkaVo> progressList(Date disableDate) {
...@@ -329,23 +349,26 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -329,23 +349,26 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
@Override @Override
@Transactional @Transactional
public void updateMain(AddEventParam addEventParam) { public void updateMain(AddEventParam addEventParam) {
Event subject = new Event(); Event oldEvent = this.getById(addEventParam.getId());
BeanUtils.copyProperties(addEventParam, subject); Event event = new Event();
String eventId = subject.getId(); BeanUtils.copyProperties(addEventParam, event);
baseMapper.updateById(subject); String eventId = event.getId();
baseMapper.updateById(event);
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
//专题-类别、项目的绑定关系处理 //专题-类别、项目的绑定关系处理
//删除专题-类别绑定关系 //删除专题-类别绑定关系
iSubjectTypeMapService.deleteBySubjectId(subject.getId()); iSubjectTypeMapService.deleteBySubjectId(event.getId());
//删除专题-项目的绑定关系 //删除专题-项目的绑定关系
iProjectSubjectMapService.deleteBySubjectId(subject.getId()); iProjectSubjectMapService.deleteBySubjectId(event.getId());
saveMapMain(subject, addEventParam); saveMapMain(event, addEventParam);
//地域关系处理 //地域关系处理
LambdaQueryWrapper<EventRegionMap> queryWrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<EventRegionMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(EventRegionMap::getEventId, eventId); queryWrapper.eq(EventRegionMap::getEventId, eventId);
eventRegionMapService.remove(queryWrapper); eventRegionMapService.remove(queryWrapper);
List<RegionVO> regionList = addEventParam.getRegionList(); List<RegionVO> regionList = addEventParam.getRegionList();
addRegionMap(eventId, regionList); addRegionMap(eventId, regionList);
//修改redis缓存,,用于向事件里补充数据
updateRedisCache(event, oldEvent);
}); });
} }
...@@ -378,6 +401,76 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -378,6 +401,76 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
} }
@Override @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() { public List<ModelVO> modelList() {
return baseMapper.modelList(); return baseMapper.modelList();
} }
...@@ -724,4 +817,34 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -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 ...@@ -58,6 +58,9 @@ public class KeyWordsServiceImpl extends ServiceImpl<KeyWordsMapper, KeyWords> i
private CodeGenerateUtil codeGenerateUtil; private CodeGenerateUtil codeGenerateUtil;
@Autowired @Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Autowired
private ConfigurationMessageService configurationMessageService;
@Resource @Resource
private KafkaTemplate<String,String> kafkaTemplate; private KafkaTemplate<String,String> kafkaTemplate;
...@@ -168,6 +171,10 @@ public class KeyWordsServiceImpl extends ServiceImpl<KeyWordsMapper, KeyWords> i ...@@ -168,6 +171,10 @@ public class KeyWordsServiceImpl extends ServiceImpl<KeyWordsMapper, KeyWords> i
if (StringUtils.isNotEmpty(keyWordsTypeId)) { if (StringUtils.isNotEmpty(keyWordsTypeId)) {
addMapMain(keyWords, keyWordsTypeId); addMapMain(keyWords, keyWordsTypeId);
} }
//通知采集更新配置
//同步配置到采集
configurationMessageService.sendEditKeyWordsConfigurationMessage(keyWords.getId());
} }
@Override @Override
......
...@@ -46,6 +46,9 @@ public class SubjectInfoSourceMapServiceImpl extends ServiceImpl<SubjectInfoSour ...@@ -46,6 +46,9 @@ public class SubjectInfoSourceMapServiceImpl extends ServiceImpl<SubjectInfoSour
private InfoSourceGroupService infoSourceGroupService; private InfoSourceGroupService infoSourceGroupService;
@Autowired @Autowired
private ScoreModelService scoreModelService; private ScoreModelService scoreModelService;
@Autowired
private ConfigurationMessageService configurationMessageService;
@Override @Override
@Transactional @Transactional
...@@ -60,6 +63,11 @@ public class SubjectInfoSourceMapServiceImpl extends ServiceImpl<SubjectInfoSour ...@@ -60,6 +63,11 @@ public class SubjectInfoSourceMapServiceImpl extends ServiceImpl<SubjectInfoSour
} }
@Override @Override
public void deleteInfoSourceIds(String subjectId, List<String> infoSourceIds, Integer type) {
baseMapper.deleteInfoSourceIds(subjectId, infoSourceIds, type);
}
@Override
public List<String> subjectRealBindInfoSourceList(List<String> subjectIds) { public List<String> subjectRealBindInfoSourceList(List<String> subjectIds) {
return baseMapper.subjectRealBindInfoSourceList(subjectIds); return baseMapper.subjectRealBindInfoSourceList(subjectIds);
} }
...@@ -200,6 +208,9 @@ public class SubjectInfoSourceMapServiceImpl extends ServiceImpl<SubjectInfoSour ...@@ -200,6 +208,9 @@ public class SubjectInfoSourceMapServiceImpl extends ServiceImpl<SubjectInfoSour
} }
this.saveBatch(mapList); this.saveBatch(mapList);
//同步配置到采集
configurationMessageService.bindInfoSourceSend(subjectPage.getId());
} }
@Override @Override
...@@ -246,6 +257,8 @@ public class SubjectInfoSourceMapServiceImpl extends ServiceImpl<SubjectInfoSour ...@@ -246,6 +257,8 @@ public class SubjectInfoSourceMapServiceImpl extends ServiceImpl<SubjectInfoSour
if (directionIds != null && directionIds.size() > 0) { if (directionIds != null && directionIds.size() > 0) {
baseMapper.deleteInfoSourceIds(subjectPage.getId(), directionIds, BindTypeEnum.DIRECTIONA_INFO_SOURCE_GROUP.getvalue()); baseMapper.deleteInfoSourceIds(subjectPage.getId(), directionIds, BindTypeEnum.DIRECTIONA_INFO_SOURCE_GROUP.getvalue());
} }
//同步配置到采集
configurationMessageService.bindInfoSourceSend(subjectPage.getId());
} }
@Override @Override
......
...@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateTime; ...@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
...@@ -94,6 +95,14 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -94,6 +95,14 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
private IKeyWordsService iKeyWordsService; private IKeyWordsService iKeyWordsService;
@Autowired @Autowired
private IClbModelArrangeService clbModelArrangeService; private IClbModelArrangeService clbModelArrangeService;
@Autowired
private ConfigurationMessageService configurationMessageService;
@Autowired
private ScoreModelService scoreModelService;
@Autowired
private InfoSourceGroupService infoSourceGroupService;
@Autowired
private ISubjectInfoSourceMapService iSubjectInfoSourceMapService;
@Value("${python.subjectProcessorUrl}") @Value("${python.subjectProcessorUrl}")
private String subjectProcessorUrl; private String subjectProcessorUrl;
...@@ -303,6 +312,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -303,6 +312,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
subjectInfoSourceMapService.save(subjectInfoSourceMap); subjectInfoSourceMapService.save(subjectInfoSourceMap);
} }
} }
//同步配置到采集
configurationMessageService.bindInfoSourceSend(subjectId);
} }
@Override @Override
...@@ -327,6 +338,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -327,6 +338,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
subjectInfoSourceMapService.save(subjectInfoSourceMap); subjectInfoSourceMapService.save(subjectInfoSourceMap);
} }
} }
//同步配置到采集
configurationMessageService.bindInfoSourceSend(subjectId);
} }
@Override @Override
...@@ -345,6 +358,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -345,6 +358,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
.eq(SubjectInfoSourceMap::getType, 3); .eq(SubjectInfoSourceMap::getType, 3);
subjectInfoSourceMapService.remove(queryWrapper); subjectInfoSourceMapService.remove(queryWrapper);
} }
//同步配置到采集
configurationMessageService.bindInfoSourceSend(subjectId);
} }
@Override @Override
...@@ -362,6 +377,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -362,6 +377,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
} }
subjectKeywordsMapService.saveBatch(mapList); subjectKeywordsMapService.saveBatch(mapList);
} }
//同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectPage.getId());
} }
@Override @Override
...@@ -378,6 +395,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -378,6 +395,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
redisUtil.del(Constants.KEY_WORDS_TO_REDIS_PREFIX + keyWordsPage.getWordsCode()); redisUtil.del(Constants.KEY_WORDS_TO_REDIS_PREFIX + keyWordsPage.getWordsCode());
} }
} }
//同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectPage.getId());
} }
@Override @Override
...@@ -643,7 +662,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -643,7 +662,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
String format = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); String format = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
dateList.add(format); 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]));
} }
/** /**
...@@ -698,7 +717,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -698,7 +717,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
} }
} }
if (CollectionUtils.isNotEmpty(newDateList)) { 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]));
} }
} }
} }
...@@ -710,5 +729,307 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -710,5 +729,307 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
} }
@Override
@Transactional
public Result<?> infoSourceBindNew(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("解绑标签不能为空");
}
//绑定信息源组
if (StrUtil.equals(subjectPage.getSourceType(),"1")) {
bindInfoSourceGroup(subjectPage);
}
//绑定信息源
if (StrUtil.equals(subjectPage.getSourceType(),"2")) {
bindInfoSource(subjectPage);
}
//绑定标签
if (StrUtil.equals(subjectPage.getSourceType(),"3")) {
bindLabels(subjectPage);
}
configurationMessageService.bindInfoSourceSend(subjectId);
return Result.OK("绑定成功");
}
@Override
@Transactional
public void deleteBindNew(SubjectPage subjectPage) {
//解绑信息源组
if (StrUtil.equals(subjectPage.getSourceType(),"1")) {
unBindInfoSourceGroup(subjectPage);
}
//解绑信息源
if (StrUtil.equals(subjectPage.getSourceType(),"2")) {
unBindInfoSource(subjectPage);
}
//解绑标签
if (StrUtil.equals(subjectPage.getSourceType(),"3")) {
unBindLabels(subjectPage);
}
configurationMessageService.bindInfoSourceSend(subjectPage.getId());
}
private void unBindInfoSourceGroup(SubjectPage subjectPage) {
String sourceBindType = subjectPage.getSourceBindType();
List<String> idList = subjectPage.getBindIds();
if(CollectionUtil.isEmpty(idList)){
return ;
}
if (StrUtil.equals(sourceBindType,"1")) {
//解绑通用信息源组
unbindInfoSource(subjectPage, idList, BindTypeEnum.INFO_SOURCE_GROUP.getvalue());
}
if (StrUtil.equals(sourceBindType,"2")) {
//解绑定向信息源组
unbindInfoSource(subjectPage, idList, BindTypeEnum.DIRECTIONA_INFO_SOURCE_GROUP.getvalue());
}
if (StrUtil.equals(sourceBindType,"3")) {
//解绑屏蔽信息源组
unbindInfoSource(subjectPage, idList, BindTypeEnum.EXCLUDE_INFO_SOURCE_GROUP.getvalue());
}
}
private void unBindLabels(SubjectPage subjectPage) {
String sourceBindType = subjectPage.getSourceBindType();
List<BindLabelVo> bindLabels = subjectPage.getBindLabels();
if(CollectionUtil.isEmpty(bindLabels)){
return ;
}
if (StrUtil.equals(sourceBindType,"1")) {
//解绑通用标签
unBindLabel(subjectPage, BindTypeEnum.INFO_SOURCE_LABEL.getvalue());
}
if (StrUtil.equals(sourceBindType,"2")) {
//解绑定向标签
unBindLabel(subjectPage, BindTypeEnum.DIRECTIONA_INFO_SOURCE_LABEL.getvalue());
}
if (StrUtil.equals(sourceBindType,"3")) {
//解绑屏蔽标签
unBindLabel(subjectPage, BindTypeEnum.EXCLUDE_INFO_SOURCE_LABEL.getvalue());
}
}
private void unBindLabel(SubjectPage subjectPage, Integer type) {
List<BindLabelVo> bindLabels = subjectPage.getBindLabels();
if(CollectionUtil.isEmpty(bindLabels)){
return ;
}
Set<String> labelCode = new HashSet<>();
Set<String> labelItemCode = new HashSet<>();
List<SubjectInfoSourceMap> mapList = new ArrayList<>();
for (BindLabelVo bindLabelVo : bindLabels) {
labelCode.add(bindLabelVo.getLabelCode());
labelItemCode.add(bindLabelVo.getLabelItemCode());
}
iSubjectInfoSourceMapService.remove(Wrappers.<SubjectInfoSourceMap>lambdaQuery()
.in(SubjectInfoSourceMap::getSourceId,labelCode)
.in(SubjectInfoSourceMap::getSourceItemId,labelItemCode)
.eq(SubjectInfoSourceMap::getSubjectId,subjectPage.getId())
.eq(SubjectInfoSourceMap::getType,type));
}
private void unBindInfoSource(SubjectPage subjectPage) {
String sourceBindType = subjectPage.getSourceBindType();
List<String> idList = subjectPage.getBindIds();
if(CollectionUtil.isEmpty(idList)){
return ;
}
if (StrUtil.equals(sourceBindType,"1")) {
//解绑通用信息源
unbindInfoSource(subjectPage, idList, BindTypeEnum.INFO_SOURCE.getvalue());
}
if (StrUtil.equals(sourceBindType,"2")) {
//解绑定向信息源
unbindInfoSource(subjectPage, idList, BindTypeEnum.DIRECTIONA_INFO_SOURCE.getvalue());
}
if (StrUtil.equals(sourceBindType,"3")) {
//解绑屏蔽信息源
unbindInfoSource(subjectPage, idList, BindTypeEnum.EXCLUDE_INFO_SOURCE.getvalue());
}
}
private void unbindInfoSource(SubjectPage subjectPage, List<String> idList, Integer bindType) {
iSubjectInfoSourceMapService.deleteInfoSourceIds(subjectPage.getId(), idList, bindType);
if (BindTypeEnum.INFO_SOURCE_GROUP.getvalue().equals(bindType)) {
//更改打分模型中的信息源组绑定情况
List<ScoreModelVo> scoreModelList = scoreModelService.queryScoreModel(subjectPage.getId(), null);
for (String groupId : idList) {
for (ScoreModelVo scoreModel : scoreModelList) {
JSONArray jsonArray = JSONArray.parseArray(scoreModel.getData().toString());
JSONObject jsonObject = jsonArray.getJSONObject(0);
JSONArray children = jsonObject.getJSONArray("children");
//若信息源打分配置中已经存在的有相同的,则去除掉这部分
for (int i = 0; i < children.size(); i++) {
String infoSourceGroupId = children.getJSONObject(i).getString("infoSourceGroupId");
if (groupId.equals(infoSourceGroupId)) {
children.remove(i);
break;
}
}
jsonObject.put("children", children);
jsonArray.remove(0);
jsonArray.add(0, jsonObject);
scoreModel.setData(jsonArray.toJSONString());
scoreModel.setChangeType(0);
//去除完之后,更新进去
scoreModelService.addOrUpdate(scoreModel,subjectPage.getCategory());
}
}
}
}
private void bindInfoSourceGroup(SubjectPage subjectPage) {
String sourceBindType = subjectPage.getSourceBindType();
List<String> idList = subjectPage.getBindIds();
if(CollectionUtil.isEmpty(idList)){
return ;
}
if (StrUtil.equals(sourceBindType,"1")) {
//绑定通用信息源组
bindInfoSource(subjectPage, idList, BindTypeEnum.INFO_SOURCE_GROUP.getvalue());
}
if (StrUtil.equals(sourceBindType,"2")) {
//绑定定向信息源组
bindInfoSource(subjectPage, idList, BindTypeEnum.DIRECTIONA_INFO_SOURCE_GROUP.getvalue());
}
if (StrUtil.equals(sourceBindType,"3")) {
//绑定屏蔽信息源组
bindInfoSource(subjectPage, idList, BindTypeEnum.EXCLUDE_INFO_SOURCE_GROUP.getvalue());
}
}
private void bindInfoSource(SubjectPage subjectPage, List<String> idList, Integer type) {
List<SubjectInfoSourceMap> mapList = new ArrayList<>();
for (String infoSourceId : idList) {
SubjectInfoSourceMap subjectInfoSourceMap = new SubjectInfoSourceMap();
subjectInfoSourceMap.setSourceId(infoSourceId);
subjectInfoSourceMap.setSubjectId(subjectPage.getId());
subjectInfoSourceMap.setType(type);
mapList.add(subjectInfoSourceMap);
}
if (BindTypeEnum.INFO_SOURCE_GROUP.getvalue().equals(type)) {
//判断打分模型是否存在过,若存在则更改
List<ScoreModelVo> scoreModelList = scoreModelService.queryScoreModel(subjectPage.getId(), null);
for (ScoreModelVo scoreModelVo : scoreModelList) {
String typeId = scoreModelVo.getType();
JSONArray jsonArray = JSONArray.parseArray(scoreModelVo.getData().toString());
JSONObject jsonObject = jsonArray.getJSONObject(0);
JSONArray children = jsonObject.getJSONArray("children");
int count = children.size();
//判断是否存在节点(没有则直接添加)
if (count == 0) {
for (int i = 0; i < idList.size(); i++) {
InfoSourceGroup group = infoSourceGroupService.getGroupById(idList.get(i));
if (group != null) {
String newId = typeId + "-1-" + (i + 1);
JSONObject childJsonObject = new JSONObject();
childJsonObject.put("name", group.getGroupName());
childJsonObject.put("id", newId);
childJsonObject.put("infoSourceGroupId", idList.get(i));
childJsonObject.put("fraction", 80);
children.add(childJsonObject);
}
}
} else {
String id = children.getJSONObject(count - 1).getString("id");
for (int i = 0; i < idList.size(); i++) {
InfoSourceGroup group = infoSourceGroupService.getGroupById(idList.get(i));
if (group != null) {
String newId = typeId + "-1-" + (Integer.parseInt(id.substring(id.lastIndexOf("-") + 1)) + i + 1);
JSONObject childJsonObject = new JSONObject();
childJsonObject.put("name", group.getGroupName());
childJsonObject.put("id", newId);
childJsonObject.put("infoSourceGroupId", idList.get(i));
childJsonObject.put("fraction", 80);
children.add(childJsonObject);
}
}
}
jsonObject.put("children", children);
jsonArray.remove(0);
jsonArray.add(0, jsonObject);
scoreModelVo.setData(jsonArray.toJSONString());
scoreModelVo.setChangeType(0);
//增加完之后,更新进去
scoreModelService.addOrUpdate(scoreModelVo,subjectPage.getCategory());
}
}
iSubjectInfoSourceMapService.saveBatch(mapList);
}
private void bindInfoSource(SubjectPage subjectPage) {
String sourceBindType = subjectPage.getSourceBindType();
List<String> idList = subjectPage.getBindIds();
if(CollectionUtil.isEmpty(idList)){
return ;
}
if (StrUtil.equals(sourceBindType,"1")) {
//绑定通用信息源
bindInfoSource(subjectPage, idList, BindTypeEnum.INFO_SOURCE.getvalue());
}
if (StrUtil.equals(sourceBindType,"2")) {
//绑定定向信息源
bindInfoSource(subjectPage, idList, BindTypeEnum.DIRECTIONA_INFO_SOURCE.getvalue());
}
if (StrUtil.equals(sourceBindType,"3")) {
//绑定屏蔽信息源
bindInfoSource(subjectPage, idList, BindTypeEnum.EXCLUDE_INFO_SOURCE.getvalue());
}
}
private void bindLabels(SubjectPage subjectPage) {
String subjectId = subjectPage.getId();
String sourceBindType = subjectPage.getSourceBindType();
List<BindLabelVo> bindLabels = subjectPage.getBindLabels();
if(CollectionUtil.isEmpty(bindLabels)){
return ;
}
if (StrUtil.equals(sourceBindType,"1")) {
//绑定通用标签信息源
bindLabels(subjectId, bindLabels, BindTypeEnum.INFO_SOURCE_LABEL.getvalue());
}
if (StrUtil.equals(sourceBindType,"2")) {
//绑定定向标签信息源
bindLabels(subjectId, bindLabels, BindTypeEnum.DIRECTIONA_INFO_SOURCE_LABEL.getvalue());
}
if (StrUtil.equals(sourceBindType,"3")) {
//绑定屏蔽标签信息源
bindLabels(subjectId, bindLabels, BindTypeEnum.EXCLUDE_INFO_SOURCE_LABEL.getvalue());
}
}
private void bindLabels(String subjectId, List<BindLabelVo> bindLabels, Integer bindType) {
List<SubjectInfoSourceMap> mapList = new ArrayList<>();
for (BindLabelVo infoSourceId : bindLabels) {
SubjectInfoSourceMap subjectInfoSourceMap = new SubjectInfoSourceMap();
subjectInfoSourceMap.setSourceId(infoSourceId.getLabelCode());
subjectInfoSourceMap.setSourceItemId(infoSourceId.getLabelItemCode());
subjectInfoSourceMap.setSubjectId(subjectId);
subjectInfoSourceMap.setType(bindType);
mapList.add(subjectInfoSourceMap);
}
iSubjectInfoSourceMapService.saveBatch(mapList);
}
} }
...@@ -63,6 +63,8 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -63,6 +63,8 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
private ISubjectModelMapService subjectModelMapService; private ISubjectModelMapService subjectModelMapService;
@Autowired @Autowired
private ScoreModelService scoreModelService; private ScoreModelService scoreModelService;
@Autowired
private ConfigurationMessageService configurationMessageService;
@Autowired @Autowired
private EsService esService; private EsService esService;
...@@ -117,6 +119,9 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -117,6 +119,9 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
scoreModel.setType("1"); scoreModel.setType("1");
scoreModel.setData(defaultConfig); scoreModel.setData(defaultConfig);
scoreModelService.save(scoreModel); scoreModelService.save(scoreModel);
//同步配置到采集
configurationMessageService.bindInfoSourceSend(subjectId);
configurationMessageService.bindKeyWordsSend(subjectId);
return subject; return subject;
} }
...@@ -252,6 +257,9 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -252,6 +257,9 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
//关键词绑定 //关键词绑定
List<SearchWordVO> keywords = subjectSimpleVO.getKeywords(); List<SearchWordVO> keywords = subjectSimpleVO.getKeywords();
modifyKeyword(subjectSimpleVO.getId(), subjectSimpleVO.getSubjectName(), keywords); modifyKeyword(subjectSimpleVO.getId(), subjectSimpleVO.getSubjectName(), keywords);
//同步配置到采集
configurationMessageService.bindInfoSourceSend(subjectSimpleVO.getId());
configurationMessageService.bindKeyWordsSend(subjectSimpleVO.getId());
} }
@Override @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; ...@@ -3,6 +3,7 @@ package com.zzsn.event.vo;
import com.zzsn.event.entity.EventTag; import com.zzsn.event.entity.EventTag;
import lombok.Data; import lombok.Data;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -54,6 +55,7 @@ public class EventVO { ...@@ -54,6 +55,7 @@ public class EventVO {
private String projectId; private String projectId;
/**排序号*/ /**排序号*/
private Integer sortOrder; private Integer sortOrder;
private Date firstOpenTime;
/**是否生成分析报告*/ /**是否生成分析报告*/
......
...@@ -159,6 +159,22 @@ public class SubjectPage { ...@@ -159,6 +159,22 @@ public class SubjectPage {
/**预估状态*/ /**预估状态*/
private String estimateStatus; 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; private List<ClbModelArrange> clbModelArranges;
} }
...@@ -153,6 +153,8 @@ kafka: ...@@ -153,6 +153,8 @@ kafka:
topic: topic:
subject: subject:
run: subjectModelTest run: subjectModelTest
event:
run: eventSubjectModelTest
clb: clb:
subject: subject:
default: default:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论