提交 cd3ccb2c 作者: 925993793@qq.com

自定义专题

上级 c7e4973d
......@@ -134,29 +134,7 @@ public class FileController {
@GetMapping("/downloadTemplate")
public void downloadTemplate(HttpServletResponse response) {
String filePath = "subjectDataImport/导入模板.xlsx";
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
byte[] bytes = obsUtil.getObjectByte(filePath);
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
try {
OutputStream outs = response.getOutputStream();
bos = new BufferedOutputStream(outs);
bis = new BufferedInputStream(inputStream);
int i;
while ((i = bis.read(bytes)) != -1) {
bos.write(bytes, 0, i);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
bos.flush();
bos.close();
bis.close();
} catch (Exception e) {
e.printStackTrace();
}
}
commonService.downloadTemplate(response, filePath);
}
/**
......
package com.zzsn.event.controller;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.obs.services.model.PutObjectResult;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.Subject;
import com.zzsn.event.entity.SubjectKeywordsGroupRelation;
import com.zzsn.event.entity.*;
import com.zzsn.event.es.EsService;
import com.zzsn.event.service.*;
import com.zzsn.event.util.CronUtil;
import com.zzsn.event.util.HttpUtil;
import com.zzsn.event.util.*;
import com.zzsn.event.util.user.AuthUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*;
import com.zzsn.event.vo.es.DisplayInfo;
import com.zzsn.event.vo.es.SpecialInformation;
import com.zzsn.event.xxljob.entity.XxlJobInfo;
import com.zzsn.event.xxljob.service.IXxlJobInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.jsoup.Jsoup;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -29,11 +46,14 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
/**
* 平台事件管理页
......@@ -63,9 +83,19 @@ public class SubjectManageController {
@Autowired
private EsService esService;
@Autowired
SubjectKeywordsGroupRelationService subjectKeywordsGroupRelationService;
private SubjectKeywordsGroupRelationService subjectKeywordsGroupRelationService;
@Autowired
private ScoreModelService scoreModelService;
@Autowired
private ClbLabelService clbLabelService;
@Autowired
private ISubjectInfoSourceMapService subjectInfoSourceMapService;
@Autowired
private ObsUtil obsUtil;
@Autowired
private SubjectSampleFileService subjectSampleFileService;
@Autowired
private SubjectInfoSourceMiddleMapService subjectInfoSourceMiddleMapService;
@Value("${hotWords.extractUrl}")
......@@ -115,14 +145,75 @@ public class SubjectManageController {
*/
@PostMapping("/recommendWordList")
public Result<?> recommendWordList(MultipartFile[] files, String words) {
// todo
JSONObject jsonObject = new JSONObject();
jsonObject.put("article", "12");
jsonObject.put("word", "12");
boolean flag = true;
if (files != null && files.length > 0) {
for (MultipartFile file : files) {
String originalFilename = file.getOriginalFilename();
if (!(originalFilename.endsWith(".txt") || originalFilename.endsWith(".doc") || originalFilename.endsWith(".docx"))) {
flag = false;
break;
}
}
if (!flag) {
return Result.FAIL("包含不支持的文件类型");
}
List<StatisticsKeyWordVo> statisticsKeyWordVos = articleWords(files);
jsonObject.put("article", statisticsKeyWordVos);
}
if (StringUtils.isNotBlank(words)) {
List<StatisticsKeyWordVo> statisticsKeyWordVos = extractWords(words);
jsonObject.put("word", statisticsKeyWordVos);
}
return Result.OK(jsonObject);
}
/**
* 添加专题样例文章
*
* @param files 样例文章
* @return
*/
@PostMapping(value = "/addSampleFile")
public Result<?> addSampleFile(MultipartFile[] files, String subjectId) {
if (StringUtils.isBlank(subjectId)) {
return Result.FAIL("专题id不能为空");
}
boolean flag = true;
if (files != null && files.length > 0) {
for (MultipartFile file : files) {
String originalFilename = file.getOriginalFilename();
if (!(originalFilename.endsWith(".txt") || originalFilename.endsWith(".doc") || originalFilename.endsWith(".docx"))) {
flag = false;
break;
}
}
if (!flag) {
return Result.FAIL("包含不支持的文件类型");
}
List<SubjectSampleFile> sampleFiles = new ArrayList<>();
try {
for (MultipartFile file : files) {
InputStream inputStream = file.getInputStream();
PutObjectResult putObjectResult = obsUtil.uploadFile("subjectSampleFile", inputStream);
String filePath = putObjectResult.getObjectKey();
SubjectSampleFile subjectSampleFile = new SubjectSampleFile();
subjectSampleFile.setSubjectId(subjectId);
subjectSampleFile.setFileName(file.getOriginalFilename());
subjectSampleFile.setFilePath(filePath);
sampleFiles.add(subjectSampleFile);
}
} catch (IOException e) {
e.printStackTrace();
}
subjectSampleFileService.saveBatch(sampleFiles);
} else {
return Result.FAIL("请选择上传文件");
}
return Result.OK();
}
/**
* 添加
*
* @param subjectPage
......@@ -133,7 +224,7 @@ public class SubjectManageController {
Subject subject = subjectService.saveMain(subjectPage);
//插入xxlJob
xxlJobInfoService.subjectInsert(subject);
return Result.OK("添加成功!");
return Result.OK();
}
/**
......@@ -162,7 +253,7 @@ public class SubjectManageController {
kafkaTemplate.send("subjectModel", subjectPage.getSubjectCode());
}
});
return Result.OK("编辑成功!");
return Result.OK();
}
/**
......@@ -181,7 +272,7 @@ public class SubjectManageController {
Subject subject = subjectService.getOne(queryWrapper);
xxlJobInfoService.deleteByInfosourceCode(subject.getSubjectCode());
});
return Result.OK("删除成功!");
return Result.OK();
}
/**
......@@ -205,7 +296,7 @@ public class SubjectManageController {
xxlJobInfoService.deleteByInfosourceCode(subject.getSubjectCode());
}
});
return Result.OK("批量删除成功!");
return Result.OK();
}
/**
......@@ -494,7 +585,290 @@ public class SubjectManageController {
@PostMapping(value = "/sendPythonInfo")
public Result<?> sendPythonInfo(@RequestBody SubjectPage subjectPage) {
subjectService.send(subjectPage.getId(), null);
return Result.OK("编辑成功!");
return Result.OK();
}
/**
* 获取分类下的标签信息
*
* @param labelTypeId 标签分类id
* @author lkg
* @date 2025/1/2
*/
@GetMapping("/labelList")
public Result<?> labelList(@RequestParam(defaultValue = "1874739452451004417") String labelTypeId) {
List<InfoSourceLabelVO> labelList = clbLabelService.labelInfoByType(labelTypeId);
return Result.OK(labelList);
}
/**
* 绑定信息源标签数据
*
* @param subjectSourceTagVO 参数
* @author lkg
* @date 2025/1/3
*/
@PostMapping("/bindInfoSourceLabel")
public Result<?> bindInfoSourceLabel(@RequestBody SubjectSourceTagVO subjectSourceTagVO) {
if (StringUtils.isNotEmpty(subjectSourceTagVO.getSubjectId())) {
return Result.FAIL("专题id不能为空");
}
if (CollectionUtils.isEmpty(subjectSourceTagVO.getLabelCodes()) && CollectionUtils.isEmpty(subjectSourceTagVO.getLabelItemCodes())) {
return Result.FAIL("参数不全");
}
String subjectId = subjectSourceTagVO.getSubjectId();
List<String> sourceIds = CollectionUtils.isNotEmpty(subjectSourceTagVO.getLabelCodes()) ? subjectSourceTagVO.getLabelCodes() : subjectSourceTagVO.getLabelItemCodes();
List<SubjectInfoSourceMap> dataList = new ArrayList<>();
for (String sourceId : sourceIds) {
SubjectInfoSourceMap subjectInfoSourceMap = new SubjectInfoSourceMap();
subjectInfoSourceMap.setSubjectId(subjectId);
subjectInfoSourceMap.setSourceId(sourceId);
dataList.add(subjectInfoSourceMap);
}
subjectInfoSourceMapService.saveBatch(dataList);
return Result.OK();
}
/**
* 信息源分页列表(专题绑定定向信息源时使用)
*
* @param searchWord 搜索词
* @param pageNo 当前页
* @param pageSize 返回条数
* @author lkg
* @date 2025/1/4
*/
@GetMapping("/directInfoSourcePageList")
public Result<?> directSourcePageList(@RequestParam(required = false) String searchWord,
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize) {
IPage<String> page = infoSourceService.directSourcePageList(searchWord, pageNo, pageSize);
return Result.OK(page);
}
/**
* 信息源下栏目分页列表(专题绑定定向信息源时使用)
*
* @param webSiteName 信息源名称
* @param pageNo 当前页
* @param pageSize 返回条数
* @author lkg
* @date 2025/1/4
*/
@GetMapping("/directInfoSourceColumnPageList")
public Result<?> directSourceColumnPageList(String webSiteName,
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize) {
IPage<InfoSource> page = infoSourceService.directSourceColumnPageList(webSiteName, pageNo, pageSize);
return Result.OK(page);
}
/**
* 添加定向信息源(专题绑定定向信息源时使用)
*
* @param subjectSourceVO 参数
* @author lkg
* @date 2025/1/4
*/
@PostMapping("/bindDirectInfoSource")
public Result<?> bindDirectInfoSource(@RequestBody SubjectSourceVO subjectSourceVO) {
List<InfoSource> infoSources = infoSourceService.directSourceColumnList(subjectSourceVO.getWebSiteName());
if (CollectionUtils.isNotEmpty(infoSources)) {
List<SubjectInfoSourceMap> dataList = new ArrayList<>();
for (InfoSource source : infoSources) {
SubjectInfoSourceMap subjectInfoSourceMap = new SubjectInfoSourceMap();
subjectInfoSourceMap.setSubjectId(subjectSourceVO.getSubjectId());
subjectInfoSourceMap.setSourceId(source.getId());
subjectInfoSourceMap.setType(1);
dataList.add(subjectInfoSourceMap);
}
subjectInfoSourceMapService.saveBatch(dataList);
}
return Result.OK();
}
/**
* 新增信息源
*
* @param subjectInfoSourceMiddleMap 参数
* @author lkg
* @date 2025/1/4
*/
@PostMapping("/addInfoSource")
public Result<?> addInfoSource(@RequestBody SubjectInfoSourceMiddleMap subjectInfoSourceMiddleMap) {
//专题信息源关系数据
Set<SubjectInfoSourceMap> mapDataSet = new HashSet<>();
//待配置信息源新增列表
Set<SubjectInfoSourceMiddleMap> configDataSet = new HashSet<>();
String subjectId = subjectInfoSourceMiddleMap.getSubjectId();
String infoSourceName = subjectInfoSourceMiddleMap.getInfoSourceName();
String url = subjectInfoSourceMiddleMap.getUrl();
singleSupplyData(subjectId, infoSourceName, url, mapDataSet, configDataSet);
if (CollectionUtils.isNotEmpty(mapDataSet)) {
subjectInfoSourceMapService.saveBatch(mapDataSet);
}
if (CollectionUtils.isNotEmpty(configDataSet)) {
subjectInfoSourceMiddleMapService.saveBatch(configDataSet);
}
return Result.OK();
}
/**
* 信息源导入模板下载
*
* @author lkg
* @date 2024/06/21
*/
@GetMapping("/downloadInfoSourceTemplate")
public void downloadTemplate(HttpServletResponse response) {
String filePath = "infoSourceImport/导入模板.xlsx";
commonService.downloadTemplate(response, filePath);
}
/**
* 导入信息源
*
* @param file excel文件
* @param subjectId 专题id
* @author lkg
* @date 2025/1/4
*/
@PostMapping("/importDirectInfoSource")
public Result<?> importDirectInfoSource(MultipartFile file, String subjectId) throws Exception {
if (StringUtils.isBlank(subjectId)) {
return Result.FAIL("专题id不能为空");
}
if (file == null) {
return Result.FAIL("请选择上传文件");
}
String originalFilename = file.getOriginalFilename();
if (!(originalFilename.endsWith(".xlsx") || originalFilename.endsWith(".xls"))) {
List<List<String>> dataList = ExcelExportUtil.readExcel(file.getInputStream(), 1, 2);
if (CollectionUtils.isNotEmpty(dataList)) {
boolean emptyFlag = false;
for (List<String> strings : dataList) {
String name = strings.get(0);
String url = strings.get(1);
if (StringUtils.isEmpty(name) || StringUtils.isEmpty(url)) {
emptyFlag = true;
break;
}
}
if (emptyFlag) {
return Result.FAIL("存在信息源名称/信息源地址为空的数据,请核对后在导入!");
}
//专题信息源关系数据
Set<SubjectInfoSourceMap> mapDataSet = new HashSet<>();
//待配置信息源新增列表
Set<SubjectInfoSourceMiddleMap> configDataSet = new HashSet<>();
for (List<String> data : dataList) {
String webSiteName = data.get(0);
String siteUri = data.get(1);
singleSupplyData(subjectId, webSiteName, siteUri, mapDataSet, configDataSet);
}
if (CollectionUtils.isNotEmpty(mapDataSet)) {
subjectInfoSourceMapService.saveBatch(mapDataSet);
}
if (CollectionUtils.isNotEmpty(configDataSet)) {
subjectInfoSourceMiddleMapService.saveBatch(configDataSet);
}
} else {
return Result.FAIL("上传的文件没有内容");
}
} else {
return Result.FAIL("不支持的文件格式");
}
return Result.OK();
}
/**
* 单挑数据填充
*
* @param subjectId 专题id
* @param webSiteName 信息源名称
* @param siteUri 信息源地址
* @param mapDataSet 专题信息源关系数据
* @param configDataSet 待配置信息源数据
* @author lkg
* @date 2025/1/4
*/
private void singleSupplyData(String subjectId, String webSiteName, String siteUri, Set<SubjectInfoSourceMap> mapDataSet, Set<SubjectInfoSourceMiddleMap> configDataSet) {
String domain = Utility.domainURL(siteUri);
if (StringUtils.isNotEmpty(domain)) {
String replace = siteUri.replace("https://", "").replace("http://", "");
if (replace.equalsIgnoreCase(domain) || replace.equalsIgnoreCase(domain + "/")) {
List<InfoSource> infoSources = matchInfoSourceByUri(domain, 2);
supplyData(subjectId, webSiteName,siteUri, mapDataSet, configDataSet, infoSources);
} else {
List<InfoSource> infoSources = matchInfoSourceByUri(siteUri, 1);
supplyData(subjectId, webSiteName,siteUri, mapDataSet, configDataSet, infoSources);
}
} else {
List<InfoSource> infoSources = matchInfoSourceByUri(siteUri, 1);
supplyData(subjectId, webSiteName,siteUri, mapDataSet, configDataSet, infoSources);
}
}
/**
* 填充数据
*
* @param subjectId 专题id
* @param webSiteName 信息源名称
* @param siteUri 信息源地址
* @param mapDataSet 专题信息源关系数据
* @param configDataSet 待配置信息源数据
* @param infoSources 匹配到的信息源数据
* @author lkg
* @date 2025/1/4
*/
private void supplyData(String subjectId, String webSiteName, String siteUri, Set<SubjectInfoSourceMap> mapDataSet, Set<SubjectInfoSourceMiddleMap> configDataSet, List<InfoSource> infoSources) {
if (CollectionUtils.isNotEmpty(infoSources)) {
for (InfoSource source : infoSources) {
SubjectInfoSourceMap subjectInfoSourceMap = new SubjectInfoSourceMap();
subjectInfoSourceMap.setSubjectId(subjectId);
subjectInfoSourceMap.setSourceId(source.getId());
subjectInfoSourceMap.setType(1);
mapDataSet.add(subjectInfoSourceMap);
}
} else {
SubjectInfoSourceMiddleMap middleMap = new SubjectInfoSourceMiddleMap();
middleMap.setInfoSourceName(webSiteName);
middleMap.setUrl(siteUri);
middleMap.setSubjectId(subjectId);
configDataSet.add(middleMap);
}
}
/**
* 推荐信息源
*
* @param searchCondition 检索条件
* @author lkg
* @date 2024/12/26
*/
@PostMapping("/recommendSourceList")
public Result<?> recommendSourceList(@RequestBody EventDataCondition searchCondition) {
List<InfoSource> infoSources = new ArrayList<>();
String[] fetchFields = new String[]{"id", "sid"};
searchCondition.setFetchFields(fetchFields);
List<SearchWordVO> searchWordList = new ArrayList<>();
for (String words : searchCondition.getWordsList()) {
SearchWordVO searchWord = new SearchWordVO();
searchWord.setSearchAccuracy("精确");
searchWord.setSearchScope(1);
searchWord.setSearchLogicRelationship("OR");
searchWord.setSearchInfo(words);
searchWordList.add(searchWord);
}
searchCondition.setSearchWordList(searchWordList);
List<CountVO> countVOS = esService.groupBySourceId(searchCondition);
if (CollectionUtils.isNotEmpty(countVOS)) {
List<String> sourceIdList = new ArrayList<>();
infoSources = infoSourceService.listByIds(sourceIdList);
}
return Result.OK(infoSources);
}
......@@ -579,9 +953,9 @@ public class SubjectManageController {
* @date 2024/12/27
*/
@GetMapping("/keywordsCount")
public Result<?> keywordsCount(@RequestParam String subjectId,@RequestParam(defaultValue = "100") Integer size){
public Result<?> keywordsCount(@RequestParam String subjectId, @RequestParam(defaultValue = "100") Integer size) {
Set<String> excludeKeywords = commonService.getExcludeKeywords(subjectId);
List<CountVO> countVOS = esService.keywordsCount(subjectId, new ArrayList<>(excludeKeywords),size);
List<CountVO> countVOS = esService.keywordsCount(subjectId, new ArrayList<>(excludeKeywords), size);
return Result.OK(countVOS);
}
......@@ -594,4 +968,134 @@ public class SubjectManageController {
HttpUtil.doGet(extractHotWordsUrl, param, "utf-8");
}
}
private List<StatisticsKeyWordVo> extractWords(String words) {
List<StatisticsKeyWordVo> wordList = new ArrayList<>();
String[] fetchFields = new String[]{"title", "content"};
EventDataCondition searchCondition = new EventDataCondition();
searchCondition.setFetchFields(fetchFields);
List<SearchWordVO> searchWordList = new ArrayList<>();
SearchWordVO searchWord = new SearchWordVO();
searchWord.setSearchAccuracy("精确");
searchWord.setSearchScope(1);
searchWord.setSearchLogicRelationship("AND");
searchWord.setSearchInfo(words);
searchWordList.add(searchWord);
searchCondition.setSearchWordList(searchWordList);
try {
IPage<SpecialInformation> page = esService.pageListByCondtion(searchCondition, null);
if (page.getTotal() > 0) {
StringBuilder text = new StringBuilder();
List<SpecialInformation> records = page.getRecords();
for (SpecialInformation information : records) {
text.append(information.getTitle()).append(information.getContent());
}
List<Map.Entry<String, Integer>> extractKeyWordsByText = HanlpUtil.extractKeyWordsByText(text.toString(), 10);
if (CollectionUtils.isNotEmpty(extractKeyWordsByText)) {
for (Map.Entry<String, Integer> entry : extractKeyWordsByText) {
StatisticsKeyWordVo statisticsKeyWordVo = new StatisticsKeyWordVo();
statisticsKeyWordVo.setName(entry.getKey());
statisticsKeyWordVo.setValue(entry.getValue());
wordList.add(statisticsKeyWordVo);
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
return wordList;
}
/**
* 根据样例文章抽取热词
*
* @param files 样例文章
* @author lkg
* @date 2025/1/3
*/
private List<StatisticsKeyWordVo> articleWords(MultipartFile[] files) {
StringBuilder text = new StringBuilder();
for (MultipartFile file : files) {
String originalFilename = file.getOriginalFilename();
if (originalFilename.endsWith(".txt")) {
parseTxt(text, file);
} else {
parseWord(text, file);
}
}
List<StatisticsKeyWordVo> articleWordList = new ArrayList<>();
if (StringUtils.isNotEmpty(text)) {
List<Map.Entry<String, Integer>> keywordsList = HanlpUtil.extractKeyWordsByText(text.toString(), 10);
if (CollectionUtils.isNotEmpty(keywordsList)) {
for (Map.Entry<String, Integer> entry : keywordsList) {
StatisticsKeyWordVo statisticsKeyWordVo = new StatisticsKeyWordVo();
statisticsKeyWordVo.setName(entry.getKey());
statisticsKeyWordVo.setValue(entry.getValue());
articleWordList.add(statisticsKeyWordVo);
}
}
}
return articleWordList;
}
/**
* 解析word文档,获取纯文本内容
*
* @param text 内容
* @param file word文件
* @author lkg
* @date 2025/1/3
*/
private void parseWord(StringBuilder text, MultipartFile file) {
try {
InputStream inputStream = file.getInputStream();
XWPFDocument doc = new XWPFDocument(inputStream);
for (XWPFParagraph paragraph : doc.getParagraphs()) {
text.append(paragraph.getText());
}
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 解析txt文件,获取纯文本内容
*
* @param text 内容
* @param file word文件
* @author lkg
* @date 2025/1/3
*/
private void parseTxt(StringBuilder text, MultipartFile file) {
try {
InputStreamReader reader = new InputStreamReader(file.getInputStream(), "GBK");
BufferedReader buffReader = new BufferedReader(reader);
String strTmp;
while ((strTmp = buffReader.readLine()) != null) {
text.append(strTmp);
}
buffReader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 根据地址匹配信息源列表
*
* @param uri 地址/域名
* @param type 1-地址精确匹配;2-域名模糊匹配
* @author lkg
* @date 2025/1/4
*/
private List<InfoSource> matchInfoSourceByUri(String uri, Integer type) {
LambdaQueryWrapper<InfoSource> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.select(InfoSource::getId);
if (type == 1) {
queryWrapper.eq(InfoSource::getSiteUri, uri);
} else {
queryWrapper.like(InfoSource::getSiteUri, uri);
}
return infoSourceService.list(queryWrapper);
}
}
package com.zzsn.event.controller.common;
import cn.hutool.core.util.ObjectUtil;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.InfoSource;
import com.zzsn.event.entity.Subject;
import com.zzsn.event.entity.SysDictItem;
import com.zzsn.event.es.EsService;
import com.zzsn.event.service.ClbLabelService;
import com.zzsn.event.service.IInfoSourceService;
import com.zzsn.event.service.SubjectService;
import com.zzsn.event.service.SysDictItemService;
import com.zzsn.event.util.DateUtil;
import com.zzsn.event.vo.CountVO;
import com.zzsn.event.vo.EventDataCondition;
import com.zzsn.event.vo.OverviewAnalysisVO;
import com.zzsn.event.vo.*;
import com.zzsn.event.vo.es.Label;
import com.zzsn.event.vo.es.SpecialInformation;
import com.zzsn.event.entity.InfoSource;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -36,24 +40,53 @@ public class StatisticalAnalysisController {
private SubjectService subjectService;
@Autowired
private IInfoSourceService infoSourceService;
@Autowired
private SysDictItemService sysDictItemService;
@Autowired
private ClbLabelService clbLabelService;
/**
* 概述分析
*
* @param subjectId 专题id
* @param searchCondition 筛选条件
* @author lkg
* @date 2024/12/26
*/
@GetMapping("overview")
public Result<OverviewAnalysisVO> overviewAnalysis(@RequestParam String subjectId){
public Result<OverviewAnalysisVO> overviewAnalysis(@RequestBody EventDataCondition searchCondition) {
OverviewAnalysisVO overviewAnalysisVO = new OverviewAnalysisVO();
Subject subject = subjectService.getById(subjectId);
Subject subject = subjectService.getById(searchCondition.getSubjectId());
overviewAnalysisVO.setSubjectName(subject.getSubjectName());
overviewAnalysisVO.setTimeEnable(subject.getTimeEnable());
overviewAnalysisVO.setTimeDisable(subject.getTimeDisable());
int count = esService.count(subjectId, DateUtil.dateToString(subject.getTimeEnable()), DateUtil.dateToString(subject.getTimeDisable()));
overviewAnalysisVO.setInfoCount(count);
//todo 专题下绑定的信息源分类下的信息源数量
List<CountVO> countList = new ArrayList<>();
int totalCount;
List<Label> bindLabelList = bindLabelList(searchCondition.getSubjectId());
if (CollectionUtils.isEmpty(searchCondition.getIds()) && searchCondition.getNum() == null) {
List<String> includeValues = new ArrayList<>();
bindLabelList.forEach(e -> includeValues.add(e.getRelationId()));
searchCondition.setIncludeValues(includeValues.toArray(new String[0]));
countList = esService.overView(searchCondition);
totalCount = countList.get(0).getValue().intValue();
countList.remove(0);
} else {
Map<String, Label> labelMap = bindLabelList.stream().collect(Collectors.toMap(Label::getRelationId, label -> label));
String[] fetchFields = new String[]{"id", "sid", "labels"};
searchCondition.setFetchFields(fetchFields);
List<SpecialInformation> specialInformationList = esService.informationList(searchCondition);
totalCount = specialInformationList.size();
Map<String, List<SpecialInformation>> map = buildMap(specialInformationList, labelMap);
for (Map.Entry<String, List<SpecialInformation>> entry : map.entrySet()) {
CountVO countVO = new CountVO();
String key = entry.getKey();
countVO.setName(labelMap.get(key).getRelationName());
List<SpecialInformation> value = entry.getValue();
Map<String, List<SpecialInformation>> sidMap = value.stream().collect(Collectors.groupingBy(SpecialInformation::getSid));
countVO.setValue((long) sidMap.size());
}
}
overviewAnalysisVO.setInfoCount(totalCount);
overviewAnalysisVO.setCountList(countList);
return Result.OK(overviewAnalysisVO);
}
......@@ -67,8 +100,7 @@ public class StatisticalAnalysisController {
@PostMapping("/dataTrend")
public Result<List<CountVO>> dataTrend(@RequestBody EventDataCondition searchCondition) {
List<CountVO> dataList = new ArrayList<>();
List<String> ids = searchCondition.getIds();
if (CollectionUtils.isEmpty(ids)) {
if (CollectionUtils.isEmpty(searchCondition.getIds()) && searchCondition.getNum() == null) {
dataList = esService.groupByDate(searchCondition);
} else {
String[] fetchFields = new String[]{"id", "publishDate"};
......@@ -88,7 +120,7 @@ public class StatisticalAnalysisController {
if (format != null) {
String finalFormat = format;
Map<String, List<SpecialInformation>> dateMap = informationList.stream()
.collect(Collectors .groupingBy(item -> DateUtil.formatStr(item.getPublishDate(), "yyyy-MM-dd HH:mm:ss", finalFormat)));
.collect(Collectors.groupingBy(item -> DateUtil.formatStr(item.getPublishDate(), "yyyy-MM-dd HH:mm:ss", finalFormat)));
for (Map.Entry<String, List<SpecialInformation>> entry : dateMap.entrySet()) {
CountVO countVO = new CountVO();
countVO.setName(entry.getKey());
......@@ -110,23 +142,21 @@ public class StatisticalAnalysisController {
@PostMapping("/dataType/distribution")
public Result<?> dataTypeDistribution(@RequestBody EventDataCondition searchCondition) {
List<CountVO> dataList = new ArrayList<>();
List<String> ids = searchCondition.getIds();
if (CollectionUtils.isEmpty(ids)) {
if (CollectionUtils.isEmpty(searchCondition.getIds()) && searchCondition.getNum() == null) {
dataList = esService.groupByClassificationType(searchCondition);
} else {
String[] fetchFields = new String[]{"id", "classificationType"};
searchCondition.setFetchFields(fetchFields);
List<SpecialInformation> informationList = esService.informationList(searchCondition);
Map<Integer, List<SpecialInformation>> map = informationList.stream()
.collect(Collectors .groupingBy(SpecialInformation::getClassificationType));
.collect(Collectors.groupingBy(SpecialInformation::getClassificationType));
for (Map.Entry<Integer, List<SpecialInformation>> entry : map.entrySet()) {
CountVO countVO = new CountVO();
//todo 获取字典值
// countVO.setName(entry.getKey());
countVO.setValue((long) entry.getValue().size());
dataList.add(countVO);
}
}
changeKey(dataList, "Thematic_Library");
return Result.OK(dataList);
}
......@@ -138,39 +168,144 @@ public class StatisticalAnalysisController {
* @date 2024/12/26
*/
@PostMapping("/dataSource")
public Result<?> dataSource(@RequestBody EventDataCondition searchCondition){
//todo 实现
return Result.OK();
public Result<?> dataSource(@RequestBody EventDataCondition searchCondition) {
List<CountVO> dataList = new ArrayList<>();
List<Label> bindLabelList = bindLabelList(searchCondition.getSubjectId());
if (CollectionUtils.isEmpty(searchCondition.getIds()) && searchCondition.getNum() == null) {
List<String> includeValues = new ArrayList<>();
bindLabelList.forEach(e -> includeValues.add(e.getRelationId()));
searchCondition.setIncludeValues(includeValues.toArray(new String[0]));
dataList = esService.groupByInfoSourceTag(searchCondition);
} else {
Map<String, Label> labelMap = bindLabelList.stream().collect(Collectors.toMap(Label::getRelationId, label -> label));
String[] fetchFields = new String[]{"id", "labels"};
searchCondition.setFetchFields(fetchFields);
List<SpecialInformation> specialInformationList = esService.informationList(searchCondition);
Map<String, List<SpecialInformation>> map = buildMap(specialInformationList, labelMap);
for (Map.Entry<String, List<SpecialInformation>> entry : map.entrySet()) {
CountVO countVO = new CountVO();
String key = entry.getKey();
countVO.setName(labelMap.get(key).getRelationName());
countVO.setValue((long) entry.getValue().size());
}
}
return Result.OK(dataList);
}
/**
*资讯数量top的信息源统计
* 资讯数量top的信息源统计
*
* @param searchCondition 筛选条件
* @author lkg
* @date 2024/12/26
*/
@PostMapping("/infoSource/dataCount/top")
public Result<?> infoSourceDataCountTop(@RequestBody EventDataCondition searchCondition){
public Result<?> infoSourceDataCountTop(@RequestBody EventDataCondition searchCondition) {
List<CountVO> dataList = new ArrayList<>();
List<String> ids = searchCondition.getIds();
if (CollectionUtils.isEmpty(ids)) {
if (CollectionUtils.isEmpty(searchCondition.getIds()) && searchCondition.getNum() == null) {
dataList = esService.groupBySourceId(searchCondition);
} else {
String[] fetchFields = new String[]{"id", "sid"};
searchCondition.setFetchFields(fetchFields);
List<SpecialInformation> informationList = esService.informationList(searchCondition);
Map<String, List<SpecialInformation>> map = informationList.stream()
.collect(Collectors .groupingBy(SpecialInformation::getSid));
.collect(Collectors.groupingBy(SpecialInformation::getSid));
for (Map.Entry<String, List<SpecialInformation>> entry : map.entrySet()) {
CountVO countVO = new CountVO();
String sid = entry.getKey();
InfoSource infoSource = infoSourceService.getById(sid);
countVO.setName(infoSource.getSiteName());
countVO.setName(sid);
countVO.setValue((long) entry.getValue().size());
dataList.add(countVO);
}
}
if (CollectionUtils.isNotEmpty(dataList)) {
List<String> sidList = dataList.stream().map(CountVO::getName).collect(Collectors.toList());
List<InfoSource> infoSources = infoSourceService.listByIds(sidList);
Map<String, InfoSource> sourceMap = infoSources.stream().collect(Collectors.toMap(InfoSource::getId, infoSource -> infoSource));
for (CountVO countVO : dataList) {
String sid = countVO.getName();
InfoSource infoSource = sourceMap.get(sid);
countVO.setName(infoSource.getWebSiteName());
}
}
return Result.OK(dataList);
}
/**
* 改变key值(字典值码转为字典值)
*
* @param dataList 统计数据
* @param dictCode 字典编码
* @author lkg
* @date 2024/12/30
*/
private void changeKey(List<CountVO> dataList, String dictCode) {
if (CollectionUtils.isNotEmpty(dataList)) {
List<SysDictItem> dictItemList = sysDictItemService.listByDictCode("");
Map<String, List<SysDictItem>> map = dictItemList.stream().collect(Collectors.groupingBy(SysDictItem::getItemValue));
for (CountVO countVO : dataList) {
List<SysDictItem> sysDictItemList = map.get(countVO.getName());
if (CollectionUtils.isNotEmpty(sysDictItemList)) {
countVO.setName(sysDictItemList.get(0).getItemText());
}
}
}
}
/**
* 绑定的标签信息
*
* @param subjectId 专题id
* @author lkg
* @date 2024/12/30
*/
private List<Label> bindLabelList(String subjectId) {
List<Label> labels = new ArrayList<>();
List<InfoSourceLabelVO> infoSourceLabelInfos = clbLabelService.bindInfoSourceLabelInfo(subjectId);
if (ObjectUtil.isNotEmpty(infoSourceLabelInfos)) {
for (InfoSourceLabelVO infoSourceLabel : infoSourceLabelInfos) {
String labelCode = infoSourceLabel.getLabelCode();
List<InfoSourceLabelItemVO> infoSourceLabelItemList = infoSourceLabel.getInfoSourceLabelItemList();
for (InfoSourceLabelItemVO infoSourceLabelItem : infoSourceLabelItemList) {
Label label = new Label();
label.setRelationName(infoSourceLabelItem.getLabelItemName());
label.setRelationId(labelCode + "_" +infoSourceLabelItem.getLabelItemCode());
}
}
}
return labels;
}
/**
* 构建map,统计数量
*
* @param informationList 资讯信息列表
* @param labelMap 专题绑定的标签信息
* @author lkg
* @date 2025/1/2
*/
private Map<String, List<SpecialInformation>> buildMap(List<SpecialInformation> informationList, Map<String, Label> labelMap) {
Map<String, List<SpecialInformation>> map = new HashMap<>();
for (SpecialInformation information : informationList) {
List<Label> labels = information.getLabels();
String labelId = null;
for (Label label : labels) {
String labelRelationId = label.getRelationId();
Label bindLabel = labelMap.get(labelRelationId);
if (ObjectUtil.isNotEmpty(bindLabel)) {
labelId = labelRelationId;
break;
}
}
if (ObjectUtil.isNotEmpty(labelId)) {
List<SpecialInformation> list = map.get(labelId);
if (CollectionUtils.isEmpty(list)) {
list = new ArrayList<>();
map.put(labelId, list);
}
list.add(information);
}
}
return map;
}
}
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author obcy
* @since 2024-08-23
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("clb_label")
public class ClbLabel extends Model<ClbLabel> {
private static final long serialVersionUID = 1L;
/**
* 标签表id
*/
@TableId(value = "id", type = IdType.ASSIGN_ID)
private String id;
/**
* 创建人
*/
@TableField("create_by")
private String createBy;
/**
* 创建日期
*/
@TableField("create_time")
private Date createTime;
/**
* 更新人
*/
@TableField("update_by")
private String updateBy;
/**
* 更新日期
*/
@TableField("update_time")
private Date updateTime;
/**
* 实体id
*/
@TableField("entity_object_id")
private String entityObjectId;
/**
* 所属类目id
*/
@TableField("label_type_id")
private String labelTypeId;
/**
* 标签类别(字典维护)
*/
@TableField("label_category")
private String labelCategory;
/**
* 标签名称
*/
@TableField("label_name")
private String labelName;
/**
* 是否互斥(1互斥(默认),0不互斥)
*/
@TableField("is_mutual_exclusion")
private String isMutualExclusion;
/**
* 标签描述
*/
@TableField("label_desc")
private String labelDesc;
/**
* 标签状态(1开启,0关闭)
*/
@TableField("label_status")
private Integer labelStatus;
/**
* 标签编码
*/
@TableField("label_code")
private String labelCode;
/**
* 数据字典编码
*/
@TableField("dict_code")
private String dictCode;
/**
* 业务口径(1自定义,2实体表引用,3字典引用)
*/
@TableField("business_caliber")
private Integer businessCaliber;
/**
* 标签对应的任务id
*/
@TableField(exist = false)
private String taskId;
/**
* 任务计划描述
*/
@TableField(exist = false)
private String planDescription;
@Override
protected Serializable pkVal() {
return this.id;
}
}
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author obcy
* @since 2024-08-23
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("clb_label_item")
public class ClbLabelItem extends Model<ClbLabelItem> {
private static final long serialVersionUID = 1L;
/**
* 标签值id
*/
@TableId(value = "id", type = IdType.ASSIGN_ID)
private String id;
/**
* 创建人
*/
@TableField("create_by")
private String createBy;
/**
* 创建日期
*/
@TableField("create_time")
private Date createTime;
/**
* 更新人
*/
@TableField("update_by")
private String updateBy;
/**
* 更新日期
*/
@TableField("update_time")
private Date updateTime;
/**
* 所属标签id
*/
@TableField("label_id")
private String labelId;
/**
* 标签值编码
*/
@TableField("label_item_code")
private String labelItemCode;
/**
* 标签值名称
*/
@TableField("label_item_name")
private String labelItemName;
/**
* 节点绝对路径
*/
@TableField("path_ids")
private String pathIds;
@Override
protected Serializable pkVal() {
return this.id;
}
}
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
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;
/**
* @Description: 专题-信息源绑定中间表
* @Author: jeecg-boot
* @Date: 2021-12-09
* @Version: V1.0
*/
@Data
@TableName("subject_info_source_middle_map")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class SubjectInfoSourceMiddleMap implements Serializable {
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**专题id*/
@TableField("subject_id")
private String subjectId;
/**信息源id或信息源组id*/
@TableField("info_source_name")
private String infoSourceName;
/**网址*/
@TableField("url")
private String url;
/**创建时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@TableField("create_time")
private Date createTime;
/**创建人*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@TableField("create_by")
private Date createBy;
}
package com.zzsn.event.entity;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
/**
* @Description: 专题样例文章表
* @Author: jeecg-boot
* @Date: 2025-01-03
* @Version: V1.0
*/
@Data
@TableName("subject_sample_file")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="subject_sample_file对象", description="专题样例文章表")
public class SubjectSampleFile {
/**主键id*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键id")
private String id;
/**专题id*/
@Excel(name = "专题id", width = 15)
@ApiModelProperty(value = "专题id")
private String subjectId;
/**文件名称*/
@Excel(name = "文件名称", width = 15)
@ApiModelProperty(value = "文件名称")
private String fileName;
/**文件路径*/
@Excel(name = "文件路径", width = 15)
@ApiModelProperty(value = "文件路径")
private String filePath;
/**创建人*/
@Excel(name = "创建人", width = 15)
@ApiModelProperty(value = "创建人")
private String createBy;
/**创建时间*/
@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private Date createTime;
}
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @Author zhangweijian
* @since 2018-12-28
*/
@Data
@TableName("sys_dict_item")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class SysDictItem implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**
* 字典id
*/
private String dictId;
/**
* 字典项文本
*/
@Excel(name = "字典项文本", width = 20)
private String itemText;
/**
* 字典项值
*/
@Excel(name = "字典项值", width = 30)
private String itemValue;
/**
* 描述
*/
@Excel(name = "描述", width = 40)
private String description;
/**
* 排序
*/
@Excel(name = "排序", width = 15,type=4)
private Integer sortOrder;
/**
* 状态(1启用 0不启用)
*/
private Integer status;
private String createBy;
private Date createTime;
private String updateBy;
private Date updateTime;
/**
* 字典id
*/
private String pid;
/**
* 字典id
*/
private String hasChild;
/**
* 字典id
*/
private String pathIds;
/**
* 字典id
*/
private String dictItemCode;
/**
* 层级
*/
private Integer level;
}
package com.zzsn.event.es;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.entity.CollectionMap;
import com.zzsn.event.service.*;
import com.zzsn.event.util.DateUtil;
import com.zzsn.event.util.EsDateUtil;
......@@ -43,6 +39,7 @@ import org.elasticsearch.search.aggregations.bucket.nested.ParsedNested;
import org.elasticsearch.search.aggregations.bucket.terms.IncludeExclude;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.Cardinality;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.collapse.CollapseBuilder;
import org.elasticsearch.search.sort.SortBuilders;
......@@ -81,10 +78,6 @@ public class EsService {
private LabelEntityService labelEntityService;
@Autowired
private ISubjectKeywordsMapService subjectKeywordsMapService;
@Autowired
private ICollectionMapService collectionMapService;
@Autowired
private CommonService commonService;
/**
......@@ -716,12 +709,11 @@ public class EsService {
/**
* 事件对应专题库的资讯分页列表
*
* @param userId
* @param searchCondition
* @param searchCondition 检索条件
* @author lkg
* @date 2024/5/6
*/
public IPage<DisplayInfo> subjectPageList(String userId, EventDataCondition searchCondition) throws IOException {
public IPage<SpecialInformation> pageListByCondtion(EventDataCondition searchCondition,List<String> subjectIdList) throws IOException {
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//设置分页参数
......@@ -735,6 +727,7 @@ public class EsService {
switch (column) {
case "topNum":
searchSourceBuilder.sort("topNum", SortOrder.DESC);
searchSourceBuilder.sort("publishDate", SortOrder.DESC);
break;
case "score":
if (order.equals("asc")) {
......@@ -754,54 +747,25 @@ public class EsService {
searchSourceBuilder.sort("score", SortOrder.ASC);
}
break;
default:
searchSourceBuilder.sort("publishDate", SortOrder.DESC);
break;
}
//默认最大数量是10000,设置为true后,显示准确数量
searchSourceBuilder.trackTotalHits(true);
List<String> subjectIdList = new ArrayList<>();
//判断是否是专题
if ("1".equals(searchCondition.getIsSubject())) {
if (StringUtils.isNotEmpty(searchCondition.getSubjectId())) {
subjectIdList.add(searchCondition.getSubjectId());
}
} else {
//该id其实是专题类别id
//查询类别id的所有明细id
String subjectTypeId = searchCondition.getSubjectId();
Integer category = searchCondition.getCategory();
List<String> typeIds = subjectTypeService.belowIdList(subjectTypeId, category);
if (category == 1) {
subjectIdList = subjectTypeMapService.selectSubjectByTypeIds(typeIds);
} else if (category == 2) {
subjectIdList = subjectTypeMapService.selectEventByTypeIds(typeIds);
}
}
BoolQueryBuilder boolQuery = buildQuery(searchCondition, subjectIdList);
searchSourceBuilder.query(boolQuery);
searchRequest.source(searchSourceBuilder);
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
SearchHit[] searchHits = searchResponse.getHits().getHits();
List<DisplayInfo> list = new ArrayList<>();
List<LabelModelVo> labelModelVos = commonService.subjectModelBindLabels(subjectIdList);
Map<String, List<LabelModelVo>> modelMap = labelModelVos.stream().collect(Collectors.groupingBy(LabelModelVo::getSubjectId));
List<SpecialInformation> list = new ArrayList<>();
for (SearchHit hit : searchHits) {
String queryInfo = hit.getSourceAsString();
DisplayInfo info = JSONUtil.toBean(queryInfo, DisplayInfo.class);
info.setPublishDate(EsDateUtil.esFieldDateMapping(info.getPublishDate()));
QueryWrapper<CollectionMap> query = Wrappers.query();
query.eq("user_id", userId);
query.eq("article_id", info.getId());
int count = collectionMapService.count(query);
if (count > 0) {
info.setYnCollect(true);
}
//标签处理
List<LabelModelVo> modelVoList = modelMap.get(info.getSubjectId());
formatLabel(modelVoList, info);
String index = hit.getIndex();
info.setIndex(index);
SpecialInformation info = JSONUtil.toBean(queryInfo, SpecialInformation.class);
info.setIndex(hit.getIndex());
list.add(info);
}
IPage<DisplayInfo> pageData = new Page<>(pageNo, pageSize, searchResponse.getHits().getTotalHits().value);
IPage<SpecialInformation> pageData = new Page<>(pageNo, pageSize, searchResponse.getHits().getTotalHits().value);
pageData.setRecords(list);
return pageData;
}
......@@ -1433,6 +1397,61 @@ public class EsService {
}
/**
* 概述分析,信息源统计
*
* @param searchCondition 筛选条件
* @author lkg
* @date 2024/12/30
*/
public List<CountVO> overView(EventDataCondition searchCondition) {
List<CountVO> list = new ArrayList<>();
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.trackTotalHits(true);
searchSourceBuilder.size(0);
//构建查询语句
List<String> subjectIds = new ArrayList<>();
subjectIds.add(searchCondition.getSubjectId());
BoolQueryBuilder boolQuery = buildQuery(searchCondition, subjectIds);
searchSourceBuilder.query(boolQuery);
NestedAggregationBuilder nestedAggregationBuilder = AggregationBuilders.nested("labels", "labels")
.subAggregation(AggregationBuilders.terms("groupTag")
.field("labels.relationId")
.size(10)
.includeExclude(new IncludeExclude(searchCondition.getIncludeValues(), searchCondition.getExcludeValues()))
.subAggregation(AggregationBuilders.cardinality("sidCount").field("sid.keyword")));
searchSourceBuilder.aggregation(nestedAggregationBuilder);
searchRequest.source(searchSourceBuilder);
long totalCount = 0;
try {
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
totalCount = searchResponse.getHits().getTotalHits().value;
Aggregations aggregations = searchResponse.getAggregations();
ParsedNested labels = aggregations.get("labels");
Aggregations labelsAggregations = labels.getAggregations();
Terms groupTag = labelsAggregations.get("groupTag");
List<? extends Terms.Bucket> buckets = groupTag.getBuckets();
for (Terms.Bucket bucket : buckets) {
CountVO countVO = new CountVO();
String key = bucket.getKeyAsString();
countVO.setName(key);
Aggregations natureAggregations = bucket.getAggregations();
Cardinality sidCount = natureAggregations.get("sidCount");
long value = sidCount.getValue();
countVO.setValue(value);
list.add(countVO);
}
} catch (Exception e) {
e.printStackTrace();
}
CountVO countVO = new CountVO();
countVO.setName("total");
countVO.setValue(totalCount);
list.add(0, countVO);
return list;
}
/**
* 按日期分组统计
*
* @param searchCondition 筛选条件
......@@ -1497,9 +1516,7 @@ public class EsService {
* @date 2024/12/26
*/
public List<CountVO> groupByClassificationType(EventDataCondition searchCondition) {
List<CountVO> list = groupByTerm(searchCondition,"group","classificationType",null,false);
//todo 资讯类型字典值
return list;
return groupByTerm(searchCondition, "group", "classificationType",false);
}
/**
......@@ -1510,8 +1527,52 @@ public class EsService {
* @date 2024/12/26
*/
public List<CountVO> groupBySourceId(EventDataCondition searchCondition) {
List<CountVO> list = groupByTerm(searchCondition, "groupSid", "sid.keyword", 10, false);
//todo 资讯类型字典值 转换name
return groupByTerm(searchCondition, "groupSid", "sid.keyword", false);
}
/**
* 按信息源标签分组统计
*
* @param searchCondition 筛选条件
* @author lkg
* @date 2024/12/26
*/
public List<CountVO> groupByInfoSourceTag(EventDataCondition searchCondition) {
List<CountVO> list = new ArrayList<>();
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.trackTotalHits(true);
searchSourceBuilder.size(0);
//构建查询语句
List<String> subjectIds = new ArrayList<>();
subjectIds.add(searchCondition.getSubjectId());
BoolQueryBuilder boolQuery = buildQuery(searchCondition, subjectIds);
searchSourceBuilder.query(boolQuery);
NestedAggregationBuilder nestedAggregationBuilder = AggregationBuilders.nested("labels", "labels")
.subAggregation(AggregationBuilders.terms("groupTag")
.field("labels.relationId")
.size(10)
.includeExclude(new IncludeExclude(searchCondition.getIncludeValues(), searchCondition.getExcludeValues())));
searchSourceBuilder.aggregation(nestedAggregationBuilder);
searchRequest.source(searchSourceBuilder);
try {
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
Aggregations aggregations = searchResponse.getAggregations();
ParsedNested labels = aggregations.get("labels");
Aggregations labelsAggregations = labels.getAggregations();
Terms groupTag = labelsAggregations.get("groupTag");
List<? extends Terms.Bucket> buckets = groupTag.getBuckets();
for (Terms.Bucket bucket : buckets) {
CountVO countVO = new CountVO();
String key = bucket.getKeyAsString();
countVO.setName(key);
long value = bucket.getDocCount();
countVO.setValue(value);
list.add(countVO);
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
......@@ -1522,7 +1583,7 @@ public class EsService {
* @param size
* @return
*/
public List<CountVO> keywordsCount(String subjectId,List<String> excludeKeywords,Integer size){
public List<CountVO> keywordsCount(String subjectId, List<String> excludeKeywords, Integer size) {
List<CountVO> list = new ArrayList<>();
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
......@@ -1537,7 +1598,7 @@ public class EsService {
.field("keyWordsList.keyword")
.size(size)
.order(BucketOrder.count(false));
aggregationBuilder.includeExclude((new IncludeExclude(null,String.join(",",excludeKeywords).split(","))));
aggregationBuilder.includeExclude((new IncludeExclude(null, String.join(",", excludeKeywords).split(","))));
searchSourceBuilder.aggregation(aggregationBuilder);
searchRequest.source(searchSourceBuilder);
try {
......@@ -1565,12 +1626,11 @@ public class EsService {
* @param searchCondition 筛选条件
* @param groupName 分组名称
* @param field 分组字段
* @param size 返回个数
* @param sort 排序方式 true正序;false倒序
* @author lkg
* @date 2024/12/27
*/
private List<CountVO> groupByTerm(EventDataCondition searchCondition, String groupName, String field, Integer size, boolean sort) {
private List<CountVO> groupByTerm(EventDataCondition searchCondition, String groupName, String field, boolean sort) {
List<CountVO> list = new ArrayList<>();
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
......@@ -1583,6 +1643,7 @@ public class EsService {
searchSourceBuilder.query(boolQuery);
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(groupName);
aggregationBuilder.field(field);
Integer size = searchCondition.getPageSize();
if (size != null) {
aggregationBuilder.size(size);
}
......@@ -1595,7 +1656,6 @@ public class EsService {
Terms groupSource = aggregations.get(groupName);
List<? extends Terms.Bucket> buckets = groupSource.getBuckets();
for (Terms.Bucket bucket : buckets) {
String key = bucket.getKeyAsString();
long count = bucket.getDocCount();
CountVO countVO = new CountVO();
......@@ -1744,35 +1804,6 @@ public class EsService {
return data;
}
private void formatLabel(List<LabelModelVo> labelModelVos, DisplayInfo info) {
if (CollectionUtils.isNotEmpty(labelModelVos)) {
List<Label> list = info.getLabels();
List<LabelInfo> labelInfos = new ArrayList<>();
//获取专题打的标签
for (LabelModelVo labelModelVo : labelModelVos) {
LabelInfo labelInfo = new LabelInfo();
labelInfo.setLabelId(labelModelVo.getLabelId());
labelInfo.setLabelName(labelModelVo.getLabelName());
labelInfo.setLabelType(labelModelVo.getLabelType());
labelInfo.setLabelMark(labelModelVo.getLabelMark());
List<Label> labelList = new ArrayList<>();
if (list != null && !list.isEmpty()) {
for (Label label : list) {
if (StringUtils.isNotBlank(label.getLabelMark()) &&
(label.getLabelMark().contains(labelModelVo.getLabelMark()) || ("company_label".equals(labelModelVo.getLabelType()) && "company_label".equals(label.getLabelRemarks())))) {
labelList.add(label);
}
}
}
labelInfo.setLabelList(labelList);
labelInfos.add(labelInfo);
}
info.setLabelInfos(labelInfos);
}
}
//格式化数据
private List<SubjectDataVo> formatData(SearchHits searchHits) {
List<SubjectDataVo> list = new ArrayList<>();
......@@ -1877,25 +1908,38 @@ public class EsService {
Integer searchScope = ask.getSearchScope();
String searchAccuracy = ask.getSearchAccuracy();
if (searchScope == 1) {
if ("精确".equals(searchAccuracy)) {
boolQuery.must(QueryBuilders.matchPhraseQuery("title", searchInfo));
} else if ("模糊".equals(searchAccuracy)) {
boolQuery.must(QueryBuilders.matchQuery("title", searchInfo));
}
buildSplitWordMustQuery(boolQuery, searchInfo, "title", searchAccuracy);
} else if (searchScope == 2) {
if ("精确".equals(searchAccuracy)) {
MultiMatchQueryBuilder multiMatchQuery = QueryBuilders.multiMatchQuery(searchInfo, "title", "content");
multiMatchQuery.type(MultiMatchQueryBuilder.Type.PHRASE);
boolQuery.must(multiMatchQuery);
if (searchInfo.contains("|")) {
BoolQueryBuilder splitWordQuery = QueryBuilders.boolQuery();
for (String word : searchInfo.split("\\|")) {
MultiMatchQueryBuilder multiMatchQuery = QueryBuilders.multiMatchQuery(word, "title", "content");
multiMatchQuery.type(MultiMatchQueryBuilder.Type.PHRASE);
splitWordQuery.should(multiMatchQuery);
}
boolQuery.must(splitWordQuery);
} else {
MultiMatchQueryBuilder multiMatchQuery = QueryBuilders.multiMatchQuery(searchInfo, "title", "content");
multiMatchQuery.type(MultiMatchQueryBuilder.Type.PHRASE);
boolQuery.must(multiMatchQuery);
}
} else if ("模糊".equals(searchAccuracy)) {
boolQuery.must(QueryBuilders.multiMatchQuery(searchInfo, "title", "content"));
if (searchInfo.contains("|")) {
BoolQueryBuilder splitWordQuery = QueryBuilders.boolQuery();
for (String word : searchInfo.split("\\|")) {
MultiMatchQueryBuilder multiMatchQuery = QueryBuilders.multiMatchQuery(word, "title", "content");
splitWordQuery.should(multiMatchQuery);
}
boolQuery.must(splitWordQuery);
} else {
boolQuery.must(QueryBuilders.multiMatchQuery(searchInfo, "title", "content"));
}
}
} else if (searchScope == 3) {
if ("精确".equals(searchAccuracy)) {
boolQuery.must(QueryBuilders.matchPhraseQuery("origin", searchInfo));
} else if ("模糊".equals(searchAccuracy)) {
boolQuery.must(QueryBuilders.matchQuery("origin", searchInfo));
}
buildSplitWordMustQuery(boolQuery, searchInfo, "origin", searchAccuracy);
} else if (searchScope == 4) {
buildSplitWordMustQuery(boolQuery, searchInfo, "content", searchAccuracy);
}
}
if (type == 1) {
......@@ -1922,29 +1966,80 @@ public class EsService {
Integer searchScope = ask.getSearchScope();
String searchAccuracy = ask.getSearchAccuracy();
if (searchScope == 1) {
if ("精确".equals(searchAccuracy)) {
boolQuery.should(QueryBuilders.matchPhraseQuery("title", searchInfo));
} else if ("模糊".equals(searchAccuracy)) {
boolQuery.should(QueryBuilders.matchQuery("title", searchInfo));
}
buildSplitWordShouldQuery(boolQuery, searchInfo, "title", searchAccuracy);
} else if (searchScope == 2) {
if ("精确".equals(searchAccuracy)) {
MultiMatchQueryBuilder multiMatchQuery = QueryBuilders.multiMatchQuery(searchInfo, "title", "content");
multiMatchQuery.type(MultiMatchQueryBuilder.Type.PHRASE);
boolQuery.should(multiMatchQuery);
if (searchInfo.contains("|")) {
for (String word : searchInfo.split("\\|")) {
MultiMatchQueryBuilder multiMatchQuery = QueryBuilders.multiMatchQuery(word, "title", "content");
multiMatchQuery.type(MultiMatchQueryBuilder.Type.PHRASE);
boolQuery.should(multiMatchQuery);
}
} else {
MultiMatchQueryBuilder multiMatchQuery = QueryBuilders.multiMatchQuery(searchInfo, "title", "content");
multiMatchQuery.type(MultiMatchQueryBuilder.Type.PHRASE);
boolQuery.should(multiMatchQuery);
}
} else if ("模糊".equals(searchAccuracy)) {
boolQuery.should(QueryBuilders.multiMatchQuery(searchInfo, "title", "content"));
if (searchInfo.contains("|")) {
for (String word : searchInfo.split("\\|")) {
boolQuery.should(QueryBuilders.multiMatchQuery(word, "title", "content"));
}
} else {
boolQuery.should(QueryBuilders.multiMatchQuery(searchInfo, "title", "content"));
}
}
} else if (searchScope == 3) {
if ("精确".equals(searchAccuracy)) {
boolQuery.should(QueryBuilders.matchPhraseQuery("origin", searchInfo));
} else if ("模糊".equals(searchAccuracy)) {
boolQuery.should(QueryBuilders.matchQuery("origin", searchInfo));
}
buildSplitWordShouldQuery(boolQuery, searchInfo, "origin", searchAccuracy);
} else if (searchScope == 4) {
buildSplitWordShouldQuery(boolQuery, searchInfo, "content", searchAccuracy);
}
}
allBoolQuery.should(boolQuery);
}
}
private void buildSplitWordMustQuery(BoolQueryBuilder boolQuery, String searchInfo, String fieldName, String searchAccuracy) {
if ("精确".equals(searchAccuracy)) {
if (searchInfo.contains("|")) {
BoolQueryBuilder splitWordQuery = QueryBuilders.boolQuery();
for (String word : searchInfo.split("\\|")) {
splitWordQuery.should(QueryBuilders.matchPhraseQuery(fieldName, word));
}
boolQuery.must(splitWordQuery);
} else {
boolQuery.must(QueryBuilders.matchPhraseQuery(fieldName, searchInfo));
}
} else if ("模糊".equals(searchAccuracy)) {
if (searchInfo.contains("|")) {
BoolQueryBuilder splitWordQuery = QueryBuilders.boolQuery();
for (String word : searchInfo.split("\\|")) {
splitWordQuery.should(QueryBuilders.matchQuery(fieldName, word));
}
boolQuery.must(splitWordQuery);
} else {
boolQuery.must(QueryBuilders.matchQuery(fieldName, searchInfo));
}
}
}
private void buildSplitWordShouldQuery(BoolQueryBuilder boolQuery, String searchInfo, String fieldName, String searchAccuracy) {
if ("精确".equals(searchAccuracy)) {
if (searchInfo.contains("|")) {
for (String word : searchInfo.split("\\|")) {
boolQuery.should(QueryBuilders.matchPhraseQuery(fieldName, word));
}
} else {
boolQuery.must(QueryBuilders.matchPhraseQuery(fieldName, searchInfo));
}
} else if ("模糊".equals(searchAccuracy)) {
if (searchInfo.contains("|")) {
for (String word : searchInfo.split("\\|")) {
boolQuery.should(QueryBuilders.matchQuery(fieldName, word));
}
} else {
boolQuery.must(QueryBuilders.matchQuery(fieldName, searchInfo));
}
}
}
}
package com.zzsn.event.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.entity.ClbLabelItem;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author obcy
* @since 2024-08-23
*/
@Mapper
public interface ClbLabelItemMapper extends BaseMapper<ClbLabelItem> {
}
package com.zzsn.event.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.entity.ClbLabel;
import com.zzsn.event.vo.InfoSourceLabelVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author obcy
* @since 2024-08-23
*/
@Mapper
public interface ClbLabelMapper extends BaseMapper<ClbLabel> {
/**
* 专题绑定的信息源标签信息
*
* @param subjectId 专题id
* @author lkg
* @date 2025/1/2
*/
List<InfoSourceLabelVO> bindInfoSourceLabelInfo(@Param("subjectId") String subjectId);
/**
* 获取分类下的标签信息
*
* @param labelTypeId 标签分类id
* @author lkg
* @date 2025/1/2
*/
List<InfoSourceLabelVO> labelInfoByType(@Param("labelTypeId") String labelTypeId);
}
......@@ -62,7 +62,7 @@ public interface CommonMapper {
* @author lkg
* @date 2024/4/24
*/
List<SubjectInfoSourceLabelTypeVo> bindSourceList(@Param("subjectIds") List<String> subjectId);
List<SubjectSourceVO> bindSourceList(@Param("subjectIds") List<String> subjectId);
/**
* 专题/事件绑定的信息源集合
......@@ -71,7 +71,7 @@ public interface CommonMapper {
* @author lkg
* @date 2024/4/24
*/
List<SubjectInfoSourceLabelTypeVo> excludeSourceList(@Param("subjectIds") List<String> subjectId);
List<SubjectSourceVO> excludeSourceList(@Param("subjectIds") List<String> subjectId);
/**
* 模型列表
......
......@@ -236,33 +236,6 @@ public interface EventMapper extends BaseMapper<Event> {
*/
List<EventVO> eventList(@Param("eventIdList") List<String> eventIdList);
/**
* 专题绑定关键词数量
*
* @param idList 专题id集合
* @author lkg
* @date 2024/4/28
*/
List<SubjectPage> bindKeywordCountList(@Param("idList") List<String> idList);
/**
* 专题绑定的信息源集合
*
* @param subjectIds 专题id
* @author lkg
* @date 2024/4/24
*/
List<SubjectSourceVO> bindSourceList(@Param("subjectIds") List<String> subjectIds);
/**
* 专题绑定的信息源集合
*
* @param subjectIds 专题id
* @author lkg
* @date 2024/4/24
*/
List<SubjectSourceVO> excludeSourceList(@Param("subjectIds") List<String> subjectIds);
/**
* 专题绑定关键词的id集合
......
......@@ -68,4 +68,33 @@ public interface InfoSourceMapper extends BaseMapper<InfoSource> {
* @date 2024/4/30
*/
Page<InfoSourceVo> unBindSourcePageList(@Param("infoSourceVo") InfoSourceCondition infoSourceCondition, Page<InfoSourceVo> page);
/**
* 信息源分页列表(专题绑定定向信息源时使用)
*
* @param searchWord 搜索词
* @param page 分页参数
* @author lkg
* @date 2025/1/4
*/
Page<String> directSourceList(@Param("searchWord") String searchWord, Page<String> page);
/**
* 信息源下栏目分页列表(专题绑定定向信息源时使用)
*
* @param webSiteName 信息源名称
* @param page 分页参数
* @author lkg
* @date 2025/1/4
*/
Page<InfoSource> directSourceColumnList(@Param("webSiteName") String webSiteName, Page<InfoSource> page);
/**
* 信息源下栏目列表(专题绑定定向信息源时使用)
*
* @param webSiteName 信息源名称
* @author lkg
* @date 2025/1/4
*/
List<InfoSource> directSourceColumnList(@Param("webSiteName") String webSiteName);
}
package com.zzsn.event.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.entity.SubjectInfoSourceMiddleMap;
import org.apache.ibatis.annotations.Mapper;
/**
* 专题-信息源绑定中间表
*
* @author lkg
* @date 2025/1/2
*/
@Mapper
public interface SubjectInfoSourceMiddleMapMapper extends BaseMapper<SubjectInfoSourceMiddleMap> {
}
......@@ -8,8 +8,6 @@ import com.zzsn.event.vo.SubjectPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Description: 专题表
* @Author: jeecg-boot
......
package com.zzsn.event.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.entity.SubjectSampleFile;
import org.apache.ibatis.annotations.Mapper;
/**
* @Description: 专题样例文章表
* @Author: jeecg-boot
* @Date: 2025-01-03
* @Version: V1.0
*/
@Mapper
public interface SubjectSampleFileMapper extends BaseMapper<SubjectSampleFile> {
}
package com.zzsn.event.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.entity.SysDictItem;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @Author zhangweijian
* @since 2018-12-28
*/
@Mapper
public interface SysDictItemMapper extends BaseMapper<SysDictItem> {
List<SysDictItem> listByDictCode(@Param("dictCode") String dictCode);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zzsn.event.mapper.ClbLabelMapper">
<resultMap id="labelMap" type="com.zzsn.event.vo.InfoSourceLabelVO">
<result column="label_code" property="labelCode"/>
<result column="label_name" property="labelName"/>
<collection property="infoSourceLabelItemList" ofType="com.zzsn.event.vo.InfoSourceLabelItemVO">
<result column="label_item_code" property="labelItemCode"/>
<result column="label_item_name" property="labelItemName"/>
</collection>
</resultMap>
<select id="bindInfoSourceLabelInfo" resultMap="labelMap">
select label.label_code, label.label_name, item.label_item_code, item.label_item_name
from subject_info_source_map m on s.id = m.subject_id
left join clb_label label
on m.source_id = label.label_code
left join clb_label_item item on label.id = item.label_id
where m.subject_id = #{subjectId} and m.type = 6
union
select label.label_code, label.label_name, item.label_item_code, item.label_item_name
from subject_info_source_map m on s.id = m.subject_id
left join clb_label_item item
on m.source_id = item.label_item_code
left join clb_label label on item.label_id = label.id
where m.subject_id = #{subjectId} and m.type = 7
</select>
<select id="labelInfoByType" resultMap="labelMap">
select label.label_code, label.label_name, item.label_item_code, item.label_item_name
from clb_label label
left join clb_label_item item on label.id = item.label_id
where label.label_type_id = #{labelTypeId}
order by label.create_time
</select>
</mapper>
\ No newline at end of file
......@@ -60,7 +60,7 @@
group By subject_id
</select>
<select id="bindSourceList" resultType="com.zzsn.event.vo.SubjectInfoSourceLabelTypeVo">
<select id="bindSourceList" resultType="com.zzsn.event.vo.SubjectSourceVO">
select distinct x.source_id,x.subject_id from (
select m.source_id,n.subject_id from subject_info_source_map n
inner join info_source_group_map m on n.source_id = m.group_id
......@@ -82,7 +82,7 @@
) x
</select>
<select id="excludeSourceList" resultType="com.zzsn.event.vo.SubjectInfoSourceLabelTypeVo">
<select id="excludeSourceList" resultType="com.zzsn.event.vo.SubjectSourceVO">
select distinct x.source_id,x.subject_id from (
select m.source_id,n.subject_id from subject_info_source_map n
inner join info_source_group_map m on n.source_id = m.group_id
......
......@@ -493,58 +493,6 @@
</if>
</select>
<select id="bindKeywordCountList" resultType="com.zzsn.event.vo.SubjectPage">
select subject_id as id , count(1) keyWordsNum from subject_keywords_map where subject_id in
<foreach collection="idList" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
group By subject_id
</select>
<select id="bindSourceList" resultType="com.zzsn.event.vo.SubjectSourceVO">
select distinct x.source_id,x.subject_id from (
select m.source_id,n.subject_id from subject_info_source_map n
inner join info_source_group_map m on n.source_id = m.group_id
where n.type in(2,5)
<if test="subjectIds != null and subjectIds.size() > 0">
and n.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
select sm.source_id,sm.subject_id from subject_info_source_map sm where type = 1
<if test="subjectIds != null and subjectIds.size() > 0">
and sm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
) x
</select>
<select id="excludeSourceList" resultType="com.zzsn.event.vo.SubjectSourceVO">
select distinct x.source_id,x.subject_id from (
select m.source_id,n.subject_id from subject_info_source_map n
inner join info_source_group_map m on n.source_id = m.group_id
where n.type = 4
<if test="subjectIds != null and subjectIds.size() > 0">
and n.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
select sm.source_id,sm.subject_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>
) x
</select>
<select id="bindKeyWordsIdList" resultType="String">
select distinct b.id from key_words b
......
......@@ -203,4 +203,24 @@
</if>
order by s.create_time desc
</select>
<select id="directSourceList" resultType="String">
select iso.web_site_name
from info_source iso where 1=1
<if test="searchWord!=null and searchWord != ''">
and (
iso.web_site_name like CONCAT('%',#{infoSourceCondition.searchWord},'%')
or iso.site_uri = like CONCAT('%',#{infoSourceCondition.searchWord},'%')
)
</if>
group by iso.web_site_name
order by iso.create_time
</select>
<select id="directSourceColumnList" resultType="com.zzsn.event.entity.InfoSource">
select iso.site_name,iso.site_uri
from info_source iso where iso.web_site_name = #{webSiteName}
order by iso.create_time
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zzsn.event.mapper.SubjectSampleFileMapper">
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zzsn.event.mapper.SysDictItemMapper">
<select id="listByDictCode" resultType="com.zzsn.event.entity.SysDictItem">
select * from sys_dict_item item inner join sys_dict dict on item.dict_id = dict.id
where dict.dict_code = #{dictCode}
</select>
</mapper>
\ No newline at end of file
package com.zzsn.event.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.ClbLabelItem;
/**
* <p>
* 服务类
* </p>
*
* @author obcy
* @since 2024-08-23
*/
public interface ClbLabelItemService extends IService<ClbLabelItem> {
}
package com.zzsn.event.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.ClbLabel;
import com.zzsn.event.vo.InfoSourceLabelVO;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author obcy
* @since 2024-08-23
*/
public interface ClbLabelService extends IService<ClbLabel> {
/**
* 专题绑定的信息源标签信息
*
* @param subjectId 专题
* @author lkg
* @date 2025/1/2
*/
List<InfoSourceLabelVO> bindInfoSourceLabelInfo(String subjectId);
/**
* 获取分类下的标签信息
*
* @param labelTypeId 标签分类id
* @author lkg
* @date 2025/1/2
*/
List<InfoSourceLabelVO> labelInfoByType(String labelTypeId);
}
......@@ -5,6 +5,7 @@ import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.*;
import org.apache.ibatis.annotations.Param;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Set;
......@@ -68,9 +69,11 @@ public interface CommonService {
* @author lkg
* @date 2024/4/24
*/
List<SubjectInfoSourceLabelTypeVo> bindSourceList(List<String> subjectIds);
List<SubjectSourceVO> bindSourceList(List<String> subjectIds);
/**获取所有节点*/
/**
* 获取所有节点
*/
List<ModelVO> allList(String subjectType);
/**
......@@ -86,4 +89,14 @@ public interface CommonService {
* 根据专题或栏目配置查询关键词黑名单
*/
Set<String> getExcludeKeywords(String databaseIds);
/**
* 下载模板文件
*
* @param response 响应
* @param path 文件路径
* @author lkg
* @date 2025/1/4
*/
void downloadTemplate(HttpServletResponse response, String path);
}
......@@ -40,7 +40,7 @@ public interface IInfoSourceService extends IService<InfoSource> {
* @author lkg
* @date 2024/4/30
*/
IPage<InfoSourceVo> unBindSourcePageList(InfoSourceCondition infoSourceCondition,Integer pageNo, Integer pageSize);
IPage<InfoSourceVo> unBindSourcePageList(InfoSourceCondition infoSourceCondition, Integer pageNo, Integer pageSize);
/**
......@@ -51,4 +51,36 @@ public interface IInfoSourceService extends IService<InfoSource> {
* @date 2024/4/24
*/
Integer bindSourceCount(List<String> subjectIds);
/**
* 信息源分页列表(专题绑定定向信息源时使用)
*
* @param searchWord 搜索词
* @param pageNo 当前页
* @param pageSize 返回条数
* @author lkg
* @date 2025/1/4
*/
IPage<String> directSourcePageList(String searchWord, Integer pageNo, Integer pageSize);
/**
* 信息源下栏目分页列表(专题绑定定向信息源时使用)
*
* @param webSiteName 信息源名称
* @param pageNo 当前页
* @param pageSize 返回条数
* @author lkg
* @date 2025/1/4
*/
IPage<InfoSource> directSourceColumnPageList(String webSiteName, Integer pageNo, Integer pageSize);
/**
* 信息源下栏目列表(专题绑定定向信息源时使用)
*
* @param webSiteName 信息源名称
* @author lkg
* @date 2025/1/4
*/
List<InfoSource> directSourceColumnList(String webSiteName);
}
package com.zzsn.event.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.SubjectInfoSourceMiddleMap;
/**
* 专题-信息源绑定时,待配置信息源表
*
* @author lkg
* @date 2025/1/2
*/
public interface SubjectInfoSourceMiddleMapService extends IService<SubjectInfoSourceMiddleMap> {
}
package com.zzsn.event.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.SubjectSampleFile;
/**
* @Description: 专题样例文章表
* @Author: jeecg-boot
* @Date: 2025-01-03
* @Version: V1.0
*/
public interface SubjectSampleFileService extends IService<SubjectSampleFile> {
}
......@@ -4,10 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.Subject;
import com.zzsn.event.vo.DirectBindInfoVO;
import com.zzsn.event.vo.SearchEnginesVo;
import com.zzsn.event.vo.SubjectCondition;
import com.zzsn.event.vo.SubjectPage;
import com.zzsn.event.vo.*;
import java.util.List;
......
package com.zzsn.event.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.SysDictItem;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @Author zhangweijian
* @since 2018-12-28
*/
public interface SysDictItemService extends IService<SysDictItem> {
List<SysDictItem> listByDictCode(String dictCode);
}
package com.zzsn.event.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.ClbLabelItem;
import com.zzsn.event.mapper.ClbLabelItemMapper;
import com.zzsn.event.service.ClbLabelItemService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author obcy
* @since 2024-08-23
*/
@Service
public class ClbLabelItemServiceImpl extends ServiceImpl<ClbLabelItemMapper, ClbLabelItem> implements ClbLabelItemService {
}
package com.zzsn.event.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.ClbLabel;
import com.zzsn.event.mapper.ClbLabelMapper;
import com.zzsn.event.service.ClbLabelService;
import com.zzsn.event.vo.InfoSourceLabelVO;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author obcy
* @since 2024-08-23
*/
@Service
public class ClbLabelServiceImpl extends ServiceImpl<ClbLabelMapper, ClbLabel> implements ClbLabelService {
@Override
public List<InfoSourceLabelVO> bindInfoSourceLabelInfo(String subjectId) {
return baseMapper.bindInfoSourceLabelInfo(subjectId);
}
@Override
public List<InfoSourceLabelVO> labelInfoByType(String labelTypeId) {
return baseMapper.labelInfoByType(labelTypeId);
}
}
......@@ -11,6 +11,7 @@ import com.zzsn.event.enums.ScoreTypeEnum;
import com.zzsn.event.mapper.CommonMapper;
import com.zzsn.event.service.*;
import com.zzsn.event.util.DateUtil;
import com.zzsn.event.util.ObsUtil;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.*;
import org.apache.commons.lang3.StringUtils;
......@@ -18,6 +19,8 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.*;
/**
......@@ -42,7 +45,7 @@ public class CommonServiceImpl implements CommonService {
@Autowired
private SubjectKeywordsService subjectKeywordsService;
@Autowired
private InfoSourceGroupService infoSourceGroupService;
private ObsUtil obsUtil;
@Override
......@@ -247,9 +250,9 @@ public class CommonServiceImpl implements CommonService {
}
@Override
public List<SubjectInfoSourceLabelTypeVo> bindSourceList(List<String> subjectIds) {
List<SubjectInfoSourceLabelTypeVo> bindList = commonMapper.bindSourceList(subjectIds);
List<SubjectInfoSourceLabelTypeVo> excludeList = commonMapper.excludeSourceList(subjectIds);
public List<SubjectSourceVO> bindSourceList(List<String> subjectIds) {
List<SubjectSourceVO> bindList = commonMapper.bindSourceList(subjectIds);
List<SubjectSourceVO> excludeList = commonMapper.excludeSourceList(subjectIds);
bindList.removeAll(excludeList);
return bindList;
}
......@@ -310,6 +313,33 @@ public class CommonServiceImpl implements CommonService {
return set;
}
@Override
public void downloadTemplate(HttpServletResponse response, String path) {
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
byte[] bytes = obsUtil.getObjectByte(path);
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
try {
OutputStream outs = response.getOutputStream();
bos = new BufferedOutputStream(outs);
bis = new BufferedInputStream(inputStream);
int i;
while ((i = bis.read(bytes)) != -1) {
bos.write(bytes, 0, i);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
bos.flush();
bos.close();
bis.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
//获取树状结构
private List<ModelVO> getTreeList(List<ModelVO> authTypeList){
List<ModelVO> topList = new ArrayList<>();
......
......@@ -93,7 +93,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
@Resource
private RestHighLevelClient client;
@Autowired
private EsService esService;
private CommonService commonService;
@Override
......@@ -472,15 +472,6 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
subjectModelMapService.saveBatch(modelMaps);
}
//专题实际绑定信息源的集合
private List<SubjectSourceVO> subjectBindSourceList(List<String> subjectIds) {
List<SubjectSourceVO> bindList = baseMapper.bindSourceList(subjectIds);
List<SubjectSourceVO> excludeList = baseMapper.excludeSourceList(subjectIds);
bindList.removeAll(excludeList);
return bindList;
}
//查询每个专题的数量
private Map<String, Integer> subjectInfoCountMap(List<String> subjectIdList, List<Integer> checkStatusList) {
Map<String, Integer> map = new HashMap<>(subjectIdList.size());
......@@ -525,10 +516,10 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
List<String> idList = pageList.stream().map(EventNewPlatVO::getId).collect(Collectors.toList());
Map<String, Integer> infoSourceNumMap = new HashMap<>();
long t1 = System.currentTimeMillis();
Map<String, Integer> keyWordsNumMap = baseMapper.bindKeywordCountList(idList).stream().collect(Collectors.toMap(SubjectPage::getId, SubjectPage::getKeyWordsNum));
Map<String, Integer> keyWordsNumMap = commonService.bindKeyWordsCountList(idList).stream().collect(Collectors.toMap(SubjectPage::getId, SubjectPage::getKeyWordsNum));
long t2 = System.currentTimeMillis();
log.info("关键词数量查询耗时==={}",t2-t1);
Map<String, List<SubjectSourceVO>> collect = subjectBindSourceList(idList).stream().collect(Collectors.groupingBy(SubjectSourceVO::getSubjectId));
Map<String, List<SubjectSourceVO>> collect = commonService.bindSourceList(idList).stream().collect(Collectors.groupingBy(SubjectSourceVO::getSubjectId));
long t3 = System.currentTimeMillis();
log.info("信息源数量查询耗时==={}",t3-t2);
for (Map.Entry<String, List<SubjectSourceVO>> entry : collect.entrySet()) {
......
......@@ -10,6 +10,7 @@ import com.zzsn.event.entity.InfoSource;
import com.zzsn.event.es.EsService;
import com.zzsn.event.mapper.InfoSourceMapper;
import com.zzsn.event.service.IInfoSourceService;
import com.zzsn.event.util.CodeGenerateUtil;
import com.zzsn.event.vo.InfoSourceCondition;
import com.zzsn.event.vo.InfoSourceVo;
import com.zzsn.event.vo.NumVO;
......@@ -105,4 +106,21 @@ public class InfoSourceServiceImpl extends ServiceImpl<InfoSourceMapper, InfoSou
Long count = baseMapper.bindSourceIdCount(null, subjectIds);
return count.intValue();
}
@Override
public IPage<String> directSourcePageList(String searchWord, Integer pageNo, Integer pageSize) {
Page<String> page = new Page<>(pageNo, pageSize);
return baseMapper.directSourceList(searchWord, page);
}
@Override
public IPage<InfoSource> directSourceColumnPageList(String webSiteName, Integer pageNo, Integer pageSize) {
Page<InfoSource> page = new Page<>(pageNo, pageSize);
return baseMapper.directSourceColumnList(webSiteName, page);
}
@Override
public List<InfoSource> directSourceColumnList(String webSiteName) {
return baseMapper.directSourceColumnList(webSiteName);
}
}
......@@ -20,10 +20,7 @@ import com.zzsn.event.util.*;
import com.zzsn.event.util.user.AuthUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*;
import com.zzsn.event.vo.es.DisplayInfo;
import com.zzsn.event.vo.es.ESData;
import com.zzsn.event.vo.es.SpecialInformation;
import com.zzsn.event.vo.es.Subjectdatabase;
import com.zzsn.event.vo.es.*;
import com.zzsn.event.vo.log.DataLifecycleLog;
import com.zzsn.event.entity.InfoSource;
import lombok.extern.slf4j.Slf4j;
......@@ -96,17 +93,60 @@ public class InformationServiceImpl implements InformationService {
}
@Override
public IPage<DisplayInfo> subjectPageList(UserVo userVo,EventDataCondition subjectInfo) {
IPage<DisplayInfo> page = new Page<>(subjectInfo.getPageNo(), subjectInfo.getPageSize());
List<String> relationIds = subjectInfo.getLabelIds();
List<String> labelTypeIds = subjectInfo.getLabelTypeIds();
public IPage<DisplayInfo> subjectPageList(UserVo userVo,EventDataCondition searchCondition) {
IPage<DisplayInfo> page = new Page<>(searchCondition.getPageNo(), searchCondition.getPageSize());
List<String> subjectIdList = new ArrayList<>();
//判断是否是专题
if ("1".equals(searchCondition.getIsSubject())) {
if (StringUtils.isNotEmpty(searchCondition.getSubjectId())) {
subjectIdList.add(searchCondition.getSubjectId());
}
} else {
//该id其实是专题类别id
//查询类别id的所有明细id
String subjectTypeId = searchCondition.getSubjectId();
Integer category = searchCondition.getCategory();
List<String> typeIds = subjectTypeService.belowIdList(subjectTypeId, category);
if (category == 1) {
subjectIdList = subjectTypeMapService.selectSubjectByTypeIds(typeIds);
} else if (category == 2) {
subjectIdList = subjectTypeMapService.selectEventByTypeIds(typeIds);
}
}
List<String> relationIds = searchCondition.getLabelIds();
List<String> labelTypeIds = searchCondition.getLabelTypeIds();
if (CollectionUtils.isNotEmpty(labelTypeIds)) {
List<String> socialCreditCodeList = commonService.codesByLabels(labelTypeIds);
relationIds.addAll(socialCreditCodeList);
}
subjectInfo.setLabelIds(relationIds);
searchCondition.setLabelIds(relationIds);
try {
page = esService.subjectPageList(userVo.getId(),subjectInfo);
IPage<SpecialInformation> specialInformationIPage = esService.pageListByCondtion(searchCondition,subjectIdList);
long total = specialInformationIPage.getTotal();
if (total > 0) {
List<DisplayInfo> dataList = new ArrayList<>();
List<LabelModelVo> labelModelVos = commonService.subjectModelBindLabels(subjectIdList);
Map<String, List<LabelModelVo>> modelMap = labelModelVos.stream().collect(Collectors.groupingBy(LabelModelVo::getSubjectId));
List<SpecialInformation> records = specialInformationIPage.getRecords();
for (SpecialInformation specialInformation : records) {
DisplayInfo info = new DisplayInfo();
BeanUtils.copyProperties(specialInformation,info);
info.setPublishDate(EsDateUtil.esFieldDateMapping(info.getPublishDate()));
LambdaQueryWrapper<CollectionMap> query = Wrappers.lambdaQuery();
query.eq(CollectionMap::getUserId, userVo.getId());
query.eq(CollectionMap::getArticleId, info.getId());
int count = collectionMapService.count(query);
if (count > 0) {
info.setYnCollect(true);
}
//标签处理
List<LabelModelVo> modelVoList = modelMap.get(info.getSubjectId());
formatLabel(modelVoList, info);
dataList.add(info);
}
page.setRecords(dataList);
page.setTotal(total);
}
} catch (Exception e) {
e.printStackTrace();
}
......@@ -604,6 +644,36 @@ public class InformationServiceImpl implements InformationService {
clbFileOperationLogService.saveEntity(clbFileOperationLog);
}
private void formatLabel(List<LabelModelVo> labelModelVos, DisplayInfo info) {
if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isNotEmpty(labelModelVos)) {
List<Label> list = info.getLabels();
List<LabelInfo> labelInfos = new ArrayList<>();
//获取专题打的标签
for (LabelModelVo labelModelVo : labelModelVos) {
LabelInfo labelInfo = new LabelInfo();
labelInfo.setLabelId(labelModelVo.getLabelId());
labelInfo.setLabelName(labelModelVo.getLabelName());
labelInfo.setLabelType(labelModelVo.getLabelType());
labelInfo.setLabelMark(labelModelVo.getLabelMark());
List<Label> labelList = new ArrayList<>();
if (list != null && !list.isEmpty()) {
for (Label label : list) {
if (StringUtils.isNotBlank(label.getLabelMark()) &&
(label.getLabelMark().contains(labelModelVo.getLabelMark()) || ("company_label".equals(labelModelVo.getLabelType()) && "company_label".equals(label.getLabelRemarks())))) {
labelList.add(label);
}
}
}
labelInfo.setLabelList(labelList);
labelInfos.add(labelInfo);
}
info.setLabelInfos(labelInfos);
}
}
private void addReadNum(DisplayInfo displayInfo, String index) {
if (displayInfo != null) {
Long readNum = displayInfo.getReadNum();
......@@ -662,7 +732,7 @@ public class InformationServiceImpl implements InformationService {
//信息加上分类
public void setInfoSourceType(SpecialInformation data) {
String url = domainURL(data.getSourceAddress());
String url = Utility.domainURL(data.getSourceAddress());
String typeNum = null;
if (StringUtils.isNotEmpty(url)) {
if (redisUtil.get(Constants.SITE_NAME_KEY + url) != null) {
......@@ -675,29 +745,4 @@ public class InformationServiceImpl implements InformationService {
}
data.setInfoSourceType(typeNum);
}
/**
* 返回匹配的域名。例如:www.baidu.com
*
* @param sourceAddress 原链接
* @author lkg
* @date 2024/12/19
*/
public static String domainURL(String sourceAddress){
if (sourceAddress==null || sourceAddress.trim().length()==0) {
return "";
}
String result = "";
try {
String regex = "(?<=//|)((\\w)+\\.)+[\\s\\S]+?(?=\\/|\\:|\\?)" ;
Pattern p = Pattern.compile(regex,Pattern.CASE_INSENSITIVE);
Matcher matcher = p.matcher(sourceAddress);
matcher.find();
result = matcher.group();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}
package com.zzsn.event.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.SubjectInfoSourceMiddleMap;
import com.zzsn.event.mapper.SubjectInfoSourceMiddleMapMapper;
import com.zzsn.event.service.SubjectInfoSourceMiddleMapService;
import org.springframework.stereotype.Service;
/**
* 专题-信息源绑定中间表
*
* @author lkg
* @date 2025/1/2
*/
@Service
public class SubjectInfoSourceMiddleMapServiceImpl extends ServiceImpl<SubjectInfoSourceMiddleMapMapper, SubjectInfoSourceMiddleMap>
implements SubjectInfoSourceMiddleMapService {
}
package com.zzsn.event.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.SubjectSampleFile;
import com.zzsn.event.mapper.SubjectSampleFileMapper;
import com.zzsn.event.service.SubjectSampleFileService;
import org.springframework.stereotype.Service;
/**
* @Description: 专题样例文章表
* @Author: jeecg-boot
* @Date: 2025-01-03
* @Version: V1.0
*/
@Service
public class SubjectSampleFileServiceImpl extends ServiceImpl<SubjectSampleFileMapper, SubjectSampleFile> implements SubjectSampleFileService {
}
......@@ -113,10 +113,10 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
List<String> idList = records.stream().map(SubjectPage::getId).collect(Collectors.toList());
Map<String, Integer> infoSourceNumMap = new HashMap<>();
Map<String, Integer> keyWordsNumMap = commonService.bindKeyWordsCountList(idList).stream().collect(Collectors.toMap(SubjectPage::getId, SubjectPage::getKeyWordsNum));
Map<String, List<SubjectInfoSourceLabelTypeVo>> collect = commonService.bindSourceList(idList).stream().collect(Collectors.groupingBy(SubjectInfoSourceLabelTypeVo::getSubjectId));
for (Map.Entry<String, List<SubjectInfoSourceLabelTypeVo>> entry : collect.entrySet()) {
Map<String, List<SubjectSourceVO>> collect = commonService.bindSourceList(idList).stream().collect(Collectors.groupingBy(SubjectSourceVO::getSubjectId));
for (Map.Entry<String, List<SubjectSourceVO>> entry : collect.entrySet()) {
String subjectId = entry.getKey();
List<SubjectInfoSourceLabelTypeVo> value = entry.getValue();
List<SubjectSourceVO> value = entry.getValue();
infoSourceNumMap.put(subjectId, value.size());
}
List<Integer> checkStatus = new ArrayList<>();
......
package com.zzsn.event.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.SysDictItem;
import com.zzsn.event.mapper.SysDictItemMapper;
import com.zzsn.event.service.SysDictItemService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @Author zhangweijian
* @since 2018-12-28
*/
@Service
public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDictItem> implements SysDictItemService {
@Override
public List<SysDictItem> listByDictCode(String dictCode) {
return this.baseMapper.listByDictCode(dictCode);
}
}
package com.zzsn.event.util;
import org.springframework.util.StringUtils;
import java.beans.PropertyEditorSupport;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
/**
* 类描述:时间操作定义类
*
* @Author: 张代浩
* @Date:2012-12-8 12:15:03
* @Version 1.0
*/
public class DateUtils extends PropertyEditorSupport {
public static ThreadLocal<SimpleDateFormat> date_sdf = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd");
}
};
public static ThreadLocal<SimpleDateFormat> yyyyMMdd = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyyMMdd");
}
};
public static ThreadLocal<SimpleDateFormat> date_sdf_wz = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy年MM月dd日");
}
};
public static ThreadLocal<SimpleDateFormat> time_sdf = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm");
}
};
public static ThreadLocal<SimpleDateFormat> yyyymmddhhmmss = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyyMMddHHmmss");
}
};
public static ThreadLocal<SimpleDateFormat> short_time_sdf = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("HH:mm");
}
};
public static ThreadLocal<SimpleDateFormat> datetimeFormat = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
}
};
// 以毫秒表示的时间
private static final long DAY_IN_MILLIS = 24 * 3600 * 1000;
private static final long HOUR_IN_MILLIS = 3600 * 1000;
private static final long MINUTE_IN_MILLIS = 60 * 1000;
private static final long SECOND_IN_MILLIS = 1000;
// 指定模式的时间格式
private static SimpleDateFormat getSDFormat(String pattern) {
return new SimpleDateFormat(pattern);
}
/**
* 当前日历,这里用中国时间表示
*
* @return 以当地时区表示的系统当前日历
*/
public static Calendar getCalendar() {
return Calendar.getInstance();
}
/**
* 指定毫秒数表示的日历
*
* @param millis 毫秒数
* @return 指定毫秒数表示的日历
*/
public static Calendar getCalendar(long millis) {
Calendar cal = Calendar.getInstance();
// --------------------cal.setTimeInMillis(millis);
cal.setTime(new Date(millis));
return cal;
}
// ////////////////////////////////////////////////////////////////////////////
// getDate
// 各种方式获取的Date
// ////////////////////////////////////////////////////////////////////////////
/**
* 当前日期
*
* @return 系统当前时间
*/
public static Date getDate() {
return new Date();
}
/**
* 指定毫秒数表示的日期
*
* @param millis 毫秒数
* @return 指定毫秒数表示的日期
*/
public static Date getDate(long millis) {
return new Date(millis);
}
/**
* 时间戳转换为字符串
*
* @param time
* @return
*/
public static String timestamptoStr(Timestamp time) {
Date date = null;
if (null != time) {
date = new Date(time.getTime());
}
return date2Str(date_sdf.get());
}
/**
* 字符串转换时间戳
*
* @param str
* @return
*/
public static Timestamp str2Timestamp(String str) {
Date date = str2Date(str, date_sdf.get());
return new Timestamp(date.getTime());
}
/**
* 字符串转换成日期
*
* @param str
* @param sdf
* @return
*/
public static Date str2Date(String str, SimpleDateFormat sdf) {
if (null == str || "".equals(str)) {
return null;
}
Date date = null;
try {
date = sdf.parse(str);
return date;
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
/**
* 日期转换为字符串
*
* @param date_sdf 日期格式
* @return 字符串
*/
public static String date2Str(SimpleDateFormat date_sdf) {
Date date = getDate();
if (null == date) {
return null;
}
return date_sdf.format(date);
}
/**
* 格式化时间
*
* @param date
* @param format
* @return
*/
public static String dateformat(String date, String format) {
SimpleDateFormat sformat = new SimpleDateFormat(format);
Date _date = null;
try {
_date = sformat.parse(date);
} catch (ParseException e) {
e.printStackTrace();
}
return sformat.format(_date);
}
/**
* 日期转换为字符串
*
* @param date 日期
* @param date_sdf 日期格式
* @return 字符串
*/
public static String date2Str(Date date, SimpleDateFormat date_sdf) {
if (null == date) {
return null;
}
return date_sdf.format(date);
}
/**
* 日期转换为字符串
*
* @param format 日期格式
* @return 字符串
*/
public static String getDate(String format) {
Date date = new Date();
if (null == date) {
return null;
}
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(date);
}
/**
* 指定毫秒数的时间戳
*
* @param millis 毫秒数
* @return 指定毫秒数的时间戳
*/
public static Timestamp getTimestamp(long millis) {
return new Timestamp(millis);
}
/**
* 以字符形式表示的时间戳
*
* @param time 毫秒数
* @return 以字符形式表示的时间戳
*/
public static Timestamp getTimestamp(String time) {
return new Timestamp(Long.parseLong(time));
}
/**
* 系统当前的时间戳
*
* @return 系统当前的时间戳
*/
public static Timestamp getTimestamp() {
return new Timestamp(System.currentTimeMillis());
}
/**
* 当前时间,格式 yyyy-MM-dd HH:mm:ss
*
* @return 当前时间的标准形式字符串
*/
public static String now() {
return datetimeFormat.get().format(getCalendar().getTime());
}
/**
* 指定日期的时间戳
*
* @param date 指定日期
* @return 指定日期的时间戳
*/
public static Timestamp getTimestamp(Date date) {
return new Timestamp(date.getTime());
}
/**
* 指定日历的时间戳
*
* @param cal 指定日历
* @return 指定日历的时间戳
*/
public static Timestamp getCalendarTimestamp(Calendar cal) {
// ---------------------return new Timestamp(cal.getTimeInMillis());
return new Timestamp(cal.getTime().getTime());
}
public static Timestamp gettimestamp() {
Date dt = new Date();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String nowTime = df.format(dt);
Timestamp buydate = Timestamp.valueOf(nowTime);
return buydate;
}
// ////////////////////////////////////////////////////////////////////////////
// getMillis
// 各种方式获取的Millis
// ////////////////////////////////////////////////////////////////////////////
/**
* 系统时间的毫秒数
*
* @return 系统时间的毫秒数
*/
public static long getMillis() {
return System.currentTimeMillis();
}
/**
* 指定日历的毫秒数
*
* @param cal 指定日历
* @return 指定日历的毫秒数
*/
public static long getMillis(Calendar cal) {
// --------------------return cal.getTimeInMillis();
return cal.getTime().getTime();
}
/**
* 指定日期的毫秒数
*
* @param date 指定日期
* @return 指定日期的毫秒数
*/
public static long getMillis(Date date) {
return date.getTime();
}
/**
* 指定时间戳的毫秒数
*
* @param ts 指定时间戳
* @return 指定时间戳的毫秒数
*/
public static long getMillis(Timestamp ts) {
return ts.getTime();
}
// ////////////////////////////////////////////////////////////////////////////
// formatDate
// 将日期按照一定的格式转化为字符串
// ////////////////////////////////////////////////////////////////////////////
/**
* 默认方式表示的系统当前日期,具体格式:年-月-日
*
* @return 默认日期按“年-月-日“格式显示
*/
public static String formatDate() {
return date_sdf.get().format(getCalendar().getTime());
}
/**
* 默认方式表示的系统当前日期,具体格式:yyyy-MM-dd HH:mm:ss
*
* @return 默认日期按“yyyy-MM-dd HH:mm:ss“格式显示
*/
public static String formatDateTime() {
return datetimeFormat.get().format(getCalendar().getTime());
}
/**
* 获取时间字符串
*/
public static String getDataString(SimpleDateFormat formatstr) {
return formatstr.format(getCalendar().getTime());
}
/**
* 指定日期的默认显示,具体格式:年-月-日
*
* @param cal 指定的日期
* @return 指定日期按“年-月-日“格式显示
*/
public static String formatDate(Calendar cal) {
return date_sdf.get().format(cal.getTime());
}
/**
* 指定日期的默认显示,具体格式:年-月-日
*
* @param date 指定的日期
* @return 指定日期按“年-月-日“格式显示
*/
public static String formatDate(Date date) {
return date_sdf.get().format(date);
}
/**
* 指定毫秒数表示日期的默认显示,具体格式:年-月-日
*
* @param millis 指定的毫秒数
* @return 指定毫秒数表示日期按“年-月-日“格式显示
*/
public static String formatDate(long millis) {
return date_sdf.get().format(new Date(millis));
}
/**
* 默认日期按指定格式显示
*
* @param pattern 指定的格式
* @return 默认日期按指定格式显示
*/
public static String formatDate(String pattern) {
return getSDFormat(pattern).format(getCalendar().getTime());
}
/**
* 指定日期按指定格式显示
*
* @param cal 指定的日期
* @param pattern 指定的格式
* @return 指定日期按指定格式显示
*/
public static String formatDate(Calendar cal, String pattern) {
return getSDFormat(pattern).format(cal.getTime());
}
/**
* 指定日期按指定格式显示
*
* @param date 指定的日期
* @param pattern 指定的格式
* @return 指定日期按指定格式显示
*/
public static String formatDate(Date date, String pattern) {
return getSDFormat(pattern).format(date);
}
// ////////////////////////////////////////////////////////////////////////////
// formatTime
// 将日期按照一定的格式转化为字符串
// ////////////////////////////////////////////////////////////////////////////
/**
* 默认方式表示的系统当前日期,具体格式:年-月-日 时:分
*
* @return 默认日期按“年-月-日 时:分“格式显示
*/
public static String formatTime() {
return time_sdf.get().format(getCalendar().getTime());
}
/**
* 指定毫秒数表示日期的默认显示,具体格式:年-月-日 时:分
*
* @param millis 指定的毫秒数
* @return 指定毫秒数表示日期按“年-月-日 时:分“格式显示
*/
public static String formatTime(long millis) {
return time_sdf.get().format(new Date(millis));
}
/**
* 指定日期的默认显示,具体格式:年-月-日 时:分
*
* @param cal 指定的日期
* @return 指定日期按“年-月-日 时:分“格式显示
*/
public static String formatTime(Calendar cal) {
return time_sdf.get().format(cal.getTime());
}
/**
* 指定日期的默认显示,具体格式:年-月-日 时:分
*
* @param date 指定的日期
* @return 指定日期按“年-月-日 时:分“格式显示
*/
public static String formatTime(Date date) {
return time_sdf.get().format(date);
}
// ////////////////////////////////////////////////////////////////////////////
// formatShortTime
// 将日期按照一定的格式转化为字符串
// ////////////////////////////////////////////////////////////////////////////
/**
* 默认方式表示的系统当前日期,具体格式:时:分
*
* @return 默认日期按“时:分“格式显示
*/
public static String formatShortTime() {
return short_time_sdf.get().format(getCalendar().getTime());
}
/**
* 指定毫秒数表示日期的默认显示,具体格式:时:分
*
* @param millis 指定的毫秒数
* @return 指定毫秒数表示日期按“时:分“格式显示
*/
public static String formatShortTime(long millis) {
return short_time_sdf.get().format(new Date(millis));
}
/**
* 指定日期的默认显示,具体格式:时:分
*
* @param cal 指定的日期
* @return 指定日期按“时:分“格式显示
*/
public static String formatShortTime(Calendar cal) {
return short_time_sdf.get().format(cal.getTime());
}
/**
* 指定日期的默认显示,具体格式:时:分
*
* @param date 指定的日期
* @return 指定日期按“时:分“格式显示
*/
public static String formatShortTime(Date date) {
return short_time_sdf.get().format(date);
}
// ////////////////////////////////////////////////////////////////////////////
// parseDate
// parseCalendar
// parseTimestamp
// 将字符串按照一定的格式转化为日期或时间
// ////////////////////////////////////////////////////////////////////////////
/**
* 根据指定的格式将字符串转换成Date 如输入:2003-11-19 11:20:20将按照这个转成时间
*
* @param src 将要转换的原始字符窜
* @param pattern 转换的匹配格式
* @return 如果转换成功则返回转换后的日期
* @throws ParseException
*/
public static Date parseDate(String src, String pattern) {
Date parse = null;
try {
parse = getSDFormat(pattern).parse(src);
} catch (Exception e) {
e.printStackTrace();
}
return parse;
}
/**
* 根据指定的格式将字符串转换成Date 如输入:2003-11-19 11:20:20将按照这个转成时间
*
* @param src 将要转换的原始字符窜
* @param pattern 转换的匹配格式
* @return 如果转换成功则返回转换后的日期
* @throws ParseException
*/
public static Calendar parseCalendar(String src, String pattern) {
Date date = parseDate(src, pattern);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
return cal;
}
public static String formatAddDate(String src, String pattern, int amount) {
Calendar cal;
cal = parseCalendar(src, pattern);
cal.add(Calendar.DATE, amount);
return formatDate(cal);
}
/**
* 根据指定的格式将字符串转换成Date 如输入:2003-11-19 11:20:20将按照这个转成时间
*
* @param src 将要转换的原始字符窜
* @param pattern 转换的匹配格式
* @return 如果转换成功则返回转换后的时间戳
* @throws ParseException
*/
public static Timestamp parseTimestamp(String src, String pattern) throws ParseException {
Date date = parseDate(src, pattern);
return new Timestamp(date.getTime());
}
// ////////////////////////////////////////////////////////////////////////////
// dateDiff
// 计算两个日期之间的差值
// ////////////////////////////////////////////////////////////////////////////
/**
* 计算两个时间之间的差值,根据标志的不同而不同
*
* @param flag 计算标志,表示按照年/月/日/时/分/秒等计算
* @param calSrc 减数
* @param calDes 被减数
* @return 两个日期之间的差值
*/
public static int dateDiff(char flag, Calendar calSrc, Calendar calDes) {
long millisDiff = getMillis(calSrc) - getMillis(calDes);
if (flag == 'y') {
return (calSrc.get(Calendar.YEAR) - calDes.get(Calendar.YEAR));
}
if (flag == 'd') {
return (int) (millisDiff / DAY_IN_MILLIS);
}
if (flag == 'h') {
return (int) (millisDiff / HOUR_IN_MILLIS);
}
if (flag == 'm') {
return (int) (millisDiff / MINUTE_IN_MILLIS);
}
if (flag == 's') {
return (int) (millisDiff / SECOND_IN_MILLIS);
}
return 0;
}
/**
* String类型 转换为Date, 如果参数长度为10 转换格式”yyyy-MM-dd“ 如果参数长度为19 转换格式”yyyy-MM-dd
* HH:mm:ss“ * @param text String类型的时间值
*/
@Override
public void setAsText(String text) throws IllegalArgumentException {
if (StringUtils.hasText(text)) {
try {
if (text.indexOf(":") == -1 && text.length() == 10) {
setValue(DateUtils.date_sdf.get().parse(text));
} else if (text.indexOf(":") > 0 && text.length() == 19) {
setValue(DateUtils.datetimeFormat.get().parse(text));
} else {
throw new IllegalArgumentException("Could not parse date, date format is error ");
}
} catch (ParseException ex) {
IllegalArgumentException iae = new IllegalArgumentException("Could not parse date: " + ex.getMessage());
iae.initCause(ex);
throw iae;
}
} else {
setValue(null);
}
}
public static int getYear() {
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(getDate());
return calendar.get(Calendar.YEAR);
}
// 获得本周一0点时间
public static Date getTimesWeekMorning() {
Calendar cal = Calendar.getInstance();
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
return cal.getTime();
}
// 获得本周日24点时间
public static Date getTimesWeekNight() {
Calendar cal = Calendar.getInstance();
cal.setTime(getTimesWeekMorning());
cal.add(Calendar.DAY_OF_WEEK, 7);
return cal.getTime();
}
// 获得本月第一天0点时间
public static Date getTimesMonthMorning() {
Calendar cal = Calendar.getInstance();
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
return cal.getTime();
}
// 获得本月最后一天24点时间
public static Date getTimesMonthNight() {
Calendar cal = Calendar.getInstance();
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
cal.set(Calendar.HOUR_OF_DAY, 24);
return cal.getTime();
}
public static Date getHalfYearStartTime() {
Calendar c = Calendar.getInstance();
int currentMonth = c.get(Calendar.MONTH) + 1;
Date now = null;
try {
if (currentMonth <= 6) {
c.set(Calendar.MONTH, 0);
} else if (currentMonth <= 12) {
c.set(Calendar.MONTH, 6);
}
c.set(Calendar.DATE, 1);
now = c.getTime();
} catch (Exception e) {
e.printStackTrace();
}
return now;
}
public static Date getHalfYearEndTime() {
Calendar c = Calendar.getInstance();
int currentMonth = c.get(Calendar.MONTH) + 1;
Date now = null;
try {
if (currentMonth <= 6) {
c.set(Calendar.MONTH, 5);
c.set(Calendar.DATE, 30);
} else if (currentMonth <= 12) {
c.set(Calendar.MONTH, 11);
c.set(Calendar.DATE, 31);
}
now = c.getTime();
} catch (Exception e) {
e.printStackTrace();
}
return now;
}
// 获得本年第一天的时间
public static Date getCurrentYearStart() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.MONTH, 0);
cal.set(Calendar.DATE, 1);
return cal.getTime();
}
// 获得本年最后一天的时间
public static Date getCurrentYearEnd() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.MONTH, 11);
cal.set(Calendar.DATE, 31);
return cal.getTime();
}
}
......@@ -2,7 +2,7 @@ package com.zzsn.event.util;
import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.seg.common.Term;
import org.springframework.util.StringUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
import java.util.regex.Matcher;
......
......@@ -890,26 +890,26 @@ public class Utility {
text = text.replaceAll(" +\r\n", "\n");
text = text.replaceAll("\r\n", "\n");
text = text.replaceAll(" +", " ");
// text = text.replaceAll("[\\u00A0\\u3000]", "");
// text = text.replaceAll(" ", "");
// text = text.replaceAll("[\\u00A0\\u3000]", "");
// text = text.replaceAll(" ", "");
text = text.replaceAll(" \n", "\n");
text = text.replaceAll("\n\n", "\n").replaceAll("\n\n", "\n").replaceAll("\n\n", "\n").replaceAll("\n\n", "\n").replaceAll("\n\n", "\n").replaceAll("\n\n", "\n");
//如果遇到table,则不加处理
if (text.contains("<table")) {
String[] textArr = text.split("\n");
String result ="";
String result = "";
for (String tex : textArr) {
if (!tex.contains("<table") && !tex.contains("<td") && !tex.contains("<tr")
&& !tex.contains("table>") && !tex.contains("td>") && !tex.contains("tr>")) {
result += "<p style='text-indent:2em;'>" + tex + "</p><br/>";
} else {
result += tex;
result += tex;
}
}
text = result;
} else {
text = text.replaceAll("\n\\s+", "</p>"+"<br/>" + "<p style='text-indent:2em;'>");
text = text.replaceAll("\n", "</p>"+"<br/>" + "<p style='text-indent:2em;'>");
text = text.replaceAll("\n\\s+", "</p>" + "<br/>" + "<p style='text-indent:2em;'>");
text = text.replaceAll("\n", "</p>" + "<br/>" + "<p style='text-indent:2em;'>");
text = "<p style='text-indent:2em;'>" + text + "</p>";
}
return text;
......@@ -1466,25 +1466,26 @@ public class Utility {
}
}
return htmlEscape(document.outerHtml()).replace("</p>","").replaceAll("<html>\\n <head></head>\\n <body> \\n ","");
return htmlEscape(document.outerHtml()).replace("</p>", "").replaceAll("<html>\\n <head></head>\\n <body> \\n ", "");
}
//对带标签的内容进行进一步处理
public static String htmlEscape(String content){
if(content.indexOf("\r\n") > -1){
public static String htmlEscape(String content) {
if (content.indexOf("\r\n") > -1) {
content = content.replaceAll("\r\n", "<br/>");
}
if(content.indexOf('\n') > -1){
if (content.indexOf('\n') > -1) {
content = content.replaceAll("\n", "<br/>");
}
while (content.replaceAll("\\s*", "").indexOf("<br/><br/>") > -1) {
content = content.replaceAll("<br/>\\s*<br/>", "<br/>");
}
//兼容已按老逻辑处理过的数据
content = content.replaceAll("</p ><p","</p ><br/><p").replace("  ","");
content = content.replaceAll("</p ><p", "</p ><br/><p").replace("  ", "");
String[] page = content.split("<br/>");
String convertContent = "";
if(page != null && page.length > 0 ) {
if (page != null && page.length > 0) {
for (String section : page) {
if (StringUtils.isNotBlank(section)) {
section = section.trim();
......@@ -1499,7 +1500,7 @@ public class Utility {
section = section.substring(1).trim();
}
}
convertContent+=section;
convertContent += section;
}
}
}
......@@ -1529,4 +1530,29 @@ public class Utility {
return result.toString();
}
/**
* 返回匹配的域名。例如:www.baidu.com
*
* @param sourceAddress 原链接
* @author lkg
* @date 2024/12/19
*/
public static String domainURL(String sourceAddress) {
String domain = null;
if (StringUtils.isNotBlank(sourceAddress)) {
try {
//String regex = "(?<=//|)((\\w)+\\.)+[\\s\\S]+?(?=\\/|\\:|\\?)" ;
String regex = "\\b(?:[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*\\.)+[a-zA-Z]{2,}\\b";
Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
Matcher matcher = p.matcher(sourceAddress);
if (matcher.find()) {
domain = matcher.group();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return domain;
}
}
......@@ -69,6 +69,10 @@ public class EventDataCondition {
//搜索词信息集合
private List<SearchWordVO> searchWordList;
//关键词信息;推荐信息源时使用
private List<String> wordsList;
//是否免审核(1-是;0-否)
private Integer isFreeCheck;
......@@ -77,6 +81,7 @@ public class EventDataCondition {
private Integer minScore;
//最大得分
private Integer maxScore;
//es查询字段数组
private String[] fetchFields;
......@@ -92,16 +97,25 @@ public class EventDataCondition {
//每页返回条数
private Integer pageSize = 10;
//资讯id集合,导出使用
//资讯id集合,导出/专题分析时 使用
private List<String> ids;
/*------资讯导出类参数---start-------------------*/
//导出方式(1-摘要;2-正文)
private Integer exportType;
/*------资讯导出类参数---end-------------------*/
/*------专题分析类参数---start-------------------*/
//聚合分组类型-按日期集合分析时使用
private String groupType;
//选择的前num条数据-专题分析时使用
private Integer num;
//信息源id集合-统计分析资讯量最多的信息源时使用
private List<String> sourceIdList;
//聚合包含的字段值的集合
private String[] includeValues;
//聚合排除的字段值的集合
private String[] excludeValues;
/*------专题分析类参数---end-------------------*/
}
package com.zzsn.event.vo;
import lombok.Data;
/**
* 信息源标签值对象信息
*
* @author lkg
* @date 2025/1/2
*/
@Data
public class InfoSourceLabelItemVO {
/**信息源标签值编码*/
private String labelItemCode;
/**信息源标签值名称*/
private String labelItemName;
}
package com.zzsn.event.vo;
import lombok.Data;
import java.util.List;
/**
* 信息源标签对象信息
*
* @author lkg
* @date 2025/1/2
*/
@Data
public class InfoSourceLabelVO {
/**信息源标签编码*/
private String labelCode;
/**信息源标签名称*/
private String labelName;
/**信息源标签下的标签值列表*/
private List<InfoSourceLabelItemVO> infoSourceLabelItemList;
}
......@@ -14,7 +14,7 @@ import lombok.Setter;
public class SearchWordVO {
/**
* 关键词检索范围(1-标题;2-全文;3-来源)
* 关键词检索范围(1-标题;2-全文;3-来源;4-正文)
*/
private Integer searchScope;
......
package com.zzsn.event.vo;
import lombok.Data;
/**
* @Description: 3
* @Author: jeecg-boot
* @Date: 2023-08-01
* @Version: V1.0
*/
@Data
public class SubjectInfoSourceLabelTypeVo {
/**信息源组id*/
private String sourceId;
/**专题id*/
private String subjectId;
}
package com.zzsn.event.vo;
import lombok.Data;
import java.util.List;
/**
* 专题信息源标签
*
* @author lkg
* @date 2025/1/3
*/
@Data
public class SubjectSourceTagVO {
/**专题id*/
private String subjectId;
/**标签编码集合*/
private List<String> labelCodes;
/**标签值编码集合*/
private List<String> labelItemCodes;
}
......@@ -12,4 +12,7 @@ import lombok.Data;
public class SubjectSourceVO {
private String subjectId;
private String sourceId;
//绑定定向信息源时使用(研究中心)
private String webSiteName;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论