From 6f372b9d09a4b3519a3966a62d58d95805d261c2 Mon Sep 17 00:00:00 2001 From: huliguo <2023611923@qq.com> Date: 星期四, 29 五月 2025 22:49:48 +0800 Subject: [PATCH] 下载字段status --- guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/videoGateway/VideoGateway.java | 83 +++++++++++++++++++++++++++++++---------- 1 files changed, 63 insertions(+), 20 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 3dd55af..6479114 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 @@ -112,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){ @@ -166,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失效,请联系管理员"); @@ -201,13 +201,13 @@ if(null == accountLogin){ accountLogin(); } - HttpRequest post = HttpUtil.createPost("https://zhyn.cg.gz.gov.cn/map/web/map/queryRuntimeInfoByCache"); + HttpRequest post = HttpUtil.createPost("https://zhyn.cg.gz.gov.cn/api/muck-core/web/map/queryRuntimeInfoByCache"); post.header("operate-terminal", "4"); post.header("token", accountLogin.getToken()); 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失效,请联系管理员"); @@ -242,12 +242,12 @@ if(null == accountLogin){ accountLogin(); } - HttpRequest get = HttpUtil.createGet("https://zhyn.cg.gz.gov.cn/jttweb/api/v1/location/locationRealTimeInfoCache"); + HttpRequest get = HttpUtil.createGet("https://zhyn.cg.gz.gov.cn/api/jtt-web/jttweb/api/v1/location/locationRealTimeInfoCache"); get.header("operate-terminal", "4"); 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失效,请联系管理员"); @@ -284,7 +284,7 @@ if(null == accountLogin){ accountLogin(); } - HttpRequest post = HttpUtil.createPost("https://zhyn.cg.gz.gov.cn/map/web/vehicleCtrl/" + terminalId + "/cameraShot"); + HttpRequest post = HttpUtil.createPost("https://zhyn.cg.gz.gov.cn/api/muck-core/web/vehicleCtrl/" + terminalId + "/cameraShot"); post.header("operate-terminal", "4"); post.header("token", accountLogin.getToken()); log.info("【2018年协议发送拍摄指令接口】请求地址:" + post.getUrl()); @@ -293,7 +293,7 @@ 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失效,请联系管理员"); @@ -346,7 +346,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失效,请联系管理员"); @@ -392,12 +392,12 @@ if(null == accountLogin){ accountLogin(); } - HttpRequest get = HttpUtil.createGet("https://zhyn.cg.gz.gov.cn/map/web/vehicleCtrl/getCameraShotById?terminalId=" + terminalId + "&id=" + fileId); + HttpRequest get = HttpUtil.createGet("https://zhyn.cg.gz.gov.cn/api/muck-core/web/vehicleCtrl/getCameraShotById?terminalId=" + terminalId + "&id=" + fileId); get.header("operate-terminal", "4"); 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失效,请联系管理员"); @@ -417,13 +417,13 @@ //图片地址 String data = result.getString("data"); if(ToolUtil.isEmpty(data)){ - if(num == 12){ + if(num == 60){ log.error(result.getString("msg")); - throw new RuntimeException("【2018年协议车辆获取拍摄图片】12次(1分钟)失败:" + execute.body()); + throw new RuntimeException("【2018年协议车辆获取拍摄图片】60次(1分钟)失败:" + execute.body()); } num++; try { - Thread.sleep(5000); + Thread.sleep(1000); } catch (InterruptedException e) { throw new RuntimeException(e); } @@ -448,7 +448,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失效,请联系管理员"); @@ -468,13 +468,13 @@ //图片地址 String data = result.getString("data"); if(ToolUtil.isEmpty(data)){ - if(num == 12){ + if(num == 60){ log.error(result.getString("msg")); - throw new RuntimeException("【2023年协议车辆获取拍摄图片】12次(1分钟)失败:" + execute.body()); + throw new RuntimeException("【2023年协议车辆获取拍摄图片】60次(1分钟)失败:" + execute.body()); } num++; try { - Thread.sleep(5000); + Thread.sleep(1000); } catch (InterruptedException e) { throw new RuntimeException(e); } @@ -497,7 +497,7 @@ if(null == accountLogin){ accountLogin(); } - HttpRequest post = HttpUtil.createPost("https://zhyn.cg.gz.gov.cn/map/web/map/getTrackInfoByVehicleNum"); + HttpRequest post = HttpUtil.createPost("https://zhyn.cg.gz.gov.cn/api/muck-core/web/map/getTrackInfoByVehicleNum"); post.header("operate-terminal", "4"); post.header("token", accountLogin.getToken()); Map<String, Object> body = new HashMap<>(); @@ -508,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失效,请联系管理员"); @@ -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