Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
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
haoban3.0
haoban-manage3.0
Commits
40f4437b
Commit
40f4437b
authored
Oct 21, 2024
by
王祖波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化通知导购 集中下发的问题
parent
b6072e12
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
4 deletions
+36
-4
NoticeMessageHandler.java
.../manage/service/service/message/NoticeMessageHandler.java
+14
-0
NoticeMessageApiServiceImpl.java
...rvice/service/notify/out/NoticeMessageApiServiceImpl.java
+6
-3
ApolloUtils.java
.../java/com/gic/haoban/manage/service/util/ApolloUtils.java
+16
-1
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/message/NoticeMessageHandler.java
View file @
40f4437b
...
@@ -44,6 +44,20 @@ public class NoticeMessageHandler {
...
@@ -44,6 +44,20 @@ public class NoticeMessageHandler {
}
}
}
}
public
void
sendMessage
(
NoticeMessageForm
noticeMessageForm
,
int
delay
){
logger
.
info
(
"消息中心发送消息实体:{}"
,
JSONObject
.
toJSONString
(
noticeMessageForm
));
if
(
ObjectUtil
.
isEmpty
(
noticeMessageForm
.
getMessageCode
())
||
ObjectUtil
.
isEmpty
(
noticeMessageForm
.
getMqRouterCode
()))
{
logger
.
info
(
"消息中心发送消息实体 messageCode 或 mqRouterCode 不存在"
);
}
GicMQClient
client
=
GICMQClientUtil
.
getClientInstance
();
try
{
client
.
sendMessage
(
noticeMessageForm
.
getMqRouterCode
(),
JSONObject
.
toJSONString
(
noticeMessageForm
),
delay
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"消息中心发送消息实体发送异常 "
,
e
);
}
}
private
int
sendDelayValue
(
boolean
delay
)
{
private
int
sendDelayValue
(
boolean
delay
)
{
if
(!
delay
)
{
if
(!
delay
)
{
return
0
;
return
0
;
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/notify/out/NoticeMessageApiServiceImpl.java
View file @
40f4437b
...
@@ -331,8 +331,11 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
...
@@ -331,8 +331,11 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
return
ServiceResponse
.
failure
(
"-1"
,
"模版枚举不存在"
);
return
ServiceResponse
.
failure
(
"-1"
,
"模版枚举不存在"
);
}
}
List
<
String
>
userIdList
=
relationList
.
stream
().
map
(
StaffClerkRelationDTO:
:
getClerkId
).
distinct
().
collect
(
Collectors
.
toList
());
List
<
String
>
userIdList
=
relationList
.
stream
().
map
(
StaffClerkRelationDTO:
:
getClerkId
).
distinct
().
collect
(
Collectors
.
toList
());
Integer
batchInterval
=
ApolloUtils
.
notifyBatchInterval
();
List
<
List
<
String
>>
listList
=
ListUtil
.
split
(
userIdList
,
1000
);
List
<
List
<
String
>>
listList
=
ListUtil
.
split
(
userIdList
,
1000
);
for
(
List
<
String
>
list
:
listList
)
{
// 优化通知导购 集中下发的问题
for
(
int
i
=
0
;
i
<
listList
.
size
();
i
++)
{
int
delay
=
batchInterval
*
i
;
noticeMessageHandler
.
sendMessage
(
NoticeMessageForm
.
builder
()
noticeMessageHandler
.
sendMessage
(
NoticeMessageForm
.
builder
()
.
messageCode
(
noticeMessageTypeEnum
.
getMessageCode
())
.
messageCode
(
noticeMessageTypeEnum
.
getMessageCode
())
.
mqRouterCode
(
noticeMessageTypeEnum
.
getRouterCode
())
.
mqRouterCode
(
noticeMessageTypeEnum
.
getRouterCode
())
...
@@ -340,8 +343,8 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
...
@@ -340,8 +343,8 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
.
createTime
(
new
Date
())
.
createTime
(
new
Date
())
.
enterpriseId
(
notifyMessageBatchQDTO
.
getEnterpriseId
())
.
enterpriseId
(
notifyMessageBatchQDTO
.
getEnterpriseId
())
.
uniqueKey
(
UniqueIdUtils
.
uniqueLongHex
())
.
uniqueKey
(
UniqueIdUtils
.
uniqueLongHex
())
.
userIdList
(
list
)
.
userIdList
(
list
List
.
get
(
i
)
)
.
variableMap
(
variableMap
).
build
());
.
variableMap
(
variableMap
).
build
()
,
delay
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"发送消息通知失败"
,
e
);
logger
.
error
(
"发送消息通知失败"
,
e
);
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/util/ApolloUtils.java
View file @
40f4437b
...
@@ -2,9 +2,13 @@ package com.gic.haoban.manage.service.util;
...
@@ -2,9 +2,13 @@ package com.gic.haoban.manage.service.util;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.ctrip.framework.apollo.ConfigService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
ApolloUtils
{
public
class
ApolloUtils
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ApolloUtils
.
class
);
/**
/**
* 旧的调用发送,是否采用新的消息中心开关1:是 0:否
* 旧的调用发送,是否采用新的消息中心开关1:是 0:否
* @return
* @return
...
@@ -14,4 +18,15 @@ public class ApolloUtils {
...
@@ -14,4 +18,15 @@ public class ApolloUtils {
String
messageCenterSwitch
=
config
.
getProperty
(
"messageCenterSwitch"
,
"0"
);
String
messageCenterSwitch
=
config
.
getProperty
(
"messageCenterSwitch"
,
"0"
);
return
"1"
.
equals
(
messageCenterSwitch
);
return
"1"
.
equals
(
messageCenterSwitch
);
}
}
/**
* 导购通知一批次间隔时间
* @return
*/
public
static
Integer
notifyBatchInterval
()
{
Config
config
=
ConfigService
.
getAppConfig
();
String
notifyBatchInterval
=
config
.
getProperty
(
"notifyBatchInterval"
,
"30"
);
log
.
info
(
"导购通知一批次间隔时间:{}"
,
notifyBatchInterval
);
return
Integer
.
parseInt
(
notifyBatchInterval
);
}
}
}
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