root před 2 roky
rodič
revize
99fad56660

+ 4 - 0
simulation-resource-monitor/src/main/java/com/css/simulation/resource/monitor/mappper/ScenePackageSublistMapper.java

@@ -1,6 +1,7 @@
 package com.css.simulation.resource.monitor.mappper;
 
 import com.css.simulation.resource.monitor.pojo.GeneralPO;
+import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
@@ -27,4 +28,7 @@ public interface ScenePackageSublistMapper {
             "    </foreach>" +
             "</script>")
     List<GeneralPO> selectGeneralDataNotIn(@Param("sceneGeneralizationIdList") List<String> sceneGeneralizationIdList);
+
+    @Delete("delete from scene_general_data where id = #{id}}")
+    void deleteById(@Param("id")String id);
 }

+ 12 - 4
simulation-resource-monitor/src/main/java/com/css/simulation/resource/monitor/scheduler/MyScheduler.java

@@ -103,7 +103,7 @@ public class MyScheduler {
     }
 
 
-    @Scheduled(fixedDelay = 60 * 1000)
+    @Scheduled(fixedDelay = 24 * 60 * 60 * 1000)
     public void deleteGeneral() {
         log.info("deleteGeneral() 开始清除泛化垃圾文件。");
         try {
@@ -117,11 +117,19 @@ public class MyScheduler {
             });
             //3 查询不在id列表中的所有泛化数据
             List<GeneralPO> generalPOS = scenePackageSublistMapper.selectGeneralDataNotIn(sceneGeneralizationIdList);
+            log.info("deleteGeneral() 准备删除:" + generalPOS);
             generalPOS.forEach(
                     generalPO -> {
-                        MinioUtil.rm(minioClient, minioConfiguration.getBucketName(), generalPO.getOsgbAddress());
-                        MinioUtil.rm(minioClient, minioConfiguration.getBucketName(), generalPO.getXodrAddress());
-                        MinioUtil.rm(minioClient, minioConfiguration.getBucketName(), generalPO.getXoscAddress());
+                        if (StringUtil.isNotEmpty(generalPO.getOsgbAddress())) {
+                            MinioUtil.rm(minioClient, minioConfiguration.getBucketName(), generalPO.getOsgbAddress());
+                        }
+                        if (StringUtil.isNotEmpty(generalPO.getXodrAddress())) {
+                            MinioUtil.rm(minioClient, minioConfiguration.getBucketName(), generalPO.getXodrAddress());
+                        }
+                        if (StringUtil.isNotEmpty(generalPO.getXoscAddress())) {
+                            MinioUtil.rm(minioClient, minioConfiguration.getBucketName(), generalPO.getXoscAddress());
+                        }
+                        scenePackageSublistMapper.deleteById(generalPO.getId());
                     }
             );
         } catch (Exception e) {