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
4bb20e93
Commit
4bb20e93
authored
Jun 06, 2022
by
renandong
🇨🇳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.加入mob推送
parent
94f7388b
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
564 additions
and
26 deletions
+564
-26
Constant.java
src/main/java/com/weface/common/utils/Constant.java
+40
-0
MobPushService.java
src/main/java/com/weface/component/MobPushService.java
+446
-0
PushController.java
src/main/java/com/weface/controller/PushController.java
+13
-1
PushLogEntity.java
src/main/java/com/weface/entity/PushLogEntity.java
+4
-0
PushLogService.java
src/main/java/com/weface/service/PushLogService.java
+9
-1
PushLogServiceImpl.java
src/main/java/com/weface/serviceimpl/PushLogServiceImpl.java
+52
-24
No files found.
src/main/java/com/weface/common/utils/Constant.java
View file @
4bb20e93
...
@@ -73,4 +73,44 @@ public class Constant {
...
@@ -73,4 +73,44 @@ public class Constant {
return
value
;
return
value
;
}
}
}
}
/**
* mob推送目标
*/
public
enum
PushTarget
{
RADIO
(
1
,
"广播群推"
),
ALIAS
(
2
,
"别名推送"
),
TAGS
(
3
,
"标签推送"
),
RIDS
(
4
,
"rid推送"
),
CITY
(
5
,
"地理位置推送"
),
BLOCK
(
6
,
"用户分群推送"
),
AREA
(
9
,
"复杂地理位置推送"
),
FILE
(
14
,
"fileId推送"
),
BATCH_ALIAS
(
22
,
"别名批量推送"
),
BATCH_RIDS
(
33
,
"rid批量推送"
);
private
int
key
;
private
String
value
;
PushTarget
(
int
key
,
String
value
)
{
this
.
key
=
key
;
this
.
value
=
value
;
}
public
int
getKey
()
{
return
key
;
}
public
void
setKey
(
int
key
)
{
this
.
key
=
key
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
}
}
}
src/main/java/com/weface/component/MobPushService.java
0 → 100644
View file @
4bb20e93
This diff is collapsed.
Click to expand it.
src/main/java/com/weface/controller/PushController.java
View file @
4bb20e93
package
com
.
weface
.
controller
;
package
com
.
weface
.
controller
;
import
com.weface.code.CommonResult
;
import
com.weface.code.CommonResult
;
import
com.weface.common.utils.Constant
;
import
com.weface.common.validator.ValidatorParam
;
import
com.weface.common.validator.ValidatorParam
;
import
com.weface.common.validator.ValidatorUtils
;
import
com.weface.common.validator.ValidatorUtils
;
import
com.weface.component.GeTuiService
;
import
com.weface.component.GeTuiService
;
import
com.weface.component.MobPushService
;
import
com.weface.dto.InformForm
;
import
com.weface.dto.InformForm
;
import
com.weface.dto.MsgDTO
;
import
com.weface.dto.MsgDTO
;
import
com.weface.dto.PushDTO
;
import
com.weface.dto.PushDTO
;
...
@@ -25,7 +27,8 @@ public class PushController {
...
@@ -25,7 +27,8 @@ public class PushController {
private
PushService
pushService
;
private
PushService
pushService
;
@Autowired
@Autowired
private
GeTuiService
geTuiService
;
private
GeTuiService
geTuiService
;
@Autowired
private
MobPushService
mobPushService
;
@PostMapping
(
"list"
)
@PostMapping
(
"list"
)
public
CommonResult
pushList
(
@RequestBody
PushDTO
param
)
throws
Exception
{
public
CommonResult
pushList
(
@RequestBody
PushDTO
param
)
throws
Exception
{
...
@@ -40,6 +43,7 @@ public class PushController {
...
@@ -40,6 +43,7 @@ public class PushController {
@PostMapping
(
"/all"
)
@PostMapping
(
"/all"
)
public
CommonResult
pushAll
(
InformForm
informForm
)
{
public
CommonResult
pushAll
(
InformForm
informForm
)
{
ValidatorUtils
.
validateEntity
(
informForm
,
InformForm
.
PushValid
.
class
);
ValidatorUtils
.
validateEntity
(
informForm
,
InformForm
.
PushValid
.
class
);
mobPushService
.
mobPush
(
informForm
,
Constant
.
PushTarget
.
RADIO
);
return
geTuiService
.
listPush
(
informForm
);
return
geTuiService
.
listPush
(
informForm
);
}
}
...
@@ -50,6 +54,10 @@ public class PushController {
...
@@ -50,6 +54,10 @@ public class PushController {
if
(
commonResult
!=
null
)
{
if
(
commonResult
!=
null
)
{
return
commonResult
;
return
commonResult
;
}
}
CommonResult
result
=
mobPushService
.
mobPush
(
informForm
,
Constant
.
PushTarget
.
ALIAS
);
if
(
result
!=
null
)
{
return
CommonResult
.
success
();
}
return
geTuiService
.
pushSingleAlias
(
informForm
);
return
geTuiService
.
pushSingleAlias
(
informForm
);
}
}
...
@@ -60,6 +68,10 @@ public class PushController {
...
@@ -60,6 +68,10 @@ public class PushController {
if
(
commonResult
!=
null
)
{
if
(
commonResult
!=
null
)
{
return
commonResult
;
return
commonResult
;
}
}
CommonResult
result
=
mobPushService
.
mobPush
(
informForm
,
Constant
.
PushTarget
.
RIDS
);
if
(
result
!=
null
)
{
return
CommonResult
.
success
();
}
return
geTuiService
.
pushSingleCid
(
informForm
);
return
geTuiService
.
pushSingleCid
(
informForm
);
}
}
}
}
src/main/java/com/weface/entity/PushLogEntity.java
View file @
4bb20e93
...
@@ -24,6 +24,10 @@ public class PushLogEntity implements Serializable {
...
@@ -24,6 +24,10 @@ public class PushLogEntity implements Serializable {
* 应用名称
* 应用名称
*/
*/
private
String
appName
;
private
String
appName
;
/**
* 推送类型 1:个推 2:袤博
*/
private
Integer
pushType
;
/**
/**
* 任务id
* 任务id
*/
*/
...
...
src/main/java/com/weface/service/PushLogService.java
View file @
4bb20e93
...
@@ -14,7 +14,7 @@ import java.util.List;
...
@@ -14,7 +14,7 @@ import java.util.List;
public
interface
PushLogService
extends
IService
<
PushLogEntity
>
{
public
interface
PushLogService
extends
IService
<
PushLogEntity
>
{
/**
/**
* 保存日志
* 保存日志
个推
*
*
* @param data 返回数据
* @param data 返回数据
* @param informForm 推送数据
* @param informForm 推送数据
...
@@ -22,6 +22,14 @@ public interface PushLogService extends IService<PushLogEntity> {
...
@@ -22,6 +22,14 @@ public interface PushLogService extends IService<PushLogEntity> {
*/
*/
public
void
saveLog
(
JSONObject
data
,
InformForm
informForm
,
String
appId
);
public
void
saveLog
(
JSONObject
data
,
InformForm
informForm
,
String
appId
);
/**
* 保存推送日志 袤博
*
* @param data 返回数据
* @param informForm 推送数据
*/
public
void
saveMobLog
(
JSONObject
data
,
InformForm
informForm
);
/**
/**
* 查询日志
* 查询日志
*
*
...
...
src/main/java/com/weface/serviceimpl/PushLogServiceImpl.java
View file @
4bb20e93
...
@@ -33,31 +33,9 @@ public class PushLogServiceImpl extends ServiceImpl<PushLogDao, PushLogEntity> i
...
@@ -33,31 +33,9 @@ public class PushLogServiceImpl extends ServiceImpl<PushLogDao, PushLogEntity> i
try
{
try
{
List
<
PushLogEntity
>
logList
=
new
ArrayList
<>();
List
<
PushLogEntity
>
logList
=
new
ArrayList
<>();
for
(
String
key
:
data
.
keySet
())
{
for
(
String
key
:
data
.
keySet
())
{
PushLogEntity
pushLogEntity
=
new
PushLogEntity
();
Long
id
=
SnowIdUtil
.
nextId
();
Long
id
=
SnowIdUtil
.
nextId
();
pushLogEntity
.
setId
(
id
);
PushLogEntity
pushLog
=
getPushLog
(
id
,
informForm
,
key
,
data
.
toString
(),
1
);
pushLogEntity
.
setAppName
(
informForm
.
getEquipmentType
());
logList
.
add
(
pushLog
);
pushLogEntity
.
setTaskId
(
key
);
String
str
=
data
.
toString
();
if
(
str
.
length
()
>
200
)
{
pushLogEntity
.
setResult
(
str
.
substring
(
0
,
200
));
}
else
{
pushLogEntity
.
setResult
(
str
);
}
String
phone
=
informForm
.
getPhone
();
if
(
StringUtils
.
isNotEmpty
(
phone
))
{
DES
des
=
DES
.
getInstanceDes
();
pushLogEntity
.
setPhone
(
des
.
encrypt
(
phone
));
}
Integer
messageTemplate
=
informForm
.
getMessageTemplate
();
if
(
messageTemplate
!=
null
)
{
pushLogEntity
.
setMessageTemplate
(
messageTemplate
);
}
pushLogEntity
.
setPushTarget
(
informForm
.
getCid
()
==
null
?
"all"
:
informForm
.
getCid
());
pushLogEntity
.
setPushContent
(
informForm
.
getBody
());
pushLogEntity
.
setArriveStatus
(
1001
);
pushLogEntity
.
setUpdateTime
(
new
Date
());
logList
.
add
(
pushLogEntity
);
RedisUtil
.
HashOps
.
hPutEx
(
Constant
.
PUSH_TASK_INFO
,
key
,
String
.
valueOf
(
id
),
2L
,
TimeUnit
.
HOURS
);
RedisUtil
.
HashOps
.
hPutEx
(
Constant
.
PUSH_TASK_INFO
,
key
,
String
.
valueOf
(
id
),
2L
,
TimeUnit
.
HOURS
);
}
}
if
(!
CollectionUtils
.
isEmpty
(
logList
))
{
if
(!
CollectionUtils
.
isEmpty
(
logList
))
{
...
@@ -69,6 +47,56 @@ public class PushLogServiceImpl extends ServiceImpl<PushLogDao, PushLogEntity> i
...
@@ -69,6 +47,56 @@ public class PushLogServiceImpl extends ServiceImpl<PushLogDao, PushLogEntity> i
}
}
}
}
@Override
public
void
saveMobLog
(
JSONObject
data
,
InformForm
informForm
)
{
try
{
Long
id
=
SnowIdUtil
.
nextId
();
String
batchId
=
data
.
getJSONObject
(
"res"
).
getString
(
"batchId"
);
PushLogEntity
pushLog
=
getPushLog
(
id
,
informForm
,
batchId
,
data
.
toString
(),
2
);
this
.
save
(
pushLog
);
}
catch
(
Exception
e
)
{
log
.
error
(
"保存mob推送日志错误:{}"
,
e
.
getMessage
());
e
.
printStackTrace
();
}
}
/**
* 推送日志存储
*
* @param id id
* @param informForm 推送内容
* @param taskId 任务编号
* @param result 推送结果
* @param pushType 推送类型 1:个推 2:袤博
* @return 执行结果
* @throws Exception 异常
*/
private
PushLogEntity
getPushLog
(
Long
id
,
InformForm
informForm
,
String
taskId
,
String
result
,
Integer
pushType
)
throws
Exception
{
PushLogEntity
pushLogEntity
=
new
PushLogEntity
();
pushLogEntity
.
setId
(
id
);
pushLogEntity
.
setAppName
(
informForm
.
getEquipmentType
());
pushLogEntity
.
setPushType
(
pushType
);
pushLogEntity
.
setTaskId
(
taskId
);
if
(
result
.
length
()
>
200
)
{
result
=
result
.
substring
(
0
,
200
);
}
pushLogEntity
.
setResult
(
result
);
String
phone
=
informForm
.
getPhone
();
if
(
StringUtils
.
isNotEmpty
(
phone
))
{
DES
des
=
DES
.
getInstanceDes
();
pushLogEntity
.
setPhone
(
des
.
encrypt
(
phone
));
}
Integer
messageTemplate
=
informForm
.
getMessageTemplate
();
if
(
messageTemplate
!=
null
)
{
pushLogEntity
.
setMessageTemplate
(
messageTemplate
);
}
pushLogEntity
.
setPushTarget
(
informForm
.
getCid
()
==
null
?
"all"
:
informForm
.
getCid
());
pushLogEntity
.
setPushContent
(
informForm
.
getBody
());
pushLogEntity
.
setArriveStatus
(
1001
);
pushLogEntity
.
setUpdateTime
(
new
Date
());
return
pushLogEntity
;
}
/**
/**
* 查询日志
* 查询日志
*
*
...
...
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