Commit 07e16f2d by YG8999

设备日志完善

parent ee2249b1
...@@ -50,6 +50,18 @@ public class DeviceLog extends BaseEntity ...@@ -50,6 +50,18 @@ public class DeviceLog extends BaseEntity
@Excel(name = "消息主题") @Excel(name = "消息主题")
private String topic; private String topic;
/**
* 房间名称
*/
@TableField(exist = false)
private String roomName;
/**
* 门店名称
*/
@TableField(exist = false)
private String storeName;
@Override @Override
public String toString() { public String toString() {
......
...@@ -79,6 +79,18 @@ public class DeviceStatusLog implements Serializable ...@@ -79,6 +79,18 @@ public class DeviceStatusLog implements Serializable
/** 备注 */ /** 备注 */
private String remark; private String remark;
/**
* 房间名称
*/
@TableField(exist = false)
private String roomName;
/**
* 门店名称
*/
@TableField(exist = false)
private String storeName;
@Override @Override
public String toString() { public String toString() {
......
package share.system.service.impl; package share.system.service.impl;
import java.util.List; 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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import share.common.utils.DateUtils; import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import share.common.utils.SecurityUtils; import share.common.utils.SecurityUtils;
import share.system.domain.*;
import share.system.domain.vo.MqttxVo; import share.system.domain.vo.MqttxVo;
import share.system.mapper.DeviceLogMapper; import share.system.mapper.DeviceLogMapper;
import share.system.domain.DeviceLog; import share.system.mapper.DeviceMapper;
import share.system.mapper.SRoomMapper;
import share.system.mapper.SStoreMapper;
import share.system.service.DeviceLogService; import share.system.service.DeviceLogService;
/** /**
...@@ -22,6 +29,12 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog ...@@ -22,6 +29,12 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog
{ {
@Autowired @Autowired
private DeviceLogMapper deviceLogMapper; private DeviceLogMapper deviceLogMapper;
@Autowired
private SRoomMapper roomMapper;
@Autowired
private SStoreMapper storeMapper;
@Autowired
private DeviceMapper deviceMapper;
/** /**
* 查询设备操作日志 * 查询设备操作日志
...@@ -44,7 +57,36 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog ...@@ -44,7 +57,36 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog
@Override @Override
public List<DeviceLog> selectDeviceLogList(DeviceLog deviceLog) public List<DeviceLog> selectDeviceLogList(DeviceLog deviceLog)
{ {
return deviceLogMapper.selectDeviceLogList(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()))));
});
}
}
return list;
} }
/** /**
......
package share.system.service.impl; package share.system.service.impl;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
...@@ -58,7 +61,30 @@ public class DeviceStatusLogServiceImpl extends ServiceImpl<DeviceStatusLogMappe ...@@ -58,7 +61,30 @@ public class DeviceStatusLogServiceImpl extends ServiceImpl<DeviceStatusLogMappe
@Override @Override
public List<DeviceStatusLog> selectDeviceStatusLogList(DeviceStatusLog deviceStatusLog) public List<DeviceStatusLog> selectDeviceStatusLogList(DeviceStatusLog deviceStatusLog)
{ {
return deviceStatusLogMapper.selectDeviceStatusLogList(deviceStatusLog); List<DeviceStatusLog> list = deviceStatusLogMapper.selectDeviceStatusLogList(deviceStatusLog);
if (list.size() > 0) {
// 提取roomId,方便批量查询
List<Long> roomIds = list.stream().map(DeviceStatusLog::getRoomId).collect(Collectors.toList());
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(log.getRoomId()));
log.setStoreName(storeMap.get(roomStoreMap.get(log.getRoomId())));
});
}
}
return list;
} }
/** /**
......
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