Browse Source

修复代码

pull/458/merge
648540858 3 years ago
parent
commit
a030d00c88
  1. 7
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java
  2. 6
      src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java
  3. 58
      src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
  4. 16
      src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java
  5. 37
      src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
  6. 2
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java
  7. 46
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java

7
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java

@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler;
import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import org.dom4j.DocumentException; import org.dom4j.DocumentException;
@ -56,6 +57,9 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent
@Autowired @Autowired
private EventPublisher publisher; private EventPublisher publisher;
@Autowired
private IDeviceService deviceService;
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
responseMessageHandler.addHandler(cmdType, this); responseMessageHandler.addHandler(cmdType, this);
@ -82,7 +86,8 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent
if (StringUtils.isEmpty(device.getStreamMode())) { if (StringUtils.isEmpty(device.getStreamMode())) {
device.setStreamMode("UDP"); device.setStreamMode("UDP");
} }
storager.updateDevice(device); deviceService.updateDevice(device);
// storager.updateDevice(device);
RequestMessage msg = new RequestMessage(); RequestMessage msg = new RequestMessage();
msg.setKey(key); msg.setKey(key);

6
src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java

@ -104,4 +104,10 @@ public interface IDeviceService {
* @return 设备信息 * @return 设备信息
*/ */
Device getDeviceByHostAndPort(String host, int port); Device getDeviceByHostAndPort(String host, int port);
/**
* 更新设备
* @param device 设备信息
*/
void updateDevice(Device device);
} }

58
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java

@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.sip.DialogState; import javax.sip.DialogState;
import javax.sip.TimeoutEvent; import javax.sip.TimeoutEvent;
@ -248,4 +249,61 @@ public class DeviceServiceImpl implements IDeviceService {
public Device getDeviceByHostAndPort(String host, int port) { public Device getDeviceByHostAndPort(String host, int port) {
return deviceMapper.getDeviceByHostAndPort(host, port); return deviceMapper.getDeviceByHostAndPort(host, port);
} }
@Override
public void updateDevice(Device device) {
Device deviceInStore = deviceMapper.getDeviceByDeviceId(device.getDeviceId());
if (deviceInStore == null) {
logger.warn("更新设备时未找到设备信息");
return;
}
if (!StringUtils.isEmpty(device.getName())) {
deviceInStore.setName(device.getName());
}
if (!StringUtils.isEmpty(device.getCharset())) {
deviceInStore.setCharset(device.getCharset());
}
if (!StringUtils.isEmpty(device.getMediaServerId())) {
deviceInStore.setMediaServerId(device.getMediaServerId());
}
// 目录订阅相关的信息
if (device.getSubscribeCycleForCatalog() > 0) {
if (deviceInStore.getSubscribeCycleForCatalog() == 0 || deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) {
deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
// 开启订阅
addCatalogSubscribe(deviceInStore);
}
}else if (device.getSubscribeCycleForCatalog() == 0) {
if (deviceInStore.getSubscribeCycleForCatalog() != 0) {
deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
// 取消订阅
removeCatalogSubscribe(deviceInStore);
}
}
// 移动位置订阅相关的信息
if (device.getSubscribeCycleForMobilePosition() > 0) {
if (deviceInStore.getSubscribeCycleForMobilePosition() == 0 || deviceInStore.getSubscribeCycleForMobilePosition() != device.getSubscribeCycleForMobilePosition()) {
deviceInStore.setMobilePositionSubmissionInterval(device.getMobilePositionSubmissionInterval());
deviceInStore.setSubscribeCycleForMobilePosition(device.getSubscribeCycleForMobilePosition());
// 开启订阅
addMobilePositionSubscribe(deviceInStore);
}
}else if (device.getSubscribeCycleForMobilePosition() == 0) {
if (deviceInStore.getSubscribeCycleForMobilePosition() != 0) {
// 取消订阅
removeMobilePositionSubscribe(deviceInStore);
}
}
String now = DateUtil.getNow();
device.setUpdateTime(now);
device.setCharset(device.getCharset().toUpperCase());
device.setUpdateTime(DateUtil.getNow());
if (deviceMapper.update(device) > 0) {
redisCatchStorage.updateDevice(device);
}
}
} }

16
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java

@ -26,22 +26,6 @@ public interface IVideoManagerStorage {
*/ */
public boolean exists(String deviceId); public boolean exists(String deviceId);
/**
* 视频设备创建
*
* @param device 设备对象
* @return true创建成功 false创建失败
*/
public boolean create(Device device);
/**
* 视频设备更新
*
* @param device 设备对象
* @return true创建成功 false创建失败
*/
public boolean updateDevice(Device device);
/** /**
* 添加设备通道 * 添加设备通道
* *

37
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java

@ -102,43 +102,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return deviceMapper.getDeviceByDeviceId(deviceId) != null; return deviceMapper.getDeviceByDeviceId(deviceId) != null;
} }
/**
* 视频设备创建
*
* @param device 设备对象
* @return true创建成功 false创建失败
*/
@Override
public synchronized boolean create(Device device) {
redisCatchStorage.updateDevice(device);
return deviceMapper.add(device) > 0;
}
/**
* 视频设备更新
*
* @param device 设备对象
* @return true更新成功 false更新失败
*/
@Override
public synchronized boolean updateDevice(Device device) {
String now = DateUtil.getNow();
device.setUpdateTime(now);
Device deviceByDeviceId = deviceMapper.getDeviceByDeviceId(device.getDeviceId());
device.setCharset(device.getCharset().toUpperCase());
if (deviceByDeviceId == null) {
device.setCreateTime(now);
redisCatchStorage.updateDevice(device);
return deviceMapper.add(device) > 0;
}else {
redisCatchStorage.updateDevice(device);
return deviceMapper.update(device) > 0;
}
}
@Override @Override
public synchronized void updateChannel(String deviceId, DeviceChannel channel) { public synchronized void updateChannel(String deviceId, DeviceChannel channel) {
String channelId = channel.getChannelId(); String channelId = channel.getChannelId();

2
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java

@ -169,7 +169,7 @@ public class MobilePositionController {
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
device.setSubscribeCycleForMobilePosition(Integer.parseInt(expires)); device.setSubscribeCycleForMobilePosition(Integer.parseInt(expires));
device.setMobilePositionSubmissionInterval(Integer.parseInt(interval)); device.setMobilePositionSubmissionInterval(Integer.parseInt(interval));
storager.updateDevice(device); deviceService.updateDevice(device);
String result = msg; String result = msg;
if (deviceService.removeMobilePositionSubscribe(device)) { if (deviceService.removeMobilePositionSubscribe(device)) {
result += ",成功"; result += ",成功";

46
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java

@ -288,7 +288,8 @@ public class DeviceQuery {
public ResponseEntity<PageInfo> updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){ public ResponseEntity<PageInfo> updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
device.setStreamMode(streamMode); device.setStreamMode(streamMode);
storager.updateDevice(device); // storager.updateDevice(device);
deviceService.updateDevice(device);
return new ResponseEntity<>(null,HttpStatus.OK); return new ResponseEntity<>(null,HttpStatus.OK);
} }
@ -305,51 +306,12 @@ public class DeviceQuery {
public ResponseEntity<WVPResult<String>> updateDevice(Device device){ public ResponseEntity<WVPResult<String>> updateDevice(Device device){
if (device != null && device.getDeviceId() != null) { if (device != null && device.getDeviceId() != null) {
Device deviceInStore = storager.queryVideoDevice(device.getDeviceId());
if (!StringUtils.isEmpty(device.getName())) {
deviceInStore.setName(device.getName());
}
if (!StringUtils.isEmpty(device.getCharset())) {
deviceInStore.setCharset(device.getCharset());
}
if (!StringUtils.isEmpty(device.getMediaServerId())) {
deviceInStore.setMediaServerId(device.getMediaServerId());
}
// 目录订阅相关的信息
if (device.getSubscribeCycleForCatalog() > 0) {
if (deviceInStore.getSubscribeCycleForCatalog() == 0 || deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) {
deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
// 开启订阅
deviceService.addCatalogSubscribe(deviceInStore);
}
}else if (device.getSubscribeCycleForCatalog() == 0) {
if (deviceInStore.getSubscribeCycleForCatalog() != 0) {
deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
// 取消订阅
deviceService.removeCatalogSubscribe(deviceInStore);
}
}
// 移动位置订阅相关的信息
if (device.getSubscribeCycleForMobilePosition() > 0) {
if (deviceInStore.getSubscribeCycleForMobilePosition() == 0 || deviceInStore.getSubscribeCycleForMobilePosition() != device.getSubscribeCycleForMobilePosition()) {
deviceInStore.setMobilePositionSubmissionInterval(device.getMobilePositionSubmissionInterval());
deviceInStore.setSubscribeCycleForMobilePosition(device.getSubscribeCycleForMobilePosition());
// 开启订阅
deviceService.addMobilePositionSubscribe(deviceInStore);
}
}else if (device.getSubscribeCycleForMobilePosition() == 0) {
if (deviceInStore.getSubscribeCycleForMobilePosition() != 0) {
// 取消订阅
deviceService.removeMobilePositionSubscribe(deviceInStore);
}
}
// TODO 报警订阅相关的信息 // TODO 报警订阅相关的信息
storager.updateDevice(device); deviceService.updateDevice(device);
cmder.deviceInfoQuery(device); // cmder.deviceInfoQuery(device);
} }
WVPResult<String> result = new WVPResult<>(); WVPResult<String> result = new WVPResult<>();
result.setCode(0); result.setCode(0);

Loading…
Cancel
Save