Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
Overview
Overview
Details
Activity
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
pseer
gxpt_ht
Commits
5e2c638b
Commit
5e2c638b
authored
Nov 06, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改设备操作日志查询
parent
5e448d21
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
36 deletions
+36
-36
DeviceLogServiceImpl.java
.../java/share/system/service/impl/DeviceLogServiceImpl.java
+32
-36
DeviceLogMapper.xml
...stem/src/main/resources/mapper/system/DeviceLogMapper.xml
+4
-0
No files found.
share-system/src/main/java/share/system/service/impl/DeviceLogServiceImpl.java
View file @
5e2c638b
package
share
.
system
.
service
.
impl
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
share.common.utils.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
share.common.utils.
Security
Utils
;
import
share.system.domain.
*
;
import
share.common.utils.
Date
Utils
;
import
share.system.domain.
DeviceLog
;
import
share.system.domain.vo.MqttxVo
;
import
share.system.mapper.DeviceLogMapper
;
import
share.system.mapper.DeviceMapper
;
...
...
@@ -18,6 +12,8 @@ import share.system.mapper.SRoomMapper;
import
share.system.mapper.SStoreMapper
;
import
share.system.service.DeviceLogService
;
import
java.util.List
;
/**
* 设备操作日志Service业务层处理
*
...
...
@@ -58,34 +54,34 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog
public
List
<
DeviceLog
>
selectDeviceLogList
(
DeviceLog
deviceLog
)
{
List
<
DeviceLog
>
list
=
deviceLogMapper
.
selectDeviceLogList
(
deviceLog
);
if
(
list
.
size
()
>
0
)
{
List
<
String
>
devIds
=
list
.
stream
().
map
(
DeviceLog:
:
getDevId
).
collect
(
Collectors
.
toList
());
// 设备信息查询
LambdaQueryWrapper
<
Device
>
queryDeviceWrapper
=
new
LambdaQueryWrapper
();
queryDeviceWrapper
.
in
(
Device:
:
getDevId
,
devIds
);
List
<
Device
>
deviceList
=
deviceMapper
.
selectList
(
queryDeviceWrapper
);
// 提取roomId,方便批量查询
List
<
Long
>
roomIds
=
deviceList
.
stream
().
map
(
Device:
:
getRoomId
).
collect
(
Collectors
.
toList
());
Map
<
String
,
Long
>
deviceRoomMap
=
deviceList
.
stream
().
collect
(
Collectors
.
toMap
(
Device:
:
getDevId
,
Device:
:
getRoomId
));
if
(
roomIds
!=
null
&&
roomIds
.
size
()
>
0
)
{
// 房间信息查询
LambdaQueryWrapper
<
SRoom
>
queryWrapper
=
new
LambdaQueryWrapper
();
queryWrapper
.
in
(
SRoom:
:
getId
,
roomIds
);
List
<
SRoom
>
roomList
=
roomMapper
.
selectList
(
queryWrapper
);
Map
<
Long
,
String
>
roomMap
=
roomList
.
stream
().
collect
(
Collectors
.
toMap
(
SRoom:
:
getId
,
SRoom:
:
getName
));
Map
<
Long
,
Long
>
roomStoreMap
=
roomList
.
stream
().
collect
(
Collectors
.
toMap
(
SRoom:
:
getId
,
SRoom:
:
getStoreId
));
// 门店信息查询
List
<
Long
>
storeIds
=
roomList
.
stream
().
map
(
SRoom:
:
getStoreId
).
collect
(
Collectors
.
toList
());
LambdaQueryWrapper
<
SStore
>
queryStoreWrapper
=
new
LambdaQueryWrapper
();
queryStoreWrapper
.
in
(
SStore:
:
getId
,
storeIds
);
List
<
SStore
>
storeList
=
storeMapper
.
selectList
(
queryStoreWrapper
);
Map
<
Long
,
String
>
storeMap
=
storeList
.
stream
().
collect
(
Collectors
.
toMap
(
SStore:
:
getId
,
SStore:
:
getName
));
list
.
stream
().
forEach
(
log
->
{
log
.
setRoomName
(
roomMap
.
get
(
deviceRoomMap
.
get
(
log
.
getDevId
())));
log
.
setStoreName
(
storeMap
.
get
(
roomStoreMap
.
get
(
deviceRoomMap
.
get
(
log
.
getDevId
()))));
});
}
}
//
if (list.size() > 0) {
//
List<String> devIds = list.stream().map(DeviceLog::getDevId).collect(Collectors.toList());
//
// 设备信息查询
//
LambdaQueryWrapper<Device> queryDeviceWrapper = new LambdaQueryWrapper();
//
queryDeviceWrapper.in(Device::getDevId, devIds);
//
List<Device> deviceList = deviceMapper.selectList(queryDeviceWrapper);
//
// 提取roomId,方便批量查询
//
List<Long> roomIds = deviceList.stream().map(Device::getRoomId).collect(Collectors.toList());
//
Map<String, Long> deviceRoomMap = deviceList.stream().collect(Collectors.toMap(Device::getDevId, Device::getRoomId));
//
if (roomIds != null && roomIds.size() > 0) {
//
// 房间信息查询
//
LambdaQueryWrapper<SRoom> queryWrapper = new LambdaQueryWrapper();
//
queryWrapper.in(SRoom::getId, roomIds);
//
List<SRoom> roomList = roomMapper.selectList(queryWrapper);
//
Map<Long, String> roomMap = roomList.stream().collect(Collectors.toMap(SRoom::getId, SRoom::getName));
//
Map<Long, Long> roomStoreMap = roomList.stream().collect(Collectors.toMap(SRoom::getId, SRoom::getStoreId));
//
// 门店信息查询
//
List<Long> storeIds = roomList.stream().map(SRoom::getStoreId).collect(Collectors.toList());
//
LambdaQueryWrapper<SStore> queryStoreWrapper = new LambdaQueryWrapper();
//
queryStoreWrapper.in(SStore::getId, storeIds);
//
List<SStore> storeList = storeMapper.selectList(queryStoreWrapper);
//
Map<Long, String> storeMap = storeList.stream().collect(Collectors.toMap(SStore::getId, SStore::getName));
//
list.stream().forEach(log -> {
//
log.setRoomName(roomMap.get(deviceRoomMap.get(log.getDevId())));
//
log.setStoreName(storeMap.get(roomStoreMap.get(deviceRoomMap.get(log.getDevId()))));
//
});
//
}
//
}
return
list
;
}
...
...
share-system/src/main/resources/mapper/system/DeviceLogMapper.xml
View file @
5e2c638b
...
...
@@ -22,6 +22,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"description"
column=
"description"
/>
<result
property=
"afreshNum"
column=
"afresh_num"
/>
<result
property=
"source"
column=
"source"
/>
<result
property=
"roomName"
column=
"room_name"
/>
<result
property=
"storeName"
column=
"store_name"
/>
</resultMap>
<sql
id=
"selectDeviceLogVo"
>
...
...
@@ -40,6 +42,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
t1.dev_mac,
t1.dev_id,
t1.seq,
t3.name as 'room_name',
t4.name as 'store_name',
t1.mqtt_type,
t1.mqtt_describe,
t1.payload,
...
...
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