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
42f05db9
Commit
42f05db9
authored
Jun 10, 2022
by
zengtianlai3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minitor接口开发
parent
04bffc10
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
198 additions
and
8 deletions
+198
-8
MonitorController.java
...ava/iot/sixiang/license/controller/MonitorController.java
+47
-0
Monitor.java
...nse/src/main/java/iot/sixiang/license/entity/Monitor.java
+49
-0
ForwardConnectionListener.java
...ot/sixiang/license/forward/ForwardConnectionListener.java
+3
-4
JwtFilter.java
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
+1
-2
MonitorMapper.java
...c/main/java/iot/sixiang/license/mapper/MonitorMapper.java
+22
-0
MonitorService.java
...main/java/iot/sixiang/license/service/MonitorService.java
+22
-0
MonitorServiceImpl.java
.../iot/sixiang/license/service/impl/MonitorServiceImpl.java
+40
-0
CodeGenerator.java
...src/main/java/iot/sixiang/license/util/CodeGenerator.java
+1
-1
application.yml
license/src/main/resources/application.yml
+1
-1
MonitorMapper.xml
license/src/main/resources/mapper/MonitorMapper.xml
+12
-0
No files found.
license/src/main/java/iot/sixiang/license/controller/MonitorController.java
0 → 100644
View file @
42f05db9
package
iot
.
sixiang
.
license
.
controller
;
import
iot.sixiang.license.entity.Monitor
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.service.MonitorService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.time.LocalDate
;
import
java.util.List
;
/**
* <p>
* 前端控制器
* </p>
*
* @author m33
* @since 2022-06-10
*/
@RestController
@RequestMapping
(
"/iot_license/monitor"
)
public
class
MonitorController
{
@Autowired
private
MonitorService
monitorService
;
@PostMapping
(
"add"
)
public
boolean
addMonitor
(){
return
monitorService
.
addMonitor
(
20
);
}
@GetMapping
(
"list"
)
public
ResResult
getMonitorList
(
@RequestParam
(
"type"
)
int
type
)
{
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
=
monitorService
.
getMonitorList
(
localDate
,
endDate
);
return
ResResult
.
success
().
record
(
monitorList
);
}
}
license/src/main/java/iot/sixiang/license/entity/Monitor.java
0 → 100644
View file @
42f05db9
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
;
import
java.io.Serializable
;
import
java.time.LocalDate
;
/**
* <p>
*
* </p>
*
* @author m33
* @since 2022-06-10
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
public
class
Monitor
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 主键id
*/
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Integer
id
;
/**
* 年月日
*/
private
LocalDate
date
;
/**
* 时
*/
private
Integer
hour
;
/**
* 在线数量
*/
private
Integer
count
;
}
license/src/main/java/iot/sixiang/license/forward/ForwardConnectionListener.java
View file @
42f05db9
...
@@ -20,18 +20,17 @@ public class ForwardConnectionListener extends BaseConnectionListener {
...
@@ -20,18 +20,17 @@ public class ForwardConnectionListener extends BaseConnectionListener {
@Autowired
@Autowired
private
AlarmService
alarmService
;
private
AlarmService
alarmService
;
@Override
@Override
public
void
operationComplete
(
ChannelFuture
channelFuture
)
throws
Exception
{
public
void
operationComplete
(
ChannelFuture
channelFuture
)
throws
Exception
{
if
(!
channelFuture
.
isSuccess
())
{
if
(!
channelFuture
.
isSuccess
())
{
//TODO
中转
失败进行告警
//TODO 失败进行告警
InetSocketAddress
socketAddress
=
(
InetSocketAddress
)
channelFuture
.
channel
().
remoteAddress
();
InetSocketAddress
socketAddress
=
(
InetSocketAddress
)
channelFuture
.
channel
().
remoteAddress
();
String
remoteIp
=
socketAddress
.
getHostString
();
String
remoteIp
=
socketAddress
.
getHostString
();
String
remotePort
=
String
.
valueOf
(
socketAddress
.
getPort
());
String
remotePort
=
String
.
valueOf
(
socketAddress
.
getPort
());
int
typeId
=
1
;
int
typeId
=
1
;
String
title
=
"
中转
失败"
;
String
title
=
"
连接服器
失败"
;
String
content
=
"
中转到
服务器:"
+
remoteIp
+
":"
+
remotePort
+
"失败"
;
String
content
=
"
连接
服务器:"
+
remoteIp
+
":"
+
remotePort
+
"失败"
;
alarmService
.
addAlarm
(
typeId
,
title
,
content
);
alarmService
.
addAlarm
(
typeId
,
title
,
content
);
//TODO forward client连接失败,则强制踢掉设备客户端
//TODO forward client连接失败,则强制踢掉设备客户端
...
...
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
View file @
42f05db9
...
@@ -7,14 +7,13 @@ import iot.sixiang.license.model.ResResult;
...
@@ -7,14 +7,13 @@ 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/mapper/MonitorMapper.java
0 → 100644
View file @
42f05db9
package
iot
.
sixiang
.
license
.
mapper
;
import
iot.sixiang.license.entity.Monitor
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
java.time.LocalDate
;
import
java.util.List
;
/**
* <p>
* Mapper 接口
* </p>
*
* @author m33
* @since 2022-06-10
*/
public
interface
MonitorMapper
extends
BaseMapper
<
Monitor
>
{
boolean
addMonitor
(
LocalDate
date
,
int
hour
,
int
count
);
List
<
Monitor
>
getMonitorList
(
LocalDate
localDate
,
LocalDate
endDate
);
}
license/src/main/java/iot/sixiang/license/service/MonitorService.java
0 → 100644
View file @
42f05db9
package
iot
.
sixiang
.
license
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
iot.sixiang.license.entity.Monitor
;
import
java.time.LocalDate
;
import
java.util.List
;
/**
* <p>
* 服务类
* </p>
*
* @author m33
* @since 2022-06-10
*/
public
interface
MonitorService
extends
IService
<
Monitor
>
{
boolean
addMonitor
(
int
count
);
List
<
Monitor
>
getMonitorList
(
LocalDate
localDate
,
LocalDate
endDate
);
}
license/src/main/java/iot/sixiang/license/service/impl/MonitorServiceImpl.java
0 → 100644
View file @
42f05db9
package
iot
.
sixiang
.
license
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
iot.sixiang.license.entity.Monitor
;
import
iot.sixiang.license.mapper.MonitorMapper
;
import
iot.sixiang.license.service.MonitorService
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.time.LocalDate
;
import
java.time.LocalTime
;
import
java.util.List
;
/**
* <p>
* 服务实现类
* </p>
*
* @author m33
* @since 2022-06-10
*/
@Service
public
class
MonitorServiceImpl
extends
ServiceImpl
<
MonitorMapper
,
Monitor
>
implements
MonitorService
{
@Resource
MonitorMapper
monitorMapper
;
@Override
public
boolean
addMonitor
(
int
count
)
{
LocalDate
date
=
LocalDate
.
now
();
LocalTime
localTime
=
LocalTime
.
now
();
int
hour
=
localTime
.
getHour
();
return
monitorMapper
.
addMonitor
(
date
,
hour
,
count
);
}
@Override
public
List
<
Monitor
>
getMonitorList
(
LocalDate
localDate
,
LocalDate
endDate
)
{
return
monitorMapper
.
getMonitorList
(
localDate
,
endDate
);
}
}
license/src/main/java/iot/sixiang/license/util/CodeGenerator.java
View file @
42f05db9
...
@@ -47,7 +47,7 @@ public class CodeGenerator {
...
@@ -47,7 +47,7 @@ public class CodeGenerator {
// 5、策略配置
// 5、策略配置
StrategyConfig
strategy
=
new
StrategyConfig
();
StrategyConfig
strategy
=
new
StrategyConfig
();
strategy
.
setInclude
(
"
alarm_type
"
);
strategy
.
setInclude
(
"
monitor
"
);
strategy
.
setNaming
(
NamingStrategy
.
underline_to_camel
);
//数据库表映射到实体的命名策略
strategy
.
setNaming
(
NamingStrategy
.
underline_to_camel
);
//数据库表映射到实体的命名策略
strategy
.
setTablePrefix
(
pc
.
getModuleName
()
+
"_"
);
//生成实体时去掉表前缀
strategy
.
setTablePrefix
(
pc
.
getModuleName
()
+
"_"
);
//生成实体时去掉表前缀
...
...
license/src/main/resources/application.yml
View file @
42f05db9
spring
:
spring
:
profiles
:
profiles
:
active
:
test
active
:
dev
application
:
application
:
name
:
iot_license
#当前服务的名称
name
:
iot_license
#当前服务的名称
\ No newline at end of file
license/src/main/resources/mapper/MonitorMapper.xml
0 → 100644
View file @
42f05db9
<?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.MonitorMapper"
>
<insert
id=
"addMonitor"
parameterType=
"iot.sixiang.license.entity.Monitor"
>
insert into monitor (date, hour, count) values (#{date},#{hour},#{count});
</insert>
<select
id=
"getMonitorList"
resultType=
"iot.sixiang.license.entity.Monitor"
>
select id, date, hour, count from monitor where date between #{localDate} and #{endDate}
</select>
</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