| | |
| | | return null; |
| | | } |
| | | |
| | | public static String getLoginPublicKey() { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | String json = jsonObject.toJSONString(); |
| | | // 发送JSON格式的POST请求 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | | HttpEntity<String> request = new HttpEntity<>(json, headers); |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | ResponseEntity<String> responseEntity = restTemplate.postForEntity("http://106.120.22.26:8024/account-service/security/publickey", request, String.class); |
| | | if (responseEntity.getStatusCode().is2xxSuccessful()) { |
| | | String body = responseEntity.getBody(); |
| | | return JSONObject.parseObject(body).getString("data"); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 登录实体库 |
| | | * |
| | | * @return 参数内详情 |
| | | */ |
| | | public static String login() throws Exception { |
| | | String publicKey = getLoginPublicKey(); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("userid", "admin"); |
| | | jsonObject.put("password", encrypt("admin", publicKey)); |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | // 发送JSON格式的POST请求 |
| | | StringHttpMessageConverter converter = new StringHttpMessageConverter(StandardCharsets.UTF_8); |
| | | converter.setSupportedMediaTypes(MediaType.parseMediaTypes("text/plain;charset=UTF-8")); |
| | | restTemplate.getMessageConverters().add(0, converter); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | | headers.add("Access-Control-Allow-Origin", "*"); |
| | | String json = jsonObject.toJSONString(); |
| | | HttpEntity<String> request = new HttpEntity<>(json, headers); |
| | | ResponseEntity<String> responseEntity = restTemplate.exchange("http://106.120.22.26:8024/account-service/security/login", HttpMethod.POST, request, String.class); |
| | | if (responseEntity.getStatusCode().is2xxSuccessful()) { |
| | | String body = responseEntity.getBody(); |
| | | return JSONObject.parseObject(body).getJSONObject("data").getString("token"); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static String encrypt(String str, String publicKey) throws Exception { |
| | | //Base64编码的公钥 |
| | | byte[] decoded = Base64.decodeBase64(publicKey); |
| | |
| | | * @param dtos 四个坐标点 |
| | | * @return 框选内部管线 |
| | | */ |
| | | public static JSONArray getPointInfo(List<GridDto> dtos) { |
| | | public static JSONArray getPointInfo(List<GridDto> dtos, String token) { |
| | | JSONArray paramArray = new JSONArray(); |
| | | for (GridDto dto : dtos |
| | | ) { |
| | | paramArray.add(ProjectionToGeographicUtil.get4548Point(dto.getLon(), dto.getLat())); |
| | | } |
| | | paramArray.add(ProjectionToGeographicUtil.get4548Point(dtos.get(0).getLon(), dtos.get(0).getLat())); |
| | | JSONObject jsonObject = getModule("layerQueryPointParams.json"); |
| | | jsonObject.getJSONObject("geometry").getJSONArray("coordinates").add(paramArray); |
| | | jsonObject.put("token", token); |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | // 发送JSON格式的POST请求 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | | String json = jsonObject.toJSONString(); |
| | | HttpEntity<String> request = new HttpEntity<>(json, headers); |
| | | ResponseEntity<String> responseEntity = restTemplate.postForEntity("http://106.120.22.26:8024/geo-service/entitydbdata/layer/query", request, String.class); |
| | | if (responseEntity.getStatusCode().is2xxSuccessful()) { |
| | | String body = responseEntity.getBody(); |
| | | return JSONObject.parseObject(body).getJSONObject("data").getJSONArray("items"); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | * 管线列表 |
| | | * |
| | | * @param dtos 四个坐标点 |
| | | * @return 框选内部管线 |
| | | */ |
| | | public static JSONArray getLineInfo(List<GridDto> dtos, String token) { |
| | | JSONArray paramArray = new JSONArray(); |
| | | for (GridDto dto : dtos |
| | | ) { |
| | |
| | | paramArray.add(ProjectionToGeographicUtil.get4548Point(dtos.get(0).getLon(), dtos.get(0).getLat())); |
| | | JSONObject jsonObject = getModule("layerQueryParams.json"); |
| | | jsonObject.getJSONObject("geometry").getJSONArray("coordinates").add(paramArray); |
| | | jsonObject.put("token", token); |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | // 发送JSON格式的POST请求 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | |
| | | * @param param 查询参数 |
| | | * @return 参数内详情 |
| | | */ |
| | | public static JSONArray getPointDetail(String param) { |
| | | public static JSONArray getLineDetail(String param,String token) { |
| | | JSONObject jsonObject = getModule("layerQueryDetailParams.json"); |
| | | jsonObject.put("where", param); |
| | | jsonObject.put("token",token); |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | // 发送JSON格式的POST请求 |
| | | StringHttpMessageConverter converter = new StringHttpMessageConverter(StandardCharsets.UTF_8); |