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
f89d785b
Commit
f89d785b
authored
Dec 02, 2022
by
ma
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'for-yx' of
http://120.77.240.215:9701/tianlai3/ioc_sixiang_license
into for-yx
parents
eaec19aa
dc9ff49d
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
230 additions
and
5 deletions
+230
-5
TerminalDeviceController.java
.../sixiang/license/controller/TerminalDeviceController.java
+13
-0
JwtFilter.java
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
+2
-1
DeviceMapper.java
...rc/main/java/iot/sixiang/license/mapper/DeviceMapper.java
+2
-0
TerminalDevieUnBindDTO.java
...iot/sixiang/license/model/dto/TerminalDevieUnBindDTO.java
+10
-0
ResourceVo.java
...rc/main/java/iot/sixiang/license/model/vo/ResourceVo.java
+3
-0
ResourceManager.java
...in/java/iot/sixiang/license/resource/ResourceManager.java
+9
-1
DeviceService.java
.../main/java/iot/sixiang/license/service/DeviceService.java
+6
-0
TerminalDeviceService.java
...va/iot/sixiang/license/service/TerminalDeviceService.java
+5
-0
DeviceServiceImpl.java
...a/iot/sixiang/license/service/impl/DeviceServiceImpl.java
+42
-1
TerminalDeviceServiceImpl.java
...xiang/license/service/impl/TerminalDeviceServiceImpl.java
+25
-0
logback-spring.xml
license/src/main/resources/logback-spring.xml
+107
-0
DeviceMapper.xml
license/src/main/resources/mapper/DeviceMapper.xml
+5
-1
ResourceMapper.xml
license/src/main/resources/mapper/ResourceMapper.xml
+1
-1
No files found.
license/src/main/java/iot/sixiang/license/controller/TerminalDeviceController.java
View file @
f89d785b
...
...
@@ -7,6 +7,7 @@ import iot.sixiang.license.model.ResResult;
import
iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO
;
import
iot.sixiang.license.model.dto.ReportErrorMsgDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieBindDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieUnBindDTO
;
import
iot.sixiang.license.service.TerminalDeviceService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -41,4 +42,16 @@ public class TerminalDeviceController {
public
BaseResult
terminalDevieBind
(
@RequestBody
TerminalDevieBindDTO
terminalDevieBindDTO
)
{
return
terminalDeviceService
.
terminalDeviceBind
(
terminalDevieBindDTO
);
}
@PostMapping
(
"/unbind"
)
@ApiOperation
(
value
=
"终端设备解绑接口"
,
notes
=
"终端设备解绑接口"
)
public
BaseResult
terminalDevieunBind
(
@RequestBody
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
)
{
return
terminalDeviceService
.
terminalDeviceunBind
(
terminalDevieUnBindDTO
);
}
@GetMapping
(
"/get_bind_status"
)
@ApiOperation
(
value
=
"获取终端设备绑定状态接口"
,
notes
=
"获取终端设备绑定状态接口"
)
public
ResResult
getBindStatus
(
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
)
{
return
terminalDeviceService
.
getBindStatus
(
terminalDevieUnBindDTO
);
}
}
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
View file @
f89d785b
...
...
@@ -35,6 +35,7 @@ public class JwtFilter implements Filter {
private
static
final
String
url11
=
"/get_token"
;
private
static
final
String
url12
=
"/report_error_msg"
;
private
static
final
String
url13
=
"/bind"
;
private
static
final
String
url14
=
"/get_bind_status"
;
@Override
public
void
init
(
FilterConfig
filterConfig
)
{
...
...
@@ -89,7 +90,7 @@ public class JwtFilter implements Filter {
return
;
}
// 终端设备放行
if
(
uri
.
contains
(
url12
)
||
uri
.
contains
(
url13
))
{
if
(
uri
.
contains
(
url12
)
||
uri
.
contains
(
url13
)
||
uri
.
contains
(
url14
)
)
{
filterChain
.
doFilter
(
request
,
response
);
return
;
}
...
...
license/src/main/java/iot/sixiang/license/mapper/DeviceMapper.java
View file @
f89d785b
...
...
@@ -16,4 +16,6 @@ public interface DeviceMapper extends BaseMapper<Device> {
List
<
DeviceVo
>
getDeviceList
(
String
appName
,
String
userName
,
String
sn
,
Integer
status
);
boolean
addDevice
(
String
sn
,
String
appId
);
int
updateDeviceById
(
Device
device
);
}
license/src/main/java/iot/sixiang/license/model/dto/TerminalDevieUnBindDTO.java
0 → 100644
View file @
f89d785b
package
iot
.
sixiang
.
license
.
model
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
TerminalDevieUnBindDTO
{
@ApiModelProperty
(
"设备SN"
)
private
String
snBind
;
}
license/src/main/java/iot/sixiang/license/model/vo/ResourceVo.java
View file @
f89d785b
...
...
@@ -28,6 +28,9 @@ public class ResourceVo {
@ApiModelProperty
(
"设备编号"
)
private
String
sn
;
@ApiModelProperty
(
"绑定的SN"
)
private
String
snBind
;
@ApiModelProperty
(
"设备状态"
)
private
String
status
;
...
...
license/src/main/java/iot/sixiang/license/resource/ResourceManager.java
View file @
f89d785b
...
...
@@ -83,6 +83,10 @@ public class ResourceManager {
cell
=
row
.
createCell
((
short
)
5
);
//第六个单元格
cell
.
setCellValue
(
"状态"
);
cell
.
setCellStyle
(
styleRow
);
cell
=
row
.
createCell
((
short
)
6
);
//第七个单元格
cell
.
setCellValue
(
"设备编码"
);
cell
.
setCellStyle
(
styleRow
);
//第五步插入数据
List
<
ResourceVo
>
resourceList
=
resourceService
.
getResource
(
userId
);
for
(
int
i
=
0
;
i
<
resourceList
.
size
();
i
++)
{
...
...
@@ -114,9 +118,13 @@ public class ResourceManager {
cell
=
row
.
createCell
((
short
)
5
);
// 第六个单元格
cell
.
setCellValue
(
resourceVo
.
getStatus
());
cell
.
setCellStyle
(
style
);
cell
=
row
.
createCell
((
short
)
6
);
// 第七个单元格
cell
.
setCellValue
(
resourceVo
.
getSnBind
());
cell
.
setCellStyle
(
style
);
}
//在填完所有值以后,对每一列设置自适应宽度
for
(
int
n
=
0
;
n
<
6
;
n
++)
{
for
(
int
n
=
0
;
n
<
7
;
n
++)
{
sheet
.
autoSizeColumn
(
n
);
}
wb
.
write
(
os
);
...
...
license/src/main/java/iot/sixiang/license/service/DeviceService.java
View file @
f89d785b
...
...
@@ -3,7 +3,9 @@ package iot.sixiang.license.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
iot.sixiang.license.entity.Device
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.dto.TerminalDevieBindDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieUnBindDTO
;
import
iot.sixiang.license.model.vo.DeviceVo
;
/**
...
...
@@ -18,4 +20,8 @@ public interface DeviceService extends IService<Device> {
boolean
addDevice
(
String
appId
,
int
count
);
Boolean
terminalDevieBind
(
TerminalDevieBindDTO
terminalDevieBindDTO
);
Boolean
terminalDevieunBind
(
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
);
ResResult
getBindStatus
(
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
);
}
license/src/main/java/iot/sixiang/license/service/TerminalDeviceService.java
View file @
f89d785b
...
...
@@ -5,6 +5,7 @@ import iot.sixiang.license.model.ResResult;
import
iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO
;
import
iot.sixiang.license.model.dto.ReportErrorMsgDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieBindDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieUnBindDTO
;
import
java.util.List
;
...
...
@@ -14,4 +15,8 @@ public interface TerminalDeviceService {
BaseResult
reportErrorMsg
(
List
<
ReportErrorMsgDTO
>
reportErrorMsgDTO
);
BaseResult
terminalDeviceBind
(
TerminalDevieBindDTO
terminalDevieBindDTO
);
BaseResult
terminalDeviceunBind
(
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
);
ResResult
getBindStatus
(
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
);
}
license/src/main/java/iot/sixiang/license/service/impl/DeviceServiceImpl.java
View file @
f89d785b
...
...
@@ -8,7 +8,9 @@ import iot.sixiang.license.entity.Device;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.mapper.DeviceMapper
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.dto.TerminalDevieBindDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieUnBindDTO
;
import
iot.sixiang.license.model.vo.DeviceVo
;
import
iot.sixiang.license.service.DeviceService
;
import
iot.sixiang.license.util.CommonUtil
;
...
...
@@ -73,6 +75,16 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
public
Boolean
terminalDevieBind
(
TerminalDevieBindDTO
terminalDevieBindDTO
)
{
String
sn
=
terminalDevieBindDTO
.
getSn
();
String
snBind
=
terminalDevieBindDTO
.
getSnBind
();
LambdaQueryWrapper
<
Device
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
Device:
:
getSnBind
,
snBind
).
last
(
"limit 1"
);
Device
deviceTemp
=
deviceMapper
.
selectOne
(
wrapper
);
if
(
deviceTemp
!=
null
)
{
if
(
deviceTemp
.
getSn
().
equals
(
sn
))
{
return
true
;
}
else
{
throw
new
IotLicenseException
(
403
,
"该设备已绑定了"
+
deviceTemp
.
getSn
());
}
}
LambdaQueryWrapper
<
Device
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
Device:
:
getSn
,
sn
).
last
(
"limit 1"
);
Device
device
=
deviceMapper
.
selectOne
(
queryWrapper
);
...
...
@@ -88,7 +100,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
device
.
setStatus
(
1
);
device
.
setUpdateTime
(
new
Date
());
int
res
=
deviceMapper
.
updateById
(
device
);
if
(
res
>
=
0
)
{
if
(
res
>
0
)
{
return
true
;
}
else
{
return
false
;
...
...
@@ -96,4 +108,33 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
}
return
false
;
}
@Override
public
Boolean
terminalDevieunBind
(
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
)
{
String
snBind
=
terminalDevieUnBindDTO
.
getSnBind
();
LambdaQueryWrapper
<
Device
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
Device:
:
getSnBind
,
snBind
).
last
(
"limit 1"
);
Device
device
=
deviceMapper
.
selectOne
(
queryWrapper
);
if
(
device
!=
null
)
{
device
.
setSnBind
(
null
);
device
.
setStatus
(
0
);
device
.
setUpdateTime
(
new
Date
());
int
res
=
deviceMapper
.
updateDeviceById
(
device
);
return
res
>
0
;
}
return
false
;
}
@Override
public
ResResult
getBindStatus
(
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
)
{
String
snBind
=
terminalDevieUnBindDTO
.
getSnBind
();
LambdaQueryWrapper
<
Device
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
Device:
:
getSnBind
,
snBind
).
last
(
"limit 1"
);
Device
device
=
deviceMapper
.
selectOne
(
queryWrapper
);
if
(
device
!=
null
)
{
return
ResResult
.
success
().
record
(
device
.
getSn
());
}
else
{
return
new
ResResult
(
405
,
"未绑定"
);
}
}
}
license/src/main/java/iot/sixiang/license/service/impl/TerminalDeviceServiceImpl.java
View file @
f89d785b
...
...
@@ -10,6 +10,7 @@ import iot.sixiang.license.model.ResResult;
import
iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO
;
import
iot.sixiang.license.model.dto.ReportErrorMsgDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieBindDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieUnBindDTO
;
import
iot.sixiang.license.service.DeviceService
;
import
iot.sixiang.license.service.PmsUseService
;
import
iot.sixiang.license.service.TerminalDeviceService
;
...
...
@@ -107,4 +108,28 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService {
return
BaseResult
.
failed
();
}
}
@Override
public
BaseResult
terminalDeviceunBind
(
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
)
{
String
snBind
=
terminalDevieUnBindDTO
.
getSnBind
();
if
(
StringUtils
.
isEmpty
(
snBind
))
{
return
BaseResult
.
validate_failed
();
}
Boolean
res
=
deviceService
.
terminalDevieunBind
(
terminalDevieUnBindDTO
);
if
(
res
)
{
deviceManager
.
initDevices
();
return
BaseResult
.
success
();
}
else
{
return
BaseResult
.
failed
();
}
}
@Override
public
ResResult
getBindStatus
(
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
)
{
String
snBind
=
terminalDevieUnBindDTO
.
getSnBind
();
if
(
StringUtils
.
isEmpty
(
snBind
))
{
return
ResResult
.
validate_failed
();
}
return
deviceService
.
getBindStatus
(
terminalDevieUnBindDTO
);
}
}
license/src/main/resources/logback-spring.xml
0 → 100644
View file @
f89d785b
<?xml version="1.0" encoding="UTF-8"?>
<configuration
scan=
"false"
scanPeriod=
"10 seconds"
>
<!-- <logger>用来设置某一个包或者具体的某一个类的日志打印级别、 -->
<!-- <logger name="iot.sixiang.license" level="debug" />-->
<!--控制台输出的格式设置 -->
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<!-- 控制台输出的日志 的格式 -->
<encoder>
<pattern>
%date{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %5level %logger{96}:%line - %msg%n
</pattern>
<charset>
UTF-8
</charset>
<!-- 此处设置字符集 -->
</encoder>
<!-- 只是DEBUG级别以上的日志才显示 -->
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<level>
DEBUG
</level>
</filter>
</appender>
<!--文件输出的格式设置 -->
<appender
name=
"ALL_FILE"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<!-- 日志日常打印文件 -->
<file>
logs/license.log
</file>
<!-- 配置日志所生成的目录以及生成文件名的规则 -->
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
logs/license.log-%d{yyyy-MM-dd}.%i
</fileNamePattern>
<!-- 如果按天来回滚,则最大保存时间为365天,365天之前的都将被清理掉 -->
<maxHistory>
365
</maxHistory>
<!-- 日志总保存量为10GB -->
<totalSizeCap>
100GB
</totalSizeCap>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<!--文件达到 最大128MB时会被压缩和切割 -->
<maxFileSize>
40 MB
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<level>
DEBUG
</level>
</filter>
<!-- 文件输出的日志 的格式 -->
<encoder>
<pattern>
%date{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %5level %logger{96}:%line - %msg%n
</pattern>
<charset>
UTF-8
</charset>
<!-- 此处设置字符集 -->
</encoder>
<!-- Safely log to the same file from multiple JVMs. Degrades performance! -->
<prudent>
false
</prudent>
</appender>
<!--文件输出的格式设置 -->
<appender
name=
"MSG_FILE"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<!-- 日志日常打印文件 -->
<file>
logs/message.log
</file>
<!-- 配置日志所生成的目录以及生成文件名的规则 -->
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
logs/message.log-%d{yyyy-MM-dd}.%i
</fileNamePattern>
<!-- 如果按天来回滚,则最大保存时间为365天,365天之前的都将被清理掉 -->
<maxHistory>
365
</maxHistory>
<!-- 日志总保存量为10GB -->
<totalSizeCap>
100GB
</totalSizeCap>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<!--文件达到 最大128MB时会被压缩和切割 -->
<maxFileSize>
40 MB
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<!-- 此日志文档只记录info级别的 -->
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
INFO
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
<!-- 文件输出的日志 的格式 -->
<encoder>
<pattern>
%date{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %5level %logger{96}:%line - %msg%n
</pattern>
<charset>
UTF-8
</charset>
<!-- 此处设置字符集 -->
</encoder>
<!-- Safely log to the same file from multiple JVMs. Degrades performance! -->
<prudent>
false
</prudent>
</appender>
<!-- Enable FILE and STDOUT appenders for all log messages. By default,
only log at level INFO and above. -->
<!--这里选择INFO就代表,进行INFO级别输出记录,那么在控制台也好,log文件也好只记录INFO及以上级别的日志,这里相当于第一道设置-->
<root
level=
"info"
>
<appender-ref
ref=
"STDOUT"
/>
<appender-ref
ref=
"ALL_FILE"
/>
<appender-ref
ref=
"MSG_FILE"
/>
</root>
</configuration>
\ No newline at end of file
license/src/main/resources/mapper/DeviceMapper.xml
View file @
f89d785b
...
...
@@ -6,7 +6,7 @@
SELECT de.device_id,app_name,user_name,sn,sn_bind,de.status,de.create_time,de.update_time,de.device_id IN (select
device_id from device_black) AS blackFlag FROM device AS de
JOIN apply AS app ON de.app_id = app.app_id
JOIN
USER
AS us ON us.user_id = app.user_id
JOIN
`user`
AS us ON us.user_id = app.user_id
where 1=1
<if
test=
"null != appName and '' != appName"
>
and app_name like concat('%',#{appName},'%')
...
...
@@ -27,4 +27,8 @@
values (#{sn}, #{appId}, now(), now())
</insert>
<update
id=
"updateDeviceById"
parameterType=
"iot.sixiang.license.entity.Device"
>
update device set sn_bind = #{snBind}, status = #{status}, update_time = #{updateTime} where device_id = #{deviceId}
</update>
</mapper>
license/src/main/resources/mapper/ResourceMapper.xml
View file @
f89d785b
...
...
@@ -3,7 +3,7 @@
<mapper
namespace=
"iot.sixiang.license.mapper.ResourceMapper"
>
<select
id=
"getResource"
resultType=
"iot.sixiang.license.model.vo.ResourceVo"
>
SELECT a.user_name,a.password,a.company,b.app_name,b.app_key,c.sn, b.app_id,
SELECT a.user_name,a.password,a.company,b.app_name,b.app_key,c.sn,
c.sn_bind,
b.app_id,
(CASE c.`status` WHEN 1 THEN '已使用' WHEN 2 THEN '失效' ELSE '未使用' END) `status`
FROM USER a, apply b, device c WHERE a.user_id = b.user_id
AND b.app_id = c.app_id AND a.user_id = #{userId}
...
...
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