瀏覽代碼

附件关联测试

chenendian 1 月之前
父節點
當前提交
881f6cab80

+ 1 - 1
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/NodeAttachmentController.java

@@ -93,7 +93,7 @@ public class NodeAttachmentController extends BaseController {
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
             logger.error("处理文件异常", e);
             logger.error("处理文件异常", e);
-            return R.fail(502,"处理文件异常:" + e.getMessage());
+            return R.fail(502,"上传失败:" + e.getMessage());
         }
         }
     }
     }
 
 

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

@@ -182,7 +182,7 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
 
 
         } catch (Exception e) {
         } catch (Exception e) {
             logger.error("处理文件并保存附件信息异常,filePath: {}", filePath, e);
             logger.error("处理文件并保存附件信息异常,filePath: {}", filePath, e);
-            throw new ServiceException("处理文件并保存附件信息异常,"+e.getMessage());
+            throw new ServiceException("附件未保存成功,"+e.getMessage());
         }
         }
     }
     }
 
 

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

@@ -101,6 +101,7 @@ public class OfferDataServiceImpl implements OfferDataService {
             String nodeId = gyjsydscdjService.add(gyjsydscdjVo);
             String nodeId = gyjsydscdjService.add(gyjsydscdjVo);
             Map<String, Object> map1 = new HashMap<>();
             Map<String, Object> map1 = new HashMap<>();
             map1.put("geomData", geomsList);
             map1.put("geomData", geomsList);
+            map1.put("sourceType", "third");
             //todo 这里进行矢量文件的保存及其传输。
             //todo 这里进行矢量文件的保存及其传输。
             R<TGeomDb> res = remoteSpatialFilesDbService.saveGeom(map1);
             R<TGeomDb> res = remoteSpatialFilesDbService.saveGeom(map1);
             TGeomDb tGeomDb = res.getData();
             TGeomDb tGeomDb = res.getData();

+ 1 - 1
siwei-modules/siwei-apply/src/main/resources/mapper/NodeLandMapper.xml

@@ -71,7 +71,7 @@
             node_id,
             node_id,
             geom_db_id
             geom_db_id
         ) VALUES (
         ) VALUES (
-            gen_random_uuid()::varchar,
+            REPLACE(gen_random_uuid()::varchar, '-', ''),
             #{param1},
             #{param1},
             #{param2}
             #{param2}
         )
         )

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

@@ -135,13 +135,32 @@ public class SpatialFilesDbController extends BaseController {
         return R.ok(geomDb);
         return R.ok(geomDb);
     }
     }
 
 
+
+    /**
+     * 根据上传的空间信息进行入库操作  (不动产对接数据入库接口)
+     * 兼容一键导入数据
+     * @param geoms
+     * @return
+     * @throws IOException
+     */
     @PostMapping("/geom/save")
     @PostMapping("/geom/save")
     // @InnerAuth
     // @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));
+    public R<TGeomDb> saveGeom(@RequestBody Map<String,Object> geoms ) {
+        if(geoms.get("sourceType") == null){
+            return R.fail(-1,"执行失败,sourceType参数缺失");
+        }
+        String sourceType = (String) geoms.get("sourceType");
+        if(sourceType.equalsIgnoreCase("third")){ //第三方数据入库
+            List<String> geomsList = (List<String>) geoms.get("geomData");
+            return R.ok(iSpatialFilesDbService.thirdUploadGeom(geomsList));
+        }else if(sourceType.equalsIgnoreCase("excel")){//兼容一键导入数据
+            List<String> gdIdList = (List<String>) geoms.get("gdIdList");
+            return R.ok(iSpatialFilesDbService.excelImportGeom(gdIdList));
+        }
+        return null;
     }
     }
 
 
+
     @GetMapping("/test/parse")
     @GetMapping("/test/parse")
     public R<List<Map<String,Object>>> parse(@RequestParam("filePath") String filePath) {
     public R<List<Map<String,Object>>> parse(@RequestParam("filePath") String filePath) {
         if(StringUtils.isBlank(filePath)){
         if(StringUtils.isBlank(filePath)){

+ 4 - 0
siwei-modules/siwei-spatial/src/main/java/com/siwei/spatial/mapper/file/TGeomDbDetailsMapper.java

@@ -107,4 +107,8 @@ public interface TGeomDbDetailsMapper
      * @return 字段列表
      * @return 字段列表
      */
      */
     List<Map<String, Object>> selectTableColumns(@Param("tableName") String tableName);
     List<Map<String, Object>> selectTableColumns(@Param("tableName") String tableName);
+
+    List<Map<String,Object>> selectTableDataAndGeomById(@Param("idList") List<String> idList,@Param("tableName") String tableName);
+
+
 }
 }

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

@@ -36,5 +36,7 @@ public interface ISpatialFilesDbService {
     void writeShapefileByTable(String tableName, String filePath, String fileName) throws Exception ;
     void writeShapefileByTable(String tableName, String filePath, String fileName) throws Exception ;
 
 
 
 
+    TGeomDb excelImportGeom(List<String> gdIdList);
+
 
 
 }
 }

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

@@ -392,6 +392,54 @@ public class SpatialFilesDbServiceImpl implements ISpatialFilesDbService {
     }
     }
 
 
 
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public TGeomDb excelImportGeom(List<String> gdIdList){
+        String tDbId = IdUtils.fastSimpleUUID();
+        Long sort = 0L;
+        if(!gdIdList.isEmpty()) {
+            List<Map<String, Object>> gdDataList = tGeomDbDetailsMapper.selectTableDataAndGeomById(gdIdList, "gj_gd_data");
+            for (Map<String, Object> gdData : gdDataList) {
+                String shpGeom = (String) gdData.get("geom2");
+                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("gj_gd_data");
+        dto.setShppath("0");
+        dto.setFiletype("4");
+        dto.setFromroute("excel");
+
+        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 这里文件上传获取矢量处理
     //todo 这里文件上传获取矢量处理
     @Override
     @Override
     @Transactional(rollbackFor = Exception.class)
     @Transactional(rollbackFor = Exception.class)

+ 14 - 0
siwei-modules/siwei-spatial/src/main/resources/mapper/postgresql/spatial/file/TGeomDbDetailsMapper.xml

@@ -397,6 +397,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
 
 
 
 
+    <select id="selectTableDataAndGeomById"   resultType="Map">
+        SELECT * ,public.st_asewkt(geom) AS geom2
+        FROM vector.${tableName}
+        -- WHERE 1=1
+        <where>
+            <if test="idList != null and idList.size() > 0">
+                AND gid IN
+                <foreach collection="idList" item="id" open="(" separator="," close=")">
+                    #{id}::int4
+                </foreach>
+            </if>
+        </where>
+    </select>
+
 
 
     <select id="selectTableDataAndGeom"   resultType="Map">
     <select id="selectTableDataAndGeom"   resultType="Map">
         SELECT * ,public.st_asewkt(geom) AS geom2
         SELECT * ,public.st_asewkt(geom) AS geom2