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
29426039
Commit
29426039
authored
Jun 30, 2022
by
zengtianlai3
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'm33' into 'master'
M33 See merge request
!39
parents
fd93efa6
533bed29
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
127 additions
and
170 deletions
+127
-170
CorsConfig.java
.../src/main/java/iot/sixiang/license/config/CorsConfig.java
+1
-0
DeviceDecoder.java
...c/main/java/iot/sixiang/license/device/DeviceDecoder.java
+21
-27
DeviceEncoder.java
...c/main/java/iot/sixiang/license/device/DeviceEncoder.java
+7
-12
DeviceServerHandler.java
.../java/iot/sixiang/license/device/DeviceServerHandler.java
+1
-1
ForwardClientHandler.java
...ava/iot/sixiang/license/forward/ForwardClientHandler.java
+1
-1
ForwardDecoder.java
...main/java/iot/sixiang/license/forward/ForwardDecoder.java
+24
-30
ForwardEncoder.java
...main/java/iot/sixiang/license/forward/ForwardEncoder.java
+7
-12
JwtUtil.java
license/src/main/java/iot/sixiang/license/jwt/JwtUtil.java
+10
-16
LogAspect.java
license/src/main/java/iot/sixiang/license/log/LogAspect.java
+20
-24
BaseChannelInitializer.java
.../java/iot/sixiang/license/net/BaseChannelInitializer.java
+1
-1
BaseConnectionListener.java
.../java/iot/sixiang/license/net/BaseConnectionListener.java
+1
-1
OperateDecoder.java
...main/java/iot/sixiang/license/operate/OperateDecoder.java
+20
-27
OperateEncoder.java
...main/java/iot/sixiang/license/operate/OperateEncoder.java
+7
-13
MonitorServiceImpl.java
.../iot/sixiang/license/service/impl/MonitorServiceImpl.java
+2
-0
CommonUtil.java
...se/src/main/java/iot/sixiang/license/util/CommonUtil.java
+4
-5
No files found.
license/src/main/java/iot/sixiang/license/config/CorsConfig.java
View file @
29426039
...
@@ -24,6 +24,7 @@ public class CorsConfig implements WebMvcConfigurer {
...
@@ -24,6 +24,7 @@ public class CorsConfig implements WebMvcConfigurer {
@Override
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
System
.
out
.
println
(
"重写了addResourceHandlers方法"
);
}
}
@Override
@Override
...
...
license/src/main/java/iot/sixiang/license/device/DeviceDecoder.java
View file @
29426039
...
@@ -22,7 +22,6 @@ public class DeviceDecoder extends ByteToMessageDecoder {
...
@@ -22,7 +22,6 @@ public class DeviceDecoder extends ByteToMessageDecoder {
buffer
.
readBytes
(
packet
);
buffer
.
readBytes
(
packet
);
buffer
.
resetReaderIndex
();
buffer
.
resetReaderIndex
();
Util
.
DEBUG_HEX
(
"SERVER -> IN"
,
packet
,
packet
.
length
);
Util
.
DEBUG_HEX
(
"SERVER -> IN"
,
packet
,
packet
.
length
);
try
{
if
(
buffer
.
readableBytes
()
<
BASE_LENGTH
)
{
if
(
buffer
.
readableBytes
()
<
BASE_LENGTH
)
{
return
;
return
;
}
}
...
@@ -49,11 +48,6 @@ public class DeviceDecoder extends ByteToMessageDecoder {
...
@@ -49,11 +48,6 @@ public class DeviceDecoder extends ByteToMessageDecoder {
DeviceProtocol
protocol
=
new
DeviceProtocol
(
stx
,
len
,
cmd
,
ack
,
content
,
end
);
DeviceProtocol
protocol
=
new
DeviceProtocol
(
stx
,
len
,
cmd
,
ack
,
content
,
end
);
out
.
add
(
protocol
);
out
.
add
(
protocol
);
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
log
.
error
(
"DeviceDecoder error!"
);
}
}
}
}
}
\ No newline at end of file
license/src/main/java/iot/sixiang/license/device/DeviceEncoder.java
View file @
29426039
...
@@ -14,7 +14,6 @@ public class DeviceEncoder extends MessageToByteEncoder<DeviceProtocol> {
...
@@ -14,7 +14,6 @@ public class DeviceEncoder extends MessageToByteEncoder<DeviceProtocol> {
@Override
@Override
protected
void
encode
(
ChannelHandlerContext
tcx
,
DeviceProtocol
msg
,
ByteBuf
out
)
{
protected
void
encode
(
ChannelHandlerContext
tcx
,
DeviceProtocol
msg
,
ByteBuf
out
)
{
try
{
out
.
writeShort
(
msg
.
getStx
());
out
.
writeShort
(
msg
.
getStx
());
out
.
writeShortLE
(
msg
.
getLen
());
out
.
writeShortLE
(
msg
.
getLen
());
...
@@ -26,9 +25,5 @@ public class DeviceEncoder extends MessageToByteEncoder<DeviceProtocol> {
...
@@ -26,9 +25,5 @@ public class DeviceEncoder extends MessageToByteEncoder<DeviceProtocol> {
out
.
writeBytes
(
msg
.
getContent
());
out
.
writeBytes
(
msg
.
getContent
());
}
}
out
.
writeByte
(
msg
.
getEnd
());
out
.
writeByte
(
msg
.
getEnd
());
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
log
.
error
(
"解码器异常"
);
}
}
}
}
}
license/src/main/java/iot/sixiang/license/device/DeviceServerHandler.java
View file @
29426039
...
@@ -38,7 +38,7 @@ public class DeviceServerHandler extends SimpleChannelInboundHandler<Object> {
...
@@ -38,7 +38,7 @@ public class DeviceServerHandler extends SimpleChannelInboundHandler<Object> {
}
}
@Override
@Override
protected
void
channelRead0
(
ChannelHandlerContext
ctx
,
Object
msg
)
throws
Exception
{
protected
void
channelRead0
(
ChannelHandlerContext
ctx
,
Object
msg
)
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
...
...
license/src/main/java/iot/sixiang/license/forward/ForwardClientHandler.java
View file @
29426039
...
@@ -28,7 +28,7 @@ public class ForwardClientHandler extends SimpleChannelInboundHandler<Object> {
...
@@ -28,7 +28,7 @@ public class ForwardClientHandler extends SimpleChannelInboundHandler<Object> {
}
}
@Override
@Override
protected
void
channelRead0
(
ChannelHandlerContext
ctx
,
Object
msg
)
throws
Exception
{
protected
void
channelRead0
(
ChannelHandlerContext
ctx
,
Object
msg
){
// TODO Auto-generated method stub
// TODO Auto-generated method stub
// TODO 中转客户端收到消息后,将消息原封不动的发送给设备客户端
// TODO 中转客户端收到消息后,将消息原封不动的发送给设备客户端
...
...
license/src/main/java/iot/sixiang/license/forward/ForwardDecoder.java
View file @
29426039
...
@@ -17,7 +17,6 @@ public class ForwardDecoder extends ByteToMessageDecoder {
...
@@ -17,7 +17,6 @@ public class ForwardDecoder extends ByteToMessageDecoder {
@Override
@Override
protected
void
decode
(
ChannelHandlerContext
ctx
,
ByteBuf
buffer
,
List
<
Object
>
out
)
{
protected
void
decode
(
ChannelHandlerContext
ctx
,
ByteBuf
buffer
,
List
<
Object
>
out
)
{
// 可读长度必须大于等于基本长度
// 可读长度必须大于等于基本长度
try
{
byte
[]
packet
=
new
byte
[
buffer
.
readableBytes
()];
byte
[]
packet
=
new
byte
[
buffer
.
readableBytes
()];
buffer
.
readBytes
(
packet
);
buffer
.
readBytes
(
packet
);
buffer
.
resetReaderIndex
();
buffer
.
resetReaderIndex
();
...
@@ -55,11 +54,6 @@ public class ForwardDecoder extends ByteToMessageDecoder {
...
@@ -55,11 +54,6 @@ public class ForwardDecoder extends ByteToMessageDecoder {
DeviceProtocol
protocol
=
new
DeviceProtocol
(
stx
,
real_len
,
cmd
,
ack
,
content
,
end
);
DeviceProtocol
protocol
=
new
DeviceProtocol
(
stx
,
real_len
,
cmd
,
ack
,
content
,
end
);
out
.
add
(
protocol
);
out
.
add
(
protocol
);
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
log
.
error
(
"Decoder error"
);
}
}
}
...
...
license/src/main/java/iot/sixiang/license/forward/ForwardEncoder.java
View file @
29426039
...
@@ -11,7 +11,6 @@ public class ForwardEncoder extends MessageToByteEncoder<DeviceProtocol> {
...
@@ -11,7 +11,6 @@ public class ForwardEncoder extends MessageToByteEncoder<DeviceProtocol> {
@Override
@Override
protected
void
encode
(
ChannelHandlerContext
tcx
,
DeviceProtocol
msg
,
ByteBuf
out
)
{
protected
void
encode
(
ChannelHandlerContext
tcx
,
DeviceProtocol
msg
,
ByteBuf
out
)
{
try
{
out
.
writeShort
(
msg
.
getStx
());
out
.
writeShort
(
msg
.
getStx
());
out
.
writeShortLE
(
msg
.
getLen
());
out
.
writeShortLE
(
msg
.
getLen
());
...
@@ -22,9 +21,5 @@ public class ForwardEncoder extends MessageToByteEncoder<DeviceProtocol> {
...
@@ -22,9 +21,5 @@ public class ForwardEncoder extends MessageToByteEncoder<DeviceProtocol> {
out
.
writeBytes
(
msg
.
getContent
());
out
.
writeBytes
(
msg
.
getContent
());
}
}
out
.
writeByte
(
msg
.
getEnd
());
out
.
writeByte
(
msg
.
getEnd
());
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
log
.
error
(
"解码器异常"
);
}
}
}
}
}
license/src/main/java/iot/sixiang/license/jwt/JwtUtil.java
View file @
29426039
...
@@ -22,22 +22,23 @@ public class JwtUtil {
...
@@ -22,22 +22,23 @@ public class JwtUtil {
**/
**/
private
static
final
long
EXPIRATION
=
3600L
;
//单位为秒
private
static
final
long
EXPIRATION
=
3600L
;
//单位为秒
private
static
HashMap
<
String
,
String
>
tokens
=
new
HashMap
<>();
private
static
HashMap
<
String
,
String
>
tokens
=
new
HashMap
<>();
/**
/**
* 生成用户token,设置token超时时间
* 生成用户token,设置token超时时间
*/
*/
public
static
String
createToken
(
LoginUser
user
)
{
public
static
String
createToken
(
LoginUser
user
)
{
//过期时间
//过期时间
Date
expireDate
=
new
Date
(
System
.
currentTimeMillis
()
+
EXPIRATION
*
1000
);
Date
expireDate
=
new
Date
(
System
.
currentTimeMillis
()
+
EXPIRATION
*
1000
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"alg"
,
"HS256"
);
map
.
put
(
"alg"
,
"HS256"
);
map
.
put
(
"typ"
,
"JWT"
);
map
.
put
(
"typ"
,
"JWT"
);
String
token
=
JWT
.
create
()
String
token
=
JWT
.
create
()
.
withHeader
(
map
)
//添加头部
.
withHeader
(
map
)
//添加头部
//可以把数据存在claim中
//可以把数据存在claim中
.
withClaim
(
"userId"
,
user
.
getUserId
())
.
withClaim
(
"userId"
,
user
.
getUserId
())
.
withClaim
(
"userName"
,
user
.
getUserName
())
.
withClaim
(
"userName"
,
user
.
getUserName
())
.
withClaim
(
"password"
,
user
.
getPassword
())
.
withClaim
(
"password"
,
user
.
getPassword
())
.
withExpiresAt
(
expireDate
)
//超时设置,设置过期的日期
.
withExpiresAt
(
expireDate
)
//超时设置,设置过期的日期
.
withIssuedAt
(
new
Date
())
//签发时间
.
withIssuedAt
(
new
Date
())
//签发时间
.
sign
(
Algorithm
.
HMAC256
(
SECRET
));
//SECRET加密
.
sign
(
Algorithm
.
HMAC256
(
SECRET
));
//SECRET加密
...
@@ -63,16 +64,9 @@ public class JwtUtil {
...
@@ -63,16 +64,9 @@ public class JwtUtil {
/**
/**
* 检验token并解析token
* 检验token并解析token
*/
*/
public
static
DecodedJWT
verifyToken
(
String
token
){
public
static
DecodedJWT
verifyToken
(
String
token
)
{
DecodedJWT
jwt
=
null
;
JWTVerifier
verifier
=
JWT
.
require
(
Algorithm
.
HMAC256
(
SECRET
)).
build
();
try
{
DecodedJWT
jwt
=
verifier
.
verify
(
token
);
JWTVerifier
verifier
=
JWT
.
require
(
Algorithm
.
HMAC256
(
SECRET
)).
build
();
jwt
=
verifier
.
verify
(
token
);
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
());
log
.
error
(
"解析编码异常"
);
}
return
jwt
;
return
jwt
;
}
}
}
}
license/src/main/java/iot/sixiang/license/log/LogAspect.java
View file @
29426039
...
@@ -30,9 +30,9 @@ public class LogAspect {
...
@@ -30,9 +30,9 @@ public class LogAspect {
@Autowired
@Autowired
private
SysOperLogService
sysOperLogService
;
private
SysOperLogService
sysOperLogService
;
// 配置织入点
@Pointcut
(
"@annotation(iot.sixiang.license.log.MyLog)"
)
@Pointcut
(
"@annotation(iot.sixiang.license.log.MyLog)"
)
public
void
logPointCut
()
{
public
void
logPointCut
()
{
log
.
info
(
"------>配置织入点"
);
}
}
/**
/**
...
@@ -57,7 +57,7 @@ public class LogAspect {
...
@@ -57,7 +57,7 @@ public class LogAspect {
}
}
protected
void
handleLog
(
final
JoinPoint
joinPoint
,
final
Exception
e
,
Object
jsonResult
)
{
protected
void
handleLog
(
final
JoinPoint
joinPoint
,
final
Exception
e
,
Object
jsonResult
)
{
try
{
// 获得注解
// 获得注解
MyLog
controllerLog
=
getAnnotationLog
(
joinPoint
);
MyLog
controllerLog
=
getAnnotationLog
(
joinPoint
);
if
(
controllerLog
==
null
)
{
if
(
controllerLog
==
null
)
{
...
@@ -79,10 +79,6 @@ public class LogAspect {
...
@@ -79,10 +79,6 @@ public class LogAspect {
getControllerMethodDescription
(
joinPoint
,
controllerLog
,
operLog
);
getControllerMethodDescription
(
joinPoint
,
controllerLog
,
operLog
);
// 保存数据库
// 保存数据库
sysOperLogService
.
addOperlog
(
operLog
.
getTitle
(),
operLog
.
getBusinessType
(),
operLog
.
getUri
(),
operLog
.
getStatus
(),
operLog
.
getOptParam
(),
operLog
.
getErrorMsg
(),
operLog
.
getOperTime
());
sysOperLogService
.
addOperlog
(
operLog
.
getTitle
(),
operLog
.
getBusinessType
(),
operLog
.
getUri
(),
operLog
.
getStatus
(),
operLog
.
getOptParam
(),
operLog
.
getErrorMsg
(),
operLog
.
getOperTime
());
}
catch
(
Exception
exp
)
{
log
.
error
(
"==前置通知异常=="
);
log
.
error
(
"日志异常信息 {}"
,
exp
);
}
}
}
/**
/**
...
...
license/src/main/java/iot/sixiang/license/net/BaseChannelInitializer.java
View file @
29426039
...
@@ -8,7 +8,7 @@ public class BaseChannelInitializer extends ChannelInitializer<SocketChannel> {
...
@@ -8,7 +8,7 @@ public class BaseChannelInitializer extends ChannelInitializer<SocketChannel> {
@Override
@Override
protected
void
initChannel
(
SocketChannel
ch
)
throws
Exception
{
protected
void
initChannel
(
SocketChannel
ch
)
throws
Exception
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
System
.
out
.
println
(
"重写了initChannel方法"
);
}
}
}
}
license/src/main/java/iot/sixiang/license/net/BaseConnectionListener.java
View file @
29426039
...
@@ -13,6 +13,6 @@ public class BaseConnectionListener implements ChannelFutureListener {
...
@@ -13,6 +13,6 @@ public class BaseConnectionListener implements ChannelFutureListener {
@Override
@Override
public
void
operationComplete
(
ChannelFuture
future
)
throws
Exception
{
public
void
operationComplete
(
ChannelFuture
future
)
throws
Exception
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
System
.
out
.
println
(
"重写了operationComplete方法"
);
}
}
}
}
license/src/main/java/iot/sixiang/license/operate/OperateDecoder.java
View file @
29426039
...
@@ -16,8 +16,6 @@ public class OperateDecoder extends ByteToMessageDecoder {
...
@@ -16,8 +16,6 @@ public class OperateDecoder extends ByteToMessageDecoder {
@Override
@Override
protected
void
decode
(
ChannelHandlerContext
ctx
,
ByteBuf
buffer
,
List
<
Object
>
out
)
{
protected
void
decode
(
ChannelHandlerContext
ctx
,
ByteBuf
buffer
,
List
<
Object
>
out
)
{
// 可读长度必须大于等于基本长度
// 可读长度必须大于等于基本长度
try
{
if
(
buffer
.
readableBytes
()
<
BASE_LENGTH
)
{
if
(
buffer
.
readableBytes
()
<
BASE_LENGTH
)
{
return
;
return
;
}
}
...
@@ -49,11 +47,6 @@ public class OperateDecoder extends ByteToMessageDecoder {
...
@@ -49,11 +47,6 @@ public class OperateDecoder extends ByteToMessageDecoder {
DeviceProtocol
protocol
=
new
DeviceProtocol
(
stx
,
real_len
,
cmd
,
ack
,
content
,
end
);
DeviceProtocol
protocol
=
new
DeviceProtocol
(
stx
,
real_len
,
cmd
,
ack
,
content
,
end
);
out
.
add
(
protocol
);
out
.
add
(
protocol
);
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
log
.
error
(
"Decoder error"
);
}
}
}
...
...
license/src/main/java/iot/sixiang/license/operate/OperateEncoder.java
View file @
29426039
...
@@ -4,7 +4,6 @@ import io.netty.buffer.ByteBuf;
...
@@ -4,7 +4,6 @@ import io.netty.buffer.ByteBuf;
import
io.netty.channel.ChannelHandlerContext
;
import
io.netty.channel.ChannelHandlerContext
;
import
io.netty.handler.codec.MessageToByteEncoder
;
import
io.netty.handler.codec.MessageToByteEncoder
;
import
iot.sixiang.license.device.DeviceProtocol
;
import
iot.sixiang.license.device.DeviceProtocol
;
import
iot.sixiang.license.util.Util
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
@Slf4j
...
@@ -12,7 +11,6 @@ public class OperateEncoder extends MessageToByteEncoder<DeviceProtocol> {
...
@@ -12,7 +11,6 @@ public class OperateEncoder extends MessageToByteEncoder<DeviceProtocol> {
@Override
@Override
protected
void
encode
(
ChannelHandlerContext
tcx
,
DeviceProtocol
msg
,
ByteBuf
out
)
{
protected
void
encode
(
ChannelHandlerContext
tcx
,
DeviceProtocol
msg
,
ByteBuf
out
)
{
try
{
out
.
writeShort
(
msg
.
getStx
());
out
.
writeShort
(
msg
.
getStx
());
out
.
writeShortLE
(
msg
.
getLen
());
out
.
writeShortLE
(
msg
.
getLen
());
...
@@ -23,9 +21,5 @@ public class OperateEncoder extends MessageToByteEncoder<DeviceProtocol> {
...
@@ -23,9 +21,5 @@ public class OperateEncoder extends MessageToByteEncoder<DeviceProtocol> {
out
.
writeBytes
(
msg
.
getContent
());
out
.
writeBytes
(
msg
.
getContent
());
}
}
out
.
writeByte
(
msg
.
getEnd
());
out
.
writeByte
(
msg
.
getEnd
());
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
log
.
error
(
"解码器异常"
);
}
}
}
}
}
license/src/main/java/iot/sixiang/license/service/impl/MonitorServiceImpl.java
View file @
29426039
...
@@ -52,6 +52,8 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
...
@@ -52,6 +52,8 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
case
3
:
case
3
:
localDate
=
localDate
.
plusDays
(-
29
);
localDate
=
localDate
.
plusDays
(-
29
);
break
;
break
;
default
:
break
;
}
}
List
<
Monitor
>
monitorList
=
monitorMapper
.
getMonitorList
(
localDate
,
endDate
);
List
<
Monitor
>
monitorList
=
monitorMapper
.
getMonitorList
(
localDate
,
endDate
);
...
...
license/src/main/java/iot/sixiang/license/util/CommonUtil.java
View file @
29426039
...
@@ -2,13 +2,12 @@ package iot.sixiang.license.util;
...
@@ -2,13 +2,12 @@ package iot.sixiang.license.util;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
java.io.
*
;
import
java.io.
UnsupportedEncodingException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.SecureRandom
;
import
java.security.SecureRandom
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.regex.Matcher
;
import
java.util.Locale
;
import
java.util.regex.Pattern
;
@Slf4j
@Slf4j
public
class
CommonUtil
{
public
class
CommonUtil
{
...
...
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