From e1fcc1f21f6622871a5507fcd50aacfa99181879 Mon Sep 17 00:00:00 2001
From: 64850858 <648540858@qq.com>
Date: 星期四, 08 七月 2021 14:48:00 +0800
Subject: [PATCH] 补充swf文件
---
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java | 75 ++++++++++++++++++++++++++++++++-----
1 files changed, 65 insertions(+), 10 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
index 5d1cfc8..bbe8c2b 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
@@ -1,8 +1,10 @@
package com.genersoft.iot.vmp.storager.impl;
+import java.text.SimpleDateFormat;
import java.util.*;
import com.genersoft.iot.vmp.gb28181.bean.*;
+import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
@@ -10,6 +12,8 @@
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Component;
@@ -27,6 +31,9 @@
@SuppressWarnings("rawtypes")
@Component
public class VideoManagerStoragerImpl implements IVideoManagerStorager {
+
+ private Logger logger = LoggerFactory.getLogger(VideoManagerStoragerImpl.class);
+
@Autowired
DataSourceTransactionManager dataSourceTransactionManager;
@@ -59,6 +66,11 @@
@Autowired
private GbStreamMapper gbStreamMapper;
+
+ @Autowired
+ private VideoStreamSessionManager streamSession;
+
+ private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/**
@@ -93,8 +105,11 @@
*/
@Override
public synchronized boolean updateDevice(Device device) {
+ String now = this.format.format(new Date(System.currentTimeMillis()));
+ device.setUpdateTime(now);
Device deviceByDeviceId = deviceMapper.getDeviceByDeviceId(device.getDeviceId());
if (deviceByDeviceId == null) {
+ device.setCreateTime(now);
return deviceMapper.add(device) > 0;
}else {
return deviceMapper.update(device) > 0;
@@ -106,8 +121,12 @@
public synchronized void updateChannel(String deviceId, DeviceChannel channel) {
String channelId = channel.getChannelId();
channel.setDeviceId(deviceId);
+ channel.setStreamId(streamSession.getStreamId(deviceId, channel.getChannelId()));
+ String now = this.format.format(new Date(System.currentTimeMillis()));
+ channel.setUpdateTime(now);
DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(deviceId, channelId);
if (deviceChannel == null) {
+ channel.setCreateTime(now);
deviceChannelMapper.add(channel);
}else {
deviceChannelMapper.update(channel);
@@ -195,9 +214,22 @@
*/
@Override
public boolean delete(String deviceId) {
- int result = deviceMapper.del(deviceId);
-
- return result > 0;
+ TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
+ boolean result = false;
+ try {
+ if (platformChannelMapper.delChannelForDeviceId(deviceId) <0 // 鍒犻櫎涓庡浗鏍囧钩鍙扮殑鍏宠仈
+ || deviceChannelMapper.cleanChannelsByDeviceId(deviceId) < 0 // 鍒犻櫎浠栫殑閫氶亾
+ || deviceMapper.del(deviceId) < 0 // 绉婚櫎璁惧淇℃伅
+ ) {
+ //浜嬪姟鍥炴粴
+ dataSourceTransactionManager.rollback(transactionStatus);
+ }
+ result = true;
+ dataSourceTransactionManager.commit(transactionStatus); //鎵嬪姩鎻愪氦
+ }catch (Exception e) {
+ dataSourceTransactionManager.rollback(transactionStatus);
+ }
+ return result;
}
/**
@@ -213,7 +245,7 @@
return false;
}
device.setOnline(1);
- System.out.println("鏇存柊璁惧鍦ㄧ嚎");
+ logger.info("鏇存柊璁惧鍦ㄧ嚎: " + deviceId);
return deviceMapper.update(device) > 0;
}
@@ -225,11 +257,23 @@
*/
@Override
public synchronized boolean outline(String deviceId) {
- System.out.println("鏇存柊璁惧绂荤嚎: " + deviceId);
+ logger.info("鏇存柊璁惧绂荤嚎: " + deviceId);
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (device == null) return false;
device.setOnline(0);
return deviceMapper.update(device) > 0;
+ }
+
+ /**
+ * 鏇存柊鎵�鏈夎澶囩绾�
+ *
+ * @return true锛氭洿鏂版垚鍔� false锛氭洿鏂板け璐�
+ */
+ @Override
+ public synchronized boolean outlineForAll() {
+ logger.info("鏇存柊鎵�鏈夎澶囩绾�");
+ int result = deviceMapper.outlineForAll();
+ return result > 0;
}
/**
@@ -271,15 +315,21 @@
public boolean updateParentPlatform(ParentPlatform parentPlatform) {
int result = 0;
ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); // .getDeviceGBId());
- if ( platformMapper.getParentPlatById(parentPlatform.getServerGBId()) == null) {
+ if (parentPlatform.getId() == null ) {
result = platformMapper.addParentPlatform(parentPlatform);
-
if (parentPlatformCatch == null) {
parentPlatformCatch = new ParentPlatformCatch();
parentPlatformCatch.setParentPlatform(parentPlatform);
parentPlatformCatch.setId(parentPlatform.getServerGBId());
}
}else {
+ if (parentPlatformCatch == null) { // serverGBId 宸插彉鍖�
+ ParentPlatform parentPlatById = platformMapper.getParentPlatById(parentPlatform.getId());
+ // 浣跨敤鏃х殑鏌ュ嚭缂撳瓨ID
+ parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatById.getServerGBId());
+ parentPlatformCatch.setId(parentPlatform.getServerGBId());
+ redisCatchStorage.delPlatformCatchInfo(parentPlatById.getServerGBId());
+ }
result = platformMapper.updateParentPlatform(parentPlatform);
}
// 鏇存柊缂撳瓨
@@ -305,8 +355,8 @@
}
@Override
- public ParentPlatform queryParentPlatById(String platformGbId) {
- return platformMapper.getParentPlatById(platformGbId);
+ public ParentPlatform queryParentPlatByServerGBId(String platformGbId) {
+ return platformMapper.getParentPlatByServerGBId(platformGbId);
}
@Override
@@ -515,7 +565,7 @@
@Override
public void updateMediaList(List<StreamPushItem> streamPushItems) {
if (streamPushItems == null || streamPushItems.size() == 0) return;
- System.out.printf("updateMediaList: " + streamPushItems.size());
+ logger.info("updateMediaList: " + streamPushItems.size());
streamPushMapper.addAll(streamPushItems);
// TODO 寰呬紭鍖�
for (int i = 0; i < streamPushItems.size(); i++) {
@@ -544,4 +594,9 @@
public void mediaOutline(String app, String streamId) {
gbStreamMapper.setStatus(app, streamId, false);
}
+
+ @Override
+ public void updateParentPlatformStatus(String platformGbID, boolean online) {
+ platformMapper.updateParentPlatformStatus(platformGbID, online);
+ }
}
--
Gitblit v1.8.0