1
0
chenendian 2 месяцев назад
Родитель
Сommit
0b31abcc17

+ 3 - 2
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/BaseId.java

@@ -1,15 +1,16 @@
 package com.siwei.apply.domain;
 package com.siwei.apply.domain;
 
 
+import com.siwei.common.core.utils.uuid.IdUtils;
 import lombok.Data;
 import lombok.Data;
 
 
-import java.util.UUID;
 
 
 @Data
 @Data
 public class BaseId {
 public class BaseId {
     protected String id;
     protected String id;
 
 
     public void generateId() {
     public void generateId() {
-        this.id = UUID.randomUUID().toString();
+        //this.id = UUID.randomUUID().toString();
+        this.id = IdUtils.fastSimpleUUID();
     }
     }
 }
 }
 
 

+ 2 - 1
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/CadastreFileMapper.java

@@ -71,7 +71,8 @@ public interface CadastreFileMapper {
     List<String> selectAllTableNoView();
     List<String> selectAllTableNoView();
 
 
 
 
-    int insertTableData(@Param("tableName") String tableName, @Param("keyList")Collection<String> keyList, @Param("valueList")Collection<Object> valueList);
+    int insertTableData(@Param("tableName") String tableName, @Param("data") Map<String, Object> data, @Param("shpDbSRID") Integer shpDbSRID);
+
 
 
 
 
     String selectGeoms(String tableName);
     String selectGeoms(String tableName);

+ 14 - 11
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/cadastre/impl/CadastreManageServiceImpl.java

@@ -68,12 +68,14 @@ public class CadastreManageServiceImpl implements CadastreManageService {
             if (!cadastreFile.getStatus().equalsIgnoreCase("3")) {
             if (!cadastreFile.getStatus().equalsIgnoreCase("3")) {
                 log.info("校验未通过,不能入库");
                 log.info("校验未通过,不能入库");
                 result = "校验未通过,不能入库";
                 result = "校验未通过,不能入库";
+                return result;
             }
             }
 
 
             String gdbPath = cadastreFile.getUnzipPath();
             String gdbPath = cadastreFile.getUnzipPath();
             DataSource ds = ogr.Open(gdbPath + "/" + cadastreFile.getName(), 0); // 0 = 只读
             DataSource ds = ogr.Open(gdbPath + "/" + cadastreFile.getName(), 0); // 0 = 只读
             if (ds == null) {
             if (ds == null) {
                 log.warn("无法打开 gdb");
                 log.warn("无法打开 gdb");
+                result = "无法打开gdb文件,不能入库";
                 return result;
                 return result;
             }
             }
 
 
@@ -128,11 +130,6 @@ public class CadastreManageServiceImpl implements CadastreManageService {
 //        cadastreFileMapper.addValidFlagColumn("t_cgzj_cwtc_m");
 //        cadastreFileMapper.addValidFlagColumn("t_cgzj_cwtc_m");
 //        //todo 这里进行
 //        //todo 这里进行
 //        List<Map<String,String>> collumTypes =  cadastreFileMapper.selectTableCollumAndType("mzdzw");
 //        List<Map<String,String>> collumTypes =  cadastreFileMapper.selectTableCollumAndType("mzdzw");
-        if(true){
-            //log.info(collumTypes.toString());
-            return compareResultVo;
-        }
-
 
 
         try {
         try {
             List<CompareGemoVo> gemos = new ArrayList<>();
             List<CompareGemoVo> gemos = new ArrayList<>();
@@ -422,13 +419,18 @@ public class CadastreManageServiceImpl implements CadastreManageService {
             }
             }
 
 
             if (haveGeom.equals(true)) {
             if (haveGeom.equals(true)) {
-                String wkt = null;
+                String ewkt = null;
                 Geometry geom = feature.GetGeometryRef();
                 Geometry geom = feature.GetGeometryRef();
                 if (geom != null) {
                 if (geom != null) {
+                    // 创建空间参考对象(例如 WGS84,SRID 4326)
+//                    SpatialReference spatialRef = new SpatialReference();
+//                    spatialRef.SetWellKnownGeogCS("WGS84");
+//                    // 为几何体设置空间参考(SRID 4326)
+//                    geom.AssignSpatialReference(spatialRef);
                     // 将几何对象转换为 WKT 格式
                     // 将几何对象转换为 WKT 格式
-                    wkt = geom.ExportToWkt();
+                    ewkt = "SRID=" + 4326 + ";" + geom.ExportToWkt();;
                 }
                 }
-                map.put("geom", wkt);
+                map.put("geom", ewkt);
             }
             }
             list.add(map);
             list.add(map);
         }
         }
@@ -537,9 +539,10 @@ public class CadastreManageServiceImpl implements CadastreManageService {
         boolean addRes = false;
         boolean addRes = false;
         if (!CollectionUtils.isEmpty(theValueList)) {
         if (!CollectionUtils.isEmpty(theValueList)) {
             for (Map<String, Object> map : theValueList) {
             for (Map<String, Object> map : theValueList) {
-                Collection<Object> values = map.values();
-                Collection<String> keys = map.keySet();
-                cadastreFileMapper.insertTableData(tableName, keys, values);
+//                Collection<Object> values = map.values();
+//                Collection<String> keys = map.keySet();
+                Integer shpDbSRID = 4326;
+                cadastreFileMapper.insertTableData(tableName,map,shpDbSRID);
             }
             }
         }
         }
         return addRes;
         return addRes;

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

@@ -30,7 +30,6 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.Paths;
 import java.nio.file.StandardCopyOption;
 import java.nio.file.StandardCopyOption;
 import java.util.*;
 import java.util.*;
-import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSON;

+ 12 - 4
siwei-modules/siwei-apply/src/main/resources/mapper/cadastre/CadastreFileMapper.xml

@@ -134,14 +134,22 @@
 
 
     <insert id="insertTableData">
     <insert id="insertTableData">
         INSERT INTO vector.${tableName} (
         INSERT INTO vector.${tableName} (
-            <foreach collection="keyList" item="key" separator=",">
+            <foreach collection="data" index="key" item="value" separator=",">
                 ${key}
                 ${key}
             </foreach>
             </foreach>
         )
         )
         VALUES (
         VALUES (
-            <foreach collection="valueList" item="value" separator=",">
-                #{value}
-            </foreach>
+                <foreach collection="data" index="key" item="value" separator=",">
+                    <choose>
+                        <!-- 判断 geom 是否为空,并进行转换 -->
+                        <when test="key == 'geom' and value != null">
+                            public.st_transform(public.st_geomfromewkt(#{value}), #{shpDbSRID})
+                        </when>
+                        <otherwise>
+                            #{value}
+                        </otherwise>
+                    </choose>
+                </foreach>
          )
          )
     </insert>
     </insert>