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
9d8be15d
Commit
9d8be15d
authored
Nov 25, 2022
by
马33
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增使用记录模块
parent
49684035
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
126 additions
and
14 deletions
+126
-14
DeviceController.java
...java/iot/sixiang/license/controller/DeviceController.java
+1
-1
PmsUseLogController.java
...a/iot/sixiang/license/controller/PmsUseLogController.java
+65
-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
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
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
+1
-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
DeviceServiceImpl.java
...a/iot/sixiang/license/service/impl/DeviceServiceImpl.java
+1
-1
PmsUseServiceImpl.java
...a/iot/sixiang/license/service/impl/PmsUseServiceImpl.java
+25
-0
PmsUseLogMapper.xml
license/src/main/resources/mapper/PmsUseLogMapper.xml
+14
-0
No files found.
license/src/main/java/iot/sixiang/license/controller/DeviceController.java
View file @
9d8be15d
...
...
@@ -90,7 +90,7 @@ public class DeviceController {
@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
)
int
status
)
{
@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为总页数
...
...
license/src/main/java/iot/sixiang/license/controller/PmsUseLogController.java
0 → 100644
View file @
9d8be15d
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/device/DeviceManager.java
View file @
9d8be15d
...
...
@@ -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 @
9d8be15d
...
...
@@ -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/mapper/DeviceMapper.java
View file @
9d8be15d
...
...
@@ -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
,
int
status
);
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 @
9d8be15d
...
...
@@ -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/vo/DeviceDetailVo.java
View file @
9d8be15d
...
...
@@ -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 @
9d8be15d
...
...
@@ -29,7 +29,7 @@ public class DeviceVo implements Serializable {
private
String
snBind
;
@ApiModelProperty
(
"状态 0:未使用,1:已使用,2:失效"
)
private
String
status
;
private
Integer
status
;
@ApiModelProperty
(
"设备状态 0:正常 1:禁用"
)
private
int
blackFlag
;
...
...
license/src/main/java/iot/sixiang/license/service/DeviceService.java
View file @
9d8be15d
...
...
@@ -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
,
int
status
);
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 @
9d8be15d
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/impl/DeviceServiceImpl.java
View file @
9d8be15d
...
...
@@ -32,7 +32,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
private
DeviceMapper
deviceMapper
;
@Override
public
PageInfoModel
<
DeviceVo
>
getDeviceList
(
int
pageNo
,
int
pageSize
,
String
appName
,
String
userName
,
int
status
)
{
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
());
}
...
...
license/src/main/java/iot/sixiang/license/service/impl/PmsUseServiceImpl.java
View file @
9d8be15d
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/resources/mapper/PmsUseLogMapper.xml
0 → 100644
View file @
9d8be15d
<?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
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