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 fdbbb599
authored
Jul 26, 2021
by
水库浪子
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
启动时检索es中得索引,如果不存在,则创建索引
1 parent
a450deba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
5 deletions
linkwe-common/src/main/java/com/linkwechat/common/config/WeComeConfig.java
linkwe-quartz/src/main/java/com/linkwechat/quartz/task/RyTask.java
linkwe-common/src/main/java/com/linkwechat/common/config/WeComeConfig.java
View file @
fdbbb59
...
@@ -39,4 +39,7 @@ public class WeComeConfig {
...
@@ -39,4 +39,7 @@ public class WeComeConfig {
/**多租户相关表*/
/**多租户相关表*/
private
String
[]
needTenant
=
new
String
[]{};
private
String
[]
needTenant
=
new
String
[]{};
/**ES索引KEY**/
private
String
chatKey
;
}
}
linkwe-quartz/src/main/java/com/linkwechat/quartz/task/RyTask.java
View file @
fdbbb59
...
@@ -3,6 +3,7 @@ package com.linkwechat.quartz.task;
...
@@ -3,6 +3,7 @@ package com.linkwechat.quartz.task;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.linkwechat.common.config.WeComeConfig
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.core.elasticsearch.ElasticSearch
;
import
com.linkwechat.common.core.elasticsearch.ElasticSearch
;
import
com.linkwechat.common.core.redis.RedisCache
;
import
com.linkwechat.common.core.redis.RedisCache
;
...
@@ -22,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -22,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
...
@@ -47,10 +49,21 @@ public class RyTask {
...
@@ -47,10 +49,21 @@ public class RyTask {
@Autowired
@Autowired
private
IWeSensitiveActHitService
weSensitiveActHitService
;
private
IWeSensitiveActHitService
weSensitiveActHitService
;
@Autowired
private
WeComeConfig
weComeConfig
;
@Value
(
"${wecome.chatKey}"
)
@PostConstruct
private
String
chartKey
;
public
void
init
()
{
try
{
//初始化es索引
elasticSearch
.
createIndex2
(
weComeConfig
.
getChatKey
(),
elasticSearch
.
getFinanceMapping
());
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
());
}
}
public
void
ryMultipleParams
(
String
s
,
Boolean
b
,
Long
l
,
Double
d
,
Integer
i
)
{
public
void
ryMultipleParams
(
String
s
,
Boolean
b
,
Long
l
,
Double
d
,
Integer
i
)
{
System
.
out
.
println
(
StringUtils
.
format
(
"执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}"
,
s
,
b
,
l
,
d
,
i
));
System
.
out
.
println
(
StringUtils
.
format
(
"执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}"
,
s
,
b
,
l
,
d
,
i
));
...
@@ -68,7 +81,7 @@ public class RyTask {
...
@@ -68,7 +81,7 @@ public class RyTask {
public
void
FinanceTask
(
String
corpId
,
String
secret
)
throws
IOException
{
public
void
FinanceTask
(
String
corpId
,
String
secret
)
throws
IOException
{
log
.
info
(
"执行有参方法: params:{},{}"
,
corpId
,
secret
);
log
.
info
(
"执行有参方法: params:{},{}"
,
corpId
,
secret
);
//创建索引
//创建索引
elasticSearch
.
createIndex2
(
chartKey
,
elasticSearch
.
getFinanceMapping
());
elasticSearch
.
createIndex2
(
weComeConfig
.
getChatKey
()
,
elasticSearch
.
getFinanceMapping
());
//从缓存中获取消息标识
//从缓存中获取消息标识
Object
seqObject
=
Optional
.
ofNullable
(
redisCache
.
getCacheObject
(
WeConstans
.
CONTACT_SEQ_KEY
)).
orElse
(
0L
);
Object
seqObject
=
Optional
.
ofNullable
(
redisCache
.
getCacheObject
(
WeConstans
.
CONTACT_SEQ_KEY
)).
orElse
(
0L
);
...
@@ -88,7 +101,7 @@ public class RyTask {
...
@@ -88,7 +101,7 @@ public class RyTask {
List
<
JSONObject
>
elasticSearchEntities
=
weChatContactMappingService
.
saveWeChatContactMapping
(
chatDataList
);
List
<
JSONObject
>
elasticSearchEntities
=
weChatContactMappingService
.
saveWeChatContactMapping
(
chatDataList
);
//获取敏感行为命中信息
//获取敏感行为命中信息
weSensitiveActHitService
.
hitWeSensitiveAct
(
chatDataList
);
weSensitiveActHitService
.
hitWeSensitiveAct
(
chatDataList
);
elasticSearch
.
insertBatchAsync
(
chartKey
,
elasticSearchEntities
,
weSensitiveService:
:
hitSensitive
);
elasticSearch
.
insertBatchAsync
(
weComeConfig
.
getChatKey
()
,
elasticSearchEntities
,
weSensitiveService:
:
hitSensitive
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"消息处理异常:ex:{}"
,
e
);
log
.
error
(
"消息处理异常:ex:{}"
,
e
);
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -116,7 +129,7 @@ public class RyTask {
...
@@ -116,7 +129,7 @@ public class RyTask {
SortBuilder
<?>
sortBuilderPrice
=
SortBuilders
.
fieldSort
(
WeConstans
.
CONTACT_SEQ_KEY
).
order
(
SortOrder
.
DESC
);
SortBuilder
<?>
sortBuilderPrice
=
SortBuilders
.
fieldSort
(
WeConstans
.
CONTACT_SEQ_KEY
).
order
(
SortOrder
.
DESC
);
searchSourceBuilder
.
sort
(
sortBuilderPrice
);
searchSourceBuilder
.
sort
(
sortBuilderPrice
);
searchSourceBuilder
.
size
(
1
);
searchSourceBuilder
.
size
(
1
);
List
<
JSONObject
>
searchResultList
=
elasticSearch
.
search
(
chartKey
,
searchSourceBuilder
,
JSONObject
.
class
);
List
<
JSONObject
>
searchResultList
=
elasticSearch
.
search
(
weComeConfig
.
getChatKey
()
,
searchSourceBuilder
,
JSONObject
.
class
);
if
(
CollectionUtil
.
isNotEmpty
(
searchResultList
)){
if
(
CollectionUtil
.
isNotEmpty
(
searchResultList
)){
searchResultList
.
stream
().
findFirst
().
ifPresent
(
result
->
{
searchResultList
.
stream
().
findFirst
().
ifPresent
(
result
->
{
index
.
set
(
result
.
getLong
(
WeConstans
.
CONTACT_SEQ_KEY
)
+
1
);
index
.
set
(
result
.
getLong
(
WeConstans
.
CONTACT_SEQ_KEY
)
+
1
);
...
...
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