提交 be00e8c4 作者: 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/java/com/zzsn/event/service/impl/EventServiceImpl.java
#	src/main/java/com/zzsn/event/service/impl/KeyWordsServiceImpl.java
#	src/main/resources/application-test.yml
......@@ -178,8 +178,8 @@ public class EventManageController {
log.info("新增事件,通知采集,事件id:{}", event.getId());
configurationMessageService.bindKeyWordsEventSend(event.getId());
//事件分析
log.info("新增事件,事件分析,事件id:{}", event.getId());
kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
//log.info("新增事件,事件分析,事件id:{}", event.getId());
//kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -577,7 +577,7 @@ public class ReportDataController {
builder2.must(QueryBuilders.termsQuery(field + ".keyword", val.split(" |\\+|,|,|;|;")));
} else if ("not_in".equals(rule)) {
builder2.mustNot(QueryBuilders.termsQuery(field + ".keyword", val.split(" |\\+|,|,|;|;")));
} else if ("keyWordsGroup".equals(rule)) {
} else if (StringUtils.isNotEmpty(rule) && rule.contains("keyWordsGroup")) {
if (StringUtils.isNotEmpty(val)) {
BoolQueryBuilder wordAllBoolQuery = QueryBuilders.boolQuery();
String[] andWords = val.split("\\+");
......@@ -589,9 +589,13 @@ public class ReportDataController {
}
wordAllBoolQuery.must(wordOrBoolQuery);
}
if(rule.startsWith("not_")){
builder2.mustNot(wordAllBoolQuery);
}else{
builder2.must(wordAllBoolQuery);
}
}
}
} else if ("string".equals(type)) { //文本类查询
if ("fullText".equals(field)) {
BoolQueryBuilder fullTextBoolQuery = multiMatchQuery(val);
......@@ -599,7 +603,7 @@ public class ReportDataController {
builder2.must(fullTextBoolQuery);
} else if ("not_like".equals(rule)) {
builder2.mustNot(fullTextBoolQuery);
} else if ("keyWordsGroup".equals(rule)) {
} else if (StringUtils.isNotEmpty(rule) && rule.contains("keyWordsGroup")) {
BoolQueryBuilder wordAllBoolQuery = QueryBuilders.boolQuery();
String[] andWords = val.split("\\+");
for (String words : andWords) {
......@@ -610,8 +614,12 @@ public class ReportDataController {
}
wordAllBoolQuery.must(wordOrBoolQuery);
}
if(rule.startsWith("not_")){
builder2.mustNot(wordAllBoolQuery);
}else{
builder2.must(wordAllBoolQuery);
}
}
} else if ("eq".equals(rule)) {
builder2.must(QueryBuilders.termQuery(field + ".keyword", val));
} else if ("ne".equals(rule)) {
......@@ -624,7 +632,7 @@ public class ReportDataController {
builder2.must(QueryBuilders.matchPhrasePrefixQuery(field, val));
} else if ("not_like".equals(rule)) {
builder2.mustNot(QueryBuilders.matchPhrasePrefixQuery(field, val));
} else if ("keyWordsGroup".equals(rule)) {
} else if (StringUtils.isNotEmpty(rule) && rule.contains("keyWordsGroup")) {
BoolQueryBuilder wordAllBoolQuery = QueryBuilders.boolQuery();
String[] andWords = val.split("\\+");
for (String words : andWords) {
......@@ -635,9 +643,13 @@ public class ReportDataController {
}
wordAllBoolQuery.must(wordOrBoolQuery);
}
if(rule.startsWith("not_")){
builder2.mustNot(wordAllBoolQuery);
}else{
builder2.must(wordAllBoolQuery);
}
}
}
if ("or".equals(superQueryMatchType)) {
superBuilder.should(builder2);
} else {
......
......@@ -274,6 +274,7 @@ public class EventDataController {
AddEventParam eventParam = new AddEventParam();
BeanUtils.copyProperties(addEventVO, eventParam);
eventParam.setCreateBy(currentUser.getUsername());
eventParam.setOpen(true);
Event event = eventService.saveMain(eventParam);
//新增关键词
keyWordsService.saveBaseAndMap(event, keywordsVO.getKeyword(), keywordsVO.getExclusionWord());
......
......@@ -2949,7 +2949,7 @@ public class EsService {
builder2.must(QueryBuilders.termsQuery(field + ".keyword", val.split(" |\\+|,|,|;|;")));
} else if ("not_in".equals(rule)) {
builder2.mustNot(QueryBuilders.termsQuery(field + ".keyword", val.split(" |\\+|,|,|;|;")));
} else if ("keyWordsGroup".equals(rule)) {
} else if (StringUtils.isNotEmpty(rule) && rule.contains("keyWordsGroup")) {
if (StringUtils.isNotEmpty(val)) {
BoolQueryBuilder wordAllBoolQuery = QueryBuilders.boolQuery();
String[] andWords = val.split("\\+");
......@@ -2961,9 +2961,13 @@ public class EsService {
}
wordAllBoolQuery.must(wordOrBoolQuery);
}
if(rule.startsWith("not_")){
builder2.mustNot(wordAllBoolQuery);
}else{
builder2.must(wordAllBoolQuery);
}
}
}
} else if ("string".equals(type)) { //文本类查询
if ("fullText".equals(field)) {
BoolQueryBuilder fullTextBoolQuery = multiMatchQuery(val);
......@@ -2971,7 +2975,7 @@ public class EsService {
builder2.must(fullTextBoolQuery);
} else if ("not_like".equals(rule)) {
builder2.mustNot(fullTextBoolQuery);
} else if ("keyWordsGroup".equals(rule)) {
} else if (StringUtils.isNotEmpty(rule) && rule.contains("keyWordsGroup")) {
BoolQueryBuilder wordAllBoolQuery = QueryBuilders.boolQuery();
String[] andWords = val.split("\\+");
for (String words : andWords) {
......@@ -2982,8 +2986,12 @@ public class EsService {
}
wordAllBoolQuery.must(wordOrBoolQuery);
}
if(rule.startsWith("not_")){
builder2.mustNot(wordAllBoolQuery);
}else{
builder2.must(wordAllBoolQuery);
}
}
} else if ("eq".equals(rule)) {
builder2.must(QueryBuilders.termQuery(field + ".keyword", val));
} else if ("ne".equals(rule)) {
......@@ -2996,7 +3004,7 @@ public class EsService {
builder2.must(QueryBuilders.matchPhrasePrefixQuery(field, val));
} else if ("not_like".equals(rule)) {
builder2.mustNot(QueryBuilders.matchPhrasePrefixQuery(field, val));
} else if ("keyWordsGroup".equals(rule)) {
} else if (StringUtils.isNotEmpty(rule) && rule.contains("keyWordsGroup")) {
BoolQueryBuilder wordAllBoolQuery = QueryBuilders.boolQuery();
String[] andWords = val.split("\\+");
for (String words : andWords) {
......@@ -3007,9 +3015,13 @@ public class EsService {
}
wordAllBoolQuery.must(wordOrBoolQuery);
}
if(rule.startsWith("not_")){
builder2.mustNot(wordAllBoolQuery);
}else{
builder2.must(wordAllBoolQuery);
}
}
}
if ("or".equals(superQueryMatchType)) {
superBuilder.should(builder2);
} else {
......
package com.zzsn.event.external.controller;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.Subject;
import com.zzsn.event.external.entity.ExternalSubjectInfoSourceMap;
import com.zzsn.event.external.service.ExternalSubjectInfoSourceMapService;
import com.zzsn.event.external.vo.SubjectInfoVO;
import com.zzsn.event.external.vo.SubjectVO;
import com.zzsn.event.service.CommonService;
import com.zzsn.event.service.SubjectSimpleService;
import com.zzsn.event.util.HttpUtil;
import com.zzsn.event.util.LLMUtil;
import com.zzsn.event.vo.SubjectDetailVO;
import com.zzsn.event.vo.SubjectSimpleVO;
import com.zzsn.event.xxljob.service.IXxlJobInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
/**
* @author lkg
* @date 2025/8/12
*/
@RestController
@RequestMapping("/external")
public class ExternalController {
@Autowired
private SubjectSimpleService subjectSimpleService;
@Autowired
private IXxlJobInfoService xxlJobInfoService;
@Autowired
private ExternalSubjectInfoSourceMapService externalSubjectInfoSourceMapService;
@Autowired
private CommonService commonService;
@Value("${caiji.keywordCrawler.url:}")
private String keywordCrawlerUrl;
/**
* 创建专题
*
* @param subjectVO 参数
* @author lkg
* @date 2025/1/9
*/
@PostMapping("/createSubject")
public Result<?> createSubject(@RequestBody SubjectVO subjectVO) {
subjectVO.setDataScope("1");
SubjectSimpleVO subjectSimpleVO = new SubjectSimpleVO();
BeanUtils.copyProperties(subjectVO, subjectSimpleVO);
Subject subject = subjectSimpleService.createExternalSubject(subjectSimpleVO);
CompletableFuture.runAsync(() -> {
//插入xxlJob
xxlJobInfoService.subjectInsert(subject);
});
return Result.OK(subject.getId());
}
/**
* 编辑专题
*
* @param subjectVO 参数
* @author lkg
* @date 2025/1/9
*/
@PostMapping("/updateSubject")
public Result<?> updateSubject(@RequestBody SubjectVO subjectVO) {
subjectVO.setDataScope("1");
SubjectSimpleVO subjectSimpleVO = new SubjectSimpleVO();
BeanUtils.copyProperties(subjectVO, subjectSimpleVO);
subjectSimpleService.editExternalSubject(subjectSimpleVO);
return Result.OK();
}
/**
* 采集词推荐
*
* @param remark 专题描述
* @author lkg
* @date 2025/8/12
*/
@GetMapping("/crawlerWordRecommend")
public Result<?> crawlerWordRecommend(@RequestParam String remark) {
return Result.OK(LLMUtil.crawlerWord(remark));
}
/**
* 绑定信息源分页列表
*
* @param subjectId 专题id
* @param pageNo 页码
* @param pageSize 每页返回条数
* @author lkg
* @date 2025/8/12
*/
@GetMapping("/bindSourcePageList")
public Result<?> bindSourceList(@RequestParam String subjectId,
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize) {
Page<ExternalSubjectInfoSourceMap> page = new Page<>(pageNo, pageSize);
LambdaQueryWrapper<ExternalSubjectInfoSourceMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(ExternalSubjectInfoSourceMap::getSubjectId, subjectId)
.eq(ExternalSubjectInfoSourceMap::getType, 1);
Page<ExternalSubjectInfoSourceMap> list = externalSubjectInfoSourceMapService.page(page, queryWrapper);
return Result.OK(list);
}
/**
* 下载导入信息源
*
* @author lkg
* @date 2024/06/21
*/
@GetMapping("/downloadInfoSourceTemplate")
public void downloadResearchTemplate(HttpServletResponse response) {
String filePath = "subjectDataImport/导入信息源模板.xlsx";
commonService.downloadTemplate(response, filePath);
}
/**
* 批量导入绑定得信息源
*
* @author lkg
* @date 2025/8/12
*/
@PostMapping("/importInfoSource")
public Result<?> importInfoSource(HttpServletRequest request) {
String subjectId = request.getParameter("subjectId");
if (StringUtils.isBlank(subjectId)) {
return Result.FAIL(500, "专题id不能为空");
}
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
if (fileMap.size() < 1) {
return Result.FAIL(500, "请上传excel文件");
}
MultipartFile multipartFile = fileMap.get(new ArrayList<>(fileMap.keySet()).get(0));
int index = multipartFile.getOriginalFilename().lastIndexOf(".");
String fileSuffix = multipartFile.getOriginalFilename().substring(index + 1);
if ("xls".equals(fileSuffix) || "xlsx".equals(fileSuffix)) {
try {
ExcelReader reader = ExcelUtil.getReader(multipartFile.getInputStream());
Map<String, String> header = new HashMap<>();
header.put("信息源名称", "infoSourceName");
header.put("信息源地址", "infoSourceUrl");
reader.setHeaderAlias(header);
List<ExternalSubjectInfoSourceMap> infoSourceList = reader.read(0, 1, ExternalSubjectInfoSourceMap.class);
infoSourceList.forEach(infoSource -> {
infoSource.setSubjectId(subjectId);
infoSource.setType(1);
});
externalSubjectInfoSourceMapService.saveBatch(infoSourceList);
} catch (IOException e) {
e.printStackTrace();
}
} else {
return Result.FAIL(500, "不支持的文件类型");
}
return Result.OK();
}
/**
* 绑定信息源
*
* @param externalSubjectInfoSourceMap 参数
* @author lkg
* @date 2025/8/12
*/
@PostMapping("/bindSource")
public Result<?> bindSource(@RequestBody ExternalSubjectInfoSourceMap externalSubjectInfoSourceMap) {
externalSubjectInfoSourceMap.setType(1);
externalSubjectInfoSourceMapService.save(externalSubjectInfoSourceMap);
return Result.OK();
}
/**
* 解绑信息源
*
* @param ids id集合
* @author lkg
* @date 2025/8/12
*/
@GetMapping("/unBindSource")
public Result<?> bindSource(@RequestParam List<String> ids) {
externalSubjectInfoSourceMapService.removeByIds(ids);
return Result.OK();
}
/**
* 专题详情
*
* @param subjectId 专题id
* @author lkg
* @date 2025/1/9
*/
@GetMapping("/queryInfo")
public Result<?> queryInfo(@RequestParam String subjectId) {
SubjectInfoVO subjectInfoVO = new SubjectInfoVO();
SubjectDetailVO subjectDetailVO = subjectSimpleService.queryInfo(subjectId);
BeanUtils.copyProperties(subjectDetailVO, subjectInfoVO);
LambdaQueryWrapper<ExternalSubjectInfoSourceMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(ExternalSubjectInfoSourceMap::getSubjectId, subjectId)
.eq(ExternalSubjectInfoSourceMap::getType, 1);
subjectInfoVO.setInfoSourceList(externalSubjectInfoSourceMapService.list(queryWrapper));
return Result.OK(subjectInfoVO);
}
/**
* 配置信息推送给采集
*
* @param subjectId 专题id
* @author lkg
* @date 2025/8/12
*/
@GetMapping("/pushToCaiji")
public Result<?> pushToCaiji(@RequestParam String subjectId) {
SubjectInfoVO subjectInfoVO = new SubjectInfoVO();
SubjectDetailVO subjectDetailVO = subjectSimpleService.queryInfo(subjectId);
BeanUtils.copyProperties(subjectDetailVO, subjectInfoVO);
LambdaQueryWrapper<ExternalSubjectInfoSourceMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(ExternalSubjectInfoSourceMap::getSubjectId, subjectId)
.eq(ExternalSubjectInfoSourceMap::getType, 1);
subjectInfoVO.setInfoSourceList(externalSubjectInfoSourceMapService.list(queryWrapper));
try {
HttpUtil.doPost(keywordCrawlerUrl, JSONObject.from(subjectInfoVO), 30000);
} catch (IOException e) {
e.printStackTrace();
}
return Result.OK();
}
}
package com.zzsn.event.external.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@Data
@TableName("external_subject_info_source_map")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class ExternalSubjectInfoSourceMap implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**
* 信息源地址
*/
private String subjectId;
/**
* 信息源id
*/
private String infoSourceUrl;
/**
* 信息源名称
*/
private String infoSourceName;
/**
* 专题描述
*/
private String description;
/**
* 1-信息源;2-专题描述
*/
private Integer type;
/**
* 创建人
*/
private String createBy;
/**
* 创建日期
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**
* 更新人
*/
private String updateBy;
/**
* 更新日期
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
}
package com.zzsn.event.external.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.external.entity.ExternalSubjectInfoSourceMap;
import org.apache.ibatis.annotations.Mapper;
/**
*
*
* @author lkg
* @date 2025/8/12
*/
@Mapper
public interface ExternalSubjectInfoSourceMapMapper extends BaseMapper<ExternalSubjectInfoSourceMap> {
}
package com.zzsn.event.external.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.external.entity.ExternalSubjectInfoSourceMap;
/**
*
*
* @author lkg
* @date 2025/8/12
*/
public interface ExternalSubjectInfoSourceMapService extends IService<ExternalSubjectInfoSourceMap> {
}
package com.zzsn.event.external.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.external.entity.ExternalSubjectInfoSourceMap;
import com.zzsn.event.external.mapper.ExternalSubjectInfoSourceMapMapper;
import com.zzsn.event.external.service.ExternalSubjectInfoSourceMapService;
import org.springframework.stereotype.Service;
/**
*
*
* @author lkg
* @date 2025/8/12
*/
@Service
public class ExternalSubjectInfoSourceMapServiceImpl extends ServiceImpl<ExternalSubjectInfoSourceMapMapper, ExternalSubjectInfoSourceMap>
implements ExternalSubjectInfoSourceMapService {
}
package com.zzsn.event.external.vo;
import com.zzsn.event.external.entity.ExternalSubjectInfoSourceMap;
import com.zzsn.event.vo.SubjectDetailVO;
import lombok.Data;
import java.util.List;
/**
* 专题详情信息(包含样例文章)
*
* @author lkg
* @date 2025/1/8
*/
@Data
public class SubjectInfoVO extends SubjectDetailVO {
List<ExternalSubjectInfoSourceMap> infoSourceList;
}
package com.zzsn.event.external.vo;
import com.zzsn.event.external.entity.ExternalSubjectInfoSourceMap;
import com.zzsn.event.vo.SubjectSimpleVO;
import lombok.Data;
import java.util.List;
/**
* 简化流程后的入参对象-研究中心
*
* @author lkg
* @date 2025/1/9
*/
@Data
public class SubjectVO extends SubjectSimpleVO {
List<ExternalSubjectInfoSourceMap> infoSourceList;
}
......@@ -69,7 +69,14 @@
s.time_disable as end_time
from subject s
where
<choose>
<when test="sql != null and sql != ''">
((s.face_public = #{facePublic} and s.create_by = #{username}) or (s.face_public = #{facePublic} and ${sql}))
</when>
<otherwise>
(s.create_by = #{username} or s.face_public = #{facePublic})
</otherwise>
</choose>
<if test="subjectType!=null">
and s.subject_type = #{subjectType}
</if>
......
......@@ -23,6 +23,15 @@ public interface SubjectSimpleService {
Subject createSubject(SubjectSimpleVO subjectSimpleVO);
/**
* 新增专题-对外【自定义专题地址】
*
* @param subjectSimpleVO 参数
* @author lkg
* @date 2025/1/14
*/
Subject createExternalSubject(SubjectSimpleVO subjectSimpleVO);
/**
* 专题配置校验
*
* @param subjectParamsCheckVO 参数
......@@ -41,6 +50,15 @@ public interface SubjectSimpleService {
void editSubject(SubjectSimpleVO subjectSimpleVO);
/**
* 编辑专题
*
* @param subjectSimpleVO 参数
* @author lkg
* @date 2025/1/14
*/
void editExternalSubject(SubjectSimpleVO subjectSimpleVO);
/**
* 专题绑定关键词信息
*
* @param subjectId 专题id
......
......@@ -379,6 +379,11 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
event.setStatus(1);
Date now = new Date();
event.setFirstOpenTime(now);
if (ObjectUtil.isNotEmpty(addEventParam.isOpen()) && addEventParam.isOpen()) {
//立即开启
event.setStatus(1);
event.setFirstOpenTime(new Date());
}
Date endTime = event.getEndTime();
if (endTime == null) {
endTime = cn.hutool.core.date.DateUtil.offsetWeek(addEventParam.getStartTime(), 3);
......
......@@ -5,6 +5,7 @@ import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -35,6 +36,7 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.jsoup.Jsoup;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
......@@ -96,6 +98,9 @@ public class InformationServiceImpl implements InformationService {
private ImageUtil imageUtil;
private String subjectId = "1898653164373065730";//中外智库专栏对应专题id
@Value("${ai-article.thematicColumnConfig-url:}")
private String thematicColumnConfig;
@Override
public IPage<EventDataVO> collectPageList(InfoDataSearchCondition eventDataCondition) {
return esService.collectPageList(eventDataCondition);
......@@ -158,7 +163,7 @@ public class InformationServiceImpl implements InformationService {
publishDate = EsDateUtil.esFieldDateMapping(info.getPublishDate());
String dateFormat = searchCondition.getDateFormat();
if (!dateFormat.equals("yyyy-MM-dd HH:mm:ss")) {
info.setPublishDate(DateUtil.formatStr(publishDate,"yyyy-MM-dd HH:mm:ss", dateFormat));
info.setPublishDate(DateUtil.formatStr(publishDate, "yyyy-MM-dd HH:mm:ss", dateFormat));
}
}
//标签处理
......@@ -285,6 +290,10 @@ public class InformationServiceImpl implements InformationService {
map.put("infoList", listN);
list.add(map);
});
List<String> columnConfigList = thematicColumnConfig(searchCondition.getSubjectId());
if (CollectionUtils.isNotEmpty(columnConfigList)) {
sortByAnotherList(list, columnConfigList);
}
} else {
//不加标签获取列表数据
searchCondition.setLabelMark(null);
......@@ -370,6 +379,44 @@ public class InformationServiceImpl implements InformationService {
return groupedByLabelMark;
}
private List<String> thematicColumnConfig(String subjectId) {
List<String> list = new ArrayList<>();
try {
Map<String, String> variables = new HashMap<>();
variables.put("id", subjectId);
String response = HttpUtil.doGet(thematicColumnConfig, variables, null, "utf-8");
JSONObject jsonObject = JSONObject.parseObject(response);
if (jsonObject == null) {
return list;
}
JSONArray data = jsonObject.getJSONArray("data");
if (data != null && data.size() > 0) {
for (Object datum : data) {
JSONObject item = (JSONObject) datum;
list.add(item.getString("themeName"));
}
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
//目标集合按照另一个集合的顺序排序
private void sortByAnotherList(List<HashMap> list, List<String> anotherList) {
list.sort((o1, o2) -> {
int index1 = anotherList.indexOf(o1.get("relationName").toString());
int index2 = anotherList.indexOf(o2.get("relationName").toString());
if (index1 != -1) {
index1 = list.size() - index1;
}
if (index2 != -1) {
index2 = list.size() - index2;
}
return index2 - index1;
});
}
@Override
public DisplayInfo queryInfo(Integer type, String index, String id) {
DisplayInfo info = (DisplayInfo) esOpUtil.getInfoById(index, id, DisplayInfo.class);
......@@ -1101,7 +1148,7 @@ public class InformationServiceImpl implements InformationService {
dataList.add(specialInformation);
}
esOpUtil.docSaveBulk(index, dataList);
log.info("专题-{},批量插入-{}-条数据完成",subjectId, lists.size());
log.info("专题-{},批量插入-{}-条数据完成", subjectId, lists.size());
}
}
......@@ -1226,7 +1273,7 @@ public class InformationServiceImpl implements InformationService {
deleteParams.put("fieldType", word);
long start = System.currentTimeMillis();
esOpUtil.batchNestedDeleteScript(indexArr, buildQuery, deleteParams, "sortField");
log.info("删除关键词-{},耗时:{}",word, System.currentTimeMillis()-start);
log.info("删除关键词-{},耗时:{}", word, System.currentTimeMillis() - start);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
......@@ -1250,11 +1297,11 @@ public class InformationServiceImpl implements InformationService {
}
Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("checkStatus", 1);
modifyParams.put("deleteFlag",0);
modifyParams.put("updateDate",EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
modifyParams.put("deleteFlag", 0);
modifyParams.put("updateDate", EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
long start = System.currentTimeMillis();
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
log.info("添加到精选,耗时:{}", System.currentTimeMillis()-start);
log.info("添加到精选,耗时:{}", System.currentTimeMillis() - start);
}
@Override
......@@ -1271,12 +1318,12 @@ public class InformationServiceImpl implements InformationService {
buildQuery = QueryBuilders.boolQuery().must(QueryBuilders.termsQuery("id", ids));
}
Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("checkStatus",3);
modifyParams.put("deleteFlag",0);
modifyParams.put("updateDate",EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
modifyParams.put("checkStatus", 3);
modifyParams.put("deleteFlag", 0);
modifyParams.put("updateDate", EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
long start = System.currentTimeMillis();
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
log.info("添加到待定,耗时:{}", System.currentTimeMillis()-start);
log.info("添加到待定,耗时:{}", System.currentTimeMillis() - start);
}
@Override
......@@ -1293,11 +1340,11 @@ public class InformationServiceImpl implements InformationService {
buildQuery = QueryBuilders.boolQuery().must(QueryBuilders.termsQuery("id", ids));
}
Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("deleteFlag",1);
modifyParams.put("updateDate",EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
modifyParams.put("deleteFlag", 1);
modifyParams.put("updateDate", EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
long start = System.currentTimeMillis();
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
log.info("添加到删除,耗时:{}", System.currentTimeMillis()-start);
log.info("添加到删除,耗时:{}", System.currentTimeMillis() - start);
}
@Override
......@@ -1308,12 +1355,12 @@ public class InformationServiceImpl implements InformationService {
String[] indexArr = EsIndexUtil.getIndexIntervalYearStr(Constants.SUBJECT_INDEX, minCreateTime);
BoolQueryBuilder buildQuery = esService.buildQuery(searchCondition, subjectIdList);
Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("checkStatus",0);
modifyParams.put("deleteFlag",0);
modifyParams.put("updateDate",EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
modifyParams.put("checkStatus", 0);
modifyParams.put("deleteFlag", 0);
modifyParams.put("updateDate", EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
long start = System.currentTimeMillis();
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
log.info("初始化数据,耗时:{}", System.currentTimeMillis()-start);
log.info("初始化数据,耗时:{}", System.currentTimeMillis() - start);
}
@Override
......@@ -1327,7 +1374,7 @@ public class InformationServiceImpl implements InformationService {
Integer searchScope = searchWordVO.getSearchScope();
String oldWord = searchWordVO.getSearchInfo();
String newWord = searchCondition.getReplaceWord();
if(StringUtils.isEmpty(newWord)) {
if (StringUtils.isEmpty(newWord)) {
newWord = "";
}
List<String> modifyFields = new ArrayList<>();
......@@ -1350,14 +1397,14 @@ public class InformationServiceImpl implements InformationService {
BoolQueryBuilder buildQuery = esService.buildQuery(searchCondition, subjectIdList);
long start = System.currentTimeMillis();
esOpUtil.batchReplaceScript(indexArr, buildQuery, modifyFields, oldWord, newWord);
log.info("字符串替换-{},耗时:{}", oldWord,System.currentTimeMillis()-start);
log.info("字符串替换-{},耗时:{}", oldWord, System.currentTimeMillis() - start);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("updateDate",EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
modifyParams.put("updateDate", EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
}
......@@ -1377,17 +1424,17 @@ public class InformationServiceImpl implements InformationService {
Map<String, Object> addParams = new HashMap<>();
for (Label markTag : searchCondition.getMarkTags()) {
Map<String, String> addTag = ObjectUtil.objectToMap(markTag);
addParams.put("labels",addTag);
addParams.put("labels", addTag);
long start = System.currentTimeMillis();
esOpUtil.batchNestedAddScript(indexArr, buildQuery, addParams,"labels","relationId");
log.info("打标-{},耗时:{}", markTag.getRelationName(),System.currentTimeMillis()-start);
esOpUtil.batchNestedAddScript(indexArr, buildQuery, addParams, "labels", "relationId");
log.info("打标-{},耗时:{}", markTag.getRelationName(), System.currentTimeMillis() - start);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("updateDate",EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
modifyParams.put("updateDate", EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
try {
Thread.sleep(1000);
......@@ -1420,14 +1467,14 @@ public class InformationServiceImpl implements InformationService {
deleteParams.put("relationId", markTag.getRelationId());
long start = System.currentTimeMillis();
esOpUtil.batchNestedDeleteScript(indexArr, buildQuery, deleteParams, "labels");
log.info("删除标签-{},耗时:{}", markTag.getRelationName(),System.currentTimeMillis()-start);
log.info("删除标签-{},耗时:{}", markTag.getRelationName(), System.currentTimeMillis() - start);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("updateDate",EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
modifyParams.put("updateDate", EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
try {
Thread.sleep(1000);
......
......@@ -139,6 +139,29 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
return subject;
}
@Override
public Subject createExternalSubject(SubjectSimpleVO subjectSimpleVO) {
SubjectPage subjectPage = new SubjectPage();
BeanUtils.copyProperties(subjectSimpleVO, subjectPage);
subjectPage.setProjectId("1955112691539480577");
Subject subject = saveMain(subjectPage);
String subjectId = subject.getId();
//关键词绑定
List<SearchWordVO> keywords = subjectSimpleVO.getKeywords();
if (CollectionUtils.isNotEmpty(keywords)) {
modifyKeyword(subjectId, subject.getSubjectName(), keywords);
//同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectId);
//默认绑定tpu流程
ClbModelArrangeSubjectMap tpu = new ClbModelArrangeSubjectMap();
tpu.setSubjectId(subject.getId());
tpu.setArrangeId("1955564099203072002");
tpu.setType("baseDateToSubject");
clbModelArrangeSubjectMapService.save(tpu);
}
return subject;
}
public Subject saveMain(SubjectPage subjectPage) {
Subject subject = new Subject();
//事件专题的默认分析规则参数-必填
......@@ -358,6 +381,21 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
}
@Override
public void editExternalSubject(SubjectSimpleVO subjectSimpleVO) {
SubjectPage subjectPage = new SubjectPage();
BeanUtils.copyProperties(subjectSimpleVO, subjectPage);
subjectPage.setProjectId("1955112691539480577");
subjectService.updateMain(subjectPage);
//关键词绑定
List<SearchWordVO> keywords = subjectSimpleVO.getKeywords();
if (CollectionUtils.isNotEmpty(keywords)) {
modifyKeyword(subjectSimpleVO.getId(), subjectSimpleVO.getSubjectName(), keywords);
//同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectSimpleVO.getId());
}
}
@Override
public List<SearchWordVO> subjectBindWordInfo(String subjectId) {
List<SearchWordVO> wordInfoList = subjectKeywordsMapService.subjectBindWordInfo(subjectId);
Map<String, SearchWordVO> map = wordInfoList.stream().collect(Collectors.toMap(SearchWordVO::getId, item -> item));
......
......@@ -21,7 +21,8 @@ public class LLMUtil {
final static String ChatGlm4_URL = "https://open.bigmodel.cn/api/paas/v4/chat/completions";
final static String API_KEY = "2eb40c7bb8e4d22b389cd9ada5a8d6cc.bAbE6g6y71TeC0on";
//final static String API_KEY = "2eb40c7bb8e4d22b389cd9ada5a8d6cc.bAbE6g6y71TeC0on";
final static String API_KEY = "c5a53bd5f95a4e37a8997deb5d0c6031.orXyRRPNvZiqRaxF";
/**
* LLM-推荐关键词
......@@ -63,8 +64,51 @@ public class LLMUtil {
return list;
}
public static void main(String[] args) {
List<String> list = wordRecommend("人工智能|汽车");
System.out.println(JSON.toJSONString(list));
public static String crawlerWord(String remark) {
String result = null;
String prompt = "你是一个专业信息采集助手,根据用户提供的专题描述,精准提取核心实体和主题,生成符合以下规则的关键词表达式:\n" +
"1. 用 `+` 表示 **与** 关系(必须同时出现)\n" +
"2. 用 `|` 表示 **或** 关系(任一出现即可)\n" +
"3. +两端的关键词组用 `()` 框选\n" +
"4. 关键词必须直接来自描述或合理扩展的同义/关联词\n" +
"5. 输出仅含表达式,无额外解释\n" +
"6.+号使用不超过2个\n" +
"7.不要把时间提取进表达式\n" +
"\n" +
"\n" +
"### 示例\n" +
"专题描述:\"星动纪元、云深处科技分别完成近5亿元融资,用于人形机器人研发与量产\" \n" +
"输出:(星动纪元|云深处科技)+(融资|量产)";
JSONObject params = new JSONObject();
List<JSONObject> messages = new ArrayList<>();
JSONObject systemMap = new JSONObject();
systemMap.put("role", "system");
systemMap.put("content", prompt);
messages.add(systemMap);
JSONObject message = new JSONObject();
message.put("content", remark);
message.put("role", "user");
messages.add(message);
params.put("messages", messages);
params.put("model", "glm-4-plus");
JSONObject responseFormat = new JSONObject();
responseFormat.put("type", "json_object");
params.put("response_format", responseFormat);
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
headers.put("Authorization", "Bearer " + API_KEY);
String response = null;
try {
response = HttpUtil.doPostWithHeader(ChatGlm4_URL, params, 30000, headers);
JSONObject jsonObject = JSON.parseObject(response);
JSONArray choices = jsonObject.getJSONArray("choices");
JSONObject choice = choices.getJSONObject(0);
result = choice.getJSONObject("message").getString("content");
} catch (Exception e) {
log.info("大模型-{},调用异常:{}","glm-4-plus",e.getMessage());
log.info("返回结果:{}",response);
}
return result;
}
}
......@@ -18,4 +18,6 @@ public class AddEventParam extends Event {
/**伪事件id*/
private String fakeEventId;
/**是否立即开启*/
private boolean isOpen;
}
package com.zzsn.event.vo;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zzsn.event.entity.arrange.ClbModelArrange;
import io.swagger.annotations.ApiModel;
......@@ -47,7 +49,7 @@ public class SubjectPage {
/**状态*/
@Excel(name = "状态", width = 15, dicCode = "clb_subject_status")
@ApiModelProperty(value = "状态")
private Integer status = 0;
private Integer status;
/**是否公开(0-未公开;1-已公开)*/
private Integer facePublic;
/**数据来源(0-平台数据;1-全网搜)*/
......@@ -118,6 +120,9 @@ public class SubjectPage {
private String sysOrgCode;
/**专题类型(1-普通专题;3-嵌套专题)*/
private Integer subjectType;
/**数据范围(是否是全库) - 采集库全库-1,企业库全库-2,政策库全库-3*/
@TableField(updateStrategy = FieldStrategy.IGNORED) // 忽略更新策略
private String dataScope;
/**信息源数量*/
private Integer infoSourceNum;
......
......@@ -40,4 +40,6 @@ public class SubjectSimpleVO {
private String environment;
public String subjectTypeName;
/**数据范围(是否是全库) - 采集库全库-1,企业库全库-2,政策库全库-3*/
private String dataScope;
}
......@@ -174,6 +174,8 @@ caiji:
url: http://1.95.133.166:8823/baseSourceInfo/api/subject/infoSourceSave
allKeyWordsBind:
url: http://1.95.133.166:8823/baseSourceInfo/api/subject/keywordSave
keywordCrawler:
url: http://1.95.136.108:9010/put_keyword
projectCode: zzsn_prod
projectName: 克虏宝正式
......
......@@ -155,7 +155,7 @@ python:
hot-crawler: http://139.9.144.106:5000/data?option=OPTION
jeecg:
shiro:
excludeUrls: info/subjectPageListGroupByLabel,/subject/simple/queryInfoNoSign,/subject/manage/visiblePageListNoSign
excludeUrls: info/subjectPageListGroupByLabel,/subject/simple/**,/subject/manage/visiblePageListNoSign
kafka:
topic:
subject:
......@@ -179,6 +179,11 @@ infoSource:
waitInfoRemove: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/waitInfoRemove
columnListByWait: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/columnListByWait
columnDetail: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/columnDetail
ai-article:
thematicColumnConfig-url: http://1.95.77.159:10089/reportManage/thematicInformationColumn/column/getThematicColumnConfig
caiji:
keywordCrawler:
url: http://1.95.136.108:9010/put_keyword
model:
default-modelType: zhipu
configs:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论