提交 0cb65b6a 作者: 925993793@qq.com

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

# Conflicts:
#	src/main/java/com/zzsn/event/controller/SubjectManageController.java
#	src/main/resources/application-test.yml
...@@ -34,7 +34,7 @@ ENV APP_OPTS8="-Dspring.cloud.nacos.config.username=${NACOS_USERNAME}" ...@@ -34,7 +34,7 @@ ENV APP_OPTS8="-Dspring.cloud.nacos.config.username=${NACOS_USERNAME}"
ENV APP_OPTS9="-Dspring.cloud.nacos.config.password=${NACOS_PASSWORD}" ENV APP_OPTS9="-Dspring.cloud.nacos.config.password=${NACOS_PASSWORD}"
ENV APP_OPTS10="-Dserver.port=${PORT}" ENV APP_OPTS10="-Dserver.port=${PORT}"
ENV JVM_OPTS="-Xmx2024M -Xms256M" ENV JVM_OPTS="-Xmx6000M -Xms256M"
EXPOSE ${PORT} EXPOSE ${PORT}
# 解决导出字体缺失报错问题 # 解决导出字体缺失报错问题
......
...@@ -32,4 +32,4 @@ nacos_password="nacos" ...@@ -32,4 +32,4 @@ nacos_password="nacos"
# 资源限制 # 资源限制
## cpu ## cpu
limit_cpu=2.0 limit_cpu=2.0
limit_mem=2g limit_mem=6g
\ No newline at end of file \ No newline at end of file
...@@ -32,4 +32,4 @@ nacos_password="nacos" ...@@ -32,4 +32,4 @@ nacos_password="nacos"
# 资源限制 # 资源限制
## cpu ## cpu
limit_cpu=2.0 limit_cpu=2.0
limit_mem=2g limit_mem=6g
\ No newline at end of file \ No newline at end of file
...@@ -23,6 +23,7 @@ public class Constants { ...@@ -23,6 +23,7 @@ public class Constants {
public static final String SUBJECT_INDEX = "subjectdatabase"; public static final String SUBJECT_INDEX = "subjectdatabase";
//es 采集库索引 //es 采集库索引
public static final String COLLECT_INDEX = "basedata"; public static final String COLLECT_INDEX = "basedata";
public static final String COLLECT_MIDDLE_INDEX = "middlesubjectdatabase";
//专题事件脉络展示 伪事件脉络 的资讯数量阈值 //专题事件脉络展示 伪事件脉络 的资讯数量阈值
public static final int FAKE_NUM = 6; public static final int FAKE_NUM = 6;
......
...@@ -338,6 +338,7 @@ public class FileController { ...@@ -338,6 +338,7 @@ public class FileController {
List<FileDataVO> informationList = reader.read(0, 1, FileDataVO.class); List<FileDataVO> informationList = reader.read(0, 1, FileDataVO.class);
informationService.importDataInfo(informationList,subjectId); informationService.importDataInfo(informationList,subjectId);
} catch (IOException e) { } catch (IOException e) {
log.info("专题-{},批量插入数据异常",subjectId);
e.printStackTrace(); e.printStackTrace();
} }
}); });
......
...@@ -193,13 +193,14 @@ public class SubjectManageController { ...@@ -193,13 +193,14 @@ public class SubjectManageController {
@GetMapping("/visiblePageList") @GetMapping("/visiblePageList")
public Result<?> visiblePageList(@RequestParam Integer type, public Result<?> visiblePageList(@RequestParam Integer type,
@RequestParam(required = false) String subjectName, @RequestParam(required = false) String subjectName,
@RequestParam(defaultValue = "1") Integer subjectType,
@RequestParam(required = false) String environment, @RequestParam(required = false) String environment,
@RequestParam(required = false) String flagCode, @RequestParam(required = false) String flagCode,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest request) { HttpServletRequest request) {
UserVo loginUser = UserUtil.getLoginUser(); UserVo loginUser = UserUtil.getLoginUser();
Page<Node> pageList = subjectService.visiblePageList(loginUser.getUsername(), type, subjectName, pageNo, pageSize, environment, request, flagCode); Page<Node> pageList = subjectService.visiblePageList(loginUser.getUsername(), type, subjectName, subjectType, pageNo, pageSize, environment, request, flagCode);
return Result.OK(pageList); return Result.OK(pageList);
} }
...@@ -219,13 +220,14 @@ public class SubjectManageController { ...@@ -219,13 +220,14 @@ public class SubjectManageController {
@GetMapping("/visiblePageListNoSign") @GetMapping("/visiblePageListNoSign")
public Result<?> visiblePageListNoSign(@RequestParam Integer type, public Result<?> visiblePageListNoSign(@RequestParam Integer type,
@RequestParam(required = false) String subjectName, @RequestParam(required = false) String subjectName,
@RequestParam(defaultValue = "1") Integer subjectType,
@RequestParam(required = false) String environment, @RequestParam(required = false) String environment,
@RequestParam(required = false) String flagCode, @RequestParam(required = false) String flagCode,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest request) { HttpServletRequest request) {
UserVo loginUser = UserUtil.getLoginUser(); UserVo loginUser = UserUtil.getLoginUser();
Page<Node> pageList = subjectService.visiblePageList(loginUser.getUsername(), type, subjectName, pageNo, pageSize, environment, request, flagCode); Page<Node> pageList = subjectService.visiblePageList(loginUser.getUsername(), type, subjectName, subjectType, pageNo, pageSize, environment, request, flagCode);
return Result.OK(pageList); return Result.OK(pageList);
} }
...@@ -795,7 +797,6 @@ public class SubjectManageController { ...@@ -795,7 +797,6 @@ public class SubjectManageController {
*/ */
@PostMapping("/configScoreModel") @PostMapping("/configScoreModel")
public Result<?> configScoreModel(@RequestBody ScoreModelVo scoreModelVo) { public Result<?> configScoreModel(@RequestBody ScoreModelVo scoreModelVo) {
UserVo loginUser = UserUtil.getLoginUser();
scoreModelService.addOrUpdate(scoreModelVo, 1); scoreModelService.addOrUpdate(scoreModelVo, 1);
//调用接口,重新打分 //调用接口,重新打分
String subjectId = scoreModelVo.getSubjectId(); String subjectId = scoreModelVo.getSubjectId();
...@@ -837,7 +838,7 @@ public class SubjectManageController { ...@@ -837,7 +838,7 @@ public class SubjectManageController {
/** /**
* 模型绑定(包含去重、筛选、标签模型)--检查是否需要中断-专题配置页 * 模型绑定(包含去重、筛选、标签模型)--检查是否需要中断-专题配置页
* todo *
* *
* @param subjectPage 参数 * @param subjectPage 参数
* @return * @return
...@@ -849,7 +850,7 @@ public class SubjectManageController { ...@@ -849,7 +850,7 @@ public class SubjectManageController {
/** /**
* 前端发送请求,传参数给python * 前端发送请求,传参数给python
* todo *
*/ */
@PostMapping(value = "/sendPythonInfo") @PostMapping(value = "/sendPythonInfo")
public Result<?> sendPythonInfo(@RequestBody SubjectPage subjectPage) { public Result<?> sendPythonInfo(@RequestBody SubjectPage subjectPage) {
...@@ -907,13 +908,18 @@ public class SubjectManageController { ...@@ -907,13 +908,18 @@ public class SubjectManageController {
@PostMapping("/bindInfoSourceLabel") @PostMapping("/bindInfoSourceLabel")
public Result<?> bindInfoSourceLabel(@RequestBody SubjectSourceTagVO subjectSourceTagVO) { public Result<?> bindInfoSourceLabel(@RequestBody SubjectSourceTagVO subjectSourceTagVO) {
List<InfoSourceLabelVO> labelList = subjectSourceTagVO.getLabelList(); List<InfoSourceLabelVO> labelList = subjectSourceTagVO.getLabelList();
if (CollectionUtils.isEmpty(labelList)) {
return Result.OK();
}
String subjectId = subjectSourceTagVO.getSubjectId(); String subjectId = subjectSourceTagVO.getSubjectId();
if (StringUtils.isEmpty(subjectId)) { if (StringUtils.isEmpty(subjectId)) {
return Result.FAIL("专题id不能为空"); return Result.FAIL("专题id不能为空");
} }
//支持全部删除
//不管有没有传值,先删后增
LambdaQueryWrapper<SubjectInfoSourceMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(SubjectInfoSourceMap::getSubjectId, subjectId).eq(SubjectInfoSourceMap::getType, 12);
int count = subjectInfoSourceMapService.count(queryWrapper);
if (count > 0) {
subjectInfoSourceMapService.remove(queryWrapper);
}
List<SubjectInfoSourceMap> dataList = new ArrayList<>(); List<SubjectInfoSourceMap> dataList = new ArrayList<>();
for (InfoSourceLabelVO infoSourceLabelVO : labelList) { for (InfoSourceLabelVO infoSourceLabelVO : labelList) {
List<InfoSourceLabelItemVO> infoSourceLabelItemList = infoSourceLabelVO.getInfoSourceLabelItemList(); List<InfoSourceLabelItemVO> infoSourceLabelItemList = infoSourceLabelVO.getInfoSourceLabelItemList();
...@@ -931,13 +937,9 @@ public class SubjectManageController { ...@@ -931,13 +937,9 @@ public class SubjectManageController {
dataList.add(subjectInfoSourceMap); dataList.add(subjectInfoSourceMap);
} }
} }
LambdaQueryWrapper<SubjectInfoSourceMap> queryWrapper = Wrappers.lambdaQuery(); if (CollectionUtils.isNotEmpty(dataList)) {
queryWrapper.eq(SubjectInfoSourceMap::getSubjectId, subjectId).eq(SubjectInfoSourceMap::getType, 12); subjectInfoSourceMapService.saveBatch(dataList);
int count = subjectInfoSourceMapService.count(queryWrapper);
if (count > 0) {
subjectInfoSourceMapService.remove(queryWrapper);
} }
subjectInfoSourceMapService.saveBatch(dataList);
//同步配置到采集 //同步配置到采集
configurationMessageService.bindInfoSourceSend(subjectId); configurationMessageService.bindInfoSourceSend(subjectId);
return Result.OK(); return Result.OK();
......
package com.zzsn.event.controller.common; package com.zzsn.event.controller.common;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
...@@ -9,6 +10,7 @@ import com.zzsn.event.entity.Subject; ...@@ -9,6 +10,7 @@ import com.zzsn.event.entity.Subject;
import com.zzsn.event.entity.SysDictItem; import com.zzsn.event.entity.SysDictItem;
import com.zzsn.event.es.EsService; import com.zzsn.event.es.EsService;
import com.zzsn.event.service.*; import com.zzsn.event.service.*;
import com.zzsn.event.util.CalculateUtil;
import com.zzsn.event.util.DateUtil; import com.zzsn.event.util.DateUtil;
import com.zzsn.event.vo.*; import com.zzsn.event.vo.*;
import com.zzsn.event.vo.es.Label; import com.zzsn.event.vo.es.Label;
...@@ -18,10 +20,9 @@ import org.apache.commons.collections4.MapUtils; ...@@ -18,10 +20,9 @@ import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.time.ZoneId;
import java.util.HashMap; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -46,6 +47,8 @@ public class StatisticalAnalysisController { ...@@ -46,6 +47,8 @@ public class StatisticalAnalysisController {
private ClbLabelService clbLabelService; private ClbLabelService clbLabelService;
@Autowired @Autowired
private InformationService informationService; private InformationService informationService;
@Autowired
private CommonService commonService;
/** /**
* 概述分析 * 概述分析
...@@ -92,7 +95,7 @@ public class StatisticalAnalysisController { ...@@ -92,7 +95,7 @@ public class StatisticalAnalysisController {
} }
} }
//补充数据 //补充数据
supplyData(countList,bindLabelList,labelMap); supplyData(countList, bindLabelList, labelMap);
overviewAnalysisVO.setInfoCount(totalCount); overviewAnalysisVO.setInfoCount(totalCount);
overviewAnalysisVO.setCountList(countList); overviewAnalysisVO.setCountList(countList);
return Result.OK(overviewAnalysisVO); return Result.OK(overviewAnalysisVO);
...@@ -201,10 +204,10 @@ public class StatisticalAnalysisController { ...@@ -201,10 +204,10 @@ public class StatisticalAnalysisController {
public Result<?> dataSource(@RequestBody InfoDataSearchCondition searchCondition) { public Result<?> dataSource(@RequestBody InfoDataSearchCondition searchCondition) {
List<CountVO> dataList = new ArrayList<>(); List<CountVO> dataList = new ArrayList<>();
List<Label> bindLabelList = bindLabelList(searchCondition.getSubjectId()); List<Label> bindLabelList = bindLabelList(searchCondition.getSubjectId());
Map<String, Label> labelMap = bindLabelList.stream().collect(Collectors.toMap(label-> label.getLabelMark() + "-"+label.getRelationId(), label -> label)); Map<String, Label> labelMap = bindLabelList.stream().collect(Collectors.toMap(label -> label.getLabelMark() + "-" + label.getRelationId(), label -> label));
if (CollectionUtils.isEmpty(searchCondition.getIds()) && searchCondition.getNum() == null) { if (CollectionUtils.isEmpty(searchCondition.getIds()) && searchCondition.getNum() == null) {
List<String> includeValues = new ArrayList<>(); List<String> includeValues = new ArrayList<>();
bindLabelList.forEach(e -> includeValues.add(e.getLabelMark() + "-" +e.getRelationId())); bindLabelList.forEach(e -> includeValues.add(e.getLabelMark() + "-" + e.getRelationId()));
searchCondition.setIncludeValues(includeValues.toArray(new String[0])); searchCondition.setIncludeValues(includeValues.toArray(new String[0]));
dataList = esService.groupByInfoSourceTag(searchCondition); dataList = esService.groupByInfoSourceTag(searchCondition);
} else { } else {
...@@ -226,8 +229,6 @@ public class StatisticalAnalysisController { ...@@ -226,8 +229,6 @@ public class StatisticalAnalysisController {
} }
/** /**
* 资讯数量top的信息源统计 * 资讯数量top的信息源统计
* *
...@@ -375,4 +376,127 @@ public class StatisticalAnalysisController { ...@@ -375,4 +376,127 @@ public class StatisticalAnalysisController {
} }
} }
} }
/*--------------------------------------------以下为【统战部】风险评估页面接口---------------------------------------------------------*/
/**
* 单个国家统计
*
* @param subjectId 专题id
* @param country 国家名称
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2025/6/7
*/
@GetMapping("/singleCcountryStatistic")
public Result<?> singleCountryStatistic(@RequestParam String subjectId, @RequestParam String country,
@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime) {
List<Map<String, Object>> maps = esService.singleCountryStatistic(subjectId, country, startTime, endTime);
return Result.OK(maps);
}
/**
* 按国家统计
*
* @param subjectId 专题id
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2025/6/7
*/
@GetMapping("/countryStatistic")
public Result<?> countryStatistic(@RequestParam String subjectId,
@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime) {
List<CountVO> countVOS = esService.countryStatistic(subjectId, startTime, endTime);
return Result.OK(countVOS);
}
/**
* 按风险统计
*
* @param subjectId 专题id
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2025/6/7
*/
@GetMapping("/riskTypeStatistic")
public Result<?> riskTypeStatistic(@RequestParam String subjectId,
@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime) {
List<CountVO> countVOS = esService.riskTypeStatistic(subjectId, startTime, endTime);
return Result.OK(countVOS);
}
/**
* 按月统计(默认近一年)
*
* @param subjectId 专题id
* @author lkg
* @date 2025/6/10
*/
@GetMapping("/monthStatistic")
public Result<?> monthStatistic(@RequestParam String subjectId) {
DateTime startDateTime = cn.hutool.core.date.DateUtil.offsetMonth(new Date(), -13);
String startTime = startDateTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().withDayOfMonth(1).toLocalDate().atStartOfDay().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
String endTime = cn.hutool.core.date.DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
List<CountVO> countVOS = esService.groupByMonth(subjectId, startTime, endTime);
List<String> months = DateUtil.getMonthsBetween(startTime, endTime);
for (String month : months) {
boolean exist = countVOS.stream().anyMatch(e -> month.equals(e.getName()));
if (!exist) {
CountVO countVO = new CountVO();
countVO.setName(month);
countVO.setValue(0L);
countVOS.add(countVO);
}
}
countVOS.sort(Comparator.comparing(CountVO::getName));
for (int i = 1; i < countVOS.size(); i++) {
CountVO before = countVOS.get(i - 1);
CountVO current = countVOS.get(i);
if (before.getValue() == 0) {
current.setPercentage("0");
} else {
long subtract = current.getValue() - before.getValue();
String divide = CalculateUtil.divide(String.valueOf(subtract), String.valueOf(before.getValue()), 2);
current.setPercentage(divide);
}
}
countVOS.remove(0);
return Result.OK(countVOS);
}
/**
* 数据源统计
*
* @param subjectId 专题id
* @author lkg
* @date 2025/6/10
*/
@GetMapping("/sourceStatistic")
public Result<?> sourceStatistic(@RequestParam String subjectId) {
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> sourceTypeMap = new HashMap<>();
sourceTypeMap.put("value", 4);
sourceTypeMap.put("name", "数据源类型");
dataList.add(sourceTypeMap);
List<String> subjectIds = new ArrayList<>();
subjectIds.add(subjectId);
Map<String, Object> sourceNumMap = new HashMap<>();
Map<String, Integer> sourceCountMap = commonService.bindSourceCount(subjectIds);
sourceNumMap.put("value", sourceCountMap.get(subjectId));
sourceNumMap.put("name", "信息源个数");
dataList.add(sourceNumMap);
Map<String, Object> collectNumMap = new HashMap<>();
int collectCount = esService.currentCollectCount(subjectId);
collectNumMap.put("value", collectCount);
collectNumMap.put("name", "今日采集量");
dataList.add(collectNumMap);
return Result.OK(dataList);
}
} }
...@@ -140,13 +140,14 @@ public class SubjectTypeController { ...@@ -140,13 +140,14 @@ public class SubjectTypeController {
public Result<?> subjectAndTypeTree(@RequestParam(required = false) Integer facePublic, public Result<?> subjectAndTypeTree(@RequestParam(required = false) Integer facePublic,
@RequestParam(required = false) String environment, @RequestParam(required = false) String environment,
@RequestParam(required = false) String flagCode, @RequestParam(required = false) String flagCode,
@RequestParam(defaultValue = "1") Integer subjectType,
HttpServletRequest request) { HttpServletRequest request) {
UserVo loginUser = UserUtil.getLoginUser(); UserVo loginUser = UserUtil.getLoginUser();
List<SubjectTreeVO> dataList = null; List<SubjectTreeVO> dataList = null;
if (facePublic == null) { if (facePublic == null) {
dataList = subjectTypeService.subjectAndTypeTree(environment); dataList = subjectTypeService.subjectAndTypeTree(subjectType,environment);
} else if (facePublic == 1) { } else if (facePublic == 1) {
dataList = subjectTypeService.subjectsByFacePublic(facePublic,environment,loginUser.getUsername(),flagCode,request); dataList = subjectTypeService.subjectsByFacePublic(subjectType,facePublic,environment,loginUser.getUsername(),flagCode,request);
} }
return Result.OK(dataList); return Result.OK(dataList);
} }
......
...@@ -42,6 +42,7 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms; ...@@ -42,6 +42,7 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.search.sort.SortOrder;
import org.jsoup.Jsoup;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -358,6 +359,10 @@ public class ReportDataController { ...@@ -358,6 +359,10 @@ public class ReportDataController {
for (SearchHit hit : searchHits) { for (SearchHit hit : searchHits) {
String queryInfo = hit.getSourceAsString(); String queryInfo = hit.getSourceAsString();
ReportDataVO info = JSONUtil.toBean(queryInfo, ReportDataVO.class); ReportDataVO info = JSONUtil.toBean(queryInfo, ReportDataVO.class);
String summary = info.getSummary();
if (StringUtils.isNotEmpty(summary)) {
info.setSummary(Jsoup.parse(summary).text());
}
info.setPublishDate(EsDateUtil.esFieldDateMapping(info.getPublishDate())); info.setPublishDate(EsDateUtil.esFieldDateMapping(info.getPublishDate()));
info.setCreateDate(EsDateUtil.esFieldDateMapping(info.getCreateDate())); info.setCreateDate(EsDateUtil.esFieldDateMapping(info.getCreateDate()));
list.add(info); list.add(info);
......
package com.zzsn.event.es; package com.zzsn.event.es;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.net.URLDecoder; import cn.hutool.core.net.URLDecoder;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
...@@ -9,10 +10,12 @@ import com.alibaba.fastjson2.JSONObject; ...@@ -9,10 +10,12 @@ import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cronutils.model.field.expression.On;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import com.zzsn.event.constant.Constants; import com.zzsn.event.constant.Constants;
import com.zzsn.event.entity.Event; import com.zzsn.event.entity.Event;
import com.zzsn.event.entity.Subject; import com.zzsn.event.entity.Subject;
import com.zzsn.event.entity.SysDictItem;
import com.zzsn.event.service.*; import com.zzsn.event.service.*;
import com.zzsn.event.util.*; import com.zzsn.event.util.*;
import com.zzsn.event.util.tree.Node; import com.zzsn.event.util.tree.Node;
...@@ -94,6 +97,8 @@ public class EsService { ...@@ -94,6 +97,8 @@ public class EsService {
private CommonService commonService; private CommonService commonService;
@Autowired @Autowired
private EsOpUtil esOpUtil; private EsOpUtil esOpUtil;
@Autowired
private SysDictItemService sysDictItemService;
/** /**
* 获取专题下的资讯 * 获取专题下的资讯
...@@ -869,6 +874,8 @@ public class EsService { ...@@ -869,6 +874,8 @@ public class EsService {
for (SearchHit hit : searchHits) { for (SearchHit hit : searchHits) {
String queryInfo = hit.getSourceAsString(); String queryInfo = hit.getSourceAsString();
SpecialInformation info = JSONUtil.toBean(queryInfo, SpecialInformation.class); SpecialInformation info = JSONUtil.toBean(queryInfo, SpecialInformation.class);
info.setPublishDate(EsDateUtil.esFieldDateMapping(info.getPublishDate()));
info.setCreateDate(EsDateUtil.esFieldDateMapping(info.getCreateDate()));
info.setDbIndex(hit.getIndex()); info.setDbIndex(hit.getIndex());
info.setIndex(hit.getIndex()); info.setIndex(hit.getIndex());
list.add(info); list.add(info);
...@@ -1856,12 +1863,12 @@ public class EsService { ...@@ -1856,12 +1863,12 @@ public class EsService {
* *
* @param subjectIds 专题id集合 * @param subjectIds 专题id集合
* @param auditStatus 审核状态-平台(null-全部;1-通过;2-未审核;3-暂定;4-删除;5-免审核) * @param auditStatus 审核状态-平台(null-全部;1-通过;2-未审核;3-暂定;4-删除;5-免审核)
* @param auditStatus 审核状态-研究中心(0-全部;1-模型推荐;2-精选;3-待定;4-移除) * @param status 审核状态-研究中心(0-全部;1-模型推荐;2-精选;3-待定;4-移除)
* @param type 是否多层聚合(先按专题,再按发布时间) * @param type 是否多层聚合(先按专题,再按发布时间)
* @author lkg * @author lkg
* @date 2025/3/25 * @date 2025/3/25
*/ */
public List<StatisticVO> subjectStatisticInfo(List<String> subjectIds, Integer auditStatus,Integer status, Integer type) { public List<StatisticVO> subjectStatisticInfo(List<String> subjectIds, Integer auditStatus, Integer status, Integer type) {
List<StatisticVO> list = new ArrayList<>(); List<StatisticVO> list = new ArrayList<>();
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX); SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
...@@ -2075,7 +2082,7 @@ public class EsService { ...@@ -2075,7 +2082,7 @@ public class EsService {
public BoolQueryBuilder buildQuery(InfoDataSearchCondition searchCondition, List<String> subjectIdList) { public BoolQueryBuilder buildQuery(InfoDataSearchCondition searchCondition, List<String> subjectIdList) {
//判断是否需要查询发布时间为空的数据 //判断是否需要查询发布时间为空的数据
boolean timeFlag = false; boolean timeFlag = false;
if(StringUtils.isEmpty(searchCondition.getStartTime()) && StringUtils.isEmpty(searchCondition.getEndTime())) { if (StringUtils.isEmpty(searchCondition.getStartTime()) && StringUtils.isEmpty(searchCondition.getEndTime())) {
//前端没有穿时间参数时,需要查询发布时间为空的数据 //前端没有穿时间参数时,需要查询发布时间为空的数据
timeFlag = true; timeFlag = true;
} }
...@@ -2115,13 +2122,13 @@ public class EsService { ...@@ -2115,13 +2122,13 @@ public class EsService {
} }
} }
//时间过滤筛选-专题配置 //时间过滤筛选-专题配置
if (StringUtils.isNotEmpty(configStartTime) && (StringUtils.isEmpty(searchCondition.getStartTime())||configStartTime.compareTo(searchCondition.getStartTime())>0)) { if (StringUtils.isNotEmpty(configStartTime) && (StringUtils.isEmpty(searchCondition.getStartTime()) || configStartTime.compareTo(searchCondition.getStartTime()) > 0)) {
searchCondition.setStartTime(configStartTime); searchCondition.setStartTime(configStartTime);
} }
if(StringUtils.isEmpty(configEndTime)){ if (StringUtils.isEmpty(configEndTime)) {
configEndTime = EsDateUtil.esFieldDateFormat(DateUtil.dateToString(new Date())); configEndTime = EsDateUtil.esFieldDateFormat(DateUtil.dateToString(new Date()));
} }
if (StringUtils.isEmpty(searchCondition.getEndTime())||configEndTime.compareTo(searchCondition.getEndTime())<0) { if (StringUtils.isEmpty(searchCondition.getEndTime()) || configEndTime.compareTo(searchCondition.getEndTime()) < 0) {
searchCondition.setEndTime(configEndTime); searchCondition.setEndTime(configEndTime);
} }
} }
...@@ -2174,11 +2181,33 @@ public class EsService { ...@@ -2174,11 +2181,33 @@ public class EsService {
} }
//资讯状态-研究中心(0-全部;1-模型推荐;2-精选;3-待定;4-移除),和checkStatus、deleteFlag、isFreeCheck互斥 //资讯状态-研究中心(0-全部;1-模型推荐;2-精选;3-待定;4-移除),和checkStatus、deleteFlag、isFreeCheck互斥
Integer status = searchCondition.getStatus(); Integer status = searchCondition.getStatus();
List<Integer> excludeStatus = searchCondition.getExcludeStatus();
if (status != null) { if (status != null) {
if (status == 1) { if (status == 0) {
boolQuery.must(QueryBuilders.termQuery("checkStatus", 0)); if (CollectionUtils.isNotEmpty(excludeStatus)) {
if (excludeStatus.contains(2)) {
boolQuery.mustNot(QueryBuilders.termQuery("checkStatus", 1));
}
if (excludeStatus.contains(3)) {
boolQuery.mustNot(QueryBuilders.termQuery("checkStatus", 3));
}
if (excludeStatus.contains(4)) {
boolQuery.mustNot(QueryBuilders.termQuery("deleteFlag", 1));
}
}
} else if (status == 1) {
boolQuery.must(QueryBuilders.termQuery("isFreeCheck", 1)); boolQuery.must(QueryBuilders.termQuery("isFreeCheck", 1));
boolQuery.mustNot(QueryBuilders.termQuery("deleteFlag", 1)); if (CollectionUtils.isNotEmpty(excludeStatus)) {
if (excludeStatus.contains(2)) {
boolQuery.mustNot(QueryBuilders.termQuery("checkStatus", 1));
}
if (excludeStatus.contains(3)) {
boolQuery.mustNot(QueryBuilders.termQuery("checkStatus", 3));
}
if (excludeStatus.contains(4)) {
boolQuery.mustNot(QueryBuilders.termQuery("deleteFlag", 1));
}
}
} else if (status == 2) { } else if (status == 2) {
boolQuery.must(QueryBuilders.termQuery("checkStatus", 1)); boolQuery.must(QueryBuilders.termQuery("checkStatus", 1));
boolQuery.mustNot(QueryBuilders.termQuery("deleteFlag", 1)); boolQuery.mustNot(QueryBuilders.termQuery("deleteFlag", 1));
...@@ -2282,7 +2311,7 @@ public class EsService { ...@@ -2282,7 +2311,7 @@ public class EsService {
configDateQueryBuilder.must(QueryBuilders.rangeQuery("publishDate").lte(EsDateUtil.esFieldDateFormat(DateUtil.dateToString(new Date())))); configDateQueryBuilder.must(QueryBuilders.rangeQuery("publishDate").lte(EsDateUtil.esFieldDateFormat(DateUtil.dateToString(new Date()))));
} }
publishDateQueryBuilder.should(configDateQueryBuilder); publishDateQueryBuilder.should(configDateQueryBuilder);
if(timeFlag){ if (timeFlag) {
publishDateQueryBuilder.should(QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery("publishDate"))); publishDateQueryBuilder.should(QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery("publishDate")));
} }
boolQuery.must(publishDateQueryBuilder); boolQuery.must(publishDateQueryBuilder);
...@@ -2798,4 +2827,255 @@ public class EsService { ...@@ -2798,4 +2827,255 @@ public class EsService {
jsonObject.put("updateDate", EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime())); jsonObject.put("updateDate", EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
esOpUtil.docUpdateById(index, id, jsonObject.toString()); esOpUtil.docUpdateById(index, id, jsonObject.toString());
} }
public List<Map<String,Object>> singleCountryStatistic(String subjectId,String country, String startTime, String endTime) {
List<Map<String,Object>> dataList = new ArrayList<>();
//根据地区的id从ES查询相关的记录
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.trackTotalHits(true);
searchSourceBuilder.size(0);
//创建查询对象
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
boolQuery.must(QueryBuilders.termQuery("subjectId.keyword", subjectId));
List<SysDictItem> countryItemList = sysDictItemService.listByDictCode("article_tzb_guojia");
Optional<SysDictItem> first = countryItemList.stream().filter(item -> item.getItemText().equals(country)).findFirst();
if (first.isPresent()) {
String countryId = first.get().getId();
TermQueryBuilder termQueryBuilder = QueryBuilders.termQuery("labels.relationId", countryId);
boolQuery.must(QueryBuilders.nestedQuery("labels", termQueryBuilder, ScoreMode.None));
} else {
MatchQueryBuilder matchQueryBuilder = QueryBuilders.matchQuery("labels.relationName", country);
boolQuery.must(QueryBuilders.nestedQuery("labels", matchQueryBuilder, ScoreMode.None));
}
//统计没有删除的
boolQuery.mustNot(QueryBuilders.matchQuery("deleteFlag", "1"));
if (StringUtils.isNotEmpty(startTime) || StringUtils.isNotEmpty(endTime)) {
RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery("publishDate");
if (StringUtils.isNotEmpty(startTime)) {
rangeQueryBuilder.gte(EsDateUtil.esFieldDateFormat(startTime));
}
if (StringUtils.isNotEmpty(endTime)) {
rangeQueryBuilder.lte(EsDateUtil.esFieldDateFormat(endTime));
}
boolQuery.filter(rangeQueryBuilder);
}
searchSourceBuilder.query(boolQuery);
List<SysDictItem> riskTypeItemList = sysDictItemService.listByDictCode("article_risk_type");
Map<String, String> riskTypeMap = riskTypeItemList.stream().collect(Collectors.toMap(SysDictItem::getId, SysDictItem::getItemText));
NestedAggregationBuilder nestedAggregationBuilder = AggregationBuilders.nested("labels", "labels")
.subAggregation(AggregationBuilders.terms("group_risk")
.field("labels.relationId")
.size(1)
.order(BucketOrder.count(false))
.includeExclude(new IncludeExclude(riskTypeItemList.stream().map(SysDictItem::getId).toArray(String[]::new), null)));
searchSourceBuilder.aggregation(nestedAggregationBuilder);
searchRequest.source(searchSourceBuilder);
try {
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
long totalCount = searchResponse.getHits().getTotalHits().value;
Map<String, Object> countMap = new HashMap<>();
countMap.put("name", "风险事件");
countMap.put("value", totalCount);
dataList.add(countMap);
Aggregations aggregations = searchResponse.getAggregations();
ParsedNested labels = aggregations.get("labels");
Aggregations labelsAggregations = labels.getAggregations();
Terms groupCountry = labelsAggregations.get("group_risk");
List<? extends Terms.Bucket> buckets = groupCountry.getBuckets();
String mainRiskType = riskTypeMap.get(buckets.get(0).getKeyAsString());
Map<String, Object> riskMap = new HashMap<>();
riskMap.put("name", "主要风险");
riskMap.put("value", mainRiskType);
dataList.add(riskMap);
} catch (Exception e) {
e.printStackTrace();
}
return dataList;
}
public List<CountVO> countryStatistic(String subjectId, String startTime, String endTime) {
List<CountVO> countList = new ArrayList<>();
//根据地区的id从ES查询相关的记录
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.trackTotalHits(true);
searchSourceBuilder.size(0);
//创建查询对象
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
boolQuery.must(QueryBuilders.termQuery("subjectId.keyword", subjectId));
//统计没有删除的
boolQuery.mustNot(QueryBuilders.matchQuery("deleteFlag", "1"));
if (StringUtils.isNotEmpty(startTime) || StringUtils.isNotEmpty(endTime)) {
RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery("publishDate");
if (StringUtils.isNotEmpty(startTime)) {
rangeQueryBuilder.gte(EsDateUtil.esFieldDateFormat(startTime));
}
if (StringUtils.isNotEmpty(endTime)) {
rangeQueryBuilder.lte(EsDateUtil.esFieldDateFormat(endTime));
}
boolQuery.filter(rangeQueryBuilder);
}
searchSourceBuilder.query(boolQuery);
List<SysDictItem> countryItemList = sysDictItemService.listByDictCode("article_tzb_guojia");
Map<String, String> countryMap = countryItemList.stream().collect(Collectors.toMap(SysDictItem::getId, SysDictItem::getItemText));
NestedAggregationBuilder nestedAggregationBuilder = AggregationBuilders.nested("labels", "labels")
.subAggregation(AggregationBuilders.terms("group_country")
.field("labels.relationId")
.size(countryItemList.size())
.includeExclude(new IncludeExclude(countryItemList.stream().map(SysDictItem::getId).toArray(String[]::new), null)));
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 groupCountry = labelsAggregations.get("group_country");
List<? extends Terms.Bucket> buckets = groupCountry.getBuckets();
for (Terms.Bucket bucket : buckets) {
CountVO countVO = new CountVO();
String key = bucket.getKeyAsString();
countVO.setName(countryMap.get(key));
countVO.setValue(bucket.getDocCount());
countList.add(countVO);
}
} catch (Exception e) {
e.printStackTrace();
}
return countList;
}
public List<CountVO> riskTypeStatistic(String subjectId, String startTime, String endTime) {
List<CountVO> countList = new ArrayList<>();
//根据地区的id从ES查询相关的记录
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.trackTotalHits(true);
searchSourceBuilder.size(0);
//创建查询对象
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
boolQuery.must(QueryBuilders.termQuery("subjectId.keyword", subjectId));
//统计没有删除的
boolQuery.mustNot(QueryBuilders.matchQuery("deleteFlag", "1"));
if (StringUtils.isNotEmpty(startTime) || StringUtils.isNotEmpty(endTime)) {
RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery("publishDate");
if (StringUtils.isNotEmpty(startTime)) {
rangeQueryBuilder.gte(EsDateUtil.esFieldDateFormat(startTime));
}
if (StringUtils.isNotEmpty(endTime)) {
rangeQueryBuilder.lte(EsDateUtil.esFieldDateFormat(endTime));
}
boolQuery.filter(rangeQueryBuilder);
}
searchSourceBuilder.query(boolQuery);
List<SysDictItem> riskTypeItemList = sysDictItemService.listByDictCode("article_risk_type");
Map<String, String> map = riskTypeItemList.stream().collect(Collectors.toMap(SysDictItem::getId, SysDictItem::getItemText));
NestedAggregationBuilder nestedAggregationBuilder = AggregationBuilders.nested("labels", "labels")
.subAggregation(AggregationBuilders.terms("group_risk")
.field("labels.relationId")
.size(riskTypeItemList.size())
.includeExclude(new IncludeExclude(riskTypeItemList.stream().map(SysDictItem::getId).toArray(String[]::new), null))
);
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 groupRisk = labelsAggregations.get("group_risk");
List<? extends Terms.Bucket> buckets = groupRisk.getBuckets();
for (Terms.Bucket bucket : buckets) {
CountVO countVO = new CountVO();
String key = bucket.getKeyAsString();
countVO.setName(map.get(key));
countVO.setValue(bucket.getDocCount());
countList.add(countVO);
}
} catch (Exception e) {
e.printStackTrace();
}
return countList;
}
public List<CountVO> groupByMonth(String subjectId, String startTime, String endTime) {
List<CountVO> countList = new ArrayList<>();
//根据地区的id从ES查询相关的记录
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.trackTotalHits(true);
searchSourceBuilder.size(0);
//创建查询对象
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
boolQuery.must(QueryBuilders.termQuery("subjectId.keyword", subjectId));
//统计没有删除的
boolQuery.mustNot(QueryBuilders.matchQuery("deleteFlag", "1"));
if (StringUtils.isNotEmpty(startTime) || StringUtils.isNotEmpty(endTime)) {
RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery("publishDate");
if (StringUtils.isNotEmpty(startTime)) {
rangeQueryBuilder.gte(EsDateUtil.esFieldDateFormat(startTime));
}
if (StringUtils.isNotEmpty(endTime)) {
rangeQueryBuilder.lte(EsDateUtil.esFieldDateFormat(endTime));
}
boolQuery.filter(rangeQueryBuilder);
}
searchSourceBuilder.query(boolQuery);
DateHistogramAggregationBuilder aggregationBuilder = AggregationBuilders.dateHistogram("groupMonth")
.field("publishDate")
.calendarInterval(DateHistogramInterval.MONTH)
.format("yyyy-MM");
searchSourceBuilder.aggregation(aggregationBuilder);
searchRequest.source(searchSourceBuilder);
try {
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
Aggregations aggregations = searchResponse.getAggregations();
ParsedDateHistogram parsedDateHistogram = aggregations.get("groupMonth");
List<? extends Histogram.Bucket> buckets = parsedDateHistogram.getBuckets();
for (Histogram.Bucket bucket : buckets) {
CountVO countVO = new CountVO();
countVO.setName(bucket.getKeyAsString());
countVO.setValue(bucket.getDocCount());
countList.add(countVO);
}
} catch (Exception e) {
e.printStackTrace();
}
return countList;
}
/**
* 今日采集量
*
* @param subjectId 专题id
* @author lkg
* @date 2025/6/7
*/
public int currentCollectCount(String subjectId) {
long count = 0L;
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//创建查询对象
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
boolQuery.must(QueryBuilders.termQuery("subjectIds", subjectId));
DateTime beginOfDay = cn.hutool.core.date.DateUtil.beginOfDay(new Date());
boolQuery.filter(QueryBuilders.rangeQuery("createDate").gte(EsDateUtil.esFieldDateFormat(DateUtil.format(beginOfDay, "yyyy-MM-dd HH:mm:ss"))));
SearchRequest searchRequest = new SearchRequest(EsIndexUtil.getIndexYear(Constants.COLLECT_MIDDLE_INDEX));
//默认最大数量是10000,设置为true后,显示准确数量
searchSourceBuilder.trackTotalHits(true);
searchSourceBuilder.query(boolQuery);
searchRequest.source(searchSourceBuilder);
SearchResponse searchResponse;
try {
searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
count = searchResponse.getHits().getTotalHits().value;
} catch (Exception e) {
log.info("获取专题-{}-下资讯,查询es库失败", subjectId);
e.printStackTrace();
}
return (int) count;
}
} }
...@@ -33,14 +33,14 @@ public interface SubjectMapper extends BaseMapper<Subject> { ...@@ -33,14 +33,14 @@ public interface SubjectMapper extends BaseMapper<Subject> {
Page<SubjectPage> pageList(@Param("subjectCondition") SubjectCondition subjectCondition, Page<SubjectPage> page); Page<SubjectPage> pageList(@Param("subjectCondition") SubjectCondition subjectCondition, Page<SubjectPage> page);
/** /**
*专题分页列表-新 * 专题分页列表-新
* *
* @param subjectCondition 查询条件 * @param subjectCondition 查询条件
* @param page 分页参数 * @param page 分页参数
* @author lkg * @author lkg
* @date 2025/3/25 * @date 2025/3/25
*/ */
Page<SubjectPageVO> pageList_new(Page<SubjectPageVO> page,@Param("subjectCondition") SubjectCondition subjectCondition,@Param("userId") String userId); Page<SubjectPageVO> pageList_new(Page<SubjectPageVO> page, @Param("subjectCondition") SubjectCondition subjectCondition, @Param("userId") String userId);
/** /**
* 专题详情(包含专题分类、专题项目) * 专题详情(包含专题分类、专题项目)
...@@ -50,6 +50,7 @@ public interface SubjectMapper extends BaseMapper<Subject> { ...@@ -50,6 +50,7 @@ public interface SubjectMapper extends BaseMapper<Subject> {
* @date 2025/3/25 * @date 2025/3/25
*/ */
SubjectPage getInfo(@Param("subjectId") String subjectId); SubjectPage getInfo(@Param("subjectId") String subjectId);
/** /**
* 专题分页列表(个人)-研究中心 * 专题分页列表(个人)-研究中心
* *
...@@ -68,7 +69,7 @@ public interface SubjectMapper extends BaseMapper<Subject> { ...@@ -68,7 +69,7 @@ public interface SubjectMapper extends BaseMapper<Subject> {
* @author lkg * @author lkg
* @date 2025/1/14 * @date 2025/1/14
*/ */
Page<SubjectPage> researchCenterFacePageList(@Param("subjectCondition") SubjectCondition subjectCondition, Page<SubjectPage> page,@Param("sql") String sql,@Param("username") String username); Page<SubjectPage> researchCenterFacePageList(@Param("subjectCondition") SubjectCondition subjectCondition, Page<SubjectPage> page, @Param("sql") String sql, @Param("username") String username);
/** /**
* 当前用户可见的专题分页列表(公开和个人非公开)-研究中心 * 当前用户可见的专题分页列表(公开和个人非公开)-研究中心
...@@ -76,11 +77,12 @@ public interface SubjectMapper extends BaseMapper<Subject> { ...@@ -76,11 +77,12 @@ public interface SubjectMapper extends BaseMapper<Subject> {
* @param username 用户名称 * @param username 用户名称
* @param type 分类(1-个人;2-公开;3-个人+公开) * @param type 分类(1-个人;2-公开;3-个人+公开)
* @param subjectName 专题名称 * @param subjectName 专题名称
* @param subjectType 专题类别(1:通用专题;3:研究中心主题专题[复合专题])
* @param page 分页参数 * @param page 分页参数
* @author lkg * @author lkg
* @date 2025/2/8 * @date 2025/2/8
*/ */
Page<Node> visibleList(@Param("username") String username, @Param("type") Integer type, @Param("subjectName") String subjectName, Page<String> page,@Param("environment") String environment,@Param("sql") String sql); Page<Node> visibleList(@Param("username") String username, @Param("type") Integer type, @Param("subjectName") String subjectName, @Param("subjectType") Integer subjectType, Page<String> page, @Param("environment") String environment, @Param("sql") String sql);
/** /**
* 获取专题详情(包含样例文章信息) * 获取专题详情(包含样例文章信息)
...@@ -120,7 +122,7 @@ public interface SubjectMapper extends BaseMapper<Subject> { ...@@ -120,7 +122,7 @@ public interface SubjectMapper extends BaseMapper<Subject> {
*/ */
int ynBelowExcludeGroup(@Param("subjectId") String subjectId, @Param("sourceId") String sourceId); int ynBelowExcludeGroup(@Param("subjectId") String subjectId, @Param("sourceId") String sourceId);
List<String> getBindSubjectIds(@Param("id")String id); List<String> getBindSubjectIds(@Param("id") String id);
String getMinCreateTime(@Param("subjectIdList") List<String> subjectIdList); String getMinCreateTime(@Param("subjectIdList") List<String> subjectIdList);
} }
...@@ -78,7 +78,7 @@ public interface SubjectTypeMapper extends BaseMapper<SubjectType> { ...@@ -78,7 +78,7 @@ public interface SubjectTypeMapper extends BaseMapper<SubjectType> {
* @author lkg * @author lkg
* @date 2025/1/7 * @date 2025/1/7
*/ */
List<SubjectTreeVO> subjectsByFacePublic(@Param("facePublic") Integer facePublic,@Param("environment") String environment,@Param("username") String username List<SubjectTreeVO> subjectsByFacePublic(@Param("subjectType") Integer subjectType,@Param("facePublic") Integer facePublic,@Param("environment") String environment,@Param("username") String username
,@Param("sql") String sql); ,@Param("sql") String sql);
/** /**
...@@ -87,7 +87,7 @@ public interface SubjectTypeMapper extends BaseMapper<SubjectType> { ...@@ -87,7 +87,7 @@ public interface SubjectTypeMapper extends BaseMapper<SubjectType> {
* @author lkg * @author lkg
* @date 2024/4/29 * @date 2024/4/29
*/ */
List<SubjectTreeVO> subjectAndTypeTree(@Param("username") String createBy,@Param("environment") String environment); List<SubjectTreeVO> subjectAndTypeTree(@Param("subjectType") Integer subjectType,@Param("username") String createBy,@Param("environment") String environment);
/** /**
* 获取分类下的专题列表 * 获取分类下的专题列表
......
...@@ -45,9 +45,10 @@ ...@@ -45,9 +45,10 @@
</select> </select>
<select id="pageList_new" resultType="com.zzsn.event.vo.SubjectPageVO"> <select id="pageList_new" resultType="com.zzsn.event.vo.SubjectPageVO">
SELECT d.id,d.subject_name,d.status,d.data_scope, SELECT d.id,d.subject_code,d.subject_name,d.status,d.data_scope,
s.total_num,s.un_check_num,s.bind_source_num,s.bind_keyword_num,s.latest_data_date, s.total_num,s.un_check_num,s.bind_source_num,s.bind_keyword_num,s.latest_data_date,
c.type_name as subjectTypeName, g.project_name as projectName c.type_name as subjectTypeName, g.project_name as projectName,d.estimate_status,
d.create_by,d.create_time,d.update_by,d.update_time
from subject d from subject d
<if test="userId !=null and userId != ''"> <if test="userId !=null and userId != ''">
inner join sys_user_data_permission dp on d.id=dp.permission_id and dp.user_id = #{userId} inner join sys_user_data_permission dp on d.id=dp.permission_id and dp.user_id = #{userId}
...@@ -70,6 +71,9 @@ ...@@ -70,6 +71,9 @@
<if test="subjectCondition.subjectName!=null and subjectCondition.subjectName != ''"> <if test="subjectCondition.subjectName!=null and subjectCondition.subjectName != ''">
and d.subject_name like CONCAT('%',#{subjectCondition.subjectName},'%') and d.subject_name like CONCAT('%',#{subjectCondition.subjectName},'%')
</if> </if>
<if test="subjectCondition.subjectCode!=null and subjectCondition.subjectCode != ''">
and d.subject_code like CONCAT('%',#{subjectCondition.subjectCode},'%')
</if>
<if test="subjectCondition.status!=null"> <if test="subjectCondition.status!=null">
and d.status = #{subjectCondition.status} and d.status = #{subjectCondition.status}
</if> </if>
...@@ -189,6 +193,9 @@ ...@@ -189,6 +193,9 @@
<if test="subjectCondition.username!=null and subjectCondition.username != ''"> <if test="subjectCondition.username!=null and subjectCondition.username != ''">
and d.create_by = #{subjectCondition.username} and d.create_by = #{subjectCondition.username}
</if> </if>
<if test="subjectCondition.subjectType != null">
and d.subject_type = #{subjectCondition.subjectType}
</if>
order by d.create_time desc order by d.create_time desc
</select> </select>
<select id="researchCenterFacePageList" resultType="com.zzsn.event.vo.SubjectPage"> <select id="researchCenterFacePageList" resultType="com.zzsn.event.vo.SubjectPage">
...@@ -232,6 +239,9 @@ ...@@ -232,6 +239,9 @@
<if test="subjectCondition.status!=null"> <if test="subjectCondition.status!=null">
and d.status = #{subjectCondition.status} and d.status = #{subjectCondition.status}
</if> </if>
<if test="subjectCondition.subjectType!=null">
and d.subject_type = #{subjectCondition.subjectType}
</if>
order by d.create_time desc order by d.create_time desc
</select> </select>
...@@ -282,6 +292,9 @@ ...@@ -282,6 +292,9 @@
<if test="subjectName != null and subjectName != ''"> <if test="subjectName != null and subjectName != ''">
and subject_name like concat('%',#{subjectName},'%') and subject_name like concat('%',#{subjectName},'%')
</if> </if>
<if test="subjectType!=null">
and subject_type = #{subjectType}
</if>
<if test="environment != null and environment != ''"> <if test="environment != null and environment != ''">
and environment = #{environment} and environment = #{environment}
</if> </if>
......
...@@ -70,6 +70,9 @@ ...@@ -70,6 +70,9 @@
from subject s from subject s
where where
((s.face_public = #{facePublic} and s.create_by = #{username}) or (s.face_public = #{facePublic} and ${sql})) ((s.face_public = #{facePublic} and s.create_by = #{username}) or (s.face_public = #{facePublic} and ${sql}))
<if test="subjectType!=null">
and s.subject_type = #{subjectType}
</if>
<if test="environment!=null and environment != ''"> <if test="environment!=null and environment != ''">
and s.environment = #{environment} and s.environment = #{environment}
</if> </if>
...@@ -120,6 +123,9 @@ ...@@ -120,6 +123,9 @@
s.create_time s.create_time
from subject s from subject s
where 1 = 1 where 1 = 1
<if test="subjectType!=null">
and s.subject_type = #{subjectType}
</if>
<if test="username!=null and username != ''"> <if test="username!=null and username != ''">
and s.create_by = #{username} and s.create_by = #{username}
</if> </if>
......
...@@ -80,16 +80,18 @@ public interface ISubjectTypeService extends IService<SubjectType> { ...@@ -80,16 +80,18 @@ public interface ISubjectTypeService extends IService<SubjectType> {
* @author lkg * @author lkg
* @date 2025/1/7 * @date 2025/1/7
*/ */
List<SubjectTreeVO> subjectsByFacePublic(Integer facePublic,String environment,String username,String flagCode, List<SubjectTreeVO> subjectsByFacePublic(Integer subjectType,Integer facePublic,String environment,String username,String flagCode,
HttpServletRequest request); HttpServletRequest request);
/** /**
* 专题和分类列表-研究中心 * 专题和分类列表-研究中心
* *
* @param subjectType 类别(1-专题;3-复合专题)
* @param environment 环境
* @author lkg * @author lkg
* @date 2024/12/26 * @date 2025/6/4
*/ */
List<SubjectTreeVO> subjectAndTypeTree(String environment); List<SubjectTreeVO> subjectAndTypeTree(Integer subjectType,String environment);
/** /**
* 获取分类下的所有节点id集合-研究中心 * 获取分类下的所有节点id集合-研究中心
......
...@@ -76,12 +76,13 @@ public interface SubjectService extends IService<Subject> { ...@@ -76,12 +76,13 @@ public interface SubjectService extends IService<Subject> {
* @param username 用户名称 * @param username 用户名称
* @param type 分类(1-个人;2-公开;3-个人+公开) * @param type 分类(1-个人;2-公开;3-个人+公开)
* @param subjectName 专题名称 * @param subjectName 专题名称
* @param subjectName 专题类别(1:通用专题;3:研究中心主题专题[复合专题])
* @param pageNo 当前页 * @param pageNo 当前页
* @param pageSize 每页返回条数 * @param pageSize 每页返回条数
* @author lkg * @author lkg
* @date 2025/2/8 * @date 2025/2/8
*/ */
Page<Node> visiblePageList(String username, Integer type, String subjectName, Integer pageNo, Integer pageSize, String environment,HttpServletRequest request,String flagCode); Page<Node> visiblePageList(String username, Integer type, String subjectName, Integer subjectType, Integer pageNo, Integer pageSize, String environment,HttpServletRequest request,String flagCode);
/** /**
* 获取专题详情(包含样例文章信息) * 获取专题详情(包含样例文章信息)
......
...@@ -345,7 +345,7 @@ public class CommonServiceImpl implements CommonService { ...@@ -345,7 +345,7 @@ public class CommonServiceImpl implements CommonService {
@Override @Override
public List<LabelItemMapVO> infoSourceLabelsBySidList(List<String> sidList) { public List<LabelItemMapVO> infoSourceLabelsBySidList(List<String> sidList) {
List<LabelItemMapVO> clbLabelItems = new ArrayList<>(); List<LabelItemMapVO> clbLabelItems = new ArrayList<>();
if (CollectionUtils.isEmpty(sidList)) { if (CollectionUtils.isNotEmpty(sidList)) {
clbLabelItems = commonMapper.infoSourceLabelsBySidList(sidList); clbLabelItems = commonMapper.infoSourceLabelsBySidList(sidList);
} }
return clbLabelItems; return clbLabelItems;
......
...@@ -956,7 +956,7 @@ public class InformationServiceImpl implements InformationService { ...@@ -956,7 +956,7 @@ public class InformationServiceImpl implements InformationService {
try { try {
SpecialInformation specialInformation = new SpecialInformation(); SpecialInformation specialInformation = new SpecialInformation();
specialInformation.setId(codeGenerateUtil.geneIdNo(Constants.DATA_ADD_ID, 8)); specialInformation.setId(subjectId + codeGenerateUtil.geneIdNo(Constants.DATA_ADD_ID, 8));
//判断正文是否为空 //判断正文是否为空
if (StringUtils.isEmpty(info.get(3))) { if (StringUtils.isEmpty(info.get(3))) {
ClbFileOperationLogDetails clbFileOperationLogDetails = clbFileOperationLogDetailsService.buildFailDetails(info.get(1), info.get(5), info.get(7), "资讯内容为空"); ClbFileOperationLogDetails clbFileOperationLogDetails = clbFileOperationLogDetailsService.buildFailDetails(info.get(1), info.get(5), info.get(7), "资讯内容为空");
...@@ -1038,7 +1038,7 @@ public class InformationServiceImpl implements InformationService { ...@@ -1038,7 +1038,7 @@ public class InformationServiceImpl implements InformationService {
List<SpecialInformation> dataList = new ArrayList<>(); List<SpecialInformation> dataList = new ArrayList<>();
for (FileDataVO info : lists) { for (FileDataVO info : lists) {
SpecialInformation specialInformation = new SpecialInformation(); SpecialInformation specialInformation = new SpecialInformation();
specialInformation.setId(codeGenerateUtil.geneIdNo(Constants.DATA_ADD_ID, 8)); specialInformation.setId(subjectId + codeGenerateUtil.geneIdNo(Constants.DATA_ADD_ID, 8));
if (StringUtils.isNotEmpty(info.getTitle())) { if (StringUtils.isNotEmpty(info.getTitle())) {
specialInformation.setTitle(info.getTitle()); specialInformation.setTitle(info.getTitle());
} }
...@@ -1067,10 +1067,11 @@ public class InformationServiceImpl implements InformationService { ...@@ -1067,10 +1067,11 @@ public class InformationServiceImpl implements InformationService {
specialInformation.setPublishDate(EsDateUtil.esFieldDateFormat(info.getPublishDate())); specialInformation.setPublishDate(EsDateUtil.esFieldDateFormat(info.getPublishDate()));
} }
if (StringUtils.isNotEmpty(info.getContent())) { if (StringUtils.isNotEmpty(info.getContent())) {
specialInformation.setContent(info.getContent()); specialInformation.setContent(Jsoup.parse(info.getContent()).text());
specialInformation.setContentWithTag(info.getContent());
} }
if (StringUtils.isNotEmpty(info.getSummary())) { if (StringUtils.isNotEmpty(info.getSummary())) {
specialInformation.setContent(info.getSummary()); specialInformation.setSummary(info.getSummary());
} }
specialInformation.setCheckStatus(1); specialInformation.setCheckStatus(1);
specialInformation.setDeleteFlag(0); specialInformation.setDeleteFlag(0);
...@@ -1089,6 +1090,7 @@ public class InformationServiceImpl implements InformationService { ...@@ -1089,6 +1090,7 @@ public class InformationServiceImpl implements InformationService {
dataList.add(specialInformation); dataList.add(specialInformation);
} }
esOpUtil.docSaveBulk(index, dataList); esOpUtil.docSaveBulk(index, dataList);
log.info("专题-{},批量插入-{}-条数据完成",subjectId, lists.size());
} }
} }
...@@ -1137,7 +1139,7 @@ public class InformationServiceImpl implements InformationService { ...@@ -1137,7 +1139,7 @@ public class InformationServiceImpl implements InformationService {
esOpUtil.docRemoveBulk(removeMap); esOpUtil.docRemoveBulk(removeMap);
} }
if (CollectionUtils.isNotEmpty(dataList)) { if (CollectionUtils.isNotEmpty(dataList)) {
Map<String, List<SpecialInformation>> updateMap = removeList.stream().collect(Collectors.groupingBy(SpecialInformation::getDbIndex)); Map<String, List<SpecialInformation>> updateMap = dataList.stream().collect(Collectors.groupingBy(SpecialInformation::getDbIndex));
updateMap.forEach((k, v) -> esOpUtil.docUpdateBulk(k, v)); updateMap.forEach((k, v) -> esOpUtil.docUpdateBulk(k, v));
} }
//python 去重接口 //python 去重接口
......
...@@ -3,6 +3,7 @@ package com.zzsn.event.service.impl; ...@@ -3,6 +3,7 @@ package com.zzsn.event.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
...@@ -115,6 +116,9 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -115,6 +116,9 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
@Value("${clb.subject.default.processing.advanceMonth}") @Value("${clb.subject.default.processing.advanceMonth}")
private Integer defaultAdvanceMonth; private Integer defaultAdvanceMonth;
//专题信息数量本地缓存
LocalCache<String, Map<String,StatisticVO>> numLocalCache = new LocalCache<>(60 * 1000);
@Override @Override
public Page<SubjectPage> pageList(SubjectCondition subjectCondition, Integer pageNo, Integer pageSize) { public Page<SubjectPage> pageList(SubjectCondition subjectCondition, Integer pageNo, Integer pageSize) {
...@@ -217,7 +221,50 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -217,7 +221,50 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
} }
}); });
} }
//专题统计信息-总数量、最新资讯日期 for (Subject subject : subjects) {
String subjectId = subject.getId();
String estimateStatus = subject.getEstimateStatus();
SubjectStatisticInfo subjectStatisticInfo = new SubjectStatisticInfo();
subjectStatisticInfo.setSubjectId(subjectId);
if (infoSourceNumMap.containsKey(subjectId)) {
subjectStatisticInfo.setBindSourceNum(infoSourceNumMap.get(subjectId));
} else {
subjectStatisticInfo.setBindSourceNum(sourceCountMap.get(subjectId) == null ? 0 : sourceCountMap.get(subjectId));
}
subjectStatisticInfo.setBindKeywordNum(keyWordsNumMap.get(subjectId) == null ? 0 : keyWordsNumMap.get(subjectId));
StatisticVO totalAndLatestDate;
StatisticVO unCheckNum;
StatisticVO modelNum;
List<String> subjectIdList = new ArrayList<>();
subjectIdList.add(subjectId);
if (!(StringUtils.isEmpty(estimateStatus) || "已完成".equals(estimateStatus))) {
totalAndLatestDate = esService.subjectStatisticInfo(subjectIdList, null, null, 1).get(0);
unCheckNum = esService.subjectStatisticInfo(subjectIdList, 2, null, null).get(0);
modelNum = esService.subjectStatisticInfo(subjectIdList, null, 1, null).get(0);
} else {
if (numLocalCache.get(subjectId) == null) {
totalAndLatestDate = esService.subjectStatisticInfo(subjectIdList, null, null, 1).get(0);
unCheckNum = esService.subjectStatisticInfo(subjectIdList, 2, null, null).get(0);
modelNum = esService.subjectStatisticInfo(subjectIdList, null, 1, null).get(0);
Map<String, StatisticVO> numMap = new HashMap<>();
numMap.put("totalAndLatestDate", totalAndLatestDate);
numMap.put("unCheckNum", unCheckNum);
numMap.put("modelNum", modelNum);
numLocalCache.put(subjectId, numMap);
} else {
Map<String, StatisticVO> numMap = numLocalCache.get(subjectId);
totalAndLatestDate = numMap.get("totalAndLatestDate");
unCheckNum = numMap.get("unCheckNum");
modelNum = numMap.get("modelNum");
}
}
subjectStatisticInfo.setTotalNum(totalAndLatestDate.getCount());
subjectStatisticInfo.setLatestDataDate(totalAndLatestDate.getPublishDate());
subjectStatisticInfo.setUnCheckNum(unCheckNum.getCount());
subjectStatisticInfo.setModelNum(modelNum.getCount());
list.add(subjectStatisticInfo);
}
/*//专题统计信息-总数量、最新资讯日期
List<StatisticVO> totalAndLatestDateList = esService.subjectStatisticInfo(subjectIds, null,null, 1); List<StatisticVO> totalAndLatestDateList = esService.subjectStatisticInfo(subjectIds, null,null, 1);
Map<String,StatisticVO> totalAndLatestDateMap = totalAndLatestDateList.stream().collect(Collectors.toMap(StatisticVO::getSubjectId, e -> e)); Map<String,StatisticVO> totalAndLatestDateMap = totalAndLatestDateList.stream().collect(Collectors.toMap(StatisticVO::getSubjectId, e -> e));
//专题统计信息-待审核数量 //专题统计信息-待审核数量
...@@ -240,7 +287,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -240,7 +287,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
} }
subjectStatisticInfo.setBindKeywordNum(keyWordsNumMap.get(subjectId) == null ? 0 : keyWordsNumMap.get(subjectId)); subjectStatisticInfo.setBindKeywordNum(keyWordsNumMap.get(subjectId) == null ? 0 : keyWordsNumMap.get(subjectId));
list.add(subjectStatisticInfo); list.add(subjectStatisticInfo);
} }*/
return list; return list;
} }
...@@ -291,7 +338,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -291,7 +338,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
} }
@Override @Override
public Page<Node> visiblePageList(String username, Integer type, String subjectName, Integer pageNo, Integer pageSize, String environment,HttpServletRequest request,String flagCode) { public Page<Node> visiblePageList(String username, Integer type, String subjectName,Integer subjectType, Integer pageNo, Integer pageSize, String environment,HttpServletRequest request,String flagCode) {
Page<String> page = new Page<>(pageNo, pageSize); Page<String> page = new Page<>(pageNo, pageSize);
String sql = ""; String sql = "";
if(StringUtils.isNotBlank(flagCode)){ if(StringUtils.isNotBlank(flagCode)){
...@@ -309,7 +356,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -309,7 +356,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
log.info("visiblePageList sql:{}",sql); log.info("visiblePageList sql:{}",sql);
} }
log.info("visiblePageList username:{},type:{},subjectName:{},environment:{},sql:{}",username,type,subjectName,environment,sql); log.info("visiblePageList username:{},type:{},subjectName:{},environment:{},sql:{}",username,type,subjectName,environment,sql);
return baseMapper.visibleList(username, type, subjectName, page,environment,sql); return baseMapper.visibleList(username, type, subjectName,subjectType, page,environment,sql);
} }
@Override @Override
...@@ -326,6 +373,16 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -326,6 +373,16 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
if (subject.getSubjectType() == null) { if (subject.getSubjectType() == null) {
subject.setSubjectType(1); subject.setSubjectType(1);
} }
Date timeEnable = subject.getTimeEnable();
if (timeEnable != null) {
String format = cn.hutool.core.date.DateUtil.format(timeEnable, "yyyy-MM-dd 00:00:00");
subject.setTimeEnable(cn.hutool.core.date.DateUtil.parse(format));
}
Date timeDisable = subject.getTimeDisable();
if (timeDisable != null) {
String format = cn.hutool.core.date.DateUtil.format(timeDisable, "yyyy-MM-dd 23:59:59");
subject.setTimeDisable(DateUtil.parse(format));
}
String subjectCode = codeGenerateUtil.geneCodeNo(CodePrefixEnum.SUBJECT_DEFAULT.getValue()); String subjectCode = codeGenerateUtil.geneCodeNo(CodePrefixEnum.SUBJECT_DEFAULT.getValue());
subject.setSubjectCode(subjectCode); subject.setSubjectCode(subjectCode);
String cron = CronUtil.generateCron(subject.getUnit(), subject.getSpace()); String cron = CronUtil.generateCron(subject.getUnit(), subject.getSpace());
...@@ -345,6 +402,16 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -345,6 +402,16 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
BeanUtils.copyProperties(subjectPage, subject); BeanUtils.copyProperties(subjectPage, subject);
String cron = CronUtil.generateCron(subject.getUnit(), subject.getSpace()); String cron = CronUtil.generateCron(subject.getUnit(), subject.getSpace());
subject.setCron(cron); subject.setCron(cron);
Date timeEnable = subject.getTimeEnable();
if (timeEnable != null) {
String format = DateUtil.format(timeEnable, "yyyy-MM-dd 00:00:00");
subject.setTimeEnable(DateUtil.parse(format));
}
Date timeDisable = subject.getTimeDisable();
if (timeDisable != null) {
String format = DateUtil.format(timeDisable, "yyyy-MM-dd 23:59:59");
subject.setTimeDisable(DateUtil.parse(format));
}
baseMapper.updateById(subject); baseMapper.updateById(subject);
//删除专题-类别绑定关系 //删除专题-类别绑定关系
subjectTypeMapService.deleteBySubjectId(subject.getId()); subjectTypeMapService.deleteBySubjectId(subject.getId());
......
package com.zzsn.event.service.impl; package com.zzsn.event.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
...@@ -144,6 +145,16 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -144,6 +145,16 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
if (subject.getSubjectType() == null) { if (subject.getSubjectType() == null) {
subject.setSubjectType(1); subject.setSubjectType(1);
} }
Date timeEnable = subject.getTimeEnable();
if (timeEnable != null) {
String format = DateUtil.format(timeEnable, "yyyy-MM-dd 00:00:00");
subject.setTimeEnable(DateUtil.parse(format));
}
Date timeDisable = subject.getTimeDisable();
if (timeDisable != null) {
String format = DateUtil.format(timeDisable, "yyyy-MM-dd 23:59:59");
subject.setTimeDisable(DateUtil.parse(format));
}
String subjectCode = codeGenerateUtil.geneCodeNo(CodePrefixEnum.SUBJECT_DEFAULT.getValue()); String subjectCode = codeGenerateUtil.geneCodeNo(CodePrefixEnum.SUBJECT_DEFAULT.getValue());
subject.setSubjectCode(subjectCode); subject.setSubjectCode(subjectCode);
String cron = CronUtil.generateCron(subject.getUnit(), subject.getSpace()); String cron = CronUtil.generateCron(subject.getUnit(), subject.getSpace());
...@@ -375,11 +386,11 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -375,11 +386,11 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
} }
} else if ("3".equals(relationType)) { } else if ("3".equals(relationType)) {
String valueStr = params.get(0).get("value").toString(); String valueStr = params.get(0).get("value").toString();
map.get(valueStr).setSearchLogicRelationship("and"); map.get(valueStr).setSearchLogicRelationship("not");
for (int i = 1; i < params.size() - 2; i += 2) { for (int i = 1; i < params.size() - 2; i += 2) {
JSONObject param = params.get(i + 1); JSONObject param = params.get(i + 1);
String id = param.get("value").toString(); String id = param.get("value").toString();
map.get(id).setSearchLogicRelationship("and"); map.get(id).setSearchLogicRelationship("not");
} }
} }
} }
......
...@@ -105,7 +105,7 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje ...@@ -105,7 +105,7 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje
} }
@Override @Override
public List<SubjectTreeVO> subjectsByFacePublic(Integer facePublic,String environment,String username,String flagCode, public List<SubjectTreeVO> subjectsByFacePublic(Integer subjectType,Integer facePublic,String environment,String username,String flagCode,
HttpServletRequest request) { HttpServletRequest request) {
String sql = ""; String sql = "";
if(StringUtils.isNotBlank(flagCode)){ if(StringUtils.isNotBlank(flagCode)){
...@@ -123,16 +123,16 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje ...@@ -123,16 +123,16 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje
log.info("subjectsByFacePublic sql:{}",sql); log.info("subjectsByFacePublic sql:{}",sql);
} }
log.info("subjectsByFacePublic username:{},facePublic:{},environment:{},sql:{}",username,facePublic,environment,sql); log.info("subjectsByFacePublic username:{},facePublic:{},environment:{},sql:{}",username,facePublic,environment,sql);
List<SubjectTreeVO> list = baseMapper.subjectsByFacePublic(facePublic,environment,username,sql); List<SubjectTreeVO> list = baseMapper.subjectsByFacePublic(subjectType,facePublic,environment,username,sql);
log.info("subjectsByFacePublic=======list.size:{}",list.size()); log.info("subjectsByFacePublic=======list.size:{}",list.size());
return list; return list;
} }
@Override @Override
public List<SubjectTreeVO> subjectAndTypeTree(String environment) { public List<SubjectTreeVO> subjectAndTypeTree(Integer subjectType,String environment) {
String username = UserUtil.getLoginUser().getUsername(); String username = UserUtil.getLoginUser().getUsername();
List<SubjectTreeVO> tree = new ArrayList<>(); List<SubjectTreeVO> tree = new ArrayList<>();
List<SubjectTreeVO> subjectTreeVOS = baseMapper.subjectAndTypeTree(username,environment); List<SubjectTreeVO> subjectTreeVOS = baseMapper.subjectAndTypeTree(subjectType,username,environment);
if (CollectionUtils.isNotEmpty(subjectTreeVOS)) { if (CollectionUtils.isNotEmpty(subjectTreeVOS)) {
tree = TreeUtil.tree(subjectTreeVOS, "0"); tree = TreeUtil.tree(subjectTreeVOS, "0");
} }
......
...@@ -2,6 +2,7 @@ package com.zzsn.event.util; ...@@ -2,6 +2,7 @@ package com.zzsn.event.util;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
...@@ -135,6 +136,27 @@ public class DateUtil { ...@@ -135,6 +136,27 @@ public class DateUtil {
return dateList; return dateList;
} }
public static List<String> getMonthsBetween(String startDateStr, String endDateStr) {
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
DateTimeFormatter monthFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
LocalDate startDate = LocalDate.parse(startDateStr, dateFormatter);
LocalDate endDate = LocalDate.parse(endDateStr, dateFormatter);
List<String> months = new ArrayList<>();
YearMonth startYearMonth = YearMonth.from(startDate);
YearMonth endYearMonth = YearMonth.from(endDate);
for (YearMonth yearMonth = startYearMonth;
!yearMonth.isAfter(endYearMonth);
yearMonth = yearMonth.plusMonths(1)) {
months.add(yearMonth.format(monthFormatter));
}
return months;
}
public static String format(Date d, String format){ public static String format(Date d, String format){
if (d == null) { if (d == null) {
return ""; return "";
......
package com.zzsn.event.util;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
/**
* 本地缓存,带时效性
*
* @author lkg
* @date 2025/6/4
*/
public class LocalCache<K, V> {
private final ConcurrentHashMap<K, CacheValue<V>> cache;
private final long defaultExpiryTime; // 默认过期时间(毫秒)
public LocalCache(long defaultExpiryTime) {
this.cache = new ConcurrentHashMap<>();
this.defaultExpiryTime = defaultExpiryTime;
}
public void put(K key, V value) {
put(key, value, defaultExpiryTime);
}
public void put(K key, V value, long expiryTime) {
cache.put(key, new CacheValue<>(value, System.currentTimeMillis() + expiryTime));
}
public V get(K key) {
CacheValue<V> cacheValue = cache.get(key);
if (cacheValue == null || cacheValue.isExpired()) {
cache.remove(key);
return null;
}
return cacheValue.getValue();
}
public void remove(K key) {
cache.remove(key);
}
public void clear() {
cache.clear();
}
public int size() {
return cache.size();
}
static class CacheValue<V> {
private final V value;
private final long expiryTime;
CacheValue(V value, long expiryTime) {
this.value = value;
this.expiryTime = expiryTime;
}
V getValue() {
return value;
}
boolean isExpired() {
return System.currentTimeMillis() > expiryTime;
}
}
public static void main(String[] args) throws InterruptedException {
LocalCache<String, String> cache = new LocalCache<>(2 * 1000);
cache.put("key1", "value1");
System.out.println("Get key1 immediately: " + cache.get("key1"));
TimeUnit.SECONDS.sleep(1); // 等待3秒
System.out.println("Get key1 after 3 seconds: " + cache.get("key1"));
}
}
...@@ -59,6 +59,8 @@ public class InfoDataSearchCondition { ...@@ -59,6 +59,8 @@ public class InfoDataSearchCondition {
//资讯状态-研究中心(0-全部;1-模型推荐;2-精选;3-待定;4-移除),和auditStatus互斥 //资讯状态-研究中心(0-全部;1-模型推荐;2-精选;3-待定;4-移除),和auditStatus互斥
private Integer status; private Integer status;
//排除状态-研究中心(2-精选;3-待定;4-移除)
private List<Integer> excludeStatus;
//平台-审核状态(null-全部;1-通过;2-未审核;3-暂定;4-删除;5-免审核) //平台-审核状态(null-全部;1-通过;2-未审核;3-暂定;4-删除;5-免审核)
private Integer auditStatus; private Integer auditStatus;
......
...@@ -14,6 +14,8 @@ public class SubjectCondition { ...@@ -14,6 +14,8 @@ public class SubjectCondition {
/**专题id*/ /**专题id*/
private String id; private String id;
/**专题编码*/
private String subjectCode;
/**专题名称*/ /**专题名称*/
private String subjectName; private String subjectName;
/**项目id*/ /**项目id*/
...@@ -43,4 +45,7 @@ public class SubjectCondition { ...@@ -43,4 +45,7 @@ public class SubjectCondition {
private String column; private String column;
/**排序方式*/ /**排序方式*/
private String order; private String order;
/*专题类别(1:通用专题;3:研究中心主题专题[复合专题])*/
private Integer subjectType = 1;
} }
...@@ -53,15 +53,15 @@ public class SubjectPage { ...@@ -53,15 +53,15 @@ public class SubjectPage {
/**数据来源(0-平台数据;1-全网搜)*/ /**数据来源(0-平台数据;1-全网搜)*/
private Integer dataSource; private Integer dataSource;
/**启用时间*/ /**启用时间*/
@Excel(name = "启用时间", width = 15, format = "yyyy-MM-dd HH:mm:ss") @Excel(name = "启用时间", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "启用时间") @ApiModelProperty(value = "启用时间")
private Date timeEnable; private Date timeEnable;
/**停用时间*/ /**停用时间*/
@Excel(name = "停用时间", width = 15, format = "yyyy-MM-dd HH:mm:ss") @Excel(name = "停用时间", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "停用时间") @ApiModelProperty(value = "停用时间")
private Date timeDisable; private Date timeDisable;
/**划分专题库*/ /**划分专题库*/
......
...@@ -2,7 +2,9 @@ package com.zzsn.event.vo; ...@@ -2,7 +2,9 @@ package com.zzsn.event.vo;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.zzsn.event.entity.arrange.ClbModelArrange; import com.zzsn.event.entity.arrange.ClbModelArrange;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date; import java.util.Date;
...@@ -48,4 +50,15 @@ public class SubjectPageVO { ...@@ -48,4 +50,15 @@ public class SubjectPageVO {
/**主题绑定流程信息*/ /**主题绑定流程信息*/
private List<ClbModelArrange> clbModelArranges; private List<ClbModelArrange> clbModelArranges;
/**创建人*/
private String createBy;
/**创建时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
private java.util.Date createTime;
/**更新人*/
private String updateBy;
/**更新时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
private java.util.Date updateTime;
} }
...@@ -177,6 +177,7 @@ clb: ...@@ -177,6 +177,7 @@ clb:
data-permit: data-permit:
dataPermitGetQueryEntityTest: http://1.95.77.159:10089/permission/ dataPermitGetQueryEntityTest: http://1.95.77.159:10089/permission/
dataPermitGetQueryEntityProd: http://1.95.14.24:8060/ dataPermitGetQueryEntityProd: http://1.95.14.24:8060/
infoSource: infoSource:
pageList: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/pageList pageList: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/pageList
columnList: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/columnList columnList: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/columnList
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论