suerprisePlus
2024-09-03 2e9e03c7971f1da71cc9e9bd7d2f159c244839f3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
//package com.yb.controller;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONArray;
//import com.alibaba.fastjson.JSONObject;
//import com.yb.config.R;
//import com.yb.entity.ReqEntity;
//import com.yb.helper.RsaHelper;
//import com.yb.util.EntityHttpUtil;
//import io.swagger.v3.oas.annotations.Operation;
//import io.swagger.v3.oas.annotations.Parameter;
//import io.swagger.v3.oas.annotations.tags.Tag;
//import org.locationtech.jts.geom.*;
//import org.locationtech.jts.operation.buffer.BufferOp;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.*;
//
//
//@Tag(name = "新智接口")
//@RestController
//@RequestMapping("/api/v1")
//public class XzController2 {
//    @Autowired
//    WebSocketController webSocketController;
//    @Autowired
//    private EntityHttpUtil entityHttpUtil;
//    @Value("${spring.geographical.canview}")
//    String canview;
//    @Value("${spring.geographical.entityName}")
//    String entityName;
//    @Value("${spring.geographical.dbid}")
//    String dbid;
//    @Value("${spring.geographical.layerId}")
//    String layerId;
//    @Value("${spring.geographical.queryEntity}")
//    String queryEntity;
//    @Value("${spring.geographical.publickey}")
//    String publickey;
//    @Value("${spring.geographical.token}")
//    String token;
//
//
//    @PostMapping("/poiMap")
//    @Operation(summary = "显示地点")
//    public R poiMap(@RequestParam Map<String, String> allParams) throws Exception {
//        String place = allParams.get("place");
//        String mid = allParams.get("mid");
//        System.out.println("rec poiMap:" + place + "  mid:" + mid);
//        if (place == null || mid == null) {
//            return R.error("数据传递错误");
//        }
//        HashMap<String, Object> hash = new HashMap<>();
//        hash.put("func", "poiMap");
//        hash.put("mid", mid);
//        ReqEntity reqEntity = new ReqEntity();
//        String item = getQueryFiled(place);
//        JSONObject obj = JSONObject.parseObject(item);
//        reqEntity.setX(obj.getString("lon"));
//        reqEntity.setY(obj.getString("lat"));
//        reqEntity.setPlace(obj.getString("enti_name"));
//        System.out.println("rec poiMap:" + reqEntity);
//        hash.put("poi", reqEntity);
//        String message = JSON.toJSONString(hash);
//        webSocketController.sendAllMessage(message);
//        return R.ok(hash);
//    }
//
//    @PostMapping("/aroundPoi")
//    @Operation(summary = "周边属性查询")
//    public R aroundPoi(@RequestParam Map<String, String> allParams) throws Exception {
//        System.out.println("rec aroundPoi:" + allParams);
//        String place = allParams.get("place");
//        String mid = allParams.get("mid");
//        String type = allParams.get("type");
//        String dis = allParams.get("radius");
//        int radius= 0;
//        if(dis != null){
//            radius= Integer.parseInt(dis);
//        }
////        int radius = Integer.parseInt();
//        System.out.println("rec aroundPoi:" + place + "  mid:" + mid + "  type:" + type + "  radius:" + radius);
//        if (type == null || place == null || mid == null) {
//            return R.error("数据传递错误");
//        }
//        HashMap<String, Object> hash = new HashMap<>();
//        hash.put("func", "aroundPoi");
//        hash.put("mid", mid);
//        System.out.println("rec aroundPoi:" + place + "  mid:" + mid + "  type:" + type + "  radius:" + radius);
//        String item = getQueryFiled(place);
//        JSONObject obj = JSONObject.parseObject(item);
//        Double lon = Double.parseDouble(obj.getString("lon"));
//        Double lat = Double.parseDouble(obj.getString("lat"));
//        String wkt = getWKt(lon, lat, radius);
//        String itemList = getQueryAround(type, wkt);
////        System.out.print("ces: "+itemList);
//        JSONArray dataArray = JSONArray.parseArray(itemList);
//        ArrayList<ReqEntity> arrayList = new ArrayList<>();
//        for (int i = 0; i < dataArray.size(); i++) {
//            Object element = dataArray.get(i);
//            if (element instanceof JSONObject) {
//                JSONObject jsonObject = (JSONObject) element;
//                ReqEntity reqEntity = new ReqEntity();
//                reqEntity.setX(jsonObject.getString("lon"));
//                reqEntity.setY(jsonObject.getString("lat"));
//                reqEntity.setPlace(jsonObject.getString("enti_name"));
//                arrayList.add(reqEntity);
//            }
//        }
//        System.out.println("rec aroundPoi:" + arrayList);
//        hash.put("poi", arrayList);
//        String message = JSON.toJSONString(hash);
//        webSocketController.sendAllMessage(message);
//        return R.ok(hash);
//    }
//
//    @PostMapping("/queryMeta")
//    @Operation(summary = "元信息查询")
//    public R queryMeta(@RequestParam Map<String, String> allParams) {
//        String mid = allParams.get("mid");
//        System.out.println("rec queryMeta:" +"  mid:" + mid);
//        if (mid == null) {
//            return R.error("数据传递错误");
//        }
//        HashMap<String, Object> hash = new HashMap<>();
//        hash.put("func", "queryMeta");
//        hash.put("mid", mid);
////        统计查询接口拼接
//        JSONArray jsonArray = new JSONArray();
//        HashMap<String, Object> staticField = new HashMap<>();
//        String filed = "sjnr";
//        staticField.put("type", "count");
//        staticField.put("field", "sjnr");
//        staticField.put("outfield", "count_" + filed);
//        jsonArray.add(staticField);
//        HashMap<String, String> formData = getHashMap();
//        formData.put("statistics", jsonArray.toString());
//        formData.put("groupby", filed);
//        String filedString = entityHttpUtil.getPostMessage(queryEntity, formData);
//        System.out.println("rec queryMeta:" + filedString);
//        JSONObject jsonObject = JSON.parseObject(filedString);
//        JSONArray dataArray = jsonObject.getJSONArray("data");
//        HashMap<String, Object> markMap = new HashMap<>();
//        JSONArray markArray = new JSONArray();
//        String markDown = "| 数据类型 | 数据量 |\\n|------|------|\\n";
//        for (int i = 0; i < dataArray.size(); i++) {
//            JSONObject dataObj = dataArray.getJSONObject(i);
//            System.out.println("rec queryMeta:" + dataObj);
//            String[] filedValue = new String[2];
//
//            for (String key : dataObj.keySet()) {
//                if (key == filed) {
//                    filedValue[0] = dataObj.getString(key);
//                } else {
//                    filedValue[1] = dataObj.getString(key);
//                }
//            }
//            markDown += "| " + filedValue[0] + " | " + filedValue[1] + " |\n";
//        }
//
//        markMap.put("markdown", markDown);
//        markArray.add(markMap);
//        hash.put("markdown", markArray);
//        hash.put("content", "地理实体数据库");
//        System.out.println("rec queryMeta:" + hash);
//        String message = JSON.toJSONString(hash);
//        webSocketController.sendAllMessage(message);
//        return R.ok(hash);
//    }
//
//    public HashMap getHashMap() {
//        HashMap<String, String> hashMap = new HashMap<>();
//        hashMap.put("token", token);
//        hashMap.put("containCount", "true");
//        hashMap.put("layerid", layerId);
//        hashMap.put("dbid", dbid);
//        return hashMap;
//    }
//
//    public String getWKt(double lon, double lat, int radius) {
//        // 创建一个坐标点
//        Coordinate coord = new Coordinate(lon, lat);
//        // 创建GeometryFactory实例,并指定坐标参考系统为WGS84
//        GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4326);
//        // 使用坐标创建一个点
//        Point point = geometryFactory.createPoint(coord);
//        // 创建BufferOp实例,用于生成缓冲区
//        BufferOp bufferOp = new BufferOp(point);
//        int dis = 500;
//        if (radius != 0) {
//            dis = radius;
//        }
//        // 设置缓冲区距离为500米
//        Geometry bufferedGeometry = bufferOp.getResultGeometry(dis);
//        // 创建WKTWriter实例,用于将Geometry转换为WKT格式
////        WKTWriter wktWriter = new WKTWriter();
//
//        // 将缓冲区Geometry转换为WKT格式
////        String wkt = wktWriter.write(bufferedGeometry);
//        // 输出WKT
////        System.out.println("WKT: " + wkt);
//        Envelope envelope = bufferedGeometry.getEnvelopeInternal();
//        double[] wkt = new double[4];
//        wkt[0] = envelope.getMinX();
//        wkt[1] = envelope.getMinY();
//        wkt[2] = envelope.getMaxX();
//        wkt[3] = envelope.getMaxY();
//        String arrayAsString = Arrays.toString(wkt);
//        System.out.println("arrayAsString: " + arrayAsString);
//        return arrayAsString;
//    }
//
//    public String getQueryAround(String type, String wkt) throws Exception {
//        String query = "sjnr  like '%" + type + "%'" + "";
//        String key = getPublickey();
//        String encrypt = RsaHelper.encrypt(key, query);
//        HashMap formData = getHashMap();
//        formData.put("start", "1");
//        formData.put("count", "0");
//        formData.put("where", encrypt);
//        formData.put("box", wkt);
//        String jsonString = entityHttpUtil.getPostMessage(queryEntity, formData);
//        JSONObject jsonObject = JSON.parseObject(jsonString);
//        JSONObject dataObjject = jsonObject.getJSONObject("data");
//        JSONArray dataArray = dataObjject.getJSONArray("items");
//        return dataArray.toString();
//    }
//
//    //关键字查询
//    public String getQueryFiled(String place) throws Exception {
//        String query = "enti_name like '%" + place + "%'" + "";
//        String key = getPublickey();
//        String encrypt = RsaHelper.encrypt(key, query);
//        HashMap formData = getHashMap();
//        formData.put("start", "1");
//        formData.put("count", "0");
//        formData.put("where", encrypt);
//        String jsonString = entityHttpUtil.getPostMessage(queryEntity, formData);
//        JSONObject jsonObject = JSON.parseObject(jsonString);
//        JSONObject dataObjject = jsonObject.getJSONObject("data");
//        JSONArray dataArray = dataObjject.getJSONArray("items");
//        return dataArray.getJSONObject(0).toString();
//    }
//
//    //获取秘钥接口
//    public String getPublickey() {
//        HashMap<String, String> map = new HashMap<>();
//        map.put("token", token);
//        String jsonString = entityHttpUtil.getPostMessage(publickey, map);
//        JSONObject jsonObject = JSON.parseObject(jsonString);
//        return jsonObject.getString("data");
//    }
//
//
//    @PostMapping("/aroundPoi2")
//    @Operation(summary = "周边查询")
//    public R aroundPoi2(@RequestBody ReqEntity reqEntity) {
//        System.out.println("rec message:" + reqEntity);
//        HashMap<String, Object> hash = new HashMap<>();
//        hash.put("func", "aroundPoi");
//        hash.put("mid", "mid");
//        List<ReqEntity> list = new ArrayList<>();
////        reqEntity.setX("120.9671");
////        reqEntity.setY("13.5748");
//        list.add(reqEntity);
//        list.add(reqEntity);
//        hash.put("poi", list);
//
//        String message = JSON.toJSONString(hash);
//        webSocketController.sendAllMessage(message);
//
//        return R.ok(hash);
//    }
//
//
//    /*@GetMapping("/queryPath/{start_point}/{end_point}")
//    @Operation(summary = "路线查询")
//    public R queryPath(@PathVariable("start_point")String start_point,@PathVariable("end_point")String end_point){
//        System.out.println("rec start_point: "+start_point+"  end_point: "+end_point);
//        HashMap<String,Object> hash = new HashMap<>();
//
//        hash.put("func","searchPath");
//        List<ReqEntity> list = new ArrayList<>();
//
//        hash.put("path",list);
//
//        String message = JSON.toJSONString(hash);
//        webSocketController.sendAllMessage(message);
//
//        return R.ok(hash);
//    }
//*/
//    @PostMapping("/queryMeta2")
//    @Operation(summary = "元信息查询")
//    public R queryMeta2(@Parameter String mid) {
//        System.out.println("queryMeta ");
//        HashMap<String, Object> hash = new HashMap<>();
//        hash.put("func", "queryMeta");
//        hash.put("mid", mid);
//        List<ReqEntity> list = new ArrayList<>();
//        hash.put("meta", list);
//        String message = JSON.toJSONString(hash);
//        webSocketController.sendAllMessage(message);
//
//        return R.ok(hash);
//    }
//}