From 92022f8a8b7bccc865c47bd8cfafaffb91c2799c Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 13 十月 2022 22:18:06 +0800
Subject: [PATCH] Merge pull request #640 from duzeng/wvp-28181-2.0

---
 src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 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 260047f..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.IVideoManagerStorager;
+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鍏煎锛氳澶囨帶鍒�
@@ -23,7 +29,7 @@
     private SIPCommander cmder;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     /**
      * 璁惧鎺у埗 - 浜戝彴鎺у埗
@@ -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){
@@ -44,11 +50,11 @@
             logger.debug("妯℃嫙鎺ュ彛> 璁惧浜戝彴鎺у埗 API璋冪敤锛宒eviceId锛歿} 锛宑hannelId锛歿} 锛宑ommand锛歿} 锛宻peed锛歿} ",
                     serial, code, command, speed);
         }
+        if (channel == null) {channel = 0;}
+        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){
@@ -89,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