1
0
Просмотр исходного кода

不动土地首次登记代码兼容

chenendian 1 неделя назад
Родитель
Сommit
2608571e20

+ 62 - 4
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/impl/TakeDataServiceImpl.java

@@ -3,24 +3,25 @@ package com.siwei.apply.service.third.impl;
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
+import com.fasterxml.jackson.databind.JsonNode;
 import com.siwei.apply.domain.*;
 
 import com.siwei.apply.domain.vo.*;
 import com.siwei.apply.enums.AloneWorkFlowEnum;
 
 import com.siwei.apply.mapper.*;
-import com.siwei.apply.service.GyjsydjfwscdjService;
-import com.siwei.apply.service.GyjsydscdjService;
-import com.siwei.apply.service.NodeAttachmentService;
-import com.siwei.apply.service.NodeLandService;
+import com.siwei.apply.service.*;
 import com.siwei.apply.service.third.TakeDataService;
+import com.siwei.apply.utils.ArcGisUtil;
 import com.siwei.apply.utils.HttpClientUtil;
 import com.siwei.apply.utils.ServiceUtil;
+import com.siwei.common.core.domain.R;
 import com.siwei.common.core.exception.ServiceException;
 import com.siwei.common.core.utils.DateUtils;
 import com.siwei.common.core.utils.StringUtils;
 import com.siwei.common.core.utils.bean.BeanUtils;
 import com.siwei.spatial.api.RemoteSpatialFilesDbService;
+import com.siwei.spatial.api.domain.file.TGeomDb;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.MapUtils;
@@ -77,6 +78,15 @@ public class TakeDataServiceImpl implements TakeDataService {
     @Autowired
     private  LandOneCodeMapper landOneCodeMapper;
 
+    @Autowired
+    private ProjectService projectService;
+
+    @Autowired
+    LandOneCodeService landOneCodeService;
+
+
+
+
     @Override
     public String add(TakeDataAddVo takeDataAddVo) {
         // TODO: Implement add logic
@@ -243,6 +253,11 @@ public class TakeDataServiceImpl implements TakeDataService {
         if (StringUtils.isBlank(yfbdcdyh)) {
             throw new ServiceException("预赋不动产单元号为空");
         }
+        String bdcdyh = paramVo.getBdcdyh();
+        if (StringUtils.isBlank(bdcdyh)) {
+            throw new ServiceException("不动产单元号为空");
+        }
+
         String ywh = paramVo.getYwh();
         if (StringUtils.isBlank(ywh)) {
             throw new ServiceException("业务编号为空");
@@ -284,6 +299,49 @@ public class TakeDataServiceImpl implements TakeDataService {
                 retMap.put("projectId",projectId);
                 retMap.put("nodeId",addNodeId);
             }
+        } catch (Exception e) {
+            log.error("调用不动产基本信息保存错误,业务编号:{}: ", ywh);
+            e.printStackTrace();
+            throw new RuntimeException(e);
+        }
+
+
+        //todo 这里进行远程请求,获取不动产矢量数据
+        try {
+
+            String projectId = retMap.get("projectId").toString();
+            String nodeId = retMap.get("nodeId").toString();
+
+            ArcGisUtil client = new ArcGisUtil(ArcGisUtil.ARCGIS_BASE_URL, ArcGisUtil.LAYER_ID, ArcGisUtil.SRID);
+            String where = "BDCDYH='"+bdcdyh+"'";
+            JsonNode page = client.query(where, ArcGisUtil.WITH_GEOMETRY, 0, ArcGisUtil.PAGE_SIZE);
+            log.info("run get ArcGIS service  OK: {} (layer={}, srid={})", ArcGisUtil.PAGE_SIZE, ArcGisUtil.LAYER_ID, ArcGisUtil.SRID);
+            JsonNode features = page.path("features");
+            JsonNode f = features.get(0);
+            if (ArcGisUtil.WITH_GEOMETRY) {
+                JsonNode rings = f.path("geometry").path("rings");
+                String ewkt4490 = client.ringsToEwkt(rings);
+                log.info("ewkt OK: {} ", ewkt4490);
+                // 这里进行数据入库更新建立关联
+                Map<String, Object> map = new HashMap<>();
+                map.put("geoms", ewkt4490);
+                map.put("sourceType", "bdc");
+                R<TGeomDb> saveGeomRes = remoteSpatialFilesDbService.saveGeom(map);
+                TGeomDb tGeomDb = saveGeomRes.getData();
+                log.info("远程调用geom保存,返回结果:{}", tGeomDb);
+                //这里保存geom映射关系
+                nodeLandService.createNodeLand(nodeId, tGeomDb.getId());
+                //预付码逻辑
+                projectService.addPreAssignCode(nodeId,projectId,tGeomDb.getId(),0);
+                //这里进行当上链操作:
+                gyjsydscdjService.updateHasOnchain(nodeId,true);
+                // 更新项目表的上链数量
+                projectService.countOnChinaNum(projectId);
+                //这里生成资源吗
+                landOneCodeService.addOrUpdateLandOneCodeInfo(projectId,nodeId);
+            }
+
+
         } catch (Exception e) {
             log.error("调用矢量保存文件错误,业务编号:{}: ", ywh);
             e.printStackTrace();

+ 13 - 6
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/utils/ArcGisUtil.java

@@ -22,7 +22,13 @@ import java.util.*;
 public class ArcGisUtil {
 
     private static final Logger log = LoggerFactory.getLogger(ArcGisUtil.class);
-    private static final int PAGE_SIZE = 1000;
+    public static final int PAGE_SIZE = 1000;
+    public static final int LAYER_ID = 0;
+    public static final int SRID = 4490;
+    public static final boolean WITH_GEOMETRY = true;
+    public static final String ARCGIS_BASE_URL = "http://192.168.100.1:6080/arcgis/rest/services/GJXQ/BDC_DBZD/MapServer";
+
+
 
     private final ObjectMapper mapper = new ObjectMapper();
 
@@ -94,7 +100,6 @@ public class ArcGisUtil {
         if (rings == null || !rings.isArray() || rings.isEmpty()) return null;
         JsonNode firstRing = rings.get(0);
         if (!firstRing.isArray() || firstRing.isEmpty()) return null;
-
         StringBuilder pts = new StringBuilder();
         for (int i = 0; i < firstRing.size(); i++) {
             JsonNode pt = firstRing.get(i);
@@ -106,13 +111,15 @@ public class ArcGisUtil {
         // 显式闭合:首末相同,便于 WKTReader 严格解析
         JsonNode head = firstRing.get(0);
         pts.append(", ").append(String.format("%.6f %.6f", head.get(0).asDouble(), head.get(1).asDouble()));
-
-        String wkt = "POLYGON((" + pts + "))";
-        org.locationtech.jts.geom.Geometry jts =
-                new org.locationtech.jts.io.WKTReader().read(wkt);
+        // ========= 修改1:外层改为 MULTIPOLYGON 包裹 =========
+        String wkt = "MULTIPOLYGON(((" + pts + ")))";
+        org.locationtech.jts.geom.Geometry jts = new org.locationtech.jts.io.WKTReader().read(wkt);
+        // ========= 修改2:固定SRID=4490 =========
         return "SRID=" + srid + ";" + jts.toText();
     }
 
+
+
     /**
      * 只取要素总数(用于同步前估算总量)。
      */

+ 3 - 0
siwei-modules/siwei-spatial/src/main/java/com/siwei/spatial/controller/file/SpatialFilesDbController.java

@@ -161,6 +161,9 @@ public class SpatialFilesDbController extends BaseController {
         }else if(sourceType.equalsIgnoreCase("excel")){//兼容一键导入数据
             List<String> gdIdList = (List<String>) geoms.get("gdIdList");
             return R.ok(iSpatialFilesDbService.excelImportGeom(gdIdList));
+        }else if(sourceType.equalsIgnoreCase("bdc")){//兼容不动产数据
+            String geomData =  String.valueOf(geoms.get("geoms"));
+            return R.ok(iSpatialFilesDbService.bdcArcgisGeom(geomData));
         }
         return null;
     }

+ 2 - 2
siwei-modules/siwei-spatial/src/main/java/com/siwei/spatial/service/file/ISpatialFilesDbService.java

@@ -29,14 +29,14 @@ public interface ISpatialFilesDbService {
 
     String testInsertShpZD(List<Map<String,Object>> shpDataMapList);
 
-
     void  dealShpFileDownLoad(HttpServletResponse response, String ysdm );
 
-
     void writeShapefileByTable(String tableName, String filePath, String fileName) throws Exception ;
 
     TGeomDb excelImportGeom(List<String> gdIdList);
 
+    TGeomDb bdcArcgisGeom(String geoms);
+
     List<Map<String, Object>> readShpFileByPath(String shpFilePath) throws IOException;
 
 }

+ 40 - 0
siwei-modules/siwei-spatial/src/main/java/com/siwei/spatial/service/file/impl/SpatialFilesDbServiceImpl.java

@@ -494,6 +494,46 @@ public class SpatialFilesDbServiceImpl implements ISpatialFilesDbService {
         return dto;
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public TGeomDb bdcArcgisGeom(String geoms){
+        String tDbId = IdUtils.fastSimpleUUID();
+        Long sort = 0L;
+        if(StringUtils.isNotBlank(geoms)) {
+            String shpGeom = geoms;
+            TGeomDbDetails detailsDTO = new TGeomDbDetails();
+            detailsDTO.setShpDbSRID(shpDbSRID);
+            detailsDTO.setShpAreaSRID(shpAreaSRID);
+            detailsDTO.setShpOutSRID(shpOutSRID);
+            detailsDTO.setShpAreaGeography(shpAreaGeography);
+            detailsDTO.setId(IdUtils.fastSimpleUUID());
+            detailsDTO.setUploadId(tDbId);
+            //直接获取geom
+            detailsDTO.setGeom(shpGeom);
+            detailsDTO.setSort(sort);
+            //这里如何获取其他属性
+            detailsDTO.setGeomJson("{\"id\":\"" + detailsDTO.getId() + "\"}");
+            itGeomDbDetailsService.insertTGeomDbDetails(detailsDTO);
+        }
+
+        TGeomDb dto = new TGeomDb();
+        dto.setId(tDbId);
+        dto.setName("bdc_data");
+        dto.setShppath("0");
+        dto.setFiletype("4");
+        dto.setFromroute("remote");
+
+        TGeomDb retDto = itGeomDbDetailsService.sumGeomDetailsByUploadId(tDbId);
+        dto.setGeom(retDto.getGeom());
+        dto.setGeomNumber(retDto.getGeomNumber());
+        dto.setGeomArea(retDto.getGeomArea());
+        dto.setShpDbSRID(shpDbSRID);
+        dto.setShpAreaSRID(shpAreaSRID);
+        dto.setShpOutSRID(shpOutSRID);
+        dto.setShpAreaGeography(shpAreaGeography);
+        itGeomDbService.insertTGeomDb(dto);
+        return dto;
+    }
 
 
     //todo 这里文件上传获取矢量处理