Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
push-message
Project
Project
Details
Activity
Releases
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
liucheng
push-message
Commits
7d2c1770
Commit
7d2c1770
authored
Jun 23, 2022
by
renandong
🇨🇳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1,设置毛博厂商特殊配置
2,增加查询毛博推送是否到达 3,短信推送定时任务增加毛博
parent
36a8d9ce
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
22 deletions
+99
-22
MobPushService.java
src/main/java/com/weface/component/MobPushService.java
+59
-4
UserTagsTask.java
src/main/java/com/weface/task/UserTagsTask.java
+39
-17
PushLogDao.xml
src/main/resources/mapper/PushLogDao.xml
+1
-1
No files found.
src/main/java/com/weface/component/MobPushService.java
View file @
7d2c1770
...
...
@@ -19,10 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
java.lang.reflect.Type
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
/**
* @author : Administrator
...
...
@@ -79,6 +76,9 @@ public class MobPushService {
request
.
put
(
"pushNotify"
,
pushNotify
);
Map
<
String
,
Object
>
pushForward
=
getPushForward
();
request
.
put
(
"pushForward"
,
pushForward
);
//厂商特殊配置
Map
<
String
,
Object
>
pushFactoryExtra
=
getPushFactoryExtra
();
request
.
put
(
"pushFactoryExtra"
,
pushFactoryExtra
);
//groupId: AB分组测试ID
request
.
put
(
"groupId"
,
target
.
getValue
());
String
body
=
generalPost
(
request
,
pushUrl
);
...
...
@@ -89,6 +89,22 @@ public class MobPushService {
return
null
;
}
/**
* 厂商特殊渠道配置
*
* @return map
*/
private
Map
<
String
,
Object
>
getPushFactoryExtra
()
{
Map
<
String
,
Object
>
pushFactoryExtra
=
new
HashMap
<>();
Map
<
String
,
Object
>
huaweiExtra
=
new
HashMap
<>();
huaweiExtra
.
put
(
"importance"
,
"NORMAL"
);
pushFactoryExtra
.
put
(
"huaweiExtra"
,
huaweiExtra
);
Map
<
String
,
Object
>
vivoExtra
=
new
HashMap
<>();
vivoExtra
.
put
(
"classification"
,
"1"
);
pushFactoryExtra
.
put
(
"vivoExtra"
,
vivoExtra
);
return
pushFactoryExtra
;
}
/**
* mob批量推送
*
...
...
@@ -136,6 +152,45 @@ public class MobPushService {
return
Model
.
error
();
}
public
boolean
getPushInfoById
(
String
workId
)
{
String
reqUrl
=
"http://api.push.mob.com/v3/stats/getByWorkId"
;
Map
<
String
,
Object
>
request
=
new
HashMap
<>();
//appkey
request
.
put
(
"appkey"
,
APP_KEY
);
request
.
put
(
"workId"
,
workId
);
String
body
=
generalPost
(
request
,
reqUrl
);
log
.
error
(
"查询回调结果:{}"
,
body
);
if
(
JSONUtil
.
isJson
(
body
))
{
JSONObject
json
=
JSONObject
.
parseObject
(
body
);
if
(
json
.
containsKey
(
"status"
)
&&
json
.
getInteger
(
"status"
).
equals
(
200
))
{
if
(
json
.
containsKey
(
"res"
))
{
JSONObject
res
=
json
.
getJSONObject
(
"res"
);
if
(
Objects
.
nonNull
(
res
))
{
if
(
res
.
containsKey
(
"android"
))
{
JSONObject
android
=
res
.
getJSONObject
(
"android"
);
if
(
Objects
.
nonNull
(
android
))
{
if
(
android
.
containsKey
(
"deliverFailNum"
))
{
Integer
deliverFailNum
=
android
.
getInteger
(
"deliverFailNum"
);
return
deliverFailNum
<=
0
;
}
}
}
else
if
(
res
.
containsKey
(
"ios"
))
{
JSONObject
ios
=
res
.
getJSONObject
(
"ios"
);
if
(
Objects
.
nonNull
(
ios
))
{
if
(
ios
.
containsKey
(
"deliverFailNum"
))
{
Integer
deliverFailNum
=
ios
.
getInteger
(
"deliverFailNum"
);
return
deliverFailNum
<=
0
;
}
}
}
}
}
}
}
return
false
;
}
private
Map
<
String
,
Object
>
getItems
(
String
[]
target
,
String
title
,
String
content
,
Integer
pushType
)
{
Map
<
String
,
Object
>
items
=
new
HashMap
<>();
items
.
put
(
"itemId"
,
IdUtil
.
fastUUID
());
...
...
src/main/java/com/weface/task/UserTagsTask.java
View file @
7d2c1770
...
...
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import
cn.hutool.json.JSONUtil
;
import
com.weface.common.utils.*
;
import
com.weface.component.MenuService
;
import
com.weface.component.MobPushService
;
import
com.weface.config.RedisExpireData
;
import
com.weface.entity.MenuTagsEntity
;
import
com.weface.entity.PushLogEntity
;
...
...
@@ -58,38 +59,59 @@ public class UserTagsTask {
@Autowired
private
PushLogService
pushLogService
;
@Autowired
private
MobPushService
mobPushService
;
/**
* 查询推送日志时间
*/
private
static
final
Integer
TIME
=
1
;
private
static
final
Integer
TIME
=
2
;
/**
* 查询未推送消息成功记录,发送短信通知
*/
@Scheduled
(
cron
=
"0 0 0/1 * * ? "
)
// @Scheduled(cron = "0 0 0/1 * * ?")
@Scheduled
(
cron
=
"0 0/2 * * * ?"
)
public
void
sendMessage
()
{
try
{
log
.
error
(
"开始执行短信
发
送任务"
);
log
.
error
(
"开始执行短信
推
送任务"
);
List
<
PushLogEntity
>
list
=
pushLogService
.
getPushLogByTime
(
TIME
);
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
DES
des
=
DES
.
getInstanceDes
();
for
(
PushLogEntity
pushLogEntity
:
list
)
{
String
phone
=
pushLogEntity
.
getPhone
();
if
(
StringUtils
.
isNotEmpty
(
phone
)){
if
(
CommonUtil
.
isBase64
(
phone
))
{
phone
=
des
.
decrypt
(
phone
);
}
String
pushContent
=
pushLogEntity
.
getPushContent
();
Integer
messageTemplate
=
pushLogEntity
.
getMessageTemplate
();
Integer
arriveStatus
=
pushLogEntity
.
getArriveStatus
();
if
(
1001
==
arriveStatus
)
{
boolean
b
=
ShortMsgSend
.
sendMobileByRegister
(
pushContent
,
phone
,
messageTemplate
);
if
(
b
)
{
log
.
error
(
"执行短信发送成功"
);
pushLogEntity
.
setArriveStatus
(
1003
);
pushLogEntity
.
setUpdateTime
(
new
Date
());
pushLogService
.
updateById
(
pushLogEntity
);
if
(
StringUtils
.
isEmpty
(
phone
))
{
continue
;
}
if
(
CommonUtil
.
isBase64
(
phone
))
{
phone
=
des
.
decrypt
(
phone
);
}
Integer
arriveStatus
=
pushLogEntity
.
getArriveStatus
();
if
(
arriveStatus
.
equals
(
1001
))
{
Integer
pushType
=
pushLogEntity
.
getPushType
();
if
(
Objects
.
nonNull
(
pushType
))
{
String
pushContent
=
pushLogEntity
.
getPushContent
();
Integer
messageTemplate
=
pushLogEntity
.
getMessageTemplate
();
boolean
push
=
false
;
//毛博推送
if
(
pushType
.
equals
(
2
))
{
//查询推送记录是否送到
push
=
mobPushService
.
getPushInfoById
(
pushLogEntity
.
getTaskId
());
//推送已到达
if
(
push
)
{
pushLogEntity
.
setArriveStatus
(
1002
);
pushLogEntity
.
setUpdateTime
(
new
Date
());
pushLogService
.
updateById
(
pushLogEntity
);
}
}
if
(!
push
)
{
boolean
b
=
ShortMsgSend
.
sendMobileByRegister
(
pushContent
,
phone
,
messageTemplate
);
if
(
b
)
{
log
.
error
(
"执行短信发送成功:{}"
,
phone
);
pushLogEntity
.
setArriveStatus
(
1003
);
pushLogEntity
.
setUpdateTime
(
new
Date
());
pushLogService
.
updateById
(
pushLogEntity
);
}
}
}
}
...
...
src/main/resources/mapper/PushLogDao.xml
View file @
7d2c1770
...
...
@@ -24,7 +24,7 @@
<select
id=
"getPushLogByTime"
resultMap=
"pushLogMap"
>
SELECT *
FROM tb_push_log
WHERE is_valid = 1
WHERE is_valid = 1
AND phone IS NOT NULL
AND arrive_status = 1001
AND create_time > DATE_SUB(
NOW(),
...
...
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