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
d5f23c73
Commit
d5f23c73
authored
Sep 09, 2021
by
tianbo
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'developer' of
http://172.16.10.76/moa/amos-boot-biz
into developer
parents
2e94045e
f9fa00de
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
115 additions
and
82 deletions
+115
-82
PushMsgParam.java
.../com/yeejoin/amos/patrol/business/param/PushMsgParam.java
+10
-0
MessageServiceImpl.java
...amos/patrol/business/service/impl/MessageServiceImpl.java
+27
-9
IMessageService.java
...n/amos/patrol/business/service/intfc/IMessageService.java
+4
-1
AsyncTask.java
...in/java/com/yeejoin/amos/patrol/core/async/AsyncTask.java
+5
-33
PushFeignServer.java
...n/java/com/yeejoin/amos/patrol/feign/PushFeignServer.java
+46
-26
AppMessagePushService.java
.../com/yeejoin/amos/patrol/jpush/AppMessagePushService.java
+12
-12
JobService.java
.../main/java/com/yeejoin/amos/patrol/quartz/JobService.java
+1
-1
pom.xml
pom.xml
+10
-0
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 @
d5f23c73
...
...
@@ -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 @
d5f23c73
...
...
@@ -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
);
...
...
@@ -223,8 +231,8 @@ public class MessageServiceImpl implements IMessageService {
}
List
<
String
>
pushApps
=
jpushUser
.
stream
()
.
filter
(
bo
->
StringUtil
.
isNotEmpty
(
bo
.
getUser
name
()))
.
map
(
PushTargetBo:
:
getUser
name
).
collect
(
Collectors
.
toList
());
.
filter
(
bo
->
StringUtil
.
isNotEmpty
(
bo
.
getUser
Id
()))
.
map
(
PushTargetBo:
:
getUser
Id
).
collect
(
Collectors
.
toList
());
pushApps
=
pushApps
.
stream
().
distinct
().
collect
(
Collectors
.
toList
());
if
(!
pushApps
.
isEmpty
()){
List
<
PushMsgParam
>
pmps
=
new
ArrayList
<
PushMsgParam
>();
...
...
@@ -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
.
get
TargetTel
()));
pushMsg
.
setRecivers
(
Arrays
.
asList
(
msg
.
get
UserId
()));
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 @
d5f23c73
...
...
@@ -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 @
d5f23c73
...
...
@@ -66,37 +66,7 @@ public class AsyncTask {
private
static
final
String
TAB
=
"\r\n"
;
/**
* 邮件发送
* @param msgResponse
* @return
* @throws InterruptedException
*/
// @Async("asyncTaskExecutor")
// public Future<Boolean> sendEmail(PushMsgParam pmp) throws InterruptedException {
// long start = System.currentTimeMillis();
// iEmailService.sendSimpleEmail(pmp.getEmails(), pmp.getSubject(), pmp.getContent());
// long end = System.currentTimeMillis();
// log.info("=====邮件发送耗时:"+(end-start)+"======");
// return new AsyncResult<Boolean>(true);
// }
//
// /**
// * jpush 推送
// * @param pmps
// * @return
// * @throws InterruptedException
// */
// @Async("asyncTaskExecutor")
// public Future<Boolean> sendJpush(List<PushMsgParam> pmps) throws InterruptedException {
// long start = System.currentTimeMillis();
// appMessagePushService.sendMessage(pmps);
// long end = System.currentTimeMillis();
// //返回true,告诉此任务已完成
// log.info("=====Jpush发送耗时:"+(end-start)+"======");
// return new AsyncResult<Boolean>(true);
// }
/**
* 检查消息推送
* @param checkId
...
...
@@ -231,6 +201,7 @@ public class AsyncTask {
msg
.
setIsImmediately
(
true
);
msg
.
setSendTime
(
date
);
msg
.
setCreateDate
(
date
);
msg
.
setTargetTel
(
user
.
getString
(
"username"
));
msg
.
setReciverName
(
user
.
getString
(
"realName"
));
sendUserIds
.
add
(
user
.
getString
(
"userId"
));
msgs
.
add
(
msg
);
...
...
@@ -247,11 +218,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 @
d5f23c73
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/jpush/AppMessagePushService.java
View file @
d5f23c73
...
...
@@ -110,17 +110,17 @@ public class AppMessagePushService {
}
public
void
sendMessage
(
PushMsgParam
response
){
try
{
if
(
null
!=
response
&&
"true"
.
equals
(
isPush
)){
CommonResponse
commonResponse
=
PushFeign
.
sendMessageone
(
response
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
e
.
printStackTrace
();
}
}
//
public void sendMessage(PushMsgParam response){
//
//
try {
//
if(null!=response && "true".equals(isPush)){
//
CommonResponse commonResponse = PushFeign.sendMessageone(response);
//
}
//
} catch (Exception e) {
//
log.error(e.getMessage(),e);
//
e.printStackTrace();
//
//
}
//
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/quartz/JobService.java
View file @
d5f23c73
...
...
@@ -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 @
d5f23c73
...
...
@@ -200,6 +200,16 @@
</exclusions>
</dependency>
<dependency>
<groupId>
com.yeejoin
</groupId>
<artifactId>
amos-feign-privilege
</artifactId>
<version>
${amos.version}
</version>
</dependency>
<dependency>
<groupId>
com.yeejoin
</groupId>
<artifactId>
amos-feign-systemctl
</artifactId>
<version>
1.6.3-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
io.swagger
</groupId>
<artifactId>
swagger-annotations
</artifactId>
<version>
1.5.13
</version>
...
...
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