From a4bfa94e3d97406c410e6975d9ab1b625ed05fe1 Mon Sep 17 00:00:00 2001 From: huliguo <2023611923@qq.com> Date: 星期三, 28 五月 2025 18:00:22 +0800 Subject: [PATCH] 新增任务管理、任务记录等搜索字段,可重复审核,添加导出任务记录字段 --- guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/videoGateway/VideoGateway.java | 200 +++++++++++++++++++++++++++++++++++++------------ 1 files changed, 150 insertions(+), 50 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 5f74528..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 @@ -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; @@ -36,10 +37,10 @@ public static SessionId getSessionId(){ HttpRequest get = HttpUtil.createGet("https://zhyn.cg.gz.gov.cn/api/cws-auth/v1/session-id/third-platform"); get.header("operate-terminal", "4"); - log.info("请求参数:" + get); + log.info("【获取 SessionId】请求参数:" + get); HttpResponse execute = get.execute(); String body = execute.body(); - log.info("返回结果:" + body); + log.info("【获取 SessionId】返回结果:" + body); JSONObject result = JSON.parseObject(body); Integer code = result.getInteger("code"); if(-1 == code){ @@ -70,10 +71,10 @@ String encryptHex = sm4.encryptHex("Lti52D@#&J6q"); body.put("pwd", encryptHex); body.put("sessionId", sessionId.getSessionId()); - log.info("请求参数:" + JSON.toJSONString(body) + "\npublicKey:" + sessionId.getPublicKey() + "\n加密key:" + sessionId.getKey()); + log.info("【登录】请求参数:" + JSON.toJSONString(body) + "\npublicKey:" + sessionId.getPublicKey() + "\n加密key:" + sessionId.getKey()); post.body(JSON.toJSONString(body)); HttpResponse execute = post.execute(); - log.info("返回结果:" + execute.body()); + log.info("【登录】返回结果:" + execute.body()); JSONObject result = JSON.parseObject(execute.body()); Integer code = result.getInteger("code"); if(0 != code){ @@ -108,10 +109,10 @@ if(StringUtils.isNotEmpty(companyName)){ body.put("companyName", companyName); } - log.info("请求参数:" + JSON.toJSONString(body)); + 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){ @@ -121,7 +122,7 @@ num++; return getVehicleList(vehicleNum, companyId, companyName, num); } - log.info("返回结果:" + execute.body()); + log.info("【获取车辆列表】返回结果:" + execute.body()); JSONObject result = JSON.parseObject(execute.body()); Integer code = result.getInteger("code"); if(0 != code){ @@ -162,10 +163,10 @@ if(StringUtils.isNotEmpty(companyName)){ body.put("companyName", companyName); } - log.info("请求参数:" + JSON.toJSONString(body)); + 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失效,请联系管理员"); @@ -175,7 +176,7 @@ accountLogin = null; return getShipList(shipNum, companyId, companyName, num); } - log.info("返回结果:" + execute.body()); + log.info("【获取船舶列表】返回结果:" + execute.body()); JSONObject result = JSON.parseObject(execute.body()); Integer code = result.getInteger("code"); if(0 != code){ @@ -200,12 +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失效,请联系管理员"); @@ -215,7 +217,7 @@ accountLogin = null; return queryRuntimeInfoByCache(num); } - log.info("返回结果:" + execute.body()); + log.info("【2018年协议车辆在线】返回结果:" + execute.body()); JSONObject result = JSON.parseObject(execute.body()); Integer code = result.getInteger("code"); if(0 != code){ @@ -240,11 +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失效,请联系管理员"); @@ -254,7 +257,7 @@ accountLogin = null; return locationRealTimeInfoCache(num); } - log.info("返回结果:" + execute.body()); + log.info("【2023年协议车辆在线】返回结果:" + execute.body()); JSONObject result = JSON.parseObject(execute.body()); Integer code = result.getInteger("code"); if(0 != code){ @@ -281,33 +284,48 @@ 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()); Map<String, Object> body = new HashMap<>(); body.put("channelId", channelId); - log.info("请求参数:" + JSON.toJSONString(body)); + 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; return cameraShot2018(terminalId, channelId, num); } - log.info("返回结果:" + execute.body()); + log.info("【2018年协议发送拍摄指令接口】返回结果:" + execute.body()); JSONObject result = JSON.parseObject(execute.body()); 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; } @@ -326,28 +344,41 @@ HttpRequest get = HttpUtil.createGet("https://zhyn.cg.gz.gov.cn/api/cws-business/biz-device-send-records/v1/cameraShot?vehicleId=" + vehicleId + "&vehicleType=" + vehicleType + "&terminalId=" + terminalId + "&channelId=" + channelId); get.header("operate-terminal", "4"); get.header("token", accountLogin.getToken()); - Map<String, Object> body = new HashMap<>(); - log.info("请求参数:" + get.getUrl()); + 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; return cameraShot2023(vehicleId, vehicleType, terminalId, channelId, num); } - log.info("返回结果:" + execute.body()); + log.info("【2023年协议发送拍摄指令接口】返回结果:" + execute.body()); JSONObject result = JSON.parseObject(execute.body()); 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; } @@ -361,33 +392,44 @@ 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("请求参数:" + get.getUrl()); + 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; return getCameraShotByFileId2018(terminalId, fileId, num); } - log.info("返回结果:" + execute.body()); + log.info("【2018年协议车辆获取拍摄图片】返回结果:" + execute.body()); JSONObject result = JSON.parseObject(execute.body()); 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 == 60){ + log.error(result.getString("msg")); + throw new RuntimeException("【2018年协议车辆获取拍摄图片】60次(1分钟)失败:" + execute.body()); + } + num++; + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + return getCameraShotByFileId2018(terminalId, fileId, num); } + data = data.replaceAll(";", ""); return "https://zhyn-pic.cg.gz.gov.cn" + data; } @@ -404,30 +446,41 @@ HttpRequest get = HttpUtil.createGet("https://zhyn.cg.gz.gov.cn/api/cws-business/biz-device-send-records/v1/getCameraShotById?id=" + fileId); get.header("operate-terminal", "4"); get.header("token", accountLogin.getToken()); - log.info("请求参数:" + get.getUrl()); + 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; return getCameraShotByFileId2023(fileId, num); } - log.info("返回结果:" + execute.body()); + log.info("【2023年协议车辆获取拍摄图片】返回结果:" + execute.body()); JSONObject result = JSON.parseObject(execute.body()); 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 == 60){ + log.error(result.getString("msg")); + throw new RuntimeException("【2023年协议车辆获取拍摄图片】60次(1分钟)失败:" + execute.body()); + } + num++; + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + return getCameraShotByFileId2023(fileId, num); } + data = data.replaceAll(";", ""); return "https://zhyn-pic.cg.gz.gov.cn" + data; } @@ -444,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<>(); @@ -455,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失效,请联系管理员"); @@ -482,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()); @@ -489,12 +585,16 @@ // String decryptStr = sm4.decryptStr("357b94ca60ce8140f3d22eceaaa5d71b0d25d6cd20c8218d9a3ddcd30881126d", CharsetUtil.CHARSET_UTF_8); // System.err.println(decryptStr); - accountLogin(); - System.err.println(accountLogin); +// accountLogin(); +// System.err.println(accountLogin); // getVehicleList(null, null, null); // getShipList(null, null, null); // queryRuntimeInfoByCache(); - locationRealTimeInfoCache(0); +// locationRealTimeInfoCache(0); + + + List<VehicleOnline> vehicleOnlines = queryRuntimeInfoByCache(0); + System.err.println(vehicleOnlines); } // public static void main(String[] args) { -- Gitblit v1.7.1