Commit 7211bd8d7f910e12e76d986dbae0ce3aa2db9937

Authored by xp.Huang
1 parent 609f0f5b

fix: 海康ISC平台调用异常处理

@@ -51,26 +51,29 @@ public class HikVisionArtemisPostUtils { @@ -51,26 +51,29 @@ public class HikVisionArtemisPostUtils {
51 //返回url地址 51 //返回url地址
52 if (StringUtils.isNotEmpty(result)) { 52 if (StringUtils.isNotEmpty(result)) {
53 JsonNode json = JacksonUtil.toJsonNode(result); 53 JsonNode json = JacksonUtil.toJsonNode(result);
54 - if(json.get("code").asText().equals("0")){  
55 - json = json.get("data");  
56 - String message = null;  
57 - if(null == json || json.get("url") == null){  
58 - if(null == json){  
59 - message = ErrorMessage.HIKVISION_GET_URL_ERROR.getMessage();  
60 - }else if(json.get("url") == null && Objects.equals(protocolType.getValue(),  
61 - ProtocolType.HLSS.getValue())){  
62 - message = ErrorMessage.VIDEO_PLATFORM_NEED_ENABLE_HLS_HTTPS.getMessage(); 54 + if(null!=json.get("code")){
  55 + if(json.get("code").asText().equals("0")){
  56 + json = json.get("data");
  57 + String message = null;
  58 + if(null == json || json.get("url") == null){
  59 + if(null == json){
  60 + message = ErrorMessage.HIKVISION_GET_URL_ERROR.getMessage();
  61 + }else if(json.get("url") == null && Objects.equals(protocolType.getValue(),
  62 + ProtocolType.HLSS.getValue())){
  63 + message = ErrorMessage.VIDEO_PLATFORM_NEED_ENABLE_HLS_HTTPS.getMessage();
  64 + }
  65 + throw new TkDataValidationException(message);
63 } 66 }
64 - throw new TkDataValidationException(message); 67 + VideoUrlUtils.putVideoUrl(key,json.get("url").textValue(), LocalDateTime.now().plusMinutes(5));
  68 + return json.get("url").textValue();
  69 + }else{
  70 + String errorCode = json.get("code").asText();
  71 + String msg = json.get("msg").asText();
  72 + throw new TkDataValidationException(String.format(ErrorMessage.HIKVISION_API_ERROR.getMessage(),msg,errorCode));
65 } 73 }
66 - VideoUrlUtils.putVideoUrl(key,json.get("url").textValue(), LocalDateTime.now().plusMinutes(5));  
67 - return json.get("url").textValue();  
68 }else{ 74 }else{
69 - String errorCode = json.get("code").asText();  
70 - String msg = json.get("msg").asText();  
71 - throw new TkDataValidationException(String.format(ErrorMessage.HIKVISION_API_ERROR.getMessage(),msg,errorCode)); 75 + throw new TkDataValidationException(ErrorMessage.VIDEO_PLATFORM_CONFIG_ERROR.getMessage());
72 } 76 }
73 -  
74 } else { 77 } else {
75 throw new TkDataValidationException(ErrorMessage.VIDEO_PLATFORM_CONFIG_ERROR.getMessage()); 78 throw new TkDataValidationException(ErrorMessage.VIDEO_PLATFORM_CONFIG_ERROR.getMessage());
76 } 79 }