提交 7c581c80 作者: 925993793@qq.com

Merge remote-tracking branch 'origin/event_fusion' into dev_0710

# Conflicts:
#	src/main/java/com/zzsn/event/controller/EventManageController.java
#	src/main/resources/application-test.yml
# 镜像仓库
# 版本 T1.0.0: T为测试版,R为稳定版
version="R1.0.0" # 可自定义
# 镜像仓库地址
domain="swr.cn-southwest-2.myhuaweicloud.com"
# 镜像分组,按部门区分
namespace="ciglobal"
#repo_username="ciglobal-ap"
#repo_passwd="ciglobal.zzsn"
repo_username="cn-southwest-2@O2PWMHIOLKRM0YPULE96"
repo_passwd="9e59dd258a1b25f2949549ad60be11b7a6f0f94349f62ad5b5d7fd1d839a1c0e"
# 服务配置
# 数据挂载根目录
root_dir="/zzsn/clb/logs"
# 需根据日志配置填写,比如:logback-spring.xml
svc_logs="/workspace/logs"
# 环境变量 test or prod
svc_env="yjzx"
profiles="nacos"
# 服务名
svc_name="subject-server"
# 服务端口
svc_port="1689"
# nacos配置
nacos_server="192.168.0.19:8848"
nacos_username="nacos"
nacos_password="Nacos.2024Socan"
# 资源限制
## cpu
limit_cpu=2.0
limit_mem=6g
\ No newline at end of file
package com.zzsn.event.controller; package com.zzsn.event.controller;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
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;
...@@ -9,12 +10,15 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -9,12 +10,15 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsn.clb.common.model.task.dto.titr.KeyWordsDTO; import com.zzsn.clb.common.model.task.dto.titr.KeyWordsDTO;
import com.zzsn.event.constant.Constants; import com.zzsn.event.constant.Constants;
import com.zzsn.event.constant.Result; import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.ClbModelArrangeSubjectMap;
import com.zzsn.event.entity.Event; import com.zzsn.event.entity.Event;
import com.zzsn.event.entity.EventAnalysisVersionRecord; import com.zzsn.event.entity.EventAnalysisVersionRecord;
import com.zzsn.event.entity.KeyWords; import com.zzsn.event.entity.KeyWords;
import com.zzsn.event.entity.SubjectInfoSourceMap; import com.zzsn.event.entity.SubjectInfoSourceMap;
import com.zzsn.event.enums.AnalysisColumnEnum; import com.zzsn.event.enums.AnalysisColumnEnum;
import com.zzsn.event.service.*; import com.zzsn.event.service.*;
import com.zzsn.event.service.*;
import com.zzsn.event.service.impl.CaiJiCenterHttpService;
import com.zzsn.event.service.impl.ConfigurationMessageService; import com.zzsn.event.service.impl.ConfigurationMessageService;
import com.zzsn.event.util.HttpUtil; import com.zzsn.event.util.HttpUtil;
import com.zzsn.event.util.ObjectUtil; import com.zzsn.event.util.ObjectUtil;
...@@ -22,6 +26,7 @@ import com.zzsn.event.util.RedisUtil; ...@@ -22,6 +26,7 @@ import com.zzsn.event.util.RedisUtil;
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 com.zzsn.event.xxljob.service.IXxlJobInfoService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -62,6 +67,9 @@ public class EventManageController { ...@@ -62,6 +67,9 @@ public class EventManageController {
@Autowired @Autowired
private IKeyWordsService keyWordsService; private IKeyWordsService keyWordsService;
@Autowired @Autowired
private ClbModelArrangeSubjectMapService clbModelArrangeSubjectMapService;
@Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Resource @Resource
private KafkaTemplate<String, String> kafkaTemplate; private KafkaTemplate<String, String> kafkaTemplate;
...@@ -160,26 +168,16 @@ public class EventManageController { ...@@ -160,26 +168,16 @@ public class EventManageController {
eventParam.setCreateBy(currentUser.getUsername()); eventParam.setCreateBy(currentUser.getUsername());
Event event = eventService.saveMain(eventParam); Event event = eventService.saveMain(eventParam);
//新增关键词 //新增关键词
KeyWords keyWords = keyWordsService.saveKeyword(event, keywordsVO.getKeyword(), keywordsVO.getExclusionWord()); keyWordsService.saveBaseAndMap(event, keywordsVO.getKeyword(), keywordsVO.getExclusionWord());
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
//插入xxlJob //插入xxlJob
log.info("新增事件,插入xxlJob,事件id:{}", event.getId());
iXxlJobInfoService.eventInsert(event); iXxlJobInfoService.eventInsert(event);
/*-------------------------------------------------------------老采集逻辑---------------*/
//关键词入缓存
KeyWordsDTO redisKeywordDTO = new KeyWordsDTO();
BeanUtils.copyProperties(keyWords, redisKeywordDTO);
redisKeywordDTO.setStartTime(event.getStartTime());
redisKeywordDTO.setEndTime(event.getEndTime());
redisKeywordDTO.setSearchEngines(new ArrayList<>(Constants.DEFAULT_SEARCH_ENGINE.values()));
redisUtil.set(Constants.KEY_WORDS_TO_REDIS_PREFIX + keyWords.getWordsCode(), redisKeywordDTO);
//插入xxljob
iXxlJobInfoService.keyWordsInsert(redisKeywordDTO);
//为了立即响应,关键词新增时放入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO));
/*-----------------------------------------------------------------老采集逻辑---------------*/
//通知采集 //通知采集
log.info("新增事件,通知采集,事件id:{}", event.getId());
configurationMessageService.bindKeyWordsEventSend(event.getId()); configurationMessageService.bindKeyWordsEventSend(event.getId());
//事件分析 //事件分析
log.info("新增事件,事件分析,事件id:{}", event.getId());
kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode()); kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
}); });
return Result.OK(); return Result.OK();
...@@ -203,21 +201,8 @@ public class EventManageController { ...@@ -203,21 +201,8 @@ public class EventManageController {
addEventParam.setUpdateTime(new Date()); addEventParam.setUpdateTime(new Date());
addEventParam.setUpdateBy(currentUser.getUsername()); addEventParam.setUpdateBy(currentUser.getUsername());
eventService.updateMain(addEventParam); eventService.updateMain(addEventParam);
keyWordsService.update(Wrappers.<KeyWords>lambdaUpdate().eq(KeyWords::getId, keywordsVO.getId()) keyWordsService.updateBaseAndMap(addEventParam, keywordsVO.getKeyword(), keywordsVO.getExclusionWord());
.set(KeyWords::getKeyWord, keywordsVO.getKeyword())
.set(KeyWords::getExclusionWord, keywordsVO.getExclusionWord()));
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
/*-----------------------------------------------------------------老采集逻辑---------------*/
KeyWordsDTO redisKeywordDTO = new KeyWordsDTO();
BeanUtils.copyProperties(keywordsVO, redisKeywordDTO);
redisKeywordDTO.setKeyWord(keywordsVO.getKeyword());
redisKeywordDTO.setStartTime(addEventParam.getStartTime());
redisKeywordDTO.setEndTime(addEventParam.getEndTime());
redisKeywordDTO.setSearchEngines(new ArrayList<>(Constants.DEFAULT_SEARCH_ENGINE.values()));
redisUtil.set(Constants.KEY_WORDS_TO_REDIS_PREFIX + keywordsVO.getWordsCode(), redisKeywordDTO);
//为了立即响应,关键词编辑时放入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO));
/*-----------------------------------------------------------------老采集逻辑---------------*/
//通知采集 //通知采集
configurationMessageService.bindKeyWordsEventSend(addEventParam.getId()); configurationMessageService.bindKeyWordsEventSend(addEventParam.getId());
}); });
...@@ -227,6 +212,9 @@ public class EventManageController { ...@@ -227,6 +212,9 @@ public class EventManageController {
} }
} }
@Autowired
private CaiJiCenterHttpService caiJiCenterHttpService;
/** /**
* 启用 * 启用
* *
...@@ -236,7 +224,42 @@ public class EventManageController { ...@@ -236,7 +224,42 @@ public class EventManageController {
*/ */
@GetMapping("/enable") @GetMapping("/enable")
public Result<?> enable(@RequestParam String eventId) { public Result<?> enable(@RequestParam String eventId) {
eventService.updateStatus(eventId, 1); Event event = eventService.updateStatus(eventId, 1);
CompletableFuture.runAsync(() -> {
try {
kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
} catch (Exception e) {
log.error("事件分析调度失败{}", e.getMessage(), e);
}
try {
configurationMessageService.bindInfoSourceSend(event.getId());
configurationMessageService.bindKeyWordsSend(event.getId());
configurationMessageService.subjectEnterpriseSourceSync(event.getId());
configurationMessageService.subjectPolicySourceSync(event.getId());
} catch (Exception e) {
log.error("通知采集失败{}", e.getMessage(), e);
}
try {
iXxlJobInfoService.update(Wrappers.<XxlJobInfo>lambdaUpdate().eq(XxlJobInfo::getInfoSourceCode, event.getEventCode())
.set(XxlJobInfo::getTriggerStatus, 1));
} catch (Exception e) {
log.error("修改xxlJob状态失败{}", e.getMessage(), e);
}
try {
String res = caiJiCenterHttpService.subjectStatusEdit(event.getStatus(), event.getId());
cn.hutool.json.JSONObject entries = JSONUtil.parseObj(res);
//获取code状态码
Integer code = entries.getInt("code");
if (cn.hutool.core.util.ObjectUtil.isEmpty(code) || code != 200) {
log.error("专题状态同步采集失败{}", res);
}
} catch (Exception e) {
log.error("专题状态同步采集失败{}", e.getMessage(), e);
}
});
return Result.OK(); return Result.OK();
} }
...@@ -249,7 +272,18 @@ public class EventManageController { ...@@ -249,7 +272,18 @@ public class EventManageController {
*/ */
@GetMapping("/disable") @GetMapping("/disable")
public Result<?> disable(@RequestParam String eventId) { public Result<?> disable(@RequestParam String eventId) {
eventService.updateStatus(eventId, 0); Event event = eventService.updateStatus(eventId, 0);
try {
String res = caiJiCenterHttpService.subjectStatusEdit(event.getStatus(), event.getId());
cn.hutool.json.JSONObject entries = JSONUtil.parseObj(res);
//获取code状态码
Integer code = entries.getInt("code");
if (cn.hutool.core.util.ObjectUtil.isEmpty(code) || code != 200) {
log.error("专题状态同步采集失败{}", res);
}
} catch (Exception e) {
log.error("专题状态同步采集失败{}", e.getMessage(), e);
}
return Result.OK(); return Result.OK();
} }
...@@ -267,13 +301,9 @@ public class EventManageController { ...@@ -267,13 +301,9 @@ public class EventManageController {
EventVO eventVO = eventService.queryInfo(id); EventVO eventVO = eventService.queryInfo(id);
iXxlJobInfoService.deleteByInfosourceCode(eventVO.getEventCode()); iXxlJobInfoService.deleteByInfosourceCode(eventVO.getEventCode());
//删除关键词 //删除关键词
KeywordsVO keywordsVO = eventVO.getKeywordsVO(); keyWordsService.removeBaseAndMap(id);
if (keywordsVO != null) { //删除流程绑定
String wordsCode = keywordsVO.getWordsCode(); clbModelArrangeSubjectMapService.remove(Wrappers.<ClbModelArrangeSubjectMap>lambdaQuery().eq(ClbModelArrangeSubjectMap::getSubjectId, id));
keyWordsService.remove(Wrappers.<KeyWords>lambdaQuery().eq(KeyWords::getWordsCode, wordsCode));
redisUtil.del(Constants.KEY_WORDS_TO_REDIS_PREFIX + wordsCode);
iXxlJobInfoService.deleteByInfosourceCode(wordsCode);
}
}); });
return Result.OK(); return Result.OK();
} }
...@@ -298,13 +328,7 @@ public class EventManageController { ...@@ -298,13 +328,7 @@ public class EventManageController {
EventVO eventVO = eventService.queryInfo(id); EventVO eventVO = eventService.queryInfo(id);
iXxlJobInfoService.deleteByInfosourceCode(eventVO.getEventCode()); iXxlJobInfoService.deleteByInfosourceCode(eventVO.getEventCode());
//删除关键词 //删除关键词
KeywordsVO keywordsVO = eventVO.getKeywordsVO(); keyWordsService.removeBaseAndMap(id);
if (keywordsVO != null) {
String wordsCode = keywordsVO.getWordsCode();
keyWordsService.remove(Wrappers.<KeyWords>lambdaQuery().eq(KeyWords::getWordsCode, wordsCode));
redisUtil.del(Constants.KEY_WORDS_TO_REDIS_PREFIX + wordsCode);
iXxlJobInfoService.deleteByInfosourceCode(wordsCode);
}
} }
}); });
return Result.OK(); return Result.OK();
......
...@@ -518,8 +518,10 @@ public class FileController { ...@@ -518,8 +518,10 @@ public class FileController {
private List<String> supplyHeaders(String[] arr, List<LabelModelVo> labelTypeVos) { private List<String> supplyHeaders(String[] arr, List<LabelModelVo> labelTypeVos) {
List<String> headers = new ArrayList<>(Arrays.asList(arr)); List<String> headers = new ArrayList<>(Arrays.asList(arr));
if (CollectionUtils.isNotEmpty(labelTypeVos)) { if (CollectionUtils.isNotEmpty(labelTypeVos)) {
for (LabelModelVo labelTypeVo : labelTypeVos) { for (int i = 0; i < labelTypeVos.size(); i++) {
LabelModelVo labelTypeVo = labelTypeVos.get(i);
headers.add(labelTypeVo.getLabelName()); headers.add(labelTypeVo.getLabelName());
labelTypeVo.setOrderNo(i);
} }
} }
return headers; return headers;
...@@ -669,7 +671,6 @@ public class FileController { ...@@ -669,7 +671,6 @@ public class FileController {
data.add(sb.substring(1)); data.add(sb.substring(1));
} }
} }
} }
list.add(data); list.add(data);
} }
......
...@@ -910,6 +910,19 @@ public class SubjectManageController { ...@@ -910,6 +910,19 @@ public class SubjectManageController {
Subject subject = subjectService.subjectUpdateScope(subjectId, type, scop); Subject subject = subjectService.subjectUpdateScope(subjectId, type, scop);
return Result.OK(subject); return Result.OK(subject);
} }
/**
* 更新事件subject的数据范围
*
* @param subjectId 专题id
*/
@GetMapping("/eventUpdateScope")
public Result<?> eventUpdateScope(@RequestParam(name = "subjectId") String subjectId,
@RequestParam(name = "type") String type,
@RequestParam(name = "scop", defaultValue = "") String scop
) {
Event subject = subjectService.eventUpdateScope(subjectId, type, scop);
return Result.OK(subject);
}
/** /**
* 绑定信息源标签数据 * 绑定信息源标签数据
......
...@@ -128,7 +128,7 @@ public class RelationBindController { ...@@ -128,7 +128,7 @@ public class RelationBindController {
IPage<InfoSourceVo> pageList = null; IPage<InfoSourceVo> pageList = null;
if (CollectionUtil.isNotEmpty(subjectIdList) && subjectIdList.size() == 1 && subjectId.equals(subjectIdList.get(0))) { if (CollectionUtil.isNotEmpty(subjectIdList) && subjectIdList.size() == 1 && subjectId.equals(subjectIdList.get(0))) {
Subject byId = subjectService.getById(subjectId); Subject byId = subjectService.getSubjectOrEventById(subjectId);
if (ObjectUtil.isNotNull(byId) && StringUtils.isNotEmpty(byId.getDataScope()) && byId.getDataScope().contains("1")) { if (ObjectUtil.isNotNull(byId) && StringUtils.isNotEmpty(byId.getDataScope()) && byId.getDataScope().contains("1")) {
Page<InfoSource> page = new Page<>(pageNo, pageSize); Page<InfoSource> page = new Page<>(pageNo, pageSize);
return Result.OK(infoSourceService.page(page, return Result.OK(infoSourceService.page(page,
......
...@@ -183,7 +183,7 @@ public class EventDataController { ...@@ -183,7 +183,7 @@ public class EventDataController {
* @author lkg * @author lkg
* @date 2024/7/22 * @date 2024/7/22
*/ */
@PostMapping("/simpleSaveEvent") //@PostMapping("/simpleSaveEvent")
public Result<?> addEvent(@RequestBody AddEventVO addEventVO) { public Result<?> addEvent(@RequestBody AddEventVO addEventVO) {
if(StringUtils.isNotEmpty(CLB_EVENT_ADD)){ if(StringUtils.isNotEmpty(CLB_EVENT_ADD)){
UserVo currentUser = UserUtil.getLoginUser(); UserVo currentUser = UserUtil.getLoginUser();
...@@ -258,6 +258,32 @@ public class EventDataController { ...@@ -258,6 +258,32 @@ public class EventDataController {
} }
} }
@PostMapping("/simpleSaveEvent")
public Result<?> addEvent_new(@RequestBody AddEventVO addEventVO) {
KeywordsVO keywordsVO = addEventVO.getKeywordsVO();
if (keywordsVO != null) {
UserVo currentUser = UserUtil.getLoginUser();
AddEventParam eventParam = new AddEventParam();
BeanUtils.copyProperties(addEventVO, eventParam);
eventParam.setCreateBy(currentUser.getUsername());
Event event = eventService.saveMain(eventParam);
//新增关键词
keyWordsService.saveBaseAndMap(event, keywordsVO.getKeyword(), keywordsVO.getExclusionWord());
CompletableFuture.runAsync(() -> {
//插入xxlJob
iXxlJobInfoService.eventInsert(event);
//通知采集
configurationMessageService.bindKeyWordsEventSend(event.getId());
//事件分析
kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
});
return Result.OK();
} else {
return Result.FAIL(500, "关键词不能为空");
}
}
/** /**
* 编辑事件(页面简化版) * 编辑事件(页面简化版)
* *
...@@ -265,7 +291,7 @@ public class EventDataController { ...@@ -265,7 +291,7 @@ public class EventDataController {
* @author lkg * @author lkg
* @date 2024/7/22 * @date 2024/7/22
*/ */
@PostMapping("/simpleUpdateEvent") //@PostMapping("/simpleUpdateEvent")
public Result<?> updateEvent(@RequestBody AddEventVO addEventVO) { public Result<?> updateEvent(@RequestBody AddEventVO addEventVO) {
if(StringUtils.isNotEmpty(CLB_EVENT_EDIT)){ if(StringUtils.isNotEmpty(CLB_EVENT_EDIT)){
UserVo currentUser = UserUtil.getLoginUser(); UserVo currentUser = UserUtil.getLoginUser();
...@@ -325,6 +351,28 @@ public class EventDataController { ...@@ -325,6 +351,28 @@ public class EventDataController {
} }
} }
@PostMapping("/simpleUpdateEvent")
public Result<?> updateEvent_new(@RequestBody AddEventVO addEventVO) {
KeywordsVO keywordsVO = addEventVO.getKeywordsVO();
AddEventParam addEventParam = new AddEventParam();
BeanUtils.copyProperties(addEventVO, addEventParam);
if (keywordsVO != null) {
UserVo currentUser = UserUtil.getLoginUser();
addEventParam.setUpdateTime(new Date());
addEventParam.setUpdateBy(currentUser.getUsername());
eventService.updateMain(addEventParam);
keyWordsService.updateBaseAndMap(addEventParam, keywordsVO.getKeyword(), keywordsVO.getExclusionWord());
CompletableFuture.runAsync(() -> {
//通知采集
configurationMessageService.bindKeyWordsEventSend(addEventParam.getId());
});
return Result.OK();
} else {
return Result.FAIL(500, "关键词不能为空");
}
}
/** /**
* 事件配置校验 * 事件配置校验
* *
...@@ -345,7 +393,7 @@ public class EventDataController { ...@@ -345,7 +393,7 @@ public class EventDataController {
* @author lkg * @author lkg
* @date 2025/2/6 * @date 2025/2/6
*/ */
@GetMapping("/clearData") //@GetMapping("/clearData")
public Result<?> clearData(@RequestParam String eventId){ public Result<?> clearData(@RequestParam String eventId){
if (StringUtils.isNotEmpty(CLB_CLEAR_DATA)) { if (StringUtils.isNotEmpty(CLB_CLEAR_DATA)) {
try { try {
...@@ -363,14 +411,19 @@ public class EventDataController { ...@@ -363,14 +411,19 @@ public class EventDataController {
return Result.OK("正在清空数据"); return Result.OK("正在清空数据");
} }
@GetMapping("/clearData")
public Result<?> clearData_new(@RequestParam String eventId){
eventService.clearSubjectData(eventId);
return Result.OK("正在清空数据");
}
/** /**
* 通过id删除 * 通过id删除
* *
* @param param:id 事件id * @param param:id 事件id
* @return * @return
*/ */
@ApiOperation(value = "事件-通过id删除", notes = "事件-通过id删除") //@PostMapping(value = "/simpleDeleteEvent")
@PostMapping(value = "/simpleDeleteEvent")
public Result<?> delete(@RequestBody JSONObject param) { public Result<?> delete(@RequestBody JSONObject param) {
if(StringUtils.isNotEmpty(CLB_EVENT_DELETE)){ if(StringUtils.isNotEmpty(CLB_EVENT_DELETE)){
try { try {
...@@ -415,6 +468,19 @@ public class EventDataController { ...@@ -415,6 +468,19 @@ public class EventDataController {
} }
} }
@PostMapping(value = "/simpleDeleteEvent")
public Result<?> delete_new(@RequestBody JSONObject param) {
String id = param.getString("id");
eventService.deleteMain(id);
CompletableFuture.runAsync(() -> {
EventVO eventVO = eventService.queryInfo(id);
iXxlJobInfoService.deleteByInfosourceCode(eventVO.getEventCode());
//删除关键词
keyWordsService.removeBaseAndMap(id);
});
return Result.OK();
}
@GetMapping("/labelList") @GetMapping("/labelList")
public Result<?> labelList(){ public Result<?> labelList(){
......
package com.zzsn.event.entity; package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModelProperty;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.util.Date; import java.util.Date;
...@@ -53,6 +52,7 @@ public class ClbModelArrangeSubjectMap { ...@@ -53,6 +52,7 @@ public class ClbModelArrangeSubjectMap {
/** /**
* 删除标志 0-正常 1-删除 * 删除标志 0-正常 1-删除
*/ */
@TableLogic
@TableField("del_flag") @TableField("del_flag")
private Integer delFlag; private Integer delFlag;
...@@ -73,4 +73,7 @@ public class ClbModelArrangeSubjectMap { ...@@ -73,4 +73,7 @@ public class ClbModelArrangeSubjectMap {
*/ */
@TableField("update_time") @TableField("update_time")
private Date updateTime; private Date updateTime;
@Excel(name = "专题名称", width = 15)
@ApiModelProperty(value = "专题名称")
private String subjectName;
} }
...@@ -118,6 +118,9 @@ public class Event { ...@@ -118,6 +118,9 @@ public class Event {
@DateTimeFormat(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;
/**数据范围(是否是全库) - 采集库全库-1,企业库全库-2,政策库全库-3*/
@TableField(updateStrategy = FieldStrategy.IGNORED) // 忽略更新策略
private String dataScope;
/** /**
* 修改人id * 修改人id
*/ */
...@@ -218,6 +221,7 @@ public class Event { ...@@ -218,6 +221,7 @@ public class Event {
* 是否开启采集(1-是;0-否) * 是否开启采集(1-是;0-否)
*/ */
private Integer ynCollect; private Integer ynCollect;
/** /**
* 第一次开启时间 * 第一次开启时间
*/ */
......
...@@ -621,8 +621,8 @@ public class EsService { ...@@ -621,8 +621,8 @@ public class EsService {
*/ */
public IPage<EventDataVO> collectPageList(InfoDataSearchCondition eventDataCondition) { public IPage<EventDataVO> collectPageList(InfoDataSearchCondition eventDataCondition) {
String index = Constants.COLLECT_INDEX; String index = Constants.COLLECT_INDEX;
Subject byId = subjectService.getSubjectOrEventById(eventDataCondition.getSubjectId());
if ("1".equals(eventDataCondition.getIsSubject())) { if ("1".equals(eventDataCondition.getIsSubject())) {
Subject byId = subjectService.getById(eventDataCondition.getSubjectId());
//更新开始、结束时间 //更新开始、结束时间
if (byId.getTimeEnable() != null) { if (byId.getTimeEnable() != null) {
String timeEnable = DateUtil.format(byId.getTimeEnable(), "yyyy-MM-dd"); String timeEnable = DateUtil.format(byId.getTimeEnable(), "yyyy-MM-dd");
...@@ -701,14 +701,20 @@ public class EsService { ...@@ -701,14 +701,20 @@ public class EsService {
infoSourceIdList.addAll(wordsIdList); infoSourceIdList.addAll(wordsIdList);
} }
//装配信息源的条件 //装配信息源的条件
if (CollectionUtils.isNotEmpty(infoSourceIdList)) { if (!StrUtil.contains(byId.getDataScope(),"1") && CollectionUtils.isNotEmpty(infoSourceIdList)) {
boolQuery.must(QueryBuilders.termsQuery("sid", infoSourceIdList.stream().filter(StringUtils::isNotEmpty).collect(Collectors.toList()))); boolQuery.must(QueryBuilders.termsQuery("sid", infoSourceIdList.stream().filter(StringUtils::isNotEmpty).collect(Collectors.toList())));
} else if (StrUtil.contains(byId.getDataScope(),"1")) {
}else if (!Constants.COLLECT_INDEX.equals(index)){
} else { } else {
return new Page<>(); return new Page<>();
} }
} else { } else {
boolQuery.must(QueryBuilders.termQuery("sid", eventDataCondition.getSourceId())); boolQuery.must(QueryBuilders.termQuery("sid", eventDataCondition.getSourceId()));
} }
//
specialQuery(byId,eventDataCondition, boolQuery);
//高级查询数据处理 //高级查询数据处理
BoolQueryBuilder superQuery = buildSuperQuery(eventDataCondition.getSuperQueryMatchType(), eventDataCondition.getSuperQueryParams()); BoolQueryBuilder superQuery = buildSuperQuery(eventDataCondition.getSuperQueryMatchType(), eventDataCondition.getSuperQueryParams());
if (superQuery != null) { if (superQuery != null) {
...@@ -769,6 +775,13 @@ public class EsService { ...@@ -769,6 +775,13 @@ public class EsService {
return pageData; return pageData;
} }
private void specialQuery(Subject byId, InfoDataSearchCondition eventDataCondition, BoolQueryBuilder boolQuery) {
if (StrUtil.isNotBlank(byId.getEsIndex()) && "researchreportdata".equals(byId.getEsIndex()) && StrUtil.equals(byId.getId(),"1662011688013963265")){
//研报库数据,查询企业库的研报类型的数据
boolQuery.must(QueryBuilders.termQuery("type.keyword", "0"));
}
}
/** /**
* 事件对应专题库的资讯分页列表 * 事件对应专题库的资讯分页列表
......
...@@ -36,6 +36,7 @@ public interface KeyWordsMapper extends BaseMapper<KeyWords> { ...@@ -36,6 +36,7 @@ public interface KeyWordsMapper extends BaseMapper<KeyWords> {
* @date 2024/9/12 * @date 2024/9/12
*/ */
KeywordsVO keywordInfoByEventId(@Param("eventId") String eventId); KeywordsVO keywordInfoByEventId(@Param("eventId") String eventId);
List<KeywordsVO> keywordInfoByEventIdList(@Param("eventId") String eventId);
/** /**
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
t.event_type, t.event_type,
t.sort_order, t.sort_order,
t.yn_collect, t.yn_collect,
t.data_scope,
t.first_open_time, t.first_open_time,
stm.type_id as subjectTypeId, stm.type_id as subjectTypeId,
psm.project_id, psm.project_id,
...@@ -50,8 +51,8 @@ ...@@ -50,8 +51,8 @@
</select> </select>
<select id="pageList" resultType="com.zzsn.event.vo.EventManageVO"> <select id="pageList" resultType="com.zzsn.event.vo.EventManageVO">
select t2.type_name,t1.id,t1.event_icon,t1.event_name,m.subjectTypeName,t1.event_label,t1.status, select t2.type_name,t1.id,t1.event_icon,t1.event_name,m.subjectTypeName,t1.event_label,t1.status,t1.event_code,
t1.face_public,t1.publish_status,t1.create_time,t1.publish_date,t1.start_time,t1.end_time,t1.create_by t1.face_public,t1.publish_status,t1.create_time,t1.publish_date,t1.start_time,t1.end_time,t1.create_by,t1.data_scope
from event t1 from event t1
inner join event_category t2 on t1.event_type =t2.id inner join event_category t2 on t1.event_type =t2.id
INNER JOIN INNER JOIN
...@@ -89,7 +90,7 @@ ...@@ -89,7 +90,7 @@
and t1.create_time <![CDATA[ <= ]]> #{endTime} and t1.create_time <![CDATA[ <= ]]> #{endTime}
</if> </if>
<if test="createBy!=null and createBy != ''"> <if test="createBy!=null and createBy != ''">
and t1.create_by like CONCAT('%',#{create_by},'%') and t1.create_by like CONCAT('%',#{createBy},'%')
</if> </if>
<if test="order!=null and order != ''"> <if test="order!=null and order != ''">
order by t1.${order} order by t1.${order}
...@@ -137,7 +138,7 @@ ...@@ -137,7 +138,7 @@
and t1.create_time <![CDATA[ <= ]]> #{endTime} and t1.create_time <![CDATA[ <= ]]> #{endTime}
</if> </if>
<if test="createBy!=null and createBy != ''"> <if test="createBy!=null and createBy != ''">
and t1.create_by like CONCAT('%',#{create_by},'%') and t1.create_by like CONCAT('%',#{createBy},'%')
</if> </if>
</select> </select>
......
...@@ -182,4 +182,10 @@ ...@@ -182,4 +182,10 @@
</if> </if>
group by b.id group by b.id
</select> </select>
<select id="keywordInfoByEventIdList" resultType="com.zzsn.event.vo.KeywordsVO">
select word.id, word.words_code, word.key_word, word.exclusion_word,map.binding_type
from key_words word
inner join subject_keywords_map map on word.id = map.keywords_id
where map.subject_id = #{eventId}
</select>
</mapper> </mapper>
...@@ -27,113 +27,397 @@ ...@@ -27,113 +27,397 @@
</update> </update>
<select id="subjectRealBindInfoSourceList" resultType="String"> <select id="subjectRealBindInfoSourceList" resultType="String">
select distinct a.source_id from
(select distinct x.source_id from ( SELECT
select m.source_id from subject_info_source_map n distinct x.id
inner join info_source_group_map m on n.source_id = m.group_id FROM
where n.type in(2,5) (
SELECT
iso.id
FROM
subject_info_source_map sm
INNER JOIN info_source iso ON sm.source_id = iso.id
WHERE
sm.type IN ( 1, 6 )
<if test="subjectIds != null and subjectIds.size() > 0"> <if test="subjectIds != null and subjectIds.size() > 0">
and n.subject_id in and sm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=","> <foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
</if> </if> UNION
union SELECT
select sm.source_id from subject_info_source_map sm where sm.type in(1,6) iso.id
FROM
subject_info_source_map sm
INNER JOIN info_source_main im ON im.id = sm.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id
WHERE
sm.type IN ( 31, 36 )
<if test="subjectIds != null and subjectIds.size() > 0"> <if test="subjectIds != null and subjectIds.size() > 0">
and sm.subject_id in and sm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=","> <foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
</if> </if> UNION
union SELECT
select m.entity_code as source_id from subject_info_source_map n iso.id
inner join clb_label_info_source_map m on n.source_id = m.label_code and n.source_item_id = m.label_item_code FROM
where n.type in(12,15) subject_info_source_map sim
INNER JOIN info_source_group_map m ON m.group_id = sim.source_id
INNER JOIN info_source iso ON m.source_id = iso.id
WHERE
sim.type IN ( 2, 5 )
<if test="subjectIds != null and subjectIds.size() > 0">
and sim.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if> UNION
SELECT
iso.id
FROM
subject_info_source_map sim
INNER JOIN info_source_main_group_map m ON m.group_id = sim.source_id
INNER JOIN info_source_main im ON im.id = m.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id
WHERE
sim.type IN ( 32, 35 )
<if test="subjectIds != null and subjectIds.size() > 0">
and sim.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if> UNION
SELECT
isoo.id
FROM
subject_info_source_map smm
INNER JOIN clb_label_info_source_map lam ON smm.source_id = lam.label_code
AND smm.source_item_id = lam.label_item_code
INNER JOIN info_source isoo ON lam.entity_code = isoo.id
WHERE
smm.type IN ( 12, 15 )
<if test="subjectIds != null and subjectIds.size() > 0"> <if test="subjectIds != null and subjectIds.size() > 0">
and n.subject_id in and smm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if> UNION
SELECT
isoo.id
FROM
subject_info_source_map smm
INNER JOIN clb_label_main_source_map lam ON smm.source_id = lam.label_code
AND smm.source_item_id = lam.label_item_code
INNER JOIN info_source_main im ON lam.entity_code = im.id
INNER JOIN info_source isoo ON im.id = isoo.info_source_id
WHERE
smm.type IN ( 312, 315 )
<if test="subjectIds != null and subjectIds.size() > 0">
and smm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=","> <foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
</if> </if>
) x) a LEFT JOIN ) x
(select distinct x.source_id from ( WHERE
select m.source_id from subject_info_source_map n 1 = 1
inner join info_source_group_map m on n.source_id = m.group_id AND x.id NOT IN (
where n.type = 4 SELECT DISTINCT
y.source_id
FROM
(
SELECT
m.source_id
FROM
info_source_group_map m
WHERE
m.group_id IN ( SELECT source_id FROM subject_info_source_map WHERE type = 4
<if test="subjectIds != null and subjectIds.size() > 0"> <if test="subjectIds != null and subjectIds.size() > 0">
and n.subject_id in and subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=","> <foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
</if> </if>
union GROUP BY source_id ) UNION
select sm.source_id from subject_info_source_map sm where sm.type = 3 SELECT
iso.id
FROM
subject_info_source_map sim
INNER JOIN info_source_main_group_map m ON m.group_id = sim.source_id
INNER JOIN info_source_main im ON im.id = m.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id
WHERE
sim.type = 34
<if test="subjectIds != null and subjectIds.size() > 0">
and sim.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if> UNION
SELECT
sm.source_id
FROM
subject_info_source_map sm
WHERE
type = 3
<if test="subjectIds != null and subjectIds.size() > 0"> <if test="subjectIds != null and subjectIds.size() > 0">
and sm.subject_id in and sm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=","> <foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
</if> </if> UNION
union SELECT
select m.entity_code as source_id from subject_info_source_map n iso.id
inner join clb_label_info_source_map m on n.source_id = m.label_code and n.source_item_id = m.label_item_code FROM
where n.type = 14 subject_info_source_map sm
INNER JOIN info_source_main im ON im.id = sm.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id
WHERE
sm.type = 33
<if test="subjectIds != null and subjectIds.size() > 0">
and sm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if> UNION
SELECT
isoo.id
FROM
subject_info_source_map smm
INNER JOIN clb_label_info_source_map lam ON smm.source_id = lam.label_code
AND smm.source_item_id = lam.label_item_code
INNER JOIN info_source isoo ON lam.entity_code = isoo.id
WHERE
smm.type = 14
<if test="subjectIds != null and subjectIds.size() > 0">
and smm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if> UNION
SELECT
isoo.id
FROM
subject_info_source_map smm
INNER JOIN clb_label_main_source_map lam ON smm.source_id = lam.label_code
AND smm.source_item_id = lam.label_item_code
INNER JOIN info_source_main im ON lam.entity_code = im.id
INNER JOIN info_source isoo ON im.id = isoo.info_source_id
WHERE
smm.type = 314
<if test="subjectIds != null and subjectIds.size() > 0"> <if test="subjectIds != null and subjectIds.size() > 0">
and n.subject_id in and smm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=","> <foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
</if> </if>
) x) b ) y
on (a.source_id = b.source_id) )
where b.source_id is null
</select> </select>
<select id="subjectRealBindInfoSources" resultType="com.zzsn.event.vo.SubjectStatisticsVo"> <select id="subjectRealBindInfoSources" resultType="com.zzsn.event.vo.SubjectStatisticsVo">
select distinct x.* from ( SELECT
select iso.id,iso.web_site_name,iso.site_name,iso.site_uri distinct x.*
from info_source_group_map m inner join info_source iso on m.source_id = iso.id FROM
where m.group_id in ( (
select source_id from subject_info_source_map where type in(2,5) SELECT
iso.id,
iso.web_site_name,
iso.site_name,
iso.site_uri
FROM
subject_info_source_map sm
INNER JOIN info_source iso ON sm.source_id = iso.id
WHERE
sm.type IN ( 1, 6 )
<if test="subjectIds != null and subjectIds.size() > 0"> <if test="subjectIds != null and subjectIds.size() > 0">
and subject_id in and sm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=","> <foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
</if> </if> UNION
group by source_id SELECT
) iso.id,
union iso.web_site_name,
select iso.id,iso.web_site_name,iso.site_name,iso.site_uri iso.site_name,
from subject_info_source_map sm inner join info_source iso on sm.source_id = iso.id where sm.type = 1 iso.site_uri
FROM
subject_info_source_map sm
INNER JOIN info_source_main im ON im.id = sm.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id
WHERE
sm.type IN ( 31, 36 )
<if test="subjectIds != null and subjectIds.size() > 0"> <if test="subjectIds != null and subjectIds.size() > 0">
and sm.subject_id in and sm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=","> <foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
</if> UNION
SELECT
iso.id,
iso.web_site_name,
iso.site_name,
iso.site_uri
FROM
subject_info_source_map sim
INNER JOIN info_source_group_map m ON m.group_id = sim.source_id
INNER JOIN info_source iso ON m.source_id = iso.id
WHERE
sim.type IN ( 2, 5 )
<if test="subjectIds != null and subjectIds.size() > 0">
and sim.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if> UNION
SELECT
iso.id,
iso.web_site_name,
iso.site_name,
iso.site_uri
FROM
subject_info_source_map sim
INNER JOIN info_source_main_group_map m ON m.group_id = sim.source_id
INNER JOIN info_source_main im ON im.id = m.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id
WHERE
sim.type IN ( 32, 35 )
<if test="subjectIds != null and subjectIds.size() > 0">
and sim.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if> UNION
SELECT
isoo.id,
isoo.web_site_name,
isoo.site_name,
isoo.site_uri
FROM
subject_info_source_map smm
INNER JOIN clb_label_info_source_map lam ON smm.source_id = lam.label_code
AND smm.source_item_id = lam.label_item_code
INNER JOIN info_source isoo ON lam.entity_code = isoo.id
WHERE
smm.type IN ( 12, 15 )
<if test="subjectIds != null and subjectIds.size() > 0">
and smm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if> UNION
SELECT
isoo.id,
isoo.web_site_name,
isoo.site_name,
isoo.site_uri
FROM
subject_info_source_map smm
INNER JOIN clb_label_main_source_map lam ON smm.source_id = lam.label_code
AND smm.source_item_id = lam.label_item_code
INNER JOIN info_source_main im ON lam.entity_code = im.id
INNER JOIN info_source isoo ON im.id = isoo.info_source_id
WHERE
smm.type IN ( 312, 315 )
<if test="subjectIds != null and subjectIds.size() > 0">
and smm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if> </if>
) x ) x
where x.id not in( WHERE
select distinct y.source_id from ( 1 = 1
select m.source_id from info_source_group_map m AND x.id NOT IN (
where m.group_id in ( SELECT DISTINCT
select source_id from subject_info_source_map where type = 4 y.source_id
FROM
(
SELECT
m.source_id
FROM
info_source_group_map m
WHERE
m.group_id IN ( SELECT source_id FROM subject_info_source_map WHERE type = 4
<if test="subjectIds != null and subjectIds.size() > 0"> <if test="subjectIds != null and subjectIds.size() > 0">
and subject_id in and subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=","> <foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
</if> </if>
group by source_id GROUP BY source_id ) UNION
) SELECT
union iso.id
select sm.source_id from subject_info_source_map sm where type = 3 FROM
subject_info_source_map sim
INNER JOIN info_source_main_group_map m ON m.group_id = sim.source_id
INNER JOIN info_source_main im ON im.id = m.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id
WHERE
sim.type = 34
<if test="subjectIds != null and subjectIds.size() > 0">
and sim.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if> UNION
SELECT
sm.source_id
FROM
subject_info_source_map sm
WHERE
type = 3
<if test="subjectIds != null and subjectIds.size() > 0">
and sm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if> UNION
SELECT
iso.id
FROM
subject_info_source_map sm
INNER JOIN info_source_main im ON im.id = sm.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id
WHERE
sm.type = 33
<if test="subjectIds != null and subjectIds.size() > 0"> <if test="subjectIds != null and subjectIds.size() > 0">
and sm.subject_id in and sm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=","> <foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
</if> UNION
SELECT
isoo.id
FROM
subject_info_source_map smm
INNER JOIN clb_label_info_source_map lam ON smm.source_id = lam.label_code
AND smm.source_item_id = lam.label_item_code
INNER JOIN info_source isoo ON lam.entity_code = isoo.id
WHERE
smm.type = 14
<if test="subjectIds != null and subjectIds.size() > 0">
and smm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if> UNION
SELECT
isoo.id
FROM
subject_info_source_map smm
INNER JOIN clb_label_main_source_map lam ON smm.source_id = lam.label_code
AND smm.source_item_id = lam.label_item_code
INNER JOIN info_source_main im ON lam.entity_code = im.id
INNER JOIN info_source isoo ON im.id = isoo.info_source_id
WHERE
smm.type = 314
<if test="subjectIds != null and subjectIds.size() > 0">
and smm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if> </if>
) y ) y
) )
......
...@@ -220,7 +220,7 @@ ...@@ -220,7 +220,7 @@
LEFT JOIN subject_type c ON b.type_id = c.id LEFT JOIN subject_type c ON b.type_id = c.id
LEFT JOIN subject_statistic_info s on s.subject_id = d.id LEFT JOIN subject_statistic_info s on s.subject_id = d.id
where where
((d.face_public = 1 and d.create_by = #{username}) or (d.face_public = 1 and ${sql})) (d.create_by = #{username} or (d.face_public = 1 and ${sql}))
<if test="subjectCondition.environment !=null and subjectCondition.environment !=''"> <if test="subjectCondition.environment !=null and subjectCondition.environment !=''">
and d.environment =#{subjectCondition.environment} and d.environment =#{subjectCondition.environment}
</if> </if>
......
...@@ -241,10 +241,11 @@ ...@@ -241,10 +241,11 @@
</select> </select>
<select id="allList" resultType="com.zzsn.event.entity.SubjectType"> <select id="allList" resultType="com.zzsn.event.entity.SubjectType">
select t.* from subject_type t where 1=1 select t.* from subject_type t
<if test="userId !=null and userId != ''"> <if test="userId !=null and userId != ''">
inner join sys_user_data_permission dp on t.id=dp.permission_id and dp.user_id = #{userId} inner join sys_user_data_permission dp on t.id=dp.permission_id and dp.user_id = #{userId}
</if> </if>
where 1=1
<if test="category !=null"> <if test="category !=null">
and t.category = #{category} and t.category = #{category}
</if> </if>
......
...@@ -153,7 +153,7 @@ public interface IEventService extends IService<Event> { ...@@ -153,7 +153,7 @@ public interface IEventService extends IService<Event> {
void deleteMain(String id); void deleteMain(String id);
void updateStatus(String eventId, Integer status); Event updateStatus(String eventId, Integer status);
/** /**
* 事件配置校验 * 事件配置校验
......
...@@ -64,6 +64,7 @@ public interface IKeyWordsService extends IService<KeyWords> { ...@@ -64,6 +64,7 @@ public interface IKeyWordsService extends IService<KeyWords> {
* @date 2024/9/12 * @date 2024/9/12
*/ */
KeywordsVO keywordInfoByEventId(String eventId); KeywordsVO keywordInfoByEventId(String eventId);
List<KeywordsVO> keywordInfoByEventIdList(String eventId);
/** /**
* 专题绑定的关键词组-分页列表 * 专题绑定的关键词组-分页列表
...@@ -90,4 +91,33 @@ public interface IKeyWordsService extends IService<KeyWords> { ...@@ -90,4 +91,33 @@ public interface IKeyWordsService extends IService<KeyWords> {
Integer countByTypeAndIdList(String userId, String customerId,List<String> finalIdList, String subjectId); Integer countByTypeAndIdList(String userId, String customerId,List<String> finalIdList, String subjectId);
List<KeyWordsPage> bindKeyWordsListByIdsAndBindType(List<String> ids, String bindingType,Integer metaSearchFlag); List<KeyWordsPage> bindKeyWordsListByIdsAndBindType(List<String> ids, String bindingType,Integer metaSearchFlag);
/**
* 保存基本信息以及关系数据
*
* @param event 事件信息
* @param keyword 关键词
* @param exclusionWord 排除词
* @author lkg
* @date 2025/7/15
*/
void saveBaseAndMap(Event event, String keyword, String exclusionWord);
/**
* 更新基本信息以及关系数据
*
* @param event 事件信息
* @param keyword 关键词
* @param exclusionWord 排除词
* @author lkg
* @date 2025/7/15
*/
void updateBaseAndMap(Event event, String keyword, String exclusionWord);
/**
* 删除基本信息以及关系数据
*
* @param eventId 事件id
* @author lkg
* @date 2025/7/15
*/
void removeBaseAndMap(String eventId);
} }
...@@ -3,6 +3,7 @@ package com.zzsn.event.service; ...@@ -3,6 +3,7 @@ package com.zzsn.event.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.constant.Result; import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.Event;
import com.zzsn.event.entity.Subject; import com.zzsn.event.entity.Subject;
import com.zzsn.event.entity.SubjectStatisticInfo; import com.zzsn.event.entity.SubjectStatisticInfo;
import com.zzsn.event.util.tree.Node; import com.zzsn.event.util.tree.Node;
...@@ -206,4 +207,9 @@ public interface SubjectService extends IService<Subject> { ...@@ -206,4 +207,9 @@ public interface SubjectService extends IService<Subject> {
Subject subjectUpdateScope(String subjectId, String type, String scop); Subject subjectUpdateScope(String subjectId, String type, String scop);
Event eventUpdateScope(String subjectId, String type, String scop);
/**根据id查询专题或者事件*/
Subject getSubjectOrEventById(String id);
/**根据编码查询专题或者事件*/
Subject getSubjectOrEvent(String subjectCode);
} }
...@@ -48,6 +48,8 @@ public class CommonServiceImpl implements CommonService { ...@@ -48,6 +48,8 @@ public class CommonServiceImpl implements CommonService {
private SubjectKeywordsService subjectKeywordsService; private SubjectKeywordsService subjectKeywordsService;
@Autowired @Autowired
private ObsUtil obsUtil; private ObsUtil obsUtil;
@Autowired
private SubjectDictMapService subjectDictMapService;
@Override @Override
...@@ -299,7 +301,24 @@ public class CommonServiceImpl implements CommonService { ...@@ -299,7 +301,24 @@ public class CommonServiceImpl implements CommonService {
@Override @Override
public List<LabelModelVo> subjectModelBindLabels(List<String> subjectIds) { public List<LabelModelVo> subjectModelBindLabels(List<String> subjectIds) {
return commonMapper.subjectModelBindLabels(subjectIds); Set<LabelModelVo> dataSet = new HashSet<>();
List<DictVO> allList = new ArrayList<>();
for (String subjectId : subjectIds) {
List<DictVO> boundList = subjectDictMapService.boundList(subjectId);
allList.addAll(boundList);
}
for (DictVO dictVO : allList) {
LabelModelVo labelModelVo = new LabelModelVo();
labelModelVo.setLabelName(dictVO.getName());
String labelMark = StringUtils.isEmpty(dictVO.getLabelMark()) ? dictVO.getCode() : dictVO.getLabelMark();
if ("enterprise".equals(labelMark)) {
labelModelVo.setLabelMark("company_label");
} else {
labelModelVo.setLabelMark(labelMark);
}
dataSet.add(labelModelVo);
}
return new ArrayList<>(dataSet);
} }
@Override @Override
......
...@@ -133,7 +133,7 @@ public class ConfigurationMessageService { ...@@ -133,7 +133,7 @@ public class ConfigurationMessageService {
} catch (Exception e) { } catch (Exception e) {
log.error("删除专题缓存失败{}",e.getMessage(),e); log.error("删除专题缓存失败{}",e.getMessage(),e);
} }
Subject byId = subjectService.getById(subjectId); Subject byId = subjectService.getSubjectOrEventById(subjectId);
if (byId == null || byId.getStatus() == null || byId.getStatus() != 1) { if (byId == null || byId.getStatus() == null || byId.getStatus() != 1) {
log.info("未查询到专题或专题未启用"); log.info("未查询到专题或专题未启用");
return; return;
...@@ -196,7 +196,7 @@ public class ConfigurationMessageService { ...@@ -196,7 +196,7 @@ public class ConfigurationMessageService {
} catch (Exception e) { } catch (Exception e) {
log.error("删除专题缓存失败{}",e.getMessage(),e); log.error("删除专题缓存失败{}",e.getMessage(),e);
} }
Subject byId = subjectService.getById(subjectId); Subject byId = subjectService.getSubjectOrEventById(subjectId);
if (byId == null || byId.getStatus() == null || byId.getStatus() != 1) { if (byId == null || byId.getStatus() == null || byId.getStatus() != 1) {
log.info("未查询到专题或专题未启用"); log.info("未查询到专题或专题未启用");
return; return;
...@@ -241,7 +241,7 @@ public class ConfigurationMessageService { ...@@ -241,7 +241,7 @@ public class ConfigurationMessageService {
} }
public void subjectEnterpriseSourceSync(String subjectId){ public void subjectEnterpriseSourceSync(String subjectId){
Subject subject = subjectService.getById(subjectId); Subject subject = subjectService.getSubjectOrEventById(subjectId);
if (subject == null || subject.getStatus() == null || subject.getStatus() != 1) { if (subject == null || subject.getStatus() == null || subject.getStatus() != 1) {
log.info("未查询到专题或专题未启用"); log.info("未查询到专题或专题未启用");
return; return;
...@@ -477,7 +477,7 @@ public class ConfigurationMessageService { ...@@ -477,7 +477,7 @@ public class ConfigurationMessageService {
} }
public void subjectPolicySourceSync(String subjectId){ public void subjectPolicySourceSync(String subjectId){
Subject subject = subjectService.getById(subjectId); Subject subject = subjectService.getSubjectOrEventById(subjectId);
if (subject == null || subject.getStatus() == null || subject.getStatus() != 1) { if (subject == null || subject.getStatus() == null || subject.getStatus() != 1) {
log.info("未查询到专题或专题未启用"); log.info("未查询到专题或专题未启用");
return; return;
......
...@@ -3,6 +3,7 @@ package com.zzsn.event.service.impl; ...@@ -3,6 +3,7 @@ package com.zzsn.event.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
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;
...@@ -118,10 +119,15 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -118,10 +119,15 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
private EsOpUtil esOpUtil; private EsOpUtil esOpUtil;
@Autowired @Autowired
private IClbModelArrangeService clbModelArrangeService; private IClbModelArrangeService clbModelArrangeService;
@Autowired
private ClbModelArrangeSubjectMapService clbModelArrangeSubjectMapService;
@Value("${kafka.topic.event.run:}") @Value("${kafka.topic.event.run:}")
private String EVENT_MODEL_KAFKA_CHANNEL; private String EVENT_MODEL_KAFKA_CHANNEL;
@Value("${clb.subject.default.processing.advanceMonth}")
private Integer defaultAdvanceMonth;
@Override @Override
public List<SubjectKafkaVo> progressList(Date disableDate) { public List<SubjectKafkaVo> progressList(Date disableDate) {
return this.baseMapper.processList(disableDate); return this.baseMapper.processList(disableDate);
...@@ -147,7 +153,11 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -147,7 +153,11 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
eventVO.setEventTag(one); eventVO.setEventTag(one);
List<RegionVO> regionList = eventRegionMapService.regionList(eventId); List<RegionVO> regionList = eventRegionMapService.regionList(eventId);
eventVO.setRegionList(regionList); eventVO.setRegionList(regionList);
KeywordsVO keywordsVO = keyWordsService.keywordInfoByEventId(eventId); // KeywordsVO keywordsVO = keyWordsService.keywordInfoByEventId(eventId);
KeywordsVO keywordsVO = new KeywordsVO();
List<KeywordsVO> keywordsVOS = keyWordsService.keywordInfoByEventIdList(eventId);
keywordsVOS.stream().filter(f -> StrUtil.equals(f.getBindingType(),"1")).findFirst().ifPresent(f -> keywordsVO.setKeyword(f.getKeyword()));
keywordsVOS.stream().filter(f -> StrUtil.equals(f.getBindingType(),"3")).findFirst().ifPresent(f -> keywordsVO.setExclusionWord(f.getKeyword()));
eventVO.setKeywordsVO(keywordsVO); eventVO.setKeywordsVO(keywordsVO);
return eventVO; return eventVO;
} }
...@@ -364,6 +374,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -364,6 +374,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
Event event = new Event(); Event event = new Event();
BeanUtils.copyProperties(addEventParam, event); BeanUtils.copyProperties(addEventParam, event);
event.setStatus(1); event.setStatus(1);
event.setFirstOpenTime(new Date());
Date endTime = event.getEndTime(); Date endTime = event.getEndTime();
if (endTime == null) { if (endTime == null) {
endTime = DateUtil.addDate(new Date(), 15); endTime = DateUtil.addDate(new Date(), 15);
...@@ -384,20 +395,45 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -384,20 +395,45 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
event.setCron(cron); event.setCron(cron);
baseMapper.insert(event); baseMapper.insert(event);
String eventId = event.getId(); String eventId = event.getId();
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
try {
log.info("开始补充redis日期缓存-{}",event.getEventCode());
setRedisCache(event);
//插入专题-类别、项目的绑定关系 //插入专题-类别、项目的绑定关系
log.info("开始插入关系");
saveMapMain(event, addEventParam); saveMapMain(event, addEventParam);
log.info("开始绑定流程");
bindArrayModel(event);
//事件标签 //事件标签
log.info("开始插入事件标签");
eventTagService.save(EventTag.builder().eventId(eventId).build()); eventTagService.save(EventTag.builder().eventId(eventId).build());
//地缘关系绑定 //地缘关系绑定
log.info("地缘关系绑定");
List<RegionVO> regionList = addEventParam.getRegionList(); List<RegionVO> regionList = addEventParam.getRegionList();
addRegionMap(eventId, regionList); addRegionMap(eventId, regionList);
//默认绑定搜索引擎、模型 //默认绑定搜索引擎、模型
saveDefaultMap(eventId); saveDefaultMap(eventId);
} catch (Exception e) {
log.error("事件配置异常:{}",e.getMessage(),e);
throw new RuntimeException(e);
}
}); });
return event; return event;
} }
private void bindArrayModel(Event event) {
ClbModelArrangeSubjectMap m = new ClbModelArrangeSubjectMap();
m.setSubjectId(event.getId());
m.setType("baseDateToSubject");
m.setSubjectName(event.getEventName());
UserVo currentUser = UserUtil.getLoginUser();
m.setCreateBy(currentUser.getUsername());
m.setCreateTime(new Date());
m.setArrangeId("1945383263241506818");
clbModelArrangeSubjectMapService.save(m);
}
@Override @Override
@Transactional @Transactional
public void updateMain(AddEventParam addEventParam) { public void updateMain(AddEventParam addEventParam) {
...@@ -424,6 +460,11 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -424,6 +460,11 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
}); });
} }
@Override @Override
@Transactional @Transactional
public void deleteMain(String id) { public void deleteMain(String id) {
...@@ -483,26 +524,15 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -483,26 +524,15 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
} }
@Override @Override
public void updateStatus(String eventId, Integer status) { public Event updateStatus(String eventId, Integer status) {
Event event = this.getById(eventId); Event event = this.getById(eventId);
LambdaUpdateWrapper<Event> updateWrapper = Wrappers.lambdaUpdate(); event.setStatus(status);
updateWrapper.set(Event::getStatus, status).eq(Event::getId, eventId);
if (status == 1 && event.getFirstOpenTime() == null) { if (status == 1 && event.getFirstOpenTime() == null) {
//判断是否第一次启用 //判断是否第一次启用
updateWrapper.set(Event::getFirstOpenTime, new Date()); event.setFirstOpenTime( 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());
} }
}); this.updateById(event);
return event;
} }
@Override @Override
...@@ -787,18 +817,34 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -787,18 +817,34 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
private void saveMapMain(Event subject, AddEventParam addEventParam) { private void saveMapMain(Event subject, AddEventParam addEventParam) {
if (StringUtils.isNotEmpty(addEventParam.getSubjectTypeId())) { if (StringUtils.isNotEmpty(addEventParam.getSubjectTypeId())) {
log.info("事件专题类别id:{}-事件专题id:{}", addEventParam.getSubjectTypeId(),subject.getId());
SubjectTypeMap subjectTypeMap = new SubjectTypeMap(); SubjectTypeMap subjectTypeMap = new SubjectTypeMap();
subjectTypeMap.setSubjectId(subject.getId()); subjectTypeMap.setSubjectId(subject.getId());
subjectTypeMap.setUpdateBy(subject.getUpdateBy()); subjectTypeMap.setUpdateBy(subject.getUpdateBy());
subjectTypeMap.setUpdateTime(subject.getUpdateTime()); subjectTypeMap.setUpdateTime(subject.getUpdateTime());
subjectTypeMap.setTypeId(addEventParam.getSubjectTypeId()); subjectTypeMap.setTypeId(addEventParam.getSubjectTypeId());
iSubjectTypeMapService.save(subjectTypeMap); iSubjectTypeMapService.save(subjectTypeMap);
}else {
log.info("事件专题类别id:{}-事件专题id:{}", addEventParam.getSubjectTypeId(),subject.getId());
SubjectTypeMap subjectTypeMap = new SubjectTypeMap();
subjectTypeMap.setSubjectId(subject.getId());
subjectTypeMap.setUpdateBy(subject.getUpdateBy());
subjectTypeMap.setUpdateTime(subject.getUpdateTime());
subjectTypeMap.setTypeId("1802619433932296193");
iSubjectTypeMapService.save(subjectTypeMap);
} }
if (StringUtils.isNotEmpty(addEventParam.getProjectId())) { if (StringUtils.isNotEmpty(addEventParam.getProjectId())) {
log.info("项目id:{}-事件专题id:{}", addEventParam.getProjectId(),subject.getId());
ProjectSubjectMap projectSubjectMap = new ProjectSubjectMap(); ProjectSubjectMap projectSubjectMap = new ProjectSubjectMap();
projectSubjectMap.setProjectId(addEventParam.getProjectId()); projectSubjectMap.setProjectId(addEventParam.getProjectId());
projectSubjectMap.setSubjectId(subject.getId()); projectSubjectMap.setSubjectId(subject.getId());
iProjectSubjectMapService.save(projectSubjectMap); iProjectSubjectMapService.save(projectSubjectMap);
}else {
log.info("项目id:{}-事件专题id:{}", addEventParam.getProjectId(),subject.getId());
ProjectSubjectMap projectSubjectMap = new ProjectSubjectMap();
projectSubjectMap.setProjectId("1476527644425682945");
projectSubjectMap.setSubjectId(subject.getId());
iProjectSubjectMapService.save(projectSubjectMap);
} }
} }
...@@ -907,6 +953,42 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -907,6 +953,42 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
} }
} }
/**
* 将事件的时间范围存入redis缓存(事件第一次启用时生效)
*
* @param event 事件id
* @author lkg
* @date 2025/2/7
*/
private void setRedisCache(Event event) {
Date timeEnable = event.getStartTime();
Date timeDisable = event.getEndTime();
//date 转 localdate
LocalDate start;
LocalDate end;
if (cn.hutool.core.util.ObjectUtil.isNull(timeEnable)) {
start = LocalDate.now().minusMonths(defaultAdvanceMonth);
} else {
start = timeEnable.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
}
if (cn.hutool.core.util.ObjectUtil.isNull(timeDisable)) {
end = LocalDate.now();
} else {
end = timeDisable.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
}
//循环 start 到 end 的每一天
List<String> dateList = new ArrayList<>();
for (LocalDate date = end; !date.isBefore(start); date = date.minusDays(1)) {
// 在这里处理每一天的逻辑
//格式化date成字符串
String format = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
dateList.add(format);
}
redisUtil.rpushMultipleValues(Constants.HISTORY_SUBJECT_DATE_QUEUE + event.getEventCode(), dateList.toArray(new String[0]));
}
/** /**
* 修改事件时间缓存,用于补充数据(只有启用过的事件才会起作用) * 修改事件时间缓存,用于补充数据(只有启用过的事件才会起作用)
* *
......
...@@ -151,7 +151,6 @@ public class InformationServiceImpl implements InformationService { ...@@ -151,7 +151,6 @@ public class InformationServiceImpl implements InformationService {
if (total > 0) { if (total > 0) {
List<DisplayInfo> dataList = new ArrayList<>(); List<DisplayInfo> dataList = new ArrayList<>();
List<LabelModelVo> labelModelVos = commonService.subjectModelBindLabels(subjectIdList); List<LabelModelVo> labelModelVos = commonService.subjectModelBindLabels(subjectIdList);
Map<String, List<LabelModelVo>> modelMap = labelModelVos.stream().collect(Collectors.groupingBy(LabelModelVo::getSubjectId));
List<SpecialInformation> records = specialInformationIPage.getRecords(); List<SpecialInformation> records = specialInformationIPage.getRecords();
for (SpecialInformation specialInformation : records) { for (SpecialInformation specialInformation : records) {
DisplayInfo info = new DisplayInfo(); DisplayInfo info = new DisplayInfo();
...@@ -165,8 +164,7 @@ public class InformationServiceImpl implements InformationService { ...@@ -165,8 +164,7 @@ public class InformationServiceImpl implements InformationService {
} }
} }
//标签处理 //标签处理
List<LabelModelVo> modelVoList = modelMap.get(info.getSubjectId()); formatLabel(labelModelVos, info);
formatLabel(modelVoList, info);
dataList.add(info); dataList.add(info);
} }
page.setRecords(dataList); page.setRecords(dataList);
......
package com.zzsn.event.service.impl; package com.zzsn.event.service.impl;
import com.alibaba.fastjson2.JSON;
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.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.clb.common.model.task.dto.titr.KeyWordsDTO; import com.zzsn.clb.common.model.task.dto.titr.KeyWordsDTO;
import com.zzsn.event.constant.Constants; import com.zzsn.event.constant.Constants;
import com.zzsn.event.entity.Event; import com.zzsn.event.entity.*;
import com.zzsn.event.entity.KeyWords;
import com.zzsn.event.entity.KeywordsType;
import com.zzsn.event.entity.KeywordsTypeMap;
import com.zzsn.event.enums.CodePrefixEnum; import com.zzsn.event.enums.CodePrefixEnum;
import com.zzsn.event.mapper.KeyWordsMapper; import com.zzsn.event.mapper.KeyWordsMapper;
import com.zzsn.event.service.IKeyWordsService; import com.zzsn.event.service.*;
import com.zzsn.event.service.IKeywordsTypeMapService;
import com.zzsn.event.service.IKeywordsTypeService;
import com.zzsn.event.service.ISubjectKeywordsMapService;
import com.zzsn.event.util.CodeGenerateUtil; import com.zzsn.event.util.CodeGenerateUtil;
import com.zzsn.event.util.RedisUtil; import com.zzsn.event.util.RedisUtil;
import com.zzsn.event.util.tree.Node; import com.zzsn.event.util.tree.Node;
...@@ -28,17 +26,22 @@ import com.zzsn.event.vo.KeyWordsPage; ...@@ -28,17 +26,22 @@ import com.zzsn.event.vo.KeyWordsPage;
import com.zzsn.event.vo.KeywordsVO; import com.zzsn.event.vo.KeywordsVO;
import com.zzsn.event.vo.SubjectKeywordsMap; import com.zzsn.event.vo.SubjectKeywordsMap;
import com.zzsn.event.xxljob.service.IXxlJobInfoService; import com.zzsn.event.xxljob.service.IXxlJobInfoService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.checkerframework.checker.units.qual.K;
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.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/** /**
* @Description: 关键词管理 * @Description: 关键词管理
...@@ -63,6 +66,8 @@ public class KeyWordsServiceImpl extends ServiceImpl<KeyWordsMapper, KeyWords> i ...@@ -63,6 +66,8 @@ public class KeyWordsServiceImpl extends ServiceImpl<KeyWordsMapper, KeyWords> i
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Autowired @Autowired
private ConfigurationMessageService configurationMessageService; private ConfigurationMessageService configurationMessageService;
@Autowired
private SubjectKeywordsGroupRelationService subjectKeywordsGroupRelationService;
@Resource @Resource
private KafkaTemplate<String,String> kafkaTemplate; private KafkaTemplate<String,String> kafkaTemplate;
...@@ -278,6 +283,10 @@ public class KeyWordsServiceImpl extends ServiceImpl<KeyWordsMapper, KeyWords> i ...@@ -278,6 +283,10 @@ public class KeyWordsServiceImpl extends ServiceImpl<KeyWordsMapper, KeyWords> i
public KeywordsVO keywordInfoByEventId(String eventId) { public KeywordsVO keywordInfoByEventId(String eventId) {
return baseMapper.keywordInfoByEventId(eventId); return baseMapper.keywordInfoByEventId(eventId);
} }
@Override
public List<KeywordsVO> keywordInfoByEventIdList(String eventId) {
return baseMapper.keywordInfoByEventIdList(eventId);
}
@Override @Override
...@@ -314,4 +323,138 @@ public class KeyWordsServiceImpl extends ServiceImpl<KeyWordsMapper, KeyWords> i ...@@ -314,4 +323,138 @@ public class KeyWordsServiceImpl extends ServiceImpl<KeyWordsMapper, KeyWords> i
public List<KeyWordsPage> bindKeyWordsListByIdsAndBindType(List<String> ids, String bindingType,Integer metaSearchFlag) { public List<KeyWordsPage> bindKeyWordsListByIdsAndBindType(List<String> ids, String bindingType,Integer metaSearchFlag) {
return baseMapper.bindKeyWordsListByIdsAndBindType(ids,bindingType,metaSearchFlag); return baseMapper.bindKeyWordsListByIdsAndBindType(ids,bindingType,metaSearchFlag);
} }
@Override
@Transactional
public void saveBaseAndMap(Event event, String keyword, String exclusionWord) {
if (StringUtils.isNotEmpty(keyword)) {
addMapMain(event, keyword,1);
}
if (StringUtils.isNotEmpty(exclusionWord)) {
addMapMain(event, exclusionWord,2);
}
}
@Override
@Transactional
public void updateBaseAndMap(Event event, String keyword, String exclusionWord) {
//采集词
LambdaQueryWrapper<SubjectKeywordsMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(SubjectKeywordsMap::getSubjectId, event.getId()).eq(SubjectKeywordsMap::getBindingType, 1);
SubjectKeywordsMap one = subjectKeywordsMapService.getOne(queryWrapper);
if (one != null) {
String keywordsId = one.getKeywordsId();
LambdaUpdateWrapper<KeyWords> update = Wrappers.lambdaUpdate();
update.set(KeyWords::getKeyWord, keyword).eq(KeyWords::getId, keywordsId);
this.update(update);
}
//排除词
LambdaQueryWrapper<SubjectKeywordsMap> query = Wrappers.lambdaQuery();
query.eq(SubjectKeywordsMap::getSubjectId, event.getId()).eq(SubjectKeywordsMap::getBindingType, 3);
SubjectKeywordsMap excludeOne = subjectKeywordsMapService.getOne(queryWrapper);
if (StringUtils.isNotEmpty(exclusionWord)) {
if (excludeOne == null) {
addMapMain(event, exclusionWord,2);
} else {
String keywordsId = excludeOne.getKeywordsId();
LambdaUpdateWrapper<KeyWords> update = Wrappers.lambdaUpdate();
update.set(KeyWords::getKeyWord, exclusionWord).eq(KeyWords::getId, keywordsId);
this.update(update);
}
} else {
if (excludeOne != null) {
this.removeById(excludeOne.getKeywordsId());
subjectKeywordsMapService.removeById(excludeOne.getId());
LambdaQueryWrapper<SubjectKeywordsGroupRelation> wrapper = Wrappers.lambdaQuery();
wrapper.eq(SubjectKeywordsGroupRelation::getRelationType, 3)
.eq(SubjectKeywordsGroupRelation::getSubjectId, excludeOne.getSubjectId());
subjectKeywordsGroupRelationService.remove(wrapper);
}
}
}
@Override
@Transactional
public void removeBaseAndMap(String eventId) {
LambdaQueryWrapper<SubjectKeywordsMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(SubjectKeywordsMap::getSubjectId, eventId);
List<SubjectKeywordsMap> list = subjectKeywordsMapService.list(queryWrapper);
Set<String> ids = list.stream().map(SubjectKeywordsMap::getKeywordsId).collect(Collectors.toSet());
this.removeByIds(ids);
subjectKeywordsMapService.remove(queryWrapper);
LambdaQueryWrapper<SubjectKeywordsGroupRelation> query = Wrappers.lambdaQuery();
query.eq(SubjectKeywordsGroupRelation::getSubjectId, eventId);
subjectKeywordsGroupRelationService.remove(query);
}
private void addMapMain(Event event, String keyword, Integer type) {
KeyWords keyWords = new KeyWords();
//关键词
String wordsCode = codeGenerateUtil.geneCodeNo(CodePrefixEnum.KEY_WORDS_DEFAULT.getValue());
keyWords.setWordsCode(wordsCode);
String wordsName = event.getEventName() + "_" + System.currentTimeMillis();
keyWords.setWordsName(wordsName);
keyWords.setKeyWord(keyword);
keyWords.setStatus("1");
this.save(keyWords);
String keyWordsId = keyWords.getId();
//关键词和分类关系
KeywordsTypeMap keywordsTypeMap = new KeywordsTypeMap();
keywordsTypeMap.setKeywordsId(keyWordsId);
//分类默认 事件专题
keywordsTypeMap.setTypeId("1802634369064525826");
keywordsTypeMapService.save(keywordsTypeMap);
//词组间关系
List<SubjectKeywordsGroupRelation> relationList = new ArrayList<>();
//专题和关键词关系
List<SubjectKeywordsMap> dataList = new ArrayList<>();
if (type == 1) {
for (int i = 1; i < 3; i++) {
//专题和词组关系
SubjectKeywordsMap subjectKeywordsMap = new SubjectKeywordsMap();
subjectKeywordsMap.setKeywordsId(keyWordsId);
subjectKeywordsMap.setSubjectId(event.getId());
subjectKeywordsMap.setType("1");
subjectKeywordsMap.setBindingType(String.valueOf(i));
subjectKeywordsMap.setMetaSearchFlag(1);
dataList.add(subjectKeywordsMap);
//词组关系
SubjectKeywordsGroupRelation relation = new SubjectKeywordsGroupRelation();
relation.setSubjectId(event.getId());
relation.setKeywordsGroupIds(keyWordsId);
relation.setRelationType(String.valueOf(i));
relation.setExpressionStr(keyWordsId);
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
jsonObject.put("title", wordsName);
jsonObject.put("value", keyWordsId);
jsonArray.add(jsonObject);
relation.setParamsStr(JSON.toJSONString(jsonArray));
relationList.add(relation);
}
} else if (type == 2) {
//专题和词组关系
SubjectKeywordsMap subjectKeywordsMap = new SubjectKeywordsMap();
subjectKeywordsMap.setKeywordsId(keyWordsId);
subjectKeywordsMap.setSubjectId(event.getId());
subjectKeywordsMap.setType("1");
subjectKeywordsMap.setBindingType("3");
dataList.add(subjectKeywordsMap);
//词组关系
SubjectKeywordsGroupRelation relation = new SubjectKeywordsGroupRelation();
relation.setSubjectId(event.getId());
relation.setKeywordsGroupIds(keyWordsId);
relation.setRelationType("3");
relation.setExpressionStr(keyWordsId);
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
jsonObject.put("title", wordsName);
jsonObject.put("value", keyWordsId);
jsonArray.add(jsonObject);
relation.setParamsStr(JSON.toJSONString(jsonArray));
relationList.add(relation);
}
subjectKeywordsMapService.saveBatch(dataList);
subjectKeywordsGroupRelationService.saveBatch(relationList);
}
} }
...@@ -10,6 +10,7 @@ import cn.hutool.json.JSONUtil; ...@@ -10,6 +10,7 @@ import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSONArray; 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.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -106,6 +107,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -106,6 +107,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
@Autowired @Autowired
private InfoSourceGroupService infoSourceGroupService; private InfoSourceGroupService infoSourceGroupService;
@Autowired @Autowired
private IEventService eventService;
@Autowired
private ISubjectInfoSourceMapService iSubjectInfoSourceMapService; private ISubjectInfoSourceMapService iSubjectInfoSourceMapService;
@Autowired @Autowired
private ParamAop paramAop; private ParamAop paramAop;
...@@ -1082,6 +1085,50 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -1082,6 +1085,50 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
return byId; return byId;
} }
@Override
public Event eventUpdateScope(String subjectId, String type, String scop) {
Event byId = eventService.getById(subjectId);
// Subject byId = super.getById(subjectId);
if (ObjectUtil.isNotNull(byId)){
String dataScope = byId.getDataScope();
if (StrUtil.isNotBlank(dataScope)){
List<String> scopeList = CollectionUtil.newArrayList(dataScope.split(","));
if (StrUtil.equals(type,"1") && "1".equals(scop)){
scopeList.add("1");
}else if (StrUtil.equals(type,"1") && "0".equals(scop)){
scopeList.remove("1");
}
if (StrUtil.equals(type,"2") && "1".equals(scop)){
scopeList.add("2");
}else if (StrUtil.equals(type,"2") && "0".equals(scop)){
scopeList.remove("2");
}
if (StrUtil.equals(type,"3") && "1".equals(scop)){
scopeList.add("3");
}else if (StrUtil.equals(type,"3") && "0".equals(scop)){
scopeList.remove("3");
}
if (CollectionUtil.isNotEmpty(scopeList)) {
scopeList = scopeList.stream().distinct().collect(Collectors.toList());
String join = StrUtil.join(",", scopeList);
byId.setDataScope(join);
}else {
byId.setDataScope(null);
}
eventService.updateById(byId);
}else {
if ("1".equals(scop)) {
byId.setDataScope(scop);
}
eventService.updateById(byId);
}
}
return byId;
}
private void unBindInfoSourceGroup(SubjectPage subjectPage) { private void unBindInfoSourceGroup(SubjectPage subjectPage) {
String sourceBindType = subjectPage.getSourceBindType(); String sourceBindType = subjectPage.getSourceBindType();
...@@ -1453,5 +1500,92 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -1453,5 +1500,92 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
} }
@Override
public Subject getSubjectOrEvent(String subjectCode) {
try {
//根据编码查询出专题设置信息
//查询专题的设置信息
QueryWrapper<Subject> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("subject_code", subjectCode);
Subject subject = super.getOne(queryWrapper);
if (ObjectUtil.isEmpty(subject)){
QueryWrapper<Event> queryWrapper1 = new QueryWrapper<>();
queryWrapper1.eq("event_code", subjectCode);
Event one = eventService.getOne(queryWrapper1);
if (ObjectUtil.isNotEmpty(one)) {
subject = new Subject();
subject.setId(one.getId());
subject.setSubjectCode(one.getEventCode());
subject.setSubjectName(one.getEventName());
subject.setSubjectType(2);
subject.setCreateTime(one.getCreateTime());
subject.setTimeEnable(one.getStartTime());
subject.setTimeDisable(one.getEndTime());
subject.setDataScope(one.getDataScope());
subject.setFirstOpenTime(one.getFirstOpenTime());
subject.setStatus(one.getStatus());
}
}
if (ObjectUtil.isEmpty(subject)){
return null;
}
// if (subject.getCreateTime().before(DateTime.of("2023-11-30","yyyy-MM-dd"))){
// log.info("2023-11-30之前创建的专题{}按照之前的处理逻辑处理",subject.getSubjectName());
// return null;
// }
return subject;
} catch (Exception e) {
log.error("查询专题异常{}",e.getMessage(),e);
return null;
}
}
@Override
public Subject getSubjectOrEventById(String id) {
try {
//根据编码查询出专题设置信息
//查询专题的设置信息
Subject subject = super.getById(id);
if (ObjectUtil.isEmpty(subject)){
Event one = eventService.getById(id);
if (ObjectUtil.isNotEmpty(one)) {
subject = new Subject();
subject.setId(one.getId());
subject.setSubjectCode(one.getEventCode());
subject.setSubjectName(one.getEventName());
subject.setSubjectType(2);
subject.setCreateTime(one.getCreateTime());
subject.setTimeEnable(one.getStartTime());
subject.setTimeDisable(one.getEndTime());
subject.setDataScope(one.getDataScope());
subject.setFirstOpenTime(one.getFirstOpenTime());
subject.setStatus(one.getStatus());
}
}
if (ObjectUtil.isEmpty(subject)){
return null;
}
// if (subject.getCreateTime().before(DateTime.of("2023-11-30","yyyy-MM-dd"))){
// log.info("2023-11-30之前创建的专题{}按照之前的处理逻辑处理",subject.getSubjectName());
// return null;
// }
return subject;
} catch (Exception e) {
log.error("查询专题异常{}",e.getMessage(),e);
return null;
}
}
} }
...@@ -12,6 +12,7 @@ import org.apache.commons.collections4.CollectionUtils; ...@@ -12,6 +12,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -72,6 +73,9 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi ...@@ -72,6 +73,9 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
@Override @Override
public List<DictTreeVO> dictItemTreeList(List<String> dictIds) { public List<DictTreeVO> dictItemTreeList(List<String> dictIds) {
List<DictTreeVO> itemList = baseMapper.dictItemList(dictIds); List<DictTreeVO> itemList = baseMapper.dictItemList(dictIds);
if (CollectionUtils.isEmpty(itemList)) {
return new ArrayList<>();
}
List<DictTreeVO> tree = TreeUtil.tree(itemList, "0"); List<DictTreeVO> tree = TreeUtil.tree(itemList, "0");
tree.forEach(e -> e.setPid(e.getDictId())); tree.forEach(e -> e.setPid(e.getDictId()));
return tree; return tree;
......
...@@ -29,6 +29,9 @@ public class EventManageVO { ...@@ -29,6 +29,9 @@ public class EventManageVO {
private String startTime; private String startTime;
private String endTime; private String endTime;
private Integer status; private Integer status;
private String dataScope;
private String eventCode;
/**专题题绑定流程信息*/ /**专题题绑定流程信息*/
private List<ClbModelArrange> clbModelArranges; private List<ClbModelArrange> clbModelArranges;
} }
...@@ -78,4 +78,5 @@ public class EventVO { ...@@ -78,4 +78,5 @@ public class EventVO {
List<RegionVO> regionList; List<RegionVO> regionList;
/**关键词*/ /**关键词*/
private KeywordsVO keywordsVO; private KeywordsVO keywordsVO;
private String dataScope;
} }
...@@ -29,4 +29,6 @@ public class KeywordsVO { ...@@ -29,4 +29,6 @@ public class KeywordsVO {
* 屏蔽词 * 屏蔽词
*/ */
private String exclusionWord; private String exclusionWord;
/**绑定类型1:绑定为采集词,2:绑定为过滤词,3绑定为排除词组*/
private String bindingType;
} }
...@@ -155,7 +155,7 @@ python: ...@@ -155,7 +155,7 @@ python:
hot-crawler: http://139.9.144.106:5000/data?option=OPTION hot-crawler: http://139.9.144.106:5000/data?option=OPTION
jeecg: jeecg:
shiro: shiro:
excludeUrls: info/subjectPageListGroupByLabel,/subject/simple/**,/subject/manage/visiblePageListNoSign,/test/** excludeUrls: info/subjectPageListGroupByLabel,/subject/simple/queryInfoNoSign,/subject/manage/visiblePageListNoSign
kafka: kafka:
topic: topic:
subject: subject:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论