Ver código fonte

添加oauth用户认证,打包配置

DESKTOP-6LTVLN7\Liumouren 1 mês atrás
pai
commit
8cd793f3d5
27 arquivos alterados com 1522 adições e 364 exclusões
  1. 1 0
      .gitignore
  2. 5 9
      pom.xml
  3. 2 1
      src/main/java/com/skyversation/poiaddr/PoiAddrApplication.java
  4. 6 7
      src/main/java/com/skyversation/poiaddr/addquery/AddressQueryEngine.java
  5. 78 0
      src/main/java/com/skyversation/poiaddr/config/AuthInterceptor.java
  6. 21 0
      src/main/java/com/skyversation/poiaddr/config/GlobalExceptionHandler.java
  7. 14 0
      src/main/java/com/skyversation/poiaddr/config/WebConfig.java
  8. 15 46
      src/main/java/com/skyversation/poiaddr/controller/PoiAddressController.java
  9. 0 11
      src/main/java/com/skyversation/poiaddr/dao/PoiAddressRepository.java
  10. 14 0
      src/main/java/com/skyversation/poiaddr/entity/AddressV4Result.java
  11. 317 0
      src/main/java/com/skyversation/poiaddr/entity/PYToken.java
  12. 0 163
      src/main/java/com/skyversation/poiaddr/entity/PoiAddress.java
  13. 55 0
      src/main/java/com/skyversation/poiaddr/entity/ProxyItem.java
  14. 106 0
      src/main/java/com/skyversation/poiaddr/entity/UserRecord.java
  15. 28 0
      src/main/java/com/skyversation/poiaddr/entity/VerifyBean.java
  16. 56 50
      src/main/java/com/skyversation/poiaddr/service/AreaService.java
  17. 0 12
      src/main/java/com/skyversation/poiaddr/service/PoiAddressService.java
  18. 0 49
      src/main/java/com/skyversation/poiaddr/service/impl/PoiAddressServiceImpl.java
  19. 158 0
      src/main/java/com/skyversation/poiaddr/util/Constant.java
  20. 134 0
      src/main/java/com/skyversation/poiaddr/util/MessageManage.java
  21. 46 0
      src/main/java/com/skyversation/poiaddr/util/PYVerify.java
  22. 8 6
      src/main/java/com/skyversation/poiaddr/util/geotools/GeoJsonIntersector.java
  23. 154 0
      src/main/java/com/skyversation/poiaddr/util/net/MultiThreadedAsyncHttpClient.java
  24. 242 0
      src/main/java/com/skyversation/poiaddr/util/net/NetTools.java
  25. 58 0
      src/main/java/com/skyversation/poiaddr/util/test/NetworkRequestTest.java
  26. 3 0
      src/main/resources/META-INF/MANIFEST.MF
  27. 1 10
      src/main/resources/application.properties

+ 1 - 0
.gitignore

@@ -31,3 +31,4 @@ build/
 
 ### VS Code ###
 .vscode/
+output/

+ 5 - 9
pom.xml

@@ -9,10 +9,11 @@
         <relativePath/> <!-- lookup parent from repository -->
     </parent>
     <groupId>com.skyversation</groupId>
-    <artifactId>place_name_search</artifactId>
+    <artifactId>poiaddr</artifactId>
     <version>0.0.1-SNAPSHOT</version>
-    <name>place_name_search</name>
-    <description>place_name_search</description>
+    <name>poiaddr</name>
+    <description>poiaddr</description>
+    <packaging>jar</packaging>
     <url/>
     <licenses>
         <license/>
@@ -28,7 +29,7 @@
     </scm>
     <properties>
         <geotools.version>25.2</geotools.version>
-        <java.version>17</java.version>
+        <java.version>11</java.version>
     </properties>
     <dependencies>
         <dependency>
@@ -134,11 +135,6 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>
-        <!-- Spring Data JPA -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-data-jpa</artifactId>
-        </dependency>
         <!-- PostgreSQL -->
         <dependency>
             <groupId>org.postgresql</groupId>

+ 2 - 1
src/main/java/com/skyversation/poiaddr/PoiAddrApplication.java

@@ -2,8 +2,9 @@ package com.skyversation.poiaddr;
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
 import org.springframework.scheduling.annotation.EnableScheduling;
-@SpringBootApplication
+@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
 @EnableScheduling
 public class PoiAddrApplication {
     public static void main(String[] args) {

+ 6 - 7
src/main/java/com/skyversation/poiaddr/addquery/AddressQueryEngine.java

@@ -288,7 +288,7 @@ public class AddressQueryEngine {
      */
     public AddressResult.ContentBean verificaData(AddressResult result, AddressLevel level, String addr) {
         switch (level) {
-            case LEVEL_1 -> {
+            case LEVEL_1: {
                 if (result != null && result.getData() != null && result.getData().size() > 0) {
                     return result.getData().get(0);
                 } else {
@@ -296,7 +296,7 @@ public class AddressQueryEngine {
                 }
             }
 //          2. 搜索到结果去除行政区划后,存在包含关系,则使用;
-            case LEVEL_CONTAINS_2 -> {
+            case LEVEL_CONTAINS_2: {
                 if (result != null && result.getData() != null && result.getData().size() > 0) {
                     List<AddressResult.ContentBean> contentBean = result.getData();
                     for (AddressResult.ContentBean contentBean1 : contentBean) {
@@ -311,7 +311,7 @@ public class AddressQueryEngine {
                 }
             }
 //          3. 搜索到结果,数字进行分词,数字匹配则使用;
-            case LEVLE_NUMBER_3 -> {
+            case LEVLE_NUMBER_3: {
                 if (result != null && result.getData() != null && result.getData().size() > 0) {
                     List<AddressResult.ContentBean> contentBean = result.getData();
                     for (AddressResult.ContentBean contentBean1 : contentBean) {
@@ -326,7 +326,7 @@ public class AddressQueryEngine {
                 }
             }
 //          4. 搜索到结果,数字与文本均匹配,则使用;
-            case LEVEL_NUMBER_TEXT_4 -> {
+            case LEVEL_NUMBER_TEXT_4: {
                 if (result != null && result.getData() != null && result.getData().size() > 0) {
                     List<AddressResult.ContentBean> contentBean = result.getData();
                     for (AddressResult.ContentBean contentBean1 : contentBean) {
@@ -343,7 +343,7 @@ public class AddressQueryEngine {
                 }
             }
 //          结果与基准数据完全一致,则使用。
-            case LEVEL_TOTAL_CONTAINS_5 -> {
+            case LEVEL_TOTAL_CONTAINS_5: {
                 if (result != null && result.getData() != null && result.getData().size() > 0) {
                     List<AddressResult.ContentBean> contentBean = result.getData();
                     for (AddressResult.ContentBean contentBean1 : contentBean) {
@@ -357,11 +357,10 @@ public class AddressQueryEngine {
                     return null;
                 }
             }
-            default -> {
+            default: {
                 return null;
             }
         }
-        return null;
     }
 
     public static String addressReplaceAll(String address) {

+ 78 - 0
src/main/java/com/skyversation/poiaddr/config/AuthInterceptor.java

@@ -0,0 +1,78 @@
+package com.skyversation.poiaddr.config;
+
+import com.skyversation.poiaddr.util.net.NetTools;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+import org.springframework.web.servlet.HandlerInterceptor;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.PrintWriter;
+
+@Slf4j
+@Component
+public class AuthInterceptor implements HandlerInterceptor {
+
+
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+
+        log.info(">>>AuthInterceptor>>>>>>>在请求处理之前进行调用(Controller方法调用之前)");
+        log.info(">>>>>>>>>>>>>>>" + request.getRequestURL() + "<<<<<<<<<<<<<<<<<<<<<<");
+
+        //增加响应头缺失代码
+        response.addHeader("X-Frame-Options","SAMEORIGIN");
+        response.addHeader("Referrer-Policy","origin");
+        response.addHeader("Content-Security-Policy","object-src 'self'");
+        response.addHeader("X-Permitted-Cross-Domain-Policies","master-only");
+        response.addHeader("X-Content-Type-Options","nosniff");
+        response.addHeader("X-XSS-Protection","1; mode=block");
+        response.addHeader("X-Download-Options","noopen");
+        response.addHeader("Strict-Transport-Security","max-age=63072000; includeSubdomains; preload");
+        //处理cookie问题
+        Cookie[] cookies = request.getCookies();
+        if (cookies != null) {
+            for (Cookie cookie : cookies) {
+                String value = cookie.getValue();
+                StringBuilder builder = new StringBuilder();
+                builder.append(cookie.getName()+"="+value+";");
+                builder.append("Secure;");//Cookie设置Secure标识
+                builder.append("HttpOnly;");//Cookie设置HttpOnly
+                response.addHeader("Set-Cookie", builder.toString());
+            }
+        }
+
+        String token = request.getHeader("token");
+        String requestURI = request.getRequestURI();
+        if (StringUtils.isEmpty(token)){
+            token = request.getParameter("token");
+        }
+        if(StringUtils.isEmpty(token)){
+            response.setCharacterEncoding("utf-8");
+            response.setContentType("application/json; charset=utf-8");
+            PrintWriter writer = response.getWriter();
+            writer.write("无token");
+            return false;
+        }
+        log.info("token : [ {} ]", token);
+        String userRedis = NetTools.getInstance().getUserByToken(token,requestURI,response,request);
+        if (userRedis.contains("无效token")){
+            response.setCharacterEncoding("utf-8");
+            response.setContentType("application/json; charset=utf-8");
+            PrintWriter writer = response.getWriter();
+            writer.write("无效token");
+            return false;
+        }else if (userRedis.contains("无权限")){
+            response.setCharacterEncoding("utf-8");
+            response.setContentType("application/json; charset=utf-8");
+            PrintWriter writer = response.getWriter();
+            writer.write("无权限");
+            return false;
+        }
+
+        return true;
+    }
+
+}

+ 21 - 0
src/main/java/com/skyversation/poiaddr/config/GlobalExceptionHandler.java

@@ -0,0 +1,21 @@
+package com.skyversation.poiaddr.config;
+import org.springframework.web.bind.MissingServletRequestParameterException;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@ControllerAdvice
+public class GlobalExceptionHandler {
+
+    @ExceptionHandler(MissingServletRequestParameterException.class)
+    @ResponseBody
+    public Map<String, Object> handleMissingParams(MissingServletRequestParameterException ex) {
+        Map<String, Object> result = new HashMap<>();
+        result.put("status", 400);
+        result.put("message", "请求缺少参数:" + ex.getParameterName());
+        return result;
+    }
+}

+ 14 - 0
src/main/java/com/skyversation/poiaddr/config/WebConfig.java

@@ -0,0 +1,14 @@
+package com.skyversation.poiaddr.config;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@Configuration
+public class WebConfig implements WebMvcConfigurer {
+
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        registry.addInterceptor(new AuthInterceptor())
+                .addPathPatterns("/**"); // 拦截所有请求
+    }
+}

+ 15 - 46
src/main/java/com/skyversation/poiaddr/controller/PoiAddressController.java

@@ -3,8 +3,6 @@ package com.skyversation.poiaddr.controller;
 import com.skyversation.poiaddr.addquery.AddressQueryEngine;
 import com.skyversation.poiaddr.bean.AddressResult;
 import com.skyversation.poiaddr.entity.FileDataDto;
-import com.skyversation.poiaddr.entity.PoiAddress;
-import com.skyversation.poiaddr.service.PoiAddressService;
 import com.skyversation.poiaddr.util.CsvWriter;
 import com.skyversation.poiaddr.util.ExcelReaderUtils;
 import com.skyversation.poiaddr.util.RequestUtils;
@@ -14,17 +12,13 @@ import com.skyversation.poiaddr.util.geotools.GeoJsonIntersector;
 import com.skyversation.poiaddr.util.geotools.GeoJsonPointInRegion;
 import com.skyversation.poiaddr.util.status.AddressLevel;
 import lombok.extern.slf4j.Slf4j;
-import org.locationtech.jts.geom.Coordinate;
-import org.locationtech.jts.geom.GeometryFactory;
-import org.locationtech.jts.geom.Point;
 import org.locationtech.jts.io.ParseException;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.MediaType;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
-import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 import java.util.*;
@@ -39,36 +33,6 @@ import java.util.concurrent.Future;
 @RequestMapping("/poiAddress")
 public class PoiAddressController {
 
-    @Value("${zip_file_path}")
-    private String ZIP_FILE_PATH;
-    @Value("${zip_file_name}")
-    private String outFileName;
-
-    @Resource
-    private PoiAddressService poiAddressService;
-
-    //    查询所有数据
-    @GetMapping(value = "/getAll")
-    public List<PoiAddress> getAll() {
-        return poiAddressService.findAll();
-    }
-
-    //    根据uuid更新或添加数据
-    @PostMapping(value = "/update")
-    public String update(@RequestBody PoiAddress poiAddress) {
-        if (poiAddress.getUuid() != null) {
-            poiAddressService.update(poiAddress);
-            return "更新成功";
-        } else {
-            poiAddress.setUuid(UUID.randomUUID().toString());
-            GeometryFactory geometryFactory = new GeometryFactory();
-            Point point = geometryFactory.createPoint(new Coordinate(121.21, 31.31));
-            poiAddress.setLocation(point.toString());
-            poiAddressService.save(poiAddress);
-            return "插入成功";
-        }
-    }
-
     //    地址查询
     @GetMapping(value = "/selectAddressInfo/{address}")
     public Object selectAddressInfo(@PathVariable("address") String address) {
@@ -101,10 +65,15 @@ public class PoiAddressController {
      * *** regionalJudgment: 区域判断,geojson、shape文件[前端可以内置一些常用的区域文件,通过下拉框的方式进行选择]
      * *** outFileType: 输出文件类型【xlsx、csv、geojson、shape】
      *
+     * JDK版本要规定为11(已完成)
+     * 需要使用request获取参数,参数校验不能太严格。
+     * 接口调用要使用oauth认证,添加拦截器验证headers里面的token。
+     * 任务开始和结束要操作DMS(开始时间-创建时间,结束时间-修改时间,文件名,任务状态,备注)。
+     * 注意传入的文件可能数据量过大,可能导致保存xlsx或者csv数据丢失,还要注意字段对应是否正确。
      * @return Object
      */
-    @PostMapping(value = "/nameQueryTaskInterface", produces = MediaType.MULTIPART_FORM_DATA_VALUE)
-    public Object GeoCoordinate(HttpServletResponse response, @RequestParam(name = "file") MultipartFile file,
+    @RequestMapping(value = "/nameQueryTaskInterface", produces = MediaType.MULTIPART_FORM_DATA_VALUE)
+    public Object GeoCoordinate(HttpServletResponse response, HttpServletRequest request, @RequestParam(name = "file") MultipartFile file,
                                 @RequestParam(name = "addrColNames") String addrColNames,
                                 @RequestParam(name = "inCoordinate", required = false) String inCoordinate,
                                 @RequestParam(name = "latLonColName", required = false) String latLonColName,
@@ -115,7 +84,7 @@ public class PoiAddressController {
                                 @RequestParam(name = "regionalJudgment", required = false) MultipartFile regionalJudgment,
                                 @RequestParam(name = "outFileType", required = false) String outFileType,
                                 @RequestParam(name = "outputFileName", required = false) String outputFileName) throws IOException, ParseException {
-//            参数合法性判断
+//      参数合法性判断
         if ((file != null && !file.isEmpty()) && (addrColNames != null && !addrColNames.isEmpty())) {
             outputFileName += UUID.randomUUID();
 //          搜索地址key
@@ -167,7 +136,7 @@ public class PoiAddressController {
             List<FileDataDto> fileDataDtoList = ReadFileData.ReadMultipartFile(file);
             List<FileDataDto> regionalDataList = new ArrayList<>();
             if (regionalJudgment != null && !regionalJudgment.isEmpty()) {
-//                  解析geojson文件得到区域
+//              解析geojson文件得到区域
                 regionalDataList = ReadFileData.ReadMultipartFile(regionalJudgment);
             }
 //          TODO 补充FileDataDto中的搜索条件参数
@@ -275,7 +244,7 @@ public class PoiAddressController {
             executorService.shutdown();
 //          TODO 转换坐标(根据输入坐标系将参考坐标统一转换成wgs84)
             ArrayList<String> selectOptions = new ArrayList<>();
-//            {"WGS84(国际通用)", "GCJ02(高德、QQ地图)", "BD09(百度地图)", "上海2000坐标系"}
+//          {"WGS84(国际通用)", "GCJ02(高德、QQ地图)", "BD09(百度地图)", "上海2000坐标系"}
             selectOptions.add("WGS84");
             selectOptions.add("GCJ02");
             selectOptions.add("BD09");
@@ -288,14 +257,14 @@ public class PoiAddressController {
                 inCoordinate = "WGS84";
             }
             List<Map<String, Object>> dataList = new ArrayList<>();
-            // TODO 距离计算和区域判断和转换坐标
+//          TODO 距离计算和区域判断和转换坐标
             for (FileDataDto fileDataDto : fileDataDtoList) {
                 if (fileDataDto.getLat() != null && fileDataDto.getLon() != null) {
                     double[] lonLat = com.skyversation.poiaddr.util.Coordinate.transformationCoordinateByCoordinate(fileDataDto.getLat(), fileDataDto.getLon(), inCoordinate, outCoordinate);
                     fileDataDto.setLat(lonLat[1]);
                     fileDataDto.setLon(lonLat[0]);
                 }
-                //          TODO 距离计算
+//              TODO 距离计算
                 if (matchingDistance != null) {
                     if (fileDataDto.getResultLat() != null && fileDataDto.getResultLon() != null && fileDataDto.getLat() != null && fileDataDto.getLon() != null) {
                         double distance = com.skyversation.poiaddr.util.Coordinate.calculateDistance(fileDataDto.getResultLat(), fileDataDto.getResultLon(), fileDataDto.getLat(), fileDataDto.getLon());
@@ -308,7 +277,7 @@ public class PoiAddressController {
                         }
                     }
                 }
-                //          TODO 区域判断(得到经纬度后,要判断得到的点是否在传入的geojson面内)
+//              TODO 区域判断(得到经纬度后,要判断得到的点是否在传入的geojson面内)
                 if (regionalDataList != null && regionalDataList.size() > 0) {
 //                  解析geojson文件得到区域
                     boolean isArea= false;
@@ -344,7 +313,7 @@ public class PoiAddressController {
                         break;
                 }
             } else {
-                //            保存实体类到序列化文件
+//              保存实体类到序列化文件
                 SerializationUtils.serialize(fileDataDtoList, "output/output" + outputFileName + ".ser");
             }
             // 从文件中反序列化读取数据

+ 0 - 11
src/main/java/com/skyversation/poiaddr/dao/PoiAddressRepository.java

@@ -1,11 +0,0 @@
-package com.skyversation.poiaddr.dao;
-
-import com.skyversation.poiaddr.entity.PoiAddress;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Service;
-
-@Service
-public interface PoiAddressRepository extends JpaRepository<PoiAddress, String> {
-
-//    Integer getByAddressLike(String address);
-}

+ 14 - 0
src/main/java/com/skyversation/poiaddr/entity/AddressV4Result.java

@@ -0,0 +1,14 @@
+package com.skyversation.poiaddr.entity;
+
+import com.alibaba.fastjson.JSONArray;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor
+@Data
+public class AddressV4Result {
+    private int resultCode; // 0 精确结果; 1 推荐结果
+    private String message;
+    private JSONArray exactResult;//精确地址
+    private JSONArray recomResult;//推荐地址
+}

+ 317 - 0
src/main/java/com/skyversation/poiaddr/entity/PYToken.java

@@ -0,0 +1,317 @@
+package com.skyversation.poiaddr.entity;
+
+import java.util.Date;
+
+public class PYToken {
+
+    /***
+     * 主键id
+     */
+    private Integer id;
+
+    /**
+     * token
+     */
+    private String token;
+
+    /**
+     * 使用方式
+     */
+    private String useType;
+
+    /**
+     * 申请人
+     */
+    private String applicant;
+
+    /**
+     * 申请单位
+     */
+    private String applicantUnit;
+
+    /**
+     * 数据使用单位
+     */
+    private String dataUseUnit;
+
+    /**
+     * 场景分类
+     */
+    private String sceneCategory;
+
+    /**
+     * 事项名称,不能为空
+     */
+    private String matterName;
+
+    /**
+     * 需求描述
+     */
+    private String demandDescription;
+
+    /**
+     * 共享方式
+     */
+    private String shareType;
+
+    /**
+     * 申请应用,不能为空
+     */
+    private String application;
+
+    /**
+     * 使用期限(天),不能为空
+     */
+    private Integer usePeriod;
+
+    /**
+     * 认证类型,不能为空
+     */
+    private String authenticationType;
+
+    /**
+     * IP地址白名单,用逗号分隔,例如:192.168.1.1,192.168.1.2    ,不能为空
+     */
+    private String ipAddress;
+
+    /**
+     * 每天访问限制,不能为空
+     */
+    private Integer dailyAccessLimit;
+
+    /**
+     * 创建日期,不能为空
+     */
+    private Date createDate;
+
+    /**
+     * 更新日期,不能为空
+     */
+    private Date updateDate;
+
+    /**
+     * 失效日期,不能为空
+     */
+    private Date invalidDate;
+
+    /***
+     * 可以使用的服务名称,以逗号分隔,例如:GEO_SERVER,IMAGE_SERVER   ,不能为空
+     */
+    private String serverName;
+
+    /***
+     * 是否在用,0 在用,1 已删除,2 已过期,3 已拉黑  ,不能为空
+     */
+    private Integer archived;
+
+    private String errorMsg;
+
+    /**
+     * 备注
+     */
+    private String note;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getToken() {
+        return token;
+    }
+
+    public void setToken(String token) {
+        this.token = token;
+    }
+
+    public String getUseType() {
+        return useType;
+    }
+
+    public void setUseType(String useType) {
+        this.useType = useType;
+    }
+
+    public String getApplicant() {
+        return applicant;
+    }
+
+    public void setApplicant(String applicant) {
+        this.applicant = applicant;
+    }
+
+    public String getApplicantUnit() {
+        return applicantUnit;
+    }
+
+    public void setApplicantUnit(String applicantUnit) {
+        this.applicantUnit = applicantUnit;
+    }
+
+    public String getDataUseUnit() {
+        return dataUseUnit;
+    }
+
+    public void setDataUseUnit(String dataUseUnit) {
+        this.dataUseUnit = dataUseUnit;
+    }
+
+    public String getSceneCategory() {
+        return sceneCategory;
+    }
+
+    public void setSceneCategory(String sceneCategory) {
+        this.sceneCategory = sceneCategory;
+    }
+
+    public String getMatterName() {
+        return matterName;
+    }
+
+    public void setMatterName(String matterName) {
+        this.matterName = matterName;
+    }
+
+    public String getDemandDescription() {
+        return demandDescription;
+    }
+
+    public void setDemandDescription(String demandDescription) {
+        this.demandDescription = demandDescription;
+    }
+
+    public String getShareType() {
+        return shareType;
+    }
+
+    public void setShareType(String shareType) {
+        this.shareType = shareType;
+    }
+
+    public String getApplication() {
+        return application;
+    }
+
+    public void setApplication(String application) {
+        this.application = application;
+    }
+
+    public Integer getUsePeriod() {
+        return usePeriod;
+    }
+
+    public void setUsePeriod(Integer usePeriod) {
+        this.usePeriod = usePeriod;
+    }
+
+    public String getAuthenticationType() {
+        return authenticationType;
+    }
+
+    public void setAuthenticationType(String authenticationType) {
+        this.authenticationType = authenticationType;
+    }
+
+    public String getIpAddress() {
+        return ipAddress;
+    }
+
+    public void setIpAddress(String ipAddress) {
+        this.ipAddress = ipAddress;
+    }
+
+    public Integer getDailyAccessLimit() {
+        return dailyAccessLimit;
+    }
+
+    public void setDailyAccessLimit(Integer dailyAccessLimit) {
+        this.dailyAccessLimit = dailyAccessLimit;
+    }
+
+    public Date getCreateDate() {
+        return createDate;
+    }
+
+    public void setCreateDate(Date createDate) {
+        this.createDate = createDate;
+    }
+
+    public Date getInvalidDate() {
+        return invalidDate;
+    }
+
+    public void setInvalidDate(Date invalidDate) {
+        this.invalidDate = invalidDate;
+    }
+
+    public String getServerName() {
+        return serverName;
+    }
+
+    public void setServerName(String serverName) {
+        this.serverName = serverName;
+    }
+
+    public Integer getArchived() {
+        return archived;
+    }
+
+    public void setArchived(Integer archived) {
+        this.archived = archived;
+    }
+
+    public String getNote() {
+        return note;
+    }
+
+    public void setNote(String note) {
+        this.note = note;
+    }
+
+    public String getErrorMsg() {
+        return errorMsg;
+    }
+
+    public void setErrorMsg(String errorMsg) {
+        this.errorMsg = errorMsg;
+    }
+
+    public Date getUpdateDate() {
+        return updateDate;
+    }
+
+    public void setUpdateDate(Date updateDate) {
+        this.updateDate = updateDate;
+    }
+
+    @Override
+    public String toString() {
+        return "PYToken{" +
+                "id=" + id +
+                ", token='" + token + '\'' +
+                ", useType='" + useType + '\'' +
+                ", applicant='" + applicant + '\'' +
+                ", applicantUnit='" + applicantUnit + '\'' +
+                ", dataUseUnit='" + dataUseUnit + '\'' +
+                ", sceneCategory='" + sceneCategory + '\'' +
+                ", matterName='" + matterName + '\'' +
+                ", demandDescription='" + demandDescription + '\'' +
+                ", shareType='" + shareType + '\'' +
+                ", application='" + application + '\'' +
+                ", usePeriod=" + usePeriod +
+                ", authenticationType='" + authenticationType + '\'' +
+                ", ipAddress='" + ipAddress + '\'' +
+                ", dailyAccessLimit=" + dailyAccessLimit +
+                ", createDate=" + createDate +
+                ", updateDate=" + updateDate +
+                ", invalidDate=" + invalidDate +
+                ", serverName='" + serverName + '\'' +
+                ", archived=" + archived +
+                ", errorMsg='" + errorMsg + '\'' +
+                ", note='" + note + '\'' +
+                '}';
+    }
+}

+ 0 - 163
src/main/java/com/skyversation/poiaddr/entity/PoiAddress.java

@@ -1,163 +0,0 @@
-package com.skyversation.poiaddr.entity;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Table;
-import javax.persistence.Id;
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * @Description  
- * @Author  LiuMengxiang
- * @Date 2024-11-18 15:48:33 
- */
-
-@AllArgsConstructor
-@NoArgsConstructor
-@Data
-@Entity
-@Table ( name ="poi_address" , schema = "")
-public class PoiAddress  implements Serializable {
-
-	private static final long serialVersionUID =  6661768566542572780L;
-
-   	@Column(name = "location" )
-	private String location;
-
-   	@Column(name = "poi_string" )
-	private String poiString;
-
-   	@Column(name = "relation_sn_mark" )
-	private String relationSnMark;
-
-   	@Column(name = "region_xq" )
-	private String regionXq;
-
-   	@Column(name = "region_jd" )
-	private String regionJd;
-
-   	@Column(name = "building" )
-	private String building;
-
-   	@Column(name = "region_xq_alias" )
-	private String regionXqAlias;
-
-   	@Column(name = "no1" )
-	private String no1;
-
-   	@Column(name = "no2" )
-	private String no2;
-
-   	@Column(name = "no3" )
-	private String no3;
-
-   	@Column(name = "no4" )
-	private String no4;
-
-   	@Column(name = "update_time" )
-	private Date updateTime;
-
-   	@Column(name = "coord_adcode" )
-	private String coordAdcode;
-
-   	@Column(name = "specification_update_mark" )
-	private String specificationUpdateMark;
-
-   	@Column(name = "point_y" )
-	private String pointY;
-
-   	@Column(name = "region_jw" )
-	private String regionJw;
-
-   	@Column(name = "point_x" )
-	private String pointX;
-
-   	@Column(name = "source_address" )
-	private String sourceAddress;
-
-   	@Column(name = "operation_remark" )
-	private String operationRemark;
-
-   	@Column(name = "attach_info" )
-	private String attachInfo;
-
-   	@Column(name = "room_no_alias" )
-	private String roomNoAlias;
-
-   	@Column(name = "data_operation" )
-	private String dataOperation;
-
-   	@Column(name = "unit_alias" )
-	private String unitAlias;
-
-   	@Column(name = "room_no" )
-	private String roomNo;
-
-   	@Column(name = "floor" )
-	private String floor;
-
-   	@Column(name = "manual_mark" )
-	private String manualMark;
-
-   	@Column(name = "address_code" )
-	private String addressCode;
-
-   	@Column(name = "relation_extra_alias" )
-	private String relationExtraAlias;
-
-   	@Column(name = "point_l" )
-	private String pointL;
-
-   	@Column(name = "address" )
-	private String address;
-
-   	@Column(name = "create_time" )
-	private Date createTime;
-
-   	@Column(name = "region_ss" )
-	private String regionSs;
-
-   	@Column(name = "building_alias" )
-	private String buildingAlias;
-
-   	@Column(name = "point_b" )
-	private String pointB;
-
-   	@Column(name = "operation_remark_check" )
-	private String operationRemarkCheck;
-
-   	@Column(name = "sub_region_xq" )
-	private String subRegionXq;
-
-   	@Column(name = "data_source" )
-	private String dataSource;
-
-   	@Column(name = "parent_address_code" )
-	private String parentAddressCode;
-
-   	@Column(name = "history_data" )
-	private String historyData;
-
-   	@Column(name = "unit" )
-	private String unit;
-
-   	@Column(name = "semantics_source" )
-	private String semanticsSource;
-
-   	@Column(name = "data_operation_check" )
-	private String dataOperationCheck;
-
-   	@Column(name = "region_qx" )
-	private String regionQx;
-
-   	@Column(name = "name1" )
-	private String name1;
-
-	@Id
-   	@Column(name = "uuid" )
-	private String uuid;
-}

+ 55 - 0
src/main/java/com/skyversation/poiaddr/entity/ProxyItem.java

@@ -0,0 +1,55 @@
+package com.skyversation.poiaddr.entity;
+
+public class ProxyItem {
+
+    /** 标识 */
+    private String key = "";
+    /** 描述 */
+    private String content = "";
+    /** 地址 */
+    private String url = "";
+    /** 类型 */
+    private String type = "";
+    /** 请求参数 */
+    private String param = "";
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getParam() {
+        return param;
+    }
+
+    public void setParam(String param) {
+        this.param = param;
+    }
+}

+ 106 - 0
src/main/java/com/skyversation/poiaddr/entity/UserRecord.java

@@ -0,0 +1,106 @@
+package com.skyversation.poiaddr.entity;
+
+import lombok.Data;
+
+
+// 用户行为记录表
+@Data
+public class UserRecord {
+
+    private Integer userId;                      // 用户id
+    private String refreshToken;              // 登录时的refresh token
+    private String accessToken;               // 登录时的access token
+    private String roleId;                      // 角色sid
+    private String loginIp;                  // 登录ip地址
+    private String content;                   //描述
+    private String userName;                  //用户名称
+    private String requestUrl;                   //访问接口
+    private String serviceOrigin;             //服务ID
+    private String state ;
+
+
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+
+    public String getRefreshToken() {
+        return refreshToken;
+    }
+
+    public void setRefreshToken(String refreshToken) {
+        this.refreshToken = refreshToken;
+    }
+
+    public String getAccessToken() {
+        return accessToken;
+    }
+
+    public void setAccessToken(String accessToken) {
+        this.accessToken = accessToken;
+    }
+
+    public String getRoleId() {
+        return roleId;
+    }
+
+    public void setRoleId(String roleId) {
+        this.roleId = roleId;
+    }
+
+    public String getLoginIp() {
+        return loginIp;
+    }
+
+    public void setLoginIp(String loginIp) {
+        this.loginIp = loginIp;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getRequestUrl() {
+        return requestUrl;
+    }
+
+    public void setRequestUrl(String requestUrl) {
+        this.requestUrl = requestUrl;
+    }
+
+    public String getServiceOrigin() {
+        return serviceOrigin;
+    }
+
+    public void setServiceOrigin(String serviceOrigin) {
+        this.serviceOrigin = serviceOrigin;
+    }
+
+    @Override
+    public String toString() {
+        return "UserRecord{" +
+                "userId=" + userId +
+                ", refreshToken='" + refreshToken + '\'' +
+                ", accessToken='" + accessToken + '\'' +
+                ", roleId=" + roleId +
+                ", loginIp='" + loginIp + '\'' +
+                '}';
+    }
+}

+ 28 - 0
src/main/java/com/skyversation/poiaddr/entity/VerifyBean.java

@@ -0,0 +1,28 @@
+package com.skyversation.poiaddr.entity;
+
+public class VerifyBean {
+
+    public VerifyBean(){};
+    public VerifyBean(boolean verify, String errorMsg){
+        this.verify = verify;
+        this.errorMsg = errorMsg;
+    }
+    private boolean verify;
+    private String errorMsg;
+
+    public boolean isVerify() {
+        return verify;
+    }
+
+    public void setVerify(boolean verify) {
+        this.verify = verify;
+    }
+
+    public String getErrorMsg() {
+        return errorMsg;
+    }
+
+    public void setErrorMsg(String errorMsg) {
+        this.errorMsg = errorMsg;
+    }
+}

+ 56 - 50
src/main/java/com/skyversation/poiaddr/service/AreaService.java

@@ -25,8 +25,9 @@ import java.util.List;
 public class AreaService {
 
     private static AreaService instance;
-    public static AreaService getInstance(){
-        if(instance == null){
+
+    public static AreaService getInstance() {
+        if (instance == null) {
             return new AreaService();
         }
         return instance;
@@ -47,23 +48,25 @@ public class AreaService {
     public List<GeoJsonBean> gridPolygonList = new ArrayList<>();
 
     @PostConstruct
-    public void initGeoData(){
+    public void initGeoData() {
         System.out.println("<<<<<<<<------AreaService>initGeoData------>>>>>>>>>");
         instance = this;
-        new Thread(()->runGeoData()).start();
-        new Thread(()->runZEWLData()).start();
-        new Thread(()->initPolygons()).start();
+        new Thread(() -> runGeoData()).start();
+        new Thread(() -> runZEWLData()).start();
+        new Thread(() -> initPolygons()).start();
     }
 
-    public void initPolygons(){
+    public void initPolygons() {
         List<List<GeoJsonBean>> lis = new ArrayList<>();
         lis.add(cjPolygonList);
         lis.add(wGridPolygonList);
         lis.add(gridPolygonList);
         String[] path = new String[]{"classpath:geojson/qp_cunju.geojson", "classpath:geojson/青浦区微网格-wgs84.geojson",
                 "classpath:geojson/责任网格-wgs84.geojson"};
+//        String[] path = new String[]{"D:/geojson/qp_cunju.geojson", "D:/geojson/青浦区微网格-wgs84.geojson",
+//                "D:/geojson/责任网格-wgs84.geojson"};
 
-        for(int j = 0; j < path.length; j ++){
+        for (int j = 0; j < path.length; j++) {
             BufferedReader br = null;
             try {
                 File file = ResourceUtils.getFile(path[j]);
@@ -78,7 +81,7 @@ public class AreaService {
 
                 JSONArray featrues = json.getJSONArray("features");
 
-                for(int i = 0; i < featrues.size(); i ++){
+                for (int i = 0; i < featrues.size(); i++) {
                     JSONObject properties = featrues.getJSONObject(i).getJSONObject("properties");
                     JSONObject geoJson = new JSONObject();
                     geoJson.put("type", "MultiPolygon");
@@ -88,7 +91,7 @@ public class AreaService {
                     GeometryJSON geometryJSON = new GeometryJSON();
                     MultiPolygon multiPolygon = geometryJSON.readMultiPolygon(geoJson.toJSONString());
                     GeoJsonBean geoJsonBean = new GeoJsonBean();
-                    if(file.getName().contains("cunju")){
+                    if (file.getName().contains("cunju")) {
                         JSONObject resultProp = new JSONObject();
                         resultProp.put("网格名称", properties.getString("__10"));
                         resultProp.put("shape_leng", properties.getString("shape__length"));
@@ -103,7 +106,7 @@ public class AreaService {
                         resultProp.put("面积", properties.getString("__1"));
                         resultProp.put("objectid", properties.getString("objectid"));
                         geoJsonBean.setProperties(resultProp);
-                    } else if(file.getName().contains("微网格")){
+                    } else if (file.getName().contains("微网格")) {
                         JSONObject resultProp = new JSONObject();
                         resultProp.put("objectid", properties.getString("OBJECTID"));
                         resultProp.put("所属街道", properties.getString("æ\u0089\u0080å±\u009Eè¡\u0097"));
@@ -113,7 +116,7 @@ public class AreaService {
                         resultProp.put("Shape_Area", properties.getString("Shape_Area"));
                         resultProp.put("微格网名称", properties.getString("å¾®ç½\u0091_1"));
                         geoJsonBean.setProperties(resultProp);
-                    } else if(file.getName().contains("责任网格")){
+                    } else if (file.getName().contains("责任网格")) {
                         geoJsonBean.setProperties(properties);
                     }
                     geoJsonBean.setMultiPolygon(multiPolygon);
@@ -129,7 +132,7 @@ public class AreaService {
     }
 
 
-    public GeoJsonBean isInGridPolygon(double lon, double lat){
+    public GeoJsonBean isInGridPolygon(double lon, double lat) {
         Geometry point = null;
         try {
             point = reader.read("POINT (" + lon + " " + lat + ")");
@@ -137,19 +140,19 @@ public class AreaService {
             throw new RuntimeException(e);
         }
 
-        for(GeoJsonBean bean : gridPolygonList){
-            try{
-                if(bean.getMultiPolygon().contains(point)){
+        for (GeoJsonBean bean : gridPolygonList) {
+            try {
+                if (bean.getMultiPolygon().contains(point)) {
                     return bean;
                 }
-            } catch (Exception e){
+            } catch (Exception e) {
 
             }
         }
         return null;
     }
 
-    public GeoJsonBean isInWGridPolygon(double lon, double lat){
+    public GeoJsonBean isInWGridPolygon(double lon, double lat) {
         Geometry point = null;
         try {
             point = reader.read("POINT (" + lon + " " + lat + ")");
@@ -157,15 +160,15 @@ public class AreaService {
             throw new RuntimeException(e);
         }
 
-        for(GeoJsonBean bean : wGridPolygonList){
-            if(bean.getMultiPolygon().contains(point)){
+        for (GeoJsonBean bean : wGridPolygonList) {
+            if (bean.getMultiPolygon().contains(point)) {
                 return bean;
             }
         }
         return null;
     }
 
-    public GeoJsonBean isInCJPolygon(double lon, double lat){
+    public GeoJsonBean isInCJPolygon(double lon, double lat) {
         Geometry point = null;
         try {
             point = reader.read("POINT (" + lon + " " + lat + ")");
@@ -173,8 +176,8 @@ public class AreaService {
             throw new RuntimeException(e);
         }
 
-        for(GeoJsonBean bean : cjPolygonList){
-            if(bean.getMultiPolygon().contains(point)){
+        for (GeoJsonBean bean : cjPolygonList) {
+            if (bean.getMultiPolygon().contains(point)) {
                 return bean;
             }
         }
@@ -182,8 +185,10 @@ public class AreaService {
     }
 
 
-    /** 初始化责任网络数据 **/
-    public void runZEWLData(){
+    /**
+     * 初始化责任网络数据
+     **/
+    public void runZEWLData() {
         JSONArray jsonArray = new JSONArray();
         BufferedReader br = null;
         try {
@@ -197,7 +202,7 @@ public class AreaService {
             }
             zrwl = JSONObject.parseObject(sb.toString(), Zerenwangluo.class);
             zrwlFeatures = zrwl.getFeatures();
-            for(int i = 0; i < zrwlFeatures.size(); i ++) {
+            for (int i = 0; i < zrwlFeatures.size(); i++) {
 
                 Zerenwangluo.FeaturesDTO.AttributesDTO attributes = zrwlFeatures.get(i).getAttributes();
                 zrwlProperties.add(attributes);
@@ -206,9 +211,9 @@ public class AreaService {
                 JSONArray coordinates = new JSONArray();
                 JSONArray coordinates1 = new JSONArray();
 
-                for(List<List<Double>> rings : geometry.getRings()){
+                for (List<List<Double>> rings : geometry.getRings()) {
                     JSONArray coordinates2 = new JSONArray();
-                    for(List<Double> ring : rings){
+                    for (List<Double> ring : rings) {
                         JSONArray coordinates3 = new JSONArray();
                         double x = ring.get(0);
                         double y = ring.get(1);
@@ -242,26 +247,25 @@ public class AreaService {
     }
 
 
-
-    public JSONObject getLiabilityGridByLatlon(double lat, double lon){
+    public JSONObject getLiabilityGridByLatlon(double lat, double lon) {
         Zerenwangluo.FeaturesDTO.AttributesDTO attribute = null;
         try {
             Geometry point = reader.read("POINT (" + lon + " " + lat + ")");
             boolean done = false;
-            for(int i = 0; i < zrwlMulPolygonList.size(); i ++){
-                if(done){
+            for (int i = 0; i < zrwlMulPolygonList.size(); i++) {
+                if (done) {
                     break;
                 }
                 MultiPolygon multiPolygon = zrwlMulPolygonList.get(i);
                 String wktStr = multiPolygon.toString();
-                if(wktStr.contains("), (")){// 如果是多面,则拆分成单面再重新比对
+                if (wktStr.contains("), (")) {// 如果是多面,则拆分成单面再重新比对
                     String[] wktStrs = wktStr.split("\\), \\(");
                     List<MultiPolygon> polygons = new ArrayList<>();
-                    for(int j = 0; j < wktStrs.length; j ++){
-                        if(j == 0){
+                    for (int j = 0; j < wktStrs.length; j++) {
+                        if (j == 0) {
                             MultiPolygon polygon1 = (MultiPolygon) reader.read(wktStrs[0] + ")))");
                             polygons.add(polygon1);
-                        } else if(j == wktStrs.length - 1){
+                        } else if (j == wktStrs.length - 1) {
                             MultiPolygon polygon2 = (MultiPolygon) reader.read("MULTIPOLYGON (((" + wktStrs[j]);
                             polygons.add(polygon2);
                         } else {
@@ -269,15 +273,15 @@ public class AreaService {
                             polygons.add(polygon3);
                         }
                     }
-                    for(MultiPolygon polygon : polygons){
-                        if(polygon.contains(point)){
+                    for (MultiPolygon polygon : polygons) {
+                        if (polygon.contains(point)) {
                             attribute = zrwlProperties.get(i);
                             done = true;
                             break;
                         }
                     }
                 } else {// 如果是单面,则直接比对
-                    if(multiPolygon.contains(point)){
+                    if (multiPolygon.contains(point)) {
                         attribute = zrwlProperties.get(i);
                         break;
                     }
@@ -292,8 +296,10 @@ public class AreaService {
         return JSONObject.parseObject(JSON.toJSONString(attribute));
     }
 
-    /** 初始化村居数据 **/
-    public void runGeoData(){
+    /**
+     * 初始化村居数据
+     **/
+    public void runGeoData() {
         BufferedReader br = null;
         try {
             File file = ResourceUtils.getFile("classpath:geojson/qp_cunju.geojson");
@@ -307,7 +313,7 @@ public class AreaService {
 
             JSONObject json = JSONObject.parseObject(sb.toString());
             JSONArray features = json.getJSONArray("features");
-            for(int i = 0; i < features.size(); i ++) {
+            for (int i = 0; i < features.size(); i++) {
 
                 JSONObject feature = features.getJSONObject(i);
                 JSONObject geometry = feature.getJSONObject("geometry");
@@ -327,19 +333,19 @@ public class AreaService {
         } catch (IOException e) {
             e.printStackTrace();
             System.out.println("<<<<<<<<------run geo data error------>>>>>>>>>");
-        } catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
             System.out.println("<<<<<<<<------run geo data error------>>>>>>>>>");
         }
         System.out.println("<<<<<<<<------run geo data complete------>>>>>>>>>");
     }
 
-    public Village getAreaCodeByLatlon(double lat, double lon){
+    public Village getAreaCodeByLatlon(double lat, double lon) {
         Village geoAC = null;
         try {
             Geometry point = reader.read("POINT (" + lon + " " + lat + ")");
-            for(int i = 0; i < mulPolygonList.size(); i ++){
-                if(mulPolygonList.get(i).contains(point)){
+            for (int i = 0; i < mulPolygonList.size(); i++) {
+                if (mulPolygonList.get(i).contains(point)) {
                     geoAC = propertiList.get(i);
                     break;
                 }
@@ -351,19 +357,19 @@ public class AreaService {
         return geoAC;
     }
 
-    public List<Village> getAreaCodeByLatlons(JSONArray locations){
-        if(locations == null || locations.size() < 1){
+    public List<Village> getAreaCodeByLatlons(JSONArray locations) {
+        if (locations == null || locations.size() < 1) {
             return null;
         } else {
             List<Village> result = new ArrayList<>();
             try {
-                for(int i = 0; i < locations.size(); i ++){
+                for (int i = 0; i < locations.size(); i++) {
                     JSONObject jsonObject = locations.getJSONObject(i);
                     Village geoAreaCode = getAreaCodeByLatlon(jsonObject.getDouble("lat"), jsonObject.getDouble("lon"));
                     result.add(geoAreaCode);
                 }
                 return result;
-            } catch (Exception e){
+            } catch (Exception e) {
                 return null;
             }
         }

+ 0 - 12
src/main/java/com/skyversation/poiaddr/service/PoiAddressService.java

@@ -1,12 +0,0 @@
-package com.skyversation.poiaddr.service;
-
-import com.skyversation.poiaddr.entity.PoiAddress;
-
-import java.util.List;
-
-public interface PoiAddressService {
-    PoiAddress save(PoiAddress poiAddress);
-//    自定义查询:根据地址关键字模糊查询
-    List<PoiAddress> findAll();
-    PoiAddress update(PoiAddress poiAddress);
-}

+ 0 - 49
src/main/java/com/skyversation/poiaddr/service/impl/PoiAddressServiceImpl.java

@@ -1,49 +0,0 @@
-package com.skyversation.poiaddr.service.impl;
-
-import com.skyversation.poiaddr.dao.PoiAddressRepository;
-import com.skyversation.poiaddr.entity.PoiAddress;
-import com.skyversation.poiaddr.service.PoiAddressService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.annotation.Resource;
-import javax.persistence.EntityManager;
-import java.util.List;
-
-@Service
-public class PoiAddressServiceImpl implements PoiAddressService {
-
-    @Resource
-    private PoiAddressRepository poiAddressRepository;
-
-    @Autowired
-    private EntityManager entityManager;
-
-    @Override
-    public PoiAddress save(PoiAddress poiAddress) {
-        return poiAddressRepository.save(poiAddress);
-    }
-
-    @Override
-    public List<PoiAddress> findAll() {
-        List<PoiAddress> poiAddressList = poiAddressRepository.findAll();
-        return poiAddressList;
-    }
-
-    /**
-     * 根据uuid查询数据并更新新的数据到数据库
-     *
-     * @param poiAddress
-     * @return
-     */
-    @Transactional
-    public PoiAddress update(PoiAddress poiAddress) {
-        PoiAddress poiAddress1 = entityManager.find(PoiAddress.class, poiAddress.getUuid());
-        if (poiAddress1 != null) {
-            return entityManager.merge(poiAddress);
-        } else {
-            return null;
-        }
-    }
-}

+ 158 - 0
src/main/java/com/skyversation/poiaddr/util/Constant.java

@@ -0,0 +1,158 @@
+package com.skyversation.poiaddr.util;
+
+import com.skyversation.poiaddr.entity.ProxyItem;
+import com.skyversation.poiaddr.entity.UserRecord;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class Constant {
+
+    public static Constant instance = new Constant();
+
+    private Constant(){};
+
+    public static Constant getInstance(){
+        if(instance == null)
+            instance = new Constant();
+        if(instance.defaultToken.size() < 1)
+            instance.initData();
+        return instance;
+    }
+
+    /**
+     * 外部amap地理/逆地理搜索
+     * */
+    public static String AMAP_GEO_URL = "https://restapi.amap.com/v3/geocode/geo";
+    public static String AMAP_REGEO_URL = "https://restapi.amap.com/v3/geocode/regeo";
+
+    public static String AMAP_SEARCH_NAME_V3 = "https://restapi.amap.com/v3/place/text";
+    public static String AMAP_SEARCH_TYPES = "010000|020000|030000|040000|050000|060000|070000|080000|090000" +
+            "|100000|110000|120000|130000|140000|150000|160000|170000|180000|190000|200000|220000|970000|980000|990000";
+
+    /***
+     * 高德路径规划
+     */
+//    public static String AMAP_DRIVING = "https://restapi.amap.com/v5/direction/driving";
+    public static String AMAP_DRIVING = "https://restapi.amap.com/v3/direction/driving";
+    /**
+     * amap经纬度误差
+     * */
+    public static double AMAP_LAT_WUCHA = -0.001853;
+    public static double AMAP_LON_WUCHA = 0.004624;
+
+
+    public List<String> defaultToken = new ArrayList<>();
+    public Map<String, UserRecord> defaultTokenMap = new HashMap<>();
+    public Map<String, String> dicMap = new HashMap<>();
+
+    public Map<String, ProxyItem> requestMap = new HashMap<>();
+
+    public Map<String, String> proxyMap = new HashMap<>();
+    public Map<String, String> proxyMODEL = new HashMap<>();
+    public Map<String, String> proxyGLTF = new HashMap<>();
+    public Map<String, String> proxyDATA = new HashMap<>();
+    public Map<String, String> proxyUNKNOWN = new HashMap<>();
+//    public static String OAUTH_URL = "http://122.228.28.40:10096/oauth/api/user/getUserByToken";
+
+    public static String OAUTH_URL = "http://121.43.55.7:10086/oauth/api/user/getUserByToken";
+    public static String SEARCH_BY_NAME_URL = "http://121.43.55.7:10011/proxy/searchByName?address=";
+    public static String SEARCH_BY_NAME_V3_URL = "http://121.43.55.7:10011/proxy/searchByNameV3?address=";
+    public static String AMAP_DRIVING_URL = "http://121.43.55.7:10011/proxy/driving?key=";
+    public static String TDT_IMAGE_URL = "http://121.43.55.7:10011/proxy/tdt_image?key=";
+    public static String OAUTH_URL_GETUSER = "http://121.43.55.7:10086/oauth/api/user/getUserByToken";
+    public static String OAUTH_GET_USER_BY_TOKEN = "http://121.43.55.7:10086/oauth/api/user/getUserByToken";
+    public static String OAUTH_PY_URL = "http://121.43.55.7:10086/oauth/py/validateToken";
+    public static String OAUTH_RECORD_URL = "http://127.0.0.1:10086/oauth/record/addRecord";
+    public static String DMS_URL_UPDATE = "http://121.43.55.7:";
+//    public static String OAUTH_URL = "http://127.0.0.1:10096/oauth/api/user/getUserByToken";
+
+    public static String OAUTH_LOGIN_URL = "http://121.43.55.7:8888/oauth/api/user/login";
+    public static final String TOKEN = "token";
+    public static final String STRURL = "strUrl";
+    public static final String SERVICEID = "serviceId";
+
+    /** 网络请求返回值 **/
+    public final static int SUCCESS = 200;
+    /** 参数错误 **/
+    public final static int PARAM_ERROR = -1;
+    /** 服务端错误 **/
+    public final static int SERVER_ERROR = 500;
+    /** 无权限 **/
+    public final static int NO_PERMISSION = 201;
+    /** 数据错误,无数据 **/
+    public final static int NO_DATA = 202;
+    /** 内部错误 **/
+    public final static int INTER_ERROR = 203;
+    /** 数据库错误 **/
+    public final static int DATABASE_ERROR = 204;
+    /** 数据为空 **/
+    public final static int NULL_DATA = 205;
+    /** 用户过期 **/
+    public final static int USER_FAILURE = 206;
+    /** 用户失效 **/
+    public final static int USER_ARCHIVED = 207;
+    /** 无token **/
+    public final static int NO_TOKEN = 208;
+    /** 无效token **/
+    public final static int FAILURE_TOKEN = 212;
+    /** 没有注册此服务 **/
+    public final static int NO_SERVICE = 213;
+    /** ip验证不通过 **/
+    public final static int IP_NOT_PASS = 314;
+    /** 事项验证不通过 **/
+    public final static int MATTER_NOT_PASS = 315;
+    /** 经纬度格式错误 **/
+    public final static int LAT_LON_ERROR = 316;
+
+
+    /** JWT ACCESS 密钥加密 **/
+    public final static String JWT_ACCESS_PRIVATE_KEY = "SKYVERSATION-ACCESS";
+    /** JWT REFRESH 密钥加密 **/
+    public final static String JWT_REFRESH_PRIVATE_KEY = "SKYVERSATION-REFRESH";
+
+    /** access token 有效时间 **/
+    public final static long ACCESS_TOKEN_TIME = 1000 * 60 * 60 * 16;
+    public void initData(){
+        defaultToken.add("65463DEE-620A-0ED5-2385-17ECD07CD351");
+        defaultToken.add("C651EBF8-5728-4F2F-1C1F-52A9F1BDC889");
+        defaultToken.add("079B1D50-DE99-AF49-FF56-DCB95D3E3147");
+        defaultToken.add("C4BCA7C6-DF66-4A7D-2931-A258DFEFF8AB");
+        defaultToken.add("CFC5CEB8-755F-0916-899C-4CD578F323CC");
+        defaultToken.add("DF45046F-AE7B-50B3-C084-FECDE82CEE32");
+        defaultToken.add("1472624D-EBC3-8B49-F1A2-B21446925D48");
+        defaultToken.add("1C73AFA8-3567-E2CC-048D-6ECAB6DD58D6");
+        defaultToken.add("40DC31DD-2FA7-F6D1-5197-D5B9A3E823EE");
+        defaultToken.add("622067E9-93E5-D8EC-E677-85B58A63C0C7");// 750 专用token
+
+        UserRecord userF750 = new UserRecord();
+        userF750.setUserId(999999);
+        userF750.setAccessToken("622067E9-93E5-D8EC-E677-85B58A63C0C7");
+        userF750.setContent("750项目专用 转发服务");
+        userF750.setUserName("750项目转发服务");
+        userF750.setServiceOrigin("750");
+        defaultTokenMap.put("622067E9-93E5-D8EC-E677-85B58A63C0C7", userF750);
+        UserRecord userFNB = new UserRecord();
+        userFNB.setUserId(999998);
+        userFNB.setAccessToken("65463DEE-620A-0ED5-2385-17ECD07CD351");
+        userFNB.setContent("内部人员专用token");
+        userFNB.setUserName("内部人员专用token");
+        userFNB.setServiceOrigin("neibu");
+        defaultTokenMap.put("65463DEE-620A-0ED5-2385-17ECD07CD351", userFNB);
+
+//        dicMap.put("NatGeo_World_Map" ,"https://server.arcgisonline.com/arcgis/rest/services/NatGeo_World_Map/MapServer");
+//        dicMap.put("USA_Topo_Maps" ,"https://server.arcgisonline.com/arcgis/rest/services/USA_Topo_Maps/MapServer");
+//        dicMap.put("World_Imagery" ,"https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer");
+//        dicMap.put("World_Physical_Map" ,"https://server.arcgisonline.com/arcgis/rest/services/World_Physical_Map/MapServer");
+//        dicMap.put("World_Shaded_Relief" ,"https://server.arcgisonline.com/arcgis/rest/services/World_Shaded_Relief/MapServer");
+//        dicMap.put("World_Terrain_Base" ,"https://server.arcgisonline.com/arcgis/rest/services/World_Terrain_Base/MapServer");
+//        dicMap.put("World_Street_Map" ,"https://server.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer");
+//        dicMap.put("World_Topo_Map" ,"https://server.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer");
+//        dicMap.put("3DModel" ,"http://122.228.13.28:1009/3DTiles/qp/QPXZFWZX/JJ");
+
+    }
+
+
+}

+ 134 - 0
src/main/java/com/skyversation/poiaddr/util/MessageManage.java

@@ -0,0 +1,134 @@
+package com.skyversation.poiaddr.util;
+
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONException;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.skyversation.poiaddr.entity.AddressV4Result;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.List;
+
+/***
+ * 接口返回消息封装管理工具
+ */
+
+@Slf4j
+public class MessageManage {
+
+    private static MessageManage messageManage = new MessageManage();
+    private MessageManage(){}
+    public static MessageManage getInstance(){
+        if(messageManage == null) {
+            messageManage = new MessageManage();
+        }
+        return messageManage;
+    }
+
+    public String getResultContent(int code, String content, String message){
+        JSONObject json = new JSONObject();
+        try {
+            json.put("code", code);
+            if(content == null || content.equals("")){
+                json.put("content", null);
+            } else {
+                json.put("content", content);
+            }
+            json.put("message", message);
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+        log.info(json.toString());
+        return json.toString();
+    }
+
+    public String getResultContent(int code, AddressV4Result addV4, String message){
+        JSONObject json = new JSONObject();
+        try {
+            json.put("code", code);
+            if(addV4 == null){
+                json.put("content", null);
+            } else {
+                JSONObject content = new JSONObject();
+                content.put("resultCode", addV4.getResultCode());
+                content.put("message", addV4.getMessage());
+                content.put("exactResult", addV4.getExactResult());
+                content.put("recomResult", addV4.getRecomResult());
+                json.put("content", content);
+            }
+            json.put("message", message);
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+        return JSON.toJSONString(json, SerializerFeature.DisableCircularReferenceDetect);
+    }
+
+    public String getResultContent(int code, Object bean, String message){
+        JSONObject json = new JSONObject();
+        try {
+            json.put("code", code);
+            if(bean == null){
+                json.put("content", null);
+            } else {
+                json.put("content", JSON.toJSON(bean));
+            }
+            json.put("message", message);
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+        log.info(json.toString());
+        return json.toString();
+    }
+
+    public String getResultContent(int code, List lis, String message){
+        JSONObject json = new JSONObject();
+        try {
+            json.put("code", code);
+            json.put("message", message);
+            if(lis != null && lis.size() > 0){
+                JSONArray data = new JSONArray();
+                for(Object obj : lis){
+                    data.add(JSON.toJSON(obj));
+                }
+                json.put("content", data);
+            } else {
+                json.put("content", null);
+            }
+
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+        log.info(json.toString());
+        return json.toString();
+    }
+    public String getResultContent(int code, List lis, String message, Long total){
+        JSONObject json = new JSONObject();
+        try {
+            json.put("code", code);
+            json.put("message", message);
+            if(total == null || total < 0){
+                json.put("total", 0);
+            } else {
+                json.put("total", total);
+            }
+            if(lis != null && lis.size() > 0){
+                JSONArray data = new JSONArray();
+                for(Object obj : lis){
+                    data.add(JSON.toJSON(obj));
+                }
+                json.put("content", data);
+            } else {
+                json.put("content", "");
+            }
+
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+        log.info(json.toString());
+        return json.toString();
+    }
+
+
+}

+ 46 - 0
src/main/java/com/skyversation/poiaddr/util/PYVerify.java

@@ -0,0 +1,46 @@
+package com.skyversation.poiaddr.util;
+
+import com.skyversation.poiaddr.entity.PYToken;
+import com.skyversation.poiaddr.entity.VerifyBean;
+import com.skyversation.poiaddr.util.net.NetTools;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class PYVerify {
+
+    private static PYVerify instance = new PYVerify();
+    private PYVerify() {}
+    public static PYVerify getInstance() {
+        return instance;
+    }
+
+    public VerifyBean verify(HttpServletRequest request, String token, String servertype) {
+        // 包含token合法验证、次数验证、失效验证
+        PYToken pyToken = NetTools.getInstance().verifyPYToken(token,servertype);
+        if(!StringUtils.isEmpty(pyToken.getErrorMsg())){
+            return new VerifyBean(false, pyToken.getErrorMsg());
+        }
+        if(pyToken == null){
+            return new VerifyBean(false,
+                    MessageManage.getInstance().getResultContent(Constant.FAILURE_TOKEN, "无效token", "无效token"));
+        }
+        // token验证通过,开始验证ip地址和请求是否有授权
+        if(!pyToken.getIpAddress().contains("0.0.0.0")){
+            String ip = NetTools.getIpAddress(request);
+            if(!pyToken.getIpAddress().contains(ip)){
+                return new VerifyBean(false,
+                        MessageManage.getInstance().getResultContent(Constant.IP_NOT_PASS, "ip验证不通过", "ip验证不通过"));
+            }
+        }
+        // ip验证通过,开始验证请求事项
+        if(!pyToken.getMatterName().contains("ALL")){
+            if(!pyToken.getMatterName().contains(servertype)){
+                return new VerifyBean(false,
+                        MessageManage.getInstance().getResultContent(Constant.MATTER_NOT_PASS, "事项验证不通过", "事项验证不通过"));
+            }
+        }
+        return new VerifyBean(true, null);
+    }
+
+}

+ 8 - 6
src/main/java/com/skyversation/poiaddr/util/geotools/GeoJsonIntersector.java

@@ -14,19 +14,20 @@ import java.util.List;
  */
 public class GeoJsonIntersector {
     public static void main(String[] args) throws Exception {
-//        run("香花桥街道", "向阳村,爱星村,大联村,东方村,金米村,东斜村,新姚村,新桥村,民惠第三居委会,燕南村,泾阳村,胜利村,天一村,曹泾村,香花桥居委会,朝阳村,金星村,都汇华庭居委会,陈桥村,盈中村,石西村,杨元村,袁家村,七汇村,郏一村,青山居委会,金巷居委会", "博文中学");
+        run("香花桥街道", "向阳村,爱星村,大联村,东方村,金米村,东斜村,新姚村,新桥村,民惠第三居委会,燕南村,泾阳村,胜利村,天一村,曹泾村,香花桥居委会,朝阳村,金星村,都汇华庭居委会,陈桥村,盈中村,石西村,杨元村,袁家村,七汇村,郏一村,青山居委会,金巷居委会", "博文中学");
 //        run("香花桥街道", "燕南村,泾阳村,东方村,大联村,金米村,新桥村,爱星村,大盈居委会,民惠居委会,民惠第二居委会,民惠第三居委会,新姚村,友爱居委会,胜利村,天一村,向阳村,曹泾村,东斜村", "博文小学");
 //        run("香花桥街道","香花桥居委会,朝阳村,金星村,都汇华庭居委会,盈中村,石西村,杨元村,七汇村,袁家村,郏一村,青山居委会,金巷居委会","香花桥小学");
+//        run("夏阳街道", "青华居委,南箐园社区居委,塔湾村,南门塔湾,大生桥,李腰泾,王仙村,城南村,塘郁村,枫泾村,太来村,新阳村,金家村,夏阳村,夏阳湖社区居委,青平居委,华骥苑社区居委,桂花园社区居委", "豫英小学");
 //        run("夏阳街道", "南门塔湾,大生桥,李腰泾,王仙村,城南村,塘郁村,枫泾村,太来村,新阳村,金家村,夏阳村,丝绸新村,志诚上和里", "豫才中学");
 //        run("盈浦街道", "南横村", "思源中学");
-        run("香花桥街道","","香花桥街道");
+//        run("夏阳街道","仓桥村","仓桥村");
 
     }
 
     public static void run(String jdNameStr, String czNameStr, String fileName) throws Exception {
         List<String> jdNameList = new ArrayList<>(Arrays.asList(jdNameStr.split(",")));
         List<String> nameList = new ArrayList<>();
-        if(czNameStr != null && !czNameStr.isEmpty()){
+        if (czNameStr != null && !czNameStr.isEmpty()) {
             nameList = new ArrayList<>(Arrays.asList(czNameStr.split(",")));
             System.out.println("******需要匹配的村名个数:" + nameList.size());
         }
@@ -39,16 +40,16 @@ public class GeoJsonIntersector {
             String jiezhen = item.getJSONObject("properties").getString("jz");
             String cunName = item.getJSONObject("properties").getString("cjname");
             if (jdNameList.contains(jiezhen)) {
-                if(czNameStr == null || czNameStr.isEmpty()){
+                if (czNameStr == null || czNameStr.isEmpty()) {
                     newFeatures.add(feature);
-                }else if(nameList.contains(cunName)){
+                } else if (nameList.contains(cunName)) {
                     newFeatures.add(feature);
                     System.out.println("++++匹配到:" + jiezhen + "." + cunName);
                     nameList.remove(cunName);
                 }
             }
         }
-        if(nameList.size()>0){
+        if (nameList.size() > 0) {
             for (String cName : nameList) {
                 System.out.println("----没有匹配到:" + cName);
             }
@@ -60,6 +61,7 @@ public class GeoJsonIntersector {
         saveGeoJson(processingGeoJson, "output/result_" + fileName + ".geojson");
         System.out.println("解析完成,已保存结果geojson文件到output/,文件名称:result_" + fileName + ".geojson");
     }
+
     private static JSONObject readGeoJson(String path) throws Exception {
         String fileData = new JSONParser().parse(new FileReader(path)).toString();
         return JSONObject.parseObject(fileData);

+ 154 - 0
src/main/java/com/skyversation/poiaddr/util/net/MultiThreadedAsyncHttpClient.java

@@ -0,0 +1,154 @@
+package com.skyversation.poiaddr.util.net;
+import java.net.URI;
+import java.net.URLEncoder;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+import java.util.concurrent.*;
+
+/**
+ * executeAsyncRequests 方法:
+ * 接收请求的 URL 列表、请求头和请求参数作为输入。
+ * 创建一个固定大小的线程池,线程池的大小与 URL 列表的大小相同。
+ * 使用 CountDownLatch 来确保所有任务都执行完毕。
+ * 遍历 URL 列表,为每个 URL 创建一个 RequestTask 任务,并提交到线程池中执行。
+ * 等待所有任务完成后,关闭线程池并返回所有请求的结果。
+ * RequestTask 类:
+ * 实现了 Runnable 接口,用于定义请求任务。
+ * 在 run 方法中,构建请求 URL,添加请求头和参数,使用 HttpClient 发送异步请求。
+ * 处理响应并将结果添加到 results 列表中。
+ * 在 finally 块中调用 latch.countDown() 方法,减少计数器的值,表示任务完成。
+ * saveResultsToDatabase 方法:
+ * 模拟将请求结果存储到数据库的操作,这里只是简单地打印结果。
+ *
+ * 注意事项
+ * 线程池大小:线程池的大小应根据系统资源和请求的性质进行合理调整,避免创建过多线程导致系统资源耗尽。
+ * 异常处理:在 RequestTask 的 run 方法中捕获并处理可能的异常,确保任务的稳定性。
+ * 数据库存储:实际应用中,需要根据具体的数据库类型和使用的数据库访问框架(如 JDBC、MyBatis 等)来实现将结果存储到数据库的功能。
+ * 通过这种方式,可以实现多线程异步请求,并在所有请求完成后将结果存储到数据库。
+ */
+public class MultiThreadedAsyncHttpClient {
+
+    public static void main(String[] args) {
+        // 模拟请求的 URL 列表
+        List<String> urls = Arrays.asList(
+                "https://www.example.com/api/endpoint1",
+                "https://www.example.com/api/endpoint2"
+        );
+
+        // 配置请求头
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Authorization", "Bearer your_token");
+        headers.put("Content-Type", "application/json");
+
+        // 配置请求参数
+        Map<String, String> params = new HashMap<>();
+        params.put("param1", "value1");
+        params.put("param2", "value2");
+
+        // 执行多线程异步请求
+        List<String> results = executeAsyncRequests(urls, headers, params);
+
+        // 模拟将结果存储到数据库
+        saveResultsToDatabase(results);
+    }
+
+    public static List<String> executeAsyncRequests(List<String> urls, Map<String, String> headers, Map<String, String> params) {
+        // 创建一个固定大小的线程池
+        int threadPoolSize = urls.size();
+        ExecutorService executorService = Executors.newFixedThreadPool(threadPoolSize);
+
+        // 创建 CountDownLatch 用于等待所有任务完成
+        CountDownLatch latch = new CountDownLatch(threadPoolSize);
+
+        // 用于存储所有请求的结果
+        List<String> results = new CopyOnWriteArrayList<>();
+
+        // 创建并提交任务到线程池
+        for (String url : urls) {
+            executorService.submit(new RequestTask(url, headers, params, latch, results));
+        }
+
+        try {
+            // 等待所有任务完成
+            latch.await();
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            e.printStackTrace();
+        }
+
+        // 关闭线程池
+        executorService.shutdown();
+
+        return results;
+    }
+
+    static class RequestTask implements Runnable {
+        private final String url;
+        private final Map<String, String> headers;
+        private final Map<String, String> params;
+        private final CountDownLatch latch;
+        private final List<String> results;
+
+        public RequestTask(String url, Map<String, String> headers, Map<String, String> params, CountDownLatch latch, List<String> results) {
+            this.url = url;
+            this.headers = headers;
+            this.params = params;
+            this.latch = latch;
+            this.results = results;
+        }
+
+        @Override
+        public void run() {
+            try {
+                // 创建 HttpClient 实例
+                HttpClient client = HttpClient.newHttpClient();
+
+                // 构建请求 URL,添加参数
+                StringBuilder query = new StringBuilder();
+                for (Map.Entry<String, String> entry : params.entrySet()) {
+                    if (query.length() > 0) {
+                        query.append("&");
+                    }
+                    query.append(URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8));
+                    query.append("=");
+                    query.append(URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8));
+                }
+                String fullUrl = url + "?" + query.toString();
+
+                // 创建 HttpRequest 实例
+                HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
+                        .uri(URI.create(fullUrl));
+
+                // 添加请求头
+                for (Map.Entry<String, String> entry : headers.entrySet()) {
+                    requestBuilder.header(entry.getKey(), entry.getValue());
+                }
+
+                HttpRequest request = requestBuilder.build();
+
+                // 发送异步请求
+                CompletableFuture<HttpResponse<String>> future = client.sendAsync(request, HttpResponse.BodyHandlers.ofString());
+                HttpResponse<String> response = future.get();
+
+                // 处理响应
+                results.add(response.body());
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                // 任务完成,减少计数器
+                latch.countDown();
+            }
+        }
+    }
+
+    public static void saveResultsToDatabase(List<String> results) {
+        // 模拟将结果存储到数据库
+        System.out.println("将以下结果存储到数据库:");
+        for (String result : results) {
+            System.out.println(result);
+        }
+    }
+}

+ 242 - 0
src/main/java/com/skyversation/poiaddr/util/net/NetTools.java

@@ -0,0 +1,242 @@
+package com.skyversation.poiaddr.util.net;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.skyversation.poiaddr.entity.PYToken;
+import com.skyversation.poiaddr.entity.UserRecord;
+import com.skyversation.poiaddr.entity.VerifyBean;
+import com.skyversation.poiaddr.util.Constant;
+import com.skyversation.poiaddr.util.MessageManage;
+import com.skyversation.poiaddr.util.PYVerify;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.springframework.http.*;
+import org.springframework.http.client.SimpleClientHttpRequestFactory;
+import org.springframework.http.converter.StringHttpMessageConverter;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+
+public class NetTools {
+
+    private static NetTools instance = new NetTools();
+
+    private NetTools() {
+    }
+
+    public synchronized static NetTools getInstance() {
+        if (instance == null) {
+            instance = new NetTools();
+        }
+        return instance;
+    }
+
+    public List<String> tempToken = new ArrayList<>();
+    public boolean isRun = false;
+
+    private String userName = "user001";
+
+    /**
+     * Oauth 密码
+     */
+    private String password = "1234567890";
+
+    public String getUserByToken(String token, String requestURI, HttpServletResponse response, HttpServletRequest request) throws IOException {
+        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+        Map<String, String> header = new HashMap<>();
+        header.put("token", token);
+        params.put("strUrl", Collections.singletonList(requestURI));
+        params.put("serviceId", Collections.singletonList("10"));
+        JSONObject jsonObject = null;
+        try {
+            jsonObject = JSONObject.parseObject(requestPost(Constant.OAUTH_GET_USER_BY_TOKEN, params, header));
+        } catch (Exception e) {
+            System.err.println(e.getMessage());
+        }
+        response.setCharacterEncoding("utf-8");
+        response.setContentType("application/json; charset=utf-8");
+        return MessageManage.getInstance().getResultContent(jsonObject.getInteger("code"), jsonObject.getString("content"), jsonObject.getString("message"));
+    }
+
+    public VerifyBean verifyToken(String token, String strUrl) {
+        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+        Map<String, String> header = new HashMap<>();
+        header.put("token", token);
+        params.put("strUrl", Collections.singletonList(strUrl));
+        params.put("serviceId", Collections.singletonList("8"));
+        JSONObject jsonObject = JSONObject.parseObject(requestPost(Constant.OAUTH_URL_GETUSER, params, header));
+        if (jsonObject.getInteger("code") == 200) {
+            return new VerifyBean(true, null);
+        } else {
+            return new VerifyBean(false, jsonObject.toJSONString());
+        }
+    }
+
+    /***
+     * 验证PY token, 包含token合法验证、次数验证、失效验证
+     * @param token
+     * @return
+     */
+    public PYToken verifyPYToken(String token, String serverType) {
+        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+        Map<String, String> header = new HashMap<>();
+        params.put("token", Collections.singletonList(token));
+        params.put("serverType", Collections.singletonList(serverType));
+        JSONObject jsonObject =
+                JSONObject.parseObject(requestPost(Constant.OAUTH_PY_URL, params, header));
+        if (jsonObject.getInteger("code") == 200) {
+            return JSON.parseObject(jsonObject.getJSONObject("content").toJSONString(), PYToken.class);
+        } else {
+            PYToken pyToken = new PYToken();
+            pyToken.setErrorMsg(jsonObject.toJSONString());
+            return pyToken;
+        }
+    }
+
+    public VerifyBean isDefautUser(HttpServletRequest request, String token, String servertype) {
+        if (Constant.getInstance().defaultToken.contains(token)) {
+            UserRecord userRecord = Constant.getInstance().defaultTokenMap.get(token);
+            if (userRecord != null) {
+                MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+                params.add("userId", userRecord.getUserId() + "");
+                params.add("accessToken", token);
+                params.add("loginIp", getIpAddress(request));
+                params.add("content", userRecord.getContent());
+                params.add("userName", userRecord.getUserName());
+                params.add("requestUrl", request.getRequestURI());
+                params.add("serviceOrigin", userRecord.getServiceOrigin());
+                params.add("state", servertype);
+                requestPost(Constant.OAUTH_RECORD_URL, params, new HashMap<>());
+            }
+            return new VerifyBean(true, null);
+        }
+        return new VerifyBean(false,
+                MessageManage.getInstance().getResultContent(Constant.FAILURE_TOKEN, "无效token", "无效token"));
+    }
+
+    public String requestPost(String url, MultiValueMap<String, String> params, Map<String, String> headerMap) {
+        SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
+        requestFactory.setConnectTimeout(10 * 1000);
+        requestFactory.setReadTimeout(10 * 1000);
+        RestTemplate client = new RestTemplate(requestFactory);
+        client.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
+        HttpHeaders headers = new HttpHeaders();
+        //请勿轻易改变此提交方式,大部分的情况下,提交方式都是表单提交
+        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+        if (headerMap != null) {
+            Set<String> sets = headerMap.keySet();
+            for (String key : sets) {
+                headers.add(key, headerMap.get(key));
+            }
+        }
+
+        HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(params, headers);//执行HTTP请求
+        ResponseEntity<String> response = client.exchange(url, HttpMethod.POST, requestEntity, String.class);
+        return response.getBody();
+    }
+
+    public ResponseEntity requestGet(String url, MultiValueMap<String, String> params, Map<String, String> headerMap) {
+        SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
+        requestFactory.setConnectTimeout(10 * 1000);
+        requestFactory.setReadTimeout(10 * 1000);
+        RestTemplate client = new RestTemplate(requestFactory);
+        client.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
+        HttpHeaders headers = new HttpHeaders();
+        //请勿轻易改变此提交方式,大部分的情况下,提交方式都是表单提交
+        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+        if (headerMap != null) {
+            Set<String> sets = headerMap.keySet();
+            for (String key : sets) {
+                headers.add(key, headerMap.get(key));
+            }
+        }
+
+        HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(params, headers);//执行HTTP请求
+        ResponseEntity<String> response = client.exchange(url, HttpMethod.GET, requestEntity, String.class);
+        return response;
+    }
+
+    public static String sendGetRequest(String urlString) throws Exception {
+        HttpClient httpClient = HttpClients.createDefault();
+        HttpGet httpGet = new HttpGet(urlString);
+        HttpResponse response = httpClient.execute(httpGet);
+        HttpEntity entity = (HttpEntity) response.getEntity();
+        return EntityUtils.toString((org.apache.http.HttpEntity) entity);
+    }
+
+    /**
+     * Oauth 登录获取token
+     *
+     * @return
+     */
+    public String loginForToken() {
+        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+        params.add("userName", userName);
+        params.add("password", password);
+        params.add("clientId", "8");
+        String response = NetTools.getInstance().requestPost(Constant.OAUTH_LOGIN_URL, params, new HashMap<>());
+        JSONObject jsonObject = JSON.parseObject(response);
+        return jsonObject.getString("message");
+    }
+
+    /**
+     * 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址;
+     *
+     * @param request
+     * @return
+     * @throws IOException
+     */
+    public final static String getIpAddress(HttpServletRequest request) {
+        String ip = "";
+        try {
+            // 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址
+            ip = request.getHeader("X-Forwarded-For");
+            if (ip != null && ip.length() > 0 && !"unKnown".equalsIgnoreCase(ip)) {
+                // 多次反向代理后会有多个ip值,第一个ip才是真实ip
+                int index = ip.indexOf(",");
+                if (index != -1) {
+                    return ip.substring(0, index);
+                } else {
+                    return ip;
+                }
+            }
+            ip = request.getHeader("X-Real-IP");
+            if (ip != null && ip.length() > 0 && !"unKnown".equalsIgnoreCase(ip)) {
+                return ip;
+            }
+            ip = request.getRemoteAddr();
+        } catch (Exception e) {
+            // TODO: handle exception
+        }
+        return ip;
+    }
+
+    public static boolean verifyToken(HttpServletRequest request, String token, String servertype){
+        // TODO 正常代理服务
+        VerifyBean verifyBean = null;
+        if(token.length() == 36){
+            verifyBean = NetTools.getInstance().isDefautUser(request, token, servertype);
+        } else {
+            verifyBean = NetTools.getInstance().verifyToken(token, servertype);
+            if(!verifyBean.isVerify()){
+                verifyBean = PYVerify.getInstance().verify(request, token, servertype);
+            }
+        }
+
+        if(!verifyBean.isVerify()){
+            return false;
+        }
+
+        return true;
+    }
+
+}

+ 58 - 0
src/main/java/com/skyversation/poiaddr/util/test/NetworkRequestTest.java

@@ -0,0 +1,58 @@
+package com.skyversation.poiaddr.util.test;
+
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.*;
+
+/**
+ * 根据测试数据条数,测试市大数据中心接口响应时间
+ */
+public class NetworkRequestTest {
+    private static final String URL = "https://service-api.onemap.sh.gov.cn/data-service-manage-service/MapProxyApi/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBsaWNhdGlvbl9pZCI6NjEsImFwcGxpY2F0aW9uX25hbWUiOiLpnZLmtabkuozkuInnu7TmnI3liqHns7vnu58iLCJleHAiOjIwNDY2Nzg0MDN9.IKUMdjUX4U1jncIUNren-iotL7duXI90aLECMjpvUX8/address_search/MapServer?region=310118&page_num=1&page_size=1&query=馨浦苑西区"; // 替换为实际的接口地址
+    private static final int TEST_DURATION = 1000; // 测试请求次数
+
+    public static void main(String[] args) throws InterruptedException {
+        int threadCount = Runtime.getRuntime().availableProcessors();
+        ExecutorService executorService = Executors.newFixedThreadPool(threadCount);
+
+        long startTime = System.currentTimeMillis();
+        List<Future<?>> futures = new ArrayList<>();
+        for (int i = 0; i < TEST_DURATION - 1; i++) {
+            futures.add(executorService.submit(() -> {
+                try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
+                    HttpGet httpGet = new HttpGet(URL);
+                    try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
+                        // 处理响应
+                        System.out.println("-----------------请求结果:" + response.toString());
+                        EntityUtils.consume(response.getEntity());
+                    }
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }));
+        }
+
+        // 等待所有任务完成
+        for (Future<?> future : futures) {
+            try {
+                future.get();
+            } catch (InterruptedException | ExecutionException e) {
+                e.printStackTrace();
+            }
+        }
+        // 关闭线程池
+        executorService.shutdown();
+        long endTime = System.currentTimeMillis();
+        System.out.println("线程个数:" + threadCount);
+        long time = (endTime - startTime) / 1000;
+        System.out.println(TEST_DURATION + "个请求所用的时间: " + time + "秒!");
+        System.out.println("平均一秒请求" + TEST_DURATION / time + "个!");
+    }
+}

+ 3 - 0
src/main/resources/META-INF/MANIFEST.MF

@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: com.skyversation.poiaddr.PoiAddrApplication
+

+ 1 - 10
src/main/resources/application.properties

@@ -1,14 +1,5 @@
 server.port=8081
 server.servlet.context-path=/poiApi/
 spring.application.name=poiAddr
-# application.properties
-spring.datasource.url=jdbc:postgresql://127.0.0.1:5432/postgres
-spring.datasource.username=postgres
-spring.datasource.password=WE176852439@lmx
-spring.jpa.hibernate.ddl-auto=update
-spring.jpa.show-sql=true
 spring.servlet.multipart.max-file-size=300MB
-spring.servlet.multipart.max-request-size=300MB
-
-zip_file_path: ${ZIP_FILE_PATH:C:/Users/Liumouren/Desktop/}
-zip_file_name: ${ZIP_FILE_NAME:outFile}
+spring.servlet.multipart.max-request-size=300MB