Commit d00bde17 by 李传峰

Merge remote-tracking branch 'remotes/origin/feature/2.x' into 3.x

# Conflicts:
#	pcloud-service-book/pom.xml
parents 27a0dec2 5b7a64d8
...@@ -3728,13 +3728,13 @@ public class BookBizImpl implements BookBiz { ...@@ -3728,13 +3728,13 @@ public class BookBizImpl implements BookBiz {
return new ArrayList<>(); return new ArrayList<>();
} }
//系列书关键词 //系列书关键词
String[] keywords = seriesBook.getSeriesBookKeyword().split(" "); // String[] keywords = seriesBook.getSeriesBookKeyword().split(" ");
List<String> keywordList = new ArrayList<String>(Arrays.asList(keywords)); // List<String> keywordList = new ArrayList<String>(Arrays.asList(keywords));
//编辑id //编辑id
List<Long> adviserIds = adviserConsr.getByAgentId(seriesBook.getAgentId()); List<Long> adviserIds = adviserConsr.getByAgentId(seriesBook.getAgentId());
Integer currentPage = 0; Integer currentPage = 0;
Integer numPerPage = 50; Integer numPerPage = 50;
Page<ESBookAndAdviser> esPage = esBookAndAdviserBiz.getAdviserBooks4SeriesBook(keywordList, currentPage, numPerPage, adviserIds, seriesBook.getAgentId(), null, graLabelId, seriesBook.getSerialNumber(), null, null); Page<ESBookAndAdviser> esPage = esBookAndAdviserBiz.getAdviserBooks4SeriesBook(seriesBook.getSeriesBookKeyword(), currentPage, numPerPage, adviserIds, seriesBook.getAgentId(), null, graLabelId, seriesBook.getSerialNumber(), null, null);
List<ESBookAndAdviser> esBookAndAdvisers = esPage.getContent(); List<ESBookAndAdviser> esBookAndAdvisers = esPage.getContent();
if (ListUtils.isEmpty(esBookAndAdvisers)) { if (ListUtils.isEmpty(esBookAndAdvisers)) {
return new ArrayList<>(); return new ArrayList<>();
...@@ -3800,7 +3800,7 @@ public class BookBizImpl implements BookBiz { ...@@ -3800,7 +3800,7 @@ public class BookBizImpl implements BookBiz {
} }
if (isSeriesBook){ if (isSeriesBook){
List<Long> adviserIds = adviserConsr.getByAgentId(agentId); List<Long> adviserIds = adviserConsr.getByAgentId(agentId);
Page<ESBookAndAdviser> esPage = esBookAndAdviserBiz.getAdviserBooks4SeriesBook(keywordList, 0, 50, adviserIds, agentId, null, bookAdviserDto.getGraLabelId(), serialNumber, null, null); Page<ESBookAndAdviser> esPage = esBookAndAdviserBiz.getAdviserBooks4SeriesBook(StringUtils.join(keywordList, ' '), 0, 50, adviserIds, agentId, null, bookAdviserDto.getGraLabelId(), serialNumber, null, null);
List<ESBookAndAdviser> esBookAndAdvisers = esPage.getContent(); List<ESBookAndAdviser> esBookAndAdvisers = esPage.getContent();
List<Long> subjectLabels = new ArrayList<>(); List<Long> subjectLabels = new ArrayList<>();
if (!ListUtils.isEmpty(esBookAndAdvisers)) { if (!ListUtils.isEmpty(esBookAndAdvisers)) {
...@@ -3829,15 +3829,15 @@ public class BookBizImpl implements BookBiz { ...@@ -3829,15 +3829,15 @@ public class BookBizImpl implements BookBiz {
return new PageBeanNew<>(); return new PageBeanNew<>();
} }
//系列书关键词 //系列书关键词
String[] keywords = seriesBook.getSeriesBookKeyword().split(" "); // String[] keywords = seriesBook.getSeriesBookKeyword().split(" ");
List<String> keywordList = new ArrayList<String>(Arrays.asList(keywords)); // List<String> keywordList = new ArrayList<String>(Arrays.asList(keywords));
//编辑id //编辑id
List<Long> adviserIds = adviserConsr.getByAgentId(seriesBook.getAgentId()); List<Long> adviserIds = adviserConsr.getByAgentId(seriesBook.getAgentId());
if(!NumberUtil.isNumber(currentPage) || !NumberUtil.isNumber(numPerPage)){ if(!NumberUtil.isNumber(currentPage) || !NumberUtil.isNumber(numPerPage)){
currentPage = 0; currentPage = 0;
numPerPage = 50; numPerPage = 50;
} }
Page<ESBookAndAdviser> esPage = esBookAndAdviserBiz.getAdviserBooks4SeriesBook(keywordList, currentPage, numPerPage, adviserIds, Page<ESBookAndAdviser> esPage = esBookAndAdviserBiz.getAdviserBooks4SeriesBook(seriesBook.getSeriesBookKeyword(), currentPage, numPerPage, adviserIds,
seriesBook.getAgentId(), subLabelId, graLabelId, seriesBook.getSerialNumber(), verLabelId, volLabelId); seriesBook.getAgentId(), subLabelId, graLabelId, seriesBook.getSerialNumber(), verLabelId, volLabelId);
List<ESBookAndAdviser> esBookAndAdvisers = esPage.getContent(); List<ESBookAndAdviser> esBookAndAdvisers = esPage.getContent();
if (ListUtils.isEmpty(esBookAndAdvisers)) { if (ListUtils.isEmpty(esBookAndAdvisers)) {
......
...@@ -8,9 +8,9 @@ import com.pcloud.book.book.dto.BookFundDto; ...@@ -8,9 +8,9 @@ import com.pcloud.book.book.dto.BookFundDto;
import com.pcloud.book.book.dto.BookTypeDto; import com.pcloud.book.book.dto.BookTypeDto;
import com.pcloud.book.consumer.book.elasticsearch.BookElasticSearchConsr; import com.pcloud.book.consumer.book.elasticsearch.BookElasticSearchConsr;
import com.pcloud.book.consumer.user.PartyConsr; import com.pcloud.book.consumer.user.PartyConsr;
import com.pcloud.book.elasticsearch7.entity.Es7Book; import com.pcloud.book.elasticsearch7.domain.dto.param.PlatformSearchDto;
import com.pcloud.book.elasticsearch7.entity.Es7BookFreeze; import com.pcloud.book.elasticsearch7.domain.entity.Es7Book;
import com.pcloud.book.elasticsearch7.search.domain.dto.param.PlatformSearchDto; import com.pcloud.book.elasticsearch7.domain.entity.Es7BookFreeze;
import com.pcloud.book.util.common.Converter; import com.pcloud.book.util.common.Converter;
import com.pcloud.common.core.constant.SystemCode; import com.pcloud.common.core.constant.SystemCode;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
......
...@@ -19,7 +19,7 @@ import com.pcloud.book.book.vo.request.BookQualifyInfoVO; ...@@ -19,7 +19,7 @@ import com.pcloud.book.book.vo.request.BookQualifyInfoVO;
import com.pcloud.book.book.vo.request.BookSearchParamVO; import com.pcloud.book.book.vo.request.BookSearchParamVO;
import com.pcloud.book.book.vo.request.SyncRelateDataToRaysVO; import com.pcloud.book.book.vo.request.SyncRelateDataToRaysVO;
import com.pcloud.book.book.vo.request.UpdateBookRobotProcessDto; import com.pcloud.book.book.vo.request.UpdateBookRobotProcessDto;
import com.pcloud.book.elasticsearch7.search.domain.dto.param.PlatformSearchDto; import com.pcloud.book.elasticsearch7.domain.dto.param.PlatformSearchDto;
import com.pcloud.common.core.constant.SystemCode; import com.pcloud.common.core.constant.SystemCode;
import com.pcloud.common.dto.ResponseDto; import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
......
package com.pcloud.book.consumer.book.elasticsearch; package com.pcloud.book.consumer.book.elasticsearch;
import com.pcloud.book.elasticsearch7.entity.Es7Book; import com.pcloud.book.elasticsearch7.domain.dto.param.PlatformSearchDto;
import com.pcloud.book.elasticsearch7.search.domain.dto.param.PlatformSearchDto; import com.pcloud.book.elasticsearch7.domain.entity.Es7Book;
import com.pcloud.book.elasticsearch7.search.facade.PlatformBookSearchFacade; import com.pcloud.book.elasticsearch7.service.PlatformBookSearchService;
import com.pcloud.common.dto.ResponseDto; import com.pcloud.common.dto.ResponseDto;
import com.pcloud.universe.commons.paging.Pagination; import com.pcloud.universe.commons.paging.Pagination;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -22,11 +22,11 @@ public class BookElasticSearchConsr { ...@@ -22,11 +22,11 @@ public class BookElasticSearchConsr {
private final Logger logger = LoggerFactory.getLogger(getClass()); private final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired @Autowired
private PlatformBookSearchFacade platformBookSearchFacade; private PlatformBookSearchService platformBookSearchService;
public Pagination<Es7Book> search(PlatformSearchDto dto) { public Pagination<Es7Book> search(PlatformSearchDto dto) {
try { try {
ResponseDto<Pagination<Es7Book>> r = platformBookSearchFacade.search(dto); ResponseDto<Pagination<Es7Book>> r = platformBookSearchService.search(dto);
return r.getData(); return r.getData();
} catch (Exception e) { } catch (Exception e) {
logger.error("platform book es search exception.", e); logger.error("platform book es search exception.", e);
......
...@@ -23,10 +23,6 @@ public interface ESBookAndAdviserBiz { ...@@ -23,10 +23,6 @@ public interface ESBookAndAdviserBiz {
Page<ESBookAndAdviser> getESAdviserBooks4AppletV2(String grayStatus, String keyword, List<Long> templetIds, List<Long> graLabelIds, List<Long> subLabelIds, Integer currentPage, Integer numPerPage, List<Long> scecondTempletIds, List<Long> adviserIds, Long agentId); Page<ESBookAndAdviser> getESAdviserBooks4AppletV2(String grayStatus, String keyword, List<Long> templetIds, List<Long> graLabelIds, List<Long> subLabelIds, Integer currentPage, Integer numPerPage, List<Long> scecondTempletIds, List<Long> adviserIds, Long agentId);
void deleteAdviserBooks4ES();
void deleteChoosedAdviserBooks4ES(String keyword);
/** /**
* 答案,搜索全平台书刊 * 答案,搜索全平台书刊
* @author:zhuyajie * @author:zhuyajie
...@@ -40,14 +36,12 @@ public interface ESBookAndAdviserBiz { ...@@ -40,14 +36,12 @@ public interface ESBookAndAdviserBiz {
* @date:2020/11/23 17:26 * @date:2020/11/23 17:26
* * @param null * * @param null
*/ */
Page<ESBookAndAdviser> getAdviserBooks4SeriesBook(List<String> keywords, Integer currentPage, Integer numPerPage, List<Long> adviserIds, Long agentId, Long subLabelId, Long graLabelId, String serialNumber, Long verLabelId, Long volLabelId); Page<ESBookAndAdviser> getAdviserBooks4SeriesBook(String keyword, Integer currentPage, Integer numPerPage, List<Long> adviserIds, Long agentId, Long subLabelId, Long graLabelId, String serialNumber, Long verLabelId, Long volLabelId);
Map<String, Object> getNotFoundBookId(String lastBookId)throws Exception; Map<String, Object> getNotFoundBookId(String lastBookId)throws Exception;
void stopNotFoundBookId(); void stopNotFoundBookId();
void updateTempletId();
/** /**
* 查所有书刊,选中的在前 * 查所有书刊,选中的在前
* @author:zhuyajie * @author:zhuyajie
...@@ -56,8 +50,4 @@ public interface ESBookAndAdviserBiz { ...@@ -56,8 +50,4 @@ public interface ESBookAndAdviserBiz {
*/ */
Page<ESBookAndAdviser> getESBooksOrderByChose(String keyword, List<Long> choseBookIdList, Integer currentPage, Integer numPerPage); Page<ESBookAndAdviser> getESBooksOrderByChose(String keyword, List<Long> choseBookIdList, Integer currentPage, Integer numPerPage);
/**
* 获取编辑书刊列表(ERP项目用)
*/
Page<ESBookAndAdviser> getESBooks4Erp(String isbn, String uniqueNumber, List<String> listName, List<Long> adviserIdList, Integer currentPage, Integer numPerPage);
} }
...@@ -9,12 +9,6 @@ import java.util.List; ...@@ -9,12 +9,6 @@ import java.util.List;
public interface ESBookGroupQrcodeBiz { public interface ESBookGroupQrcodeBiz {
/** /**
* 初始化数据-将数据从 MySQL 导入到 Elasticsearch 中
*/
void initData();
/**
* 通过微信群ID(xxx@chatroom)获取ES中的群信息 * 通过微信群ID(xxx@chatroom)获取ES中的群信息
* *
* @param wxGroupIds 微信群ID * @param wxGroupIds 微信群ID
......
package com.pcloud.book.es.biz.impl;
import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wltea.analyzer.lucene.IKAnalyzer;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
/**
* 分词工具
*/
public class IKAnalyzerUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(IKAnalyzerUtil.class);
/**
* 通配符
*/
public static final char WILDCARD_CHAR = '*';
/**
* 前后加通配符
* @param text 内容
* @return
*/
public static String aroundWildcard(String text) {
return WILDCARD_CHAR + text + WILDCARD_CHAR;
}
/**
* 解析成分词后通配字符串
* @param text 内容
* @return String,*通配
*/
public static String parseWildcardString(String text) {
if (StringUtils.isBlank(text)) {
return text;
}
return StringUtils.join(analyzerText(text), WILDCARD_CHAR);
}
/**
* 分词
* @param text 内容
* @return List<分词>
*/
public static List<String> analyzerText(String text) {
List<String> result = new ArrayList<>();
TokenStream ts = null;
try (IKAnalyzer analyzer = new IKAnalyzer(true)) {
ts = analyzer.tokenStream("text", new StringReader(text));
CharTermAttribute term = ts.addAttribute(CharTermAttribute.class);
ts.reset();
while (ts.incrementToken()) {
result.add(term.toString());
}
ts.end();
} catch (IOException ioe) {
result.add(text);
LOGGER.warn("analyzer text exception,text={}", text, ioe);
} finally {
closeTokenStream(text, ts);
}
return result;
}
private static void closeTokenStream(String text, TokenStream ts) {
if (ts != null) {
try {
ts.close();
} catch (IOException ioe) {
LOGGER.warn("analyzer text, close stream exception,text={}", text, ioe);
}
}
}
}
package com.pcloud.book.es.entity; package com.pcloud.book.es.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldIndex;
import org.springframework.data.elasticsearch.annotations.FieldType;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
...@@ -18,14 +11,12 @@ import java.util.Date; ...@@ -18,14 +11,12 @@ import java.util.Date;
* @Date 2020/4/13 14:29 * @Date 2020/4/13 14:29
**/ **/
@Data @Data
@Document(indexName = "book", type = "book_and_adviser")
public class ESBookAndAdviser { public class ESBookAndAdviser {
/** /**
* 书籍标识 * 书籍标识
*/ */
@Id
private String bookId; private String bookId;
/** /**
...@@ -71,19 +62,16 @@ public class ESBookAndAdviser { ...@@ -71,19 +62,16 @@ public class ESBookAndAdviser {
/** /**
* 书籍ISBN码 * 书籍ISBN码
*/ */
@Field(type = FieldType.String, index = FieldIndex.not_analyzed)
private String isbn; private String isbn;
/** /**
* 书籍名称 * 书籍名称
*/ */
@Field(type = FieldType.String, index = FieldIndex.not_analyzed)
private String bookName; private String bookName;
/** /**
* 书籍名称,同上面bookName,ES按分词存储,主要用于分词搜索 * 书籍名称,同上面bookName,ES按分词存储,主要用于分词搜索
*/ */
@Field(type = FieldType.String, index = FieldIndex.analyzed, analyzer = "ik_max_word", searchAnalyzer = "ik_max_word")
private String ikBookName; private String ikBookName;
/** /**
...@@ -99,13 +87,11 @@ public class ESBookAndAdviser { ...@@ -99,13 +87,11 @@ public class ESBookAndAdviser {
/** /**
* 最后更新时间 * 最后更新时间
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date lastModifiedDate; private Date lastModifiedDate;
/** /**
* 编辑书创建时间 * 编辑书创建时间
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createdDate; private Date createdDate;
/** /**
......
...@@ -57,15 +57,13 @@ public class ESBookAndAdviserFacade { ...@@ -57,15 +57,13 @@ public class ESBookAndAdviserFacade {
@ApiOperation("es中删除部分测试图书") @ApiOperation("es中删除部分测试图书")
@GetMapping("deleteAdviserBooks4ES") @GetMapping("deleteAdviserBooks4ES")
public ResponseDto<?> deleteAdviserBooks4ES() throws BizException { public ResponseDto<?> deleteAdviserBooks4ES() throws BizException {
esBookAndAdviserBiz.deleteAdviserBooks4ES(); throw new BizException("接口已下线 - deleteAdviserBooks4ES");
return new ResponseDto<>();
} }
@ApiOperation("es中删除选中图书") @ApiOperation("es中删除选中图书")
@GetMapping("deleteChoosedAdviserBooks4ES") @GetMapping("deleteChoosedAdviserBooks4ES")
public ResponseDto<?> deleteChoosedAdviserBooks4ES(@RequestParam(value = "keyword") String keyword) throws BizException { public ResponseDto<?> deleteChoosedAdviserBooks4ES(@RequestParam(value = "keyword") String keyword) throws BizException {
esBookAndAdviserBiz.deleteChoosedAdviserBooks4ES(keyword); throw new BizException("接口已下线 - deleteChoosedAdviserBooks4ES");
return new ResponseDto<>();
} }
@ApiOperation("查询ES有而BOOK表没有的书") @ApiOperation("查询ES有而BOOK表没有的书")
...@@ -84,10 +82,7 @@ public class ESBookAndAdviserFacade { ...@@ -84,10 +82,7 @@ public class ESBookAndAdviserFacade {
@ApiOperation("ES同步图书分类信息 - 慎点 参数为接口名") @ApiOperation("ES同步图书分类信息 - 慎点 参数为接口名")
@GetMapping("/syncBookAdviserTemplet4ES") @GetMapping("/syncBookAdviserTemplet4ES")
public ResponseDto<Void> syncBookAdviserTemplet4ES(@RequestParam("conten") String content){ public ResponseDto<Void> syncBookAdviserTemplet4ES(@RequestParam("conten") String content){
if (StrUtil.equals(content,"syncBookAdviserTemplet4ES")){ throw new BizException("接口已下线 - syncBookAdviserTemplet4ES");
esBookAndAdviserBiz.updateTempletId();
}
return new ResponseDto<>();
} }
@ApiOperation("更新es书刊") @ApiOperation("更新es书刊")
......
...@@ -24,7 +24,6 @@ public class ESBookGroupQrcodeFacadeImpl { ...@@ -24,7 +24,6 @@ public class ESBookGroupQrcodeFacadeImpl {
@ApiOperation("初始化数据") @ApiOperation("初始化数据")
@RequestMapping(value = "init",method = RequestMethod.GET) @RequestMapping(value = "init",method = RequestMethod.GET)
public ResponseDto<?> initData(){ public ResponseDto<?> initData(){
esBookGroupQrcodeBiz.initData();
return new ResponseDto<>(); return new ResponseDto<>();
} }
......
package com.pcloud.book.es.repository;
import com.pcloud.book.es.entity.ESBookAndAdviser;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
public interface BookAndAdviserRepository extends ElasticsearchRepository<ESBookAndAdviser, String> {
}
package com.pcloud.book.es.repository;
import com.pcloud.book.es.entity.ESBookGroupQrcode;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
/**
* @author guiq
*/
public interface BookGroupQrcodeRepository extends ElasticsearchRepository<ESBookGroupQrcode,Long> {
}
...@@ -2,16 +2,11 @@ package com.pcloud.book.es.service.impl; ...@@ -2,16 +2,11 @@ package com.pcloud.book.es.service.impl;
import com.pcloud.book.es.biz.ESBookGroupQrcodeBiz; import com.pcloud.book.es.biz.ESBookGroupQrcodeBiz;
import com.pcloud.book.es.dto.ESBookGroupQrcodeDTO; import com.pcloud.book.es.dto.ESBookGroupQrcodeDTO;
import com.pcloud.book.es.repository.BookGroupQrcodeRepository;
import com.pcloud.book.es.service.ESBookGroupQrcodeService; import com.pcloud.book.es.service.ESBookGroupQrcodeService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate; import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
...@@ -22,8 +17,6 @@ public class ESBookGroupQrcodeServiceImpl implements ESBookGroupQrcodeService { ...@@ -22,8 +17,6 @@ public class ESBookGroupQrcodeServiceImpl implements ESBookGroupQrcodeService {
@Autowired @Autowired
private ElasticsearchTemplate elasticsearchTemplate; private ElasticsearchTemplate elasticsearchTemplate;
@Autowired @Autowired
private BookGroupQrcodeRepository bookGroupQrcodeRepository;
@Autowired
private ESBookGroupQrcodeBiz esBookGroupQrcodeBiz; private ESBookGroupQrcodeBiz esBookGroupQrcodeBiz;
......
...@@ -2,10 +2,16 @@ package com.pcloud.book.util.common; ...@@ -2,10 +2,16 @@ package com.pcloud.book.util.common;
import com.pcloud.book.book.dto.BookDto; import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.book.dto.BookFundDto; import com.pcloud.book.book.dto.BookFundDto;
import com.pcloud.book.elasticsearch7.entity.Es7Book; import com.pcloud.book.elasticsearch7.domain.entity.Es7Book;
import com.pcloud.book.elasticsearch7.entity.Es7BookFund; import com.pcloud.book.elasticsearch7.domain.entity.Es7BookFund;
import com.pcloud.book.es.entity.ESBookAndAdviser;
import com.pcloud.universe.commons.paging.Pagination;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.cglib.beans.BeanCopier; import org.springframework.cglib.beans.BeanCopier;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
...@@ -38,4 +44,58 @@ public class Converter { ...@@ -38,4 +44,58 @@ public class Converter {
return dto; return dto;
} }
public static Page<ESBookAndAdviser> convert(Pagination<Es7Book> data) {
List<ESBookAndAdviser> list = new ArrayList<>();
data.getList().forEach(b -> {
ESBookAndAdviser ba = new ESBookAndAdviser();
ba.setFundBookValue(b.getFundBookValue());
ba.setIsMainEditor(b.getIsMainEditor());
ba.setCreatedDate(b.getCreatedDate());
ba.setLastModifiedDate(b.getLastModifiedDate());
// ba.setBookUserCount(b.getBookUserCount());
// ba.setHasAnswer(b.getHasAnswer());
ba.setIsApproval(BooleanUtils.toInteger(b.getIsApproval()));
ba.setIsFundSupport(BooleanUtils.toInteger(b.getIsFundSupport()));
ba.setJoinGroupType(b.getJoinGroupType());
ba.setResourceCount(b.getResourceCount());
// ba.setAreaLabelId(b.getAreaLabelId());
ba.setBookGroupId(b.getBookGroupId());
ba.setGraLabelId(int2Long(b.getAdviserGraLabelId()));
// ba.setRightsSettingId(b.getRightsSettingId());
ba.setSubLabelId(int2Long(b.getAdviserSubLabelId()));
ba.setVerLabelId(int2Long(b.getAdviserVerLabelId()));
ba.setVolLabelId(int2Long(b.getAdviserVolLabelId()));
ba.setAdviserId(long2String(b.getAdviserId()));
ba.setBookAdviserId(long2String(b.getBookAdviserId()));
ba.setBookId(long2String(b.getBookId()));
ba.setBookName(b.getBookName());
ba.setChannelId(long2String(b.getAdviserChannelId()));
ba.setIkBookName(b.getIkBookName());
ba.setIsAdviserBook(BooleanUtils.toString(b.getIsAdviserBook(), "1", "0"));
ba.setIsbn(b.getIsbn());
ba.setIsBookAdviserDelete(BooleanUtils.toString(b.getIsBookAdviserDelete(), "1", "0"));
ba.setIsBookDelete(BooleanUtils.toString(b.getIsDelete(), "1", "0"));
ba.setLabel1(b.getLabel1());
ba.setLabel2(b.getLabel2());
ba.setLabel3(b.getLabel3());
ba.setLabel4(b.getLabel4());
ba.setSecondTempletId(long2String(b.getAdviserSecondTempletId()));
ba.setSerialNumber(b.getSerialNumber());
ba.setTempletId(long2String(b.getAdviserTempletId()));
ba.setThirdTempletId(long2String(b.getAdviserThirdTempletId()));
ba.setTypeCode(b.getTypeCode());
list.add(ba);
});
return new PageImpl<>(list, new PageRequest(data.getCurrentPageIndex(), data.getPageSize()), data.getTotalCount());
}
private static String long2String(Long l) {
return l == null ? null : l.toString();
}
private static Long int2Long(Integer l) {
return l == null ? null : l.longValue();
}
} }
...@@ -3,12 +3,8 @@ package com.pcloud.book.test; ...@@ -3,12 +3,8 @@ package com.pcloud.book.test;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.pcloud.book.BookApplication; import com.pcloud.book.BookApplication;
import com.pcloud.book.es.biz.ESBookAndAdviserBiz; import com.pcloud.book.es.biz.ESBookAndAdviserBiz;
import com.pcloud.book.es.biz.impl.IKAnalyzerUtil;
import com.pcloud.book.es.entity.ESBookAndAdviser; import com.pcloud.book.es.entity.ESBookAndAdviser;
import com.pcloud.book.group.dao.BookGroupServeDao;
import com.pcloud.book.group.vo.BookGroupServeCountVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.StopWatch; import org.apache.commons.lang3.time.StopWatch;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -17,9 +13,6 @@ import org.springframework.boot.test.context.SpringBootTest; ...@@ -17,9 +13,6 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.List;
@Slf4j @Slf4j
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
...@@ -41,7 +34,7 @@ public class ESBookAndAdviserBizTest { ...@@ -41,7 +34,7 @@ public class ESBookAndAdviserBizTest {
0, 100, 0, 100,
null, null, null, null); null, null, null, null);
log.info("key:{},count:{},cost:{},==>{}", keyword, p.getTotalElements(), sw.getTime(), StringUtils.join(IKAnalyzerUtil.analyzerText(keyword), " ")); log.info("key:{},count:{},cost:{}", keyword, p.getTotalElements(), sw.getTime());
p.forEach((baa) -> log.info(JSON.toJSONString(baa))); p.forEach((baa) -> log.info(JSON.toJSONString(baa)));
sw.reset(); sw.reset();
...@@ -52,7 +45,7 @@ public class ESBookAndAdviserBizTest { ...@@ -52,7 +45,7 @@ public class ESBookAndAdviserBizTest {
0, 100, 0, 100,
null, null, null, null); null, null, null, null);
log.info("key:{},count:{},cost:{},==>{}", keyword, p.getTotalElements(), sw.getTime(), StringUtils.join(IKAnalyzerUtil.analyzerText(keyword), " ")); log.info("key:{},count:{},cost:{}", keyword, p.getTotalElements(), sw.getTime());
p.forEach((baa) -> log.info(JSON.toJSONString(baa))); p.forEach((baa) -> log.info(JSON.toJSONString(baa)));
sw.reset(); sw.reset();
...@@ -63,7 +56,7 @@ public class ESBookAndAdviserBizTest { ...@@ -63,7 +56,7 @@ public class ESBookAndAdviserBizTest {
0, 100, 0, 100,
null, null, null, null); null, null, null, null);
log.info("key:{},count:{},cost:{},==>{}", keyword, p.getTotalElements(), sw.getTime(), StringUtils.join(IKAnalyzerUtil.analyzerText(keyword), " ")); log.info("key:{},count:{},cost:{}", keyword, p.getTotalElements(), sw.getTime());
p.forEach((baa) -> log.info(JSON.toJSONString(baa))); p.forEach((baa) -> log.info(JSON.toJSONString(baa)));
sw.reset(); sw.reset();
...@@ -74,7 +67,7 @@ public class ESBookAndAdviserBizTest { ...@@ -74,7 +67,7 @@ public class ESBookAndAdviserBizTest {
0, 100, 0, 100,
null, null, null, null); null, null, null, null);
log.info("key:{},count:{},cost:{},==>{}", keyword, p.getTotalElements(), sw.getTime(), StringUtils.join(IKAnalyzerUtil.analyzerText(keyword), " ")); log.info("key:{},count:{},cost:{}", keyword, p.getTotalElements(), sw.getTime());
p.forEach((baa) -> log.info(JSON.toJSONString(baa))); p.forEach((baa) -> log.info(JSON.toJSONString(baa)));
sw.stop(); sw.stop();
...@@ -90,7 +83,7 @@ public class ESBookAndAdviserBizTest { ...@@ -90,7 +83,7 @@ public class ESBookAndAdviserBizTest {
0, 100, 0, 100,
null, null, null, null); null, null, null, null);
log.info("key:{},count:{},cost:{},==>{}", keyword, p.getTotalElements(), sw.getTime(), StringUtils.join(IKAnalyzerUtil.analyzerText(keyword), " ")); log.info("key:{},count:{},cost:{}", keyword, p.getTotalElements(), sw.getTime());
p.forEach((baa) -> log.info(JSON.toJSONString(baa))); p.forEach((baa) -> log.info(JSON.toJSONString(baa)));
sw.reset(); sw.reset();
...@@ -101,7 +94,7 @@ public class ESBookAndAdviserBizTest { ...@@ -101,7 +94,7 @@ public class ESBookAndAdviserBizTest {
0, 100, 0, 100,
null, null, null); null, null, null);
log.info("key:{},count:{},cost:{},==>{}", keyword, p.getTotalElements(), sw.getTime(), StringUtils.join(IKAnalyzerUtil.analyzerText(keyword), " ")); log.info("key:{},count:{},cost:{}", keyword, p.getTotalElements(), sw.getTime());
p.forEach((baa) -> log.info(JSON.toJSONString(baa))); p.forEach((baa) -> log.info(JSON.toJSONString(baa)));
sw.stop(); sw.stop();
......
package com.pcloud.book.test;
import com.pcloud.book.es.biz.impl.IKAnalyzerUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
@Slf4j
public class IKAnalyzerUtilTest {
@Test
public void test() {
log.info(IKAnalyzerUtil.aroundWildcard(IKAnalyzerUtil.parseWildcardString("2020秋百年学典 同步导学与优化训练 英语 三年级 上册 配人教版")));
log.info(IKAnalyzerUtil.aroundWildcard(IKAnalyzerUtil.parseWildcardString("云教金榜·寒假作业")));
log.info(IKAnalyzerUtil.aroundWildcard(IKAnalyzerUtil.parseWildcardString("学基础训练上册")));
log.info(IKAnalyzerUtil.aroundWildcard(IKAnalyzerUtil.parseWildcardString("测试书籍")));
log.info(IKAnalyzerUtil.aroundWildcard(IKAnalyzerUtil.parseWildcardString("计算机互联网")));
}
}
...@@ -2,9 +2,9 @@ package com.pcloud.book.test; ...@@ -2,9 +2,9 @@ package com.pcloud.book.test;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.pcloud.book.BookApplication; import com.pcloud.book.BookApplication;
import com.pcloud.book.elasticsearch7.entity.Es7Book; import com.pcloud.book.elasticsearch7.domain.dto.param.PlatformSearchDto;
import com.pcloud.book.elasticsearch7.search.domain.dto.param.PlatformSearchDto; import com.pcloud.book.elasticsearch7.domain.entity.Es7Book;
import com.pcloud.book.elasticsearch7.search.facade.PlatformBookSearchFacade; import com.pcloud.book.elasticsearch7.service.PlatformBookSearchService;
import com.pcloud.common.dto.ResponseDto; import com.pcloud.common.dto.ResponseDto;
import com.pcloud.universe.commons.paging.Pagination; import com.pcloud.universe.commons.paging.Pagination;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -20,7 +20,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; ...@@ -20,7 +20,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
public class PlatformBookSearchFacadeTest { public class PlatformBookSearchFacadeTest {
@Autowired @Autowired
private PlatformBookSearchFacade platformBookSearchFacade; private PlatformBookSearchService platformBookSearchFacade;
@Test @Test
public void testSearch() { public void testSearch() {
......
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