From 24c1f8a945c6fbcb0968e9d78cf97e74f2677802 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期一, 10 二月 2025 11:23:18 +0800
Subject: [PATCH] 修改bug

---
 guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/videoGateway/VideoGateway.java |   99 +++++++++++++++++++++++++++++++++++++------------
 1 files changed, 74 insertions(+), 25 deletions(-)

diff --git a/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/videoGateway/VideoGateway.java b/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/videoGateway/VideoGateway.java
index 7274d05..30bd8c6 100644
--- a/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/videoGateway/VideoGateway.java
+++ b/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/videoGateway/VideoGateway.java
@@ -9,6 +9,7 @@
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.stylefeng.guns.core.util.ToolUtil;
 import com.stylefeng.guns.modular.system.util.videoGateway.model.*;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
@@ -111,7 +112,7 @@
 		log.info("【获取车辆列表】请求参数:" + JSON.toJSONString(body));
 		post.body(JSON.toJSONString(body));
 		HttpResponse execute = post.execute();
-		if(401 == execute.getStatus()){
+		if(401 == execute.getStatus() || 403 == execute.getStatus()){
 			log.error("token失效,重新登录");
 			accountLogin = null;
 			if(num == 3){
@@ -165,7 +166,7 @@
 		log.info("【获取船舶列表】请求参数:" + JSON.toJSONString(body));
 		post.body(JSON.toJSONString(body));
 		HttpResponse execute = post.execute();
-		if(401 == execute.getStatus()){
+		if(401 == execute.getStatus() || 403 == execute.getStatus()){
 			log.error("token失效,重新登录");
 			if(num == 3){
 				log.error("token失效,请联系管理员");
@@ -206,7 +207,7 @@
 		post.body("{}");
 		log.info("【2018年协议车辆在线】请求参数:" + post.getUrl());
 		HttpResponse execute = post.execute();
-		if(401 == execute.getStatus()){
+		if(401 == execute.getStatus() || 403 == execute.getStatus()){
 			log.error("token失效,重新登录");
 			if(num == 3){
 				log.error("token失效,请联系管理员");
@@ -246,7 +247,7 @@
 		get.header("token", accountLogin.getToken());
 		log.info("【2023年协议车辆在线】请求参数:" + get.getUrl());
 		HttpResponse execute = get.execute();
-		if(401 == execute.getStatus()){
+		if(401 == execute.getStatus() || 403 == execute.getStatus()){
 			log.error("token失效,重新登录");
 			if(num == 3){
 				log.error("token失效,请联系管理员");
@@ -292,11 +293,11 @@
 		log.info("【2018年协议发送拍摄指令接口】请求参数:" + JSON.toJSONString(body));
 		post.body(JSON.toJSONString(body));
 		HttpResponse execute = post.execute();
-		if(401 == execute.getStatus()){
+		if(401 == execute.getStatus() || 403 == execute.getStatus()){
 			log.error("token失效,重新登录");
 			if(num == 3){
 				log.error("token失效,请联系管理员");
-				return null;
+				throw new RuntimeException("token失效,请联系管理员");
 			}
 			num++;
 			accountLogin = null;
@@ -307,10 +308,24 @@
 		Integer code = result.getInteger("code");
 		if(0 != code){
 			log.error(result.getString("msg"));
-			return null;
+			throw new RuntimeException("【2018年协议发送拍摄指令接口】失败:" + execute.body());
 		}
 		//返回文件ID
-		return result.getString("data");
+		String data = result.getString("data");
+		if(ToolUtil.isEmpty(data)){
+			if(num == 12){
+				log.error(result.getString("msg"));
+				throw new RuntimeException("【2018年协议发送拍摄指令接口】12次(1分钟)失败:" + execute.body());
+			}
+			num++;
+			try {
+				Thread.sleep(5000);
+			} catch (InterruptedException e) {
+				throw new RuntimeException(e);
+			}
+			return cameraShot2018(terminalId, channelId, num);
+		}
+		return data;
 	}
 	
 	
@@ -331,11 +346,11 @@
 		get.header("token", accountLogin.getToken());
 		log.info("【2023年协议发送拍摄指令接口】请求参数:" + get.getUrl());
 		HttpResponse execute = get.execute();
-		if(401 == execute.getStatus()){
+		if(401 == execute.getStatus() || 403 == execute.getStatus()){
 			log.error("token失效,重新登录");
 			if(num == 3){
 				log.error("token失效,请联系管理员");
-				return null;
+				throw new RuntimeException("token失效,请联系管理员");
 			}
 			num++;
 			accountLogin = null;
@@ -346,10 +361,24 @@
 		Integer code = result.getInteger("code");
 		if(0 != code){
 			log.error(result.getString("msg"));
-			return null;
+			throw new RuntimeException("【2023年协议发送拍摄指令接口】失败:" + execute.body());
 		}
 		//返回文件ID
-		return result.getString("data");
+		String data = result.getString("data");
+		if(ToolUtil.isEmpty(data)){
+			if(num == 12){
+				log.error(result.getString("msg"));
+				throw new RuntimeException("【2023年协议发送拍摄指令接口】12次(1分钟)失败:" + execute.body());
+			}
+			num++;
+			try {
+				Thread.sleep(5000);
+			} catch (InterruptedException e) {
+				throw new RuntimeException(e);
+			}
+			return cameraShot2023(vehicleId, vehicleType, terminalId, channelId, num);
+		}
+		return data;
 	}
 	
 	
@@ -368,11 +397,11 @@
 		get.header("token", accountLogin.getToken());
 		log.info("【2018年协议车辆获取拍摄图片】请求参数:" + get.getUrl());
 		HttpResponse execute = get.execute();
-		if(401 == execute.getStatus()){
+		if(401 == execute.getStatus() || 403 == execute.getStatus()){
 			log.error("token失效,重新登录");
 			if(num == 3){
 				log.error("token失效,请联系管理员");
-				return null;
+				throw new RuntimeException("token失效,请联系管理员");
 			}
 			num++;
 			accountLogin = null;
@@ -383,12 +412,22 @@
 		Integer code = result.getInteger("code");
 		if(0 != code){
 			log.error(result.getString("msg"));
-			return null;
+			throw new RuntimeException("【2018年协议车辆获取拍摄图片】失败:" + execute.body());
 		}
 		//图片地址
 		String data = result.getString("data");
-		if(null == data){
-			return null;
+		if(ToolUtil.isEmpty(data)){
+			if(num == 12){
+				log.error(result.getString("msg"));
+				throw new RuntimeException("【2018年协议车辆获取拍摄图片】12次(1分钟)失败:" + execute.body());
+			}
+			num++;
+			try {
+				Thread.sleep(5000);
+			} catch (InterruptedException e) {
+				throw new RuntimeException(e);
+			}
+			return getCameraShotByFileId2018(terminalId, fileId, num);
 		}
 		data = data.replaceAll(";", "");
 		return "https://zhyn-pic.cg.gz.gov.cn" + data;
@@ -409,11 +448,11 @@
 		get.header("token", accountLogin.getToken());
 		log.info("【2023年协议车辆获取拍摄图片】请求参数:" + get.getUrl());
 		HttpResponse execute = get.execute();
-		if(401 == execute.getStatus()){
+		if(401 == execute.getStatus() || 403 == execute.getStatus()){
 			log.error("token失效,重新登录");
 			if(num == 3){
 				log.error("token失效,请联系管理员");
-				return null;
+				throw new RuntimeException("token失效,请联系管理员");
 			}
 			num++;
 			accountLogin = null;
@@ -424,12 +463,22 @@
 		Integer code = result.getInteger("code");
 		if(0 != code){
 			log.error(result.getString("msg"));
-			return null;
+			throw new RuntimeException("【2023年协议车辆获取拍摄图片】失败:" + execute.body());
 		}
 		//图片地址
 		String data = result.getString("data");
-		if(null == data){
-			return null;
+		if(ToolUtil.isEmpty(data)){
+			if(num == 12){
+				log.error(result.getString("msg"));
+				throw new RuntimeException("【2023年协议车辆获取拍摄图片】12次(1分钟)失败:" + execute.body());
+			}
+			num++;
+			try {
+				Thread.sleep(5000);
+			} catch (InterruptedException e) {
+				throw new RuntimeException(e);
+			}
+			return getCameraShotByFileId2023(fileId, num);
 		}
 		data = data.replaceAll(";", "");
 		return "https://zhyn-pic.cg.gz.gov.cn" + data;
@@ -459,7 +508,7 @@
 		log.info("请求参数:" + JSON.toJSONString(body));
 		post.body(JSON.toJSONString(body));
 		HttpResponse execute = post.execute();
-		if(401 == execute.getStatus()){
+		if(401 == execute.getStatus() || 403 == execute.getStatus()){
 			log.error("token失效,重新登录");
 			if(num == 3){
 				log.error("token失效,请联系管理员");
@@ -501,8 +550,8 @@
 //		locationRealTimeInfoCache(0);
 		
 		
-		List<Vehicle> 粤AFX998 = VideoGateway.getVehicleList("粤AFX998", null, null, 0);
-		System.err.println(粤AFX998);
+		List<VehicleOnline> vehicleOnlines = queryRuntimeInfoByCache(0);
+		System.err.println(vehicleOnlines);
 	}
 	
 //	public static void main(String[] args) {

--
Gitblit v1.7.1