提交 5e15cde4 作者: obcy

【添加数据分页查询接口-数据处理使用】

上级 4f44a2a6
......@@ -19,6 +19,7 @@ import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*;
import com.zzsn.event.vo.es.DisplayInfo;
import com.zzsn.event.vo.es.SpecialInformation;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
......@@ -208,8 +209,27 @@ public class InformationController {
if (searchCondition.getCategory() == null) {
return Result.FAIL("专题类型不能为空");
}
UserVo userVo = UserUtil.getLoginUser();
IPage<DisplayInfo> pageList = informationService.subjectPageList(userVo, searchCondition);
IPage<DisplayInfo> pageList = informationService.subjectPageList(searchCondition);
return Result.OK(pageList);
}
/**
* 事件对应专题库的资讯分页列表
*
* @param searchCondition 筛选条件
* @author lkg
* @date 2024/5/6
*/
@PostMapping("/subjectPageListForDataDetail")
public Result<?> subjectPageListForDataDetail(@RequestBody InfoDataSearchCondition searchCondition) {
if (StringUtils.isEmpty(searchCondition.getSubjectId())) {
return Result.FAIL("专题id/专题分类id不能为空");
}
if (searchCondition.getCategory() == null) {
return Result.FAIL("专题类型不能为空");
}
//排除字段默认不排除
searchCondition.setExcludeFields(null);
IPage<SpecialInformation> pageList = informationService.subjectPageListForDataDetail(searchCondition);
return Result.OK(pageList);
}
......
......@@ -739,8 +739,10 @@ public class EsService {
* @date 2024/5/6
*/
public IPage<SpecialInformation> pageListByCondition(InfoDataSearchCondition searchCondition, List<String> subjectIdList) throws IOException {
Subject byId = subjectService.getById(searchCondition.getSubjectId());
String[] indexs = EsIndexUtil.getIndexIntervalYear(Constants.SUBJECT_INDEX, byId.getCreateTime());
String minDate = subjectService.getMinCreateTime(subjectIdList);
// Subject byId = subjectService(searchCondition.getSubjectId());
String[] indexs = EsIndexUtil.getIndexIntervalYearStr(Constants.SUBJECT_INDEX, minDate);
SearchRequest searchRequest = new SearchRequest(indexs);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//默认最大数量是10000,设置为true后,显示准确数量
......@@ -822,8 +824,8 @@ public class EsService {
List<String> list = new ArrayList<>();
List<String> idList = Arrays.asList(ids.split(","));
List<String> beInStorageList = idList.stream().map(uniqueCode -> subjectId + uniqueCode).collect(Collectors.toList());
Subject byId = subjectService.getById(subjectId);
String[] indexs = EsIndexUtil.getIndexIntervalYear(Constants.SUBJECT_INDEX, byId.getCreateTime());
String minDate = subjectService.getMinCreateTime(Arrays.asList(subjectId));
String[] indexs = EsIndexUtil.getIndexIntervalYearStr(Constants.SUBJECT_INDEX, minDate);
SearchRequest searchRequest = new SearchRequest(indexs);
//创建查询对象
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
......@@ -1071,8 +1073,8 @@ public class EsService {
//调用判重接口
public boolean duplicationByTitleOrSourceAddress(DisplayInfo displayInfo) {
Subject byId = subjectService.getById(displayInfo.getSubjectId());
String[] indexs = EsIndexUtil.getIndexIntervalYear(Constants.SUBJECT_INDEX, byId.getCreateTime());
String minDate = subjectService.getMinCreateTime(Arrays.asList(displayInfo.getSubjectId()));
String[] indexs = EsIndexUtil.getIndexIntervalYearStr(Constants.SUBJECT_INDEX, minDate);
SearchRequest searchRequest = new SearchRequest(indexs);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
......@@ -1113,8 +1115,8 @@ public class EsService {
if (CollectionUtils.isNotEmpty(ids)) {
count = ids.size();
} else {
Subject byId = subjectService.getById(searchCondition.getSubjectId());
String[] indexs = EsIndexUtil.getIndexIntervalYear(Constants.SUBJECT_INDEX, byId.getCreateTime());
String minDate = subjectService.getMinCreateTime(Arrays.asList(searchCondition.getSubjectId()));
String[] indexs = EsIndexUtil.getIndexIntervalYearStr(Constants.SUBJECT_INDEX, minDate);
SearchRequest searchRequest = new SearchRequest(indexs);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//默认最大数量是10000,设置为true后,显示准确数量
......@@ -1158,8 +1160,8 @@ public class EsService {
* @param searchCondition 查询条件封装
*/
public List<SpecialInformation> informationList(InfoDataSearchCondition searchCondition) {
Subject byId = subjectService.getById(searchCondition.getSubjectId());
String[] indexs = EsIndexUtil.getIndexIntervalYear(Constants.SUBJECT_INDEX, byId.getCreateTime());
String minDate = subjectService.getMinCreateTime(Arrays.asList(searchCondition.getSubjectId()));
String[] indexs = EsIndexUtil.getIndexIntervalYearStr(Constants.SUBJECT_INDEX, minDate);
SearchRequest searchRequest = new SearchRequest(indexs);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
String column = searchCondition.getColumn();
......
......@@ -121,4 +121,6 @@ public interface SubjectMapper extends BaseMapper<Subject> {
int ynBelowExcludeGroup(@Param("subjectId") String subjectId, @Param("sourceId") String sourceId);
List<String> getBindSubjectIds(@Param("id")String id);
String getMinCreateTime(@Param("subjectIdList") List<String> subjectIdList);
}
......@@ -289,4 +289,12 @@
where subject_id = #{id}
and addition_type = 1
</select>
<select id="getMinCreateTime" resultType="java.lang.String">
SELECT MIN(create_time) FROM `subject` WHERE 1=1
<if test="subjectIdList != null">
<foreach collection="subjectIdList" item="item" open="and id in (" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
</mapper>
......@@ -33,12 +33,19 @@ public interface InformationService {
/**
* 专题库资讯分页列表
*
* @param userVo 用户信息
* @param subjectInfo 筛选条件
* @author lkg
* @date 2024/5/6
*/
IPage<DisplayInfo> subjectPageList(UserVo userVo, InfoDataSearchCondition subjectInfo);
IPage<DisplayInfo> subjectPageList(InfoDataSearchCondition subjectInfo);
/**
* 专题库资讯分页列表
*
* @param subjectInfo 筛选条件
* @author lkg
* @date 2024/5/6
*/
IPage<SpecialInformation> subjectPageListForDataDetail(InfoDataSearchCondition subjectInfo);
/**
* 资讯分页列表(根据标签分类分组)
*/
......
......@@ -200,4 +200,6 @@ public interface SubjectService extends IService<Subject> {
Result<?> infoSourceBindNew(SubjectPage subjectPage);
void deleteBindNew(SubjectPage subjectPage);
String getMinCreateTime(List<String> subjectIdList);
}
......@@ -99,7 +99,7 @@ public class InformationServiceImpl implements InformationService {
}
@Override
public IPage<DisplayInfo> subjectPageList(UserVo userVo, InfoDataSearchCondition searchCondition) {
public IPage<DisplayInfo> subjectPageList(InfoDataSearchCondition searchCondition) {
IPage<DisplayInfo> page = new Page<>(searchCondition.getPageNo(), searchCondition.getPageSize());
Integer category = searchCondition.getCategory();
List<String> subjectIdList = new ArrayList<>();
......@@ -134,13 +134,6 @@ public class InformationServiceImpl implements InformationService {
DisplayInfo info = new DisplayInfo();
BeanUtils.copyProperties(specialInformation, info);
info.setPublishDate(EsDateUtil.esFieldDateMapping(info.getPublishDate()));
/*LambdaQueryWrapper<CollectionMap> query = Wrappers.lambdaQuery();
query.eq(CollectionMap::getUserId, userVo.getId());
query.eq(CollectionMap::getArticleId, info.getId());
int count = collectionMapService.count(query);
if (count > 0) {
info.setYnCollect(true);
}*/
//标签处理
List<LabelModelVo> modelVoList = modelMap.get(info.getSubjectId());
formatLabel(modelVoList, info);
......@@ -155,6 +148,38 @@ public class InformationServiceImpl implements InformationService {
return page;
}
@Override
public IPage<SpecialInformation> subjectPageListForDataDetail(InfoDataSearchCondition searchCondition) {
IPage<SpecialInformation> page = new Page<>(searchCondition.getPageNo(), searchCondition.getPageSize());
Integer category = searchCondition.getCategory();
List<String> subjectIdList = new ArrayList<>();
//判断是否是专题
if ("1".equals(searchCondition.getIsSubject())) {
if (StringUtils.isNotEmpty(searchCondition.getSubjectId())) {
subjectIdList.add(searchCondition.getSubjectId());
}
} else {
//该id其实是专题类别id
//查询类别id的所有明细id
String subjectTypeId = searchCondition.getSubjectId();
List<String> typeIds = subjectTypeService.belowIdList(subjectTypeId, category);
if (category == 1) {
subjectIdList = subjectTypeMapService.selectSubjectByTypeIds(typeIds);
} else if (category == 2) {
subjectIdList = subjectTypeMapService.selectEventByTypeIds(typeIds);
}
}
if (CollectionUtils.isEmpty(subjectIdList)) {
return page;
}
try {
return esService.pageListByCondition(searchCondition, subjectIdList);
} catch (Exception e) {
e.printStackTrace();
}
return page;
}
@Autowired
private SubjectMapper subjectMapper;
......
......@@ -899,6 +899,11 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
configurationMessageService.bindInfoSourceSend(subjectPage.getId());
}
@Override
public String getMinCreateTime(List<String> subjectIdList) {
return baseMapper.getMinCreateTime(subjectIdList);
}
private void unBindInfoSourceGroup(SubjectPage subjectPage) {
String sourceBindType = subjectPage.getSourceBindType();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论