Explorar el Código

自动抓取不动产房屋数据

chenendian hace 19 horas
padre
commit
76ef9c1d90

+ 2 - 2
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/third/DealExcelController.java

@@ -37,13 +37,13 @@ public class DealExcelController extends BaseController {
      * 不动产数据下载
      */
     @GetMapping("/excelImmobileDown/{fileName}")
-    public R<Map<String, List<Map<String,String>>>> excelImmobileDown(@PathVariable String fileName) {
+    public R<Map<String, List<Map<String,String>>>> excelImmobileDown(@PathVariable String fileName)  {
         try {
             String uploadFile = "C:\\Users\\Administrator\\Desktop\\11\\excel_out"+"\\"+fileName;
             Path filePath = Paths.get(uploadFile);
             File file = filePath.toFile();
             Map<String, List<Map<String, String>>> dataMap = readExcelWithMergedHeaders(file);
-            String res = dealExcelService.excelImmobileDownFile(dataMap);
+            String res = dealExcelService.excelImmobileDownFile_HOUSE(dataMap);
             logger.info("检查数据结果{}",res);
             return R.ok(dataMap);
         } catch (Exception e) {

+ 71 - 6
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/impl/DealExcelServiceImpl.java

@@ -2,6 +2,7 @@ package com.siwei.apply.service.third.impl;
 
 import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.JSONWriter;
 import com.siwei.apply.common.Constant;
@@ -117,7 +118,69 @@ public class DealExcelServiceImpl {
      * @param dataMap
      * @return
      */
-    public String excelImmobileDownFile(Map<String, List<Map<String, String>>> dataMap) {
+    public String excelImmobileDownFile_HOUSE(Map<String, List<Map<String, String>>> dataMap) {
+        List<Map<String, String>> immobileList = dataMap.get("不动产权信息列表");
+        int i=0;
+        Set<String> ywhSet = immobileList.stream().map(s->s.get("业务号")).collect(Collectors.toSet());
+        for (String ywbh : ywhSet) {
+            Map<String, Object> retMap = new HashMap<>();
+            String new_ywbh = ywbh+"01";
+            //todo 这里进行远程请求,获取相关数据,解析后入库
+            try {
+                Map<String,Object> paramMap = new LinkedHashMap<>();
+                paramMap.put("ywbh",new_ywbh);
+                paramMap.put("yfbdcdyh","");
+                String remoteResult = ServiceUtil.getRemoteDataByHttpClient("query.houseRegist.datas",paramMap);
+                JSONObject root = JSON.parseObject(remoteResult);
+                log.info("远程调用返回结果: {}", root);
+                JSONObject innerDataCheck = root.getJSONObject("data");
+                if(!innerDataCheck.get("code").equals("200")){
+                    log.warn("接口请求返回: {},ywh:{}", innerDataCheck,ywbh);
+                    continue;
+                }
+                //todo 这里需要确认用户返回的是数组还是对象
+                JSONArray innerArray =  root.getJSONObject("data").getJSONArray("data");
+                String prettyJson = JSON.toJSONString(innerArray, JSONWriter.Feature.PrettyFormat);
+                //这里记录日志
+                writeToLog(ywbh+".txt",prettyJson);
+                retMap.put("body",prettyJson);
+            } catch (Exception e) {
+                log.error("调用矢量保存文件错误,业务编号:{}: ", ywbh);
+                e.printStackTrace();
+                throw new RuntimeException(e);
+            }
+
+            //第二部分获取附件数据
+            try {
+                if(MapUtils.isNotEmpty(retMap)){
+                    Map<String,Object> paramMap = new LinkedHashMap<>();
+                    paramMap.put("ywbh",new_ywbh);
+                    String remoteResult = ServiceUtil.getRemoteDataByHttpClient("query.ywFiles.datas",paramMap);
+                    JSONObject root = JSON.parseObject(remoteResult);
+                    JSONObject innerData = root.getJSONObject("data").getJSONObject("data");
+                    LandFirstParamVo body = JSON.parseObject(innerData.toString(), LandFirstParamVo.class);
+                    //这里保存附件信息
+                    if(Objects.nonNull(body) && Objects.nonNull(body.getAttachment()) && !body.getAttachment().isEmpty()){
+                        this.getThirdAttachmentToLocal(ywbh,body.getAttachment());
+                    }
+                }
+            } catch (Exception e) {
+                log.error("调用不动产获取附件信息错误,业务号:{}: ", ywbh);
+                e.printStackTrace();
+                throw new RuntimeException(e);
+            }
+            if(++i>=2)break;
+        }//end for
+        return null;
+    }
+
+
+    /**
+     * 下载相关的不动产材料附件
+     * @param dataMap
+     * @return
+     */
+    public String excelImmobileDownFile_LND(Map<String, List<Map<String, String>>> dataMap) {
         List<Map<String, String>> immobileList = dataMap.get("不动产权信息列表");
         int i=0;
         for (Map<String, String> batch : immobileList) {
@@ -138,11 +201,6 @@ public class DealExcelServiceImpl {
                     continue;
                 }
 
-
-
-
-
-
                 String remoteResult = ServiceUtil.getRemoteDataByHttpClient("query.landRegist.datas",paramMap);
                 JSONObject root = JSON.parseObject(remoteResult);
                 log.info("远程调用返回结果: {}", root);
@@ -191,6 +249,13 @@ public class DealExcelServiceImpl {
     }
 
 
+
+
+
+
+
+
+
     public String getThirdAttachmentToLocal(String nodeName,List<Map<String, Object>> attachmentList) {
         String fileDownLoadPath = "";
         try {