Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
znks
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
王夏晖
znks
Commits
b604d645
Commit
b604d645
authored
Sep 20, 2018
by
王夏晖
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.定时任务:保证网关数据链路活跃状态
2.个推改为群推
parent
6cc1b012
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
34 deletions
+69
-34
AdcDaApplication.java
adc-da-main/src/main/java/com/adc/da/AdcDaApplication.java
+2
-1
AppPushUtils.java
...main/src/main/java/com/adc/da/znks/util/AppPushUtils.java
+17
-13
ActiveGateWay.java
...c/main/java/com/adc/da/znks/util/netty/ActiveGateWay.java
+38
-0
ServerHandler.java
...c/main/java/com/adc/da/znks/util/netty/ServerHandler.java
+12
-20
No files found.
adc-da-main/src/main/java/com/adc/da/AdcDaApplication.java
View file @
b604d645
...
...
@@ -15,7 +15,7 @@ import org.springframework.context.annotation.Bean;
import
com.codahale.metrics.CsvReporter
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
@MapperScan
(
"com.adc.da.**.dao"
)
@ComponentScan
(
"com.adc"
)
...
...
@@ -23,6 +23,7 @@ import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
})
@EnableScheduling
public
class
AdcDaApplication
{
public
static
void
main
(
String
[]
args
)
{
...
...
adc-da-main/src/main/java/com/adc/da/znks/util/AppPushUtils.java
View file @
b604d645
...
...
@@ -23,7 +23,7 @@ public class AppPushUtils {
private
static
String
appKey
=
"XRxH4VbaVZAkl7uK44pd97"
;
private
static
String
masterSecret
=
"xhUi7HRWsv8uj28GJdjhR2"
;
private
static
String
url
=
"http://sdk.open.api.igexin.com/apiex.htm"
;
public
static
void
push
(
String
title
,
String
msg
,
String
clientId
)
throws
IOException
{
public
static
void
push
(
String
title
,
String
msg
,
String
[]
clientId
)
throws
IOException
{
// 配置返回每个用户返回用户状态,可选
System
.
setProperty
(
"gexin_pushList_needDetails"
,
"true"
);
...
...
@@ -40,10 +40,12 @@ public class AppPushUtils {
message
.
setOfflineExpireTime
(
24
*
1000
*
3600
);
// 配置推送目标
List
<
Target
>
targets
=
new
ArrayList
<>(
1
);
Target
target1
=
new
Target
();
target1
.
setAppId
(
appId
);
target1
.
setClientId
(
clientId
);
targets
.
add
(
target1
);
for
(
String
client
:
clientId
){
Target
target1
=
new
Target
();
target1
.
setAppId
(
appId
);
target1
.
setClientId
(
client
);
targets
.
add
(
target1
);
}
// taskId用于在推送时去查找对应的message
String
taskId
=
push
.
getContentId
(
message
);
IPushResult
ret
=
push
.
pushMessageToList
(
taskId
,
targets
);
...
...
@@ -76,7 +78,7 @@ public class AppPushUtils {
return
template
;
}
public
static
void
pushTc
(
String
title
,
String
msg
,
String
clientId
)
throws
IOException
{
public
static
void
pushTc
(
String
title
,
String
msg
,
String
[]
clientId
)
throws
IOException
{
// 配置返回每个用户返回用户状态,可选
System
.
setProperty
(
"gexin_pushList_needDetails"
,
"true"
);
...
...
@@ -93,10 +95,12 @@ public class AppPushUtils {
message
.
setOfflineExpireTime
(
24
*
1000
*
3600
);
// 配置推送目标
List
<
Target
>
targets
=
new
ArrayList
<>(
1
);
Target
target1
=
new
Target
();
target1
.
setAppId
(
appId
);
target1
.
setClientId
(
clientId
);
targets
.
add
(
target1
);
for
(
String
client
:
clientId
){
Target
target1
=
new
Target
();
target1
.
setAppId
(
appId
);
target1
.
setClientId
(
client
);
targets
.
add
(
target1
);
}
// taskId用于在推送时去查找对应的message
String
taskId
=
push
.
getContentId
(
message
);
IPushResult
ret
=
push
.
pushMessageToList
(
taskId
,
targets
);
...
...
@@ -115,11 +119,11 @@ public class AppPushUtils {
}
public
static
void
main
(
String
[]
args
)
{
try
{
push
(
"提示"
,
"测试推送"
,
"c3d2cb373109db849b7ecfb22a4fd93d"
);
/*
try {
//
push("提示", "测试推送", "c3d2cb373109db849b7ecfb22a4fd93d");
} catch (IOException e) {
e.printStackTrace();
}
}
*/
}
}
adc-da-main/src/main/java/com/adc/da/znks/util/netty/ActiveGateWay.java
0 → 100644
View file @
b604d645
package
com
.
adc
.
da
.
znks
.
util
.
netty
;
import
com.adc.da.znks.util.SystemValue
;
import
io.netty.channel.Channel
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
java.util.Map
;
/**
* @ClassName ActiveGateWay
* @Descroption TODO
* @Author 王夏晖
* @Date 2018/9/17 0017 19:50
**/
@Component
public
class
ActiveGateWay
{
@Scheduled
(
cron
=
"0 0/1 * * * ?"
)
public
void
timerToNow
(){
Map
<
String
,
Object
>
channelMap
=
SystemValue
.
channelMap
;
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
channelMap
.
entrySet
())
{
byte
[]
request
=
new
byte
[
23
];
request
[
0
]
=
0x4d
;
request
[
1
]
=
0x41
;
request
[
2
]
=
0x43
;
request
[
3
]
=
0x5F
;
request
[
4
]
=
0x52
;
request
[
5
]
=
0x45
;
request
[
6
]
=
0x51
;
request
[
7
]
=
0x55
;
request
[
8
]
=
0x45
;
request
[
9
]
=
0x53
;
request
[
10
]
=
0x54
;
Channel
channel
=
(
Channel
)
entry
.
getValue
();
channel
.
writeAndFlush
(
request
);
}
}
}
adc-da-main/src/main/java/com/adc/da/znks/util/netty/ServerHandler.java
View file @
b604d645
...
...
@@ -108,28 +108,20 @@ public class ServerHandler extends ChannelInboundHandlerAdapter {
System
.
out
.
println
(
lockType
);
serverHandler
.
lockRecordService
.
insertLockRecord
(
lockRecord
);
if
(
list
!=
null
){
if
(
"80"
.
equals
(
instruct
)){
// 远程开锁触发请求,发送透传
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++){
clientId
=
list
.
get
(
i
).
get
(
"client_id"
)!=
null
?
list
.
get
(
i
).
get
(
"client_id"
).
toString
():
""
;
if
(!
""
.
equals
(
clientId
)){
AppPushUtils
.
pushTc
(
title
,
message
,
clientId
);
AppPushUtils
.
push
(
title
,
message
,
clientId
);
}
else
{
logger
.
info
(
"clientId为空"
);
}
String
[]
client
=
new
String
[
list
.
size
()];
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++){
clientId
=
list
.
get
(
i
).
get
(
"client_id"
)!=
null
?
list
.
get
(
i
).
get
(
"client_id"
).
toString
():
""
;
if
(!
""
.
equals
(
clientId
)){
client
[
i
]
=
clientId
;
}
else
{
logger
.
info
(
"clientId为空"
);
}
}
if
(
"80"
.
equals
(
instruct
)){
// 远程开锁触发请求,发送透传
AppPushUtils
.
pushTc
(
title
,
message
,
client
);
AppPushUtils
.
push
(
title
,
message
,
client
);
}
else
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++){
clientId
=
list
.
get
(
i
).
get
(
"client_id"
)!=
null
?
list
.
get
(
i
).
get
(
"client_id"
).
toString
():
""
;
if
(!
""
.
equals
(
clientId
)){
AppPushUtils
.
push
(
title
,
message
,
clientId
);
}
else
{
logger
.
info
(
"clientId为空"
);
}
}
AppPushUtils
.
push
(
title
,
message
,
client
);
}
}
else
{
logger
.
info
(
"clientId未获取,消息发送失败"
);
...
...
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