From 1af77ab5f7c11a4b3d59c1989b51b9fca29679ce Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 18 十月 2022 22:18:49 +0800
Subject: [PATCH] Merge pull request #645 from IKangXu/wvp-28181-2.0

---
 src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java
index 9bbe1d7..c817385 100644
--- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java
+++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java
@@ -1,13 +1,19 @@
 package com.genersoft.iot.vmp.web.gb28181;
 
 import com.alibaba.fastjson.JSONObject;
+import com.genersoft.iot.vmp.conf.exception.ControllerException;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
+import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+
+import javax.sip.InvalidArgumentException;
+import javax.sip.SipException;
+import java.text.ParseException;
 
 /**
  * API鍏煎锛氳澶囨帶鍒�
@@ -35,7 +41,7 @@
      * @return
      */
     @RequestMapping(value = "/ptz")
-    private JSONObject list(String serial,String command,
+    private void list(String serial,String command,
                             @RequestParam(required = false)Integer channel,
                             @RequestParam(required = false)String code,
                             @RequestParam(required = false)Integer speed){
@@ -48,9 +54,7 @@
         if (speed == null) {speed = 0;}
         Device device = storager.queryVideoDevice(serial);
         if (device == null) {
-            JSONObject result = new JSONObject();
-            result.put("error","device[ " + serial + " ]鏈壘鍒�");
-            return result;
+            throw new ControllerException(ErrorCode.ERROR100.getCode(), "device[ " + serial + " ]鏈壘鍒�");
         }
         int cmdCode = 0;
         switch (command){
@@ -91,7 +95,11 @@
                 break;
         }
         // 榛樿鍊� 50
-        cmder.frontEndCmd(device, code, cmdCode, speed, speed, speed);
-        return null;
+        try {
+            cmder.frontEndCmd(device, code, cmdCode, speed, speed, speed);
+        } catch (SipException | InvalidArgumentException | ParseException e) {
+            logger.error("[鍛戒护鍙戦�佸け璐 浜戝彴鎺у埗: {}", e.getMessage());
+            throw new ControllerException(ErrorCode.ERROR100.getCode(), "鍛戒护鍙戦�佸け璐�: " + e.getMessage());
+        }
     }
 }

--
Gitblit v1.8.0