From da14c7f24c61cf9027a02d8e566ab89116136f19 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期五, 25 九月 2020 17:22:22 +0800
Subject: [PATCH] 拆分redis中device与channel的存储方式 支持分页 接口直接返回播放地址

---
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java |   21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
index 7038590..e9f5906 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
@@ -76,8 +76,6 @@
 	 * 澶勭悊MESSAGE璇锋眰
 	 *  
 	 * @param evt
-	 * @param layer
-	 * @param transaction  
 	 */  
 	@Override
 	public void process(RequestEvent evt) {
@@ -127,7 +125,7 @@
 			device.setManufacturer(XmlUtil.getText(rootElement,"Manufacturer"));
 			device.setModel(XmlUtil.getText(rootElement,"Model"));
 			device.setFirmware(XmlUtil.getText(rootElement,"Firmware"));
-			storager.update(device);
+			storager.updateDevice(device);
 			
 			RequestMessage msg = new RequestMessage();
 			msg.setDeviceId(deviceId);
@@ -158,11 +156,6 @@
 				if (device == null) {
 					return;
 				}
-				Map<String, DeviceChannel> channelMap = device.getChannelMap();
-				if (channelMap == null) {
-					channelMap = new HashMap<String, DeviceChannel>(5);
-					device.setChannelMap(channelMap);
-				}
 				// 閬嶅巻DeviceList
 				while (deviceListIterator.hasNext()) {
 					Element itemDevice = deviceListIterator.next();
@@ -175,7 +168,7 @@
 					String channelName = channdelNameElement != null ? channdelNameElement.getText().toString() : "";
 					Element statusElement = itemDevice.element("Status");
 					String status = statusElement != null ? statusElement.getText().toString() : "ON";
-					DeviceChannel deviceChannel = channelMap.containsKey(channelDeviceId) ? channelMap.get(channelDeviceId) : new DeviceChannel();
+					DeviceChannel deviceChannel = new DeviceChannel();
 					deviceChannel.setName(channelName);
 					deviceChannel.setChannelId(channelDeviceId);
 					if(status.equals("ON")) {
@@ -205,10 +198,12 @@
 					deviceChannel.setPassword(XmlUtil.getText(itemDevice,"Password"));
 					deviceChannel.setLongitude(itemDevice.element("Longitude") == null? 0.00:Double.parseDouble(XmlUtil.getText(itemDevice,"Longitude")));
 					deviceChannel.setLatitude(itemDevice.element("Latitude") == null? 0.00:Double.parseDouble(XmlUtil.getText(itemDevice,"Latitude")));
-					channelMap.put(channelDeviceId, deviceChannel);
+					deviceChannel.setPTZType(itemDevice.element("PTZType") == null? 0:Integer.parseInt(XmlUtil.getText(itemDevice,"PTZType")));
+					storager.updateChannel(device.getDeviceId(), deviceChannel);
 				}
 				// 鏇存柊
-				storager.update(device);
+				storager.updateDevice(device);
+
 				RequestMessage msg = new RequestMessage();
 				msg.setDeviceId(deviceId);
 				msg.setType(DeferredResultHolder.CALLBACK_CMD_CATALOG);
@@ -232,13 +227,15 @@
 			
 			Device device = storager.queryVideoDevice(deviceId);
 			if (device == null) {
+				// TODO 涔熷彲鑳芥槸閫氶亾
+//				storager.queryChannel(deviceId)
 				return;
 			}
 			device.setName(XmlUtil.getText(rootElement,"DeviceName"));
 			device.setManufacturer(XmlUtil.getText(rootElement,"Manufacturer"));
 			device.setModel(XmlUtil.getText(rootElement,"Model"));
 			device.setFirmware(XmlUtil.getText(rootElement,"Firmware"));
-			storager.update(device);
+			storager.updateDevice(device);
 			cmder.catalogQuery(device);
 		} catch (DocumentException e) {
 			e.printStackTrace();

--
Gitblit v1.8.0