Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐少华
midjourney-proxy
Commits
d00bde17
Commit
d00bde17
authored
Sep 07, 2021
by
李传峰
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'remotes/origin/feature/2.x' into 3.x
# Conflicts: # pcloud-service-book/pom.xml
parents
27a0dec2
5b7a64d8
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
210 additions
and
995 deletions
+210
-995
BookBizImpl.java
.../main/java/com/pcloud/book/book/biz/impl/BookBizImpl.java
+7
-7
BookElasticSearchBizImpl.java
...m/pcloud/book/book/biz/impl/BookElasticSearchBizImpl.java
+3
-3
BookFacadeImpl.java
...java/com/pcloud/book/book/facade/impl/BookFacadeImpl.java
+1
-1
BookElasticSearchConsr.java
...k/consumer/book/elasticsearch/BookElasticSearchConsr.java
+5
-5
ESBookAndAdviserBiz.java
...main/java/com/pcloud/book/es/biz/ESBookAndAdviserBiz.java
+1
-11
ESBookGroupQrcodeBiz.java
...ain/java/com/pcloud/book/es/biz/ESBookGroupQrcodeBiz.java
+0
-6
ESBookAndAdviserBizImpl.java
.../com/pcloud/book/es/biz/impl/ESBookAndAdviserBizImpl.java
+70
-541
ESBookGroupQrcodeBizImpl.java
...com/pcloud/book/es/biz/impl/ESBookGroupQrcodeBizImpl.java
+47
-249
IKAnalyzerUtil.java
...main/java/com/pcloud/book/es/biz/impl/IKAnalyzerUtil.java
+0
-85
ESBookAndAdviser.java
...main/java/com/pcloud/book/es/entity/ESBookAndAdviser.java
+0
-14
ESBookAndAdviserFacade.java
...ava/com/pcloud/book/es/facade/ESBookAndAdviserFacade.java
+3
-8
ESBookGroupQrcodeFacadeImpl.java
...loud/book/es/facade/impl/ESBookGroupQrcodeFacadeImpl.java
+0
-1
BookAndAdviserRepository.java
...m/pcloud/book/es/repository/BookAndAdviserRepository.java
+0
-7
BookGroupQrcodeRepository.java
.../pcloud/book/es/repository/BookGroupQrcodeRepository.java
+0
-10
ESBookGroupQrcodeServiceImpl.java
...ud/book/es/service/impl/ESBookGroupQrcodeServiceImpl.java
+1
-8
Converter.java
.../src/main/java/com/pcloud/book/util/common/Converter.java
+62
-2
ESBookAndAdviserBizTest.java
...st/java/com.pcloud.book.test/ESBookAndAdviserBizTest.java
+6
-13
IKAnalyzerUtilTest.java
...rc/test/java/com.pcloud.book.test/IKAnalyzerUtilTest.java
+0
-20
PlatformBookSearchFacadeTest.java
...va/com.pcloud.book.test/PlatformBookSearchFacadeTest.java
+4
-4
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/book/biz/impl/BookBizImpl.java
View file @
d00bde17
...
@@ -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
))
{
...
...
pcloud-service-book/src/main/java/com/pcloud/book/book/biz/impl/BookElasticSearchBizImpl.java
View file @
d00bde17
...
@@ -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
;
...
...
pcloud-service-book/src/main/java/com/pcloud/book/book/facade/impl/BookFacadeImpl.java
View file @
d00bde17
...
@@ -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
;
...
...
pcloud-service-book/src/main/java/com/pcloud/book/consumer/book/elasticsearch/BookElasticSearchConsr.java
View file @
d00bde17
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.se
arch.facade.PlatformBookSearchFacad
e
;
import
com.pcloud.book.elasticsearch7.se
rvice.PlatformBookSearchServic
e
;
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
PlatformBookSearch
Facade
platformBookSearchFacad
e
;
private
PlatformBookSearch
Service
platformBookSearchServic
e
;
public
Pagination
<
Es7Book
>
search
(
PlatformSearchDto
dto
)
{
public
Pagination
<
Es7Book
>
search
(
PlatformSearchDto
dto
)
{
try
{
try
{
ResponseDto
<
Pagination
<
Es7Book
>>
r
=
platformBookSearch
Facad
e
.
search
(
dto
);
ResponseDto
<
Pagination
<
Es7Book
>>
r
=
platformBookSearch
Servic
e
.
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
);
...
...
pcloud-service-book/src/main/java/com/pcloud/book/es/biz/ESBookAndAdviserBiz.java
View file @
d00bde17
...
@@ -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
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/es/biz/ESBookGroupQrcodeBiz.java
View file @
d00bde17
...
@@ -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
...
...
pcloud-service-book/src/main/java/com/pcloud/book/es/biz/impl/ESBookAndAdviserBizImpl.java
View file @
d00bde17
package
com
.
pcloud
.
book
.
es
.
biz
.
impl
;
package
com
.
pcloud
.
book
.
es
.
biz
.
impl
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.core.map.MapUtil
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.pcloud.analysisengine.browse.dto.BrowseCacheRecordDto
;
import
com.pcloud.book.applet.biz.AppletBookIgnorBiz
;
import
com.pcloud.book.applet.biz.AppletBookIgnorBiz
;
import
com.pcloud.book.book.biz.BookLabelBiz
;
import
com.pcloud.book.book.constant.BookConstant
;
import
com.pcloud.book.book.dao.BookAdviserDao
;
import
com.pcloud.book.book.dao.BookDao
;
import
com.pcloud.book.book.dao.BookDao
;
import
com.pcloud.book.book.entity.BookLabelTrimRelate
;
import
com.pcloud.book.book.vo.request.BookSearchParamVO
;
import
com.pcloud.book.book.vo.request.BookSearchParamVO
;
import
com.pcloud.book.consumer.analysisengine.BrowseRecordConsr
;
import
com.pcloud.book.elasticsearch7.domain.dto.param.BookSearchDto
;
import
com.pcloud.book.consumer.trade.TradeConsr
;
import
com.pcloud.book.elasticsearch7.domain.entity.Es7Book
;
import
com.pcloud.book.elasticsearch7.service.Es7BookSearchService
;
import
com.pcloud.book.elasticsearch7.service.Es7BookSyncService
;
import
com.pcloud.book.es.biz.ESBookAndAdviserBiz
;
import
com.pcloud.book.es.biz.ESBookAndAdviserBiz
;
import
com.pcloud.book.es.entity.ESBookAndAdviser
;
import
com.pcloud.book.es.entity.ESBookAndAdviser
;
import
com.pcloud.book.es.repository.BookAndAdviserRepository
;
import
com.pcloud.book.group.biz.BookGroupBiz
;
import
com.pcloud.book.group.biz.ResourcePageBiz
;
import
com.pcloud.book.group.dto.BookServeDTO
;
import
com.pcloud.book.rightsSetting.constants.RightsSettingConstant
;
import
com.pcloud.book.rightsSetting.constants.RightsSettingConstant
;
import
com.pcloud.book.util.common.ThreadPoolUtils
;
import
com.pcloud.book.util.common.Converter
;
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.core.aspect.ParamLog
;
import
com.pcloud.common.enums.AppTypeEnum
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.NumberUtil
;
import
com.pcloud.common.utils.cache.redis.JedisClusterUtils
;
import
com.pcloud.common.utils.cache.redis.JedisClusterUtils
;
import
com.pcloud.common.utils.robot.WeWorkWebHookRobotUtils
;
import
com.pcloud.common.utils.string.StringUtil
;
import
com.pcloud.common.utils.string.StringUtil
;
import
com.pcloud.facade.tradecenter.dto.BookIncomeQueryVo
;
import
com.pcloud.universe.commons.paging.Pagination
;
import
com.pcloud.facade.tradecenter.dto.IncomeBackDto
;
import
cn.hutool.core.util.StrUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.MatchQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.index.query.WildcardQueryBuilder
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
static
com
.
pcloud
.
book
.
book
.
constant
.
BookConstant
.
IGNOR_BOOK_KEY
;
import
static
com
.
pcloud
.
book
.
book
.
constant
.
BookConstant
.
IGNOR_BOOK_KEY
;
...
@@ -81,122 +53,17 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
...
@@ -81,122 +53,17 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
@Autowired
@Autowired
private
BookDao
bookDao
;
private
BookDao
bookDao
;
@Autowired
@Autowired
private
BookAndAdviserRepository
bookAndAdviserRepository
;
private
Es7BookSyncService
es7BookSyncService
;
@Autowired
private
BookGroupBiz
bookGroupBiz
;
@Autowired
private
BrowseRecordConsr
browseRecordConsr
;
@Autowired
@Autowired
private
TradeConsr
tradeConsr
;
private
Es7BookSearchService
es7BookSearchService
;
@Autowired
private
BookAdviserDao
bookAdviserDao
;
@Autowired
private
ResourcePageBiz
resourcePageBiz
;
@Autowired
@Autowired
private
AppletBookIgnorBiz
appletBookIgnorBiz
;
private
AppletBookIgnorBiz
appletBookIgnorBiz
;
@Autowired
private
BookLabelBiz
bookLabelBiz
;
@ParamLog
(
"导入全部book和bookAdviser"
)
@ParamLog
(
"导入全部book和bookAdviser"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
@Override
public
void
addAllBookAndAdviserToES
()
{
public
void
addAllBookAndAdviserToES
()
{
ThreadPoolUtils
.
OTHER_THREAD_POOL
.
execute
(()
->
{
es7BookSyncService
.
asyncAllBooks
();
Integer
count
=
bookDao
.
count
();
LOGGER
.
info
(
"总数:"
+
count
);
if
(
null
==
count
||
count
<=
0
)
{
return
;
}
Long
maxId
=
0L
;
Integer
index
=
0
;
Integer
offset
=
10000
;
List
<
ESBookAndAdviser
>
list
;
while
(
index
*
offset
<
count
)
{
list
=
bookDao
.
findAllBookAndAdviser
(
maxId
,
offset
);
if
(
ListUtils
.
isEmpty
(
list
))
{
break
;
}
fillInfo
(
list
);
bookAndAdviserRepository
.
save
(
list
);
maxId
=
Long
.
valueOf
(
list
.
get
(
list
.
size
()
-
1
).
getBookId
());
index
+=
1
;
list
.
clear
();
}
});
}
private
void
fillInfo
(
List
<
ESBookAndAdviser
>
list
){
Set
<
Long
>
searchBookIds
=
new
HashSet
<>();
Set
<
Long
>
channelIds
=
new
HashSet
<>();
Set
<
Long
>
adviserIds
=
new
HashSet
<>();
List
<
Long
>
bookIds
=
new
ArrayList
<>();
List
<
BookIncomeQueryVo
>
bookIncomeQueryVos
=
new
ArrayList
<
BookIncomeQueryVo
>();
for
(
ESBookAndAdviser
esBookAndAdviser
:
list
){
if
(
esBookAndAdviser
.
getIsFundSupport
()==
1
){
//统计基金书数据
searchBookIds
.
add
(
Long
.
valueOf
(
esBookAndAdviser
.
getBookId
()));
channelIds
.
add
(
Long
.
valueOf
(
esBookAndAdviser
.
getChannelId
()));
adviserIds
.
add
(
Long
.
valueOf
(
esBookAndAdviser
.
getAdviserId
()));
BookIncomeQueryVo
bookIncomeQueryVo
=
new
BookIncomeQueryVo
();
bookIncomeQueryVo
.
setBookId
(
Long
.
valueOf
(
esBookAndAdviser
.
getBookId
()));
bookIncomeQueryVo
.
setChannelId
(
Long
.
valueOf
(
esBookAndAdviser
.
getChannelId
()));
bookIncomeQueryVo
.
setAdviserId
(
Long
.
valueOf
(
esBookAndAdviser
.
getAdviserId
()));
bookIncomeQueryVos
.
add
(
bookIncomeQueryVo
);
}
bookIds
.
add
(
Long
.
valueOf
(
esBookAndAdviser
.
getBookId
()));
}
//书刊扫码量浏览量
Map
<
String
,
BrowseCacheRecordDto
>
bookSvUvPvMap
=
browseRecordConsr
.
getBookSvUvPv
(
new
ArrayList
<>(
adviserIds
),
new
ArrayList
<>(
channelIds
),
new
ArrayList
<>(
searchBookIds
));
// 获取书刊累计收益(销售额)
Map
<
String
,
IncomeBackDto
>
bookIncomeMap
=
tradeConsr
.
getBookIncome
(
bookIncomeQueryVos
,
null
);
//整理后的标签
Map
<
Long
,
BookLabelTrimRelate
>
trimLabelMap
=
bookLabelBiz
.
mapBookTrimLabel
(
bookIds
);
for
(
ESBookAndAdviser
bookAndAdviser
:
list
){
String
key
=
bookAndAdviser
.
getBookId
()
+
"-"
+
bookAndAdviser
.
getAdviserId
()
+
"-"
+
bookAndAdviser
.
getChannelId
();
//统计基金书数据
BigDecimal
fundBookValue
=
BigDecimal
.
ZERO
;
if
(
bookAndAdviser
.
getIsFundSupport
()==
1
)
{
Long
scanCount
=
0L
;
Long
browseCounts
=
0L
;
if
(!
MapUtils
.
isEmpty
(
bookSvUvPvMap
)
&&
bookSvUvPvMap
.
containsKey
(
key
)){
BrowseCacheRecordDto
browseCacheRecordDto
=
bookSvUvPvMap
.
get
(
key
);
scanCount
=
browseCacheRecordDto
.
getScanCount
()
==
null
?
0L
:
browseCacheRecordDto
.
getScanCount
();
browseCounts
=
browseCacheRecordDto
.
getBrowseCounts
()==
null
?
0L
:
browseCacheRecordDto
.
getBrowseCounts
();
}
BigDecimal
income
=
BigDecimal
.
ZERO
;
IncomeBackDto
incomeBack
=
bookIncomeMap
.
get
(
bookAndAdviser
.
getBookId
()+
"_"
+
bookAndAdviser
.
getChannelId
()+
"_"
+
bookAndAdviser
.
getAdviserId
());
if
(
null
!=
incomeBack
){
income
=
incomeBack
.
getIncome
()==
null
?
new
BigDecimal
(
0
):
incomeBack
.
getIncome
();
}
fundBookValue
=
income
.
multiply
(
new
BigDecimal
(
10
)).
add
(
new
BigDecimal
(
scanCount
*
3
)).
add
(
new
BigDecimal
(
browseCounts
));
}
bookAndAdviser
.
setFundBookValue
(
fundBookValue
==
null
?
BigDecimal
.
ZERO
:
fundBookValue
);
Long
adviserId
=
Long
.
valueOf
(
bookAndAdviser
.
getAdviserId
());
Long
bookId
=
Long
.
valueOf
(
bookAndAdviser
.
getBookId
());
Long
channelId
=
Long
.
valueOf
(
bookAndAdviser
.
getChannelId
());
//标记是否有答案
List
<
BookServeDTO
>
bookServeVOS
=
resourcePageBiz
.
getBookAndBookGroupServeIds
(
adviserId
,
bookId
,
channelId
);
bookGroupBiz
.
removeCanNotBuy
(
bookServeVOS
);
bookGroupBiz
.
fillBookServe
(
bookServeVOS
);
Integer
hasAnswer
=
0
;
if
(!
ListUtils
.
isEmpty
(
bookServeVOS
))
{
List
<
BookServeDTO
>
answerList
=
bookServeVOS
.
stream
().
filter
(
s
->
s
.
getServeName
().
contains
(
"答案"
)
||
s
.
getFromType
().
equals
(
AppTypeEnum
.
ANSWER
.
value
)).
collect
(
Collectors
.
toList
());
if
(!
ListUtils
.
isEmpty
(
answerList
))
{
hasAnswer
=
1
;
}
}
bookAndAdviser
.
setResourceCount
(
bookServeVOS
.
size
());
bookAndAdviser
.
setHasAnswer
(
hasAnswer
);
//整理后的标签
BookLabelTrimRelate
bookLabelTrimRelate
=
null
;
if
(!
MapUtils
.
isEmpty
(
trimLabelMap
)
&&
trimLabelMap
.
containsKey
(
bookId
))
{
bookLabelTrimRelate
=
trimLabelMap
.
get
(
bookId
);
}
bookAndAdviser
.
setLabel1
(
null
==
bookLabelTrimRelate
?
""
:
bookLabelTrimRelate
.
getLabel1
());
bookAndAdviser
.
setLabel2
(
null
==
bookLabelTrimRelate
?
""
:
bookLabelTrimRelate
.
getLabel2
());
bookAndAdviser
.
setLabel3
(
null
==
bookLabelTrimRelate
?
""
:
bookLabelTrimRelate
.
getLabel3
());
bookAndAdviser
.
setLabel4
(
null
==
bookLabelTrimRelate
?
""
:
bookLabelTrimRelate
.
getLabel4
());
}
}
}
@ParamLog
(
"更新书和编辑书"
)
@ParamLog
(
"更新书和编辑书"
)
...
@@ -206,332 +73,94 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
...
@@ -206,332 +73,94 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
return
;
return
;
}
}
try
{
try
{
List
<
ESBookAndAdviser
>
list
=
bookDao
.
findBookAndAdviserByBookIds
(
bookIds
);
es7BookSyncService
.
updateBooksByIds
(
bookIds
);
filterBooks
(
list
);
fillInfo
(
list
);
if
(
ListUtils
.
isEmpty
(
list
)){
return
;
}
bookAndAdviserRepository
.
save
(
list
);
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
LOGGER
.
error
(
"更新书和编辑书出错:"
+
bookIds
.
toString
());
LOGGER
.
error
(
"更新书和编辑书出错:{}"
,
StringUtils
.
join
(
bookIds
));
}
}
private
void
filterBooks
(
List
<
ESBookAndAdviser
>
books
)
{
if
((
ListUtils
.
isEmpty
(
books
))){
return
;
}
Iterator
<
ESBookAndAdviser
>
iterator
=
books
.
iterator
();
while
(
iterator
.
hasNext
())
{
ESBookAndAdviser
esBookAndAdviser
=
iterator
.
next
();
String
bookName
=
esBookAndAdviser
.
getBookName
();
if
(
StringUtil
.
isEmpty
(
bookName
)){
iterator
.
remove
();
}
if
(
bookName
.
matches
(
"^[`~!@#$%^&*()+=|{}:;\\[\\].<>/\\\\?~!@#¥%……()——+|{}【】‘;:”“’。,,、?0123456789]+$"
)
||
bookName
.
matches
(
"(.*)([哈]{4,})(.*)"
)
||
bookName
.
matches
(
"(.*)([或]{4,})(.*)"
)
||
bookName
.
matches
(
"(.*)(红榜)(.*)"
)
||
bookName
.
matches
(
"(.*)\\$测试\\$(.*)"
)
){
iterator
.
remove
();
}
}
}
}
}
@Override
@Override
public
Page
<
ESBookAndAdviser
>
getAdviserBooks4ES
(
String
grayStatus
,
String
keyword
,
Long
templetId
,
Long
secondTempletId
,
Long
thirdTempletId
,
Integer
currentPage
,
Integer
numPerPage
)
{
public
Page
<
ESBookAndAdviser
>
getAdviserBooks4ES
(
String
grayStatus
,
String
keyword
,
Long
templetId
,
Long
secondTempletId
,
Long
thirdTempletId
,
Integer
currentPage
,
Integer
numPerPage
)
{
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
()
.
filter
(
QueryBuilders
.
termQuery
(
"isBookDelete"
,
0
))
.
filter
(
Objects
.
isNull
(
templetId
)
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
termQuery
(
"templetId"
,
templetId
))
.
filter
(
Objects
.
isNull
(
secondTempletId
)
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
termQuery
(
"secondTempletId"
,
secondTempletId
))
.
filter
(
Objects
.
isNull
(
thirdTempletId
)
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
termQuery
(
"thirdTempletId"
,
thirdTempletId
));
BoolQueryBuilder
should1
=
QueryBuilders
.
boolQuery
()
BookSearchDto
dto
=
BookSearchDto
.
builder
()
.
should
(
QueryBuilders
.
termQuery
(
"isBookAdviserDelete"
,
0
))
.
grayStatus
(
grayStatus
).
keyword
(
keyword
).
templetIds
(
Lists
.
newArrayList
(
templetId
))
.
should
(
QueryBuilders
.
termQuery
(
"isAdviserBook"
,
0
));
.
scecondTempletIds
(
Lists
.
newArrayList
(
secondTempletId
)).
thirdTempletIds
(
Lists
.
newArrayList
(
thirdTempletId
))
// 审核通过之后屏蔽掉测试编辑的书刊
.
build
();
BoolQueryBuilder
adviserIdBuilder
=
getAdviserIdBuilder
(
grayStatus
);
dto
.
setCurrentPage
(
Optional
.
ofNullable
(
currentPage
).
orElse
(
0
)
+
1
);
dto
.
setPageSize
(
numPerPage
);
if
(
isIsbn
(
keyword
))
{
Pagination
<
Es7Book
>
data
=
es7BookSearchService
.
getAdviserBooks4ES
(
dto
);
boolQueryBuilder
.
must
(
QueryBuilders
.
termsQuery
(
"isbn"
,
keyword
));
}
else
if
(
StringUtils
.
isNotBlank
(
keyword
))
{
MatchQueryBuilder
mqb
=
QueryBuilders
.
matchQuery
(
"ikBookName"
,
keyword
).
minimumShouldMatch
(
"75%"
);
boolQueryBuilder
.
must
(
mqb
);
}
boolQueryBuilder
.
must
(
should1
);
boolQueryBuilder
.
must
(
adviserIdBuilder
);
Sort
sort
=
new
Sort
(
Sort
.
Direction
.
DESC
,
"isAdviserBook"
,
"lastModifiedDate"
,
"bookId"
);
PageRequest
pageRequest
=
new
PageRequest
(
currentPage
,
numPerPage
,
sort
);
Page
<
ESBookAndAdviser
>
search
=
bookAndAdviserRepository
.
search
(
boolQueryBuilder
,
pageRequest
);
return
search
;
}
BoolQueryBuilder
getAdviserIdBuilder
(
String
grayStatus
){
// 审核通过之后屏蔽掉测试编辑的书刊
BoolQueryBuilder
adviserIdBuilder
=
QueryBuilders
.
boolQuery
();
if
(
YesOrNoEnums
.
YES
.
getCode
().
equals
(
grayStatus
))
{
if
(
"test"
.
equalsIgnoreCase
(
BookProps
.
getSystemEnv
()))
{
adviserIdBuilder
=
QueryBuilders
.
boolQuery
().
mustNot
(
QueryBuilders
.
termQuery
(
"adviserId"
,
1404
));
}
if
(
"uat"
.
equalsIgnoreCase
(
BookProps
.
getSystemEnv
()))
{
adviserIdBuilder
=
QueryBuilders
.
boolQuery
().
mustNot
(
QueryBuilders
.
termQuery
(
"adviserId"
,
12829
));
}
if
(
"pro"
.
equalsIgnoreCase
(
BookProps
.
getSystemEnv
()))
{
adviserIdBuilder
=
QueryBuilders
.
boolQuery
().
mustNot
(
QueryBuilders
.
termQuery
(
"adviserId"
,
1362
));
}
}
return
adviserIdBuilder
;
}
private
boolean
isIsbn
(
String
keyword
)
{
return
Converter
.
convert
(
data
);
return
StringUtils
.
isNumeric
(
keyword
)
&&
StringUtils
.
length
(
keyword
)
>
4
;
}
}
@Override
@Override
public
Page
<
ESBookAndAdviser
>
getESAdviserBooks4Applet
(
String
grayStatus
,
String
keyword
,
List
<
Long
>
templetIds
,
List
<
Long
>
graLabelIds
,
public
Page
<
ESBookAndAdviser
>
getESAdviserBooks4Applet
(
String
grayStatus
,
String
keyword
,
List
<
Long
>
templetIds
,
List
<
Long
>
graLabelIds
,
List
<
Long
>
subLabelIds
,
Integer
currentPage
,
Integer
numPerPage
,
List
<
Long
>
scecondTempletIds
,
Integer
isAdviserBook
,
List
<
Long
>
adviserIds
,
Long
agentId
)
{
List
<
Long
>
subLabelIds
,
Integer
currentPage
,
Integer
numPerPage
,
List
<
Long
>
scecondTempletIds
,
Integer
isAdviserBook
,
List
<
Long
>
adviserIds
,
Long
agentId
)
{
long
start
=
System
.
currentTimeMillis
();
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
()
.
filter
(
QueryBuilders
.
termQuery
(
"isBookDelete"
,
0
))
.
filter
(
QueryBuilders
.
termQuery
(
"isBookAdviserDelete"
,
0
));
if
(
CollectionUtils
.
isNotEmpty
(
templetIds
))
{
boolQueryBuilder
.
filter
(
QueryBuilders
.
termsQuery
(
"templetId"
,
templetIds
));
}
if
(
agentId
!=
null
)
{
boolQueryBuilder
.
filter
(
QueryBuilders
.
termsQuery
(
"adviserId"
,
adviserIds
));
}
//(年级&&科目)||二级分类
BoolQueryBuilder
must1
=
QueryBuilders
.
boolQuery
()
.
filter
(
ListUtils
.
isEmpty
(
graLabelIds
)
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
termsQuery
(
"graLabelId"
,
graLabelIds
))
.
filter
(
ListUtils
.
isEmpty
(
subLabelIds
)
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
termsQuery
(
"subLabelId"
,
subLabelIds
));
BoolQueryBuilder
must2
=
QueryBuilders
.
boolQuery
().
filter
(
ListUtils
.
isEmpty
(
scecondTempletIds
)
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
termsQuery
(
"secondTempletId"
,
scecondTempletIds
));
BoolQueryBuilder
should2
=
QueryBuilders
.
boolQuery
().
should
(
must1
).
should
(
must2
);
// 审核通过之后屏蔽掉测试编辑的书刊
BoolQueryBuilder
adviserIdBuilder
=
getAdviserIdBuilder
(
grayStatus
);
boolQueryBuilder
.
must
(
adviserIdBuilder
);
//屏蔽指定书籍
BookSearchDto
dto
=
BookSearchDto
.
builder
()
BoolQueryBuilder
bookBuilder
=
getBookBuilder
();
.
grayStatus
(
grayStatus
).
keyword
(
keyword
).
templetIds
(
templetIds
).
graLabelIds
(
graLabelIds
)
boolQueryBuilder
.
must
(
bookBuilder
);
.
subLabelIds
(
subLabelIds
).
scecondTempletIds
(
scecondTempletIds
).
adviserIds
(
adviserIds
)
.
ignoreBookIdList
(
getIgnoreBookIdList
()).
filterResourceCount
(
false
)
if
(
isIsbn
(
keyword
))
{
.
build
();
boolQueryBuilder
.
must
(
QueryBuilders
.
termsQuery
(
"isbn"
,
keyword
));
dto
.
setCurrentPage
(
Optional
.
ofNullable
(
currentPage
).
orElse
(
0
)
+
1
);
}
else
if
(
StringUtils
.
isNotBlank
(
keyword
))
{
dto
.
setPageSize
(
numPerPage
);
MatchQueryBuilder
mqb
=
QueryBuilders
.
matchQuery
(
"ikBookName"
,
keyword
).
minimumShouldMatch
(
"75%"
);
Pagination
<
Es7Book
>
data
=
es7BookSearchService
.
getESAdviserBooks4AppletV2
(
dto
);
boolQueryBuilder
.
must
(
mqb
);
}
if
(
isAdviserBook
!=
null
)
{
boolQueryBuilder
.
must
(
QueryBuilders
.
termQuery
(
"isAdviserBook"
,
isAdviserBook
));
}
if
(!
ListUtils
.
isEmpty
(
scecondTempletIds
))
{
if
(
ListUtils
.
isEmpty
(
graLabelIds
)
&&
ListUtils
.
isEmpty
(
subLabelIds
))
{
boolQueryBuilder
.
must
(
must2
);
}
else
{
boolQueryBuilder
.
must
(
should2
);
}
}
else
if
(!
ListUtils
.
isEmpty
(
graLabelIds
)
||
!
ListUtils
.
isEmpty
(
subLabelIds
))
{
boolQueryBuilder
.
must
(
must1
);
}
// 排序:因为涉及分词,故而_score固定放在第一位
Sort
sort
=
new
Sort
(
Sort
.
Direction
.
DESC
,
"_score"
,
"isApproval"
,
"isFundSupport"
,
"fundBookValue"
,
"resourceCount"
,
"isAdviserBook"
,
"lastModifiedDate"
,
"bookId"
);
if
(
StringUtil
.
isEmpty
(
keyword
)){
sort
=
new
Sort
(
Sort
.
Direction
.
DESC
,
"isApproval"
,
"_score"
,
"isFundSupport"
,
"fundBookValue"
,
"resourceCount"
,
"isAdviserBook"
,
"lastModifiedDate"
,
"bookId"
);
}
PageRequest
pageRequest
=
new
PageRequest
(
currentPage
,
numPerPage
,
sort
);
Page
<
ESBookAndAdviser
>
search
=
bookAndAdviserRepository
.
search
(
boolQueryBuilder
,
pageRequest
);
log
.
info
(
"es.search({})==>{},total={},cost={}"
,
return
Converter
.
convert
(
data
);
StringUtils
.
replaceEach
(
boolQueryBuilder
.
toString
(),
new
String
[]{
"\n"
,
" "
,
" : "
},
new
String
[]{
""
,
""
,
":"
}),
search
,
search
.
getTotalElements
(),
(
System
.
currentTimeMillis
()
-
start
));
return
search
;
}
}
@Override
@Override
public
Page
<
ESBookAndAdviser
>
getESAdviserBooks4AppletV2
(
String
grayStatus
,
String
keyword
,
List
<
Long
>
templetIds
,
List
<
Long
>
graLabelIds
,
public
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
)
{
List
<
Long
>
subLabelIds
,
Integer
currentPage
,
Integer
numPerPage
,
List
<
Long
>
scecondTempletIds
,
List
<
Long
>
adviserIds
,
Long
agentId
)
{
long
start
=
System
.
currentTimeMillis
();
BookSearchDto
dto
=
BookSearchDto
.
builder
()
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
()
.
grayStatus
(
grayStatus
).
keyword
(
keyword
).
templetIds
(
templetIds
).
graLabelIds
(
graLabelIds
)
.
filter
(
QueryBuilders
.
termQuery
(
"isBookDelete"
,
0
))
.
subLabelIds
(
subLabelIds
).
scecondTempletIds
(
scecondTempletIds
).
adviserIds
(
adviserIds
)
.
filter
(
QueryBuilders
.
termQuery
(
"isBookAdviserDelete"
,
0
))
.
ignoreBookIdList
(
getIgnoreBookIdList
()).
isAdviserBook
(
true
).
filterResourceCount
(
true
)
.
filter
(
QueryBuilders
.
termQuery
(
"isAdviserBook"
,
1
))
.
build
();
.
filter
(
QueryBuilders
.
rangeQuery
(
"resourceCount"
).
gt
(
0
));
dto
.
setCurrentPage
(
Optional
.
ofNullable
(
currentPage
).
orElse
(
0
)
+
1
);
dto
.
setPageSize
(
numPerPage
);
if
(
CollectionUtils
.
isNotEmpty
(
templetIds
))
{
Pagination
<
Es7Book
>
data
=
es7BookSearchService
.
getESAdviserBooks4AppletV2
(
dto
);
boolQueryBuilder
.
filter
(
QueryBuilders
.
termsQuery
(
"templetId"
,
templetIds
));
}
if
(
agentId
!=
null
)
{
boolQueryBuilder
.
filter
(
QueryBuilders
.
termsQuery
(
"adviserId"
,
adviserIds
));
}
//(年级&&科目)||二级分类
BoolQueryBuilder
must1
=
QueryBuilders
.
boolQuery
()
.
filter
(
ListUtils
.
isEmpty
(
graLabelIds
)
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
termsQuery
(
"graLabelId"
,
graLabelIds
))
.
filter
(
ListUtils
.
isEmpty
(
subLabelIds
)
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
termsQuery
(
"subLabelId"
,
subLabelIds
));
BoolQueryBuilder
must2
=
QueryBuilders
.
boolQuery
().
filter
(
ListUtils
.
isEmpty
(
scecondTempletIds
)
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
termsQuery
(
"secondTempletId"
,
scecondTempletIds
));
BoolQueryBuilder
should2
=
QueryBuilders
.
boolQuery
().
should
(
must1
).
should
(
must2
);
// 审核通过之后屏蔽掉测试编辑的书刊
BoolQueryBuilder
adviserIdBuilder
=
getAdviserIdBuilder
(
grayStatus
);
//屏蔽指定书籍
BoolQueryBuilder
bookBuilder
=
getBookBuilder
();
boolQueryBuilder
.
filter
(
bookBuilder
);
boolQueryBuilder
.
filter
(
adviserIdBuilder
);
if
(
isIsbn
(
keyword
))
{
return
Converter
.
convert
(
data
);
boolQueryBuilder
.
filter
(
QueryBuilders
.
termsQuery
(
"isbn"
,
keyword
));
}
else
if
(
StringUtils
.
isNotBlank
(
keyword
))
{
// MatchQueryBuilder mqb = QueryBuilders.matchQuery("ikBookName", keyword).minimumShouldMatch("75%");
boolQueryBuilder
.
must
(
QueryBuilders
.
queryStringQuery
(
keyword
).
field
(
"ikBookName"
).
minimumShouldMatch
(
"75%"
));
}
if
(!
ListUtils
.
isEmpty
(
scecondTempletIds
))
{
if
(
ListUtils
.
isEmpty
(
graLabelIds
)
&&
ListUtils
.
isEmpty
(
subLabelIds
))
{
boolQueryBuilder
.
filter
(
must2
);
}
else
{
boolQueryBuilder
.
filter
(
should2
);
}
}
else
if
(!
ListUtils
.
isEmpty
(
graLabelIds
)
||
!
ListUtils
.
isEmpty
(
subLabelIds
))
{
boolQueryBuilder
.
filter
(
must1
);
}
// 排序:因为涉及分词,故而_score固定放在第一位
Sort
sort
=
new
Sort
(
Sort
.
Direction
.
DESC
,
"_score"
,
"isApproval"
,
"isFundSupport"
,
"fundBookValue"
,
"resourceCount"
,
"isAdviserBook"
,
"lastModifiedDate"
,
"bookId"
);
if
(
StringUtil
.
isEmpty
(
keyword
)){
sort
=
new
Sort
(
Sort
.
Direction
.
DESC
,
"isApproval"
,
"_score"
,
"isFundSupport"
,
"fundBookValue"
,
"resourceCount"
,
"isAdviserBook"
,
"lastModifiedDate"
,
"bookId"
);
}
PageRequest
pageRequest
=
new
PageRequest
(
currentPage
,
numPerPage
,
sort
);
Page
<
ESBookAndAdviser
>
search
=
bookAndAdviserRepository
.
search
(
boolQueryBuilder
,
pageRequest
);
log
.
info
(
"es.search({})==>{},total={},cost={}"
,
StringUtils
.
replaceEach
(
boolQueryBuilder
.
toString
(),
new
String
[]{
"\n"
,
" "
,
" : "
},
new
String
[]{
""
,
""
,
":"
}),
search
,
search
.
getTotalElements
(),
(
System
.
currentTimeMillis
()
-
start
));
return
search
;
}
}
private
BoolQueryBuilder
getBookBuilder
()
{
private
List
<
Long
>
getIgnoreBookIdList
()
{
List
<
Long
>
bookIds
=
JedisClusterUtils
.
getJsonList
(
IGNOR_BOOK_KEY
,
Long
.
class
);
List
<
Long
>
bookIds
=
JedisClusterUtils
.
getJsonList
(
IGNOR_BOOK_KEY
,
Long
.
class
);
if
(
ListUtils
.
isEmpty
(
bookIds
))
{
if
(
ListUtils
.
isEmpty
(
bookIds
))
{
bookIds
=
appletBookIgnorBiz
.
getAllIgnorBookIds
();
bookIds
=
appletBookIgnorBiz
.
getAllIgnorBookIds
();
JedisClusterUtils
.
setJsonList
(
IGNOR_BOOK_KEY
,
bookIds
,
3600
*
24
);
JedisClusterUtils
.
setJsonList
(
IGNOR_BOOK_KEY
,
bookIds
,
3600
*
24
);
}
}
BoolQueryBuilder
mustNot
=
QueryBuilders
.
boolQuery
().
mustNot
(
QueryBuilders
.
termsQuery
(
"bookId"
,
bookIds
));
return
bookIds
;
return
mustNot
;
}
}
@Override
@Override
public
void
deleteAdviserBooks4ES
()
{
public
Page
<
ESBookAndAdviser
>
getESAdviserBooks4Answer
(
BookSearchParamVO
vo
)
{
Page
<
ESBookAndAdviser
>
search
=
getEsBookAndAdvisers
();
BookSearchDto
dto
=
BookSearchDto
.
builder
()
while
(
search
.
getContent
().
size
()
>
0
){
.
grayStatus
(
vo
.
getGrayStatus
()).
keyword
(
vo
.
getKeyword
()).
isAdviserBook
(
true
)
search
.
getContent
().
stream
().
forEach
(
e
->
log
.
info
(
"从es中删除的书是"
+
e
.
getVerLabelId
()
+
":"
+
e
.
getBookName
())
);
.
label1
(
vo
.
getLabel1
()).
label2
(
vo
.
getLabel2
()).
label3
(
vo
.
getLabel3
())
bookAndAdviserRepository
.
delete
(
search
.
getContent
());
.
build
();
search
=
getEsBookAndAdvisers
();
dto
.
setCurrentPage
(
Optional
.
ofNullable
(
vo
.
getCurrentPage
()).
orElse
(
0
)
+
1
);
}
dto
.
setPageSize
(
Optional
.
ofNullable
(
vo
.
getNumPerPage
()).
orElse
(
10
));
Pagination
<
Es7Book
>
data
=
es7BookSearchService
.
getESAdviserBooks4Answer
(
dto
);
return
Converter
.
convert
(
data
);
}
}
@Override
@Override
@ParamLog
(
"删除选中的书籍"
)
public
Page
<
ESBookAndAdviser
>
getAdviserBooks4SeriesBook
(
String
keyword
,
Integer
currentPage
,
Integer
numPerPage
,
List
<
Long
>
adviserIds
,
public
void
deleteChoosedAdviserBooks4ES
(
String
keyword
)
{
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
termQuery
(
"bookName"
,
keyword
));
PageRequest
pageRequest
=
new
PageRequest
(
0
,
100
);
Page
<
ESBookAndAdviser
>
search
=
bookAndAdviserRepository
.
search
(
boolQueryBuilder
,
pageRequest
);
if
(
search
.
getSize
()
>
0
){
search
.
getContent
().
stream
().
forEach
(
e
->
log
.
info
(
"从es中删除的书是"
+
e
.
getVerLabelId
()
+
":"
+
e
.
getBookName
())
);
bookAndAdviserRepository
.
delete
(
search
.
getContent
());
}
}
private
Page
<
ESBookAndAdviser
>
getEsBookAndAdvisers
()
{
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
should1
=
QueryBuilders
.
boolQuery
()
.
should
(
QueryBuilders
.
termQuery
(
"isBookAdviserDelete"
,
0
))
.
should
(
QueryBuilders
.
termQuery
(
"isAdviserBook"
,
0
));
BoolQueryBuilder
should2
=
QueryBuilders
.
boolQuery
()
.
should
(
QueryBuilders
.
regexpQuery
(
"bookName"
,
"([`~!@#$%^&*()+=|{}:;\\[\\].<>/\\\\?~!@#¥%……()——+|{}【】‘;:”“’。,,、?]+)"
))
.
should
(
QueryBuilders
.
regexpQuery
(
"bookName"
,
"([0123456789]+)"
))
.
should
(
QueryBuilders
.
regexpQuery
(
"bookName"
,
"((.*)(["
+
BookConstant
.
HANZI
+
"]){4,}(.*))"
))
.
should
(
QueryBuilders
.
regexpQuery
(
"bookName"
,
"("
+
"(.*)(红榜)(.*)"
+
")"
));
boolQueryBuilder
.
must
(
should1
);
boolQueryBuilder
.
must
(
should2
);
PageRequest
pageRequest
=
new
PageRequest
(
0
,
10
);
return
bookAndAdviserRepository
.
search
(
boolQueryBuilder
,
pageRequest
);
}
@Override
public
Page
<
ESBookAndAdviser
>
getESAdviserBooks4Answer
(
BookSearchParamVO
bookSearchParamVO
)
{
Integer
currentPage
=
bookSearchParamVO
.
getCurrentPage
()
==
null
?
0
:
bookSearchParamVO
.
getCurrentPage
();
Integer
numPerPage
=
bookSearchParamVO
.
getNumPerPage
()
==
null
?
10
:
bookSearchParamVO
.
getNumPerPage
();
String
keyword
=
bookSearchParamVO
.
getKeyword
();
String
grayStatus
=
bookSearchParamVO
.
getGrayStatus
();
String
label1
=
bookSearchParamVO
.
getLabel1
();
String
label2
=
bookSearchParamVO
.
getLabel2
();
String
label3
=
bookSearchParamVO
.
getLabel3
();
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
()
.
filter
(
QueryBuilders
.
termQuery
(
"isBookDelete"
,
0
))
.
filter
(
QueryBuilders
.
termQuery
(
"isBookAdviserDelete"
,
0
))
.
filter
(
QueryBuilders
.
termQuery
(
"isAdviserBook"
,
1
))
.
filter
(
StringUtil
.
isEmpty
(
label1
)
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
matchPhraseQuery
(
"label1"
,
label1
))
.
filter
(
StringUtil
.
isEmpty
(
label2
)
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
matchPhraseQuery
(
"label2"
,
label2
))
.
filter
(
StringUtil
.
isEmpty
(
label3
)
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
matchPhraseQuery
(
"label3"
,
label3
));
if
(!
StringUtil
.
isEmpty
(
keyword
))
{
BoolQueryBuilder
should
=
QueryBuilders
.
boolQuery
()
.
should
(
QueryBuilders
.
wildcardQuery
(
"bookName"
,
"*"
+
keyword
+
"*"
))
.
should
(
QueryBuilders
.
wildcardQuery
(
"isbn"
,
"*"
+
keyword
+
"*"
));
boolQueryBuilder
.
must
(
should
);
}
// 审核通过之后屏蔽掉测试编辑的书刊
BoolQueryBuilder
adviserIdBuilder
=
getAdviserIdBuilder
(
grayStatus
);
boolQueryBuilder
.
must
(
adviserIdBuilder
);
Sort
sort
=
new
Sort
(
Sort
.
Direction
.
DESC
,
"isFundSupport"
,
"fundBookValue"
,
"resourceCount"
,
"isAdviserBook"
,
"lastModifiedDate"
,
"bookId"
);
PageRequest
pageRequest
=
new
PageRequest
(
currentPage
,
numPerPage
,
sort
);
Page
<
ESBookAndAdviser
>
search
=
bookAndAdviserRepository
.
search
(
boolQueryBuilder
,
pageRequest
);
return
search
;
}
@Override
public
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
)
{
Long
agentId
,
Long
subLabelId
,
Long
graLabelId
,
String
serialNumber
,
Long
verLabelId
,
Long
volLabelId
)
{
//k12教育分类校验
//k12教育分类校验
List
<
Long
>
templetIds
=
Arrays
.
asList
(
RightsSettingConstant
.
K12_TEMPLET_ID_NEW
);
List
<
Long
>
templetIds
=
Arrays
.
asList
(
RightsSettingConstant
.
K12_TEMPLET_ID_NEW
);
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
()
.
filter
(
QueryBuilders
.
termQuery
(
"isBookDelete"
,
0
))
BookSearchDto
dto
=
BookSearchDto
.
builder
().
keyword
(
keyword
).
isAdviserBook
(
true
)
.
filter
(
QueryBuilders
.
termQuery
(
"isBookAdviserDelete"
,
0
))
.
adviserIds
(
adviserIds
).
templetIds
(
templetIds
).
serialNumber
(
serialNumber
)
.
filter
(
null
==
agentId
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
termsQuery
(
"adviserId"
,
adviserIds
))
.
subLabelIds
(
Lists
.
newArrayList
(
subLabelId
)).
graLabelIds
(
Lists
.
newArrayList
(
graLabelId
))
.
filter
(
null
==
subLabelId
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
termQuery
(
"subLabelId"
,
subLabelId
))
.
verLabelIds
(
Lists
.
newArrayList
(
verLabelId
)).
volLabelIds
(
Lists
.
newArrayList
(
volLabelId
))
.
filter
(
null
==
graLabelId
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
termQuery
(
"graLabelId"
,
graLabelId
))
.
build
();
.
filter
(
null
==
verLabelId
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
termQuery
(
"verLabelId"
,
verLabelId
))
dto
.
setCurrentPage
(
Optional
.
ofNullable
(
currentPage
).
orElse
(
0
)
+
1
);
.
filter
(
null
==
volLabelId
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
termQuery
(
"volLabelId"
,
volLabelId
))
dto
.
setPageSize
(
Optional
.
ofNullable
(
numPerPage
).
orElse
(
10
));
.
filter
(
ListUtils
.
isEmpty
(
templetIds
)
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
termsQuery
(
"templetId"
,
templetIds
));
Pagination
<
Es7Book
>
data
=
es7BookSearchService
.
getAdviserBooks4SeriesBook
(
dto
);
//关键词
for
(
String
keyword:
keywords
){
return
Converter
.
convert
(
data
);
BoolQueryBuilder
should
=
QueryBuilders
.
boolQuery
().
should
(
StringUtil
.
isEmpty
(
keyword
)
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
wildcardQuery
(
"bookName"
,
"*"
+
keyword
+
"*"
));
boolQueryBuilder
.
must
(
should
);
}
//书刊序号
if
(!
StringUtil
.
isEmpty
(
serialNumber
)){
BoolQueryBuilder
should
=
QueryBuilders
.
boolQuery
().
should
(
QueryBuilders
.
termQuery
(
"serialNumber"
,
serialNumber
.
trim
()));
boolQueryBuilder
.
must
(
should
);
}
//编辑书
BoolQueryBuilder
should1
=
QueryBuilders
.
boolQuery
().
should
(
QueryBuilders
.
termQuery
(
"isAdviserBook"
,
1
));
boolQueryBuilder
.
must
(
should1
);
//权益
// 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
@Override
...
@@ -553,14 +182,9 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
...
@@ -553,14 +182,9 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
if
(
StringUtil
.
isEmpty
(
lastBookId
)){
if
(
StringUtil
.
isEmpty
(
lastBookId
)){
lastBookId
=
"0"
;
lastBookId
=
"0"
;
}
}
Sort
sort
=
new
Sort
(
Sort
.
Direction
.
ASC
,
"bookId"
);
while
(
"running"
.
equalsIgnoreCase
(
runStatus
))
{
while
(
"running"
.
equalsIgnoreCase
(
runStatus
))
{
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
Pagination
<
Es7Book
>
data
=
es7BookSearchService
.
findGreaterThanBookIdBooks
(
Long
.
parseLong
(
lastBookId
));
boolQueryBuilder
.
must
(
QueryBuilders
.
rangeQuery
(
"bookId"
).
gt
(
lastBookId
));
List
<
Long
>
esContent
=
data
.
getList
().
stream
().
map
(
Es7Book:
:
getBookId
).
collect
(
Collectors
.
toList
());;
boolQueryBuilder
.
queryName
(
"bookId"
);
PageRequest
pageRequest
=
new
PageRequest
(
0
,
5000
,
sort
);
Page
<
String
>
map
=
bookAndAdviserRepository
.
search
(
boolQueryBuilder
,
pageRequest
).
map
(
x
->
x
.
getBookId
());
List
<
String
>
esContent
=
map
.
getContent
();
if
(
esContent
.
size
()
>
0
)
{
if
(
esContent
.
size
()
>
0
)
{
// 循环每次查询100条
// 循环每次查询100条
for
(
int
i
=
0
;
i
<
(
esContent
.
size
()
%
pageNumber
==
0
?
esContent
.
size
()/
pageNumber
:
(
esContent
.
size
()/
pageNumber
+
1
));
i
++)
{
for
(
int
i
=
0
;
i
<
(
esContent
.
size
()
%
pageNumber
==
0
?
esContent
.
size
()/
pageNumber
:
(
esContent
.
size
()/
pageNumber
+
1
));
i
++)
{
...
@@ -584,7 +208,7 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
...
@@ -584,7 +208,7 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
notFoundBookIds
.
addAll
(
esBookIds
);
notFoundBookIds
.
addAll
(
esBookIds
);
}
}
}
}
lastBookId
=
esContent
.
get
(
esContent
.
size
()-
1
);
lastBookId
=
String
.
valueOf
(
esContent
.
get
(
esContent
.
size
()-
1
)
);
}
else
{
}
else
{
runStatus
=
"complete"
;
runStatus
=
"complete"
;
break
;
break
;
...
@@ -618,108 +242,13 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
...
@@ -618,108 +242,13 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
}
}
@Override
@Override
public
void
updateTempletId
()
{
try
{
WeWorkWebHookRobotUtils
.
sendTextMsg
(
"e99da8d0-62b9-4352-a196-d1f20b01960f"
,
"开始同步BookAdviser分类信息"
,
null
,
CollUtil
.
toList
(
"13035118598"
));
final
List
<
ESBookAndAdviser
>
bookList
=
new
ArrayList
<>();
bookAdviserDao
.
syncTempletId4ES
(
resultContext
->
{
ESBookAndAdviser
esBookAndAdviser
=
resultContext
.
getResultObject
();
bookList
.
add
(
esBookAndAdviser
);
if
(
bookList
.
size
()
==
1000
)
{
saveToES
(
bookList
,
resultContext
.
getResultCount
());
bookList
.
clear
();
}
});
saveToES
(
bookList
,
bookList
.
size
());
}
catch
(
Exception
e
)
{
WeWorkWebHookRobotUtils
.
sendTextMsg
(
"e99da8d0-62b9-4352-a196-d1f20b01960f"
,
String
.
format
(
"ESBookAdviser同步失败\nERR:%s"
,
Arrays
.
toString
(
e
.
getStackTrace
())),
null
,
CollUtil
.
toList
(
"13035118598"
));
}
}
private
void
saveToES
(
List
<
ESBookAndAdviser
>
bookList
,
int
resultCount
)
{
if
(
CollUtil
.
isEmpty
(
bookList
))
{
return
;
}
List
<
String
>
idList
=
bookList
.
stream
().
map
(
ESBookAndAdviser:
:
getBookId
).
collect
(
Collectors
.
toList
());
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
boolQueryBuilder
.
must
(
QueryBuilders
.
termsQuery
(
"bookId"
,
idList
));
Iterable
<
ESBookAndAdviser
>
search
=
bookAndAdviserRepository
.
search
(
boolQueryBuilder
);
List
<
ESBookAndAdviser
>
list
=
new
ArrayList
<>();
Map
<
String
,
ESBookAndAdviser
>
map
=
bookList
.
stream
().
filter
(
Objects:
:
nonNull
).
filter
(
x
->
Objects
.
nonNull
(
x
.
getBookId
())).
collect
(
Collectors
.
toMap
(
ESBookAndAdviser:
:
getBookId
,
x
->
x
));
for
(
ESBookAndAdviser
bookAndAdviser
:
search
)
{
ESBookAndAdviser
esBookAndAdviser
=
map
.
get
(
bookAndAdviser
.
getBookId
());
if
(
Objects
.
isNull
(
esBookAndAdviser
))
continue
;
bookAndAdviser
.
setTempletId
(
esBookAndAdviser
.
getTempletId
());
bookAndAdviser
.
setSecondTempletId
(
esBookAndAdviser
.
getSecondTempletId
());
bookAndAdviser
.
setThirdTempletId
(
esBookAndAdviser
.
getThirdTempletId
());
list
.
add
(
bookAndAdviser
);
}
if
(
CollUtil
.
isNotEmpty
(
list
))
{
bookAndAdviserRepository
.
save
(
list
);
WeWorkWebHookRobotUtils
.
sendTextMsg
(
"e99da8d0-62b9-4352-a196-d1f20b01960f"
,
String
.
format
(
"ESBookAdviser同步中\n当前同步数量: %d\n存入ES数量:%d"
,
resultCount
,
list
.
size
()),
null
,
CollUtil
.
toList
(
"13035118598"
));
}
}
@Override
public
Page
<
ESBookAndAdviser
>
getESBooksOrderByChose
(
String
keyword
,
List
<
Long
>
choseBookIdList
,
Integer
currentPage
,
Integer
numPerPage
)
{
public
Page
<
ESBookAndAdviser
>
getESBooksOrderByChose
(
String
keyword
,
List
<
Long
>
choseBookIdList
,
Integer
currentPage
,
Integer
numPerPage
)
{
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
()
.
filter
(
QueryBuilders
.
termQuery
(
"isBookDelete"
,
0
));
String
number
=
(!
StringUtil
.
isEmpty
(
keyword
)
&&
keyword
.
startsWith
(
"BK"
)
&&
keyword
.
length
()>
2
)?
keyword
.
substring
(
2
):
null
;
if
(!
StringUtil
.
isEmpty
(
number
)
&&
NumberUtil
.
isNumber
(
number
))
{
//书刊编号搜索
BoolQueryBuilder
bookIdBuilder
=
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
termQuery
(
"bookId"
,
Long
.
valueOf
(
number
)));
boolQueryBuilder
.
must
(
bookIdBuilder
);
}
else
{
BoolQueryBuilder
should
=
QueryBuilders
.
boolQuery
()
.
should
(
StringUtil
.
isEmpty
(
keyword
)
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
wildcardQuery
(
"bookName"
,
"*"
+
keyword
+
"*"
))
.
should
(
StringUtil
.
isEmpty
(
keyword
)
?
QueryBuilders
.
boolQuery
()
:
QueryBuilders
.
wildcardQuery
(
"isbn"
,
"*"
+
keyword
+
"*"
));
boolQueryBuilder
.
must
(
should
);
}
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
Page
<
ESBookAndAdviser
>
getESBooks4Erp
(
String
isbn
,
String
uniqueNumber
,
List
<
String
>
listName
,
List
<
Long
>
adviserIdList
,
Integer
currentPage
,
Integer
numPerPage
)
{
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
()
.
filter
(
QueryBuilders
.
termQuery
(
"isBookDelete"
,
0
))
.
filter
(
QueryBuilders
.
termQuery
(
"isBookAdviserDelete"
,
0
))
.
mustNot
(
QueryBuilders
.
termQuery
(
"bookAdviserId"
,
0
));
if
(
StrUtil
.
isNotBlank
(
uniqueNumber
)){
BookSearchDto
dto
=
BookSearchDto
.
builder
().
keyword
(
keyword
).
build
();
boolQueryBuilder
.
filter
(
wildcardQuery
(
"bookId"
,
StrUtil
.
replace
(
uniqueNumber
,
"BK"
,
""
)));
dto
.
setCurrentPage
(
Optional
.
ofNullable
(
currentPage
).
orElse
(
0
)
+
1
);
}
dto
.
setPageSize
(
numPerPage
);
if
(
StrUtil
.
isNotBlank
(
isbn
)){
Pagination
<
Es7Book
>
data
=
es7BookSearchService
.
getESBooksOrderByChose
(
dto
);
BoolQueryBuilder
contentCondition
=
QueryBuilders
.
boolQuery
();
contentCondition
.
should
(
QueryBuilders
.
termQuery
(
"isbn"
,
isbn
));
contentCondition
.
should
(
wildcardQuery
(
"bookName"
,
isbn
));
if
(
CollUtil
.
isNotEmpty
(
listName
)){
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
();
for
(
String
name
:
listName
)
{
queryBuilder
.
filter
(
wildcardQuery
(
"bookName"
,
name
));
}
contentCondition
.
should
(
queryBuilder
);
}
boolQueryBuilder
.
filter
(
contentCondition
);
}
if
(
CollUtil
.
isNotEmpty
(
adviserIdList
)){
boolQueryBuilder
.
filter
(
QueryBuilders
.
termsQuery
(
"adviserId"
,
adviserIdList
));
}
Sort
sort
=
new
Sort
(
Sort
.
Direction
.
DESC
,
"createdDate"
,
"bookId"
);
PageRequest
pageRequest
=
new
PageRequest
(
currentPage
,
numPerPage
,
sort
);
Page
<
ESBookAndAdviser
>
search
=
bookAndAdviserRepository
.
search
(
boolQueryBuilder
,
pageRequest
);
return
search
;
}
public
static
WildcardQueryBuilder
wildcardQuery
(
String
key
,
String
value
)
{
return
Converter
.
convert
(
data
);
return
QueryBuilders
.
wildcardQuery
(
key
,
'*'
+
StringUtils
.
trim
(
value
)
+
'*'
);
}
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/es/biz/impl/ESBookGroupQrcodeBizImpl.java
View file @
d00bde17
...
@@ -3,53 +3,25 @@ package com.pcloud.book.es.biz.impl;
...
@@ -3,53 +3,25 @@ package com.pcloud.book.es.biz.impl;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.pcloud.book.elasticsearch7.domain.dto.param.BookGroupQrcodeSearchDto
;
import
com.pcloud.book.book.constant.BookConstant
;
import
com.pcloud.book.elasticsearch7.domain.entity.Es7BookGroupQrcode
;
import
com.pcloud.book.consumer.reader.ReaderConsr
;
import
com.pcloud.book.elasticsearch7.service.Es7BookGroupQrcodeService
;
import
com.pcloud.book.consumer.trade.TradeConsr
;
import
com.pcloud.book.consumer.user.AdviserConsr
;
import
com.pcloud.book.consumer.user.AgentConsr
;
import
com.pcloud.book.consumer.wechat.WechatConsr
;
import
com.pcloud.book.es.biz.ESBookGroupQrcodeBiz
;
import
com.pcloud.book.es.biz.ESBookGroupQrcodeBiz
;
import
com.pcloud.book.es.dto.BookAdviserInfo
;
import
com.pcloud.book.es.dto.BookTagDTO
;
import
com.pcloud.book.es.dto.ESBookGroupQrcodeDTO
;
import
com.pcloud.book.es.dto.ESBookGroupQrcodeDTO
;
import
com.pcloud.book.es.dto.GroupQrcodeSearchDTO
;
import
com.pcloud.book.es.dto.GroupQrcodeSearchDTO
;
import
com.pcloud.book.es.entity.ESBookGroupQrcode
;
import
com.pcloud.book.es.repository.BookGroupQrcodeRepository
;
import
com.pcloud.book.group.dao.BookGroupClassifyDao
;
import
com.pcloud.book.group.dao.GroupQrcodeDao
;
import
com.pcloud.book.group.dao.GroupQrcodeDao
;
import
com.pcloud.book.group.entity.GroupQrcode
;
import
com.pcloud.book.group.entity.GroupQrcode
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.utils.cache.redis.JedisClusterUtils
;
import
com.pcloud.universe.commons.paging.Pagination
;
import
com.pcloud.facade.tradecenter.dto.OrderGroupFormDto
;
import
com.pcloud.usercenter.party.agent.dto.AgentCity
;
import
com.pcloud.wechatgroup.group.dto.ESGroupBookQrcodeDTO
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.elasticsearch.action.admin.indices.analyze.AnalyzeAction
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.elasticsearch.action.admin.indices.analyze.AnalyzeRequestBuilder
;
import
org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse
;
import
org.elasticsearch.index.query.MatchQueryBuilder
;
import
org.elasticsearch.index.query.MultiMatchQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.cglib.beans.BeanCopier
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.elasticsearch.core.ElasticsearchTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
static
com
.
pcloud
.
book
.
book
.
constant
.
BookConstant
.
BOOK_GROUP_QRCODE_ES_INIT
;
/**
/**
* @author guiq
* @author guiq
...
@@ -61,247 +33,73 @@ import static com.pcloud.book.book.constant.BookConstant.BOOK_GROUP_QRCODE_ES_IN
...
@@ -61,247 +33,73 @@ import static com.pcloud.book.book.constant.BookConstant.BOOK_GROUP_QRCODE_ES_IN
public
class
ESBookGroupQrcodeBizImpl
implements
ESBookGroupQrcodeBiz
{
public
class
ESBookGroupQrcodeBizImpl
implements
ESBookGroupQrcodeBiz
{
@Autowired
@Autowired
private
ElasticsearchTemplate
elasticsearchTemplate
;
private
Es7BookGroupQrcodeService
es7BookGroupQrcodeService
;
@Autowired
private
BookGroupQrcodeRepository
bookGroupQrcodeRepository
;
@Autowired
@Autowired
private
GroupQrcodeDao
groupQrcodeDao
;
private
GroupQrcodeDao
groupQrcodeDao
;
@Autowired
private
BookGroupClassifyDao
bookGroupClassifyDao
;
@Autowired
private
ReaderConsr
readerConsr
;
@Autowired
private
WechatConsr
wechatConsr
;
@Autowired
private
TradeConsr
tradeConsr
;
@Autowired
private
AdviserConsr
adviserConsr
;
@Autowired
private
AgentConsr
agentConsr
;
@Override
public
void
initData
()
{
long
total
=
groupQrcodeDao
.
countAll
();
if
(
JedisClusterUtils
.
setnx
(
BOOK_GROUP_QRCODE_ES_INIT
,
String
.
valueOf
(
total
)))
{
// 每次处理 1000 条数据
final
long
pageSize
=
1000
;
// 计算分页数据
long
maxPage
=
(
total
+
pageSize
-
1
)
/
pageSize
;
long
pageNum
=
0
;
while
(
pageNum
<
maxPage
)
{
// 每 1000 条处理时间大致 60s
JedisClusterUtils
.
expire
(
BOOK_GROUP_QRCODE_ES_INIT
,
60
);
importData
(
pageNum
*
pageSize
,
pageSize
);
pageNum
++;
}
// 处理完删除
JedisClusterUtils
.
del
(
BOOK_GROUP_QRCODE_ES_INIT
);
}
}
private
void
importData
(
long
start
,
long
offset
)
{
List
<
ESBookGroupQrcode
>
qrcodes
=
groupQrcodeDao
.
selectPage
(
start
,
offset
);
if
(
CollUtil
.
isEmpty
(
qrcodes
))
{
return
;
}
// 将群二维码根据群分类进行分组,获取群对应的书名信息
Map
<
Long
,
List
<
ESBookGroupQrcode
>>
classifyMap
=
qrcodes
.
stream
().
collect
(
Collectors
.
groupingBy
(
ESBookGroupQrcode:
:
getClassifyId
));
Set
<
Long
>
classifyIds
=
classifyMap
.
keySet
();
if
(
CollUtil
.
isEmpty
(
classifyIds
))
{
return
;
}
List
<
BookAdviserInfo
>
infos
=
bookGroupClassifyDao
.
getBookAndAdviserByClassifyIds
(
classifyIds
);
Map
<
Long
,
BookAdviserInfo
>
classifyBookMap
=
new
HashMap
<>();
if
(!
CollUtil
.
isEmpty
(
infos
))
{
classifyBookMap
=
infos
.
stream
().
collect
(
Collectors
.
toMap
(
BookAdviserInfo:
:
getClassifyId
,
BookAdviserInfo
->
BookAdviserInfo
));
}
// 获取编辑id集合
List
<
Long
>
advisers
=
qrcodes
.
stream
().
map
(
ESBookGroupQrcode:
:
getCreateUser
).
distinct
().
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
Map
<
Long
,
AgentCity
>
agentCityMap
=
CollUtil
.
newHashMap
();
if
(!
CollUtil
.
isEmpty
(
advisers
)){
agentCityMap
=
readerConsr
.
getAgentPositionByAdviserIds
(
advisers
);
}
// 获取群ID集合,查询城市标签及性别比例
List
<
String
>
groupIds
=
qrcodes
.
stream
().
map
(
ESBookGroupQrcode:
:
getWeixinGroupId
).
distinct
().
filter
(
x
->!
StrUtil
.
isEmpty
(
x
)).
collect
(
Collectors
.
toList
());
Map
<
String
,
ESGroupBookQrcodeDTO
>
qrcodeDTOMap
=
wechatConsr
.
aggGroupMemberUser
(
groupIds
);
// 交易中心查询群内订单数据
List
<
Long
>
collect
=
qrcodes
.
stream
().
map
(
ESBookGroupQrcode:
:
getId
).
distinct
().
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
Map
<
Long
,
OrderGroupFormDto
>
orderGroupForm4ES
=
tradeConsr
.
getOrderGroupForm4ES
(
collect
);
// 查询编辑姓名列表
Map
<
Long
,
String
>
adviserNames
=
CollUtil
.
newHashMap
(
0
);
if
(
CollUtil
.
isNotEmpty
(
advisers
)){
adviserNames
=
adviserConsr
.
getNames
(
advisers
);
}
// 查询出版社名称列表
Map
<
Long
,
String
>
agentNames
=
CollUtil
.
newHashMap
(
0
);
if
(
CollUtil
.
isNotEmpty
(
agentCityMap
)){
List
<
Long
>
agentIds
=
agentCityMap
.
values
().
stream
().
filter
(
Objects:
:
nonNull
).
map
(
AgentCity:
:
getAgentId
).
distinct
().
collect
(
Collectors
.
toList
());
if
(
CollUtil
.
isNotEmpty
(
agentIds
)){
agentNames
=
agentConsr
.
getNames
(
agentIds
);
}
}
for
(
ESBookGroupQrcode
qrcode
:
qrcodes
)
{
if
(
qrcode
==
null
)
{
continue
;
}
// 根据群名称分词获取群标签
List
<
String
>
groupNameTags
=
qrcode
.
getGroupNameTags
()
==
null
?
new
ArrayList
<>()
:
qrcode
.
getGroupNameTags
();
groupNameTags
.
addAll
(
analyzer
(
qrcode
.
getGroupName
()));
if
(!
CollUtil
.
isEmpty
(
groupNameTags
))
{
// 去除重复标签
qrcode
.
setGroupNameTags
(
groupNameTags
.
stream
().
distinct
().
collect
(
Collectors
.
toList
()));
}
if
(
qrcode
.
getClassifyId
()
!=
null
)
{
// 根据书名获取分词标签
List
<
String
>
bookNameTags
=
qrcode
.
getBookNameTags
()
==
null
?
new
ArrayList
<>()
:
qrcode
.
getBookNameTags
();
List
<
String
>
newBookNameTags
=
new
ArrayList
<>();
if
(!
CollUtil
.
isEmpty
(
classifyBookMap
)
&&
classifyBookMap
.
get
(
qrcode
.
getClassifyId
())
!=
null
){
qrcode
.
setIsbn
(
classifyBookMap
.
get
(
qrcode
.
getClassifyId
()).
getIsbn
());
}
if
(
JedisClusterUtils
.
hexists
(
BookConstant
.
BOOK_NAME_TAGS_CACHE
,
String
.
valueOf
(
qrcode
.
getClassifyId
())))
{
BookTagDTO
bookTagDTO
=
JedisClusterUtils
.
hgetJson2Class
(
BookConstant
.
BOOK_NAME_TAGS_CACHE
,
String
.
valueOf
(
qrcode
.
getClassifyId
()),
BookTagDTO
.
class
);
newBookNameTags
=
bookTagDTO
.
getBookTags
();
qrcode
.
setQrcodeBookName
(
bookTagDTO
.
getBookName
());
}
else
if
(!
CollUtil
.
isEmpty
(
classifyBookMap
)
&&
classifyBookMap
.
get
(
qrcode
.
getClassifyId
())
!=
null
){
String
bookName
=
classifyBookMap
.
get
(
qrcode
.
getClassifyId
()).
getBookName
();
if
(
!
StrUtil
.
isEmpty
(
bookName
))
{
newBookNameTags
=
analyzer
(
bookName
);
qrcode
.
setQrcodeBookName
(
bookName
);
BookTagDTO
bookTagDTO
=
new
BookTagDTO
(
bookName
,
newBookNameTags
);
JedisClusterUtils
.
hset
(
BookConstant
.
BOOK_NAME_TAGS_CACHE
,
String
.
valueOf
(
qrcode
.
getClassifyId
()),
JSONObject
.
toJSONString
(
bookTagDTO
));
}
}
bookNameTags
.
addAll
(
newBookNameTags
);
qrcode
.
setBookNameTags
(
bookNameTags
.
stream
().
distinct
().
collect
(
Collectors
.
toList
()));
}
// 获取书对应的出版社,并将出版社的地理位置作为群的地理标签,并补充出版社和编辑名称
if
(
qrcode
.
getCreateUser
()
!=
null
)
{
qrcode
.
setAdviserName
(
adviserNames
.
get
(
qrcode
.
getCreateUser
()));
AgentCity
agentCity
=
agentCityMap
.
get
(
qrcode
.
getCreateUser
());
if
(
agentCity
!=
null
)
{
qrcode
.
setAgentName
(
agentNames
.
get
(
agentCity
.
getAgentId
()));
List
<
String
>
strings
=
CollUtil
.
toList
(
agentCity
.
getCity
());
strings
=
strings
==
null
?
new
ArrayList
<>()
:
strings
;
qrcode
.
setPressTags
(
CollUtil
.
removeEmpty
(
strings
));
}
}
// 补充城市及性别信息
if
(!
CollUtil
.
isEmpty
(
qrcodeDTOMap
))
{
ESGroupBookQrcodeDTO
qrcodeDTO
=
qrcodeDTOMap
.
get
(
qrcode
.
getWeixinGroupId
());
if
(
qrcodeDTO
!=
null
)
{
qrcode
.
setCityTags
(
qrcodeDTO
.
getCityTags
());
int
male
=
qrcodeDTO
.
getMaleCount
()
==
null
?
0
:
qrcodeDTO
.
getMaleCount
();
int
female
=
qrcodeDTO
.
getFemaleCount
()
==
null
?
0
:
qrcodeDTO
.
getFemaleCount
();
int
unknown
=
qrcodeDTO
.
getUnknownCount
()
==
null
?
0
:
qrcodeDTO
.
getUnknownCount
();
qrcode
.
setMaleCount
(
male
);
qrcode
.
setFemaleCount
(
female
);
qrcode
.
setUnknownCount
(
unknown
);
qrcode
.
setGroupMemberCount
(
male
+
female
+
unknown
);
}
}
// 补充交易信息
if
(!
CollUtil
.
isEmpty
(
orderGroupForm4ES
)
&&
qrcode
.
getId
()
!=
null
)
{
OrderGroupFormDto
dto
=
orderGroupForm4ES
.
get
(
qrcode
.
getId
());
if
(
dto
!=
null
)
{
qrcode
.
setAmountActuallyPaid
(
dto
.
getAmountActuallyPaid
());
qrcode
.
setPurchaseVolume
(
dto
.
getPurchaseVolume
());
qrcode
.
setPurchaseAmount
(
dto
.
getPurchaseAmount
().
toPlainString
());
}
}
}
bookGroupQrcodeRepository
.
save
(
qrcodes
);
}
/**
* 分词方法
*
* @param content 待分词内同
* @return 分词结果
*/
private
List
<
String
>
analyzer
(
String
content
)
{
AnalyzeRequestBuilder
ikRequest
=
new
AnalyzeRequestBuilder
(
elasticsearchTemplate
.
getClient
(),
AnalyzeAction
.
INSTANCE
,
"book"
,
content
);
ikRequest
.
setTokenizer
(
"ik_smart"
);
final
ArrayList
<
String
>
list
=
CollUtil
.
newArrayList
();
final
List
<
AnalyzeResponse
.
AnalyzeToken
>
tokens
=
ikRequest
.
execute
().
actionGet
().
getTokens
();
tokens
.
forEach
(
x
->
list
.
add
(
x
.
getTerm
()));
return
list
;
}
@Override
@Override
public
List
<
ESBookGroupQrcodeDTO
>
searchByWxGroupIds
(
List
<
String
>
wxGroupIds
)
{
public
List
<
ESBookGroupQrcodeDTO
>
searchByWxGroupIds
(
List
<
String
>
wxGroupIds
)
{
if
(
CollUtil
.
isEmpty
(
wxGroupIds
))
{
return
new
ArrayList
<>();
}
List
<
ESBookGroupQrcodeDTO
>
result
=
new
ArrayList
<>();
List
<
ESBookGroupQrcodeDTO
>
result
=
new
ArrayList
<>();
Iterable
<
ESBookGroupQrcode
>
weixinGroupIds
=
bookGroupQrcodeRepository
.
search
(
QueryBuilders
.
termsQuery
(
"weixinGroupId"
,
wxGroupIds
));
List
<
Es7BookGroupQrcode
>
list
=
es7BookGroupQrcodeService
.
findByWxGroupIds
(
wxGroupIds
);
for
(
ESBookGroupQrcode
weixinGroupId
:
weixinGroupIds
)
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
if
(
weixinGroupId
!=
null
)
{
return
result
;
result
.
add
(
BeanUtil
.
copyProperties
(
weixinGroupId
,
ESBookGroupQrcodeDTO
.
class
));
}
}
}
list
.
forEach
(
bgq
->
result
.
add
(
convert
(
bgq
)));
return
result
;
return
result
;
}
}
@Override
@Override
public
void
save
(
List
<
ESBookGroupQrcodeDTO
>
dtos
)
{
public
void
save
(
List
<
ESBookGroupQrcodeDTO
>
dtos
)
{
if
(!
CollUtil
.
isEmpty
(
dtos
))
{
if
(
CollectionUtils
.
isNotEmpty
(
dtos
))
{
List
<
ESBookGroupQrcode
>
qrcodes
=
new
ArrayList
<>();
List
<
Es7BookGroupQrcode
>
qrcodes
=
new
ArrayList
<>();
for
(
ESBookGroupQrcodeDTO
dto
:
dtos
)
{
dtos
.
forEach
(
dto
->
qrcodes
.
add
(
convert
(
dto
)));
qrcodes
.
add
(
BeanUtil
.
copyProperties
(
dto
,
ESBookGroupQrcode
.
class
));
es7BookGroupQrcodeService
.
save
(
qrcodes
);
}
bookGroupQrcodeRepository
.
save
(
qrcodes
);
}
}
}
}
@Override
@Override
public
PageBeanNew
<
GroupQrcodeSearchDTO
>
search
(
String
text
,
String
methodType
,
Boolean
isOrder
,
Integer
pageSize
,
Integer
pageNum
)
{
public
PageBeanNew
<
GroupQrcodeSearchDTO
>
search
(
String
text
,
String
methodType
,
Boolean
isOrder
,
Integer
pageSize
,
Integer
pageNum
)
{
QueryBuilder
queryBuilder
;
PageRequest
pageRequest
;
if
(
Objects
.
nonNull
(
isOrder
)&&
isOrder
){
BookGroupQrcodeSearchDto
dto
=
new
BookGroupQrcodeSearchDto
();
pageRequest
=
new
PageRequest
(
pageNum
,
pageSize
,
new
Sort
(
Sort
.
Direction
.
DESC
,
"groupMemberCount"
,
"userNumber"
));
dto
.
setText
(
text
);
}
else
{
dto
.
setMethodType
(
methodType
);
pageRequest
=
new
PageRequest
(
pageNum
,
pageSize
);
dto
.
setOrder
(
isOrder
);
}
dto
.
setPageSize
(
pageSize
);
dto
.
setCurrentPage
(
pageNum
+
1
);
Pagination
<
Es7BookGroupQrcode
>
data
=
es7BookGroupQrcodeService
.
search
(
dto
);
if
(
StrUtil
.
isEmpty
(
text
))
{
List
<
GroupQrcodeSearchDTO
>
list
=
convert
(
data
.
getList
());
queryBuilder
=
QueryBuilders
.
boolQuery
();
}
else
{
if
(
"AND"
.
equals
(
methodType
))
{
queryBuilder
=
QueryBuilders
.
multiMatchQuery
(
text
,
"groupName"
,
"groupNameTags"
,
"qrcodeBookName"
,
"bookNameTags"
,
"cityTags"
,
"pressTags"
,
"pressTags"
,
"adviserName"
).
type
(
MultiMatchQueryBuilder
.
Type
.
CROSS_FIELDS
).
operator
(
MatchQueryBuilder
.
Operator
.
AND
);
}
else
{
queryBuilder
=
QueryBuilders
.
multiMatchQuery
(
text
,
"groupName"
,
"groupNameTags"
,
"qrcodeBookName"
,
"bookNameTags"
,
"cityTags"
,
"pressTags"
,
"pressTags"
,
"adviserName"
);
}
}
Page
<
ESBookGroupQrcode
>
page
=
bookGroupQrcodeRepository
.
search
(
queryBuilder
,
pageRequest
);
List
<
GroupQrcodeSearchDTO
>
list
=
convert
(
page
.
getContent
());
return
new
PageBeanNew
<>(
pageNum
,
pageSize
,
(
int
)
data
.
getTotalCount
(),
list
);
if
(
CollUtil
.
isEmpty
(
list
))
{
}
return
new
PageBeanNew
<>(
pageNum
,
pageSize
,
null
);
}
private
static
final
BeanCopier
BOOK_GROUP_QRCODE_COPIER
=
BeanCopier
.
create
(
Es7BookGroupQrcode
.
class
,
ESBookGroupQrcodeDTO
.
class
,
false
);
return
new
PageBeanNew
<>(
pageNum
,
pageSize
,
(
int
)
page
.
getTotalElements
(),
list
);
private
ESBookGroupQrcodeDTO
convert
(
Es7BookGroupQrcode
q
)
{
ESBookGroupQrcodeDTO
dto
=
new
ESBookGroupQrcodeDTO
();
BOOK_GROUP_QRCODE_COPIER
.
copy
(
q
,
dto
,
null
);
dto
.
setId
(
Long
.
parseLong
(
q
.
getId
()));
return
dto
;
}
private
static
final
BeanCopier
BOOK_GROUP_QRCODE_COPIER2
=
BeanCopier
.
create
(
ESBookGroupQrcodeDTO
.
class
,
Es7BookGroupQrcode
.
class
,
false
);
private
Es7BookGroupQrcode
convert
(
ESBookGroupQrcodeDTO
dto
)
{
Es7BookGroupQrcode
q
=
new
Es7BookGroupQrcode
();
BOOK_GROUP_QRCODE_COPIER2
.
copy
(
dto
,
q
,
null
);
q
.
setId
(
String
.
valueOf
(
dto
.
getId
()));
return
q
;
}
}
private
List
<
GroupQrcodeSearchDTO
>
convert
(
List
<
E
S
BookGroupQrcode
>
content
)
{
private
List
<
GroupQrcodeSearchDTO
>
convert
(
List
<
E
s7
BookGroupQrcode
>
content
)
{
if
(
CollUtil
.
isEmpty
(
content
)){
if
(
CollUtil
.
isEmpty
(
content
)){
return
new
ArrayList
<>();
return
new
ArrayList
<>();
}
}
List
<
GroupQrcodeSearchDTO
>
list
=
new
ArrayList
<>(
content
.
size
());
List
<
GroupQrcodeSearchDTO
>
list
=
new
ArrayList
<>(
content
.
size
());
for
(
E
S
BookGroupQrcode
esBookGroupQrcode
:
content
)
{
for
(
E
s7
BookGroupQrcode
esBookGroupQrcode
:
content
)
{
GroupQrcodeSearchDTO
groupQrcodeSearchDTO
=
new
GroupQrcodeSearchDTO
();
GroupQrcodeSearchDTO
groupQrcodeSearchDTO
=
new
GroupQrcodeSearchDTO
();
if
(
CollUtil
.
isNotEmpty
(
content
)){
if
(
CollUtil
.
isNotEmpty
(
content
)){
BeanUtil
.
copyProperties
(
esBookGroupQrcode
,
groupQrcodeSearchDTO
);
BeanUtil
.
copyProperties
(
esBookGroupQrcode
,
groupQrcodeSearchDTO
);
...
@@ -311,7 +109,7 @@ public class ESBookGroupQrcodeBizImpl implements ESBookGroupQrcodeBiz {
...
@@ -311,7 +109,7 @@ public class ESBookGroupQrcodeBizImpl implements ESBookGroupQrcodeBiz {
}
else
{
}
else
{
groupQrcodeSearchDTO
.
setPurchaseAmount
(
new
BigDecimal
(
esBookGroupQrcode
.
getPurchaseAmount
()));
groupQrcodeSearchDTO
.
setPurchaseAmount
(
new
BigDecimal
(
esBookGroupQrcode
.
getPurchaseAmount
()));
}
}
GroupQrcode
qrcode
=
groupQrcodeDao
.
getById
(
esBookGroupQrcode
.
getId
(
));
GroupQrcode
qrcode
=
groupQrcodeDao
.
getById
(
Long
.
parseLong
(
esBookGroupQrcode
.
getId
()
));
if
(
qrcode
!=
null
&&
qrcode
.
getQrcodeUrl
()!=
null
){
if
(
qrcode
!=
null
&&
qrcode
.
getQrcodeUrl
()!=
null
){
groupQrcodeSearchDTO
.
setQrcodeUrl
(
qrcode
.
getQrcodeUrl
());
groupQrcodeSearchDTO
.
setQrcodeUrl
(
qrcode
.
getQrcodeUrl
());
}
}
...
...
pcloud-service-book/src/main/java/com/pcloud/book/es/biz/impl/IKAnalyzerUtil.java
deleted
100644 → 0
View file @
27a0dec2
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
);
}
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/es/entity/ESBookAndAdviser.java
View file @
d00bde17
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
;
/**
/**
...
...
pcloud-service-book/src/main/java/com/pcloud/book/es/facade/ESBookAndAdviserFacade.java
View file @
d00bde17
...
@@ -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书刊"
)
...
...
pcloud-service-book/src/main/java/com/pcloud/book/es/facade/impl/ESBookGroupQrcodeFacadeImpl.java
View file @
d00bde17
...
@@ -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
<>();
}
}
...
...
pcloud-service-book/src/main/java/com/pcloud/book/es/repository/BookAndAdviserRepository.java
deleted
100644 → 0
View file @
27a0dec2
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
>
{
}
pcloud-service-book/src/main/java/com/pcloud/book/es/repository/BookGroupQrcodeRepository.java
deleted
100644 → 0
View file @
27a0dec2
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
>
{
}
pcloud-service-book/src/main/java/com/pcloud/book/es/service/impl/ESBookGroupQrcodeServiceImpl.java
View file @
d00bde17
...
@@ -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
;
...
...
pcloud-service-book/src/main/java/com/pcloud/book/util/common/Converter.java
View file @
d00bde17
...
@@ -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
();
}
}
}
pcloud-service-book/src/test/java/com.pcloud.book.test/ESBookAndAdviserBizTest.java
View file @
d00bde17
...
@@ -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
();
...
...
pcloud-service-book/src/test/java/com.pcloud.book.test/IKAnalyzerUtilTest.java
deleted
100644 → 0
View file @
27a0dec2
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
(
"计算机互联网"
)));
}
}
pcloud-service-book/src/test/java/com.pcloud.book.test/PlatformBookSearchFacadeTest.java
View file @
d00bde17
...
@@ -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.se
arch.facade.PlatformBookSearchFacad
e
;
import
com.pcloud.book.elasticsearch7.se
rvice.PlatformBookSearchServic
e
;
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
PlatformBookSearch
Facad
e
platformBookSearchFacade
;
private
PlatformBookSearch
Servic
e
platformBookSearchFacade
;
@Test
@Test
public
void
testSearch
()
{
public
void
testSearch
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment