From 0eee65bc424cbdb348052ba4ef6b91add28bc6a4 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期三, 24 十一月 2021 10:02:47 +0800 Subject: [PATCH] 保存拉流代理返回结果添加streamInfo --- src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java | 98 ++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 89 insertions(+), 9 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 8354b56..0e24942 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,34 +1,42 @@ package com.genersoft.iot.vmp.storager.impl; -import java.util.*; - -import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; +import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; 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; +import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import com.genersoft.iot.vmp.storager.dao.*; 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; - -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.Transactional; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** - * @Description:瑙嗛璁惧鏁版嵁瀛樺偍-jdbc瀹炵幇 + * @description:瑙嗛璁惧鏁版嵁瀛樺偍-jdbc瀹炵幇 * @author: swwheihei * @date: 2020骞�5鏈�6鏃� 涓嬪崍2:31:42 */ @SuppressWarnings("rawtypes") @Component public class VideoManagerStoragerImpl implements IVideoManagerStorager { + + private Logger logger = LoggerFactory.getLogger(VideoManagerStoragerImpl.class); + @Autowired DataSourceTransactionManager dataSourceTransactionManager; @@ -65,6 +73,11 @@ @Autowired private VideoStreamSessionManager streamSession; + @Autowired + private MediaServerMapper mediaServerMapper; + + private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + /** * 鏍规嵁璁惧ID鍒ゆ柇璁惧鏄惁瀛樺湪 @@ -98,8 +111,11 @@ */ @Override public synchronized boolean updateDevice(Device device) { + String now = this.format.format(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; @@ -112,12 +128,25 @@ String channelId = channel.getChannelId(); channel.setDeviceId(deviceId); channel.setStreamId(streamSession.getStreamId(deviceId, channel.getChannelId())); + String now = this.format.format(System.currentTimeMillis()); + channel.setUpdateTime(now); DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(deviceId, channelId); if (deviceChannel == null) { + channel.setCreateTime(now); deviceChannelMapper.add(channel); }else { deviceChannelMapper.update(channel); } + } + + @Override + public void deviceChannelOnline(String deviceId, String channelId) { + deviceChannelMapper.online(deviceId, channelId); + } + + @Override + public void deviceChannelOffline(String deviceId, String channelId) { + deviceChannelMapper.offline(deviceId, channelId); } @Override @@ -166,6 +195,11 @@ return deviceChannelMapper.queryChannel(deviceId, channelId); } + + @Override + public int delChannel(String deviceId, String channelId) { + return deviceChannelMapper.del(deviceId, channelId); + } /** * 鑾峰彇澶氫釜璁惧 @@ -232,7 +266,7 @@ return false; } device.setOnline(1); - System.out.println("鏇存柊璁惧鍦ㄧ嚎"); + logger.info("鏇存柊璁惧鍦ㄧ嚎: " + deviceId); return deviceMapper.update(device) > 0; } @@ -244,11 +278,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; } /** @@ -434,6 +480,8 @@ boolean result = false; streamProxyItem.setStreamType("proxy"); streamProxyItem.setStatus(true); + String now = this.format.format(System.currentTimeMillis()); + streamProxyItem.setCreateTime(now); try { if (gbStreamMapper.add(streamProxyItem)<0 || streamProxyMapper.add(streamProxyItem) < 0) { //浜嬪姟鍥炴粴 @@ -442,6 +490,7 @@ result = true; dataSourceTransactionManager.commit(transactionStatus); //鎵嬪姩鎻愪氦 }catch (Exception e) { + logger.error("鍚戞暟鎹簱娣诲姞娴佷唬鐞嗗け璐ワ細", e); dataSourceTransactionManager.rollback(transactionStatus); } return result; @@ -540,7 +589,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++) { @@ -570,5 +619,36 @@ gbStreamMapper.setStatus(app, streamId, false); } + @Override + public void updateParentPlatformStatus(String platformGbID, boolean online) { + platformMapper.updateParentPlatformStatus(platformGbID, online); + } + @Override + public void updateMediaServer(MediaServerItem mediaServerItem) { + String now = this.format.format(System.currentTimeMillis()); + mediaServerItem.setUpdateTime(now); + if (mediaServerMapper.queryOne(mediaServerItem.getId()) != null) { + mediaServerMapper.update(mediaServerItem); + }else { + mediaServerItem.setCreateTime(now); + mediaServerMapper.add(mediaServerItem); + } + } + + @Override + public List<StreamProxyItem> getStreamProxyListForEnableInMediaServer(String id, boolean enable) { + return streamProxyMapper.selectForEnableInMediaServer(id, enable); + } + + + @Override + public Device queryVideoDeviceByChannelId( String channelId) { + Device result = null; + List<DeviceChannel> channelList = deviceChannelMapper.queryChannelByChannelId(channelId); + if (channelList.size() == 1) { + result = deviceMapper.getDeviceByDeviceId(channelList.get(0).getDeviceId()); + } + return result; + } } -- Gitblit v1.8.0