|
@@ -1,75 +1,85 @@
|
|
|
-//package com.fdkankan.scene.init;
|
|
|
-//
|
|
|
-//import cn.hutool.core.collection.CollUtil;
|
|
|
-//import com.alibaba.fastjson.JSON;
|
|
|
-//import com.alibaba.fastjson.JSONObject;
|
|
|
-//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-//import com.fdkankan.download.bean.DownLoadTaskBean;
|
|
|
-//import com.fdkankan.redis.constant.RedisKey;
|
|
|
-//import com.fdkankan.redis.constant.RedisLockKey;
|
|
|
-//import com.fdkankan.redis.util.RedisLockUtil;
|
|
|
-//import com.fdkankan.redis.util.RedisUtil;
|
|
|
-//import com.fdkankan.scene.entity.ScenePlus;
|
|
|
-//import com.fdkankan.scene.entity.ScenePlusExt;
|
|
|
-//import com.fdkankan.scene.service.IScenePlusExtService;
|
|
|
-//import com.fdkankan.scene.service.IScenePlusService;
|
|
|
-//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-//import org.springframework.boot.CommandLineRunner;
|
|
|
-//import org.springframework.data.redis.core.RedisTemplate;
|
|
|
-//import org.springframework.stereotype.Component;
|
|
|
-//
|
|
|
-//import java.util.List;
|
|
|
-//import java.util.stream.Collectors;
|
|
|
-//
|
|
|
-///**
|
|
|
-// * <p>
|
|
|
-// * 应用启动校验是否有下载任务正在进行,如有过就重新入队头,从新下载
|
|
|
-// * </p>
|
|
|
-// *
|
|
|
-// * @author dengsixing
|
|
|
-// * @since 2022/2/22
|
|
|
-// **/
|
|
|
-//@Component
|
|
|
-//public class InitDataHandler implements CommandLineRunner {
|
|
|
-//
|
|
|
-// @Autowired
|
|
|
-// RedisUtil redisUtil;
|
|
|
-// @Autowired
|
|
|
-// RedisTemplate redisTemplate;
|
|
|
-// @Autowired
|
|
|
-// RedisLockUtil redisLockUtil;
|
|
|
-// @Autowired
|
|
|
-// private IScenePlusService scenePlusService;
|
|
|
-// @Autowired
|
|
|
-// private IScenePlusExtService scenePlusExtService;
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run(String... args) throws Exception {
|
|
|
-//
|
|
|
-// List<ScenePlusExt> scenePlusExtList = scenePlusExtService.list(new LambdaQueryWrapper<ScenePlusExt>().like(ScenePlusExt::getVideos, "/oss/"));
|
|
|
-// if(CollUtil.isNotEmpty(scenePlusExtList)){
|
|
|
-// scenePlusExtList.stream().forEach(ext -> {
|
|
|
-// ScenePlus scenePlus = scenePlusService.getById(ext.getPlusId());
|
|
|
-//
|
|
|
-// JSONObject jsonObject = JSON.parseObject(ext.getVideos());
|
|
|
-// String upPath = jsonObject.getString("upPath");
|
|
|
-// jsonObject.put("upPath", upPath.replace("/oss/", ""));
|
|
|
-//
|
|
|
-// String key = String.format(RedisKey.SCENE_JSON, scenePlus.getNum());
|
|
|
-// String sceneJsonStr = redisUtil.get(key);
|
|
|
-// JSONObject sceneJsonObj = JSON.parseObject(sceneJsonStr);
|
|
|
-// sceneJsonObj.getJSONObject()
|
|
|
-//
|
|
|
-//
|
|
|
-// });
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//}
|
|
|
+package com.fdkankan.scene.init;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.model.constants.UploadFilePath;
|
|
|
+import com.fdkankan.redis.constant.RedisKey;
|
|
|
+import com.fdkankan.redis.util.RedisLockUtil;
|
|
|
+import com.fdkankan.redis.util.RedisUtil;
|
|
|
+import com.fdkankan.scene.entity.ScenePlus;
|
|
|
+import com.fdkankan.scene.entity.ScenePlusExt;
|
|
|
+import com.fdkankan.scene.service.IScenePlusExtService;
|
|
|
+import com.fdkankan.scene.service.IScenePlusService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.CommandLineRunner;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 应用启动校验是否有下载任务正在进行,如有过就重新入队头,从新下载
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author dengsixing
|
|
|
+ * @since 2022/2/22
|
|
|
+ **/
|
|
|
+@Component
|
|
|
+public class InitDataHandler implements CommandLineRunner {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ RedisUtil redisUtil;
|
|
|
+ @Autowired
|
|
|
+ RedisTemplate redisTemplate;
|
|
|
+ @Autowired
|
|
|
+ RedisLockUtil redisLockUtil;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusExtService scenePlusExtService;
|
|
|
+ @Resource
|
|
|
+ private FYunFileServiceInterface fYunFileService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void run(String... args) throws Exception {
|
|
|
+
|
|
|
+ List<ScenePlusExt> scenePlusExtList = scenePlusExtService.list(new LambdaQueryWrapper<ScenePlusExt>().like(ScenePlusExt::getVideos, "/oss/"));
|
|
|
+ if(CollUtil.isNotEmpty(scenePlusExtList)){
|
|
|
+ scenePlusExtList.stream().forEach(ext -> {
|
|
|
+ ScenePlus scenePlus = scenePlusService.getById(ext.getPlusId());
|
|
|
+
|
|
|
+ //修改数据库
|
|
|
+ JSONObject jsonObject = JSON.parseObject(ext.getVideos());
|
|
|
+ String upPath = jsonObject.getString("upPath");
|
|
|
+ jsonObject.put("upPath", upPath.replace("/oss/", ""));
|
|
|
+ ext.setVideos(jsonObject.toJSONString());
|
|
|
+ scenePlusExtService.updateById(ext);
|
|
|
+
|
|
|
+ //修改redis缓存
|
|
|
+ String key = String.format(RedisKey.SCENE_JSON, scenePlus.getNum());
|
|
|
+ String sceneJsonStr = redisUtil.get(key);
|
|
|
+ JSONObject sceneJsonObj = JSON.parseObject(sceneJsonStr);
|
|
|
+ sceneJsonObj.put("videos", jsonObject.toJSONString());
|
|
|
+ redisUtil.set(key, sceneJsonObj.toJSONString());
|
|
|
+
|
|
|
+ //修改scene.json
|
|
|
+ String sceneJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH, scenePlus.getNum()).concat("scene.json");
|
|
|
+ fYunFileService.uploadFile(sceneJsonObj.toJSONString().getBytes(StandardCharsets.UTF_8), sceneJsonPath);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|