提交 e946419c 作者: 925993793@qq.com

【fix】克虏宝平台专题列表逻辑优化

上级 ca95dc4a
......@@ -95,6 +95,8 @@ public class SubjectManageController {
private SysDictItemService sysDictItemService;
@Autowired
private ConfigurationMessageService configurationMessageService;
@Autowired
private SubjectStatisticInfoService subjectStatisticInfoService;
@Autowired
private ObsUtil obsUtil;
......@@ -217,11 +219,30 @@ public class SubjectManageController {
public Result<?> pageList(SubjectCondition subjectCondition,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
IPage<SubjectPage> pageList = subjectService.pageList(subjectCondition, pageNo, pageSize);
IPage<SubjectPageVO> pageList = subjectService.pageList_new(subjectCondition, pageNo, pageSize);
return Result.OK(pageList);
}
/**
* 专题统计信息
*
* @param subjectIds 专题id集合
* @author lkg
* @date 2025/3/25
*/
@GetMapping(value = "/statisticInfo")
private Result<?> statisticInfo(@RequestParam List<String> subjectIds){
List<SubjectStatisticInfo> statisticInfoList = subjectService.statisticInfo(subjectIds);
//异步更新专题统计信息表的数据
CompletableFuture.runAsync(() -> {
if (CollectionUtils.isNotEmpty(statisticInfoList)) {
subjectStatisticInfoService.batchModify(statisticInfoList);
}
});
return Result.OK(statisticInfoList);
}
/**
* 推荐关键词
*
* @param files 眼里文章
......@@ -326,7 +347,7 @@ public class SubjectManageController {
}
/**
* 获取专题详情(只包含专题信息)
* 专题详情(包含专题分类、专题项目)
*
* @param subjectId 专题id
* @author lkg
......@@ -334,7 +355,7 @@ public class SubjectManageController {
*/
@GetMapping("/getById")
public Result<?> detailById(@RequestParam String subjectId) {
return Result.OK(subjectService.getById(subjectId));
return Result.OK(subjectService.getInfo(subjectId));
}
/**
......
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 专题统计信息
*
* @author lkg
* @date 2025/3/25
*/
@Data
@TableName("subject_statistic_info")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SubjectStatisticInfo {
/**主键id*/
private String subjectId;
/**专题id*/
private String id;
/**信息总数量*/
private Integer totalNum;
/**待审核数量*/
private Integer unCheckNum;
/**绑定信息源数量*/
private Integer bindSourceNum;
/**绑定关键词组数量*/
private Integer bindKeywordNum;
/**最新数据日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date latestDataDate;
/**更新时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/**创建时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date createTime;
}
......@@ -13,6 +13,7 @@ import com.google.common.base.Charsets;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.entity.Event;
import com.zzsn.event.entity.Subject;
import com.zzsn.event.entity.SubjectStatisticInfo;
import com.zzsn.event.service.*;
import com.zzsn.event.util.DateUtil;
import com.zzsn.event.util.EsDateUtil;
......@@ -33,6 +34,7 @@ import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.*;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.BucketOrder;
......@@ -611,7 +613,7 @@ public class EsService {
String[] excludeFields = eventDataCondition.getExcludeFields();
if (fetchFields != null && fetchFields.length > 0) {
searchSourceBuilder.fetchSource(fetchFields, null);
} else if (excludeFields != null && excludeFields.length > 0){
} else if (excludeFields != null && excludeFields.length > 0) {
searchSourceBuilder.fetchSource(null, excludeFields);
}
//设置分页参数
......@@ -744,7 +746,7 @@ public class EsService {
String[] excludeFields = searchCondition.getExcludeFields();
if (fetchFields != null && fetchFields.length > 0) {
searchSourceBuilder.fetchSource(fetchFields, null);
} else if (excludeFields != null && excludeFields.length > 0){
} else if (excludeFields != null && excludeFields.length > 0) {
searchSourceBuilder.fetchSource(null, excludeFields);
}
//设置分页参数
......@@ -1745,9 +1747,9 @@ public class EsService {
searchSourceBuilder.trackTotalHits(true);
searchSourceBuilder.size(1);
searchSourceBuilder.query(boolQueryBuilder);
if("asc".equals(sortOrder)){
if ("asc".equals(sortOrder)) {
searchSourceBuilder.sort("publishDate", SortOrder.ASC);
}else {
} else {
searchSourceBuilder.sort("publishDate", SortOrder.DESC);
}
searchRequest.source(searchSourceBuilder);
......@@ -1767,6 +1769,92 @@ public class EsService {
}
/**
* 专题信息数量统计
*
* @param subjectIds 专题id集合
* @param checkStatus 审核状态
* @param type 是否多层聚合(先按专题,再按发布时间)
* @author lkg
* @date 2025/3/25
*/
public List<StatisticVO> subjectStatisticInfo(List<String> subjectIds, Integer checkStatus, Integer type) {
List<StatisticVO> list = new ArrayList<>();
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.trackTotalHits(true);
searchSourceBuilder.size(0);
InfoDataSearchCondition searchCondition = new InfoDataSearchCondition();
if (checkStatus != null) {
searchCondition.setCheckStatus(checkStatus);
}
BoolQueryBuilder boolQuery = buildQuery(searchCondition, subjectIds);
searchSourceBuilder.query(boolQuery);
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("group_subject");
aggregationBuilder.field("subjectId.keyword");
if (!Objects.isNull(searchCondition.getIncludeValues()) || !Objects.isNull(searchCondition.getExcludeValues())) {
if (!Objects.isNull(searchCondition.getIncludeValues())) {
aggregationBuilder.size(searchCondition.getIncludeValues().length);
}
aggregationBuilder.includeExclude(new IncludeExclude(searchCondition.getIncludeValues(), searchCondition.getExcludeValues()));
}
if (null != type && type == 1) {
DateHistogramAggregationBuilder format = AggregationBuilders.dateHistogram("groupDay")
.field("publishDate")
.calendarInterval(DateHistogramInterval.DAY)
.format("yyyy-MM-dd")
.order(BucketOrder.key(false));
aggregationBuilder.subAggregation(format);
}
searchSourceBuilder.aggregation(aggregationBuilder);
searchRequest.source(searchSourceBuilder);
try {
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
Aggregations aggregations = searchResponse.getAggregations();
Terms groupSubject = aggregations.get("group_subject");
List<? extends Terms.Bucket> buckets = groupSubject.getBuckets();
for (Terms.Bucket bucket : buckets) {
StatisticVO statisticVO = new StatisticVO();
String subjectId = bucket.getKeyAsString();
long count = bucket.getDocCount();
statisticVO.setSubjectId(subjectId);
statisticVO.setCount((int) count);
if (null != type && type == 1) {
ParsedDateHistogram groupDay = bucket.getAggregations().get("groupDay");
List<? extends Histogram.Bucket> groupDayBuckets = groupDay.getBuckets();
if (CollectionUtils.isNotEmpty(groupDayBuckets)) {
Histogram.Bucket groupDayBucket = groupDayBuckets.get(0);
String latestDataDate = groupDayBucket.getKeyAsString();
statisticVO.setPublishDate(DateUtil.stringToDate(latestDataDate, "yyyy-MM-dd"));
}
}
list.add(statisticVO);
}
} catch (Exception e) {
e.printStackTrace();
}
if (CollectionUtils.isNotEmpty(list)) {
if (list.size() < subjectIds.size()) {
for (String subjectId : subjectIds) {
if (!list.stream().map(StatisticVO::getSubjectId).collect(Collectors.toList()).contains(subjectId)) {
StatisticVO statisticVO = new StatisticVO();
statisticVO.setSubjectId(subjectId);
statisticVO.setCount(0);
list.add(statisticVO);
}
}
}
} else {
list = subjectIds.stream().map(subjectId -> {
StatisticVO statisticVO = new StatisticVO();
statisticVO.setSubjectId(subjectId);
statisticVO.setCount(0);
return statisticVO;
}).collect(Collectors.toList());
}
return list;
}
/**
* term方式聚合分组
*
* @param searchCondition 筛选条件
......@@ -2422,9 +2510,9 @@ public class EsService {
private BoolQueryBuilder multiMatchQuery(String word) {
BoolQueryBuilder fullTextBoolQuery = QueryBuilders.boolQuery();
String[] fullTextFields = new String[] {"title", "summary", "content"};
String[] fullTextFields = new String[]{"title", "summary", "content"};
for (String fullTextField : fullTextFields) {
fullTextBoolQuery.should(QueryBuilders.matchPhraseQuery(fullTextField,word));
fullTextBoolQuery.should(QueryBuilders.matchPhraseQuery(fullTextField, word));
}
return fullTextBoolQuery;
}
......
......@@ -7,6 +7,7 @@ import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.SubjectCondition;
import com.zzsn.event.vo.SubjectPage;
import com.zzsn.event.vo.SubjectDetailVO;
import com.zzsn.event.vo.SubjectPageVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -32,6 +33,24 @@ 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(@Param("subjectCondition") SubjectCondition subjectCondition, Page<SubjectPageVO> page);
/**
* 专题详情(包含专题分类、专题项目)
*
* @param subjectId 专题id
* @author lkg
* @date 2025/3/25
*/
SubjectPage getInfo(@Param("subjectId") String subjectId);
/**
* 专题分页列表(个人)-研究中心
*
* @param subjectCondition 查询条件
......
package com.zzsn.event.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.entity.SubjectStatisticInfo;
import org.apache.ibatis.annotations.Mapper;
/**
* 专题统计信息 数据层
*
* @author lkg
* @date 2025/3/25
*/
@Mapper
public interface SubjectStatisticInfoMapper extends BaseMapper<SubjectStatisticInfo> {
}
......@@ -44,6 +44,68 @@
order by d.sort_order,d.create_time desc
</select>
<select id="pageList_new" resultType="com.zzsn.event.vo.SubjectPageVO">
SELECT d.id,d.subject_name,d.status,
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
from subject d
INNER JOIN subject_type_map b ON b.subject_id = d.id
INNER JOIN subject_type c ON b.type_id = c.id
LEFT JOIN project_subject_map f ON f.subject_id = d.id
LEFT JOIN project g ON f.project_id = g.id
LEFT JOIN subject_statistic_info s on s.subject_id = d.id
where 1 = 1
<if test="subjectCondition.typeIds!=null and subjectCondition.typeIds.size()>0">
and b.type_id in
<foreach collection="subjectCondition.typeIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="subjectCondition.id !=null and subjectCondition.id !=''">
and d.id =#{subjectCondition.id}
</if>
<if test="subjectCondition.subjectName!=null and subjectCondition.subjectName != ''">
and d.subject_name like CONCAT('%',#{subjectCondition.subjectName},'%')
</if>
<if test="subjectCondition.status!=null">
and d.status = #{subjectCondition.status}
</if>
<if test="subjectCondition.facePublic!=null">
and d.face_public = #{subjectCondition.facePublic}
</if>
<if test="subjectCondition.startTime != null and subjectCondition.startTime != ''">
and d.create_time >= #{subjectCondition.startTime}
</if>
<if test="subjectCondition.endTime != null and subjectCondition.endTime != ''">
and d.create_time <![CDATA[ <= ]]> #{subjectCondition.endTime}
</if>
<if test="subjectCondition.projectId!=null and subjectCondition.projectId != ''">
and g.id = #{subjectCondition.projectId}
</if>
<if test="subjectCondition.username!=null and subjectCondition.username != ''">
and d.create_by = #{subjectCondition.username}
</if>
<choose>
<when test="subjectCondition.column != null and subjectCondition.column != ''">
order by ${subjectCondition.column}
<if test="subjectCondition.order != null and subjectCondition.order != ''">
${subjectCondition.order}
</if>
</when>
<otherwise>
order by d.sort_order,d.create_time desc
</otherwise>
</choose>
</select>
<select id="getInfo" resultType="com.zzsn.event.vo.SubjectPage">
SELECT d.*, b.type_id as subjectTypeId, f.project_id
from subject d
INNER JOIN subject_type_map b ON b.subject_id = d.id
LEFT JOIN project_subject_map f ON f.subject_id = d.id
where d.id = #{subjectId}
</select>
<select id="selectSubjectById" resultType="com.zzsn.event.vo.SubjectPage">
SELECT d.*,
c.id as subjectTypeId,
......@@ -188,7 +250,7 @@
s.library,
s.estimate_status,
s.first_open_time,
c.id as subjectTypeId,
c.id as subjectTypeId,
c.type_name as subjectTypeName,
f.id,
f.file_name,
......@@ -222,6 +284,9 @@
</select>
<select id="getBindSubjectIds" resultType="java.lang.String">
select addition_relation_id from subject_addition where subject_id = #{id} and addition_type = 1
select addition_relation_id
from subject_addition
where subject_id = #{id}
and addition_type = 1
</select>
</mapper>
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.Subject;
import com.zzsn.event.entity.SubjectStatisticInfo;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.*;
......@@ -30,6 +31,35 @@ public interface SubjectService extends IService<Subject> {
Page<SubjectPage> pageList(SubjectCondition subjectCondition, Integer pageNo, Integer pageSize);
/**
* 分页列表-新
*
* @param subjectCondition 查询条件
* @param pageNo 当前页
* @param pageSize 每页返回条数
* @author lkg
* @date 2024/12/18
*/
Page<SubjectPageVO> pageList_new(SubjectCondition subjectCondition, Integer pageNo, Integer pageSize);
/**
* 专题统计信息
*
* @param subjectIds 专题id集合
* @author lkg
* @date 2024/12/18
*/
List<SubjectStatisticInfo> statisticInfo(List<String> subjectIds);
/**
* 专题详情(包含专题分类、专题项目)
*
* @param subjectId 专题id
* @author lkg
* @date 2025/3/25
*/
SubjectPage getInfo(String subjectId);
/**
* 分页列表-研究中心
*
* @param subjectCondition 查询条件
......
package com.zzsn.event.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.SubjectStatisticInfo;
import java.util.List;
/**
* 专题统计信息 业务层
*
* @author lkg
* @date 2025/3/25
*/
public interface SubjectStatisticInfoService extends IService<SubjectStatisticInfo> {
void batchModify(List<SubjectStatisticInfo> list);
}
......@@ -20,6 +20,7 @@ import com.zzsn.event.entity.arrange.ClbModelArrange;
import com.zzsn.event.enums.BindTypeEnum;
import com.zzsn.event.enums.CodePrefixEnum;
import com.zzsn.event.enums.SourceTypeEnum;
import com.zzsn.event.es.EsService;
import com.zzsn.event.mapper.SubjectMapper;
import com.zzsn.event.permit.ParamAop;
import com.zzsn.event.permit.UQueryEntity;
......@@ -106,6 +107,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
private ISubjectInfoSourceMapService iSubjectInfoSourceMapService;
@Autowired
private ParamAop paramAop;
@Autowired
private EsService esService;
@Value("${python.subjectProcessorUrl}")
private String subjectProcessorUrl;
@Value("${clb.subject.default.processing.advanceMonth}")
......@@ -160,6 +163,63 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
}
@Override
public Page<SubjectPageVO> pageList_new(SubjectCondition subjectCondition, Integer pageNo, Integer pageSize) {
//查询类别id的所有明细id
List<String> typeIds = new ArrayList<>();
String subjectTypeId = subjectCondition.getSubjectTypeId();
if (StringUtils.isNotEmpty(subjectTypeId) && !"0".equals(subjectTypeId)) {
typeIds = subjectTypeService.belowIdList(subjectTypeId, 1);
}
subjectCondition.setTypeIds(typeIds);
Page<SubjectPageVO> page = new Page<>(pageNo, pageSize);
Page<SubjectPageVO> pageList = baseMapper.pageList_new(subjectCondition, page);
List<SubjectPageVO> records = pageList.getRecords();
if (CollUtil.isNotEmpty(records)) {
List<String> idList = records.stream().map(SubjectPageVO::getId).collect(Collectors.toList());
//查询绑定的流程
List<ClbModelArrange> clbModelArranges = clbModelArrangeService.listBySubjectIds(idList);
if (CollectionUtil.isNotEmpty(clbModelArranges)) {
clbModelArranges.forEach(e -> e.setType(SourceTypeEnum.getValueNameByValue(e.getType())));
Map<String, List<ClbModelArrange>> collect = clbModelArranges.stream().collect(Collectors.groupingBy(ClbModelArrange::getSubjectId));
records.forEach(e -> e.setClbModelArranges(collect.get(e.getId())));
}
}
return pageList;
}
@Override
public List<SubjectStatisticInfo> statisticInfo(List<String> subjectIds) {
List<SubjectStatisticInfo> list = new ArrayList<>();
//按专题分组,统计绑定关键词组的数量
Map<String, Integer> keyWordsNumMap = commonService.bindKeyWordsCountList(subjectIds).stream().collect(Collectors.toMap(SubjectPage::getId, SubjectPage::getKeyWordsNum));
//按专题分组,统计绑定信息源的数量
Map<String, Integer> sourceCountMap = commonService.bindSourceCount(subjectIds);
//专题统计信息-总数量、最新资讯日期
List<StatisticVO> totalAndLatestDateList = esService.subjectStatisticInfo(subjectIds, null, 1);
Map<String,StatisticVO> totalAndLatestDateMap = totalAndLatestDateList.stream().collect(Collectors.toMap(StatisticVO::getSubjectId, e -> e));
//专题统计信息-待审核数量
List<StatisticVO> unCheckNumList = esService.subjectStatisticInfo(subjectIds, 0, null);
Map<String, StatisticVO> unCheckNumMap = unCheckNumList.stream().collect(Collectors.toMap(StatisticVO::getSubjectId, e->e));
for (String subjectId : subjectIds) {
SubjectStatisticInfo subjectStatisticInfo = new SubjectStatisticInfo();
subjectStatisticInfo.setSubjectId(subjectId);
subjectStatisticInfo.setTotalNum(totalAndLatestDateMap.get(subjectId).getCount());
subjectStatisticInfo.setLatestDataDate(totalAndLatestDateMap.get(subjectId).getPublishDate());
subjectStatisticInfo.setUnCheckNum(unCheckNumMap.get(subjectId).getCount());
subjectStatisticInfo.setBindSourceNum(sourceCountMap.get(subjectId) == null ? 0 : sourceCountMap.get(subjectId));
subjectStatisticInfo.setBindKeywordNum(keyWordsNumMap.get(subjectId) == null ? 0 : keyWordsNumMap.get(subjectId));
list.add(subjectStatisticInfo);
}
return list;
}
@Override
public SubjectPage getInfo(String subjectId) {
return baseMapper.getInfo(subjectId);
}
@Override
public Page<SubjectPage> researchCenterPageList(SubjectCondition subjectCondition, Integer pageNo, Integer pageSize,String flagCode,HttpServletRequest request,String username) {
Integer facePublic = subjectCondition.getFacePublic();
Page<SubjectPage> page = new Page<>(pageNo, pageSize);
......
package com.zzsn.event.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.SubjectStatisticInfo;
import com.zzsn.event.mapper.SubjectStatisticInfoMapper;
import com.zzsn.event.service.SubjectStatisticInfoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
* 准提统计信息 业务实现层
*
* @author lkg
* @date 2025/3/25
*/
@Service
public class SubjectStatisticInfoServiceImpl extends ServiceImpl<SubjectStatisticInfoMapper, SubjectStatisticInfo> implements SubjectStatisticInfoService {
@Override
@Transactional
public void batchModify(List<SubjectStatisticInfo> list) {
for (SubjectStatisticInfo subjectStatisticInfo : list) {
String subjectId = subjectStatisticInfo.getSubjectId();
LambdaQueryWrapper<SubjectStatisticInfo> query = Wrappers.lambdaQuery();
query.eq(SubjectStatisticInfo::getSubjectId, subjectId);
SubjectStatisticInfo one = this.getOne(query);
if (one == null) {
subjectStatisticInfo.setCreateTime(new Date());
this.save(subjectStatisticInfo);
} else {
subjectStatisticInfo.setId(one.getId());
subjectStatisticInfo.setUpdateTime(new Date());
this.updateById(subjectStatisticInfo);
}
}
}
}
package com.zzsn.event.task;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzsn.event.entity.Subject;
import com.zzsn.event.entity.SubjectStatisticInfo;
import com.zzsn.event.service.SubjectService;
import com.zzsn.event.service.SubjectStatisticInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CompletableFuture;
/**
* 专题统计信息任务
*
* @author lkg
* @date 2025/3/25
*/
@Slf4j
@Component
public class SubjectStatisticTask {
@Autowired
private SubjectService subjectService;
@Autowired
private SubjectStatisticInfoService subjectStatisticInfoService;
@Value("${scheduling.yjzxEnable:false}")
Boolean yjzxEnable;
@Scheduled(cron = "0 30 0 * * ?")
public void statistic() {
if(yjzxEnable){
//研究中心不需要此任务
return;
}
LambdaQueryWrapper<Subject> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.select(Subject::getId).eq(Subject::getSubjectType, 1);
List<Subject> list = subjectService.list(queryWrapper);
for (Subject subject : list) {
CompletableFuture.runAsync(() ->{
String subjectId = subject.getId();
try {
List<String> subjectIds = new ArrayList<>();
subjectIds.add(subjectId);
List<SubjectStatisticInfo> subjectStatisticInfos = subjectService.statisticInfo(subjectIds);
SubjectStatisticInfo statisticInfo = subjectStatisticInfos.get(0);
LambdaQueryWrapper<SubjectStatisticInfo> query = Wrappers.lambdaQuery();
query.eq(SubjectStatisticInfo::getSubjectId, subjectId);
SubjectStatisticInfo one = subjectStatisticInfoService.getOne(query);
if (one == null) {
statisticInfo.setCreateTime(new Date());
subjectStatisticInfoService.save(statisticInfo);
} else {
statisticInfo.setId(one.getId());
statisticInfo.setUpdateTime(new Date());
subjectStatisticInfoService.updateById(statisticInfo);
}
log.info("专题-{},统计信息任务完成",subjectId);
} catch (Exception e) {
log.info("专题-{},统计信息任务异常:{}",subjectId,e.getMessage());
}
});
}
log.info("专题统计信息任务完成");
}
}
package com.zzsn.event.vo;
import lombok.Data;
import java.util.Date;
/**
* es聚合 专题统计信息
*
* @author lkg
* @date 2025/3/25
*/
@Data
public class StatisticVO {
private String subjectId;
private Date publishDate;
private Integer count;
}
......@@ -38,4 +38,9 @@ public class SubjectCondition {
private String customerId;
/** 环境 1-测试 2-正式 */
private String environment;
/**排序字段*/
private String column;
/**排序方式*/
private String order;
}
package com.zzsn.event.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zzsn.event.entity.arrange.ClbModelArrange;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
/**
* 专题分页实体
*
* @author lkg
* @date 2025/3/25
*/
@Data
public class SubjectPageVO {
/**专题id*/
private String id;
/**专题名称*/
private String subjectName;
/**状态(1-启用;0-禁用)*/
private Integer status;
/**专题所属分类名称*/
private String subjectTypeName;
/**专题所属项目名称*/
private String projectName;
/**信息总数量*/
private Integer totalNum;
/**待审核数量*/
private Integer unCheckNum;
/**绑定信息源数量*/
private Integer bindSourceNum;
/**绑定关键词组数量*/
private Integer bindKeywordNum;
/**最新数据日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date latestDataDate;
/**主题绑定流程信息*/
private List<ClbModelArrange> clbModelArranges;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论