Explorar o código

Merge branch 'master' of http://47.110.251.215:3000/java_org/bladex

liuyc %!s(int64=3) %!d(string=hai) anos
pai
achega
f2efc57f16

+ 48 - 0
blade-common/src/main/java/org/springblade/common/utils/BaiduApiUtil.java

@@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
@@ -51,4 +52,51 @@ public class BaiduApiUtil {
         return map;
     }
 
+    /**
+     * 根据项目位置获取经纬度
+     */
+    public static Map<String, Object> geocoding(String address)
+            throws IOException {
+        Map<String, Object> map = new HashMap<>();
+        BufferedReader in = null;
+        String getUrl = "http://api.map.baidu.com/geocoding/v3/?address=" + address + "&output=json&ak=" + API_AK;
+        URL url = new URL(getUrl);
+        in = new BufferedReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8));
+        String res;
+        StringBuilder sb = new StringBuilder("");
+        while ((res = in.readLine()) != null) {
+            sb.append(res.trim());
+        }
+        JSONObject jsonData = JSONObject.parseObject(sb.toString());
+        JSONObject result = (JSONObject) jsonData.get("result");
+        JSONObject location = (JSONObject) result.get("location");
+        map.put("lat", location.get("lat").toString());
+        map.put("lng", location.get("lng").toString());
+        return map;
+    }
+
+    /**
+     * 根据经纬度坐标解析地址详情
+     */
+    public static Map<String, String> getPosition(String LatitudeAndLongitude)
+            throws IOException {
+        Map<String, String> map = new HashMap<>();
+        String getUrl = "http://api.map.baidu.com/reverse_geocoding/v3/?ak=" + API_AK + "&output=json&coordtype=wgs84ll&location=" + LatitudeAndLongitude;
+        URL url = new URL(getUrl);
+        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8));
+        String res;
+        StringBuilder sb = new StringBuilder("");
+        while ((res = in.readLine()) != null) {
+            sb.append(res.trim());
+        }
+        JSONObject jsonData = JSONObject.parseObject(sb.toString());
+        JSONObject result = (JSONObject) jsonData.get("result");
+        JSONObject addressComponent = (JSONObject) result.get("addressComponent");
+        map.put("province", addressComponent.get("province").toString());
+        map.put("city", addressComponent.get("city").toString());
+        map.put("district", addressComponent.get("district").toString());
+        map.put("adcode", addressComponent.get("adcode").toString());
+        return map;
+    }
+
 }

+ 46 - 0
blade-service/blade-business/src/main/java/sql/m_project_contract_area.sql

@@ -0,0 +1,46 @@
+/*
+ Navicat Premium Data Transfer
+
+ Source Server         : localhost
+ Source Server Type    : MySQL
+ Source Server Version : 50651
+ Source Host           : localhost:3306
+ Source Schema         : bladex
+
+ Target Server Type    : MySQL
+ Target Server Version : 50651
+ File Encoding         : 65001
+
+ Date: 26/05/2022 16:45:16
+*/
+
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for m_project_contract_area
+-- ----------------------------
+DROP TABLE IF EXISTS `m_project_contract_area`;
+CREATE TABLE `m_project_contract_area`  (
+  `id` bigint(64) NOT NULL COMMENT '主键',
+  `project_id` bigint(64) NOT NULL COMMENT '项目ID',
+  `contract_id` bigint(64) NOT NULL COMMENT '合同段ID',
+  `province` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '省',
+  `city` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '市',
+  `county` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '县/区',
+  `city_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '编码',
+  `create_user` bigint(64) NULL DEFAULT NULL COMMENT '创建人',
+  `create_dept` bigint(64) NULL DEFAULT NULL COMMENT '创建人所在部门',
+  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
+  `update_user` bigint(64) NULL DEFAULT NULL COMMENT '修改人',
+  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
+  `status` int(10) NULL DEFAULT NULL COMMENT '状态',
+  `is_deleted` int(10) NULL DEFAULT NULL COMMENT '是否已删除,默认0',
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '项目合同段所在地区表' ROW_FORMAT = Compact;
+
+-- ----------------------------
+-- Records of m_project_contract_area
+-- ----------------------------
+
+SET FOREIGN_KEY_CHECKS = 1;