From 4dd78acfe298217ebc5dd247c5b45c6f33deea9b Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期六, 08 十一月 2025 22:43:14 +0800
Subject: [PATCH] feat:医院选择计算

---
 app/pages/task/create-emergency.vue                                                 |  337 ++++++++++++++++++++++++++++++++++++++++-
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/HospDataController.java   |    8 +
 ruoyi-system/src/main/java/com/ruoyi/system/mapper/HospDataMapper.java              |    1 
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/VehicleGpsController.java |   74 +++++++++
 app/api/map.js                                                                      |   17 ++
 ruoyi-system/src/main/resources/mapper/system/HospDataMapper.xml                    |    7 
 6 files changed, 430 insertions(+), 14 deletions(-)

diff --git a/app/api/map.js b/app/api/map.js
index ed85e5b..05acf2e 100644
--- a/app/api/map.js
+++ b/app/api/map.js
@@ -126,4 +126,21 @@
       toCity: toCity
     }
   })
+}
+
+// 鐧惧害鍦板浘鍦板潃鎼滅储鎻愮ずAPI锛堣緭鍏ヨ仈鎯筹級
+export function baiduPlaceSuggestion(query, region) {
+  // 鍙傛暟楠岃瘉
+  if (!query) {
+    return Promise.reject(new Error('鍙傛暟涓嶅畬鏁�,缂哄皯鎼滅储鍏抽敭璇�'))
+  }
+  
+  return request({
+    url: '/system/gps/baidu/place/suggestion',
+    method: 'get',
+    params: {
+      query: query,
+      region: region || '骞垮窞'
+    }
+  })
 }
\ No newline at end of file
diff --git a/app/pages/task/create-emergency.vue b/app/pages/task/create-emergency.vue
index 094a808..7d96be1 100644
--- a/app/pages/task/create-emergency.vue
+++ b/app/pages/task/create-emergency.vue
@@ -217,7 +217,26 @@
       
       <view class="form-item">
         <view class="form-label">杞嚭鍦板潃</view>
-        <view class="form-input picker-input disabled">
+        <view class="address-input-container" v-if="taskForm.hospitalOut.name === '瀹朵腑'">
+          <input 
+            class="form-input" 
+            placeholder="璇疯緭鍏ヨ缁嗗湴鍧�" 
+            v-model="taskForm.hospitalOut.address"
+            @input="onAddressOutInput"
+            @focus="onAddressOutFocus"
+          />
+          <view class="address-suggestions" v-if="showAddressOutSuggestions && addressOutSuggestions.length > 0">
+            <view 
+              class="address-suggestion-item" 
+              v-for="(item, index) in addressOutSuggestions" 
+              :key="index"
+              @click="selectAddressOut(item)">
+              <view class="suggestion-name">{{ item.name }}</view>
+              <view class="suggestion-address">{{ item.district }}{{ item.address }}</view>
+            </view>
+          </view>
+        </view>
+        <view v-else class="form-input picker-input disabled">
           {{ taskForm.hospitalOut.address || '閫夋嫨鍖婚櫌鍚庤嚜鍔ㄥ~鍏�' }}
         </view>
       </view>
@@ -268,7 +287,26 @@
       
       <view class="form-item">
         <view class="form-label">杞叆鍦板潃</view>
-        <view class="form-input picker-input disabled">
+        <view class="address-input-container" v-if="taskForm.hospitalIn.name === '瀹朵腑'">
+          <input 
+            class="form-input" 
+            placeholder="璇疯緭鍏ヨ缁嗗湴鍧�" 
+            v-model="taskForm.hospitalIn.address"
+            @input="onAddressInInput"
+            @focus="onAddressInFocus"
+          />
+          <view class="address-suggestions" v-if="showAddressInSuggestions && addressInSuggestions.length > 0">
+            <view 
+              class="address-suggestion-item" 
+              v-for="(item, index) in addressInSuggestions" 
+              :key="index"
+              @click="selectAddressIn(item)">
+              <view class="suggestion-name">{{ item.name }}</view>
+              <view class="suggestion-address">{{ item.district }}{{ item.address }}</view>
+            </view>
+          </view>
+        </view>
+        <view v-else class="form-input picker-input disabled">
           {{ taskForm.hospitalIn.address || '閫夋嫨鍖婚櫌鍚庤嚜鍔ㄥ~鍏�' }}
         </view>
       </view>
@@ -443,7 +481,7 @@
 import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
 import { addTask } from "@/api/task"
 import { listAvailableVehicles, getUserBoundVehicle } from "@/api/vehicle"
-import { calculateDistance, baiduDistanceByAddress } from "@/api/map"
+import { calculateDistance, baiduDistanceByAddress, baiduPlaceSuggestion } from "@/api/map"
 import { searchHospitals, getFrequentOutHospitals, getFrequentInHospitals } from "@/api/hospital"
 import { listUser } from "@/api/system/user"
 import { searchIcd10 } from "@/api/icd10"
@@ -481,6 +519,12 @@
       showHospitalInResults: false,
       searchTimer: null,
       defaultHospitals: [], // 榛樿鐨�100鏉″尰闄㈡暟鎹�
+      // 鍦板潃鎼滅储鎻愮ず鐩稿叧
+      addressOutSuggestions: [], // 杞嚭鍦板潃鎻愮ず鍒楄〃
+      showAddressOutSuggestions: false,
+      addressInSuggestions: [], // 杞叆鍦板潃鎻愮ず鍒楄〃
+      showAddressInSuggestions: false,
+      addressSearchTimer: null, // 鍦板潃鎼滅储闃叉姈瀹氭椂鍣�
       // 浜哄憳閫夋嫨鐩稿叧
       selectedStaff: [], // 宸查�夋嫨鐨勪汉鍛樺垪琛�
       allStaffList: [], // 鎵�鏈変汉鍛樺垪琛�
@@ -985,9 +1029,14 @@
     selectHospitalOut(hospital) {
       this.taskForm.hospitalOut.id = hospital.hospId  // 淇濆瓨鍖婚櫌ID
       this.taskForm.hospitalOut.name = hospital.hospName
-      // 鍚堝苟鐪佸競鍖� + 璇︾粏鍦板潃
-      const fullAddress = this.buildFullAddress(hospital)
-      this.taskForm.hospitalOut.address = fullAddress
+      // 濡傛灉閫夋嫨鐨勬槸"瀹朵腑"锛屾竻绌哄湴鍧�璁╃敤鎴锋墜鍔ㄨ緭鍏ワ紱鍚﹀垯鑷姩濉厖鍦板潃
+      if (hospital.hospName === '瀹朵腑') {
+        this.taskForm.hospitalOut.address = ''
+      } else {
+        // 鍚堝苟鐪佸競鍖� + 璇︾粏鍦板潃
+        const fullAddress = this.buildFullAddress(hospital)
+        this.taskForm.hospitalOut.address = fullAddress
+      }
       this.hospitalOutSearchKeyword = hospital.hospName
       this.showHospitalOutResults = false
       this.hospitalOutResults = []
@@ -995,9 +1044,15 @@
       // 淇濆瓨杞嚭鍖婚櫌鐨勫煄甯備俊鎭�
       this.taskForm.hospitalOut.city = hospital.hopsCity || ''
       
-      // 濡傛灉涓や釜鍖婚櫌閮藉凡閫夋嫨锛岃嚜鍔ㄨ绠楄窛绂�
+      // 濡傛灉杞叆鍦板潃宸插~鍐�,鑷姩璁$畻璺濈
       if (this.taskForm.hospitalIn.address) {
-        this.calculateHospitalDistance()
+        // 濡傛灉涓や釜閮戒笉鏄�"瀹朵腑",浣跨敤鍖婚櫌璺濈璁$畻
+        if (hospital.hospName !== '瀹朵腑' && this.taskForm.hospitalIn.name !== '瀹朵腑') {
+          this.calculateHospitalDistance()
+        } else {
+          // 鏈変竴涓槸"瀹朵腑",浣跨敤鍦板潃璁$畻
+          this.calculateDistanceByManualAddress()
+        }
       }
     },
     
@@ -1095,9 +1150,14 @@
     selectHospitalIn(hospital) {
       this.taskForm.hospitalIn.id = hospital.hospId  // 淇濆瓨鍖婚櫌ID
       this.taskForm.hospitalIn.name = hospital.hospName
-      // 鍚堝苟鐪佸競鍖� + 璇︾粏鍦板潃
-      const fullAddress = this.buildFullAddress(hospital)
-      this.taskForm.hospitalIn.address = fullAddress
+      // 濡傛灉閫夋嫨鐨勬槸"瀹朵腑"锛屾竻绌哄湴鍧�璁╃敤鎴锋墜鍔ㄨ緭鍏ワ紱鍚﹀垯鑷姩濉厖鍦板潃
+      if (hospital.hospName === '瀹朵腑') {
+        this.taskForm.hospitalIn.address = ''
+      } else {
+        // 鍚堝苟鐪佸競鍖� + 璇︾粏鍦板潃
+        const fullAddress = this.buildFullAddress(hospital)
+        this.taskForm.hospitalIn.address = fullAddress
+      }
       this.hospitalInSearchKeyword = hospital.hospName
       this.showHospitalInResults = false
       this.hospitalInResults = []
@@ -1105,9 +1165,15 @@
       // 淇濆瓨杞叆鍖婚櫌鐨勫煄甯備俊鎭�
       this.taskForm.hospitalIn.city = hospital.hopsCity || ''
       
-      // 濡傛灉涓や釜鍖婚櫌閮藉凡閫夋嫨锛岃嚜鍔ㄨ绠楄窛绂�
+      // 濡傛灉杞嚭鍦板潃宸插~鍐�,鑷姩璁$畻璺濈
       if (this.taskForm.hospitalOut.address) {
-        this.calculateHospitalDistance()
+        // 濡傛灉涓や釜閮戒笉鏄�"瀹朵腑",浣跨敤鍖婚櫌璺濈璁$畻
+        if (hospital.hospName !== '瀹朵腑' && this.taskForm.hospitalOut.name !== '瀹朵腑') {
+          this.calculateHospitalDistance()
+        } else {
+          // 鏈変竴涓槸"瀹朵腑",浣跨敤鍦板潃璁$畻
+          this.calculateDistanceByManualAddress()
+        }
       }
     },
     
@@ -1285,6 +1351,208 @@
     
     addStaff() {
       this.showStaffSelector()
+    },
+    
+    // ==================== 鍦板潃杈撳叆鑱旀兂鐩稿叧鏂规硶 ====================
+    
+    // 杞嚭鍦板潃杈撳叆鐩戝惉
+    onAddressOutInput(e) {
+      const query = e.detail.value
+      this.taskForm.hospitalOut.address = query
+      
+      // 闃叉姈澶勭悊
+      if (this.addressSearchTimer) {
+        clearTimeout(this.addressSearchTimer)
+      }
+      
+      // 濡傛灉杈撳叆涓虹┖锛岄殣钘忔彁绀哄垪琛�
+      if (!query || query.trim() === '') {
+        this.showAddressOutSuggestions = false
+        this.addressOutSuggestions = []
+        return
+      }
+      
+      // 杈撳叆闀垮害澶т簬2鎵嶅紑濮嬫悳绱�
+      if (query.trim().length < 2) {
+        this.showAddressOutSuggestions = false
+        return
+      }
+      
+      // 寤惰繜300ms鎼滅储
+      this.addressSearchTimer = setTimeout(() => {
+        this.searchAddressOut(query)
+      }, 300)
+    },
+    
+    // 杞嚭鍦板潃杈撳叆妗嗚幏寰楃劍鐐�
+    onAddressOutFocus() {
+      // 濡傛灉鏈夊湴鍧�涓旀湁鎼滅储缁撴灉锛屾樉绀烘彁绀哄垪琛�
+      if (this.taskForm.hospitalOut.address && this.addressOutSuggestions.length > 0) {
+        this.showAddressOutSuggestions = true
+      }
+    },
+    
+    // 鎼滅储杞嚭鍦板潃
+    searchAddressOut(query) {
+      // 鑾峰彇褰撳墠鍖哄煙锛堜紭鍏堜娇鐢ㄥ綊灞炴満鏋勭殑鍖哄煙锛�
+      const region = this.selectedRegion || '骞垮窞'
+      
+      baiduPlaceSuggestion(query, region).then(response => {
+        if (response.code === 200 && response.data) {
+          this.addressOutSuggestions = response.data
+          this.showAddressOutSuggestions = true
+        } else {
+          this.addressOutSuggestions = []
+          this.showAddressOutSuggestions = false
+        }
+      }).catch(error => {
+        console.error('鎼滅储杞嚭鍦板潃澶辫触:', error)
+        this.addressOutSuggestions = []
+        this.showAddressOutSuggestions = false
+      })
+    },
+    
+    // 閫夋嫨杞嚭鍦板潃
+    selectAddressOut(item) {
+      // 濉厖瀹屾暣鍦板潃
+      const fullAddress = item.district + item.address
+      this.taskForm.hospitalOut.address = fullAddress
+      
+      // 淇濆瓨缁忕含搴︼紙濡傛灉鏈夛級
+      if (item.location) {
+        this.taskForm.hospitalOut.latitude = item.location.lat
+        this.taskForm.hospitalOut.longitude = item.location.lng
+      }
+      
+      // 闅愯棌鎻愮ず鍒楄〃
+      this.showAddressOutSuggestions = false
+      this.addressOutSuggestions = []
+      
+      // 濡傛灉杞叆鍦板潃涔熷凡濉啓,鑷姩璁$畻璺濈
+      if (this.taskForm.hospitalIn.address) {
+        this.calculateDistanceByManualAddress()
+      }
+    },
+    
+    // 杞叆鍦板潃杈撳叆鐩戝惉
+    onAddressInInput(e) {
+      const query = e.detail.value
+      this.taskForm.hospitalIn.address = query
+      
+      // 闃叉姈澶勭悊
+      if (this.addressSearchTimer) {
+        clearTimeout(this.addressSearchTimer)
+      }
+      
+      // 濡傛灉杈撳叆涓虹┖锛岄殣钘忔彁绀哄垪琛�
+      if (!query || query.trim() === '') {
+        this.showAddressInSuggestions = false
+        this.addressInSuggestions = []
+        return
+      }
+      
+      // 杈撳叆闀垮害澶т簬2鎵嶅紑濮嬫悳绱�
+      if (query.trim().length < 2) {
+        this.showAddressInSuggestions = false
+        return
+      }
+      
+      // 寤惰繜300ms鎼滅储
+      this.addressSearchTimer = setTimeout(() => {
+        this.searchAddressIn(query)
+      }, 300)
+    },
+    
+    // 杞叆鍦板潃杈撳叆妗嗚幏寰楃劍鐐�
+    onAddressInFocus() {
+      // 濡傛灉鏈夊湴鍧�涓旀湁鎼滅储缁撴灉锛屾樉绀烘彁绀哄垪琛�
+      if (this.taskForm.hospitalIn.address && this.addressInSuggestions.length > 0) {
+        this.showAddressInSuggestions = true
+      }
+    },
+    
+    // 鎼滅储杞叆鍦板潃
+    searchAddressIn(query) {
+      // 鑾峰彇褰撳墠鍖哄煙锛堜紭鍏堜娇鐢ㄥ綊灞炴満鏋勭殑鍖哄煙锛�
+      const region = this.selectedRegion || '骞垮窞'
+      
+      baiduPlaceSuggestion(query, region).then(response => {
+        if (response.code === 200 && response.data) {
+          this.addressInSuggestions = response.data
+          this.showAddressInSuggestions = true
+        } else {
+          this.addressInSuggestions = []
+          this.showAddressInSuggestions = false
+        }
+      }).catch(error => {
+        console.error('鎼滅储杞叆鍦板潃澶辫触:', error)
+        this.addressInSuggestions = []
+        this.showAddressInSuggestions = false
+      })
+    },
+    
+    // 閫夋嫨杞叆鍦板潃
+    selectAddressIn(item) {
+      // 濉厖瀹屾暣鍦板潃
+      const fullAddress = item.district + item.address
+      this.taskForm.hospitalIn.address = fullAddress
+      
+      // 淇濆瓨缁忕含搴︼紙濡傛灉鏈夛級
+      if (item.location) {
+        this.taskForm.hospitalIn.latitude = item.location.lat
+        this.taskForm.hospitalIn.longitude = item.location.lng
+      }
+      
+      // 闅愯棌鎻愮ず鍒楄〃
+      this.showAddressInSuggestions = false
+      this.addressInSuggestions = []
+      
+      // 濡傛灉杞嚭鍦板潃涔熷凡濉啓,鑷姩璁$畻璺濈
+      if (this.taskForm.hospitalOut.address) {
+        this.calculateDistanceByManualAddress()
+      }
+    },
+    
+    // 鎵嬪姩杈撳叆鍦板潃鏃惰绠楄窛绂�
+    calculateDistanceByManualAddress() {
+      const fromAddress = this.taskForm.hospitalOut.address
+      const toAddress = this.taskForm.hospitalIn.address
+      
+      if (!fromAddress || !toAddress) {
+        return
+      }
+      
+      console.log('璁$畻鎵嬪姩杈撳叆鍦板潃璺濈:', fromAddress, '->', toAddress)
+      
+      // 鏄剧ず鍔犺浇鎻愮ず
+      uni.showLoading({
+        title: '璁$畻璺濈涓�...'
+      })
+      
+      // 璋冪敤鐧惧害鍦板浘API璁$畻璺濈
+      const region = this.selectedRegion || '骞垮窞'
+      baiduDistanceByAddress(fromAddress, region, toAddress, region)
+        .then(response => {
+          uni.hideLoading()
+          
+          if (response.code === 200 && response.data) {
+            const distanceInMeters = response.data.distance
+            // 杞崲涓哄叕閲岋紝淇濈枡1浣嶅皬鏁�
+            const distanceInKm = (distanceInMeters / 1000).toFixed(1)
+            this.taskForm.transferDistance = distanceInKm
+            
+            console.log('璺濈璁$畻鎴愬姛:', distanceInKm, 'km')
+            this.$modal.showToast(`璺濈: ${distanceInKm}鍏噷`)
+          } else {
+            console.error('璺濈璁$畻澶辫触:', response.msg)
+            this.$modal.showToast('璺濈璁$畻澶辫触,璇锋墜鍔ㄨ緭鍏�')
+          }
+        })
+        .catch(error => {
+          uni.hideLoading()
+          console.error('璺濈璁$畻澶辫触:', error)
+          this.$modal.showToast('璺濈璁$畻澶辫触,璇锋墜鍔ㄨ緭鍏�')
+        })
     },
     
     // ==================== 鐥呮儏閫夋嫨鐩稿叧鏂规硶 ====================
@@ -1748,6 +2016,49 @@
         }
       }
       
+      .address-input-container {
+        position: relative;
+        
+        .address-suggestions {
+          position: absolute;
+          top: 75rpx;
+          left: 0;
+          right: 0;
+          max-height: 400rpx;
+          background-color: white;
+          border: 1rpx solid #eee;
+          border-radius: 10rpx;
+          box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
+          z-index: 100;
+          overflow-y: auto;
+          
+          .address-suggestion-item {
+            padding: 20rpx 30rpx;
+            border-bottom: 1rpx solid #f0f0f0;
+            
+            &:last-child {
+              border-bottom: none;
+            }
+            
+            &:active {
+              background-color: #f5f5f5;
+            }
+            
+            .suggestion-name {
+              font-size: 28rpx;
+              color: #333;
+              font-weight: bold;
+              margin-bottom: 8rpx;
+            }
+            
+            .suggestion-address {
+              font-size: 24rpx;
+              color: #999;
+            }
+          }
+        }
+      }
+      
       .form-input {
         height: 70rpx;
         padding: 0 20rpx;
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/HospDataController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/HospDataController.java
index 80a6869..cf35021 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/HospDataController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/HospDataController.java
@@ -62,6 +62,10 @@
         if (hospIds == null || hospIds.isEmpty()) {
             return success();
         }
+        Integer homeHospId=hospDataMapper.getHomeHospId();
+        if (!hospIds.contains(homeHospId)) {
+            hospIds.add(0,homeHospId);
+        }
         // 鏍规嵁ID鍒楄〃鏌ヨ鍖婚櫌璇︽儏
         List<HospData> hospitals = hospDataMapper.selectHospDataByIds(hospIds, region);
         return success(hospitals);
@@ -81,6 +85,10 @@
         if (hospIds == null || hospIds.isEmpty()) {
             return success();
         }
+        Integer homeHospId=hospDataMapper.getHomeHospId();
+        if (!hospIds.contains(homeHospId)) {
+            hospIds.add(0,homeHospId);
+        }
         // 鏍规嵁ID鍒楄〃鏌ヨ鍖婚櫌璇︽儏
         List<HospData> hospitals = hospDataMapper.selectHospDataByIds(hospIds, region);
         return success(hospitals);
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
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/HospDataMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/HospDataMapper.java
index 192a29d..02aeb52 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/HospDataMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/HospDataMapper.java
@@ -41,6 +41,7 @@
      */
     List<Integer> selectFrequentOutHospitalIds(@Param("serviceOrdClass") String serviceOrdClass);
     
+    Integer getHomeHospId();
     /**
      * 鏌ヨ甯哥敤杞叆鍖婚櫌ID鍒楄〃
      * 
diff --git a/ruoyi-system/src/main/resources/mapper/system/HospDataMapper.xml b/ruoyi-system/src/main/resources/mapper/system/HospDataMapper.xml
index a7e7a9f..d0de80d 100644
--- a/ruoyi-system/src/main/resources/mapper/system/HospDataMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/HospDataMapper.xml
@@ -53,7 +53,9 @@
         )
         </if>
         AND (HospState IS NULL OR HospState = 1)
-        ORDER BY HospName
+        ORDER BY 
+            CASE WHEN HospName = '瀹朵腑' THEN 0 ELSE 1 END,
+            HospName
     </select>
     
     <select id="selectHospDataById" parameterType="Integer" resultMap="HospDataResult">
@@ -75,6 +77,9 @@
         ) as t
         order by InCount desc
     </select>
+    <select id="getHomeHospId" resultType="java.lang.Integer">
+        select HospID from HospData where HospName='瀹朵腑'
+    </select>
     
     <!-- 鏌ヨ甯哥敤杞叆鍖婚櫌ID鍒楄〃 -->
     <select id="selectFrequentInHospitalIds" resultType="java.lang.Integer">

--
Gitblit v1.9.1