存储部分使用sqlite代替redis-3

This commit is contained in:
panlinlin
2021-01-04 18:30:44 +08:00
parent a25f7e4f99
commit dcd78a1cfa
20 changed files with 222 additions and 1225 deletions

View File

@@ -1,14 +1,10 @@
package com.genersoft.iot.vmp.storager;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.PageResult;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.github.pagehelper.PageInfo;
/**
* @Description:视频设备数据存储接口
@@ -65,7 +61,7 @@ public interface IVideoManagerStorager {
* @param count 每页数量
* @return
*/
public PageResult queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, String online, int page, int count);
public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count);
/**
* 获取某个设备的通道列表
@@ -82,13 +78,13 @@ public interface IVideoManagerStorager {
*/
public DeviceChannel queryChannel(String deviceId, String channelId);
/**
/**
* 获取多个设备
*
* @param deviceIds 设备ID数组
* @param page 当前页数
* @param count 每页数量
* @return List<Device> 设备对象数组
*/
public PageResult<Device> queryVideoDeviceList(String[] deviceIds, int page, int count);
public PageInfo<Device> queryVideoDeviceList(int page, int count);
/**
* 获取多个设备
@@ -131,7 +127,7 @@ public interface IVideoManagerStorager {
* @param count
* @return
*/
PageResult querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, String online, int page, int count);
PageInfo querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, String online, int page, int count);
/**

View File

@@ -1,17 +0,0 @@
package com.genersoft.iot.vmp.storager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@Component
public class VodeoMannagerTask implements CommandLineRunner {
@Autowired
private IVideoManagerStorager redisStorager;
@Override
public void run(String... strings) throws Exception {
redisStorager.updateCatch();
}
}

View File

@@ -1,20 +1,50 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.common.PageResult;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.*;
import java.util.List;
/**
* 用于存储设备通道信息
*/
@Mapper
public interface DeviceChannelMapper {
@Insert("INSERT INTO device_channel (channelId, deviceId, name, manufacture, model, owner, civilCode, block, " +
"address, parental, parentId, safetyWay, registerWay, certNum, certifiable, errCode, secrecy, " +
"ipAddress, port, password, PTZType, status) " +
"VALUES ('${channelId}', '${deviceId}', '${name}', '${manufacture}', '${model}', '${owner}', '${civilCode}', '${block}'," +
"'${address}', ${parental}, '${parentId}', ${safetyWay}, ${registerWay}, '${certNum}', ${certifiable}, ${errCode}, '${secrecy}', " +
"'${ipAddress}', ${port}, '${password}', ${PTZType}, ${status})")
int add(DeviceChannel channel);
@Update("UPDATE device_channel " +
"SET name=#{name}, manufacture=#{manufacture}, model=#{model}, owner=#{owner}, civilCode=#{civilCode}, " +
"block=#{block}, address=#{address}, parental=#{parental}, parentId=#{parentId}, safetyWay=#{safetyWay}, " +
"registerWay=#{registerWay}, certNum=#{certNum}, certifiable=#{certifiable}, errCode=#{errCode}, secrecy=#{secrecy}, " +
"ipAddress=#{ipAddress}, port=#{port}, password=#{password}, PTZType=#{PTZType}, status=#{status} " +
"WHERE deviceId=#{deviceId} AND channelId=#{channelId}")
int update(DeviceChannel channel);
List<DeviceChannel> queryChannelsByDeviceId(String deviceId);
List<DeviceChannel> queryChannelsByDeviceId(String deviceId, String parentChannelId);
@Select(value = {" <script>" +
"SELECT * FROM ( "+
" SELECT * , (SELECT count(0) FROM device_channel WHERE parentId=dc.channelId) as subCount FROM device_channel dc " +
" WHERE dc.deviceId=#{deviceId} " +
" <if test=\"query != null\"> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
" <if test=\"parentChannelId != null\"> AND dc.parentId=#{parentChannelId} </if> " +
" <if test=\"online == true\" > AND dc.status=1</if>" +
" <if test=\"online == false\" > AND dc.status=0</if>) dcr" +
" WHERE 1=1 " +
" <if test=\"hasSubChannel == true\" > AND subCount >0</if>" +
" <if test=\"hasSubChannel == false\" > AND subCount=0</if>" +
" </script>"})
List<DeviceChannel> queryChannelsByDeviceId(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online);
@Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND channelId=#{channelId}")
DeviceChannel queryChannel(String deviceId, String channelId);
@Delete("DELETE FROM device_channel WHERE deviceId=#{deviceId}")
int cleanChannelsByDeviceId(String deviceId);
}

View File

@@ -1,24 +1,66 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 用于存储设备信息
*/
@Mapper
@Repository
public interface DeviceMapper {
@Select("SELECT * FROM device WHERE deviceId = #{deviceId}")
Device getDeviceByDeviceId(String deviceId);
@Insert("SELECT * FROM device WHERE deviceId = #{deviceId}")
@Insert("INSERT INTO device (" +
"deviceId, " +
"name, " +
"manufacturer, " +
"model, " +
"firmware, " +
"transport," +
"streamMode," +
"ip," +
"port," +
"hostAddress," +
"online" +
") VALUES (" +
"#{deviceId}," +
"#{name}," +
"#{manufacturer}," +
"#{model}," +
"#{firmware}," +
"#{transport}," +
"#{streamMode}," +
"#{ip}," +
"#{port}," +
"#{hostAddress}," +
"#{online}" +
")")
int add(Device device);
@Update("UPDATE device " +
"SET name=#{name}, " +
"manufacturer=#{manufacturer}," +
"model=#{model}," +
"firmware=#{firmware}, " +
"transport=#{transport}," +
"streamMode=#{streamMode}, " +
"ip=#{ip}, " +
"port=#{port}, " +
"hostAddress=#{hostAddress}, " +
"online=#{online} " +
"WHERE deviceId=#{deviceId}")
int update(Device device);
@Select("SELECT *, (SELECT count(0) FROM device_channel WHERE deviceId=de.deviceId) as channelCount FROM device de")
List<Device> getDevices();
@Delete("DELETE FROM device WHERE deviceId=#{deviceId}")
int del(String deviceId);
}

View File

@@ -6,7 +6,6 @@ import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -22,9 +21,6 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@Autowired
private RedisUtil redis;
@Autowired
private DeviceMapper deviceMapper;
@Autowired
private DeviceChannelMapper deviceChannelMapper;

View File

@@ -2,19 +2,17 @@ package com.genersoft.iot.vmp.storager.impl;
import java.util.*;
import com.genersoft.iot.vmp.common.PageResult;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import org.springframework.util.StringUtils;
/**
@@ -50,7 +48,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
* @return true创建成功 false创建失败
*/
@Override
public boolean create(Device device) {
public synchronized boolean create(Device device) {
return deviceMapper.add(device) > 0;
}
@@ -63,69 +61,26 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
* @return true更新成功 false更新失败
*/
@Override
public boolean updateDevice(Device device) {
// if (deviceMap.get(device.getDeviceId()) == null) {
// deviceMap.put(device.getDeviceId(), new HashMap<String, HashSet<String>>());
// }
// 更新device中的通道数量
// device.setChannelCount(deviceMap.get(device.getDeviceId()).size());
int result = deviceMapper.update(device);
// 存储device
return result > 0;
public synchronized boolean updateDevice(Device device) {
Device deviceByDeviceId = deviceMapper.getDeviceByDeviceId(device.getDeviceId());
if (deviceByDeviceId == null) {
return deviceMapper.add(device) > 0;
}else {
return deviceMapper.update(device) > 0;
}
}
@Override
public void updateChannel(String deviceId, DeviceChannel channel) {
public synchronized void updateChannel(String deviceId, DeviceChannel channel) {
String channelId = channel.getChannelId();
channel.setDeviceId(deviceId);
deviceChannelMapper.update(channel);
// HashMap<String, HashSet<String>> channelMap = deviceMap.get(deviceId);
// if (channelMap == null) return;
// // 作为父设备, 确定自己的子节点数
// if (channelMap.get(channelId) == null) {
// channelMap.put(channelId, new HashSet<String>());
// }else if (channelMap.get(channelId).size() > 0) {
// channel.setSubCount(channelMap.get(channelId).size());
// }
//
// // 存储通道
// redis.set(VideoManagerConstants.CACHEKEY_PREFIX + deviceId +
// "_" + channel.getChannelId() +
// "_" + (channel.getStatus() == 1 ? "on":"off") +
// "_" + (channelMap.get(channelId).size() > 0)+
// "_" + (StringUtils.isEmpty(channel.getParentId())?null:channel.getParentId()),
// channel);
// // 更新device中的通道数量
// Device device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceId);
// device.setChannelCount(deviceMap.get(deviceId).size());
// redis.set(VideoManagerConstants.DEVICE_PREFIX+device.getDeviceId(), device);
//
//
// // 如果有父设备,更新父设备内子节点数
// String parentId = channel.getParentId();
// if (!StringUtils.isEmpty(parentId) && !parentId.equals(deviceId)) {
//
// if (channelMap.get(parentId) == null) {
// channelMap.put(parentId, new HashSet<String>());
// }
// channelMap.get(parentId).add(channelId);
//
// DeviceChannel deviceChannel = queryChannel(deviceId, parentId);
// if (deviceChannel != null) {
// deviceChannel.setSubCount(channelMap.get(parentId).size());
// redis.set(VideoManagerConstants.CACHEKEY_PREFIX + deviceId +
// "_" + deviceChannel.getChannelId() +
// "_" + (deviceChannel.getStatus() == 1 ? "on":"off") +
// "_" + (channelMap.get(deviceChannel.getChannelId()).size() > 0)+
// "_" + (StringUtils.isEmpty(deviceChannel.getParentId())?null:deviceChannel.getParentId()),
// deviceChannel);
//
// }
// }
DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(deviceId, channelId);
if (deviceChannel == null) {
deviceChannelMapper.add(channel);
}else {
deviceChannelMapper.update(channel);
}
}
/**
@@ -140,179 +95,45 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
}
@Override
public PageResult queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, String online, int page, int count) {
public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count) {
// 获取到所有正在播放的流
List<DeviceChannel> result = new ArrayList<>();
PageResult pageResult = new PageResult<DeviceChannel>();
deviceChannelMapper.queryChannelsByDeviceId(deviceId);
// String queryContent = "*";
// if (!StringUtils.isEmpty(query)) queryContent = String.format("*%S*",query);
// String queryHasSubChannel = "*";
// if (hasSubChannel != null) queryHasSubChannel = hasSubChannel?"true":"false";
// String queryOnline = "*";
// if (!StringUtils.isEmpty(online)) queryOnline = online;
// String queryStr = VideoManagerConstants.CACHEKEY_PREFIX + deviceId +
// "_" + queryContent + // 搜索编号和名称
// "_" + queryOnline + // 搜索是否在线
// "_" + queryHasSubChannel + // 搜索是否含有子节点
// "_" + "*";
// List<Object> deviceChannelList = redis.scan(queryStr);
// //对查询结果排序,避免出现通道排列顺序乱序的情况
// Collections.sort(deviceChannelList,new Comparator<Object>(){
// @Override
// public int compare(Object o1, Object o2) {
// return o1.toString().compareToIgnoreCase(o2.toString());
// }
// });
// pageResult.setPage(page);
// pageResult.setCount(count);
// pageResult.setTotal(deviceChannelList.size());
// int maxCount = (page + 1 ) * count;
// if (deviceChannelList != null && deviceChannelList.size() > 0 ) {
// for (int i = page * count; i < (pageResult.getTotal() > maxCount ? maxCount : pageResult.getTotal() ); i++) {
// DeviceChannel deviceChannel = (DeviceChannel)redis.get((String)deviceChannelList.get(i));
// StreamInfo streamInfo = stringStreamInfoMap.get(deviceId + "_" + deviceChannel.getChannelId());
// deviceChannel.setPlay(streamInfo != null);
// if (streamInfo != null) deviceChannel.setStreamId(streamInfo.getStreamId());
// result.add(deviceChannel);
// }
// pageResult.setData(result);
// }
return pageResult;
PageHelper.startPage(page, count);
List<DeviceChannel> all = deviceChannelMapper.queryChannelsByDeviceId(deviceId, null, query, hasSubChannel, online);
return new PageInfo<>(all);
}
@Override
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) {
// List<DeviceChannel> result = new ArrayList<>();
//// List<Object> deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*");
// List<Object> deviceChannelList = redis.scan(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*");
//
// if (deviceChannelList != null && deviceChannelList.size() > 0 ) {
// for (int i = 0; i < deviceChannelList.size(); i++) {
// result.add((DeviceChannel)redis.get((String) deviceChannelList.get(i)));
// }
// }
return deviceChannelMapper.queryChannelsByDeviceId(deviceId);
return deviceChannelMapper.queryChannelsByDeviceId(deviceId, null,null, null, null);
}
@Override
public PageResult querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, String online, int page, int count) {
deviceChannelMapper.queryChannelsByDeviceId(deviceId, parentChannelId);
// List<DeviceChannel> allDeviceChannels = new ArrayList<>();
// String queryContent = "*";
// if (!StringUtils.isEmpty(query)) queryContent = String.format("*%S*",query);
// String queryHasSubChannel = "*";
// if (hasSubChannel != null) queryHasSubChannel = hasSubChannel?"true":"false";
// String queryOnline = "*";
// if (!StringUtils.isEmpty(online)) queryOnline = online;
// String queryStr = VideoManagerConstants.CACHEKEY_PREFIX + deviceId +
// "_" + queryContent + // 搜索编号和名称
// "_" + queryOnline + // 搜索是否在线
// "_" + queryHasSubChannel + // 搜索是否含有子节点
// "_" + parentChannelId;
//
//// List<Object> deviceChannelList = redis.keys(queryStr);
// List<Object> deviceChannelList = redis.scan(queryStr);
//
// if (deviceChannelList != null && deviceChannelList.size() > 0 ) {
// for (int i = 0; i < deviceChannelList.size(); i++) {
// DeviceChannel deviceChannel = (DeviceChannel)redis.get((String)deviceChannelList.get(i));
// if (deviceChannel.getParentId() != null && deviceChannel.getParentId().equals(parentChannelId)) {
// allDeviceChannels.add(deviceChannel);
// }
// }
// }
// int maxCount = (page + 1 ) * count;
PageResult pageResult = new PageResult<DeviceChannel>();
// pageResult.setPage(page);
// pageResult.setCount(count);
// pageResult.setTotal(allDeviceChannels.size());
//
// if (allDeviceChannels.size() > 0) {
// pageResult.setData(allDeviceChannels.subList(
// page * count, pageResult.getTotal() > maxCount ? maxCount : pageResult.getTotal()
// ));
// }
return pageResult;
}
public List<DeviceChannel> querySubChannels(String deviceId, String parentChannelId) {
List<DeviceChannel> allDeviceChannels = new ArrayList<>();
// List<Object> deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*");
// List<Object> deviceChannelList = redis.scan(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*");
//
// if (deviceChannelList != null && deviceChannelList.size() > 0 ) {
// for (int i = 0; i < deviceChannelList.size(); i++) {
// DeviceChannel deviceChannel = (DeviceChannel)redis.get((String)deviceChannelList.get(i));
// if (deviceChannel.getParentId() != null && deviceChannel.getParentId().equals(parentChannelId)) {
// allDeviceChannels.add(deviceChannel);
// }
// }
// }
return allDeviceChannels;
public PageInfo<DeviceChannel> querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, String online, int page, int count) {
PageHelper.startPage(page, count);
List<DeviceChannel> all = deviceChannelMapper.queryChannelsByDeviceId(deviceId, parentChannelId, null, null, null);
return new PageInfo<>(all);
}
@Override
public DeviceChannel queryChannel(String deviceId, String channelId) {
DeviceChannel deviceChannel = null;
return deviceChannelMapper.queryChannel(deviceId, channelId);
//// List<Object> deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + deviceId +
// List<Object> deviceChannelList = redis.scan(VideoManagerConstants.CACHEKEY_PREFIX + deviceId +
// "_" + channelId + "*");
// if (deviceChannelList != null && deviceChannelList.size() > 0 ) {
// deviceChannel = (DeviceChannel)redis.get((String)deviceChannelList.get(0));
// }
// return deviceChannel;
}
/**
* 获取多个设备
*
* @param deviceIds 设备ID数组
* @return List<Device> 设备对象数组
* @param page 当前页数
* @param count 每页数量
* @return PageInfo<Device> 分页设备对象数组
*/
@Override
public PageResult<Device> queryVideoDeviceList(String[] deviceIds, int page, int count) {
List<Device> devices = new ArrayList<>();
PageResult pageResult = new PageResult<Device>();
// pageResult.setPage(page);
// pageResult.setCount(count);
// Device device = null;
//
// if (deviceIds == null || deviceIds.length == 0) {
//
//// List<Object> deviceIdList = redis.keys(VideoManagerConstants.DEVICE_PREFIX+"*");
// List<Object> deviceIdList = redis.scan(VideoManagerConstants.DEVICE_PREFIX+"*");
// pageResult.setTotal(deviceIdList.size());
// int maxCount = (page + 1)* count;
// for (int i = page * count; i < (pageResult.getTotal() > maxCount ? maxCount : pageResult.getTotal() ); i++) {
// // devices.add((Device)redis.get((String)deviceIdList.get(i)));
// device =(Device)redis.get((String)deviceIdList.get(i));
// if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){
// // outline(device.getDeviceId());
// }
// devices.add(device);
// }
// } else {
// for (int i = 0; i < deviceIds.length; i++) {
// // devices.add((Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i]));
// device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i]);
// if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){
// // outline(device.getDeviceId());
// }
// devices.add(device);
// }
// }
// pageResult.setData(devices);
return pageResult;
public PageInfo<Device> queryVideoDeviceList(int page, int count) {
PageHelper.startPage(page, count);
List<Device> all = deviceMapper.getDevices();
return new PageInfo<>(all);
}
/**
@@ -323,26 +144,6 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
@Override
public List<Device> queryVideoDeviceList() {
// if (deviceIds == null || deviceIds.length == 0) {
//// List<Object> deviceIdList = redis.keys(VideoManagerConstants.DEVICE_PREFIX+"*");
// List<Object> deviceIdList = redis.scan(VideoManagerConstants.DEVICE_PREFIX+"*");
// for (int i = 0; i < deviceIdList.size(); i++) {
// device =(Device)redis.get((String)deviceIdList.get(i));
// if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){
// outline(device.getDeviceId());
// }
// devices.add(device);
// }
// } else {
// for (int i = 0; i < deviceIds.length; i++) {
// device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i]);
// if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){
// outline(device.getDeviceId());
// }
// devices.add(device);
// }
// }
List<Device> deviceList = deviceMapper.getDevices();
return deviceList;
}
@@ -367,9 +168,13 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
* @return true更新成功 false更新失败
*/
@Override
public boolean online(String deviceId) {
public synchronized boolean online(String deviceId) {
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
device.setOnline(1);
System.out.println("更新设备在线");
if (device == null) {
return false;
}
return deviceMapper.update(device) > 0;
}
@@ -380,14 +185,10 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
* @return true更新成功 false更新失败
*/
@Override
public boolean outline(String deviceId) {
// Device device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceId);
// if (device == null) return false;
// device.setOnline(0);
// return redis.set(VideoManagerConstants.DEVICE_PREFIX+device.getDeviceId(), device);
public synchronized boolean outline(String deviceId) {
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
device.setOnline(0);
System.out.println("更新设备离线");
return deviceMapper.update(device) > 0;
}