Commit 5e2c638b by 吕明尚

修改设备操作日志查询

parent 5e448d21
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.SecurityUtils;
import share.system.domain.*;
import share.common.utils.DateUtils;
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;
}
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment