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

调试bug修改

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