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
4a671a1b
Commit
4a671a1b
authored
Jun 09, 2022
by
zengtianlai3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
运维模块-告警
parent
2f5f9c7f
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
151 additions
and
24 deletions
+151
-24
OperateController.java
...ava/iot/sixiang/license/controller/OperateController.java
+30
-12
Alarm.java
license/src/main/java/iot/sixiang/license/entity/Alarm.java
+18
-0
JwtFilter.java
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
+2
-1
AlarmMapper.java
...src/main/java/iot/sixiang/license/mapper/AlarmMapper.java
+25
-0
OperateClientHandler.java
...ava/iot/sixiang/license/operate/OperateClientHandler.java
+2
-0
OperateConnectionListener.java
...ot/sixiang/license/operate/OperateConnectionListener.java
+4
-4
OperateDecoder.java
...main/java/iot/sixiang/license/operate/OperateDecoder.java
+3
-3
OperateManager.java
...main/java/iot/sixiang/license/operate/OperateManager.java
+11
-4
AlarmService.java
...c/main/java/iot/sixiang/license/service/AlarmService.java
+22
-0
AlarmServiceImpl.java
...va/iot/sixiang/license/service/impl/AlarmServiceImpl.java
+25
-0
AlarmMapper.xml
license/src/main/resources/mapper/AlarmMapper.xml
+9
-0
No files found.
license/src/main/java/iot/sixiang/license/controller/OperateController.java
View file @
4a671a1b
...
...
@@ -2,7 +2,11 @@ package iot.sixiang.license.controller;
import
com.alibaba.fastjson.JSONObject
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.SamMonitor
;
import
iot.sixiang.license.operate.OperateManager
;
import
iot.sixiang.license.service.AlarmService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -15,20 +19,34 @@ import java.util.List;
@RequestMapping
(
"/iot_license/operate"
)
public
class
OperateController
{
@Autowired
private
OperateManager
operateManager
;
@Autowired
private
AlarmService
alarmService
;
@GetMapping
(
"monitor/server"
)
public
ResResult
getDeviceTypes
()
{
List
<
JSONObject
>
list
=
new
ArrayList
<>();
JSONObject
obj
=
new
JSONObject
();
obj
.
put
(
"serverIp"
,
"192.168.1.11"
);
obj
.
put
(
"serverSam"
,
100
);
obj
.
put
(
"onlineCount"
,
55
);
list
.
add
(
obj
);
JSONObject
obj2
=
new
JSONObject
();
obj2
.
put
(
"serverIp"
,
"192.168.1.12"
);
obj2
.
put
(
"serverSam"
,
100
);
obj2
.
put
(
"onlineCount"
,
55
);
list
.
add
(
obj2
);
return
ResResult
.
success
().
record
(
list
);
// List<JSONObject> list = new ArrayList<>();
// JSONObject obj = new JSONObject();
// obj.put("serverIp", "192.168.1.11");
// obj.put("samCount", 100);
// obj.put("onlineCount",55);
// list.add(obj);
// JSONObject obj2 = new JSONObject();
// obj2.put("serverIp", "192.168.1.12");
// obj2.put("samCount", 100);
// obj2.put("onlineCount",55);
// list.add(obj2);
List
<
SamMonitor
>
records
=
operateManager
.
getSamMonitorList
();
return
ResResult
.
success
().
record
(
records
);
}
@GetMapping
(
"alarm/add"
)
public
void
addlog
(){
alarmService
.
addAlarm
(
"test"
);
}
}
license/src/main/java/iot/sixiang/license/entity/Alarm.java
0 → 100644
View file @
4a671a1b
package
iot
.
sixiang
.
license
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
public
class
Alarm
{
private
static
final
long
serialVersionUID
=
1L
;
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
private
String
content
;
}
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
View file @
4a671a1b
...
...
@@ -7,13 +7,14 @@ import iot.sixiang.license.model.ResResult;
import
lombok.extern.slf4j.Slf4j
;
import
javax.servlet.*
;
import
javax.servlet.annotation.WebFilter
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.Map
;
@Slf4j
//
@WebFilter(filterName = "jwtFilter", urlPatterns = "/iot_license/*")
@WebFilter
(
filterName
=
"jwtFilter"
,
urlPatterns
=
"/iot_license/*"
)
public
class
JwtFilter
implements
Filter
{
...
...
license/src/main/java/iot/sixiang/license/mapper/AlarmMapper.java
0 → 100644
View file @
4a671a1b
package
iot
.
sixiang
.
license
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
iot.sixiang.license.entity.Alarm
;
import
iot.sixiang.license.entity.Apply
;
import
iot.sixiang.license.model.vo.AppVo
;
import
java.util.List
;
/**
* Title: AlarmMapper
* Description: TODO
*
* @author m33
* @version V1.0
* @date 2022-06-09
*/
public
interface
AlarmMapper
extends
BaseMapper
<
Alarm
>
{
boolean
addAlarm
(
String
content
);
// List<Alarm> getAlarmList(String id);
//
// Apply getApplyByAppName(String id);
}
license/src/main/java/iot/sixiang/license/operate/OperateClientHandler.java
View file @
4a671a1b
...
...
@@ -34,7 +34,9 @@ public class OperateClientHandler extends SimpleChannelInboundHandler<Object> {
SocketChannel
channel
=
(
SocketChannel
)
ctx
.
channel
();
InetSocketAddress
socketAddr
=
(
InetSocketAddress
)
ctx
.
channel
().
remoteAddress
();
String
remoteIp
=
socketAddr
.
getHostString
();
DeviceProtocol
protocol
=
(
DeviceProtocol
)
msg
;
OperateSAMStatusEvent
event
=
new
OperateSAMStatusEvent
();
event
.
setProtocol
(
protocol
);
event
.
setIp
(
remoteIp
);
...
...
license/src/main/java/iot/sixiang/license/operate/OperateConnectionListener.java
View file @
4a671a1b
...
...
@@ -26,11 +26,11 @@ public class OperateConnectionListener extends BaseConnectionListener {
short
stx
=
21930
;
int
len
=
2
;
//
byte cmd = 0x5f;
byte
cmd
=
0x5b
;
byte
cmd
=
0x5f
;
//
byte cmd = 0x5b;
byte
ack
=
0x00
;
//
byte end = 0x5f;
byte
end
=
0x5b
;
byte
end
=
0x5f
;
//
byte end = 0x5b;
SocketChannel
channel
=
(
SocketChannel
)
channelFuture
.
channel
();
DeviceProtocol
protocol
=
new
DeviceProtocol
(
stx
,
len
,
cmd
,
ack
,
null
,
end
);
...
...
license/src/main/java/iot/sixiang/license/operate/OperateDecoder.java
View file @
4a671a1b
...
...
@@ -31,15 +31,15 @@ public class OperateDecoder extends ByteToMessageDecoder {
short
stx
=
buffer
.
readShort
();
//55AA->21930
short
len
=
buffer
.
readShortLE
();
log
.
debug
(
"msg rece len:"
+
packet
.
length
+
",decode len:"
+
len
);
len
=
2677
;
byte
cmd
=
buffer
.
readByte
();
byte
ack
=
buffer
.
readByte
();
////stx:21930,len:52,cmd:-112,ack:0
log
.
debug
(
"stx:"
+
stx
+
",len:"
+
len
);
int
real_len
=
len
;
//注意,透传前已经去掉了END一个字符
int
real_len
=
len
;
int
cmd_ack_len
=
2
;
if
(
buffer
.
readableBytes
()
<
real_len
-
cmd_ack_len
+
1
)
{
...
...
license/src/main/java/iot/sixiang/license/operate/OperateManager.java
View file @
4a671a1b
...
...
@@ -2,16 +2,14 @@ package iot.sixiang.license.operate;
import
iot.sixiang.license.entity.Server
;
import
iot.sixiang.license.model.SamMonitor
;
import
iot.sixiang.license.model.vo.DeviceVo
;
import
iot.sixiang.license.service.ServerService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
@Component
@Slf4j
...
...
@@ -33,6 +31,14 @@ public class OperateManager {
samMonitorMap
.
put
(
serverIp
,
samMonitor
);
}
public
List
<
SamMonitor
>
getSamMonitorList
()
{
List
<
SamMonitor
>
result
=
new
ArrayList
<>();
if
(
samMonitorMap
.
size
()
>
0
)
{
samMonitorMap
.
entrySet
().
stream
().
sorted
(
Map
.
Entry
.<
String
,
SamMonitor
>
comparingByKey
()).
forEachOrdered
(
x
->
result
.
add
(
x
.
getValue
()));
}
return
result
;
}
@PostConstruct
public
void
init
()
{
List
<
Server
>
servers
=
serverService
.
getServerList
(
0
,
20
);
...
...
@@ -55,6 +61,7 @@ public class OperateManager {
// for(int i =0;i<5;i++){
String
serverIp
=
server
.
getServerIp
();
Integer
port
=
server
.
getPort
();
serverIp
=
"192.168.1.56"
;
// serverIp = "172.17.115.81";
// port = 777;
this
.
startTcpClient
(
serverIp
,
port
);
...
...
license/src/main/java/iot/sixiang/license/service/AlarmService.java
0 → 100644
View file @
4a671a1b
package
iot
.
sixiang
.
license
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
iot.sixiang.license.entity.Alarm
;
import
iot.sixiang.license.entity.Apply
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.vo.AppVo
;
/**
* Title: AlarmService
* Description: TODO
*
* @author m33
* @version V1.0
* @date 2022-06-09
*/
public
interface
AlarmService
extends
IService
<
Alarm
>
{
boolean
addAlarm
(
String
content
);
// PageInfoModel<AppVo> getAppList(int pageNo, int pageSize, String appName);
}
license/src/main/java/iot/sixiang/license/service/impl/AlarmServiceImpl.java
0 → 100644
View file @
4a671a1b
package
iot
.
sixiang
.
license
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
iot.sixiang.license.entity.Alarm
;
import
iot.sixiang.license.entity.Apply
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.mapper.AlarmMapper
;
import
iot.sixiang.license.mapper.ApplyMapper
;
import
iot.sixiang.license.service.AlarmService
;
import
iot.sixiang.license.service.ApplyService
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
@Service
public
class
AlarmServiceImpl
extends
ServiceImpl
<
AlarmMapper
,
Alarm
>
implements
AlarmService
{
@Resource
AlarmMapper
alarmMapper
;
@Override
public
boolean
addAlarm
(
String
content
)
{
return
alarmMapper
.
addAlarm
(
content
);
}
}
license/src/main/resources/mapper/AlarmMapper.xml
0 → 100644
View file @
4a671a1b
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"iot.sixiang.license.mapper.AlarmMapper"
>
<insert
id=
"addAlarm"
parameterType=
"iot.sixiang.license.entity.Alarm"
>
insert into alarm(content) values (#{content})
</insert>
</mapper>
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