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
1f2285d5
Commit
1f2285d5
authored
Jun 10, 2022
by
zengtianlai3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
监控连接数
parent
b0fcf3a4
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
103 additions
and
17 deletions
+103
-17
MonitorController.java
...ava/iot/sixiang/license/controller/MonitorController.java
+3
-9
ForwardConnectionListener.java
...ot/sixiang/license/forward/ForwardConnectionListener.java
+4
-1
JwtFilter.java
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
+2
-1
OperateManager.java
...main/java/iot/sixiang/license/operate/OperateManager.java
+13
-0
MonitorService.java
...main/java/iot/sixiang/license/service/MonitorService.java
+2
-1
MonitorServiceImpl.java
.../iot/sixiang/license/service/impl/MonitorServiceImpl.java
+71
-3
OperateSchedu.java
...src/main/java/iot/sixiang/license/util/OperateSchedu.java
+8
-2
No files found.
license/src/main/java/iot/sixiang/license/controller/MonitorController.java
View file @
1f2285d5
...
@@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -31,15 +32,8 @@ public class MonitorController {
...
@@ -31,15 +32,8 @@ public class MonitorController {
@GetMapping
(
"list"
)
@GetMapping
(
"list"
)
public
ResResult
getMonitorList
(
@RequestParam
(
"type"
)
int
type
)
{
public
ResResult
getMonitorList
(
@RequestParam
(
"type"
)
int
type
)
{
LocalDate
localDate
=
LocalDate
.
now
();
LocalDate
endDate
=
LocalDate
.
now
();
HashMap
<
String
,
List
<
Integer
>>
monitorList
=
monitorService
.
getMonitorList
(
type
);
switch
(
type
)
{
case
0
:
localDate
=
LocalDate
.
now
();
break
;
case
1
:
localDate
=
localDate
.
plusDays
(-
1
);
break
;
case
2
:
localDate
=
localDate
.
plusDays
(-
6
);
break
;
case
3
:
localDate
=
localDate
.
plusDays
(-
29
);
break
;
}
List
<
Monitor
>
monitorList
=
monitorService
.
getMonitorList
(
localDate
,
endDate
);
return
ResResult
.
success
().
record
(
monitorList
);
return
ResResult
.
success
().
record
(
monitorList
);
}
}
...
...
license/src/main/java/iot/sixiang/license/forward/ForwardConnectionListener.java
View file @
1f2285d5
...
@@ -8,6 +8,7 @@ import iot.sixiang.license.event.DeviceClientLicenseEvent;
...
@@ -8,6 +8,7 @@ import iot.sixiang.license.event.DeviceClientLicenseEvent;
import
iot.sixiang.license.event.EventPublisher
;
import
iot.sixiang.license.event.EventPublisher
;
import
iot.sixiang.license.event.ForwardClientConnectEvent
;
import
iot.sixiang.license.event.ForwardClientConnectEvent
;
import
iot.sixiang.license.net.BaseConnectionListener
;
import
iot.sixiang.license.net.BaseConnectionListener
;
import
iot.sixiang.license.operate.OperateManager
;
import
iot.sixiang.license.service.AlarmService
;
import
iot.sixiang.license.service.AlarmService
;
import
iot.sixiang.license.util.SpringUtil
;
import
iot.sixiang.license.util.SpringUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -20,6 +21,8 @@ public class ForwardConnectionListener extends BaseConnectionListener {
...
@@ -20,6 +21,8 @@ public class ForwardConnectionListener extends BaseConnectionListener {
@Autowired
@Autowired
private
AlarmService
alarmService
;
private
AlarmService
alarmService
;
@Autowired
private
OperateManager
operateManager
;
@Override
@Override
public
void
operationComplete
(
ChannelFuture
channelFuture
)
throws
Exception
{
public
void
operationComplete
(
ChannelFuture
channelFuture
)
throws
Exception
{
...
@@ -39,7 +42,7 @@ public class ForwardConnectionListener extends BaseConnectionListener {
...
@@ -39,7 +42,7 @@ public class ForwardConnectionListener extends BaseConnectionListener {
EventPublisher
eventPublisher
=
SpringUtil
.
getBean
(
EventPublisher
.
class
);
EventPublisher
eventPublisher
=
SpringUtil
.
getBean
(
EventPublisher
.
class
);
eventPublisher
.
publishEvent
(
deviceClientBeForcedOfflineEvent
);
eventPublisher
.
publishEvent
(
deviceClientBeForcedOfflineEvent
);
}
else
{
}
else
{
operateManager
.
autoIncrement
();
SocketChannel
channel
=
(
SocketChannel
)
channelFuture
.
channel
();
SocketChannel
channel
=
(
SocketChannel
)
channelFuture
.
channel
();
String
channelId
=
channel
.
id
().
asLongText
();
String
channelId
=
channel
.
id
().
asLongText
();
...
...
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
View file @
1f2285d5
...
@@ -7,13 +7,14 @@ import iot.sixiang.license.model.ResResult;
...
@@ -7,13 +7,14 @@ import iot.sixiang.license.model.ResResult;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
javax.servlet.*
;
import
javax.servlet.*
;
import
javax.servlet.annotation.WebFilter
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Map
;
import
java.util.Map
;
@Slf4j
@Slf4j
//
@WebFilter(filterName = "jwtFilter", urlPatterns = "/iot_license/*")
@WebFilter
(
filterName
=
"jwtFilter"
,
urlPatterns
=
"/iot_license/*"
)
public
class
JwtFilter
implements
Filter
{
public
class
JwtFilter
implements
Filter
{
...
...
license/src/main/java/iot/sixiang/license/operate/OperateManager.java
View file @
1f2285d5
...
@@ -20,6 +20,7 @@ public class OperateManager {
...
@@ -20,6 +20,7 @@ public class OperateManager {
private
Map
<
String
,
Server
>
allServers
=
null
;
private
Map
<
String
,
Server
>
allServers
=
null
;
private
Map
<
String
,
SamMonitor
>
samMonitorMap
=
null
;
private
Map
<
String
,
SamMonitor
>
samMonitorMap
=
null
;
private
int
count
=
0
;
public
OperateManager
()
{
public
OperateManager
()
{
allServers
=
new
HashMap
<
String
,
Server
>();
allServers
=
new
HashMap
<
String
,
Server
>();
...
@@ -42,6 +43,18 @@ public class OperateManager {
...
@@ -42,6 +43,18 @@ public class OperateManager {
return
result
;
return
result
;
}
}
public
int
getCount
(){
return
this
.
count
;
}
public
synchronized
void
clearCount
()
{
this
.
count
=
0
;
}
public
synchronized
void
autoIncrement
()
{
this
.
count
++;
}
@PostConstruct
@PostConstruct
public
void
init
()
{
public
void
init
()
{
List
<
Server
>
servers
=
serverService
.
getServerList
(
0
,
20
);
List
<
Server
>
servers
=
serverService
.
getServerList
(
0
,
20
);
...
...
license/src/main/java/iot/sixiang/license/service/MonitorService.java
View file @
1f2285d5
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import
iot.sixiang.license.entity.Monitor
;
import
iot.sixiang.license.entity.Monitor
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -18,5 +19,5 @@ public interface MonitorService extends IService<Monitor> {
...
@@ -18,5 +19,5 @@ public interface MonitorService extends IService<Monitor> {
boolean
addMonitor
(
int
count
);
boolean
addMonitor
(
int
count
);
List
<
Monitor
>
getMonitorList
(
LocalDate
localDate
,
LocalDate
endDat
e
);
HashMap
<
String
,
List
<
Integer
>>
getMonitorList
(
int
typ
e
);
}
}
license/src/main/java/iot/sixiang/license/service/impl/MonitorServiceImpl.java
View file @
1f2285d5
...
@@ -9,6 +9,8 @@ import org.springframework.stereotype.Service;
...
@@ -9,6 +9,8 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.time.LocalTime
;
import
java.time.LocalTime
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -34,7 +36,73 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
...
@@ -34,7 +36,73 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
}
}
@Override
@Override
public
List
<
Monitor
>
getMonitorList
(
LocalDate
localDate
,
LocalDate
endDate
)
{
public
HashMap
<
String
,
List
<
Integer
>>
getMonitorList
(
int
type
)
{
return
monitorMapper
.
getMonitorList
(
localDate
,
endDate
);
LocalDate
localDate
=
LocalDate
.
now
();
LocalDate
endDate
=
LocalDate
.
now
();
switch
(
type
)
{
case
0
:
localDate
=
LocalDate
.
now
();
break
;
case
1
:
localDate
=
localDate
.
plusDays
(-
1
);
break
;
case
2
:
localDate
=
localDate
.
plusDays
(-
6
);
break
;
case
3
:
localDate
=
localDate
.
plusDays
(-
29
);
break
;
}
List
<
Monitor
>
monitorList
=
monitorMapper
.
getMonitorList
(
localDate
,
endDate
);
HashMap
<
Integer
,
List
<
Integer
>>
map
=
new
HashMap
<>();
List
<
Integer
>
listX
=
new
ArrayList
<>();
List
<
Integer
>
listY
=
new
ArrayList
<>();
if
(
type
==
0
||
type
==
1
)
{
for
(
int
i
=
0
;
i
<
24
;
i
++)
{
int
count
=
0
;
for
(
Monitor
monitor
:
monitorList
)
{
Integer
hour
=
monitor
.
getHour
();
if
(
i
==
hour
)
{
count
=
monitor
.
getCount
();
break
;
}
}
listX
.
add
(
i
);
listY
.
add
(
count
);
}
}
else
{
LocalDate
now
=
LocalDate
.
now
();
int
end
=
0
;
if
(
type
==
2
)
{
end
=
7
;
}
else
{
end
=
30
;
}
for
(
int
i
=
0
;
i
<
end
;
i
++)
{
LocalDate
target
=
now
.
plusDays
(-
i
);
int
count
=
0
;
for
(
Monitor
monitor
:
monitorList
)
{
LocalDate
tempDate
=
monitor
.
getDate
();
if
(
target
.
isEqual
(
tempDate
))
{
count
=
monitor
.
getCount
();
break
;
}
}
listX
.
add
(
i
);
listY
.
add
(
count
);
}
}
HashMap
<
String
,
List
<
Integer
>>
maps
=
new
HashMap
<>();
maps
.
put
(
"x"
,
listX
);
maps
.
put
(
"y"
,
listY
);
return
maps
;
}
}
}
}
license/src/main/java/iot/sixiang/license/util/OperateSchedu.java
View file @
1f2285d5
package
iot
.
sixiang
.
license
.
util
;
package
iot
.
sixiang
.
license
.
util
;
import
iot.sixiang.license.operate.OperateManager
;
import
iot.sixiang.license.operate.OperateManager
;
import
iot.sixiang.license.service.MonitorService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -13,9 +14,14 @@ public class OperateSchedu {
...
@@ -13,9 +14,14 @@ public class OperateSchedu {
@Autowired
@Autowired
private
OperateManager
operateManager
;
private
OperateManager
operateManager
;
@Autowired
private
MonitorService
monitorService
;
@Scheduled
(
cron
=
"0 0 0/1 * * ?"
)
@Scheduled
(
cron
=
"0 0 0/1 * * ?"
)
public
void
scheduled
(){
public
void
scheduled
()
{
operateManager
.
createProxyClient
();
operateManager
.
createProxyClient
();
int
count
=
operateManager
.
getCount
();
monitorService
.
addMonitor
(
count
);
operateManager
.
clearCount
();
}
}
}
}
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