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 491eb31e
authored
Jul 15, 2021
by
danmo
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
任务修改
1 parent
0d0aec46
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
43 deletions
linkwe-quartz/src/main/java/com/linkwechat/quartz/task/GroupMessageTask.java
linkwe-quartz/src/main/java/com/linkwechat/quartz/task/RyTask.java
linkwe-quartz/src/main/java/com/linkwechat/quartz/task/GroupMessageTask.java
0 → 100644
View file @
491eb31
package
com
.
linkwechat
.
quartz
.
task
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.wecom.domain.WeCustomerMessageTimeTask
;
import
com.linkwechat.wecom.mapper.WeCustomerMessageTimeTaskMapper
;
import
com.linkwechat.wecom.service.IWeCustomerMessageService
;
import
com.linkwechat.wecom.service.IWeCustomerService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
/**
* @author danmo
* @description 消息群发任务
* @date 2021/7/15 22:59
**/
@Slf4j
@Component
(
"groupMessageTask"
)
public
class
GroupMessageTask
{
@Autowired
private
WeCustomerMessageTimeTaskMapper
customerMessageTimeTaskMapper
;
@Autowired
private
IWeCustomerMessageService
weCustomerMessageService
;
/**
* 扫描群发消息定时任务
*/
public
void
messageTask
()
{
//获的当前时间的毫秒数
long
currentTime
=
System
.
currentTimeMillis
();
//customerMessageTimeTaskMapper
List
<
WeCustomerMessageTimeTask
>
weCustomerMessageTimeTasks
=
customerMessageTimeTaskMapper
.
selectWeCustomerMessageTimeTaskGteSettingTime
(
currentTime
);
if
(
CollectionUtils
.
isNotEmpty
(
weCustomerMessageTimeTasks
))
{
weCustomerMessageTimeTasks
.
forEach
(
s
->
{
try
{
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
.
getGroupsInfo
())))
{
weCustomerMessageService
.
sendMessgae
(
s
.
getMessageInfo
(),
s
.
getMessageId
(),
s
.
getCustomersInfo
(),
s
.
getGroupsInfo
());
//更新消息处理状态
customerMessageTimeTaskMapper
.
updateTaskSolvedById
(
s
.
getTaskId
());
}
}
catch
(
Exception
e
)
{
log
.
error
(
"定时群发消息处理异常:ex:{}"
,
e
);
e
.
printStackTrace
();
}
}
);
}
}
}
linkwe-quartz/src/main/java/com/linkwechat/quartz/task/RyTask.java
View file @
491eb31
...
@@ -46,13 +46,7 @@ public class RyTask {
...
@@ -46,13 +46,7 @@ public class RyTask {
private
IWeSensitiveService
weSensitiveService
;
private
IWeSensitiveService
weSensitiveService
;
@Autowired
@Autowired
private
IWeSensitiveActHitService
weSensitiveActHitService
;
private
IWeSensitiveActHitService
weSensitiveActHitService
;
@Autowired
private
IWeCustomerService
weCustomerService
;
@Autowired
private
WeCustomerMessageTimeTaskMapper
customerMessageTimeTaskMapper
;
@Autowired
private
IWeCustomerMessageService
weCustomerMessageService
;
@Value
(
"${wecome.chatKey}"
)
@Value
(
"${wecome.chatKey}"
)
private
String
chartKey
;
private
String
chartKey
;
...
@@ -102,7 +96,7 @@ public class RyTask {
...
@@ -102,7 +96,7 @@ public class RyTask {
}
}
}
}
public
void
WeCustomers
()
{
//
public void WeCustomers() {
// //查询系统所有客户
// //查询系统所有客户
// List<WeCustomer> cacheList = redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY);
// List<WeCustomer> cacheList = redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY);
// if (CollectionUtils.isEmpty(cacheList)) {
// if (CollectionUtils.isEmpty(cacheList)) {
...
@@ -115,7 +109,7 @@ public class RyTask {
...
@@ -115,7 +109,7 @@ public class RyTask {
// redisCache.setCacheList(WeConstans.WECUSTOMERS_KEY, customers);
// redisCache.setCacheList(WeConstans.WECUSTOMERS_KEY, customers);
// }
// }
// }
// }
}
//
}
private
void
setRedisCacheSeqValue
(
AtomicLong
index
)
{
private
void
setRedisCacheSeqValue
(
AtomicLong
index
)
{
SearchSourceBuilder
searchSourceBuilder
=
new
SearchSourceBuilder
();
SearchSourceBuilder
searchSourceBuilder
=
new
SearchSourceBuilder
();
...
@@ -141,39 +135,4 @@ public class RyTask {
...
@@ -141,39 +135,4 @@ public class RyTask {
}
}
/**
* 扫描群发消息定时任务
*/
public
void
messageTask
()
{
//获的当前时间的毫秒数
long
currentTime
=
System
.
currentTimeMillis
();
//customerMessageTimeTaskMapper
List
<
WeCustomerMessageTimeTask
>
weCustomerMessageTimeTasks
=
customerMessageTimeTaskMapper
.
selectWeCustomerMessageTimeTaskGteSettingTime
(
currentTime
);
final
Semaphore
semaphore
=
new
Semaphore
(
5
);
if
(
CollectionUtils
.
isNotEmpty
(
weCustomerMessageTimeTasks
))
{
weCustomerMessageTimeTasks
.
forEach
(
s
->
{
try
{
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
.
getGroupsInfo
())))
{
weCustomerMessageService
.
sendMessgae
(
s
.
getMessageInfo
(),
s
.
getMessageId
(),
s
.
getCustomersInfo
(),
s
.
getGroupsInfo
());
//更新消息处理状态
customerMessageTimeTaskMapper
.
updateTaskSolvedById
(
s
.
getTaskId
());
}
semaphore
.
release
();
}
catch
(
JsonProcessingException
|
InterruptedException
e
)
{
log
.
error
(
"定时群发消息处理异常:ex:{}"
,
e
);
e
.
printStackTrace
();
}
}
);
}
}
}
}
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