Parcourir la source

添加定时删除视图功能

DESKTOP-2K9OVK9\siwei il y a 4 mois
Parent
commit
491172e3a3

+ 2 - 1
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/mapper/vector/TableDataMapper.java

@@ -40,8 +40,9 @@ public interface TableDataMapper {
 
     List<String> getTableNames(@Param("schema") String schema, @Param("startWith") String startWith);
 
-    List<String> getVectorTableS();
+    List<Map<String,Object>> getVectorTableS();
 
+    int dropVectorView(@Param("tableName") String tableName);
     int dropVectorTable(@Param("tableName") String tableName);
 
     void delElongatedPolygon(@Param("tableName") String tableName, @Param("minArea") float minArea, @Param("elongationRatio") float elongationRatio);

+ 11 - 3
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/task/AnalyseDBSchedule.java

@@ -10,6 +10,8 @@ import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.Locale;
+import java.util.Map;
 
 /**
  * 定时删除空间计算生成的临时表
@@ -32,13 +34,19 @@ public class AnalyseDBSchedule {
         long tenMinutesInMillis = 60 * 60 * 1000; // 10分钟的毫秒数
         Long timeMillis = System.currentTimeMillis() - tenMinutesInMillis;
         String tenMinutesTableName = TEMPORARY + "_" + timeMillis;
-        List<String> tableList = tableDataMapper.getVectorTableS();
+        List<Map<String, Object>> tableList = tableDataMapper.getVectorTableS();
         log.info("data :" + timeMillis);
         log.info("data1 :" + DateUtils.dateTimeNow());
-        for (String tableName : tableList) {
+        for (Map<String, Object> tableValueMap : tableList) {
+            String tableName = (String) tableValueMap.get("table_name");
             if (tableName.indexOf(TEMPORARY) == 0) {
                 if (tableName.compareTo(tenMinutesTableName) < 0) {
-                    tableDataMapper.dropVectorTable(tableName);
+                    String tableType = StringUtils.toRootLowerCase((String) tableValueMap.get("table_type"));
+                    if ("view".equals(tableType)) {
+                        tableDataMapper.dropVectorView(tableName);
+                    } else {
+                        tableDataMapper.dropVectorTable(tableName);
+                    }
                 }
             }
         }

+ 5 - 2
onemap-modules/onemap-analyse/src/main/resources/mapper/oracle/vector/TableDateMapper.xml

@@ -241,12 +241,15 @@
         WHERE table_name LIKE #{tableName}
     </select>
 
-    <select id="getVectorTableS" resultType="String">
-        SELECT table_name
+    <select id="getVectorTableS" resultType="map">
+        SELECT table_name,table_type
         FROM information_schema.tables
         WHERE table_schema = 'vector'
     </select>
 
+    <delete id="dropVectorView">
+        DROP VIEW "${tableName}"
+    </delete>
     <delete id="dropVectorTable">
         DROP TABLE "${tableName}"
     </delete>

+ 4 - 0
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/service/dimentity/impl/DimEntityServiceImpl.java

@@ -31,7 +31,11 @@ public class DimEntityServiceImpl implements DimEntityService {
                 level = 4;
             } else if (len == 6) {
                 level = 5;
+            } else {
+                id = null;
             }
+        } else {
+            id = null;
         }
         //创建视图
         String viewTableName = StringUtils.getTemporaryTableName();