提交 e5e191de 作者: zgz

查询优化

上级 48c6c2a1
...@@ -275,6 +275,7 @@ public class LeaderCategoryServiceImpl extends ServiceImpl<LeaderCategoryMapper, ...@@ -275,6 +275,7 @@ public class LeaderCategoryServiceImpl extends ServiceImpl<LeaderCategoryMapper,
map.put(item.getId(), item); map.put(item.getId(), item);
} else { } else {
existing.setThinktankCount(existing.getThinktankCount() + item.getThinktankCount()); existing.setThinktankCount(existing.getThinktankCount() + item.getThinktankCount());
map.put(item.getId(), existing);
} }
} }
List<ThinktankCategoryStructureVo> mergedList = new ArrayList<>(map.values()); List<ThinktankCategoryStructureVo> mergedList = new ArrayList<>(map.values());
......
...@@ -29,11 +29,13 @@ import org.springframework.stereotype.Service; ...@@ -29,11 +29,13 @@ import org.springframework.stereotype.Service;
import org.springframework.util.ResourceUtils; import org.springframework.util.ResourceUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -82,7 +84,9 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf ...@@ -82,7 +84,9 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
@Value("${files.storage}") @Value("${files.storage}")
String filesStorage; String filesStorage;
@Resource
private SimRedisUtil simRedisUtil;
private final static String KEY = "thinkTank:getList";
private static final String IMPORT_TEMP = "think-tank-import-temp.xlsx"; private static final String IMPORT_TEMP = "think-tank-import-temp.xlsx";
private static final String IMPORT_TEMP_NAME = "智库信息导入模板.xlsx"; private static final String IMPORT_TEMP_NAME = "智库信息导入模板.xlsx";
...@@ -300,6 +304,15 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf ...@@ -300,6 +304,15 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
@Override @Override
public Result<?> getList(ThinktankBasicInfoListVo thinktankBasicInfoListVo) { public Result<?> getList(ThinktankBasicInfoListVo thinktankBasicInfoListVo) {
if(thinktankBasicInfoListVo!=null && StringUtils.isNotBlank(thinktankBasicInfoListVo.getTypeId())
&& StringUtils.isBlank(thinktankBasicInfoListVo.getTagId())){
IPage cacheObject = (IPage)simRedisUtil.getCacheObject(KEY + "_" + thinktankBasicInfoListVo.getTypeId()
+ "_" + thinktankBasicInfoListVo.getColumn() + "_" + thinktankBasicInfoListVo.getOrder());
if(cacheObject!=null){
return Result.OK(cacheObject);
}
}
IPage page = new Page(); IPage page = new Page();
thinktankBasicInfoListVo.setColumn(StringUtil.humpToLine(thinktankBasicInfoListVo.getColumn())); thinktankBasicInfoListVo.setColumn(StringUtil.humpToLine(thinktankBasicInfoListVo.getColumn()));
...@@ -386,7 +399,11 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf ...@@ -386,7 +399,11 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
thinktankTagService.addTagTop(s); thinktankTagService.addTagTop(s);
} }
} }
if(thinktankBasicInfoListVo!=null && StringUtils.isNotBlank(thinktankBasicInfoListVo.getTypeId())
&& StringUtils.isBlank(thinktankBasicInfoListVo.getTagId())){
simRedisUtil.setCacheObject(KEY + "_" + thinktankBasicInfoListVo.getTypeId()
+ "_" + thinktankBasicInfoListVo.getColumn() + "_" + thinktankBasicInfoListVo.getOrder(), page,10L, TimeUnit.DAYS);
}
return Result.OK(page); return Result.OK(page);
} }
...@@ -825,25 +842,28 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf ...@@ -825,25 +842,28 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
} }
}); });
} }
if(regionalCountriesTypeId!=null && regionalCountriesTypeId.size()>0){ if(regionalCountriesTypeId!=null && regionalCountriesTypeId.size()>0 && StringUtils.isNotBlank(regionalCountriesTypeId.get(0))){
for(String id:regionalCountriesTypeId){ for(String id:regionalCountriesTypeId){
SysBaseRegion region = sysBaseRegionService.getById(id); SysBaseRegion region = sysBaseRegionService.getById(id);
if(region!=null && region.getLevelId()!=null && region.getLevelId().equals("country")){ if(region!=null && region.getLevelId()!=null && region.getLevelId().equals("country")){
regionalCountriesTypeIds.add(id); regionalCountriesTypeIds.add(id);
}else if(region!=null && region.getLevelId()!=null && region.getLevelId().equals("continent")){ }else if(region!=null && region.getLevelId()!=null && region.getLevelId().equals("continent")){
QueryWrapper<SysBaseRegion> query = new QueryWrapper<>(); QueryWrapper<SysBaseRegion> query = new QueryWrapper<>();
query.eq("pid","id"); query.eq("pid",id);
List<SysBaseRegion> list = sysBaseRegionService.list(query); List<SysBaseRegion> list = sysBaseRegionService.list(query);
for(SysBaseRegion obj:list){ for(SysBaseRegion obj:list){
regionalCountriesTypeIds.add(obj.getId()); regionalCountriesTypeIds.add(obj.getId());
} }
} }
} }
}else{
//查询国外智库
queryWrapper.ne("belong_country_id","1405761925932109826");//查询非中国智库
} }
if(regionalCountriesTypeIds!=null && regionalCountriesTypeIds.size()>0){ if(regionalCountriesTypeIds!=null && regionalCountriesTypeIds.size()>0){
queryWrapper.and(wreapper->{ queryWrapper.and(wreapper->{
for(int i=0;i<regionalCountriesTypeIds.size();i++){ for(int i=0;i<regionalCountriesTypeIds.size();i++){
wreapper.like("belong_country_id",regionalCountriesTypeIds.get(i)); wreapper.eq("belong_country_id",regionalCountriesTypeIds.get(i));
if(i != regionalCountriesTypeIds.size()-1){ if(i != regionalCountriesTypeIds.size()-1){
wreapper.or(); wreapper.or();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论