From 766c2b5c6940fb4373b7b8097b31d2b03aa49ac2 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期一, 10 十一月 2025 21:22:16 +0800
Subject: [PATCH] fix:优化小程序人员加载和后台用户管理中的用户加载

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/VehicleGpsController.java |   74 +++++++++++++++++++++++++++++++++++++
 1 files changed, 74 insertions(+), 0 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/VehicleGpsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/VehicleGpsController.java
index ac0efe6..1a770d2 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/VehicleGpsController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/VehicleGpsController.java
@@ -666,4 +666,78 @@
             return AjaxResult.error("璁$畻璺濈澶辫触锛�" + e.getMessage());
         }
     }
+    
+    /**
+     * 鐧惧害鍦板浘鍦板潃鎼滅储鎻愮ずAPI锛堣緭鍏ヨ仈鎯筹級
+     * Place Suggestion API - 鐢ㄤ簬鍦板潃杈撳叆鏃剁殑鏅鸿兘鎻愮ず
+     */
+    @Anonymous()
+    @GetMapping("/baidu/place/suggestion")
+    public AjaxResult baiduPlaceSuggestion(String query, String region) {
+        try {
+            // 妫�鏌ュ弬鏁�
+            if (query == null || query.trim().isEmpty()) {
+                return AjaxResult.error("鍙傛暟涓嶅畬鏁达紝缂哄皯鎼滅储鍏抽敭璇�");
+            }
+            
+            // 鏋勫缓鐧惧害鍦板浘 Place Suggestion API URL
+            String url = "https://api.map.baidu.com/place/v2/suggestion";
+            String params = "query=" + URLEncoder.encode(query, StandardCharsets.UTF_8.toString()) +
+                           (region != null && !region.trim().isEmpty() ? 
+                            "&region=" + URLEncoder.encode(region, StandardCharsets.UTF_8.toString()) : "") +
+                           "&output=json" +
+                           "&ak=" + baiduMapConfig.getAk();
+            
+            logger.info("鐧惧害鍦板浘鍦板潃鎼滅储鎻愮ず璇锋眰: query={}, region={}", query, region);
+            
+            // 鍙戦�丠TTP璇锋眰
+            String response = HttpUtils.sendGet(url, params);
+            logger.debug("鐧惧害鍦板浘鍦板潃鎼滅储鎻愮ず鍝嶅簲: {}", response);
+            
+            // 瑙f瀽鍝嶅簲
+            com.alibaba.fastjson2.JSONObject jsonResponse = com.alibaba.fastjson2.JSONObject.parseObject(response);
+            if (jsonResponse.getInteger("status") != 0) {
+                logger.error("鍦板潃鎼滅储鎻愮ず澶辫触: {}", response);
+                return AjaxResult.error("鍦板潃鎼滅储澶辫触");
+            }
+            
+            // 鎻愬彇鎻愮ず鍒楄〃
+            com.alibaba.fastjson2.JSONArray results = jsonResponse.getJSONArray("result");
+            if (results == null || results.isEmpty()) {
+                logger.info("鏈壘鍒板尮閰嶇殑鍦板潃");
+                return AjaxResult.success("鏌ヨ鎴愬姛", new ArrayList<>());
+            }
+            
+            // 鏋勫缓杩斿洖缁撴灉
+            List<Map<String, Object>> suggestions = new ArrayList<>();
+            for (int i = 0; i < results.size(); i++) {
+                com.alibaba.fastjson2.JSONObject item = results.getJSONObject(i);
+                
+                Map<String, Object> suggestion = new HashMap<>();
+                suggestion.put("name", item.getString("name")); // 鍚嶇О
+                suggestion.put("address", item.getString("address")); // 鍦板潃
+                suggestion.put("province", item.getString("province")); // 鐪�
+                suggestion.put("city", item.getString("city")); // 甯�
+                suggestion.put("district", item.getString("district")); // 鍖�
+                suggestion.put("uid", item.getString("uid")); // 鍦扮偣UID
+                
+                // 缁忕含搴︿俊鎭�
+                com.alibaba.fastjson2.JSONObject location = item.getJSONObject("location");
+                if (location != null) {
+                    Map<String, Object> locationMap = new HashMap<>();
+                    locationMap.put("lat", location.getDouble("lat"));
+                    locationMap.put("lng", location.getDouble("lng"));
+                    suggestion.put("location", locationMap);
+                }
+                
+                suggestions.add(suggestion);
+            }
+            
+            logger.info("鍦板潃鎼滅储鎻愮ず鎴愬姛: 鎵惧埌{}  鏉$粨鏋�", suggestions.size());
+            return AjaxResult.success("鏌ヨ鎴愬姛", suggestions);
+        } catch (Exception e) {
+            logger.error("鍦板潃鎼滅储鎻愮ず澶辫触", e);
+            return AjaxResult.error("鍦板潃鎼滅储澶辫触锛�" + e.getMessage());
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1