From 5e724cc0628554b949f0102bee6294db8a23c7f5 Mon Sep 17 00:00:00 2001
From: wangyimeng <421132955@qq.com>
Date: 星期三, 06 七月 2022 15:33:43 +0800
Subject: [PATCH] Merge branch 'wvp-28181-2.0' of https://github.com/mrjackwang/wvp-GB28181-pro into wvp-28181-2.0
---
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java | 117 +++++++++++++++++++++++++++++-----------------------------
1 files changed, 59 insertions(+), 58 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
index 661a69b..9a5be6e 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
@@ -13,6 +13,7 @@
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.storager.dao.*;
import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
+import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@@ -24,12 +25,13 @@
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
-import java.text.SimpleDateFormat;
import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
-/**
+/**
* 瑙嗛璁惧鏁版嵁瀛樺偍-jdbc瀹炵幇
* swwheihei
* 2020骞�5鏈�6鏃� 涓嬪崍2:31:42
@@ -91,9 +93,6 @@
@Autowired
private ParentPlatformMapper parentPlatformMapper;
- private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
-
/**
* 鏍规嵁璁惧ID鍒ゆ柇璁惧鏄惁瀛樺湪
*
@@ -105,45 +104,6 @@
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 = this.format.format(System.currentTimeMillis());
- 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
public synchronized void updateChannel(String deviceId, DeviceChannel channel) {
String channelId = channel.getChannelId();
@@ -152,7 +112,7 @@
if (streamInfo != null) {
channel.setStreamId(streamInfo.getStream());
}
- String now = this.format.format(System.currentTimeMillis());
+ String now = DateUtil.getNow();
channel.setUpdateTime(now);
DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(deviceId, channelId);
if (deviceChannel == null) {
@@ -178,7 +138,7 @@
if (streamInfo != null) {
channel.setStreamId(streamInfo.getStream());
}
- String now = this.format.format(System.currentTimeMillis());
+ String now = DateUtil.getNow();
channel.setUpdateTime(now);
channel.setCreateTime(now);
addChannels.add(channel);
@@ -193,7 +153,7 @@
if (streamInfo != null) {
channel.setStreamId(streamInfo.getStream());
}
- String now = this.format.format(System.currentTimeMillis());
+ String now = DateUtil.getNow();
channel.setUpdateTime(now);
if (channelsInStore.get(channel.getChannelId()) != null) {
updateChannels.add(channel);
@@ -236,20 +196,30 @@
@Override
public boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList) {
- if (deviceChannelList == null) {
+ if (CollectionUtils.isEmpty(deviceChannelList)) {
return false;
+ }
+ List<DeviceChannel> allChannelInPlay = deviceChannelMapper.getAllChannelInPlay();
+ Map<String,DeviceChannel> allChannelMapInPlay = new ConcurrentHashMap<>();
+ if (allChannelInPlay.size() > 0) {
+ for (DeviceChannel deviceChannel : allChannelInPlay) {
+ allChannelMapInPlay.put(deviceChannel.getChannelId(), deviceChannel);
+ }
}
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
// 鏁版嵁鍘婚噸
List<DeviceChannel> channels = new ArrayList<>();
StringBuilder stringBuilder = new StringBuilder();
Map<String, Integer> subContMap = new HashMap<>();
- if (deviceChannelList != null && deviceChannelList.size() > 1) {
+ if (deviceChannelList.size() > 1) {
// 鏁版嵁鍘婚噸
Set<String> gbIdSet = new HashSet<>();
for (DeviceChannel deviceChannel : deviceChannelList) {
if (!gbIdSet.contains(deviceChannel.getChannelId())) {
gbIdSet.add(deviceChannel.getChannelId());
+ if (allChannelMapInPlay.containsKey(deviceChannel.getChannelId())) {
+ deviceChannel.setStreamId(allChannelMapInPlay.get(deviceChannel.getChannelId()).getStreamId());
+ }
channels.add(deviceChannel);
if (!StringUtils.isEmpty(deviceChannel.getParentId())) {
if (subContMap.get(deviceChannel.getParentId()) == null) {
@@ -276,6 +246,10 @@
}
if (stringBuilder.length() > 0) {
logger.info("[鐩綍鏌ヨ]鏀跺埌鐨勬暟鎹瓨鍦ㄩ噸澶嶏細 {}" , stringBuilder);
+ }
+ if(CollectionUtils.isEmpty(channels)){
+ logger.info("閫氶亾閲嶈锛屾暟鎹负绌�={}" , deviceChannelList);
+ return false;
}
try {
int cleanChannelsResult = deviceChannelMapper.cleanChannelsNotInList(deviceId, channels);
@@ -340,10 +314,18 @@
}
@Override
- public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count) {
+ public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count) {
// 鑾峰彇鍒版墍鏈夋鍦ㄦ挱鏀剧殑娴�
PageHelper.startPage(page, count);
- List<DeviceChannel> all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online);
+ List<DeviceChannel> all;
+ if (catalogUnderDevice != null && catalogUnderDevice) {
+ all = deviceChannelMapper.queryChannels(deviceId, deviceId, query, hasSubChannel, online);
+ // 娴峰悍璁惧鐨刾arentId鏄疭IP id
+ List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, sipConfig.getId(), query, hasSubChannel, online);
+ all.addAll(deviceChannels);
+ }else {
+ all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online);
+ }
return new PageInfo<>(all);
}
@@ -455,7 +437,9 @@
public synchronized boolean outline(String deviceId) {
logger.info("鏇存柊璁惧绂荤嚎: " + deviceId);
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
- if (device == null) return false;
+ if (device == null) {
+ return false;
+ }
device.setOnline(0);
redisCatchStorage.updateDevice(device);
return deviceMapper.update(device) > 0;
@@ -488,6 +472,9 @@
*/
@Override
public synchronized boolean insertMobilePosition(MobilePosition mobilePosition) {
+ if (mobilePosition.getDeviceId().equals(mobilePosition.getChannelId())) {
+ mobilePosition.setChannelId(null);
+ }
return deviceMobilePositionMapper.insertNewPosition(mobilePosition) > 0;
}
@@ -709,6 +696,7 @@
* 鍒犻櫎鎸囧畾璁惧鐨勬墍鏈夌Щ鍔ㄤ綅缃�
* @param deviceId
*/
+ @Override
public int clearMobilePositionsByDeviceId(String deviceId) {
return deviceMobilePositionMapper.clearMobilePositionsByDeviceId(deviceId);
}
@@ -724,9 +712,8 @@
boolean result = false;
streamProxyItem.setStreamType("proxy");
streamProxyItem.setStatus(true);
- String now = this.format.format(System.currentTimeMillis());
+ String now = DateUtil.getNow();
streamProxyItem.setCreateTime(now);
- streamProxyItem.setCreateStamp(System.currentTimeMillis());
try {
if (streamProxyMapper.add(streamProxyItem) > 0) {
if (!StringUtils.isEmpty(streamProxyItem.getGbId())) {
@@ -854,7 +841,9 @@
@Override
public void updateMediaList(List<StreamPushItem> streamPushItems) {
- if (streamPushItems == null || streamPushItems.size() == 0) return;
+ if (streamPushItems == null || streamPushItems.size() == 0) {
+ return;
+ }
logger.info("updateMediaList: " + streamPushItems.size());
streamPushMapper.addAll(streamPushItems);
// TODO 寰呬紭鍖�
@@ -895,6 +884,11 @@
@Override
public int removeMedia(String app, String stream) {
return streamPushMapper.del(app, stream);
+ }
+
+ @Override
+ public StreamPushItem getMedia(String app, String stream) {
+ return streamPushMapper.selectOne(app, stream);
}
@Override
@@ -1014,7 +1008,7 @@
@Override
public int setDefaultCatalog(String platformId, String catalogId) {
- return platformMapper.setDefaultCatalog(platformId, catalogId);
+ return platformMapper.setDefaultCatalog(platformId, catalogId, DateUtil.getNow());
}
@Override
@@ -1127,7 +1121,14 @@
}
@Override
- public void updateChannelPotion(String deviceId, String channelId, double longitude, double latitude) {
- deviceChannelMapper.updatePotion(deviceId, channelId, longitude, latitude);
+ public void updateChannelPosition(DeviceChannel deviceChannel) {
+ if (deviceChannel.getChannelId().equals(deviceChannel.getDeviceId())) {
+ deviceChannel.setChannelId(null);
+ }
+ if (deviceChannel.getGpsTime() == null) {
+ deviceChannel.setGpsTime(DateUtil.getNow());
+ }
+
+ deviceChannelMapper.updatePosition(deviceChannel);
}
}
--
Gitblit v1.8.0