suerprisePlus
2024-08-27 e9b4cda4c70a3e0185767dee8ac2e4e6f5049ac7
src/main/java/com/yb/controller/XzController.java
@@ -1,57 +1,108 @@
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Tag(name="新智接口")
@Tag(name = "新智接口")
@RestController
@RequestMapping("/api/v1")
public class XzController {
    @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;
    private JSONObject jsonObject;
    @PostMapping("/poiMap")
    @Operation(summary = "显示地点")
    public R poiMap(@Parameter String place,@Parameter String mid){
        System.out.println("rec message:"+place+"  mid:"+mid);
        HashMap<String,Object> hash = new HashMap<>();
        hash.put("func","poiMap");
        hash.put("mid","mid");
    public R poiMap(@Parameter String place, @Parameter String mid) throws Exception {
        System.out.println("rec message:" + place + "  mid:" + mid);
        HashMap<String, Object> hash = new HashMap<>();
        hash.put("func", "poiMap");
        hash.put("mid", mid);
        ReqEntity reqEntity = new ReqEntity();
        reqEntity.setPlace(place);
        reqEntity.setX("120.9671");
        reqEntity.setY("13.5748");
        hash.put("poi",reqEntity);
        String message = JSON.toJSONString(hash);
        webSocketController.sendAllMessage(message);
        String query = "enti_name like '%" + place + "%'" + "";
        String key = getPublickey();
        String encrypt = RsaHelper.encrypt(key, query);
        HashMap formData = new HashMap<>();
        formData.put("token", token);
        formData.put("start", "1");
        formData.put("count", "0");
        formData.put("containCount", "true");
        formData.put("layerid", layerId);
        formData.put("dbid", dbid);
        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");
        JSONObject item = dataArray.getJSONObject(0);
        reqEntity.setX(item.getString("lon"));
        reqEntity.setY(item.getString("lat"));
        System.out.print(item);
        reqEntity.setPlace(item.getString("enti_name"));
        hash.put("poi", reqEntity);
        return R.ok(hash);
    }
    //获取秘钥接口
    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("/aroundPoi")
    @Operation(summary = "周边查询")
    public R aroundPoi(@RequestBody ReqEntity reqEntity){
        System.out.println("rec message:"+reqEntity);
        HashMap<String,Object> hash = new HashMap<>();
        hash.put("func","aroundPoi");
        hash.put("mid","mid");
    public R aroundPoi(@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");
//        reqEntity.setX("120.9671");
//        reqEntity.setY("13.5748");
        list.add(reqEntity);
        list.add(reqEntity);
        hash.put("poi",list);
        hash.put("poi", list);
        String message = JSON.toJSONString(hash);
        webSocketController.sendAllMessage(message);
@@ -78,14 +129,14 @@
*/
    @PostMapping("/queryMeta")
    @Operation(summary = "元信息查询")
    public R queryMeta(@Parameter String mid){
    public R queryMeta(@Parameter String mid) {
        System.out.println("queryMeta ");
        HashMap<String,Object> hash = new HashMap<>();
        hash.put("func","queryMeta");
        hash.put("mid",mid);
        HashMap<String, Object> hash = new HashMap<>();
        hash.put("func", "queryMeta");
        hash.put("mid", mid);
        List<ReqEntity> list = new ArrayList<>();
        hash.put("meta",list);
        hash.put("meta", list);
        String message = JSON.toJSONString(hash);
        webSocketController.sendAllMessage(message);