Commit 37d74b5f by 郑永强

feat: [1004076] 本书服务页换书与系列书整合

parent d882362e
......@@ -762,7 +762,7 @@ public interface BookBiz {
* @date:2020/11/23 19:19
* * @param null
*/
List<BookDto> getSeriesBookList(Long seriesBookId, Long subLabelId, Long graLabelId);
PageBeanNew<BookDto> getSeriesBookList(Long seriesBookId, Long subLabelId, Long graLabelId, Integer currentPage, Integer numPerPage);
/**
* 系列书查询记录
* @author:zhuyajie
......
......@@ -3678,6 +3678,12 @@ public class BookBizImpl implements BookBiz {
if (null == agentId){
return map;
}
//k12教育分类校验
List<Long> templetIds = Arrays.asList(RightsSettingConstant.K12_VERSION_ID);
// 如果不是k12分类,则无系列书
if(!templetIds.contains(bookAdviserDto.getTempletId())){
return map;
}
List<SeriesBook> seriesBooks = seriesBookDao.getSeriesBookByAgent(agentId);
if (ListUtils.isEmpty(seriesBooks)) {
return map;
......@@ -3731,27 +3737,79 @@ public class BookBizImpl implements BookBiz {
}
@Override
public List<BookDto> getSeriesBookList(Long seriesBookId, Long subLabelId, Long graLabelId) {
public PageBeanNew<BookDto> getSeriesBookList(Long seriesBookId, Long subLabelId, Long graLabelId, Integer currentPage, Integer numPerPage) {
SeriesBook seriesBook = seriesBookDao.getById(seriesBookId);
if (null == seriesBook){
return new ArrayList<>();
return new PageBeanNew<>();
}
//系列书关键词
String[] keywords = seriesBook.getSeriesBookKeyword().split(" ");
List<String> keywordList = new ArrayList<String>(Arrays.asList(keywords));
//编辑id
List<Long> adviserIds = adviserConsr.getByAgentId(seriesBook.getAgentId());
Integer currentPage = 0;
Integer numPerPage = 50;
if(!NumberUtil.isNumber(currentPage) || !NumberUtil.isNumber(numPerPage)){
currentPage = 0;
numPerPage = 50;
}
Page<ESBookAndAdviser> esPage = esBookAndAdviserBiz.getAdviserBooks4SeriesBook(keywordList, currentPage, numPerPage, adviserIds, seriesBook.getAgentId(), subLabelId, graLabelId, seriesBook.getSerialNumber());
List<ESBookAndAdviser> esBookAndAdvisers = esPage.getContent();
if (ListUtils.isEmpty(esBookAndAdvisers)) {
return new ArrayList<>();
return new PageBeanNew<>();
}
List<BookDto> bookDtos = changeToBookDto(esBookAndAdvisers);
fillOtherBookInfo(bookDtos);
fillBookInfo(bookDtos);
return bookDtos;
fillLabelNames(bookDtos);
PageBeanNew<BookDto> page = new PageBeanNew<>(currentPage,numPerPage,(int)esPage.getTotalElements(),bookDtos);
return page;
}
private void fillLabelNames(List<BookDto> recordList) {
if (ListUtils.isEmpty(recordList)) {
return;
}
List<Long> bookLabelIds = new ArrayList<>();
recordList.stream().forEach(appletUserBookcaseDTO -> {
if (null != appletUserBookcaseDTO.getGraLabelId()) {
bookLabelIds.add(appletUserBookcaseDTO.getGraLabelId());
}
if (null != appletUserBookcaseDTO.getSubLabelId()) {
bookLabelIds.add(appletUserBookcaseDTO.getSubLabelId());
}
if (null != appletUserBookcaseDTO.getVolLabelId()) {
bookLabelIds.add(appletUserBookcaseDTO.getVolLabelId());
}
if (null != appletUserBookcaseDTO.getVerLabelId()){
bookLabelIds.add(appletUserBookcaseDTO.getVerLabelId());
}
if (null != appletUserBookcaseDTO.getAreaLabelId()) {
bookLabelIds.add(appletUserBookcaseDTO.getAreaLabelId());
}
});
Map<Long, BookLabel> bookLabelMap = new HashMap<>();
if (!ListUtils.isEmpty(bookLabelIds)) {
bookLabelMap = bookLabelDao.getMapByIds(bookLabelIds);
}
for (BookDto bookDto : recordList) {
if (!MapUtils.isEmpty(bookLabelMap) && bookLabelMap.containsKey(bookDto.getGraLabelId())) {
bookDto.setGraLabelName(bookLabelMap.get(bookDto.getGraLabelId()).getName());
}
if (!MapUtils.isEmpty(bookLabelMap) && bookLabelMap.containsKey(bookDto.getSubLabelId())) {
bookDto.setSubLabelName(bookLabelMap.get(bookDto.getSubLabelId()).getName());
}
if (!MapUtils.isEmpty(bookLabelMap) && bookLabelMap.containsKey(bookDto.getVolLabelId())) {
bookDto.setVolLabelName(bookLabelMap.get(bookDto.getVolLabelId()).getName());
}
if (!MapUtils.isEmpty(bookLabelMap) && bookLabelMap.containsKey(bookDto.getVerLabelId())) {
bookDto.setVerLabelName(bookLabelMap.get(bookDto.getVerLabelId()).getName());
}
if (!MapUtils.isEmpty(bookLabelMap) && bookLabelMap.containsKey(bookDto.getAreaLabelId())) {
bookDto.setAreaLabelName(bookLabelMap.get(bookDto.getAreaLabelId()).getName());
}
}
}
@Override
......
......@@ -1222,8 +1222,10 @@ public class BookFacadeImpl implements BookFacade {
@GetMapping("getSeriesBookList")
public ResponseDto<?> getSeriesBookList(@RequestParam("seriesBookId") Long seriesBookId,
@RequestParam(value = "subLabelId", required = false) Long subLabelId,
@RequestParam(value = "graLabelId", required = false) Long graLabelId){
return new ResponseDto<>(bookBiz.getSeriesBookList(seriesBookId, subLabelId, graLabelId));
@RequestParam(value = "graLabelId", required = false) Long graLabelId,
@RequestParam(value = "currentPage", required = false, defaultValue = "0") Integer currentPage,
@RequestParam(value = "numPerPage", required = false, defaultValue = "10") Integer numPerPage){
return new ResponseDto<>(bookBiz.getSeriesBookList(seriesBookId, subLabelId, graLabelId, currentPage, numPerPage));
}
@ApiOperation("系列书查询记录埋点")
......
......@@ -3,6 +3,7 @@ package com.pcloud.book.es.biz;
import com.pcloud.book.es.entity.ESBookAndAdviser;
import org.springframework.data.domain.Page;
import java.util.HashMap;
import java.util.List;
/**
......@@ -38,4 +39,8 @@ public interface ESBookAndAdviserBiz {
* * @param null
*/
Page<ESBookAndAdviser> getAdviserBooks4SeriesBook(List<String> keywords, Integer currentPage, Integer numPerPage, List<Long> adviserIds, Long agentId, Long subLabelId, Long graLabelId, String serialNumber);
HashMap<String, String> getNotFoundBookId();
void stopNotFoundBookId();
}
......@@ -24,7 +24,9 @@ import com.pcloud.book.util.common.YesOrNoEnums;
import com.pcloud.book.util.properties.BookProps;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.enums.AppTypeEnum;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.facade.tradecenter.dto.BookIncomeQueryVo;
import com.pcloud.facade.tradecenter.dto.IncomeBackDto;
......@@ -47,6 +49,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
......@@ -66,6 +69,9 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
private static final Logger LOGGER = LoggerFactory.getLogger(ESBookAndAdviserBizImpl.class);
private static final String NOT_FOUND_BOOK_ID_SELECT_KEY = "BOOK:ESBookAndAdviserBizImpl:getNotFoundBookId";
private static final String NOT_FOUND_BOOK_ID_STATUS_SELECT_KEY = "BOOK:ESBookAndAdviserBizImpl:runStatus";
@Autowired
private BookDao bookDao;
@Autowired
......@@ -116,10 +122,6 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
}
private void fillInfo(List<ESBookAndAdviser> list, List<Long> bookIds){
//书刊资源数量(二维码)
Map<String, Integer> resourceCountMap = qrcodeSceneConsr.mapServeCount4Applet(bookIds);
//书刊资源数量(社群书)
Map<String, Integer> bookGroupResourceCountMap = bookGroupBiz.mapServeCount4Applet(bookIds);
Set<Long> searchBookIds = new HashSet<>();
Set<Long> channelIds = new HashSet<>();
Set<Long> adviserIds = new HashSet<>();
......@@ -143,6 +145,10 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
sourceAdviserIds.add(Long.valueOf(esBookAndAdviser.getAdviserId()));
sourceChannelIds.add(Long.valueOf(esBookAndAdviser.getChannelId()));
}
//书刊资源数量(二维码)
Map<String, Integer> resourceCountMap = qrcodeSceneConsr.mapServeCount4Applet(new ArrayList<>(sourceBookIds));
//书刊资源数量(社群书)
Map<String, Integer> bookGroupResourceCountMap = bookGroupBiz.mapServeCount4Applet(new ArrayList<>(sourceBookIds));
//书刊扫码量浏览量
Map<String, BrowseCacheRecordDto> bookSvUvPvMap = browseRecordConsr.getBookSvUvPv(new ArrayList<>(adviserIds),new ArrayList<>(channelIds),new ArrayList<>(searchBookIds));
// 获取书刊累计收益(销售额)
......@@ -452,12 +458,61 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
BoolQueryBuilder should1 = QueryBuilders.boolQuery().should(QueryBuilders.termQuery("isAdviserBook",1));
boolQueryBuilder.must(should1);
//权益
BoolQueryBuilder should2 = QueryBuilders.boolQuery().mustNot(QueryBuilders.termQuery("rightsSettingId",0));
boolQueryBuilder.must(should2);
// BoolQueryBuilder should2 = QueryBuilders.boolQuery().mustNot(QueryBuilders.termQuery("rightsSettingId",0));
// boolQueryBuilder.must(should2);
Sort sort = new Sort(Sort.Direction.DESC, "lastModifiedDate", "bookId");
PageRequest pageRequest = new PageRequest(currentPage, numPerPage, sort);
Page<ESBookAndAdviser> search = bookAndAdviserRepository.search(boolQueryBuilder, pageRequest);
return search;
}
@Override
public HashMap<String, String> getNotFoundBookId() {
String lock = JedisClusterUtils.get(NOT_FOUND_BOOK_ID_SELECT_KEY);
if(StringUtil.isEmpty(lock)){
throw new BizException(BizException.DB_DML_FAIL.getCode(), "请不要重复执行");
}
JedisClusterUtils.set(NOT_FOUND_BOOK_ID_SELECT_KEY, "lock", 3600);
// 解除停止状态
JedisClusterUtils.set(NOT_FOUND_BOOK_ID_STATUS_SELECT_KEY, "running", 3600);
Integer pageNumber = 100;
List<String> content = null;
try {
String runStatus = "running";
while ("running".equalsIgnoreCase(runStatus)) {
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
PageRequest pageRequest = new PageRequest(0, 10000);
Page<String> map = bookAndAdviserRepository.search(boolQueryBuilder, pageRequest).map(x -> x.getBookId());
if (map.getSize() > 0) {
// 循环查询数据库,每次100条
for (int i = 0; i < (map.getSize() % pageNumber == 0 ? map.getSize()/pageNumber : (map.getSize()/pageNumber+1)); i++) {
content = map.getContent().stream().skip(i * pageNumber).limit(pageNumber).collect(Collectors.toList());
// TODO 查询,并筛选出不存在的数据
throw new BizException("暂未实现");
}
}
runStatus = JedisClusterUtils.get(NOT_FOUND_BOOK_ID_STATUS_SELECT_KEY);
}
if("stop".equalsIgnoreCase(runStatus)){
HashMap<String, String> resultMap = new HashMap<>();
resultMap.put("runStatus", runStatus);
resultMap.put("msg", "执行被终止");
return resultMap;
}
return new HashMap<>();
} finally {
// 移除执行
JedisClusterUtils.del(NOT_FOUND_BOOK_ID_SELECT_KEY);
}
}
@Override
public void stopNotFoundBookId() {
String runStatus = JedisClusterUtils.get(NOT_FOUND_BOOK_ID_STATUS_SELECT_KEY);
if(StringUtil.isEmpty(runStatus)){
throw new BizException(BizException.DB_SELECT_IS_FAIL.getCode(), "当前没有执行中的任务");
}
JedisClusterUtils.set(NOT_FOUND_BOOK_ID_STATUS_SELECT_KEY, "stop", 3600);
}
}
......@@ -65,4 +65,16 @@ public class ESBookAndAdviserFacade {
return new ResponseDto<>();
}
@ApiOperation("查询ES有而BOOK表没有的书")
@GetMapping("getNotFoundBookId")
public ResponseDto<?> getNotFoundBookId() throws BizException {
return new ResponseDto<>(esBookAndAdviserBiz.getNotFoundBookId());
}
@ApiOperation("停止查询ES有而BOOK表没有的书")
@GetMapping("getNotFoundBookId")
public ResponseDto<?> stopNotFoundBookId() throws BizException {
esBookAndAdviserBiz.stopNotFoundBookId();
return new ResponseDto<>();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment