Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioc_sixiang_license
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
zengtianlai3
ioc_sixiang_license
Commits
2f5f9c7f
Commit
2f5f9c7f
authored
Jun 09, 2022
by
zengtianlai3
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'm33' into 'master'
统计sam业务开发 See merge request
!13
parents
dc3b192e
cc8127aa
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
119 additions
and
21 deletions
+119
-21
OperateSAMStatusEvent.java
...java/iot/sixiang/license/event/OperateSAMStatusEvent.java
+13
-0
OperateSAMStatusEventHandler.java
...t/sixiang/license/event/OperateSAMStatusEventHandler.java
+50
-0
OperateSAMStatusQueryEventHandler.java
...iang/license/event/OperateSAMStatusQueryEventHandler.java
+0
-1
SamInfo.java
license/src/main/java/iot/sixiang/license/model/SamInfo.java
+13
-0
SamMonitor.java
...e/src/main/java/iot/sixiang/license/model/SamMonitor.java
+13
-0
SamInfoMsg.java
...c/main/java/iot/sixiang/license/model/msg/SamInfoMsg.java
+17
-0
OperateClientHandler.java
...ava/iot/sixiang/license/operate/OperateClientHandler.java
+6
-20
OperateManager.java
...main/java/iot/sixiang/license/operate/OperateManager.java
+7
-0
No files found.
license/src/main/java/iot/sixiang/license/event/OperateSAMStatusEvent.java
0 → 100644
View file @
2f5f9c7f
package
iot
.
sixiang
.
license
.
event
;
import
iot.sixiang.license.device.DeviceProtocol
;
import
lombok.Data
;
/**
* Created by m33 on 2022/6/9 21:38
*/
@Data
public
class
OperateSAMStatusEvent
extends
BaseEvent
{
private
String
ip
;
private
DeviceProtocol
protocol
;
}
license/src/main/java/iot/sixiang/license/event/OperateSAMStatusEventHandler.java
0 → 100644
View file @
2f5f9c7f
package
iot
.
sixiang
.
license
.
event
;
import
com.alibaba.fastjson.JSON
;
import
iot.sixiang.license.device.DeviceProtocol
;
import
iot.sixiang.license.model.SamInfo
;
import
iot.sixiang.license.model.SamMonitor
;
import
iot.sixiang.license.model.msg.SamInfoMsg
;
import
iot.sixiang.license.operate.OperateManager
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.event.EventListener
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
/**
* Created by m33 on 2022/6/9 21:39
*/
@Component
@Slf4j
public
class
OperateSAMStatusEventHandler
{
@Autowired
public
OperateManager
operateManager
;
public
OperateSAMStatusEventHandler
()
{
}
@EventListener
public
void
handlerEvent
(
OperateSAMStatusEvent
event
)
{
DeviceProtocol
protocol
=
event
.
getProtocol
();
String
serverIp
=
event
.
getIp
();
String
jsonOperateStatus
=
new
String
(
protocol
.
getContent
(),
0
,
protocol
.
getContent
().
length
);
SamInfoMsg
samInfoMsg
=
JSON
.
parseObject
(
jsonOperateStatus
,
SamInfoMsg
.
class
);
List
<
SamInfo
>
samInfoList
=
samInfoMsg
.
getList
();
int
samCount
=
samInfoList
.
size
();
int
onlineCount
=
0
;
for
(
SamInfo
samInfo
:
samInfoList
)
{
if
(
samInfo
.
getStatus
()
==
0
||
samInfo
.
getStatus
()
==
1
||
samInfo
.
getStatus
()
==
2
||
samInfo
.
getStatus
()
==
4
)
{
onlineCount
++;
}
}
SamMonitor
samMonitor
=
new
SamMonitor
();
samMonitor
.
setServerIp
(
serverIp
);
samMonitor
.
setOnlineCount
(
onlineCount
);
samMonitor
.
setSamCount
(
samCount
);
operateManager
.
putSamMonitorMap
(
serverIp
,
samMonitor
);
log
.
debug
(
"OperateSAMStatusEventHandler"
);
}
}
license/src/main/java/iot/sixiang/license/event/OperateSAMStatusQueryEventHandler.java
View file @
2f5f9c7f
...
...
@@ -2,7 +2,6 @@ package iot.sixiang.license.event;
import
io.netty.channel.socket.SocketChannel
;
import
iot.sixiang.license.device.DeviceProtocol
;
import
iot.sixiang.license.util.Util
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.context.event.EventListener
;
import
org.springframework.stereotype.Component
;
...
...
license/src/main/java/iot/sixiang/license/model/SamInfo.java
0 → 100644
View file @
2f5f9c7f
package
iot
.
sixiang
.
license
.
model
;
import
lombok.Data
;
/**
* Created by m33 on 2022/6/9 20:34
*/
@Data
public
class
SamInfo
{
private
int
index
;
private
int
samid
;
private
int
status
;
}
license/src/main/java/iot/sixiang/license/model/SamMonitor.java
0 → 100644
View file @
2f5f9c7f
package
iot
.
sixiang
.
license
.
model
;
import
lombok.Data
;
/**
* Created by m33 on 2022/6/9 22:07
*/
@Data
public
class
SamMonitor
{
private
String
serverIp
;
private
int
samCount
;
private
int
onlineCount
;
}
license/src/main/java/iot/sixiang/license/model/msg/SamInfoMsg.java
0 → 100644
View file @
2f5f9c7f
package
iot
.
sixiang
.
license
.
model
.
msg
;
import
iot.sixiang.license.model.SamInfo
;
import
lombok.Data
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Created by m33 on 2022/6/9 20:36
*/
@Data
public
class
SamInfoMsg
{
List
<
SamInfo
>
list
=
new
ArrayList
<>();
}
license/src/main/java/iot/sixiang/license/operate/OperateClientHandler.java
View file @
2f5f9c7f
...
...
@@ -6,9 +6,7 @@ import io.netty.channel.SimpleChannelInboundHandler;
import
io.netty.channel.socket.SocketChannel
;
import
iot.sixiang.license.device.DeviceProtocol
;
import
iot.sixiang.license.event.EventPublisher
;
import
iot.sixiang.license.event.ForwardClientInactiveEvent
;
import
iot.sixiang.license.event.ForwardMessageResponseEvent
;
import
iot.sixiang.license.util.HexUtil
;
import
iot.sixiang.license.event.OperateSAMStatusEvent
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
...
...
@@ -33,26 +31,14 @@ public class OperateClientHandler extends SimpleChannelInboundHandler<Object> {
@Override
protected
void
channelRead0
(
ChannelHandlerContext
ctx
,
Object
msg
)
throws
Exception
{
// TODO Auto-generated method stub
// TODO 中转客户端收到消息后,将消息原封不动的发送给设备客户端
SocketChannel
channel
=
(
SocketChannel
)
ctx
.
channel
();
InetSocketAddress
socketAddr
=
(
InetSocketAddress
)
ctx
.
channel
().
remoteAddress
();
String
serverIp
=
socketAddr
.
getHostString
();
int
serverPort
=
socketAddr
.
getPort
();
log
.
debug
(
"channelRead0..."
);
String
remoteIp
=
socketAddr
.
getHostString
();
DeviceProtocol
protocol
=
(
DeviceProtocol
)
msg
;
log
.
info
(
"桥接服务器响应1"
+
protocol
.
toString
());
log
.
info
(
"桥接服务器响应2:"
+
HexUtil
.
bytes2hex
(
protocol
.
getContent
()));
String
channelId
=
channel
.
id
().
asLongText
();
// ForwardMessageResponseEvent forwardMessageResponseEvent = new ForwardMessageResponseEvent();
// forwardMessageResponseEvent.setChannelId(channelId);
// forwardMessageResponseEvent.setChannel(channel);
// forwardMessageResponseEvent.setProtocol(protocol);
// eventPublisher.publishEvent(forwardMessageResponseEvent);
OperateSAMStatusEvent
event
=
new
OperateSAMStatusEvent
();
event
.
setProtocol
(
protocol
);
event
.
setIp
(
remoteIp
);
eventPublisher
.
publishEvent
(
event
);
}
...
...
license/src/main/java/iot/sixiang/license/operate/OperateManager.java
View file @
2f5f9c7f
package
iot
.
sixiang
.
license
.
operate
;
import
iot.sixiang.license.entity.Server
;
import
iot.sixiang.license.model.SamMonitor
;
import
iot.sixiang.license.service.ServerService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -21,9 +22,15 @@ public class OperateManager {
public
OperateClient
client
;
private
Map
<
String
,
Server
>
allServers
=
null
;
private
Map
<
String
,
SamMonitor
>
samMonitorMap
=
null
;
public
OperateManager
()
{
allServers
=
new
HashMap
<
String
,
Server
>();
samMonitorMap
=
new
HashMap
<>();
}
public
synchronized
void
putSamMonitorMap
(
String
serverIp
,
SamMonitor
samMonitor
)
{
samMonitorMap
.
put
(
serverIp
,
samMonitor
);
}
@PostConstruct
...
...
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