当问到库中不存在的数据时,直接卡死,如问题:查看台湾花莲机场之间的关系、战场环境总结报告
| | |
| | | }
|
| | | // 意图函数匹配
|
| | | HashMap<String, Object> mapObj = intentionService.getFunctionMatch(orderString, allParams);
|
| | | // hashMap.put("place",place)
|
| | | String args = JSONObject.parseObject(orderString).getString("args");
|
| | | if(args!= null){
|
| | | String place = JSONObject.parseObject(args).getString("place");
|
| | | mapObj.put("place",place);
|
| | | }
|
| | | hashMap.put("content", mapObj);
|
| | | return R.ok(hashMap);
|
| | |
|
| | |
| | | import org.apache.commons.codec.binary.Base64;
|
| | |
|
| | | import javax.crypto.Cipher;
|
| | | import java.io.IOException;
|
| | | import java.security.KeyFactory;
|
| | | import java.security.interfaces.RSAPublicKey;
|
| | | import java.security.spec.X509EncodedKeySpec;
|
| | |
| | | public class RsaHelper {
|
| | | // RsA秘钥加密
|
| | | public static String encrypt(String key, String str) throws Exception {
|
| | | // Base64编码的公钥
|
| | | try {
|
| | | byte[] decoded = Base64.decodeBase64(key + "");
|
| | |
|
| | | RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded));
|
| | |
| | | String outStr = Base64.encodeBase64String(cipher.doFinal(str.getBytes("UTF-8")));
|
| | |
|
| | | return outStr;
|
| | | } catch (IOException e) {
|
| | | System.out.println(e.getMessage());
|
| | | return null;
|
| | | }
|
| | | // Base64编码的公钥
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | String key = "msg";
|
| | | String msg = (String) poiMap.get(key);
|
| | | hashMap.put("msg", msg);
|
| | | String center = (String) poiMap.get("center");
|
| | | if(center != null){
|
| | | hashMap.put("data", poiMap);
|
| | | }
|
| | |
|
| | | return hashMap;
|
| | | }
|
| | |
|
| | |
| | | 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++) {
|
| | |
| | |
|
| | | }
|
| | |
|
| | |
|
| | | // 关键字查询分类查询数据量
|
| | | private ArrayList getQueryByFiledList(String name) throws Exception {
|
| | | String obj = xzConfig.typeFiled + " = '" + name + "'" + "";
|
| | |
| | | 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");
|
| | |
| | | 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);
|
| | |
| | |
|
| | | }
|
| | | 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;
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | |
| | | import org.locationtech.proj4j.CoordinateTransform;
|
| | | import org.locationtech.proj4j.CoordinateTransformFactory;
|
| | | import org.locationtech.proj4j.ProjCoordinate;
|
| | |
|
| | | import java.util.HashMap;
|
| | |
|
| | | @Service
|
| | |
| | |
|
| | | // 关键字查询
|
| | | public String getQueryFiled(String place, String filed, String layerId, String dbId, String queryEntity) throws Exception {
|
| | | String query = "";
|
| | |
|
| | | String valSql = " like '%" + place + "%'";
|
| | | String key = getPublickey();
|
| | | if (filed.indexOf(",") > -1) {
|
| | | String[] fileds = filed.split(",");
|
| | | for (int i = 0; i < fileds.length; i++) {
|
| | | String name = fileds[i];
|
| | | if (i > 0) {
|
| | | query += " or ";
|
| | | }
|
| | | query += name + valSql;
|
| | | }
|
| | | } else {
|
| | | query += filed + valSql;
|
| | | }
|
| | | query += "";
|
| | | System.out.println("rec getQueryFiled:" + query);
|
| | | String encrypt = RsaHelper.encrypt(key, query);
|
| | | HashMap formData = getHashMap(layerId, dbId, "1", "0", encrypt, null);
|
| | | String querySQL = getQuerySql(valSql, filed);
|
| | | HashMap formData = getHashMap(layerId, dbId, "1", "0", querySQL, null);
|
| | | String jsonString = entityHttpUtil.getPostMessage(queryEntity, formData);
|
| | | System.out.println("rec getQueryFiled:" + jsonString);
|
| | | JSONObject jsonObject = JSON.parseObject(jsonString);
|
| | |
| | | return "";
|
| | | }
|
| | |
|
| | | // 关键字查询
|
| | | public String getQueryEntity(String place, String filed, String layerId, String dbId, String queryEntity) throws Exception {
|
| | | String query = "";
|
| | | String valSql = " like '%" + place + "%'";
|
| | | private String getQuerySql(String valSql, String filed) throws Exception {
|
| | | String key = getPublickey();
|
| | | String querySQL = "";
|
| | | if (filed.indexOf(",") > -1) {
|
| | | String[] fileds = filed.split(",");
|
| | | for (int i = 0; i < fileds.length; i++) {
|
| | | String name = fileds[i];
|
| | | if (i > 0) {
|
| | | query += " or ";
|
| | | querySQL += ";";
|
| | | }
|
| | | query += name + valSql;
|
| | | String Sql = name + valSql + "";
|
| | | querySQL += RsaHelper.encrypt(key, Sql);
|
| | | }
|
| | | } else {
|
| | | query += filed + valSql;
|
| | | String Sql = filed + valSql + "";
|
| | | querySQL = RsaHelper.encrypt(key, Sql);
|
| | | }
|
| | | query += "";
|
| | | String encrypt = RsaHelper.encrypt(key, query);
|
| | | HashMap formData = getHashMap(layerId, dbId, "1", "100", encrypt, null);
|
| | | return querySQL;
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | | // 关键字查询
|
| | | public String getQueryEntity(String place, String filed, String layerId, String dbId, String queryEntity) throws Exception {
|
| | | String valSql = " like '%" + place + "%'";
|
| | | String querySQL = getQuerySql(valSql, filed);
|
| | | HashMap formData = getHashMap(layerId, dbId, "1", "100", querySQL, null);
|
| | | formData.put("querytype", "entity");
|
| | | String jsonString1 = entityHttpUtil.getPostMessage(queryEntity, formData);
|
| | | System.out.println("rec getQueryFiled:" + jsonString1);
|
| | |
| | | // 范围查询
|
| | | public String getQueryAround(String type, String wkt, String filed, String layerId, String dbid, String entity) throws Exception {
|
| | | String query = filed + " like '%" + type + "%'" + "";
|
| | | if (type.contains("全部目标")) {
|
| | | query = filed + " like '%目标%'" + "";
|
| | | }
|
| | | String encrypt = RsaHelper.encrypt(getPublickey(), query);
|
| | | HashMap formData = getHashMap(layerId, dbid, "1", "0", encrypt, wkt);
|
| | | formData.put("querytype","entity");
|
| | |
| | | }
|
| | |
|
| | |
|
| | |
|
| | | //生成WKT
|
| | | public String getWKt(double lon, double lat, int radius) throws Exception {
|
| | | // 创建一个坐标点
|
| | |
| | | // 创建BufferOp实例,用于生成缓冲区
|
| | | BufferOp bufferOp = new BufferOp(point);
|
| | | int dis = 500;
|
| | | // if (radius != 0) {
|
| | | // dis = radius;
|
| | | // }
|
| | | if (radius != 0) {
|
| | | dis = radius;
|
| | | }
|
| | | // 设置缓冲区距离为500米
|
| | | Geometry bufferedGeometry = bufferOp.getResultGeometry(dis / 111319.9);
|
| | | // 创建WKTWriter实例,用于将Geometry转换为WKT格式
|
| | |
| | | CoordinateTransform transform = ctFactory.createTransform(src, dest);
|
| | |
|
| | | // 定义一个源坐标点(经度,纬度)
|
| | | ProjCoordinate srcgetMin = new ProjCoordinate( envelope.getMinX(), envelope.getMinY()); // 例如:北京的经纬度
|
| | | ProjCoordinate srcgetMax = new ProjCoordinate( envelope.getMaxX(), envelope.getMaxY()); // 例如:北京的经纬度
|
| | | ProjCoordinate srcgetMin = new ProjCoordinate(envelope.getMinX(), envelope.getMinY(), 0); // 例如:北京的经纬度
|
| | | ProjCoordinate srcgetMax = new ProjCoordinate(envelope.getMaxX(), envelope.getMaxY(), 0); // 例如:北京的经纬度
|
| | | // 执行转换
|
| | | ProjCoordinate destgetMin = new ProjCoordinate();
|
| | | ProjCoordinate destgetMax = new ProjCoordinate();
|
| | | System.out.println("转换后的坐标:X = " + srcgetMin);
|
| | | transform.transform(srcgetMin, destgetMin);
|
| | | transform.transform(srcgetMax, destgetMax);
|
| | | String wkt =destgetMin.x+","+destgetMin.y+","+destgetMax.x+","+destgetMax.y;
|
| | |
| | | return response.body().string();
|
| | | } catch (IOException e) {
|
| | | System.out.println(e.getMessage());
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public String getAgentMessage(String aurl) {
|
| | |
| | | return response.body().string();
|
| | | } catch (IOException e) {
|
| | | System.out.println(e.getMessage());
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | |
| | | return response.body().string();
|
| | | } catch (IOException e) {
|
| | | System.out.println(e.getMessage());
|
| | | }
|
| | | return null;
|
| | | }
|
| | | // return null;
|
| | | }
|
| | |
|
| | | public String postAgentMessage(String aurl, Map<String, String> parms) {
|
| | |
| | | return response.body().string();
|
| | | } catch (IOException e) {
|
| | | System.out.println(e.getMessage());
|
| | | }
|
| | | return null;
|
| | | }
|
| | | // return null;
|
| | |
|
| | |
|
| | |
|