From fe33646ee6e2d1e57f2b51812e94983a0e9efb04 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 14 十二月 2025 16:51:28 +0800
Subject: [PATCH] feat: 修复统计
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CmsGpsCollectServiceImpl.java | 90 +++++++++++++++++++++++++++++++++++++++++----
1 files changed, 82 insertions(+), 8 deletions(-)
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CmsGpsCollectServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CmsGpsCollectServiceImpl.java
index 493f47d..b93684a 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CmsGpsCollectServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CmsGpsCollectServiceImpl.java
@@ -6,6 +6,7 @@
import com.ruoyi.system.domain.CmsVehicleDeviceResponse;
import com.ruoyi.system.domain.CmsVehicleDeviceListResponse;
import com.ruoyi.system.domain.CmsVehicleLocationResponse;
+import com.ruoyi.system.domain.CmsTrackDetailResponse;
import com.ruoyi.system.domain.SysGpsConfig;
import com.ruoyi.system.service.ICmsGpsCollectService;
import com.ruoyi.system.service.IGpsConfigService;
@@ -15,6 +16,8 @@
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import java.util.Date;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
/**
* CMS GPS閲囬泦鏈嶅姟瀹炵幇
@@ -115,13 +118,17 @@
}
// 鏋勫缓璇锋眰URL
- String url = baseUrlConfig.getDomain() + "/StandardApiAction_getDeviceByVehicle.action?jsession=" + baseUrlConfig.getToken();
+ StringBuilder url = new StringBuilder();
+ url.append(baseUrlConfig.getDomain())
+ .append("/StandardApiAction_getDeviceByVehicle.action?jsession=")
+ .append(baseUrlConfig.getToken());
+
if (vehicleId != null && !vehicleId.isEmpty()) {
- url += "&vehiIdno=" + vehicleId;
+ url.append("&vehiIdno=").append(vehicleId);
}
// 鍙戦�佹煡璇㈣姹�
- String response = HttpUtil.get(url,null);
+ String response = HttpUtils.sendGet(url.toString());
// 瑙f瀽鍝嶅簲
CmsVehicleDeviceListResponse deviceListResponse = JSONObject.parseObject(response, CmsVehicleDeviceListResponse.class);
@@ -184,11 +191,11 @@
// 瑙f瀽鍝嶅簲
CmsVehicleLocationResponse locationResponse = JSONObject.parseObject(response, CmsVehicleLocationResponse.class);
- if (locationResponse.getResult() == 0) {
- log.info("鑾峰彇杞﹁締浣嶇疆淇℃伅鎴愬姛锛岃溅鐗屽彿锛歿}", vehicleId);
- } else {
- log.error("鑾峰彇杞﹁締浣嶇疆淇℃伅澶辫触锛岃溅鐗屽彿锛歿}", vehicleId);
- }
+// if (locationResponse.getResult() == 0) {
+// log.info("鑾峰彇杞﹁締浣嶇疆淇℃伅鎴愬姛锛岃溅鐗屽彿锛歿}", vehicleId);
+// } else {
+// log.error("鑾峰彇杞﹁締浣嶇疆淇℃伅澶辫触锛岃溅鐗屽彿锛歿}", vehicleId);
+// }
return locationResponse;
} catch (Exception e) {
@@ -196,4 +203,71 @@
throw new RuntimeException("鑾峰彇杞﹁締浣嶇疆淇℃伅寮傚父锛�" + e.getMessage());
}
}
+
+ @Override
+ public CmsTrackDetailResponse queryTrackDetail(String devIdno, String begintime, String endtime,
+ Double distance, Integer parkTime, Integer geoaddress, Integer currentPage,
+ Integer pageRecords, Integer toMap) {
+
+ try {
+ // 浠庢暟鎹簱鑾峰彇CMS閰嶇疆
+ SysGpsConfig baseUrlConfig = gpsConfigService.selectGpsConfigByKey("gpscms");
+ if (baseUrlConfig == null) {
+ throw new RuntimeException("鏈厤缃瓹MS绯荤粺鍦板潃");
+ }
+
+ // 妫�鏌oken鏄惁杩囨湡
+ if (baseUrlConfig.getTokenExpireTime() == null ||
+ baseUrlConfig.getTokenExpireTime().before(new Date())) {
+ // token杩囨湡锛岄噸鏂扮櫥褰�
+ login(baseUrlConfig.getUsername(), baseUrlConfig.getPassword());
+ baseUrlConfig = gpsConfigService.selectGpsConfigByKey("gpscms");
+ }
+
+ // 鏋勫缓璇锋眰URL
+ StringBuilder url = new StringBuilder(baseUrlConfig.getDomain())
+ .append("/StandardApiAction_queryTrackDetail.action?jsession=")
+ .append(baseUrlConfig.getToken())
+ .append("&devIdno=").append(devIdno)
+ .append("&begintime=").append(begintime)
+ .append("&endtime=").append(endtime);
+
+ // 娣诲姞鍙�夊弬鏁�
+ if (distance != null) {
+ url.append("&distance=").append(distance);
+ }
+ if (parkTime != null) {
+ url.append("&parkTime=").append(parkTime);
+ }
+ if (geoaddress != null) {
+ url.append("&geoaddress=").append(geoaddress);
+ }
+ if (currentPage != null) {
+ url.append("¤tPage=").append(currentPage);
+ }
+ if (pageRecords != null) {
+ url.append("&pageRecords=").append(pageRecords);
+ }
+ if (toMap != null) {
+ url.append("&toMap=").append(toMap);
+ }
+
+ // 鍙戦�佹煡璇㈣姹�
+ String response = HttpUtils.sendGet(url.toString());
+
+ // 瑙f瀽鍝嶅簲
+ CmsTrackDetailResponse trackResponse = JSONObject.parseObject(response, CmsTrackDetailResponse.class);
+
+// if (trackResponse.getResult() == 0) {
+// log.info("鑾峰彇璁惧鍘嗗彶杞ㄨ抗鎴愬姛锛岃澶囧彿锛歿}", devIdno);
+// } else {
+// log.error("鑾峰彇璁惧鍘嗗彶杞ㄨ抗澶辫触锛岃澶囧彿锛歿}", devIdno);
+// }
+
+ return trackResponse;
+ } catch (Exception e) {
+ log.error("鑾峰彇璁惧鍘嗗彶杞ㄨ抗寮傚父锛岃澶囧彿锛歿}", devIdno, e);
+ throw new RuntimeException("鑾峰彇璁惧鍘嗗彶杞ㄨ抗寮傚父锛�" + e.getMessage());
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1