提交 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}"
ENV APP_OPTS9="-Dspring.cloud.nacos.config.password=${NACOS_PASSWORD}"
ENV APP_OPTS10="-Dserver.port=${PORT}"
ENV JVM_OPTS="-Xmx2024M -Xms256M"
ENV JVM_OPTS="-Xmx6000M -Xms256M"
EXPOSE ${PORT}
# 解决导出字体缺失报错问题
......
......@@ -32,4 +32,4 @@ nacos_password="nacos"
# 资源限制
## cpu
limit_cpu=2.0
limit_mem=2g
\ No newline at end of file
limit_mem=6g
\ No newline at end of file
......@@ -32,4 +32,4 @@ nacos_password="nacos"
# 资源限制
## cpu
limit_cpu=2.0
limit_mem=2g
\ No newline at end of file
limit_mem=6g
\ No newline at end of file
......@@ -23,6 +23,7 @@ public class Constants {
public static final String SUBJECT_INDEX = "subjectdatabase";
//es 采集库索引
public static final String COLLECT_INDEX = "basedata";
public static final String COLLECT_MIDDLE_INDEX = "middlesubjectdatabase";
//专题事件脉络展示 伪事件脉络 的资讯数量阈值
public static final int FAKE_NUM = 6;
......
......@@ -338,6 +338,7 @@ public class FileController {
List<FileDataVO> informationList = reader.read(0, 1, FileDataVO.class);
informationService.importDataInfo(informationList,subjectId);
} catch (IOException e) {
log.info("专题-{},批量插入数据异常",subjectId);
e.printStackTrace();
}
});
......
......@@ -193,13 +193,14 @@ public class SubjectManageController {
@GetMapping("/visiblePageList")
public Result<?> visiblePageList(@RequestParam Integer type,
@RequestParam(required = false) String subjectName,
@RequestParam(defaultValue = "1") Integer subjectType,
@RequestParam(required = false) String environment,
@RequestParam(required = false) String flagCode,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest request) {
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);
}
......@@ -219,13 +220,14 @@ public class SubjectManageController {
@GetMapping("/visiblePageListNoSign")
public Result<?> visiblePageListNoSign(@RequestParam Integer type,
@RequestParam(required = false) String subjectName,
@RequestParam(defaultValue = "1") Integer subjectType,
@RequestParam(required = false) String environment,
@RequestParam(required = false) String flagCode,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest request) {
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);
}
......@@ -795,7 +797,6 @@ public class SubjectManageController {
*/
@PostMapping("/configScoreModel")
public Result<?> configScoreModel(@RequestBody ScoreModelVo scoreModelVo) {
UserVo loginUser = UserUtil.getLoginUser();
scoreModelService.addOrUpdate(scoreModelVo, 1);
//调用接口,重新打分
String subjectId = scoreModelVo.getSubjectId();
......@@ -837,7 +838,7 @@ public class SubjectManageController {
/**
* 模型绑定(包含去重、筛选、标签模型)--检查是否需要中断-专题配置页
* todo
*
*
* @param subjectPage 参数
* @return
......@@ -849,7 +850,7 @@ public class SubjectManageController {
/**
* 前端发送请求,传参数给python
* todo
*
*/
@PostMapping(value = "/sendPythonInfo")
public Result<?> sendPythonInfo(@RequestBody SubjectPage subjectPage) {
......@@ -907,13 +908,18 @@ public class SubjectManageController {
@PostMapping("/bindInfoSourceLabel")
public Result<?> bindInfoSourceLabel(@RequestBody SubjectSourceTagVO subjectSourceTagVO) {
List<InfoSourceLabelVO> labelList = subjectSourceTagVO.getLabelList();
if (CollectionUtils.isEmpty(labelList)) {
return Result.OK();
}
String subjectId = subjectSourceTagVO.getSubjectId();
if (StringUtils.isEmpty(subjectId)) {
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<>();
for (InfoSourceLabelVO infoSourceLabelVO : labelList) {
List<InfoSourceLabelItemVO> infoSourceLabelItemList = infoSourceLabelVO.getInfoSourceLabelItemList();
......@@ -931,13 +937,9 @@ public class SubjectManageController {
dataList.add(subjectInfoSourceMap);
}
}
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);
}
if (CollectionUtils.isNotEmpty(dataList)) {
subjectInfoSourceMapService.saveBatch(dataList);
}
//同步配置到采集
configurationMessageService.bindInfoSourceSend(subjectId);
return Result.OK();
......
package com.zzsn.event.controller.common;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
......@@ -9,6 +10,7 @@ import com.zzsn.event.entity.Subject;
import com.zzsn.event.entity.SysDictItem;
import com.zzsn.event.es.EsService;
import com.zzsn.event.service.*;
import com.zzsn.event.util.CalculateUtil;
import com.zzsn.event.util.DateUtil;
import com.zzsn.event.vo.*;
import com.zzsn.event.vo.es.Label;
......@@ -18,10 +20,9 @@ import org.apache.commons.collections4.MapUtils;
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.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -46,6 +47,8 @@ public class StatisticalAnalysisController {
private ClbLabelService clbLabelService;
@Autowired
private InformationService informationService;
@Autowired
private CommonService commonService;
/**
* 概述分析
......@@ -92,7 +95,7 @@ public class StatisticalAnalysisController {
}
}
//补充数据
supplyData(countList,bindLabelList,labelMap);
supplyData(countList, bindLabelList, labelMap);
overviewAnalysisVO.setInfoCount(totalCount);
overviewAnalysisVO.setCountList(countList);
return Result.OK(overviewAnalysisVO);
......@@ -201,10 +204,10 @@ public class StatisticalAnalysisController {
public Result<?> dataSource(@RequestBody InfoDataSearchCondition searchCondition) {
List<CountVO> dataList = new ArrayList<>();
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) {
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]));
dataList = esService.groupByInfoSourceTag(searchCondition);
} else {
......@@ -226,8 +229,6 @@ public class StatisticalAnalysisController {
}
/**
* 资讯数量top的信息源统计
*
......@@ -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 {
public Result<?> subjectAndTypeTree(@RequestParam(required = false) Integer facePublic,
@RequestParam(required = false) String environment,
@RequestParam(required = false) String flagCode,
@RequestParam(defaultValue = "1") Integer subjectType,
HttpServletRequest request) {
UserVo loginUser = UserUtil.getLoginUser();
List<SubjectTreeVO> dataList = null;
if (facePublic == null) {
dataList = subjectTypeService.subjectAndTypeTree(environment);
dataList = subjectTypeService.subjectAndTypeTree(subjectType,environment);
} 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);
}
......
......@@ -42,6 +42,7 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.jsoup.Jsoup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -358,6 +359,10 @@ public class ReportDataController {
for (SearchHit hit : searchHits) {
String queryInfo = hit.getSourceAsString();
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.setCreateDate(EsDateUtil.esFieldDateMapping(info.getCreateDate()));
list.add(info);
......
......@@ -33,14 +33,14 @@ public interface SubjectMapper extends BaseMapper<Subject> {
Page<SubjectPage> pageList(@Param("subjectCondition") SubjectCondition subjectCondition, Page<SubjectPage> page);
/**
*专题分页列表-新
* 专题分页列表-新
*
* @param subjectCondition 查询条件
* @param page 分页参数
* @author lkg
* @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> {
* @date 2025/3/25
*/
SubjectPage getInfo(@Param("subjectId") String subjectId);
/**
* 专题分页列表(个人)-研究中心
*
......@@ -68,7 +69,7 @@ public interface SubjectMapper extends BaseMapper<Subject> {
* @author lkg
* @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> {
* @param username 用户名称
* @param type 分类(1-个人;2-公开;3-个人+公开)
* @param subjectName 专题名称
* @param subjectType 专题类别(1:通用专题;3:研究中心主题专题[复合专题])
* @param page 分页参数
* @author lkg
* @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> {
*/
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);
}
......@@ -78,7 +78,7 @@ public interface SubjectTypeMapper extends BaseMapper<SubjectType> {
* @author lkg
* @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);
/**
......@@ -87,7 +87,7 @@ public interface SubjectTypeMapper extends BaseMapper<SubjectType> {
* @author lkg
* @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 @@
</select>
<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,
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
<if test="userId !=null and userId != ''">
inner join sys_user_data_permission dp on d.id=dp.permission_id and dp.user_id = #{userId}
......@@ -70,6 +71,9 @@
<if test="subjectCondition.subjectName!=null and subjectCondition.subjectName != ''">
and d.subject_name like CONCAT('%',#{subjectCondition.subjectName},'%')
</if>
<if test="subjectCondition.subjectCode!=null and subjectCondition.subjectCode != ''">
and d.subject_code like CONCAT('%',#{subjectCondition.subjectCode},'%')
</if>
<if test="subjectCondition.status!=null">
and d.status = #{subjectCondition.status}
</if>
......@@ -189,6 +193,9 @@
<if test="subjectCondition.username!=null and subjectCondition.username != ''">
and d.create_by = #{subjectCondition.username}
</if>
<if test="subjectCondition.subjectType != null">
and d.subject_type = #{subjectCondition.subjectType}
</if>
order by d.create_time desc
</select>
<select id="researchCenterFacePageList" resultType="com.zzsn.event.vo.SubjectPage">
......@@ -232,6 +239,9 @@
<if test="subjectCondition.status!=null">
and d.status = #{subjectCondition.status}
</if>
<if test="subjectCondition.subjectType!=null">
and d.subject_type = #{subjectCondition.subjectType}
</if>
order by d.create_time desc
</select>
......@@ -282,6 +292,9 @@
<if test="subjectName != null and subjectName != ''">
and subject_name like concat('%',#{subjectName},'%')
</if>
<if test="subjectType!=null">
and subject_type = #{subjectType}
</if>
<if test="environment != null and environment != ''">
and environment = #{environment}
</if>
......
......@@ -70,6 +70,9 @@
from subject s
where
((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 != ''">
and s.environment = #{environment}
</if>
......@@ -120,6 +123,9 @@
s.create_time
from subject s
where 1 = 1
<if test="subjectType!=null">
and s.subject_type = #{subjectType}
</if>
<if test="username!=null and username != ''">
and s.create_by = #{username}
</if>
......
......@@ -80,16 +80,18 @@ public interface ISubjectTypeService extends IService<SubjectType> {
* @author lkg
* @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);
/**
* 专题和分类列表-研究中心
*
* @param subjectType 类别(1-专题;3-复合专题)
* @param environment 环境
* @author lkg
* @date 2024/12/26
* @date 2025/6/4
*/
List<SubjectTreeVO> subjectAndTypeTree(String environment);
List<SubjectTreeVO> subjectAndTypeTree(Integer subjectType,String environment);
/**
* 获取分类下的所有节点id集合-研究中心
......
......@@ -76,12 +76,13 @@ public interface SubjectService extends IService<Subject> {
* @param username 用户名称
* @param type 分类(1-个人;2-公开;3-个人+公开)
* @param subjectName 专题名称
* @param subjectName 专题类别(1:通用专题;3:研究中心主题专题[复合专题])
* @param pageNo 当前页
* @param pageSize 每页返回条数
* @author lkg
* @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 {
@Override
public List<LabelItemMapVO> infoSourceLabelsBySidList(List<String> sidList) {
List<LabelItemMapVO> clbLabelItems = new ArrayList<>();
if (CollectionUtils.isEmpty(sidList)) {
if (CollectionUtils.isNotEmpty(sidList)) {
clbLabelItems = commonMapper.infoSourceLabelsBySidList(sidList);
}
return clbLabelItems;
......
......@@ -956,7 +956,7 @@ public class InformationServiceImpl implements InformationService {
try {
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))) {
ClbFileOperationLogDetails clbFileOperationLogDetails = clbFileOperationLogDetailsService.buildFailDetails(info.get(1), info.get(5), info.get(7), "资讯内容为空");
......@@ -1038,7 +1038,7 @@ public class InformationServiceImpl implements InformationService {
List<SpecialInformation> dataList = new ArrayList<>();
for (FileDataVO info : lists) {
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())) {
specialInformation.setTitle(info.getTitle());
}
......@@ -1067,10 +1067,11 @@ public class InformationServiceImpl implements InformationService {
specialInformation.setPublishDate(EsDateUtil.esFieldDateFormat(info.getPublishDate()));
}
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())) {
specialInformation.setContent(info.getSummary());
specialInformation.setSummary(info.getSummary());
}
specialInformation.setCheckStatus(1);
specialInformation.setDeleteFlag(0);
......@@ -1089,6 +1090,7 @@ public class InformationServiceImpl implements InformationService {
dataList.add(specialInformation);
}
esOpUtil.docSaveBulk(index, dataList);
log.info("专题-{},批量插入-{}-条数据完成",subjectId, lists.size());
}
}
......@@ -1137,7 +1139,7 @@ public class InformationServiceImpl implements InformationService {
esOpUtil.docRemoveBulk(removeMap);
}
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));
}
//python 去重接口
......
......@@ -3,6 +3,7 @@ package com.zzsn.event.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
......@@ -115,6 +116,9 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
@Value("${clb.subject.default.processing.advanceMonth}")
private Integer defaultAdvanceMonth;
//专题信息数量本地缓存
LocalCache<String, Map<String,StatisticVO>> numLocalCache = new LocalCache<>(60 * 1000);
@Override
public Page<SubjectPage> pageList(SubjectCondition subjectCondition, Integer pageNo, Integer pageSize) {
......@@ -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);
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
}
subjectStatisticInfo.setBindKeywordNum(keyWordsNumMap.get(subjectId) == null ? 0 : keyWordsNumMap.get(subjectId));
list.add(subjectStatisticInfo);
}
}*/
return list;
}
......@@ -291,7 +338,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
}
@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);
String sql = "";
if(StringUtils.isNotBlank(flagCode)){
......@@ -309,7 +356,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
log.info("visiblePageList sql:{}",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
......@@ -326,6 +373,16 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
if (subject.getSubjectType() == null) {
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());
subject.setSubjectCode(subjectCode);
String cron = CronUtil.generateCron(subject.getUnit(), subject.getSpace());
......@@ -345,6 +402,16 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
BeanUtils.copyProperties(subjectPage, subject);
String cron = CronUtil.generateCron(subject.getUnit(), subject.getSpace());
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);
//删除专题-类别绑定关系
subjectTypeMapService.deleteBySubjectId(subject.getId());
......
package com.zzsn.event.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson2.JSON;
......@@ -144,6 +145,16 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
if (subject.getSubjectType() == null) {
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());
subject.setSubjectCode(subjectCode);
String cron = CronUtil.generateCron(subject.getUnit(), subject.getSpace());
......@@ -375,11 +386,11 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
}
} else if ("3".equals(relationType)) {
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) {
JSONObject param = params.get(i + 1);
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
}
@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) {
String sql = "";
if(StringUtils.isNotBlank(flagCode)){
......@@ -123,16 +123,16 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje
log.info("subjectsByFacePublic sql:{}",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());
return list;
}
@Override
public List<SubjectTreeVO> subjectAndTypeTree(String environment) {
public List<SubjectTreeVO> subjectAndTypeTree(Integer subjectType,String environment) {
String username = UserUtil.getLoginUser().getUsername();
List<SubjectTreeVO> tree = new ArrayList<>();
List<SubjectTreeVO> subjectTreeVOS = baseMapper.subjectAndTypeTree(username,environment);
List<SubjectTreeVO> subjectTreeVOS = baseMapper.subjectAndTypeTree(subjectType,username,environment);
if (CollectionUtils.isNotEmpty(subjectTreeVOS)) {
tree = TreeUtil.tree(subjectTreeVOS, "0");
}
......
......@@ -2,6 +2,7 @@ package com.zzsn.event.util;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
......@@ -135,6 +136,27 @@ public class DateUtil {
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){
if (d == null) {
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 {
//资讯状态-研究中心(0-全部;1-模型推荐;2-精选;3-待定;4-移除),和auditStatus互斥
private Integer status;
//排除状态-研究中心(2-精选;3-待定;4-移除)
private List<Integer> excludeStatus;
//平台-审核状态(null-全部;1-通过;2-未审核;3-暂定;4-删除;5-免审核)
private Integer auditStatus;
......
......@@ -14,6 +14,8 @@ public class SubjectCondition {
/**专题id*/
private String id;
/**专题编码*/
private String subjectCode;
/**专题名称*/
private String subjectName;
/**项目id*/
......@@ -43,4 +45,7 @@ public class SubjectCondition {
private String column;
/**排序方式*/
private String order;
/*专题类别(1:通用专题;3:研究中心主题专题[复合专题])*/
private Integer subjectType = 1;
}
......@@ -53,15 +53,15 @@ public class SubjectPage {
/**数据来源(0-平台数据;1-全网搜)*/
private Integer dataSource;
/**启用时间*/
@Excel(name = "启用时间", width = 15, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Excel(name = "启用时间", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "启用时间")
private Date timeEnable;
/**停用时间*/
@Excel(name = "停用时间", width = 15, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Excel(name = "停用时间", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "停用时间")
private Date timeDisable;
/**划分专题库*/
......
......@@ -2,7 +2,9 @@ package com.zzsn.event.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zzsn.event.entity.arrange.ClbModelArrange;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
......@@ -48,4 +50,15 @@ public class SubjectPageVO {
/**主题绑定流程信息*/
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:
data-permit:
dataPermitGetQueryEntityTest: http://1.95.77.159:10089/permission/
dataPermitGetQueryEntityProd: http://1.95.14.24:8060/
infoSource:
pageList: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/pageList
columnList: http://1.95.79.85:8823/baseSourceInfo/api/infoSource/columnList
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论