提交 218f9fe8 作者: 925993793@qq.com

调试bug修改

上级 df3a629b
......@@ -19,7 +19,6 @@ import com.zzsn.event.service.LabelEntityService;
import com.zzsn.event.util.HttpUtil;
import com.zzsn.event.util.ObjectUtil;
import com.zzsn.event.util.RedisUtil;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*;
......
......@@ -23,9 +23,11 @@ import com.zzsn.event.vo.*;
import com.zzsn.event.vo.es.SpecialInformation;
import com.zzsn.event.xxljob.entity.XxlJobInfo;
import com.zzsn.event.xxljob.service.IXxlJobInfoService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.common.utils.SecurityUtils;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
......
......@@ -203,7 +203,7 @@ public class InformationController {
@PostMapping("/subjectPageList")
public Result<?> subjectPageList(@RequestBody InfoDataSearchCondition searchCondition) {
if (StringUtils.isEmpty(searchCondition.getSubjectId())) {
return Result.FAIL("专题id不能为空");
return Result.FAIL("专题id/专题分类id不能为空");
}
UserVo userVo = UserUtil.getLoginUser();
IPage<DisplayInfo> pageList = informationService.subjectPageList(userVo, searchCondition);
......@@ -421,7 +421,7 @@ public class InformationController {
}
/**
* 根据条件移除专题下数据-研究中心
* 根据条件新增专题下数据-研究中心
*
* @param params 参数
* @author lkg
......@@ -437,9 +437,7 @@ public class InformationController {
if (CollectionUtils.isEmpty(themeIds)) {
return Result.FAIL("新增的主题id集合不能为空");
}
//todo 新增 redis塞缓存,对接数据处理
//2025-01-21:123,123,123
informationService.supplyByCondition(subjectId, JSONArray.parseArray(themeIds.toJSONString(), String.class));
return Result.OK();
}
}
......@@ -11,7 +11,9 @@ import com.zzsn.event.entity.Event;
import com.zzsn.event.service.IEventService;
import com.zzsn.event.service.IInfoSourceService;
import com.zzsn.event.service.ISubjectTypeService;
import com.zzsn.event.util.*;
import com.zzsn.event.util.EsDateUtil;
import com.zzsn.event.util.EsOpUtil;
import com.zzsn.event.util.Utility;
import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*;
......@@ -19,16 +21,11 @@ import com.zzsn.event.vo.es.DisplayInfo;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 平台事件管理页
......@@ -366,9 +363,7 @@ public class PlatEventManageController {
queryWrapper.le(Event::getCreateTime, endDate);
}
if (StringUtils.isNotEmpty(keyword)) {
queryWrapper.and(q -> {
q.eq(Event::getEventType, keyword).or().like(Event::getEventName, keyword).or().eq(Event::getEventDescribe, keyword);
});
queryWrapper.and(q -> q.eq(Event::getEventType, keyword).or().like(Event::getEventName, keyword).or().eq(Event::getEventDescribe, keyword));
}
}
}
......@@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.entity.Event;
import com.zzsn.event.entity.Subject;
import com.zzsn.event.service.*;
import com.zzsn.event.util.DateUtil;
import com.zzsn.event.util.EsDateUtil;
......@@ -70,6 +72,8 @@ public class EsService {
@Autowired
private ISubjectTypeService subjectTypeService;
@Autowired
private SubjectService subjectService;
@Autowired
private IEventService eventService;
@Autowired
private ISubjectInfoSourceMapService subjectInfoSourceMapService;
......@@ -1079,8 +1083,7 @@ public class EsService {
if (CollectionUtils.isNotEmpty(ids)) {
count = ids.size();
} else {
String[] indexArr = EsIndexUtil.getIndexIntervalYear(Constants.SUBJECT_INDEX, searchCondition.getStartTime(), searchCondition.getEndTime());
SearchRequest searchRequest = new SearchRequest(indexArr);
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//默认最大数量是10000,设置为true后,显示准确数量
searchSourceBuilder.trackTotalHits(true);
......@@ -1107,8 +1110,7 @@ public class EsService {
* @param searchCondition 查询条件封装
*/
public List<SpecialInformation> informationList(InfoDataSearchCondition searchCondition) {
String[] indexArr = EsIndexUtil.getIndexIntervalYear(Constants.SUBJECT_INDEX, searchCondition.getStartTime(), searchCondition.getEndTime());
SearchRequest searchRequest = new SearchRequest(indexArr);
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
String column = searchCondition.getColumn();
String order = searchCondition.getOrder();
......@@ -1666,6 +1668,45 @@ public class EsService {
return list;
}
/**
*
*
* @param subjectIdList 专题id集合
* @param sortOrder 排序方式
* @author lkg
* @date 2025/2/21
*/
public String getFirstTime(List<String> subjectIdList,String sortOrder){
String firstTime = null;
InfoDataSearchCondition searchCondition = new InfoDataSearchCondition();
searchCondition.setColumn("publishDate");
searchCondition.setOrder(sortOrder);
searchCondition.setFetchFields(new String[]{"publishDate"});
searchCondition.setDeleteFlag(0);
BoolQueryBuilder boolQueryBuilder = buildQuery(searchCondition, subjectIdList);
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//默认最大数量是10000,设置为true后,显示准确数量
searchSourceBuilder.trackTotalHits(true);
searchSourceBuilder.size(1);
searchSourceBuilder.query(boolQueryBuilder);
searchRequest.source(searchSourceBuilder);
try {
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
SearchHits searchHits = searchResponse.getHits();
if (searchHits != null) {
SearchHit hit = searchHits.getHits()[0];
Map<String, Object> sourceAsMap = hit.getSourceAsMap();
String publishDateStr = sourceAsMap.get("publishDate").toString();
firstTime = EsDateUtil.esFieldDateMapping(publishDateStr).substring(0,10);
}
} catch (Exception e) {
e.printStackTrace();
}
return firstTime;
}
/**
* term方式聚合分组
*
......@@ -1731,7 +1772,31 @@ public class EsService {
//创建查询对象
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
if (CollectionUtils.isNotEmpty(subjectIdList)) {
Integer category = searchCondition.getCategory();
boolQuery.must(QueryBuilders.termsQuery("subjectId.keyword", subjectIdList));
if (subjectIdList.size() == 1) {
String configStartTime = null;
String configEndTime = null;
String id = subjectIdList.get(0);
if (category == 1) {
Subject subject = subjectService.getById(id);
configStartTime = DateUtil.dateToString(subject.getTimeEnable());
configEndTime = DateUtil.dateToString(subject.getTimeDisable());
} else if (category == 2) {
Event event = eventService.getById(id);
configStartTime = DateUtil.dateToString(event.getStartTime());
configEndTime = DateUtil.dateToString(event.getEndTime());
}
//时间过滤筛选-专题配置
if (StringUtils.isNotBlank(configStartTime)) {
boolQuery.filter(QueryBuilders.rangeQuery("publishDate").gte(EsDateUtil.esFieldDateFormat(configStartTime)));
}
if (StringUtils.isNotBlank(configEndTime)) {
boolQuery.filter(QueryBuilders.rangeQuery("publishDate").lte(EsDateUtil.esFieldDateFormat(configEndTime)));
} else {
boolQuery.filter(QueryBuilders.rangeQuery("publishDate").lte(EsDateUtil.esFieldDateFormat(DateUtil.dateToString(new Date()))));
}
}
}
List<SearchWordVO> searchWordList = searchCondition.getSearchWordList();
//研究中心 搜索词方式
......@@ -1800,7 +1865,7 @@ public class EsService {
if (maxScore != null) {
boolQuery.filter(QueryBuilders.rangeQuery("score").lte(maxScore));
}
//时间过滤筛选
//时间过滤筛选-前端传参
if (StringUtils.isNotBlank(searchCondition.getStartTime())) {
boolQuery.filter(QueryBuilders.rangeQuery("publishDate").gte(EsDateUtil.esFieldDateFormat(searchCondition.getStartTime())));
}
......
......@@ -68,6 +68,8 @@ public interface SubjectTypeMapper extends BaseMapper<SubjectType> {
* @date 2025/1/8
*/
List<SubjectTypeTreeVO> typeBindCountTreeList(@Param("category") Integer category);
List<SubjectTypeTreeVO> typeBindSubjectList();
List<SubjectTypeTreeVO> typeBindEventList();
/**
* 根据是否公开获取专题列表
......
......@@ -19,7 +19,7 @@
</update>
<select id="typeBindCountTreeList" resultType="com.zzsn.event.vo.SubjectTypeTreeVO">
SELECT t.id,t.type_name as name,t.pid,count(m.type_id) as subjectCount,t.create_time
SELECT t.id,t.type_name as name,t.pid,count(m.type_id) as subjectCount,t.create_time,'false' as ynSubject
FROM subject_type t
inner join `subject_type_map` m on t.id = m.type_id
<if test="category != null and category == 1">
......@@ -32,6 +32,18 @@
group by m.type_id
order by t.create_time
</select>
<select id="typeBindSubjectList" resultType="com.zzsn.event.vo.SubjectTypeTreeVO">
SELECT s.id,s.subject_name as name,m.type_id as pid,'0' as subjectCount,s.create_time,'true' as ynSubject
FROM subject s
inner join `subject_type_map` m on s.id = m.subject_id
order by s.create_time
</select>
<select id="typeBindEventList" resultType="com.zzsn.event.vo.SubjectTypeTreeVO">
SELECT s.id,s.event_name as name,m.type_id as pid,'0' as subjectCount,s.create_time,'true' as ynSubject
FROM event s
inner join `subject_type_map` m on s.id = m.subject_id
order by s.create_time
</select>
<select id="subjectsByFacePublic" resultType="com.zzsn.event.vo.SubjectTreeVO">
select s.id,
......
......@@ -198,9 +198,18 @@ public interface InformationService {
* 移除专题下的数据-研究中心
*
* @param subjectId 专题id
* @param themeIds 主题(关联标签)id集合
* @param themeIds 删除主题(关联标签)id集合
* @author lkg
* @date 2025/2/20
*/
void removeByCondition(String subjectId, List<String> themeIds);
/**
* 新增专题下的数据-研究中心
*
* @param subjectId 专题id
* @param themeIds 新增主题(关联标签)id集合
* @author lkg
* @date 2025/2/20
*/
void supplyByCondition(String subjectId, List<String> themeIds);
}
......@@ -99,6 +99,7 @@ public class InformationServiceImpl implements InformationService {
@Override
public IPage<DisplayInfo> subjectPageList(UserVo userVo, InfoDataSearchCondition searchCondition) {
IPage<DisplayInfo> page = new Page<>(searchCondition.getPageNo(), searchCondition.getPageSize());
Integer category = searchCondition.getCategory();
List<String> subjectIdList = new ArrayList<>();
//判断是否是专题
if ("1".equals(searchCondition.getIsSubject())) {
......@@ -109,7 +110,6 @@ public class InformationServiceImpl implements InformationService {
//该id其实是专题类别id
//查询类别id的所有明细id
String subjectTypeId = searchCondition.getSubjectId();
Integer category = searchCondition.getCategory();
List<String> typeIds = subjectTypeService.belowIdList(subjectTypeId, category);
if (category == 1) {
subjectIdList = subjectTypeMapService.selectSubjectByTypeIds(typeIds);
......@@ -809,6 +809,23 @@ public class InformationServiceImpl implements InformationService {
}
//python 去重接口
pythonUtil.clearDuplicateHistory(themeIds);
}
@Override
public void supplyByCondition(String subjectId, List<String> themeIds) {
Subject subject = subjectService.getById(subjectId);
String startTime = esService.getFirstTime(themeIds, "asc");
String endTime = esService.getFirstTime(themeIds, "desc");
List<String> dateList = DateUtil.betweenDate(startTime, endTime);
if (CollectionUtils.isNotEmpty(dateList)) {
List<String> redisCacheList = new ArrayList<>();
for (String date : dateList) {
//2025-01-21:123,123,123
String dateStr = date + ":" + StringUtils.join(",", themeIds);
redisCacheList.add(dateStr);
}
redisUtil.rpushMultipleValues(Constants.HISTORY_SUBJECT_DATE_QUEUE + subject.getSubjectCode(),redisCacheList.toArray(new String[0]));
}
}
......
......@@ -160,6 +160,14 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje
subjectTypeTreeVOS.add(subjectTypeTreeVO);
}
}
//获取专题数据
List<SubjectTypeTreeVO> dataList = new ArrayList<>();
if (category == 1) {
dataList = baseMapper.typeBindSubjectList();
} else if (category == 2) {
dataList = baseMapper.typeBindEventList();
}
subjectTypeTreeVOS.addAll(dataList);
//构造树型结构
resultList = TreeUtil.tree(subjectTypeTreeVOS, "0");
//递归统计绑定专题的数量
......
......@@ -23,6 +23,9 @@ public class DateUtil {
}
public static String dateToString(Date date) {
if (date == null) {
return null;
}
format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return format.format(date);
}
......
......@@ -35,6 +35,13 @@ public class InfoDataSearchCondition {
//结束时间
private String endTime;
/*-----------------单个专题时,起效-----------*/
//专题配置的开始时间
private String configStartTime;
//专题配置的结束时间
private String configEndTime;
/*-----------------单个专题时,起效-----------*/
//专题库类型(对应字典编码为【Thematic_Library】的数据字典值)
private List<Integer> classificationType;
......
......@@ -20,4 +20,6 @@ public class SubjectTypeTreeVO extends Node {
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date createTime;
private boolean ynSubject;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论