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
dc9ff49d
Commit
dc9ff49d
authored
Dec 02, 2022
by
AfirSraftGarrier
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master' into for-yx
parents
f725f03f
239c324e
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
123 additions
and
5 deletions
+123
-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
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 @
dc9ff49d
...
...
@@ -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 @
dc9ff49d
...
...
@@ -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 @
dc9ff49d
...
...
@@ -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 @
dc9ff49d
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 @
dc9ff49d
...
...
@@ -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 @
dc9ff49d
...
...
@@ -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 @
dc9ff49d
...
...
@@ -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 @
dc9ff49d
...
...
@@ -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 @
dc9ff49d
...
...
@@ -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 @
dc9ff49d
...
...
@@ -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/mapper/DeviceMapper.xml
View file @
dc9ff49d
...
...
@@ -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 @
dc9ff49d
...
...
@@ -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