1
0
فهرست منبع

远程调用优化

chenendian 2 ماه پیش
والد
کامیت
96b9ee14d6

+ 12 - 4
siwei-api/siwei-api-spatial/src/main/java/com/siwei/spatial/api/RemoteSpatialFilesDbService.java

@@ -7,12 +7,12 @@ import com.siwei.spatial.api.domain.file.TGeomDb;
 import com.siwei.spatial.api.domain.file.TGeomDbDetails;
 import com.siwei.spatial.api.factory.RemoteSpatialFilesDbFallbackFactory;
 import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.*;
 
+import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 @FeignClient(contextId = "remoteSpatialFilesDbService", value = ServiceNameConstants.SPATIAL_SERVICE, fallbackFactory = RemoteSpatialFilesDbFallbackFactory.class)
 public interface RemoteSpatialFilesDbService {
@@ -33,4 +33,12 @@ public interface RemoteSpatialFilesDbService {
 
     @GetMapping("/files/db/query/geom/details/page")
     public R<List<TGeomDbDetails>> queryGeomDetailsPage(@RequestParam("id") String id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+
+    @PostMapping("/files/db/geom/save")
+    public R<TGeomDb> saveGeom(@RequestBody Map<String,Object> geoms) throws IOException;
+
+
+
+
+
 }

+ 8 - 0
siwei-api/siwei-api-spatial/src/main/java/com/siwei/spatial/api/factory/RemoteSpatialFilesDbFallbackFactory.java

@@ -9,7 +9,9 @@ import org.slf4j.LoggerFactory;
 import org.springframework.cloud.openfeign.FallbackFactory;
 import org.springframework.stereotype.Component;
 
+import java.io.IOException;
 import java.util.List;
+import java.util.Map;
 
 
 /**
@@ -54,6 +56,12 @@ public class RemoteSpatialFilesDbFallbackFactory implements FallbackFactory<Remo
             public R<List<TGeomDbDetails>> queryGeomDetailsPage(String id, String source) {
                 return R.fail("内部调用异常");
             }
+
+            @Override
+            public R<TGeomDb> saveGeom(Map<String,Object> geomsList) throws IOException {
+                return R.fail("内部调用异常");
+            }
+
         };
 
     }

+ 2 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/vo/LandFirstParamVo.java

@@ -1,6 +1,8 @@
 package com.siwei.apply.domain.vo;
 
 import lombok.Data;
+
+
 import java.util.List;
 import java.util.Map;
 

+ 1 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/impl/NodeLandImpl.java

@@ -53,6 +53,7 @@ public class NodeLandImpl implements NodeLandService {
 
             // 先删除该nodeId的所有关联记录
             nodeLandMapper.deleteByNodeId(nodeId);
+
             logger.info("删除已存在的节点地块关联记录,nodeId: {}", nodeId);
 
             // 创建新的关联记录

+ 47 - 35
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/impl/OfferDataServiceImpl.java

@@ -8,11 +8,16 @@ import com.siwei.apply.enums.AloneWorkFlowEnum;
 import com.siwei.apply.mapper.ProjectWorkflowMapper;
 import com.siwei.apply.service.GyjsydscdjService;
 import com.siwei.apply.service.NodeAttachmentService;
+import com.siwei.apply.service.NodeLandService;
 import com.siwei.apply.service.third.OfferDataService;
 import com.siwei.apply.utils.ServiceUtil;
+import com.siwei.common.core.domain.R;
 import com.siwei.common.core.exception.ServiceException;
+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.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -27,22 +32,20 @@ import java.util.*;
 @Service
 public class OfferDataServiceImpl implements OfferDataService {
 
-
     @Autowired
     private NodeAttachmentService nodeAttachmentService;
 
     @Autowired
     private ProjectWorkflowMapper projectWorkflowMapper;
 
-
     @Autowired
     private GyjsydscdjService gyjsydscdjService;
 
+    @Autowired
+    private RemoteSpatialFilesDbService remoteSpatialFilesDbService;
 
-
-
-
-
+    @Autowired
+    private NodeLandService nodeLandService;
 
 
     @Override
@@ -55,10 +58,8 @@ public class OfferDataServiceImpl implements OfferDataService {
         return Map.of();
     }
 
-
     @Override
     public Map<String, Object> landFirstRegistration(LandFirstParamVo body) {
-        //
         String yfbdcdyh = body.getYfbdcdyh();
         if(StringUtils.isBlank(yfbdcdyh)){
             throw new ServiceException("预分不动产单元号为空");
@@ -67,39 +68,50 @@ public class OfferDataServiceImpl implements OfferDataService {
         if(StringUtils.isBlank(ywbh)){
             throw new ServiceException("业务编号为空");
         }
+        List<String> geomsList = body.getGeoms();
+        if(CollectionUtils.isEmpty(geomsList)){
+            throw new ServiceException("geom信息为空");
+        }
         //todo 这里进行文件下载入库:
 
-
-
-
-        //todo 这里进行矢量文件的保存及其传输。
-
-
-
-        GyjsydscdjVo gyjsydscdjVo = new GyjsydscdjVo();
-        gyjsydscdjVo.setProjectId(body.getXmbh());
-        gyjsydscdjVo.setQlr(body.getQlr());
-        gyjsydscdjVo.setGyqk(body.getGyqk());
-        gyjsydscdjVo.setZl(body.getZl());
-        gyjsydscdjVo.setQllx(body.getQllx());
-        gyjsydscdjVo.setQlxz(body.getQlxz());
-        gyjsydscdjVo.setTdyt(body.getTdyt());
-        if (StringUtils.isNotBlank(body.getTdmj())) {
-            gyjsydscdjVo.setArea(Float.valueOf(body.getTdmj()));
+        try {
+            GyjsydscdjVo gyjsydscdjVo = new GyjsydscdjVo();
+            gyjsydscdjVo.setProjectId(body.getXmbh());
+            gyjsydscdjVo.setQlr(body.getQlr());
+            gyjsydscdjVo.setGyqk(body.getGyqk());
+            gyjsydscdjVo.setZl(body.getZl());
+            gyjsydscdjVo.setQllx(body.getQllx());
+            gyjsydscdjVo.setQlxz(body.getQlxz());
+            gyjsydscdjVo.setTdyt(body.getTdyt());
+            if (StringUtils.isNotBlank(body.getTdmj())) {
+                gyjsydscdjVo.setArea(Float.valueOf(body.getTdmj()));
+            }
+            gyjsydscdjVo.setAreaUnit(body.getTdmjdw());
+            gyjsydscdjVo.setBdcdyh(StringUtils.isNotBlank(body.getBdcdyh()) ? body.getBdcdyh() : body.getYfbdcdyh());
+            gyjsydscdjVo.setBdczh(body.getBdczh());
+            gyjsydscdjVo.setDjjg(body.getDjjg());
+            gyjsydscdjVo.setDjDate(body.getDjrq());
+
+            String nodeId = gyjsydscdjService.add(gyjsydscdjVo);
+            Map<String, Object> map1 = new HashMap<>();
+            map1.put("geomData", geomsList);
+            //todo 这里进行矢量文件的保存及其传输。
+            R<TGeomDb> res = remoteSpatialFilesDbService.saveGeom(map1);
+            TGeomDb tGeomDb = res.getData();
+            //这里保存geom映射关系
+            nodeLandService.createNodeLand(nodeId, tGeomDb.getId());
+            Map<String, Object> map = new HashMap<>();
+            map.put("id", nodeId);
+            return map;
+        } catch (Exception e) {
+            log.error("调用矢量保存文件错误,业务编号:{}: ",ywbh);
+            e.printStackTrace();
         }
-        gyjsydscdjVo.setAreaUnit(body.getTdmjdw());
-        gyjsydscdjVo.setBdcdyh(StringUtils.isNotBlank(body.getBdcdyh()) ? body.getBdcdyh() : body.getYfbdcdyh());
-        gyjsydscdjVo.setBdczh(body.getBdczh());
-        gyjsydscdjVo.setDjjg(body.getDjjg());
-        gyjsydscdjVo.setDjDate(body.getDjrq());
-
-        String id = gyjsydscdjService.add(gyjsydscdjVo);
-        Map<String, Object> map = new HashMap<>();
-        map.put("id", id);
-        return map;
+        return null;
     }
 
 
+
     @Override
     public String getTheFile(String attachmentId, String dirName, String fileName) {
         String fileAndPath = "";

+ 12 - 4
siwei-modules/siwei-spatial/src/main/java/com/siwei/spatial/controller/file/SpatialFilesDbController.java

@@ -10,13 +10,12 @@ import com.siwei.spatial.service.file.ISpatialFilesDbService;
 import com.siwei.spatial.service.file.ITGeomDbDetailsService;
 import com.siwei.spatial.service.file.ITGeomDbService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 空间与shp文件入库相关操作处理
@@ -116,4 +115,13 @@ public class SpatialFilesDbController extends BaseController {
     }
 
 
+    @PostMapping("/geom/save")
+    // @InnerAuth
+    public R<TGeomDb> saveGeom(@RequestBody Map<String,Object> geoms ) throws IOException {
+        List<String> geomsList = (List<String>) geoms.get("geomData");
+        return R.ok(iSpatialFilesDbService.thirdUploadGeom(geomsList));
+    }
+
+
+
 }

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

@@ -3,10 +3,13 @@ package com.siwei.spatial.service.file;
 import com.siwei.spatial.api.domain.file.TGeomDb;
 
 import java.io.IOException;
+import java.util.List;
 
 public interface ISpatialFilesDbService {
 
     TGeomDb readShpFile(String shpFileName, String shpFilePath, String fromRoute) throws IOException;
 
     TGeomDb readGeom(String shpFileName, String geom, String fromRoute);
+
+    TGeomDb thirdUploadGeom(List<String> geomsList);
 }

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

@@ -319,4 +319,58 @@ public class SpatialFilesDbServiceImpl implements ISpatialFilesDbService {
                 return "GBK";
         }
     }
+
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public TGeomDb thirdUploadGeom(List<String> geomsList){
+        String tDbId = IdUtils.fastSimpleUUID();
+        //List<Map<String, Object>> shpFeaturesList = readShapeFile(shpFile);
+        Long sort = 0L;
+        for (String  shpGeom : geomsList) {
+            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(JSON.toJSONString(shpFeatures));
+            detailsDTO.setGeomJson("{\"id\":\"" + detailsDTO.getId() + "\"}");
+            itGeomDbDetailsService.insertTGeomDbDetails(detailsDTO);
+            sort++;
+        }
+
+        TGeomDb dto = new TGeomDb();
+        dto.setId(tDbId);
+        dto.setName("shpFileName");
+        dto.setShppath("0");
+        dto.setFiletype("3");
+        dto.setFromroute("third");
+
+        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;
+    }
+
+
+
+
+
+
+
+
+
+
 }