From 56996e2138bc6a50e716e66945c2773db02833f5 Mon Sep 17 00:00:00 2001
From: Lawrence <1934378145@qq.com>
Date: 星期四, 29 十月 2020 10:16:39 +0800
Subject: [PATCH] 修正拼写错误
---
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java | 63 ++++++++++++++++++-------------
1 files changed, 37 insertions(+), 26 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..ec19cd5 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
@@ -2,11 +2,7 @@
import java.io.ByteArrayInputStream;
import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import javax.sip.InvalidArgumentException;
import javax.sip.RequestEvent;
@@ -37,6 +33,7 @@
import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
+import org.springframework.util.StringUtils;
/**
* @Description:MESSAGE璇锋眰澶勭悊鍣�
@@ -76,8 +73,6 @@
* 澶勭悊MESSAGE璇锋眰
*
* @param evt
- * @param layer
- * @param transaction
*/
@Override
public void process(RequestEvent evt) {
@@ -127,7 +122,10 @@
device.setManufacturer(XmlUtil.getText(rootElement,"Manufacturer"));
device.setModel(XmlUtil.getText(rootElement,"Model"));
device.setFirmware(XmlUtil.getText(rootElement,"Firmware"));
- storager.update(device);
+ if (StringUtils.isEmpty(device.getStreamMode())){
+ device.setStreamMode("UDP");
+ }
+ storager.updateDevice(device);
RequestMessage msg = new RequestMessage();
msg.setDeviceId(deviceId);
@@ -147,7 +145,7 @@
try {
Element rootElement = getRootElement(evt);
Element deviceIdElement = rootElement.element("DeviceID");
- String deviceId = deviceIdElement.getText().toString();
+ String deviceId = deviceIdElement.getText();
Element deviceListElement = rootElement.element("DeviceList");
if (deviceListElement == null) {
return;
@@ -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();
@@ -170,18 +163,18 @@
if (channelDeviceElement == null) {
continue;
}
- String channelDeviceId = channelDeviceElement.getText().toString();
+ String channelDeviceId = channelDeviceElement.getText();
Element channdelNameElement = itemDevice.element("Name");
- String channelName = channdelNameElement != null ? channdelNameElement.getText().toString() : "";
+ String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim().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")) {
+ if(status.equals("ON") || status.equals("On")) {
deviceChannel.setStatus(1);
}
- if(status.equals("OFF")) {
+ if(status.equals("OFF") || status.equals("Off")) {
deviceChannel.setStatus(0);
}
@@ -192,7 +185,7 @@
deviceChannel.setBlock(XmlUtil.getText(itemDevice,"Block"));
deviceChannel.setAddress(XmlUtil.getText(itemDevice,"Address"));
deviceChannel.setParental(itemDevice.element("Parental") == null? 0:Integer.parseInt(XmlUtil.getText(itemDevice,"Parental")));
- deviceChannel.setParentId(XmlUtil.getText(itemDevice,"ParentId"));
+ deviceChannel.setParentId(XmlUtil.getText(itemDevice,"ParentID"));
deviceChannel.setSafetyWay(itemDevice.element("SafetyWay") == null? 0:Integer.parseInt(XmlUtil.getText(itemDevice,"SafetyWay")));
deviceChannel.setRegisterWay(itemDevice.element("RegisterWay") == null? 1:Integer.parseInt(XmlUtil.getText(itemDevice,"RegisterWay")));
deviceChannel.setCertNum(XmlUtil.getText(itemDevice,"CertNum"));
@@ -205,17 +198,25 @@
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")));
+ deviceChannel.setHasAudio(true); // 榛樿鍚湁闊抽锛屾挱鏀炬椂鍐嶆鏌ユ槸鍚︽湁闊抽鍙婃槸鍚AC
+ storager.updateChannel(device.getDeviceId(), deviceChannel);
}
- // 鏇存柊
- storager.update(device);
+
RequestMessage msg = new RequestMessage();
msg.setDeviceId(deviceId);
msg.setType(DeferredResultHolder.CALLBACK_CMD_CATALOG);
msg.setData(device);
deferredResultHolder.invokeResult(msg);
+
+ // 鍥炲200
+ if (offLineDetector.isOnline(deviceId)) {
+ responseAck(evt);
+ publisher.onlineEventPublish(deviceId, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE);
+ }
+
}
- } catch (DocumentException e) {
+ } catch (DocumentException | SipException | InvalidArgumentException | ParseException e) {
e.printStackTrace();
}
}
@@ -232,13 +233,18 @@
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);
+ if (StringUtils.isEmpty(device.getStreamMode())){
+ device.setStreamMode("UDP");
+ }
+ storager.updateDevice(device);
cmder.catalogQuery(device);
} catch (DocumentException e) {
e.printStackTrace();
@@ -303,9 +309,10 @@
record.setEndTime(DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(XmlUtil.getText(itemRecord,"EndTime")));
record.setSecrecy(itemRecord.element("Secrecy") == null? 0:Integer.parseInt(XmlUtil.getText(itemRecord,"Secrecy")));
record.setType(XmlUtil.getText(itemRecord,"Type"));
- record.setRecordId(XmlUtil.getText(itemRecord,"RecorderID"));
+ record.setRecorderId(XmlUtil.getText(itemRecord,"RecorderID"));
recordList.add(record);
}
+// recordList.sort(Comparator.naturalOrder());
recordInfo.setRecordList(recordList);
}
@@ -339,9 +346,13 @@
// 璧板埌杩欓噷锛屾湁浠ヤ笅鍙兘锛�1銆佹病鏈夊綍鍍忎俊鎭�,绗竴娆℃敹鍒皉ecordinfo鐨勬秷鎭嵆杩斿洖鍝嶅簲鏁版嵁锛屾棤redis鎿嶄綔
// 2銆佹湁褰曞儚鏁版嵁锛屼笖绗竴娆″嵆鏀跺埌瀹屾暣鏁版嵁锛岃繑鍥炲搷搴旀暟鎹紝鏃爎edis鎿嶄綔
// 3銆佹湁褰曞儚鏁版嵁锛屽湪瓒呮椂鏃堕棿鍐呮敹鍒板娆″寘缁勮鍚庢暟閲忚冻澶燂紝杩斿洖鏁版嵁
+
+ // 瀵硅褰曡繘琛屾帓搴�
RequestMessage msg = new RequestMessage();
msg.setDeviceId(deviceId);
msg.setType(DeferredResultHolder.CALLBACK_CMD_RECORDINFO);
+ // 鑷劧椤哄簭鎺掑簭, 鍏冪礌杩涜鍗囧簭鎺掑垪
+ recordInfo.getRecordList().sort(Comparator.naturalOrder());
msg.setData(recordInfo);
deferredResultHolder.invokeResult(msg);
} catch (DocumentException e) {
--
Gitblit v1.8.0