Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
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
项目统一框架
amos-boot-biz
Commits
f2df9b7b
Commit
f2df9b7b
authored
Sep 08, 2021
by
maoying
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改巡查消息推送接口
parent
03cf25ae
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
89 additions
and
37 deletions
+89
-37
PushMsgParam.java
.../com/yeejoin/amos/patrol/business/param/PushMsgParam.java
+10
-0
MessageServiceImpl.java
...amos/patrol/business/service/impl/MessageServiceImpl.java
+24
-6
IMessageService.java
...n/amos/patrol/business/service/intfc/IMessageService.java
+4
-1
AsyncTask.java
...in/java/com/yeejoin/amos/patrol/core/async/AsyncTask.java
+3
-2
PushFeignServer.java
...n/java/com/yeejoin/amos/patrol/feign/PushFeignServer.java
+46
-26
JobService.java
.../main/java/com/yeejoin/amos/patrol/quartz/JobService.java
+1
-1
pom.xml
pom.xml
+1
-1
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/param/PushMsgParam.java
View file @
f2df9b7b
...
...
@@ -41,6 +41,8 @@ public class PushMsgParam {
* jpush发送类型:1:广播;2:标签;3:别名
*/
private
String
type
=
"3"
;
private
String
relationId
;
public
String
getType
()
{
return
type
;
...
...
@@ -90,5 +92,13 @@ public class PushMsgParam {
public
void
setEmails
(
String
[]
emails
)
{
this
.
emails
=
emails
;
}
public
String
getRelationId
()
{
return
relationId
;
}
public
void
setRelationId
(
String
relationId
)
{
this
.
relationId
=
relationId
;
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/service/impl/MessageServiceImpl.java
View file @
f2df9b7b
...
...
@@ -147,8 +147,14 @@ public class MessageServiceImpl implements IMessageService {
}
}
//获取需要推送的app的用户
List
<
PushTargetBo
>
jpushUser
=
msgMapper
.
getPushUserBo
(
"app"
,
String
.
join
(
","
,
needUserIds
),
checkMsgBo
.
getRouteId
(),
getAppPushConfig
(
checkMsgBo
.
getStatus
()));
//获取需要推送的app的用户 手机端暂时无订阅功能,暂时屏蔽
// List<PushTargetBo> jpushUser = msgMapper.getPushUserBo("app", String.join(",", needUserIds), checkMsgBo.getRouteId(),getAppPushConfig(checkMsgBo.getStatus()));
List
<
PushTargetBo
>
jpushUser
=
new
ArrayList
<>();
needUserIds
.
stream
().
forEach
(
action
->{
PushTargetBo
pb
=
new
PushTargetBo
();
pb
.
setUserId
(
action
);
jpushUser
.
add
(
pb
);
});
//获取需要推送的email的用户
List
<
PushTargetBo
>
emailUser
=
msgMapper
.
getPushUserBo
(
"email"
,
String
.
join
(
","
,
needUserIds
),
checkMsgBo
.
getRouteId
(),
getEmailPushConfig
(
checkMsgBo
.
getStatus
()));
...
...
@@ -157,7 +163,9 @@ public class MessageServiceImpl implements IMessageService {
List
<
PushTargetBo
>
tempList
=
new
ArrayList
<>();
tempList
.
addAll
(
jpushUser
);
tempList
.
addAll
(
emailUser
);
List
<
String
>
userIds
=
tempList
.
stream
().
map
(
PushTargetBo:
:
getUserId
).
distinct
().
collect
(
Collectors
.
toList
());
// 手机端暂时无订阅功能,暂时屏蔽
// List<String> userIds=tempList.stream().map(PushTargetBo::getUserId).distinct().collect(Collectors.toList());
Set
<
String
>
userIds
=
needUserIds
;
List
<
AgencyUserModel
>
agencyUserModelList
=
remoteSecurityService
.
listUserByUserIds
(
toke
,
product
,
appKey
,
String
.
join
(
","
,
userIds
));
try
{
pushAppMsg
(
jpushUser
,
agencyUserModelList
,
pushMsgParam
,
checkMsgBo
,
toke
,
product
,
appKey
);
...
...
@@ -234,6 +242,7 @@ public class MessageServiceImpl implements IMessageService {
extras
.
put
(
"type"
,
MsgTypeEnum
.
CHECK
.
getCode
());
extras
.
put
(
"id"
,
checkMsgBo
.
getCheckId
()+
""
);
pushMsgParam
.
setExtras
(
extras
);
pushMsgParam
.
setRelationId
(
checkMsgBo
.
getCheckId
()+
""
);
pmps
.
add
(
pushMsgParam
);
List
<
Msg
>
msgList
=
createMsg
(
jpushUser
,
checkMsgBo
);
pushFeignServer
.
sendMessage
(
toke
,
product
,
appKey
,
pmps
);
...
...
@@ -302,13 +311,14 @@ public class MessageServiceImpl implements IMessageService {
}
@Override
public
Msg
pushMsg
(
String
toke
,
String
product
,
String
appKey
,
Msg
msg
)
{
public
Msg
pushMsg
AndSave
(
String
toke
,
String
product
,
String
appKey
,
Msg
msg
)
{
List
<
PushMsgParam
>
pmps
=
new
ArrayList
<
PushMsgParam
>();
PushMsgParam
pushMsg
=
new
PushMsgParam
();
pushMsg
.
setRecivers
(
Arrays
.
asList
(
msg
.
getTargetTel
()));
pushMsg
.
setContent
(
ObjectUtils
.
isEmpty
(
msg
.
getPushBody
())
?
msg
.
getBody
()
:
msg
.
getPushBody
());
pushMsg
.
setSubject
(
msg
.
getTitle
());
pushMsg
.
setType
(
JPushTypeEnum
.
ALIAS
.
getCode
());
pushMsg
.
setRelationId
(
msg
.
getRelationId
()==
null
?
"0"
:
msg
.
getRelationId
().
toString
());
Map
<
String
,
String
>
extras
=
new
HashMap
<
String
,
String
>();
extras
.
put
(
"type"
,
msg
.
getMsgType
());
extras
.
put
(
"id"
,
msg
.
getRelationId
()==
null
?
"0"
:
msg
.
getRelationId
().
toString
());
...
...
@@ -350,7 +360,7 @@ public class MessageServiceImpl implements IMessageService {
msg
.
setUserId
(
user
.
getUserId
());
msg
.
setReciverName
(
user
.
getRealName
());
if
(
isImmediately
)
{
//立即发送
msg
=
pushMsg
(
toke
,
product
,
appKey
,
msg
);
msg
=
pushMsg
AndSave
(
toke
,
product
,
appKey
,
msg
);
}
else
{
//定时发送
msg
.
setStatus
(
0
);
msg
.
setFixedTime
(
notice
.
getFixedTime
());
...
...
@@ -414,9 +424,17 @@ public class MessageServiceImpl implements IMessageService {
msg
.
setTargetTel
(
userNames
);
msg
.
setUserId
(
userIds
);
msg
.
setIsImmediately
(
isImmediately
);
pushMsg
(
toke
,
product
,
appKey
,
msg
);
pushMsg
AndSave
(
toke
,
product
,
appKey
,
msg
);
}
}
}
@Override
public
void
pushMsg
(
String
toke
,
String
product
,
String
appKey
,
PushMsgParam
pmsg
)
{
// TODO Auto-generated method stub
pushFeignServer
.
sendMessage
(
toke
,
product
,
appKey
,
pmsg
);
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/service/intfc/IMessageService.java
View file @
f2df9b7b
...
...
@@ -7,6 +7,7 @@ import org.springframework.data.domain.Page;
import
com.yeejoin.amos.patrol.business.param.MsgInfoPageParam
;
import
com.yeejoin.amos.patrol.business.param.NoticePublishParam
;
import
com.yeejoin.amos.patrol.business.param.PushMsgParam
;
import
com.yeejoin.amos.patrol.business.vo.MsgVo
;
import
com.yeejoin.amos.patrol.dao.entity.Check
;
import
com.yeejoin.amos.patrol.dao.entity.Msg
;
...
...
@@ -48,6 +49,8 @@ public interface IMessageService {
* 消息公告推送
* @param msg
*/
public
Msg
pushMsg
(
String
toke
,
String
product
,
String
appKey
,
Msg
msg
);
public
Msg
pushMsgAndSave
(
String
toke
,
String
product
,
String
appKey
,
Msg
msg
);
public
void
pushMsg
(
String
toke
,
String
product
,
String
appKey
,
PushMsgParam
pmsg
);
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/core/async/AsyncTask.java
View file @
f2df9b7b
...
...
@@ -247,11 +247,12 @@ public class AsyncTask {
pushMsgParam
.
setContent
(
body
);
pushMsgParam
.
setRecivers
(
Lists
.
newArrayList
(
sendUserIds
));
pushMsgParam
.
setSubject
(
title
);
pushMsgParam
.
setRelationId
(
String
.
valueOf
(
relationId
));
pushMsgParam
.
setType
(
JPushTypeEnum
.
ALIAS
.
getCode
());
pushMsgParam
.
setExtras
(
extras
);
iMsgDao
.
saveAll
(
msgs
);
appMessagePushService
.
sendMessage
(
pushMsgParam
);
// log.info("极光推送成功====>" + sendUserIds
);
Toke
toke
=
remoteSecurityService
.
getServerToken
(
);
messageService
.
pushMsg
(
toke
.
getToke
(),
toke
.
getProduct
(),
toke
.
getAppKey
(),
pushMsgParam
);
}
}
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/feign/PushFeignServer.java
View file @
f2df9b7b
package
com
.
yeejoin
.
amos
.
patrol
.
feign
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -14,38 +15,57 @@ import com.yeejoin.amos.patrol.business.param.PushMsgParam;
import
com.yeejoin.amos.patrol.business.util.CommonResponse
;
import
com.yeejoin.amos.patrol.business.util.CommonResponseUtil
;
import
com.yeejoin.amos.patrol.core.common.response.TaskInfoRespone
;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
import
com.yeejoin.amos.feign.systemctl.model.MessageModel
;
@Service
(
"pushFeignServer"
)
public
class
PushFeignServer
{
@Autowired
private
RestTemplate
restTemplate
;
@Value
(
"${Push.fegin.name}"
)
private
String
RPushFeginName
;
private
static
String
sendMessage
=
"/api/user/sendMessage"
;
// @Autowired
// private RestTemplate restTemplate;
//
// @Value("${Push.fegin.name}")
// private String RPushFeginName;
// private static String sendMessage = "/api/user/sendMessage";
//
// public String geturls(String url){
// return "http://"+RPushFeginName+url;
// }
// public HttpHeaders getHeader(String toke,String product,String appKey){
// HttpHeaders headers = new HttpHeaders();
// headers.setContentType(MediaType.APPLICATION_JSON);
// headers.set("Content-Type", "application/json");
// headers.set("token", toke);
// headers.set("product",product);
// headers.set("appKey", appKey);
// return headers;
// }
public
String
geturls
(
String
url
){
return
"http://"
+
RPushFeginName
+
url
;
}
public
HttpHeaders
getHeader
(
String
toke
,
String
product
,
String
appKey
){
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
headers
.
set
(
"Content-Type"
,
"application/json"
);
headers
.
set
(
"token"
,
toke
);
headers
.
set
(
"product"
,
product
);
headers
.
set
(
"appKey"
,
appKey
);
return
headers
;
}
public
void
sendMessage
(
String
toke
,
String
product
,
String
appKey
,
List
<
PushMsgParam
>
pushMsgParam
){
try
{
pushMsgParam
.
forEach
(
action
->{
sendJP
(
action
);
});
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
CommonResponse
sendMessage
(
String
toke
,
String
product
,
String
appKey
,
List
<
PushMsgParam
>
pushMsgParam
){
public
void
sendMessage
(
String
toke
,
String
product
,
String
appKey
,
PushMsgParam
pushMsgParam
){
try
{
HttpEntity
httpEntity
=
new
HttpEntity
<>(
pushMsgParam
,
getHeader
(
toke
,
product
,
appKey
));
CommonResponse
commonResponse1
=
restTemplate
.
postForObject
(
geturls
(
sendMessage
),
httpEntity
,
CommonResponse
.
class
);
return
commonResponse1
;
}
catch
(
Exception
e
)
{
sendJP
(
pushMsgParam
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
CommonResponseUtil
.
failure
(
"发送失败"
);
}
}
}
private
void
sendJP
(
PushMsgParam
pushMsgParam
){
MessageModel
model
=
new
MessageModel
();
model
.
setRelationId
(
pushMsgParam
.
getRelationId
());
model
.
setTitle
(
pushMsgParam
.
getSubject
());
model
.
setBody
(
pushMsgParam
.
getContent
());
model
.
setMsgType
(
"patrolSystem"
);
model
.
setRecivers
(
pushMsgParam
.
getRecivers
());
model
.
setExtras
(
pushMsgParam
.
getExtras
());
Systemctl
.
messageClient
.
create
(
model
);
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/quartz/JobService.java
View file @
f2df9b7b
...
...
@@ -521,7 +521,7 @@ public class JobService implements IJobService {
if
(
iMsgDao
.
existsById
(
msgId
))
{
Msg
msg
=
iMsgDao
.
findById
(
msgId
).
get
();
Toke
toke
=
remoteSecurityService
.
getServerToken
();
messageService
.
pushMsg
(
toke
.
getToke
(),
toke
.
getProduct
(),
toke
.
getAppKey
(),
msg
);
messageService
.
pushMsg
AndSave
(
toke
.
getToke
(),
toke
.
getProduct
(),
toke
.
getAppKey
(),
msg
);
}
removeJob
(
jobName
);
}
...
...
pom.xml
View file @
f2df9b7b
...
...
@@ -274,7 +274,7 @@
<dependency>
<groupId>
com.yeejoin
</groupId>
<artifactId>
amos-feign-systemctl
</artifactId>
<version>
${amos.version}
</version>
<version>
1.6.3-SNAPSHOT
</version>
</dependency>
</dependencies>
...
...
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