Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit bf46a8c2
authored
Mar 02, 2021
by
leejoker
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix bug
1 parent
80c77db6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
6 deletions
linkwe-common/src/main/java/com/linkwechat/common/core/elasticsearch/ElasticSearch.java
linkwe-quartz/src/main/java/com/linkwechat/quartz/task/RyTask.java
linkwe-common/src/main/java/com/linkwechat/common/core/elasticsearch/ElasticSearch.java
View file @
bf46a8c
...
...
@@ -39,6 +39,7 @@ import java.util.Collection;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.BiConsumer
;
import
java.util.function.Consumer
;
/**
* @author danmo
...
...
@@ -230,6 +231,17 @@ public class ElasticSearch {
}
}
public
void
insertBatchAsync
(
String
idxName
,
List
<
JSONObject
>
list
,
Consumer
<
List
<
JSONObject
>>
consumer
)
{
BulkRequest
request
=
new
BulkRequest
();
list
.
parallelStream
().
forEach
(
item
->
request
.
add
(
new
IndexRequest
(
idxName
,
"_doc"
).
id
(
item
.
getString
(
"msgid"
))
.
source
(
item
,
XContentType
.
JSON
)));
try
{
restHighLevelClient
.
bulkAsync
(
request
,
RequestOptions
.
DEFAULT
,
getActionListener
(
consumer
,
list
));
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
public
void
updateBatch
(
String
idxName
,
List
<
ElasticSearchEntity
>
list
)
{
BulkRequest
request
=
new
BulkRequest
();
list
.
forEach
(
item
->
request
.
add
(
new
UpdateRequest
(
idxName
,
item
.
getId
()).
upsert
(
item
.
getData
(),
XContentType
.
JSON
)));
...
...
@@ -377,6 +389,20 @@ public class ElasticSearch {
}
}
public
ActionListener
getActionListener
(
Consumer
consumer
,
List
<
JSONObject
>
list
)
{
return
new
ActionListener
()
{
@Override
public
void
onResponse
(
Object
o
)
{
consumer
.
accept
(
list
);
}
@Override
public
void
onFailure
(
Exception
e
)
{
log
.
warn
(
"work with es failed, exception={}"
,
ExceptionUtils
.
getStackTrace
(
e
));
}
};
}
public
ActionListener
getActionListener
(
BiConsumer
consumer
,
List
<
ElasticSearchEntity
>
list
,
Object
param
)
{
return
new
ActionListener
()
{
@Override
...
...
linkwe-quartz/src/main/java/com/linkwechat/quartz/task/RyTask.java
View file @
bf46a8c
...
...
@@ -3,7 +3,6 @@ package com.linkwechat.quartz.task;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.google.common.collect.Lists
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.core.elasticsearch.ElasticSearch
;
import
com.linkwechat.common.core.redis.RedisCache
;
...
...
@@ -27,7 +26,6 @@ import java.util.List;
import
java.util.Optional
;
import
java.util.concurrent.Semaphore
;
import
java.util.concurrent.atomic.AtomicLong
;
import
java.util.function.Consumer
;
/**
* 定时任务调度测试
...
...
@@ -92,9 +90,7 @@ public class RyTask {
List
<
JSONObject
>
elasticSearchEntities
=
weChatContactMappingService
.
saveWeChatContactMapping
(
chatDataList
);
//获取敏感行为命中信息
weSensitiveActHitService
.
hitWeSensitiveAct
(
chatDataList
);
List
<
Consumer
<
List
<
JSONObject
>>>
consumerList
=
Lists
.
newArrayList
();
consumerList
.
add
(
weSensitiveService:
:
hitSensitive
);
elasticSearch
.
insertBatchAsync
(
WeConstans
.
WECOM_FINANCE_INDEX
,
elasticSearchEntities
,
consumerList
);
elasticSearch
.
insertBatchAsync
(
WeConstans
.
WECOM_FINANCE_INDEX
,
elasticSearchEntities
,
weSensitiveService:
:
hitSensitive
);
}
catch
(
Exception
e
)
{
log
.
error
(
"消息处理异常:ex:{}"
,
e
);
e
.
printStackTrace
();
...
...
@@ -161,7 +157,7 @@ public class RyTask {
semaphore
.
acquire
();
if
(
s
.
getMessageInfo
()
!=
null
&&
s
.
getMessageId
()
!=
null
||
(
s
.
getMessageInfo
().
getPushType
().
equals
(
WeConstans
.
SEND_MESSAGE_CUSTOMER
)
&&
CollectionUtils
.
isNotEmpty
(
s
.
getCustomersInfo
()))
||(
s
.
getMessageInfo
().
getPushType
().
equals
(
WeConstans
.
SEND_MESSAGE_GROUP
)
&&
CollectionUtils
.
isNotEmpty
(
s
.
getCustomersInfo
()))
||
(
s
.
getMessageInfo
().
getPushType
().
equals
(
WeConstans
.
SEND_MESSAGE_GROUP
)
&&
CollectionUtils
.
isNotEmpty
(
s
.
getGroupsInfo
())))
{
weCustomerMessageService
.
sendMessgae
(
s
.
getMessageInfo
(),
s
.
getMessageId
(),
s
.
getCustomersInfo
(),
s
.
getGroupsInfo
());
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment