From 173428adf09179860a3cb1a88f46378fd98473b2 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期五, 28 二月 2025 18:49:35 +0800
Subject: [PATCH] 开发模型3业务逻辑

---
 guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/videoGateway/VideoGateway.java |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 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 30bd8c6..ee8f38d 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
@@ -535,6 +535,49 @@
 	}
 	
 	
+	/**
+	 * 验证当前位置是否在围栏内
+	 * @param longitude
+	 * @param latitude
+	 * @param num
+	 * @return
+	 */
+	public static boolean getFenceByPoint(String longitude, String latitude, int num) {
+		if(null == accountLogin){
+			accountLogin();
+		}
+		HttpRequest post = HttpUtil.createPost("https://zhyn.cg.gz.gov.cn/map/web/getFenceByPoint");
+		post.header("operate-terminal", "4");
+		post.header("token", accountLogin.getToken());
+		Map<String, Object> body = new HashMap<>();
+		body.put("longitude", longitude);
+		body.put("latitude", latitude);
+		body.put("type", "1");
+		log.info("【验证当前位置是否在围栏内】请求参数:" + JSON.toJSONString(body));
+		post.body(JSON.toJSONString(body));
+		HttpResponse execute = post.execute();
+		if(401 == execute.getStatus() || 403 == execute.getStatus()){
+			log.error("token失效,重新登录");
+			if(num == 3){
+				log.error("token失效,请联系管理员");
+				throw new RuntimeException("token失效,请联系管理员");
+			}
+			num++;
+			accountLogin = null;
+			return getFenceByPoint(longitude, latitude, num);
+		}
+		log.info("【验证当前位置是否在围栏内】返回结果:" + execute.body());
+		JSONObject result = JSON.parseObject(execute.body());
+		Integer code = result.getInteger("code");
+		if(0 != code){
+			log.error(result.getString("msg"));
+			throw new RuntimeException("【验证当前位置是否在围栏内】失败:" + execute.body());
+		}
+		Integer data = result.getInteger("data");
+		return 1 == data;
+	}
+	
+	
 	
 	public static void main(String[] args) {
 //		SM4 sm4 = SmUtil.sm4("EP77VsBj9yeOKpcO".getBytes());

--
Gitblit v1.7.1