dsx 2 rokov pred
rodič
commit
85e8fd58a9

+ 30 - 3
4dkankan-task/pom.xml

@@ -6,15 +6,31 @@
     <parent>
         <groupId>com.fdkankan</groupId>
         <artifactId>4dkankan-parent</artifactId>
-        <version>2.0.0-SNAPSHOT</version>
+        <version>ZJ-2.0.0-SNAPSHOT</version>
     </parent>
 
     <artifactId>4dkankan-task</artifactId>
+    <version>ZJ-2.0.0-SNAPSHOT</version>
 
     <properties>
         <java.version>1.8</java.version>
     </properties>
 
+    <repositories>
+        <repository>
+            <id>releases</id>
+            <url>http://192.168.0.115:8081/nexus-2.14.2-01/content/repositories/releases/</url>
+        </repository>
+        <repository>
+            <id>snapshots</id>
+            <url>http://192.168.0.115:8081/nexus-2.14.2-01/content/repositories/snapshots/</url>
+        </repository>
+        <repository>
+            <id>nexus-aliyun</id>
+            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
+        </repository>
+    </repositories>
+
     <dependencies>
 
         <dependency>
@@ -80,12 +96,12 @@
     </dependencies>
 
     <build>
+        <finalName>${artifactId}</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
             </plugin>
-
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
@@ -94,7 +110,18 @@
                 </configuration>
             </plugin>
         </plugins>
-
     </build>
 
+    <distributionManagement>
+        <repository>
+            <id>releases</id>
+            <url>http://192.168.0.115:8081/nexus-2.14.2-01/content/repositories/releases/</url>
+        </repository>
+
+        <snapshotRepository>
+            <id>snapshots</id>
+            <url>http://192.168.0.115:8081/nexus-2.14.2-01/content/repositories/snapshots/</url>
+        </snapshotRepository>
+    </distributionManagement>
+
 </project>

+ 21 - 0
4dkankan-task/src/main/java/com/fdkankan/task/controller/SceneProController.java

@@ -0,0 +1,21 @@
+package com.fdkankan.task.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * pro场景表 前端控制器
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-13
+ */
+@RestController
+@RequestMapping("/task/scenePro")
+public class SceneProController {
+
+}
+

+ 10 - 6
4dkankan-task/src/main/java/com/fdkankan/task/entity/ScenePro.java

@@ -1,11 +1,14 @@
 package com.fdkankan.task.entity;
 
-import com.baomidou.mybatisplus.annotation.*;
-import lombok.Getter;
-import lombok.Setter;
-
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
 import java.io.Serializable;
 import java.util.Date;
+import lombok.Getter;
+import lombok.Setter;
 
 /**
  * <p>
@@ -13,7 +16,7 @@ import java.util.Date;
  * </p>
  *
  * @author 
- * @since 2022-07-04
+ * @since 2023-03-13
  */
 @Getter
 @Setter
@@ -154,8 +157,8 @@ public class ScenePro implements Serializable {
     /**
      * 记录的状态,A: 生效,I: 禁用
      */
-    @TableLogic(value = "A", delval = "I")
     @TableField("rec_status")
+    @TableLogic(value = "A", delval = "I")
     private String recStatus;
 
     /**
@@ -225,4 +228,5 @@ public class ScenePro implements Serializable {
     private Integer isUpgrade;
 
 
+
 }

+ 100 - 0
4dkankan-task/src/main/java/com/fdkankan/task/generate/AutoGenerate.java

@@ -0,0 +1,100 @@
+package com.fdkankan.task.generate;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.generator.FastAutoGenerator;
+import com.baomidou.mybatisplus.generator.config.OutputFile;
+import com.baomidou.mybatisplus.generator.config.rules.DateType;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+public class AutoGenerate {
+
+
+    public static void main(String[] args) {
+
+        System.out.println("相对路径指定到:"+ System.getProperty("user.dir"));
+
+
+        String path =System.getProperty("user.dir") + "\\4dkankan-task";
+
+        generate(path,"task", getTables(new String[]{
+                "t_scene_pro"
+        }));
+
+//        generate(path,"goods", getTables(new String[]{
+//                        "t_camera","t_camera_detail","t_camera_out","t_camera_space","t_camera_version",
+//                        "t_company","t_goods","t_goods_sku","t_cart","t_goods_spec",
+//                        "t_goods_spec_value","t_goods_spu_spec","t_sn_code"
+//        }));
+//
+//        generate(path,"order", getTables(new String[]{
+//                        "t_increment_order","t_invoice","t_order","t_order_item",
+//                        "t_pre_sale","t_space_sdk","t_trade_log","t_commerce_order","t_download_order","t_expansion_order"
+//        }));
+//        generate(path,"order", getTables(new String[]{
+//                        "t_virtual_order"
+//        }));
+//
+//        generate(path,"user", getTables(new String[]{
+//                        "t_user","t_user_increment","t_manager","t_province","t_increment_type","t_intercom_message","t_receiver_info"
+//        }));
+    }
+
+    public static List<String> getTables(String [] tableNames){
+        return new ArrayList<>(Arrays.asList(tableNames));
+    }
+
+
+    public static void  generate(String path,String moduleName,  List<String> tables){
+        FastAutoGenerator.create("jdbc:mysql://120.24.144.164:3306/4dkankan_v4",
+                "root","4Dage@4Dage#@168")
+                .globalConfig(builder -> {
+                    builder.author("")               //作者
+                            .outputDir(path+"\\src\\main\\java")    //输出路径(写到java目录)
+                            //.enableSwagger()           //开启swagger
+                            .commentDate("yyyy-MM-dd")
+                            .dateType(DateType.ONLY_DATE)
+                            .fileOverride();            //开启覆盖之前生成的文件
+
+                })
+                .packageConfig(builder -> {
+                    builder.parent("com.fdkankan")
+                            .moduleName(moduleName)
+                            .entity("entity")
+                            .service("service")
+                            .serviceImpl("service.impl")
+                            .controller("controller")
+                            .mapper("mapper")
+                            .xml("test.mapper")
+                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml,path+"\\src\\main\\resources\\mapper\\"+moduleName));
+                })
+                .strategyConfig(builder -> {
+                    builder.addInclude(tables)
+                            .addTablePrefix("t_")
+
+                            .serviceBuilder()
+                            .formatServiceFileName("I%sService")
+                            .formatServiceImplFileName("%sServiceImpl")
+
+                            .entityBuilder()
+                            .enableLombok()
+                            .logicDeleteColumnName("rec_status")
+                            .enableTableFieldAnnotation()
+
+                            .controllerBuilder()
+                            .formatFileName("%sController")
+                            .enableRestStyle()
+
+                            .mapperBuilder()
+                            .superClass(BaseMapper.class)
+                            .formatMapperFileName("I%sMapper")
+                            .enableMapperAnnotation()
+                            .formatXmlFileName("%sMapper");
+                })
+                // .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
+                .execute();
+    }
+}

+ 112 - 48
4dkankan-task/src/main/java/com/fdkankan/task/schedule/ScheduleJob.java

@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateField;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.net.multipart.UploadFile;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
@@ -52,8 +53,8 @@ public class ScheduleJob {
     private static String videoPathFormat = "video/video%s/";
     private static String voicePathFormat = "voice/voice%s/";
 
-//    @Value("${userId:0}")
-//    private Long userId;
+    @Value("${userId:}")
+    private Long userId;
     @Value("${oss.bucket}")
     private String bucket;
 
@@ -68,40 +69,41 @@ public class ScheduleJob {
     @Autowired
     private IScenePlusExtService scenePlusExtService;
 
-//    @Scheduled(fixedDelay = 2*24*60*60*1000)
-//    public void deleteV3Dir(){
-//
-//        ExecutorService executorService = Executors.newFixedThreadPool(3);
-//
-//        DateTime date = DateUtil.beginOfDay(DateUtil.offset(Calendar.getInstance().getTime(), DateField.DAY_OF_MONTH, -2));
-//
-//        LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<ScenePro>();
-//        wrapper.select(ScenePro::getNum);
-//        wrapper.lt(ScenePro::getCreateTime, date);
-//        wrapper.eq(ScenePro::getStatus, -2);
-//        wrapper.eq(ScenePro::getIsUpgrade, 1);
-//        if(Objects.nonNull(userId)){
-//            wrapper.eq(ScenePro::getUserId, userId);
-//        }
-//        List<ScenePro> list = sceneProService.list(wrapper);
-//        if(CollUtil.isEmpty(list)){
-//            return;
-//        }
-//        for (ScenePro scenePro : list) {
-//            String num = scenePro.getNum();
-//            try {
-//                executorService.submit(()->{
-//                    deleteV3DirHandler(num);
-//                });
-//            }catch (Exception e){
-//                log.error("删除v3目录失败,num" + num, e);
-//            }
-//        }
-//    }
+    @Scheduled(fixedDelay = 2*24*60*60*1000)
+    public void deleteV3Dir(){
+
+        ExecutorService executorService = Executors.newFixedThreadPool(1);
+
+        DateTime date = DateUtil.beginOfDay(DateUtil.offset(Calendar.getInstance().getTime(), DateField.DAY_OF_MONTH, -2));
+
+        LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<ScenePro>();
+        wrapper.select(ScenePro::getNum);
+        wrapper.lt(ScenePro::getCreateTime, date);
+        wrapper.eq(ScenePro::getStatus, -2);
+        wrapper.eq(ScenePro::getIsUpgrade, 1);
+        if(Objects.nonNull(userId)){
+            wrapper.eq(ScenePro::getUserId, userId);
+        }
+        List<ScenePro> list = sceneProService.list(wrapper);
+        if(CollUtil.isEmpty(list)){
+            return;
+        }
+        for (ScenePro scenePro : list) {
+            String num = scenePro.getNum();
+            try {
+                executorService.submit(()->{
+                    deleteV3DirHandler(num);
+                });
+            }catch (Exception e){
+                log.error("删除v3目录失败,num" + num, e);
+            }
+        }
+    }
 
     @Scheduled(fixedDelay = 2*24*60*60*1000)
     public void deleteSceneData(){
-        List<ScenePro> list = sceneProService.listDeleteScene();
+        ExecutorService executorService = Executors.newFixedThreadPool(1);
+        List<ScenePro> list = sceneProService.listDeleteScene(userId);
         if(CollUtil.isEmpty(list)){
             return;
         }
@@ -109,12 +111,11 @@ public class ScheduleJob {
         for (ScenePro scenePro : list) {
             String num = scenePro.getNum();
             try {
-                log.info("删除全部场景数据开始,num:{}", num);
-                Thread.sleep(5000L);
-                log.info("删除全部场景数据开始,num:{}", num);
-
+                executorService.submit(()->{
+                    deleteSceneHandler(num);
+                });
             }catch (Exception e){
-                log.error("删除全部场景数据失败,num:" + num, e);
+                log.error("删除场景全部数据失败,num:" + num, e);
             }
 
         }
@@ -135,20 +136,15 @@ public class ScheduleJob {
 
             String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
             String sceneJsonPath = dataViewPath + "scene.json";
-//                if(!numSet.contains(num)){
             if(StrUtil.isNotEmpty(scenePlusExt.getVideos()) && scenePlusExt.getVideos().contains(dataPath)){
                 scenePlusExt.setVideos(scenePlusExt.getVideos().replaceAll(dataPath, dataViewPath));
                 scenePlusExtService.updateById(scenePlusExt);
+                String sceneJson = uploadToOssUtil.getObjectContent(bucket, sceneJsonPath);
+                JSONObject sceneJsonObj = JSON.parseObject(sceneJson);
+                sceneJsonObj.put("videos", JSON.parseObject(scenePlusExt.getVideos()));
+                uploadToOssUtil.upload(sceneJsonObj.toJSONString().getBytes(), sceneJsonPath);
+                redisUtil.del(String.format(RedisKey.SCENE_JSON, num));
             }
-            String sceneJson = uploadToOssUtil.getObjectContent(bucket, sceneJsonPath);
-            JSONObject sceneJsonObj = JSON.parseObject(sceneJson);
-            sceneJsonObj.put("videos", JSON.parseObject(scenePlusExt.getVideos()));
-            uploadToOssUtil.upload(sceneJsonObj.toJSONString().getBytes(), sceneJsonPath);
-
-            redisUtil.del(String.format(RedisKey.SCENE_JSON, num));
-
-
-//                }
 
             //删除data目录
             List<String> dataList = uploadToOssUtil.listKeys(dataPath);
@@ -185,6 +181,74 @@ public class ScheduleJob {
         }
     }
 
+
+    public void deleteSceneHandler(String num){
+
+        try {
+            log.info("删除场景全部数据开始,num:{}", num);
+            //删除data目录
+            String dataPath = String.format(dataPathFormat, num);
+            List<String> dataList = uploadToOssUtil.listKeys(dataPath);
+            if(CollUtil.isNotEmpty(dataList)){
+                uploadToOssUtil.deleteFile(dataPath);
+            }
+
+            //删除img目录
+            String imgPath = String.format(imgPathFormat, num);
+            List<String> imgList = uploadToOssUtil.listKeys(imgPath);
+            if(CollUtil.isNotEmpty(imgList)){
+                uploadToOssUtil.deleteFile(imgPath);
+            }
+
+            //删除video目录
+            String videoPath = String.format(videoPathFormat, num);
+            List<String> videoList = uploadToOssUtil.listKeys(videoPath);
+            if(CollUtil.isNotEmpty(videoList)){
+                uploadToOssUtil.deleteFile(videoPath);
+            }
+
+            //删除voice目录
+            String voicePath = String.format(voicePathFormat, num);
+            List<String> voiceList = uploadToOssUtil.listKeys(voicePath);
+            if(CollUtil.isNotEmpty(voiceList)){
+                uploadToOssUtil.deleteFile(voicePath);
+            }
+
+            //删除dataview目录
+            String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
+            List<String> dataViewList = uploadToOssUtil.listKeys(dataViewPath);
+            if(CollUtil.isNotEmpty(dataViewList)){
+                uploadToOssUtil.deleteFile(dataViewPath);
+            }
+
+            //删除img目录
+            String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
+            List<String> imgViewList = uploadToOssUtil.listKeys(imgViewPath);
+            if(CollUtil.isNotEmpty(imgViewList)){
+                uploadToOssUtil.deleteFile(imgViewPath);
+            }
+
+            //删除video目录
+            String videoViewPath = String.format(UploadFilePath.VIDEOS_VIEW_PATH, num);
+            List<String> videoViewList = uploadToOssUtil.listKeys(videoViewPath);
+            if(CollUtil.isNotEmpty(videoViewList)){
+                uploadToOssUtil.deleteFile(videoViewPath);
+            }
+
+            //删除voice目录
+            String voiceViewPath = String.format(UploadFilePath.VOICE_VIEW_PATH, num);
+            List<String> voiceViewList = uploadToOssUtil.listKeys(voiceViewPath);
+            if(CollUtil.isNotEmpty(voiceViewList)){
+                uploadToOssUtil.deleteFile(voiceViewPath);
+            }
+
+            redisUtil.sSet(deleteNumKey, num);
+            log.info("删除场景全部数据结束,num:{}", num);
+        }catch (Exception e){
+            log.error("删除场景全部数据失败,num:" + num, e);
+        }
+    }
+
     public static void main(String[] args) {
 
         FileUtil.writeUtf8String(2 + 1 + "", "D:\\test\\bac\\test.txt");

+ 4 - 6
4dkankan-task/src/main/java/com/fdkankan/task/service/ISceneProService.java

@@ -1,7 +1,7 @@
 package com.fdkankan.task.service;
 
-import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.task.entity.ScenePro;
+import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
 
@@ -10,13 +10,11 @@ import java.util.List;
  * pro场景表 服务类
  * </p>
  *
- * @author dengsixing
- * @since 2021-12-23
+ * @author 
+ * @since 2023-03-13
  */
 public interface ISceneProService extends IService<ScenePro> {
 
-    List<ScenePro> listDeleteScene();
-
-
+    List<ScenePro> listDeleteScene(Long userId);
 
 }

+ 5 - 8
4dkankan-task/src/main/java/com/fdkankan/task/service/impl/SceneProServiceImpl.java

@@ -1,10 +1,9 @@
 package com.fdkankan.task.service.impl;
 
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.task.entity.ScenePro;
 import com.fdkankan.task.mapper.ISceneProMapper;
 import com.fdkankan.task.service.ISceneProService;
-import lombok.extern.slf4j.Slf4j;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -14,16 +13,14 @@ import java.util.List;
  * pro场景表 服务实现类
  * </p>
  *
- * @author dengsixing
- * @since 2021-12-23
+ * @author 
+ * @since 2023-03-13
  */
-@Slf4j
 @Service
 public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro> implements ISceneProService {
 
-
     @Override
-    public List<ScenePro> listDeleteScene() {
-        return this.baseMapper.selectDeleteScene();
+    public List<ScenePro> listDeleteScene(Long userId) {
+        return this.baseMapper.selectDeleteScene(userId);
     }
 }