ximinghao vor 3 Wochen
Ursprung
Commit
028f3df0f5

+ 5 - 5
src/main/java/com/skyversation/poiaddr/config/WebConfig.java

@@ -6,9 +6,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 @Configuration
 public class WebConfig implements WebMvcConfigurer {
 
-    @Override
-    public void addInterceptors(InterceptorRegistry registry) {
-        registry.addInterceptor(new AuthInterceptor())
-                .addPathPatterns("/**"); // 拦截所有请求
-    }
+//    @Override
+//    public void addInterceptors(InterceptorRegistry registry) {
+//        registry.addInterceptor(new AuthInterceptor())
+//                .addPathPatterns("/**"); // 拦截所有请求
+//    }
 }

+ 2 - 2
src/main/java/com/skyversation/poiaddr/controller/PoiAddressController.java

@@ -53,9 +53,9 @@ public class PoiAddressController {
     public Object selectPoi(@PathVariable("address") String address){
         AddressResult addressResult = addressQueryEngine.commonSearchByName(address,AddressLevel.LEVEL_1);
         if (addressResult.getMessage().equals("失败")){
-            return MessageManage.getInstance().getResultContent(200,addressResult,"未找到");
+            return MessageManage.getInstance().getAddressResultContent(200,addressResult,"未找到");
         }else {
-            return MessageManage.getInstance().getResultContent(200,addressResult,"成功");
+            return MessageManage.getInstance().getAddressResultContent(200,addressResult,"成功");
         }
     }
     //  根据街镇名称和村居名称返回符合条件的geojson集合文件

+ 13 - 17
src/main/java/com/skyversation/poiaddr/service/AreaService.java

@@ -120,21 +120,22 @@ public class AreaService {
 
     public void initPolygons() {
         List<List<GeoJsonBean>> lis = new ArrayList<>();
-        if ("青浦".equals(area)) {
-            lis.add(cjPolygonList);
-            lis.add(wGridPolygonList);
-            lis.add(gridPolygonList);
-        }
+        lis.add(cjPolygonList);
+        lis.add(wGridPolygonList);
+        lis.add(gridPolygonList);
         lis.add(shAllAdministrativeDivisionPolygonList);
         lis.add(shAllToensPolygonList);
         lis.add(zhGridPolygonList);
         String[] path;
-        if ("青浦".equals(area)) {
-            path = new String[]{"geojson/qp_cunju.geojson", "geojson/青浦区微网格-wgs84.geojson",
-                    "geojson/责任网格-wgs84.geojson", "geojson/sh_all_administrative_division.geojson", "geojson/sh_all_towns.geojson","geojson/青浦区综合网格.geojson"};
-        } else {
-            path = new String[]{"geojson/sh_all_administrative_division.geojson", "geojson/sh_all_towns.geojson"};
-        }
+
+        path = new String[]{
+                "geojson/qp_cunju.geojson",
+                "geojson/青浦区微网格-wgs84.geojson",
+                "geojson/责任网格-wgs84.geojson",
+                "geojson/sh_all_administrative_division.geojson",
+                "geojson/sh_all_towns.geojson",
+                "geojson/青浦区综合网格.geojson"};
+
 
 
         for (int j = 0; j < path.length; j++) {
@@ -189,11 +190,7 @@ public class AreaService {
                         resultProp.put("Shape_Area", properties.getString("Shape_Area"));
                         resultProp.put("微格网名称", properties.getString("å¾®ç½\u0091_1"));
                         geoJsonBean.setProperties(resultProp);
-                    } else if (path[j].contains("责任网格")) {
-                        geoJsonBean.setProperties(properties);
-                    } else if (path[j].contains("sh_all")) {
-                        geoJsonBean.setProperties(properties);
-                    } else if (path[j].contains("青浦区综合网格")) {
+                    } else {
                         geoJsonBean.setProperties(properties);
                     }
                     geoJsonBean.setMultiPolygon(multiPolygon);
@@ -204,7 +201,6 @@ public class AreaService {
                 System.out.println("<<<<<<<<------run geo data error------>>>>>>>>>");
             }
         }
-
         System.out.println("<<<<<<<<------run geo data complete------>>>>>>>>>");
     }
 

+ 64 - 2
src/main/java/com/skyversation/poiaddr/util/MessageManage.java

@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONException;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.skyversation.poiaddr.entity.AddressV4Result;
+import com.skyversation.poiaddr.service.AreaService;
 import lombok.extern.slf4j.Slf4j;
 
 import java.util.List;
@@ -65,14 +66,75 @@ public class MessageManage {
         return JSON.toJSONString(json, SerializerFeature.DisableCircularReferenceDetect);
     }
 
-    public String getResultContent(int code, Object bean, String message){
+    public String getAddressResultContent(int code, Object bean, String message){
         JSONObject json = new JSONObject();
         try {
             json.put("code", code);
             if(bean == null){
                 json.put("content", null);
             } else {
-                json.put("content", JSON.toJSON(bean));
+                JSONObject content = JSON.parseObject(JSON.toJSONString(bean));
+                JSONArray pois = content.getJSONArray("data");
+                for(int i = 0; i < pois.size(); i++){
+                    JSONObject poi = pois.getJSONObject(i);
+                    poi.put("parent",new JSONArray());
+                    poi.put("address",poi.getString("address")==null?"":poi.getString("address"));
+                    poi.put("distance",new JSONArray());
+                    poi.put("pname",poi.getString("pname")==null?"":poi.getString("pname"));
+                    poi.put("importance",new JSONArray());
+                    JSONObject biz_ext = new JSONObject();
+                    biz_ext.put("cost",new JSONArray());
+                    biz_ext.put("rating",new JSONArray());
+                    poi.put("biz_ext",biz_ext);
+                    poi.put("biz_type",new JSONArray());
+                    String oCityname = poi.getString("cityname");
+                    String oAdname = poi.getString("adname");
+                    poi.put("cityname",poi.get("pname"));
+                    //网格信息太复杂放最后
+                    poi.put("type",poi.getString("type")==null?"":poi.getString("type"));
+                    poi.put("parking_type","");
+                    poi.put("photos",new JSONArray());
+                    poi.put("typecode","");
+                    poi.put("shopinfo","");
+                    poi.put("poiweight",new JSONArray());
+                    poi.put("childtype",new JSONArray());
+                    poi.put("adname",oCityname);
+                    poi.put("name",poi.getString("name")==null?"":poi.getString("name"));
+                    //村居信息太复杂放最后
+                    //微网格信息太复杂放最后
+                    poi.put("location",poi.getString("location")==null?"":poi.getString("location"));
+                    poi.put("tel",new JSONArray());
+                    poi.put("shopid",new JSONArray());
+                    poi.put("id","");
+                    double x = poi.getDouble("lon");
+                    double y = poi.getDouble("lat");
+                    AreaService areaService = AreaService.getInstance();
+                    //TODO 网格信息
+                    poi.put("网格信息",areaService.isInGridPolygon(x,y).getProperties());
+                    //TODO 村居信息
+                    poi.put("村居信息",areaService.isInCJPolygon(x,y).getProperties());
+                    //TODO 微网格信息
+                    poi.put("微网格信息",areaService.isInWGridPolygon(x,y).getProperties());
+
+                }
+
+
+                content.put("pois", pois);
+                content.remove("data");
+
+
+                JSONObject suggestion = new JSONObject();
+                suggestion.put("keywords",new JSONArray());
+                suggestion.put("cities",new JSONArray());
+                content.put("suggestion",suggestion);
+                content.put("count","");
+                content.put("infocode","");
+                content.put("status","");
+                content.put("info","");
+
+
+                json.put("content", JSON.toJSON(content));
+
             }
             json.put("message", message);
         } catch (JSONException e) {

+ 16 - 5
src/main/resources/application.properties

@@ -3,11 +3,22 @@ server.servlet.context-path=/poiApi/
 spring.application.name=poiAddr
 spring.servlet.multipart.max-file-size=300MB
 spring.servlet.multipart.max-request-size=300MB
+
+spring.datasource.url=jdbc:postgresql://${DMS_DB_IP:121.43.55.7}:${DMS_DB_PORT:5433}/${ADDRESS_DB_TABLE_NAME:address}?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
+spring.datasource.username=${DMS_DB_ACCOUNT:yysz}
+spring.datasource.password=${DMS_DB_PASSWORD:Yysz@1234}
+
+#spring.datasource.url=jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
+#spring.datasource.username=postgres
+#spring.datasource.password=
+#spring.datasource.driver-class-name=org.postgresql.Driver
+
 # \u6570\u636E\u5E93\u914D\u7F6E\uFF08\u672C\u5730\u8C03\u8BD5\u73AF\u5883\uFF09
-spring.datasource.url=jdbc:postgresql://127.0.0.1:5432/postgres?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
-spring.datasource.username=postgres
-spring.datasource.password=417512
-spring.datasource.driver-class-name=org.postgresql.Driver
+#spring.datasource.url=jdbc:postgresql://192.168.2.22:5432/postgres?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
+#spring.datasource.username=postgres
+#spring.datasource.password=SKYversation0816
+#spring.datasource.driver-class-name=org.postgresql.Driver
+
 # \u6570\u636E\u5E93\u8FDE\u63A5\u4FE1\u606F\uFF08\u5F00\u53D1\u73AF\u5883\uFF09
 #spring.datasource.url=jdbc:transwarp2://172.30.75.126:31768/dws
 #spring.datasource.username=dev_sjbdc_kjyy
@@ -31,7 +42,7 @@ app.area=\u9752\u6D66
 app.town=\u6731\u5BB6\u89D2\u9547\u3001\u8D75\u5DF7\u9547\u3001\u5F90\u6CFE\u9547\u3001\u534E\u65B0\u9547\u3001\u91CD\u56FA\u9547\u3001\u767D\u9E64\u9547\u3001\u7EC3\u5858\u9547\u3001\u91D1\u6CFD\u9547\u3001\u590F\u9633\u8857\u9053\u3001\u76C8\u6D66\u8857\u9053\u3001\u9999\u82B1\u6865\u8857\u9053
 
 app.net-type=${NET_TYPE:internet}
-app.yysz-address-service=${YYSZ_POI_SERVICE:http://127.0.0.1:10012/poi}
+app.yysz-address-service=${YYSZ_POI_SERVICE:http://121.43.55.7:10013/address}
 #
 #logging.level.org.hibernate=DEBUG
 #logging.level.org.springframework=DEBUG