From 53ae0215de46b9bb68d9aa5d5a3e83dde7cb3986 Mon Sep 17 00:00:00 2001
From: suerprisePlus <15810472099@163.com>
Date: 星期五, 27 九月 2024 15:20:11 +0800
Subject: [PATCH] 接口优化

---
 src/main/java/com/yb/service/IntentionService.java |   83 ++++++++++++++++++++++++++++++++++++++---
 1 files changed, 76 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/yb/service/IntentionService.java b/src/main/java/com/yb/service/IntentionService.java
index 111301b..4bf8092 100644
--- a/src/main/java/com/yb/service/IntentionService.java
+++ b/src/main/java/com/yb/service/IntentionService.java
@@ -59,10 +59,9 @@
     private HashMap<String, Object> getBatEnv(JSONObject orderObject, String func, Map<String, String> allParams) throws Exception {
         HashMap<String, Object> hashMap = new HashMap<String, Object>();
         hashMap.put("func", func);
-//        List list = orderObject.get("history");
+
         System.out.println("rec history1:" + allParams);
-        String history = allParams.get("history");
-        System.out.println("rec history1:" + history);
+
         String val = entityHttpUtil.postAgentMessage(xzConfig.battleReport, allParams);
         JSONObject js = JSONObject.parseObject(val);
         if (js == null) {
@@ -85,7 +84,11 @@
         String key = "msg";
         String msg = (String) poiMap.get(key);
         hashMap.put("msg", msg);
-        hashMap.put("data", poiMap);
+        String center = (String) poiMap.get("center");
+        if(center != null){
+            hashMap.put("data", poiMap);
+        }
+
         return hashMap;
     }
 
@@ -96,6 +99,7 @@
         String filedString = xzService.getQueryMeta(xzConfig.layerId, xzConfig.dbid, xzConfig.typeFiled, xzConfig.queryEntity);
         JSONObject metaObject = JSON.parseObject(filedString);
         JSONArray dataArray = metaObject.getJSONArray("data");
+
         String markDown = "| 鏁版嵁绫诲瀷 | 鏁版嵁閲� |\n|------|------|\n";
         ArrayList<HashMap<String, Object>> list = new ArrayList<>();
         for (int i = 0; i < dataArray.size(); i++) {
@@ -116,6 +120,7 @@
 
     }
 
+
     //    鍏抽敭瀛楁煡璇㈠垎绫绘煡璇㈡暟鎹噺
     private ArrayList getQueryByFiledList(String name) throws Exception {
         String obj = xzConfig.typeFiled + " = '" + name + "'" + "";
@@ -127,8 +132,6 @@
         System.out.println("rec queryMeta:" + fObj);
         if (fObj != null) {
             JSONArray fArray = JSONArray.parseArray(JSONObject.parseObject(fObj).getString("items"));
-            System.out.println("rec queryMeta:" + fArray);
-            System.out.println("rec queryMeta:" + fArray.size());
             if (fArray.size() > 0) {
                 for (int i = 0; i < fArray.size(); i++) {
                     String sid = JSONObject.parseObject(fArray.get(i).toString()).getString("seid");
@@ -156,10 +159,15 @@
             dis = dis.replace("m", "");
             radius = Integer.parseInt(dis);
         }
+        if (dis != null && dis.contains("鍗冪背")) {
+            dis = dis.replace("鍗冪背", "");
+            radius = Integer.parseInt(dis) * 1000;
+        }
         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()) {
             aroundPoi = agentService.getAgentAroundPoi(getTraditional(place), type, radius, xzConfig.queryFiled, xzConfig.typeFiled);
@@ -171,12 +179,73 @@
 
         }
         JSONArray dataArray = JSONArray.parseArray(aroundPoi);
-        System.out.println("aroundPoi: " + dataArray);
         hashMap.put("data", dataArray);
+        if (type.contains("鍏ㄩ儴鐩爣")) {
+            if (dataArray.size() == 0) {
+                hashMap.put("data", dataArray);
+                String msg = "宸叉煡璇㈠埌" + place + "鍐呯殑" + type + "鐩稿叧鏁版嵁銆傚叡鏌ヨ鍒�" + dataArray.size() + "鏉℃暟鎹��";
+                hashMap.put("msg", msg);
+                return hashMap;
+            }
+            ArrayList<HashMap<String, Object>> listArray = new ArrayList<>();
+            String markDown = "| 鏁版嵁绫诲瀷 | 鏁版嵁閲� |\n|------|------|\n";
+            ArrayList<HashMap<String, Object>> list = new ArrayList<>();
+            List<String> cName = new ArrayList<>();
+            List<Integer> cNum = new ArrayList<>();
+            for (int i = 0; i < dataArray.size(); i++) {
+                JSONObject dataObj = dataArray.getJSONObject(i);
+                String fclass1 = dataObj.getString("fclass_1");
+                String ids = dataObj.getString("seid");
+                if (cName.contains(fclass1)) {
+                    for (int j = 0; j < cName.size(); j++) {
+                        String name = cName.get(j);
+                        if (name.equals(fclass1)) {
+                            System.out.println("鐩爣缁熻 = " + cName.get(j) + fclass1);
+                            int num = cNum.get(j) + 1;
+                            cNum.set(j, num);
+
+                            HashMap<String, Object> itemObj = list.get(j);
+
+                            for (String key : itemObj.keySet()) {
+                                if (key.contains("ids")) {
+                                    ArrayList list_ids = (ArrayList) itemObj.get(key);
+                                    list_ids.add(ids);
+                                    itemObj.put(key,list_ids);
+                                }
+
+                            }
+
+                        }
+                    }
+
+
+                } else {
+                    cName.add(fclass1);
+                    cNum.add(1);
+                    HashMap<String, Object> listhash = new HashMap<>();
+                    ArrayList listId = new ArrayList();
+                    listId.add(ids);
+                    listhash.put("name", fclass1);
+                    listhash.put("ids", listId);
+                    list.add(listhash);
+                }
+            }
+
+            for (int i = 0; i < cName.size(); i++) {
+                markDown += "| " + cName.get(i) + " | " + cNum.get(i) + " |\n";
+            }
+            hashMap.put("ids", list);
+            hashMap.put("data", markDown);
+            hashMap.put("func", "queryMeta");
+            return hashMap;
+        }
+
+
         String msg = "宸叉煡璇㈠埌" + place + "鍐呯殑" + type + "鐩稿叧鏁版嵁銆傚叡鏌ヨ鍒�" + dataArray.size() + "鏉℃暟鎹��";
         hashMap.put("msg", msg);
         return hashMap;
 
+
     }
 
     public String getTraditional(String place) {

--
Gitblit v1.9.3