From e7c3276f2f5091fe8626af61ba5d7b41b2a1f2df Mon Sep 17 00:00:00 2001
From: suerprisePlus <15810472099@163.com>
Date: 星期一, 23 九月 2024 15:42:14 +0800
Subject: [PATCH] 添加历史记录接口,坐标转换,功能优化

---
 src/main/java/com/yb/service/IntentionService.java |   46 ++++++++++++++++++++++++++++++++++------------
 1 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/yb/service/IntentionService.java b/src/main/java/com/yb/service/IntentionService.java
index 3744eef..111301b 100644
--- a/src/main/java/com/yb/service/IntentionService.java
+++ b/src/main/java/com/yb/service/IntentionService.java
@@ -3,6 +3,7 @@
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.github.houbb.opencc4j.core.impl.ZhConvertBootstrap;
 import com.yb.config.XzConfig;
 import com.yb.helper.RsaHelper;
 import com.yb.util.EntityHttpUtil;
@@ -33,16 +34,16 @@
         String history = orderObject.getString("history");
 
         if (func.equals(xzConfig.funcName[0])) {
-            mapObj = getPoiMap(orderObject,func);
+            mapObj = getPoiMap(orderObject, func);
         } else if (func.equals(xzConfig.funcName[1])) {
             mapObj = getAroundPoi(orderObject, func);
         } else if (func.equals(xzConfig.funcName[2])) {
             mapObj = getQueryMeta(orderObject, func);
         } else if (func.equals(xzConfig.funcName[3])) {
             mapObj = getQueryRelationship(orderObject, func);
-        }else if (func.equals(xzConfig.funcName[4])) {
+        } else if (func.equals(xzConfig.funcName[4])) {
             mapObj = getCombatSimulate(orderObject, func);
-        }else if (func.equals(xzConfig.funcName[5])) {
+        } else if (func.equals(xzConfig.funcName[5])) {
             mapObj = getBatEnv(orderObject, func, allParams);
         }
         return mapObj;
@@ -52,7 +53,7 @@
     private HashMap<String, Object> getCombatSimulate(JSONObject orderObject, String func) {
         HashMap<String, Object> hashMap = new HashMap<String, Object>();
         hashMap.put("func", func);
-        return  hashMap;
+        return hashMap;
     }
 
     private HashMap<String, Object> getBatEnv(JSONObject orderObject, String func, Map<String, String> allParams) throws Exception {
@@ -64,7 +65,7 @@
         System.out.println("rec history1:" + history);
         String val = entityHttpUtil.postAgentMessage(xzConfig.battleReport, allParams);
         JSONObject js = JSONObject.parseObject(val);
-        if(js == null){
+        if (js == null) {
             hashMap.put("msg", "鎶ュ憡鐢熸垚澶辫触");
             return hashMap;
         }
@@ -147,15 +148,27 @@
         String type = argsObject.getString("attris");
         String dis = argsObject.getString("redius");
         int radius = 5000;
-        if (dis != null) {
+        if (dis != null && dis.contains("km")) {
+            dis = dis.replace("km", "");
+            radius = Integer.parseInt(dis) * 1000;
+        }
+        if (dis != null && dis.contains("m")) {
             dis = dis.replace("m", "");
+            radius = Integer.parseInt(dis);
+        }
+        if (dis != null && dis.contains("绫�")) {
+            dis = dis.replace("绫�", "");
             radius = Integer.parseInt(dis);
         }
         String aroundPoi = agentService.getAgentAroundPoi(place, type, radius, xzConfig.queryFiled, xzConfig.typeFiled);
         if (aroundPoi == "" || aroundPoi.isEmpty()) {
-            String msg = "鏈煡璇㈠埌" + place + "鐩稿叧鏁版嵁銆傝鎻愪緵鏇村姞璇︾粏鏁版嵁銆�";
-            hashMap.put("msg", msg);
-            return hashMap;
+            aroundPoi = agentService.getAgentAroundPoi(getTraditional(place), type, radius, xzConfig.queryFiled, xzConfig.typeFiled);
+            if (aroundPoi == "" || aroundPoi.isEmpty()) {
+                String msg = "鏈煡璇㈠埌" + place + "鐩稿叧鏁版嵁銆傝鎻愪緵鏇村姞璇︾粏鏁版嵁銆�";
+                hashMap.put("msg", msg);
+                return hashMap;
+            }
+
         }
         JSONArray dataArray = JSONArray.parseArray(aroundPoi);
         System.out.println("aroundPoi: " + dataArray);
@@ -163,6 +176,12 @@
         String msg = "宸叉煡璇㈠埌" + place + "鍐呯殑" + type + "鐩稿叧鏁版嵁銆傚叡鏌ヨ鍒�" + dataArray.size() + "鏉℃暟鎹��";
         hashMap.put("msg", msg);
         return hashMap;
+
+    }
+
+    public String getTraditional(String place) {
+        ZhConvertBootstrap zhConvertBootstrap = ZhConvertBootstrap.newInstance();
+        return zhConvertBootstrap.toTraditional(place);
 
     }
 
@@ -174,9 +193,12 @@
         String poiMap = agentService.getAgentPoiMap(place, xzConfig.queryFiled);
         JSONObject poiObj = JSONObject.parseObject(poiMap);
         if (poiMap == "" || poiMap.isEmpty()) {
-            String msg = "鏈煡璇㈠埌" + place + "鐩稿叧鏁版嵁銆傝鎻愪緵鏇村姞璇︾粏鏁版嵁銆�";
-            hashMap.put("msg", msg);
-            return hashMap;
+            poiMap = agentService.getAgentPoiMap(getTraditional(place), xzConfig.queryFiled);
+            if (poiMap == "" || poiMap.isEmpty()) {
+                String msg = "鏈煡璇㈠埌" + place + "鐩稿叧鏁版嵁銆傝鎻愪緵鏇村姞璇︾粏鏁版嵁銆�";
+                hashMap.put("msg", msg);
+                return hashMap;
+            }
         }
         System.out.println("poiMap: " + poiObj);
         hashMap.put("func", func);

--
Gitblit v1.9.3