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
9dbff062
Commit
9dbff062
authored
Nov 25, 2022
by
AfirSraftGarrier
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
0323c817
74c76e21
Changes
26
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
340 additions
and
58 deletions
+340
-58
AuthManager.java
...e/src/main/java/iot/sixiang/license/auth/AuthManager.java
+27
-0
DeviceController.java
...java/iot/sixiang/license/controller/DeviceController.java
+43
-36
PmsUseLogController.java
...a/iot/sixiang/license/controller/PmsUseLogController.java
+65
-0
TerminalDeviceController.java
.../sixiang/license/controller/TerminalDeviceController.java
+25
-0
DeviceManager.java
...c/main/java/iot/sixiang/license/device/DeviceManager.java
+4
-8
Device.java
license/src/main/java/iot/sixiang/license/entity/Device.java
+3
-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
+1
-1
PmsUseLogMapper.java
...main/java/iot/sixiang/license/mapper/PmsUseLogMapper.java
+4
-0
ResResult.java
...se/src/main/java/iot/sixiang/license/model/ResResult.java
+1
-1
GetTerminalDeviceTokenDTO.java
.../sixiang/license/model/dto/GetTerminalDeviceTokenDTO.java
+17
-0
DeviceDetailVo.java
...ain/java/iot/sixiang/license/model/vo/DeviceDetailVo.java
+1
-1
DeviceVo.java
.../src/main/java/iot/sixiang/license/model/vo/DeviceVo.java
+3
-0
ResourceVo.java
...rc/main/java/iot/sixiang/license/model/vo/ResourceVo.java
+3
-0
UserVo.java
...se/src/main/java/iot/sixiang/license/model/vo/UserVo.java
+12
-2
ResourceManager.java
...in/java/iot/sixiang/license/resource/ResourceManager.java
+9
-1
DeviceService.java
.../main/java/iot/sixiang/license/service/DeviceService.java
+1
-1
PmsUseService.java
.../main/java/iot/sixiang/license/service/PmsUseService.java
+5
-0
TerminalDeviceService.java
...va/iot/sixiang/license/service/TerminalDeviceService.java
+9
-0
DeviceServiceImpl.java
...a/iot/sixiang/license/service/impl/DeviceServiceImpl.java
+2
-2
PmsUseServiceImpl.java
...a/iot/sixiang/license/service/impl/PmsUseServiceImpl.java
+25
-0
TerminalDeviceServiceImpl.java
...xiang/license/service/impl/TerminalDeviceServiceImpl.java
+49
-0
DeviceMapper.xml
license/src/main/resources/mapper/DeviceMapper.xml
+4
-1
PmsUseLogMapper.xml
license/src/main/resources/mapper/PmsUseLogMapper.xml
+14
-0
ResourceMapper.xml
license/src/main/resources/mapper/ResourceMapper.xml
+2
-1
UserMapper.xml
license/src/main/resources/mapper/UserMapper.xml
+9
-2
No files found.
license/src/main/java/iot/sixiang/license/auth/AuthManager.java
View file @
9dbff062
...
...
@@ -64,6 +64,33 @@ public class AuthManager {
}
}
// 终端设备鉴权
public
boolean
authTerminalDevice
(
String
appId
,
String
sn
,
String
sign
)
{
if
(!
allApply
.
containsKey
(
appId
))
{
log
.
info
(
"no valid appId..."
);
return
false
;
}
if
(!
deviceManager
.
getContainSn
(
sn
))
{
log
.
info
(
"no this sn..."
);
return
false
;
}
DeviceVo
device
=
deviceManager
.
getDevice
(
sn
);
int
deviceId
=
device
.
getDeviceId
();
if
(
deviceBlackMap
.
containsKey
(
deviceId
))
{
log
.
info
(
"in black..."
);
return
false
;
}
Apply
apply
=
allApply
.
get
(
appId
);
String
appKey
=
apply
.
getAppKey
();
String
input
=
"app_id="
+
appId
+
"&sn="
+
sn
;
String
valSHA1
=
HmacUtil
.
encrypt
(
input
,
appKey
,
HmacUtil
.
HMAC_SHA1
).
toUpperCase
();
if
(
CommonUtil
.
toUpperCaseByEnglish
(
sign
).
equals
(
CommonUtil
.
toUpperCaseByEnglish
(
valSHA1
)))
{
return
true
;
}
else
{
log
.
info
(
"sign no valid:"
+
input
);
return
false
;
}
}
public
boolean
auth
(
String
appId
,
String
sn
,
String
sign
)
{
if
(!
allApply
.
containsKey
(
appId
))
{
...
...
license/src/main/java/iot/sixiang/license/controller/DeviceController.java
View file @
9dbff062
...
...
@@ -24,7 +24,7 @@ import java.util.List;
/**
* <p>
*
前端控制器
* 前端控制器
* </p>
*
* @author m33
...
...
@@ -45,20 +45,21 @@ public class DeviceController {
/**
* 添加device
*
* @param jsonObject
* @return
*/
@ApiOperation
(
value
=
"添加设备接口"
,
notes
=
"用于添加设备"
)
@PostMapping
(
"add"
)
@ApiOperationSupport
(
params
=
@DynamicParameters
(
name
=
"jsonObject"
,
properties
=
{
@DynamicParameter
(
name
=
"appId"
,
value
=
"应用Id"
,
required
=
true
,
dataTypeClass
=
String
.
class
),
@DynamicParameter
(
name
=
"count"
,
value
=
"需要创建的设备数量"
,
required
=
true
,
dataTypeClass
=
Integer
.
class
),
@ApiOperationSupport
(
params
=
@DynamicParameters
(
name
=
"jsonObject"
,
properties
=
{
@DynamicParameter
(
name
=
"appId"
,
value
=
"应用Id"
,
required
=
true
,
dataTypeClass
=
String
.
class
),
@DynamicParameter
(
name
=
"count"
,
value
=
"需要创建的设备数量"
,
required
=
true
,
dataTypeClass
=
Integer
.
class
),
}))
@MyLog
(
title
=
"添加设备"
,
optParam
=
"#{jsonObject}"
,
businessType
=
BusinessType
.
INSERT
)
public
BaseResult
addDevice
(
@RequestBody
JSONObject
jsonObject
)
{
String
appId
=
jsonObject
.
getString
(
"appId"
);
int
count
=
jsonObject
.
getIntValue
(
"count"
);
boolean
res
=
deviceService
.
addDevice
(
appId
,
count
);
int
count
=
jsonObject
.
getIntValue
(
"count"
);
boolean
res
=
deviceService
.
addDevice
(
appId
,
count
);
if
(
res
)
{
return
BaseResult
.
success
();
}
else
{
...
...
@@ -68,6 +69,7 @@ public class DeviceController {
/**
* 可按条件分页查询所有的设备
*
* @param pageNo
* @param pageSize
* @param appName
...
...
@@ -76,26 +78,28 @@ public class DeviceController {
*/
@ApiOperation
(
value
=
"获取设备列表接口"
,
notes
=
"用于获取设备列表"
)
@GetMapping
(
"list"
)
@MyLog
(
title
=
"获取设备列表"
,
optParam
=
"#{pageNo},#{pageSize},#{appName},#{userName}"
,
businessType
=
BusinessType
.
SELECT
)
@MyLog
(
title
=
"获取设备列表"
,
optParam
=
"#{pageNo},#{pageSize},#{appName},#{userName}
,#{status}
"
,
businessType
=
BusinessType
.
SELECT
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"pageNo"
,
value
=
"当前在第几页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页显示多少页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"appName"
,
value
=
"应用名"
),
@ApiImplicitParam
(
name
=
"userName"
,
value
=
"用户名"
)
@ApiImplicitParam
(
name
=
"pageNo"
,
value
=
"当前在第几页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页显示多少页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"appName"
,
value
=
"应用名"
),
@ApiImplicitParam
(
name
=
"userName"
,
value
=
"用户名"
),
@ApiImplicitParam
(
name
=
"status"
,
value
=
"状态"
,
dataType
=
"int"
)
})
public
PageResult
<
DeviceVo
>
getDeviceList
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
int
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
,
@RequestParam
(
value
=
"appName"
,
required
=
false
)
String
appName
,
@RequestParam
(
value
=
"userName"
,
required
=
false
)
String
userName
)
{
PageInfoModel
<
DeviceVo
>
records
=
deviceService
.
getDeviceList
(
pageNo
,
pageSize
,
appName
,
userName
);
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
,
@RequestParam
(
value
=
"appName"
,
required
=
false
)
String
appName
,
@RequestParam
(
value
=
"userName"
,
required
=
false
)
String
userName
,
@RequestParam
(
value
=
"status"
,
required
=
false
)
Integer
status
)
{
PageInfoModel
<
DeviceVo
>
records
=
deviceService
.
getDeviceList
(
pageNo
,
pageSize
,
appName
,
userName
,
status
);
int
total
=
records
.
getTotal
();
int
pages
=
total
/
pageSize
;
//pages为总页数
int
mod
=
total
%
pageSize
;
if
(
mod
!=
0
)
{
pages
=
pages
+
1
;
int
pages
=
total
/
pageSize
;
//pages为总页数
int
mod
=
total
%
pageSize
;
if
(
mod
!=
0
)
{
pages
=
pages
+
1
;
}
List
<
DeviceVo
>
pageResult
=
records
.
getResult
();
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
pageResult
);
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
pageResult
);
}
@ApiOperation
(
value
=
"获取设备详细信息接口"
,
notes
=
"用于获取设备详细信息列表"
)
...
...
@@ -108,9 +112,9 @@ public class DeviceController {
@ApiImplicitParam
(
name
=
"userName"
,
value
=
"用户名"
)
})
public
PageResult
<
DeviceDetailVo
>
getDeviceDetailList
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
int
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
,
@RequestParam
(
value
=
"appName"
,
required
=
false
)
String
appName
,
@RequestParam
(
value
=
"userName"
,
required
=
false
)
String
userName
)
{
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
,
@RequestParam
(
value
=
"appName"
,
required
=
false
)
String
appName
,
@RequestParam
(
value
=
"userName"
,
required
=
false
)
String
userName
)
{
PageInfoModel
<
DeviceDetailVo
>
records
=
deviceManager
.
getDeviceDetailList
(
pageNo
,
pageSize
,
appName
,
userName
);
int
total
=
records
.
getTotal
();
...
...
@@ -125,13 +129,14 @@ public class DeviceController {
/**
* 添加device_black
*
* @param jsonObject
* @return
*/
@ApiOperation
(
value
=
"添加设备黑名单接口"
,
notes
=
"用于添加设备黑名单"
)
@PostMapping
(
"device_black/add"
)
@ApiOperationSupport
(
params
=
@DynamicParameters
(
name
=
"jsonObject"
,
properties
=
{
@DynamicParameter
(
name
=
"deviceId"
,
value
=
"设备Id"
,
required
=
true
,
dataTypeClass
=
Integer
.
class
)
@ApiOperationSupport
(
params
=
@DynamicParameters
(
name
=
"jsonObject"
,
properties
=
{
@DynamicParameter
(
name
=
"deviceId"
,
value
=
"设备Id"
,
required
=
true
,
dataTypeClass
=
Integer
.
class
)
}))
@MyLog
(
title
=
"添加设备黑名单"
,
optParam
=
"#{jsonObject}"
,
businessType
=
BusinessType
.
INSERT
)
public
BaseResult
addDeviceBlack
(
@RequestBody
JSONObject
jsonObject
)
{
...
...
@@ -146,13 +151,14 @@ public class DeviceController {
/**
* 删除device_black
*
* @param jsonObject
* @return
*/
@ApiOperation
(
value
=
"设备黑名单删除接口"
,
notes
=
"删除设备黑名单"
)
@PostMapping
(
"device_black/delete"
)
@ApiOperationSupport
(
params
=
@DynamicParameters
(
name
=
"jsonObject"
,
properties
=
{
@DynamicParameter
(
name
=
"deviceId"
,
value
=
"设备Id"
,
required
=
true
,
dataTypeClass
=
Integer
.
class
)
@ApiOperationSupport
(
params
=
@DynamicParameters
(
name
=
"jsonObject"
,
properties
=
{
@DynamicParameter
(
name
=
"deviceId"
,
value
=
"设备Id"
,
required
=
true
,
dataTypeClass
=
Integer
.
class
)
}))
@MyLog
(
title
=
"删除设备黑名单"
,
optParam
=
"#{deviceId}"
,
businessType
=
BusinessType
.
DELETE
)
public
BaseResult
deleteDeviceBlack
(
@RequestBody
JSONObject
jsonObject
)
{
...
...
@@ -167,6 +173,7 @@ public class DeviceController {
/**
* 分页查询所有黑名单设备
*
* @param pageNo
* @param pageSize
* @return
...
...
@@ -175,19 +182,19 @@ public class DeviceController {
@GetMapping
(
"device_black/list"
)
@MyLog
(
title
=
"获取设备黑名单列表"
,
optParam
=
"#{pageNo},#{pageSize}"
,
businessType
=
BusinessType
.
SELECT
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"pageNo"
,
value
=
"当前在第几页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页显示多少页"
,
required
=
true
,
dataType
=
"int"
)
@ApiImplicitParam
(
name
=
"pageNo"
,
value
=
"当前在第几页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页显示多少页"
,
required
=
true
,
dataType
=
"int"
)
})
public
PageResult
<
DeviceBlack
>
getDeviceBlackList
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
int
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
){
PageInfoModel
<
DeviceBlack
>
records
=
deviceBlackService
.
getDeviceBlackList
(
pageNo
,
pageSize
);
public
PageResult
<
DeviceBlack
>
getDeviceBlackList
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
int
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
)
{
PageInfoModel
<
DeviceBlack
>
records
=
deviceBlackService
.
getDeviceBlackList
(
pageNo
,
pageSize
);
int
total
=
records
.
getTotal
();
int
pages
=
total
/
pageSize
;
//pages为总页数
int
mod
=
total
%
pageSize
;
if
(
mod
!=
0
)
{
pages
=
pages
+
1
;
int
pages
=
total
/
pageSize
;
//pages为总页数
int
mod
=
total
%
pageSize
;
if
(
mod
!=
0
)
{
pages
=
pages
+
1
;
}
List
<
DeviceBlack
>
pageResult
=
records
.
getResult
();
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
pageResult
);
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
pageResult
);
}
}
license/src/main/java/iot/sixiang/license/controller/PmsUseLogController.java
0 → 100644
View file @
9dbff062
package
iot
.
sixiang
.
license
.
controller
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
iot.sixiang.license.entity.PmsUseLog
;
import
iot.sixiang.license.entity.SysOperLog
;
import
iot.sixiang.license.log.BusinessType
;
import
iot.sixiang.license.log.MyLog
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.PageResult
;
import
iot.sixiang.license.model.vo.DeviceVo
;
import
iot.sixiang.license.service.PmsUseService
;
import
iot.sixiang.license.service.SysOperLogService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Date
;
import
java.util.List
;
@Slf4j
@RestController
@RequestMapping
(
"/iot_license/pms_use_log"
)
@Api
(
value
=
"使用记录模块"
,
tags
=
{
"使用记录模块"
})
public
class
PmsUseLogController
{
@Autowired
private
PmsUseService
pmsUseService
;
/**
* 分页查询使用记录
*
* @param pageNo
* @param pageSize
* @return
*/
@ApiOperation
(
value
=
"获取使用记录列表接口"
,
notes
=
"用于获取使用记录列表"
)
@GetMapping
(
"list"
)
@MyLog
(
title
=
"获取使用记录列表"
,
optParam
=
"#{pageNo},#{pageSize},#{sn},#{status}"
,
businessType
=
BusinessType
.
SELECT
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"pageNo"
,
value
=
"当前在第几页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页显示多少条"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"sn"
,
value
=
"设备编号"
),
@ApiImplicitParam
(
name
=
"status"
,
value
=
"状态 1:成功,0:失败"
,
dataType
=
"int"
)
})
public
PageResult
<
PmsUseLog
>
getPmsUseLogList
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
int
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
,
@RequestParam
(
value
=
"sn"
,
required
=
false
)
String
sn
,
@RequestParam
(
value
=
"status"
,
required
=
false
)
Integer
status
)
{
PageInfoModel
<
PmsUseLog
>
records
=
pmsUseService
.
getPmsUseLogList
(
pageNo
,
pageSize
,
sn
,
status
);
int
total
=
records
.
getTotal
();
int
pages
=
total
/
pageSize
;
//pages为总页数
int
mod
=
total
%
pageSize
;
if
(
mod
!=
0
)
{
pages
=
pages
+
1
;
}
List
<
PmsUseLog
>
result
=
records
.
getResult
();
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
result
);
}
}
license/src/main/java/iot/sixiang/license/controller/TerminalDeviceController.java
0 → 100644
View file @
9dbff062
package
iot
.
sixiang
.
license
.
controller
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO
;
import
iot.sixiang.license.service.TerminalDeviceService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/iot_license/terminal_device"
)
@Api
(
value
=
"终端设备模块"
,
tags
=
{
"终端设备模块"
})
public
class
TerminalDeviceController
{
@Autowired
TerminalDeviceService
terminalDeviceService
;
@GetMapping
(
"/get_token"
)
@ApiOperation
(
value
=
"终端设备获取token"
,
notes
=
"终端设备获取token"
)
public
ResResult
getToken
(
GetTerminalDeviceTokenDTO
getTerminalDeviceTokenDTO
)
{
return
terminalDeviceService
.
getToken
(
getTerminalDeviceTokenDTO
);
}
}
license/src/main/java/iot/sixiang/license/device/DeviceManager.java
View file @
9dbff062
...
...
@@ -13,11 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
@Component
...
...
@@ -55,7 +51,7 @@ public class DeviceManager {
public
void
initDevices
()
{
allDevice
=
new
HashMap
<>();
PageInfoModel
<
DeviceVo
>
records
=
deviceService
.
getDeviceList
(
1
,
10000
,
""
,
""
);
PageInfoModel
<
DeviceVo
>
records
=
deviceService
.
getDeviceList
(
1
,
10000
,
""
,
""
,
null
);
List
<
DeviceVo
>
deviceList
=
records
.
getResult
();
for
(
DeviceVo
deviceVo
:
deviceList
)
{
...
...
@@ -153,7 +149,7 @@ public class DeviceManager {
}
public
PageInfoModel
<
DeviceDetailVo
>
getDeviceDetailList
(
int
pageNo
,
int
pageSize
,
String
appName
,
String
userName
)
{
PageInfoModel
<
DeviceVo
>
records
=
deviceService
.
getDeviceList
(
pageNo
,
pageSize
,
appName
,
userName
);
PageInfoModel
<
DeviceVo
>
records
=
deviceService
.
getDeviceList
(
pageNo
,
pageSize
,
appName
,
userName
,
null
);
List
<
DeviceVo
>
deviceVos
=
records
.
getResult
();
PageInfoModel
<
DeviceDetailVo
>
detailVoPageInfoModel
=
new
PageInfoModel
<>();
List
<
DeviceDetailVo
>
detailVos
=
new
ArrayList
<>();
...
...
@@ -172,7 +168,7 @@ public class DeviceManager {
int
status
=
session
.
getStatus
();
String
online
=
session
.
getOnline
();
String
offline
=
session
.
getOffline
();
detailVo
.
setStatus
(
status
);
detailVo
.
set
Cur
Status
(
status
);
detailVo
.
setOnline
(
online
);
detailVo
.
setOffline
(
offline
);
...
...
license/src/main/java/iot/sixiang/license/entity/Device.java
View file @
9dbff062
...
...
@@ -37,6 +37,9 @@ public class Device implements Serializable {
@ApiModelProperty
(
"应用Id"
)
private
String
appId
;
@ApiModelProperty
(
"应用Id"
)
private
Integer
status
;
@ApiModelProperty
(
"创建时间"
)
private
Date
createTime
;
...
...
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
View file @
9dbff062
...
...
@@ -27,6 +27,7 @@ public class JwtFilter implements Filter {
private
static
final
String
url7
=
"/swagger-resources"
;
private
static
final
String
url8
=
"/webjars/"
;
private
static
final
String
url9
=
"/log/get"
;
private
static
final
String
url10
=
"/terminal_device/get_token"
;
@Override
public
void
init
(
FilterConfig
filterConfig
)
{
...
...
@@ -48,7 +49,7 @@ public class JwtFilter implements Filter {
boolean
check
=
true
;
String
uri
=
request
.
getRequestURI
();
if
(
uri
.
contains
(
url1
)
||
uri
.
contains
(
url2
)
||
uri
.
contains
(
url3
)
||
uri
.
contains
(
url4
)
||
uri
.
contains
(
url7
)
||
uri
.
contains
(
url8
)
||
uri
.
contains
(
url9
))
{
if
(
uri
.
contains
(
url1
)
||
uri
.
contains
(
url2
)
||
uri
.
contains
(
url3
)
||
uri
.
contains
(
url4
)
||
uri
.
contains
(
url7
)
||
uri
.
contains
(
url8
)
||
uri
.
contains
(
url9
)
||
uri
.
contains
(
url10
)
)
{
if
(
uri
.
contains
(
url1
)
||
uri
.
contains
(
url2
))
{
UserUtils
.
setUri
(
uri
);
}
...
...
license/src/main/java/iot/sixiang/license/mapper/DeviceMapper.java
View file @
9dbff062
...
...
@@ -13,7 +13,7 @@ import java.util.List;
* @since 2022-06-08
*/
public
interface
DeviceMapper
extends
BaseMapper
<
Device
>
{
List
<
DeviceVo
>
getDeviceList
(
String
appName
,
String
userName
);
List
<
DeviceVo
>
getDeviceList
(
String
appName
,
String
userName
,
Integer
status
);
boolean
addDevice
(
String
sn
,
String
appId
);
}
license/src/main/java/iot/sixiang/license/mapper/PmsUseLogMapper.java
View file @
9dbff062
...
...
@@ -2,6 +2,9 @@ package iot.sixiang.license.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
iot.sixiang.license.entity.PmsUseLog
;
import
iot.sixiang.license.model.vo.DeviceVo
;
import
java.util.List
;
/**
* Created by M=54G
...
...
@@ -9,4 +12,5 @@ import iot.sixiang.license.entity.PmsUseLog;
* Description
*/
public
interface
PmsUseLogMapper
extends
BaseMapper
<
PmsUseLog
>
{
List
<
PmsUseLog
>
getPmsUseLogList
(
String
sn
,
Integer
status
);
}
license/src/main/java/iot/sixiang/license/model/ResResult.java
View file @
9dbff062
...
...
@@ -69,7 +69,7 @@ public class ResResult<T> {
* @return
*/
public
static
ResResult
failed
()
{
return
new
ResResult
(
ResultCode
.
SUCCESS
.
getCode
(),
ResultCode
.
SUCCESS
.
getMsg
());
return
new
ResResult
(
ResultCode
.
FAILED
.
getCode
(),
ResultCode
.
FAILED
.
getMsg
());
}
...
...
license/src/main/java/iot/sixiang/license/model/dto/GetTerminalDeviceTokenDTO.java
0 → 100644
View file @
9dbff062
package
iot
.
sixiang
.
license
.
model
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
GetTerminalDeviceTokenDTO
{
@ApiModelProperty
(
"应用id"
)
private
String
appId
;
@ApiModelProperty
(
"设备编号"
)
private
String
sn
;
@ApiModelProperty
(
"签名"
)
private
String
sign
;
}
license/src/main/java/iot/sixiang/license/model/vo/DeviceDetailVo.java
View file @
9dbff062
...
...
@@ -8,7 +8,7 @@ import lombok.Data;
public
class
DeviceDetailVo
extends
DeviceVo
{
@ApiModelProperty
(
"当前状态,0 offline,1 online"
)
private
int
s
tatus
;
private
int
curS
tatus
;
@ApiModelProperty
(
"上线时间"
)
private
String
online
;
...
...
license/src/main/java/iot/sixiang/license/model/vo/DeviceVo.java
View file @
9dbff062
...
...
@@ -28,6 +28,9 @@ public class DeviceVo implements Serializable {
@ApiModelProperty
(
"绑定的设备编号"
)
private
String
snBind
;
@ApiModelProperty
(
"状态 0:未使用,1:已使用,2:失效"
)
private
Integer
status
;
@ApiModelProperty
(
"设备状态 0:正常 1:禁用"
)
private
int
blackFlag
;
...
...
license/src/main/java/iot/sixiang/license/model/vo/ResourceVo.java
View file @
9dbff062
...
...
@@ -28,6 +28,9 @@ public class ResourceVo {
@ApiModelProperty
(
"设备编号"
)
private
String
sn
;
@ApiModelProperty
(
"设备状态"
)
private
String
status
;
@ApiModelProperty
(
"应用id"
)
private
String
appId
;
}
\ No newline at end of file
license/src/main/java/iot/sixiang/license/model/vo/UserVo.java
View file @
9dbff062
...
...
@@ -10,6 +10,16 @@ import lombok.Data;
@Data
public
class
UserVo
extends
User
{
@ApiModelProperty
(
"设备数量"
)
public
int
deviceCount
;
@ApiModelProperty
(
"总设备"
)
public
int
totalDevice
;
@ApiModelProperty
(
"已使用设备"
)
public
int
inUseDevice
;
@ApiModelProperty
(
"未使用设备"
)
public
int
unUseDevice
;
@ApiModelProperty
(
"失效设备"
)
public
int
failedDevice
;
}
license/src/main/java/iot/sixiang/license/resource/ResourceManager.java
View file @
9dbff062
...
...
@@ -79,6 +79,10 @@ public class ResourceManager {
cell
=
row
.
createCell
((
short
)
4
);
//第五个单元格
cell
.
setCellValue
(
"sn"
);
cell
.
setCellStyle
(
styleRow
);
cell
=
row
.
createCell
((
short
)
5
);
//第六个单元格
cell
.
setCellValue
(
"状态"
);
cell
.
setCellStyle
(
styleRow
);
//第五步插入数据
List
<
ResourceVo
>
resourceList
=
resourceService
.
getResource
(
userId
);
for
(
int
i
=
0
;
i
<
resourceList
.
size
();
i
++)
{
...
...
@@ -106,9 +110,13 @@ public class ResourceManager {
cell
=
row
.
createCell
((
short
)
4
);
// 第五个单元格
cell
.
setCellValue
(
resourceVo
.
getSn
());
cell
.
setCellStyle
(
style
);
cell
=
row
.
createCell
((
short
)
5
);
// 第六个单元格
cell
.
setCellValue
(
resourceVo
.
getStatus
());
cell
.
setCellStyle
(
style
);
}
//在填完所有值以后,对每一列设置自适应宽度
for
(
int
n
=
0
;
n
<
5
;
n
++)
{
for
(
int
n
=
0
;
n
<
6
;
n
++)
{
sheet
.
autoSizeColumn
(
n
);
}
wb
.
write
(
os
);
...
...
license/src/main/java/iot/sixiang/license/service/DeviceService.java
View file @
9dbff062
...
...
@@ -12,7 +12,7 @@ import iot.sixiang.license.model.vo.DeviceVo;
* @since 2022-06-08
*/
public
interface
DeviceService
extends
IService
<
Device
>
{
PageInfoModel
<
DeviceVo
>
getDeviceList
(
int
pageNo
,
int
pageSize
,
String
appName
,
String
userName
);
PageInfoModel
<
DeviceVo
>
getDeviceList
(
int
pageNo
,
int
pageSize
,
String
appName
,
String
userName
,
Integer
status
);
boolean
addDevice
(
String
appId
,
int
count
);
}
license/src/main/java/iot/sixiang/license/service/PmsUseService.java
View file @
9dbff062
package
iot
.
sixiang
.
license
.
service
;
import
iot.sixiang.license.entity.PmsUseLog
;
import
iot.sixiang.license.model.PageInfoModel
;
/**
* Created by M=54G
* Date 11/23/22 3:09 PM
...
...
@@ -11,4 +14,6 @@ public interface PmsUseService {
void
createFailUseLog
(
String
sn
,
String
message
);
void
success
(
int
useLogId
);
PageInfoModel
<
PmsUseLog
>
getPmsUseLogList
(
int
pageNo
,
int
pageSize
,
String
sn
,
Integer
status
);
}
license/src/main/java/iot/sixiang/license/service/TerminalDeviceService.java
0 → 100644
View file @
9dbff062
package
iot
.
sixiang
.
license
.
service
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO
;
import
iot.sixiang.license.model.vo.GetTerminalDeviceTokenVO
;
public
interface
TerminalDeviceService
{
ResResult
getToken
(
GetTerminalDeviceTokenDTO
getTerminalDeviceTokenDTO
);
}
license/src/main/java/iot/sixiang/license/service/impl/DeviceServiceImpl.java
View file @
9dbff062
...
...
@@ -32,11 +32,11 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
private
DeviceMapper
deviceMapper
;
@Override
public
PageInfoModel
<
DeviceVo
>
getDeviceList
(
int
pageNo
,
int
pageSize
,
String
appName
,
String
userName
)
{
public
PageInfoModel
<
DeviceVo
>
getDeviceList
(
int
pageNo
,
int
pageSize
,
String
appName
,
String
userName
,
Integer
status
)
{
if
(
pageNo
==
0
||
pageSize
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
List
<
DeviceVo
>
deviceTypes
=
deviceMapper
.
getDeviceList
(
appName
,
userName
);
List
<
DeviceVo
>
deviceTypes
=
deviceMapper
.
getDeviceList
(
appName
,
userName
,
status
);
deviceTypes
=
deviceTypes
.
stream
().
sorted
(
Comparator
.
comparing
(
DeviceVo:
:
getCreateTime
,
Comparator
.
reverseOrder
())).
collect
(
Collectors
.
toList
());
List
<
DeviceVo
>
result
=
new
ArrayList
<>();
int
begin
=
(
pageNo
-
1
)
*
pageSize
;
...
...
license/src/main/java/iot/sixiang/license/service/impl/PmsUseServiceImpl.java
View file @
9dbff062
package
iot
.
sixiang
.
license
.
service
.
impl
;
import
iot.sixiang.license.consts.ResultCode
;
import
iot.sixiang.license.entity.PmsUseLog
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.mapper.PmsUseLogMapper
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.vo.DeviceVo
;
import
iot.sixiang.license.service.PmsUseService
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* Created by M=54G
...
...
@@ -40,6 +48,23 @@ public class PmsUseServiceImpl implements PmsUseService {
pmsUseLogMapper
.
updateById
(
pmsUseLog
);
}
@Override
public
PageInfoModel
<
PmsUseLog
>
getPmsUseLogList
(
int
pageNo
,
int
pageSize
,
String
sn
,
Integer
status
)
{
if
(
pageNo
==
0
||
pageSize
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
List
<
PmsUseLog
>
pmsUseLogs
=
pmsUseLogMapper
.
getPmsUseLogList
(
sn
,
status
);
List
<
PmsUseLog
>
result
=
new
ArrayList
<>();
int
begin
=
(
pageNo
-
1
)
*
pageSize
;
if
(
begin
>=
0
&&
pmsUseLogs
.
size
()
>
0
)
{
result
=
pmsUseLogs
.
stream
().
skip
(
begin
).
limit
(
pageSize
).
collect
(
Collectors
.
toList
());
}
PageInfoModel
<
PmsUseLog
>
pmsUseLogPageInfoModel
=
new
PageInfoModel
<>();
pmsUseLogPageInfoModel
.
setTotal
(
pmsUseLogs
.
size
());
pmsUseLogPageInfoModel
.
setResult
(
result
);
return
pmsUseLogPageInfoModel
;
}
private
PmsUseLog
getPmsUseLog
(
String
sn
)
{
PmsUseLog
pmsUseLog
=
new
PmsUseLog
();
Date
date
=
new
Date
();
...
...
license/src/main/java/iot/sixiang/license/service/impl/TerminalDeviceServiceImpl.java
0 → 100644
View file @
9dbff062
package
iot
.
sixiang
.
license
.
service
.
impl
;
import
iot.sixiang.license.auth.AuthManager
;
import
iot.sixiang.license.device.DeviceManager
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.jwt.JwtUtil
;
import
iot.sixiang.license.jwt.LoginUser
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO
;
import
iot.sixiang.license.service.TerminalDeviceService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
@Slf4j
@Service
public
class
TerminalDeviceServiceImpl
implements
TerminalDeviceService
{
@Autowired
private
AuthManager
authManager
;
@Autowired
private
DeviceManager
deviceManager
;
@Override
public
ResResult
getToken
(
GetTerminalDeviceTokenDTO
getTerminalDeviceTokenDTO
)
{
String
appId
=
getTerminalDeviceTokenDTO
.
getAppId
();
String
sn
=
getTerminalDeviceTokenDTO
.
getSn
();
String
sign
=
getTerminalDeviceTokenDTO
.
getSign
();
if
(
StringUtils
.
isEmpty
(
appId
))
{
throw
new
IotLicenseException
(
403
,
"应用id不能为空"
);
}
if
(
StringUtils
.
isEmpty
(
sn
))
{
throw
new
IotLicenseException
(
403
,
"终端编号不能为空"
);
}
if
(
StringUtils
.
isEmpty
(
sign
))
{
throw
new
IotLicenseException
(
403
,
"签名不能为空"
);
}
boolean
authResult
=
authManager
.
authTerminalDevice
(
appId
,
sn
,
sign
);
if
(
authResult
)
{
LoginUser
user
=
new
LoginUser
();
user
.
setUserId
(
appId
);
user
.
setUserName
(
sn
);
String
token
=
JwtUtil
.
createToken
(
user
);
return
ResResult
.
success
().
record
(
token
);
}
else
{
return
ResResult
.
validate_failed
();
}
}
}
license/src/main/resources/mapper/DeviceMapper.xml
View file @
9dbff062
...
...
@@ -3,7 +3,7 @@
<mapper
namespace=
"iot.sixiang.license.mapper.DeviceMapper"
>
<select
id=
"getDeviceList"
resultType=
"iot.sixiang.license.model.vo.DeviceVo"
>
SELECT de.device_id,app_name,user_name,sn,sn_bind,de.create_time,de.update_time,de.device_id IN (select
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
...
...
@@ -14,6 +14,9 @@
<if
test=
"null != userName and '' != userName"
>
and user_name like concat('%',#{userName},'%')
</if>
<if
test=
"null != status"
>
and status = #{status}
</if>
</select>
<insert
id=
"addDevice"
parameterType=
"iot.sixiang.license.entity.Device"
>
...
...
license/src/main/resources/mapper/PmsUseLogMapper.xml
0 → 100644
View file @
9dbff062
<?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.PmsUseLogMapper"
>
<select
id=
"getPmsUseLogList"
resultType=
"iot.sixiang.license.entity.PmsUseLog"
>
SELECT * FROM pms_use_log
where 1=1
<if
test=
"null != sn and '' != sn"
>
and sn = #{sn}
</if>
<if
test=
"null != status"
>
and status = #{status}
</if>
</select>
</mapper>
\ No newline at end of file
license/src/main/resources/mapper/ResourceMapper.xml
View file @
9dbff062
...
...
@@ -3,7 +3,8 @@
<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, 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}
</select>
...
...
license/src/main/resources/mapper/UserMapper.xml
View file @
9dbff062
...
...
@@ -15,8 +15,15 @@
</update>
<select
id=
"getUserList"
resultType=
"iot.sixiang.license.model.vo.UserVo"
>
SELECT user.user_id, user_name, PASSWORD, company, user.create_time, user.update_time ,COUNT(device.`device_id`) deviceCount FROM USER LEFT JOIN apply ON user.user_id = apply.user_id LEFT JOIN device ON apply.app_id = device.app_id
where 1=1
SELECT user.user_id, user_name, password, company, user.create_time, user.update_time,
COUNT(device.`device_id`) totalDevice,
COUNT(if(device.device_id is NOT NULL, if (device.`status` = 0 or device.`status` is NULL, 1, NULL), NULL)) unUseDevice,
COUNT(if(device.device_id is NOT NULL and device.`status` = 1, 1, NULL)) inUseDevice,
COUNT(if(device.device_id is NOT NULL and device.`status` = 2, 1, NULL)) failedDevice
FROM USER
LEFT JOIN apply ON user.user_id = apply.user_id
LEFT JOIN device ON apply.app_id = device.app_id
where 1=1
<if
test=
"null != userName and '' != userName"
>
and user_name like concat('%',#{userName},'%')
</if>
...
...
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