Quellcode durchsuchen

fix(route): 解决车辆定位接口异常处理问题

- 在 getCurrentLocation 方法中添加异常捕获和错误状态返回
- 当中交兴路接口返回空数据时抛出异常并记录错误信息
- 调整 DataExchangeService 超时参数从 (5000, 8000) 改为 (3000, 5000)
- 更新 .gitignore 文件添加 /out/ 目录忽略规则
- 修复 pom.xml 中 artifactId 缺失问题
xiaosonghong vor 1 Monat
Ursprung
Commit
54e416065a

+ 2 - 1
.gitignore

@@ -5,4 +5,5 @@ rebel.xml
 .rebel.xml.bak
 out/artifacts/
 dil-api.iml
-src/test
+src/test
+/out/

+ 1 - 1
pom.xml

@@ -5,7 +5,7 @@
     <modelVersion>4.0.0</modelVersion>
 
     <groupId>org.example</groupId>
-    <artifactId></artifactId>
+    <artifactId>otms</artifactId>
     <version>1.11</version>
 
     <parent>

+ 14 - 5
src/main/java/com/steerinfo/dil/controller/OffSiteTransportationController.java

@@ -552,11 +552,20 @@ public class OffSiteTransportationController extends BaseRESTfulController {
     }
     @GetMapping("/getCurrentLocation")
     public RESTfulResult getCurrentLocation(@RequestParam("capcityNumber") String capcityNumber) throws Exception {
-           CurrentLocationResult currentLocationResult = routeService.getCurrentLocation(capcityNumber);
-           if(currentLocationResult!=null && currentLocationResult.getStatus() != null){
-               currentLocationResult.setStatusStr();
-           }
-           return success(currentLocationResult);
+        CurrentLocationResult currentLocationResult;
+        try {
+            System.out.println("获取车辆"+ capcityNumber +"定位");
+            currentLocationResult = routeService.getCurrentLocation(capcityNumber);
+            if(currentLocationResult!=null && currentLocationResult.getStatus() != null){
+                currentLocationResult.setStatusStr();
+            }
+        } catch (Exception e) {
+            currentLocationResult = new CurrentLocationResult();
+            currentLocationResult.setStatus(1002);
+            currentLocationResult.setStatusStr();
+            System.out.println("获取车辆"+ capcityNumber +"定位失败:"+e.getMessage());
+        }
+        return success(currentLocationResult);
     }
     //在途订单列表
     @PostMapping("/transportationPerformance")

+ 3 - 0
src/main/java/com/steerinfo/route/service/impl/RouteServiceImpl.java

@@ -904,6 +904,9 @@ public class RouteServiceImpl implements RouteService {
     public CurrentLocationResult getCurrentLocation(String capcityNumber) throws Exception {
         String json = zhongJiaoXingLu.vLastLocationV3(capcityNumber);
         CurrentLocationResult currentLocationResult = new CurrentLocationResult();
+        if(StringUtils.isEmpty(json)){
+            throw new Exception("调用中交兴路接口失败");
+        }
         try {
             currentLocationResult = JSONObject.parseObject(json, CurrentLocationResult.class);
         } catch (Exception e) {

+ 1 - 1
src/main/java/com/steerinfo/route/threeRequest/ZhongJiaoXingLu.java

@@ -80,7 +80,7 @@ public class ZhongJiaoXingLu {
             //routeMap.get("qryEtm").toString()
             map.put("timeNearby", "30");
             String url = "https://openapi.sinoiov.cn/save/apis/visualRoute";
-            DataExchangeService des = new DataExchangeService(5000, 8000);
+            DataExchangeService des = new DataExchangeService(3000, 5000);
 
             // 通过 https 方式调用,此方法内部会使用私钥生成签名参数 sign,私钥不会发送
             String res = des.postHttps(url, map);