DESKTOP-6LTVLN7\Liumouren 1 місяць тому
батько
коміт
633cc74f66

+ 0 - 49
src/main/java/com/skyversation/poiaddr/addquery/TransfromDataTool.java

@@ -3,16 +3,11 @@ package com.skyversation.poiaddr.addquery;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.skyversation.poiaddr.bean.AddressResult;
 import com.skyversation.poiaddr.bean.AddressResult;
-import com.skyversation.poiaddr.entity.AmapAddressV3;
-import com.skyversation.poiaddr.service.AreaService;
 import com.skyversation.poiaddr.util.AddressTools;
 import com.skyversation.poiaddr.util.AddressTools;
 import com.skyversation.poiaddr.util.CoordTransform2;
 import com.skyversation.poiaddr.util.CoordTransform2;
 import com.skyversation.poiaddr.util.status.AddressResultEnum;
 import com.skyversation.poiaddr.util.status.AddressResultEnum;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
 
 
 public class TransfromDataTool {
 public class TransfromDataTool {
 
 
@@ -119,50 +114,6 @@ public class TransfromDataTool {
             result.setCode(AddressResultEnum.RESULT_NULL);
             result.setCode(AddressResultEnum.RESULT_NULL);
             return result;
             return result;
         }
         }
-
-        //          TODO 将请求返回的市中心结果入库到pgsql中
-        /*List<AmapAddressV3> amapAddressV3List = new ArrayList<>();
-        try {
-            for (int i = 0; i < array.size(); i++) {
-                JSONObject item = array.getJSONObject(i);
-                AmapAddressV3 amapAddressV3 = new AmapAddressV3();
-                amapAddressV3.setId(UUID.randomUUID().toString());
-                amapAddressV3.setName(item.get("name").toString());
-                amapAddressV3.setType("测绘院结果");
-                amapAddressV3.setAddress(item.get("address").toString());
-                JSONObject localtion = item.getJSONObject("location");
-                Double wgs84Lng = localtion.getDouble("lng");
-                Double wgs84Lat = localtion.getDouble("lat");
-                double[] points2 = CoordTransform2.getInstance().wgs84_to_shcj(wgs84Lng, wgs84Lat);
-                double[] points = CoordTransform2.getInstance().wgs84_to_gcj02(wgs84Lng, wgs84Lat);
-                amapAddressV3.setLocation(points[0] + "," + points[1]);
-                amapAddressV3.setLon(String.valueOf(points2[0]));
-                amapAddressV3.setLat(String.valueOf(points2[1]));
-                amapAddressV3.setCreateTime(new Date());
-                if (item.containsKey("ext_data")) {
-                    JSONObject ext_data = item.getJSONObject("ext_data");
-                    if (!ext_data.get("region_ss").toString().isEmpty()) {
-                        amapAddressV3.setPname(ext_data.get("region_ss").toString());
-                        amapAddressV3.setCityname(ext_data.get("region_ss").toString());
-                    }
-                    if (!ext_data.get("region_qx").toString().isEmpty()) {
-                        amapAddressV3.setAdname(ext_data.get("region_qx").toString());
-                    }
-                    if (!ext_data.get("region_jd").toString().isEmpty()) {
-                        amapAddressV3.setStreetTown(ext_data.get("region_jd").toString());
-                    }
-                    if (!ext_data.get("region_jw").toString().isEmpty()) {
-                        amapAddressV3.setResidentialCommittee(ext_data.get("region_jw").toString());
-                    }
-                }
-                amapAddressV3List.add(amapAddressV3);
-            }
-            if (amapAddressV3List.size() > 0) {
-                AreaService.getInstance().saveAmapAddressV3(amapAddressV3List);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }*/
         JSONObject jsonObject = com.skyversation.poiaddr.util.AddressTools.getInstance().findBestMatch(searchAddress, array, "address");
         JSONObject jsonObject = com.skyversation.poiaddr.util.AddressTools.getInstance().findBestMatch(searchAddress, array, "address");
         if (jsonObject.containsKey("总分") && jsonObject.get("总分") != null && !jsonObject.getString("总分").isEmpty()) {
         if (jsonObject.containsKey("总分") && jsonObject.get("总分") != null && !jsonObject.getString("总分").isEmpty()) {
             AddressResult.ContentBean content = new AddressResult.ContentBean();
             AddressResult.ContentBean content = new AddressResult.ContentBean();

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

@@ -0,0 +1,106 @@
+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 2025-06-03 19:55:31 
+ */
+
+@AllArgsConstructor
+@NoArgsConstructor
+@Data
+@Entity
+@Table ( name ="yysz_address_v3_all" , schema = "")
+public class YyszAddressV3All  implements Serializable {
+
+	private static final long serialVersionUID =  1044982171735043007L;
+
+	@Id
+   	@Column(name = "id" )
+	private String id;
+
+   	@Column(name = "parent" )
+	private String parent;
+
+   	@Column(name = "childtype" )
+	private String childtype;
+
+   	@Column(name = "name" )
+	private String name;
+
+   	@Column(name = "type" )
+	private String type;
+
+   	@Column(name = "typecode" )
+	private String typecode;
+
+   	@Column(name = "biz_type" )
+	private String bizType;
+
+   	@Column(name = "address" )
+	private String address;
+
+   	@Column(name = "location" )
+	private String location;
+
+   	@Column(name = "tel" )
+	private String tel;
+
+   	@Column(name = "pname" )
+	private String pname;
+
+   	@Column(name = "cityname" )
+	private String cityname;
+
+   	@Column(name = "adname" )
+	private String adname;
+
+   	@Column(name = "importance" )
+	private String importance;
+
+   	@Column(name = "shopid" )
+	private String shopid;
+
+   	@Column(name = "shopinfo" )
+	private String shopinfo;
+
+   	@Column(name = "poiweight" )
+	private String poiweight;
+
+   	@Column(name = "distance" )
+	private String distance;
+
+   	@Column(name = "biz_ext" )
+	private String bizExt;
+
+   	@Column(name = "photos" )
+	private String photos;
+
+   	@Column(name = "update_time" )
+	private Date updateTime;
+
+   	@Column(name = "create_time" )
+	private Date createTime;
+
+   	@Column(name = "residential_committee" )
+	private String residentialCommittee;
+
+   	@Column(name = "lon" )
+	private String lon;
+
+   	@Column(name = "lat" )
+	private String lat;
+
+   	@Column(name = "street_town" )
+	private String streetTown;
+}

+ 7 - 0
src/main/java/com/skyversation/poiaddr/service/AreaService.java

@@ -46,6 +46,9 @@ public class AreaService {
     @Autowired
     @Autowired
     private YyszAddressV3Service yyszAddressV3Service;
     private YyszAddressV3Service yyszAddressV3Service;
 
 
+    @Autowired
+    private YyszAddressV3AllService yyszAddressV3AllService;
+
     @Autowired
     @Autowired
     private YyskAddressStandardizationSerice yyskAddressStandardizationSerice;
     private YyskAddressStandardizationSerice yyskAddressStandardizationSerice;
 
 
@@ -143,6 +146,10 @@ public class AreaService {
         return yyszAddressV3Service.getDataByPages(page,pageSize);
         return yyszAddressV3Service.getDataByPages(page,pageSize);
     }
     }
 
 
+    public Page<YyszAddressV3All> getTyaData3ByPage(Integer page, Integer pageSize){
+        return yyszAddressV3AllService.getDataByPages(page,pageSize);
+    }
+
     public List<YyszAddressQp> saveYyszAddressQp(List<YyszAddressQp> amapAddressV3List){
     public List<YyszAddressQp> saveYyszAddressQp(List<YyszAddressQp> amapAddressV3List){
         return yyszAddressQpService.saveYyszAddressQp(amapAddressV3List);
         return yyszAddressQpService.saveYyszAddressQp(amapAddressV3List);
     }
     }

+ 10 - 0
src/main/java/com/skyversation/poiaddr/service/YyszAddressV3AllRepository.java

@@ -0,0 +1,10 @@
+package com.skyversation.poiaddr.service;
+
+import com.skyversation.poiaddr.entity.YyszAddressV3All;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import javax.annotation.Resource;
+
+@Resource
+public interface YyszAddressV3AllRepository extends JpaRepository<YyszAddressV3All, String> {
+}

+ 42 - 29
src/main/java/com/skyversation/poiaddr/service/impl/YyskAddressStandardizationServiceImpl.java

@@ -580,49 +580,52 @@ public class YyskAddressStandardizationServiceImpl {
     public void tyaToServer(Integer startOidIndex, Integer page, Integer pageSize) {
     public void tyaToServer(Integer startOidIndex, Integer page, Integer pageSize) {
         System.out.println("page:" + page + ",pageSize:" + pageSize);
         System.out.println("page:" + page + ",pageSize:" + pageSize);
         long startTime = System.currentTimeMillis();
         long startTime = System.currentTimeMillis();
-        Page<YyszAddressV3> sqlDatas = AreaService.getInstance().getTyaData2ByPage(page, pageSize);
-        List<YyszAddressV3> tYyszAddressList = sqlDatas.getContent();
+        Page<YyszAddressV3All> sqlDatas = AreaService.getInstance().getTyaData3ByPage(page, pageSize);
+        List<YyszAddressV3All> tYyszAddressList = sqlDatas.getContent();
         JSONObject dataList = new JSONObject();
         JSONObject dataList = new JSONObject();
 //          操作类型 1:新增,2:更新3:删除
 //          操作类型 1:新增,2:更新3:删除
         dataList.put("optFlag", 1);
         dataList.put("optFlag", 1);
         JSONArray datas = new JSONArray();
         JSONArray datas = new JSONArray();
-        for (YyszAddressV3 tYyszAddress : tYyszAddressList) {
+        for (YyszAddressV3All tYyszAddress : tYyszAddressList) {
             JSONObject dataItem = new JSONObject();
             JSONObject dataItem = new JSONObject();
             dataItem.put("oid", Long.valueOf(startOidIndex));
             dataItem.put("oid", Long.valueOf(startOidIndex));
             startOidIndex++;
             startOidIndex++;
-            dataItem.put("address", initAddrMap.outAddrMapInAddr(tYyszAddress.getSourceaddress()).getAddress());
-            dataItem.put("sourceaddress", tYyszAddress.getSourceaddress());
-            dataItem.put("city", tYyszAddress.getCity());
-            dataItem.put("county", tYyszAddress.getCounty());
-            dataItem.put("town", tYyszAddress.getTown());
-            dataItem.put("community", tYyszAddress.getCommunity());
-            dataItem.put("lon", tYyszAddress.getX());
-            dataItem.put("lat", tYyszAddress.getY());
-            dataItem.put("address_type", tYyszAddress.getAddressType());
+            dataItem.put("address", tYyszAddress.getName());
+//            dataItem.put("address", initAddrMap.outAddrMapInAddr(tYyszAddress.getAddress()).getAddress());
+            dataItem.put("sourceaddress", tYyszAddress.getAddress());
+            dataItem.put("city", tYyszAddress.getCityname());
+            dataItem.put("county", tYyszAddress.getAdname());
+            dataItem.put("town", tYyszAddress.getStreetTown());
+            dataItem.put("community", tYyszAddress.getResidentialCommittee());
+            dataItem.put("lon", tYyszAddress.getLocation().split(",")[0]);
+            dataItem.put("lat", tYyszAddress.getLocation().split(",")[1]);
+            dataItem.put("x",tYyszAddress.getLon());
+            dataItem.put("y",tYyszAddress.getLat());
+            dataItem.put("address_type", tYyszAddress.getType());
             dataItem.put("createtime", getCurrentDateTime());
             dataItem.put("createtime", getCurrentDateTime());
             dataItem.put("updatetime", getCurrentDateTime());
             dataItem.put("updatetime", getCurrentDateTime());
-            dataItem.put("match_level", tYyszAddress.getMatchLevel());
+//            dataItem.put("match_level", tYyszAddress.getMatchLevel());
             datas.add(dataItem);
             datas.add(dataItem);
         }
         }
         dataList.put("data", datas);
         dataList.put("data", datas);
 //      TODO 发送远程请求
 //      TODO 发送远程请求
-        Map<String,Object> logItem = new HashMap<>();
-        logItem.put("page",page);
-        logItem.put("pageSize",pageSize);
+        Map<String, Object> logItem = new HashMap<>();
+        logItem.put("page", page);
+        logItem.put("pageSize", pageSize);
         entityManager.clear();
         entityManager.clear();
         try {
         try {
             String resStr = AddressQueryEngine.getInstance().putDataToSJ_Big_Data_kafka_server(dataList).toString();
             String resStr = AddressQueryEngine.getInstance().putDataToSJ_Big_Data_kafka_server(dataList).toString();
-            logItem.put("res",resStr);
+            logItem.put("res", resStr);
             System.out.println(resStr);
             System.out.println(resStr);
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
             String resStr = e.toString();
             String resStr = e.toString();
-            logItem.put("res",resStr);
+            logItem.put("res", resStr);
             System.err.println(page + "页数据入湖异常" + e);
             System.err.println(page + "页数据入湖异常" + e);
         }
         }
         long endTime = System.currentTimeMillis();
         long endTime = System.currentTimeMillis();
-        logItem.put("startTime",timestampToDateTime(startTime));
-        logItem.put("endTime",timestampToDateTime(endTime));
+        logItem.put("startTime", timestampToDateTime(startTime));
+        logItem.put("endTime", timestampToDateTime(endTime));
         ScheduledTasks.LogInfos.add(logItem);
         ScheduledTasks.LogInfos.add(logItem);
         System.out.println("单批数据处理完成,用时:" + (endTime - startTime) / 1000 + "秒!");
         System.out.println("单批数据处理完成,用时:" + (endTime - startTime) / 1000 + "秒!");
         if (sqlDatas.getTotalPages() > page && !ScheduledTasks.pauseTag) {
         if (sqlDatas.getTotalPages() > page && !ScheduledTasks.pauseTag) {
@@ -630,6 +633,7 @@ public class YyskAddressStandardizationServiceImpl {
             tyaToServer(startOidIndex, page, pageSize);
             tyaToServer(startOidIndex, page, pageSize);
         }
         }
     }
     }
+
     public static String timestampToDateTime(long timestamp) {
     public static String timestampToDateTime(long timestamp) {
         // 将时间戳转换为LocalDateTime对象
         // 将时间戳转换为LocalDateTime对象
         LocalDateTime dateTime = Instant.ofEpochMilli(timestamp)
         LocalDateTime dateTime = Instant.ofEpochMilli(timestamp)
@@ -818,7 +822,16 @@ public class YyskAddressStandardizationServiceImpl {
                     yyskAddressStandardization.setResidentialCommittee(item.getOrDefault("residentialCommittee", "").toString());
                     yyskAddressStandardization.setResidentialCommittee(item.getOrDefault("residentialCommittee", "").toString());
                     yyskAddressStandardization.setLon(item.getOrDefault("lon", "").toString());
                     yyskAddressStandardization.setLon(item.getOrDefault("lon", "").toString());
                     yyskAddressStandardization.setLat(item.getOrDefault("lat", "").toString());
                     yyskAddressStandardization.setLat(item.getOrDefault("lat", "").toString());
-                    listData.add(yyskAddressStandardization);
+                    if (yyskAddressStandardization.getStandardAddress() != null && !yyskAddressStandardization.getStandardAddress().isEmpty()) {
+                        AddrBean addrBean = initAddrMap.outAddrMapInAddr(yyskAddressStandardization.getStandardAddress());
+                        if (addrBean.getMarket().contains("上海")) {
+                            yyskAddressStandardization.setStandardAddress(addrBean.getStandardAddress());
+                            yyskAddressStandardization.setDistinguish(addrBean.getDistinguish());
+                            yyskAddressStandardization.setResidentialCommittee(addrBean.getResidentialCommittee());
+                            yyskAddressStandardization.setStreetTown(addrBean.getStreetTown());
+                            listData.add(yyskAddressStandardization);
+                        }
+                    }
                 } catch (Exception e) {
                 } catch (Exception e) {
                     e.printStackTrace();
                     e.printStackTrace();
                 }
                 }
@@ -829,17 +842,17 @@ public class YyskAddressStandardizationServiceImpl {
         }
         }
         if (listData != null && listData.size() > 0) {
         if (listData != null && listData.size() > 0) {
 //              批量更新处理后的数据
 //              批量更新处理后的数据
-            List<YyskDmdzAddressStandardization> resultDataList = runExecutorService(listData);
+            /*List<YyskDmdzAddressStandardization> resultDataList = runExecutorService(listData);
             if (resultDataList.size() > 0) {
             if (resultDataList.size() > 0) {
                 ExcelReaderUtils.convertYYListToMapList(resultDataList, outPath);
                 ExcelReaderUtils.convertYYListToMapList(resultDataList, outPath);
-            }
+            }*/
 //          TODO 数据转换
 //          TODO 数据转换
-//            List<FusionKjdlTydzWf> returnDatas = YyskDmdzAddressStandardizationToFusionKjdlTydzWf(listData);
-//            try {
-//                AreaService.getInstance().saveFktws(returnDatas);
-//            } catch (Exception e) {
-//                System.err.println("第" + startFileIndex + "个文件入库异常:" + e);
-//            }
+            List<FusionKjdlTydzWf> returnDatas = YyskDmdzAddressStandardizationToFusionKjdlTydzWf(listData);
+            try {
+                AreaService.getInstance().saveFktws(returnDatas);
+            } catch (Exception e) {
+                System.err.println("第" + startFileIndex + "个文件入库异常:" + e);
+            }
             long endTime = System.currentTimeMillis();
             long endTime = System.currentTimeMillis();
             System.out.println("处理单批次用时" + (endTime - startTime) / 1000 + "秒!");
             System.out.println("处理单批次用时" + (endTime - startTime) / 1000 + "秒!");
         } else {
         } else {

+ 23 - 0
src/main/java/com/skyversation/poiaddr/service/impl/YyszAddressV3AllService.java

@@ -0,0 +1,23 @@
+package com.skyversation.poiaddr.service.impl;
+
+import com.skyversation.poiaddr.entity.YyszAddressV3All;
+import com.skyversation.poiaddr.service.YyszAddressV3AllRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.stereotype.Service;
+
+
+@Service
+public class YyszAddressV3AllService {
+
+    @Autowired
+    private YyszAddressV3AllRepository yyszAddressV3AllRepository;
+
+    public Page<YyszAddressV3All> getDataByPages(Integer page, Integer pageSize){
+        Pageable pageable = PageRequest.of(page,pageSize);
+        return yyszAddressV3AllRepository.findAll(pageable);
+    }
+
+}

+ 4 - 14
src/main/java/com/skyversation/poiaddr/util/net/AddressNetTools.java

@@ -50,10 +50,10 @@ public class AddressNetTools {
     @Async
     @Async
     public ResponseEntity requestGetOrPost(HttpMethod httpMethod, String url, JSONObject params, Map<String, String> headerMap, Integer ifReloadSize) {
     public ResponseEntity requestGetOrPost(HttpMethod httpMethod, String url, JSONObject params, Map<String, String> headerMap, Integer ifReloadSize) {
         SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
         SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
-        /*requestFactory.setConnectTimeout(10000);
-        requestFactory.setReadTimeout(5000);*/
-        requestFactory.setConnectTimeout(150000);
-        requestFactory.setReadTimeout(120000);
+        requestFactory.setConnectTimeout(10000);
+        requestFactory.setReadTimeout(5000);
+        /*requestFactory.setConnectTimeout(150000);
+        requestFactory.setReadTimeout(120000);*/
         RestTemplate client = new RestTemplate(requestFactory);
         RestTemplate client = new RestTemplate(requestFactory);
         client.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
         client.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
         HttpHeaders headers = new HttpHeaders();
         HttpHeaders headers = new HttpHeaders();
@@ -88,16 +88,6 @@ public class AddressNetTools {
             } else {
             } else {
                 e.printStackTrace();
                 e.printStackTrace();
                 return null;
                 return null;
-                /*if (e.toString().contains("timed out")) {
-                    System.out.print("请求超时!");
-                    return requestGetOrPost(httpMethod, url, params, headerMap, ifReloadSize);
-                } else if (e.toString().contains("时间戳不合法或者已经过期")) {
-                    System.out.print("时间戳过期!");
-                    return requestGetOrPost(httpMethod, url, params, AddressQueryEngine.initSigns(), ifReloadSize);
-                } else {
-                    System.err.println("requestGet err:" + e);
-                    return null;
-                }*/
             }
             }
         }
         }
     }
     }