|
@@ -0,0 +1,98 @@
|
|
|
+package com.fdkankan.job.repair;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.job.entity.ScenePlus;
|
|
|
+import com.fdkankan.job.entity.ScenePlusExt;
|
|
|
+import com.fdkankan.job.entity.ScenePro;
|
|
|
+import com.fdkankan.job.service.IHouseTypeService;
|
|
|
+import com.fdkankan.job.service.IScenePlusExtService;
|
|
|
+import com.fdkankan.job.service.IScenePlusService;
|
|
|
+import com.fdkankan.job.service.ISceneProService;
|
|
|
+import com.fdkankan.model.constants.UploadFilePath;
|
|
|
+import com.xxl.job.core.context.XxlJobHelper;
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 修复housetype.json文件数据
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author dengsixing
|
|
|
+ * @since 2022/12/16
|
|
|
+ **/
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class UploadCacheImagesHandler {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IHouseTypeService houseTypeService;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusExtService scenePlusExtService;
|
|
|
+ @Resource
|
|
|
+ private FYunFileServiceInterface fYunFileService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneProService sceneProService;
|
|
|
+
|
|
|
+ @XxlJob("uploadCacheImagesHandler")
|
|
|
+ private void repairModelKind(){
|
|
|
+ XxlJobHelper.log("uploadCacheImagesHandler start.....");
|
|
|
+
|
|
|
+ List<String> numList = null;
|
|
|
+ String nums = XxlJobHelper.getJobParam();
|
|
|
+ if(StrUtil.isNotEmpty(nums)){
|
|
|
+ numList = Arrays.asList(nums.split(","));
|
|
|
+ }
|
|
|
+
|
|
|
+ Long pageSize = 10L;
|
|
|
+ Long pageNum = 1L;
|
|
|
+ boolean hasNext = false;
|
|
|
+ do {
|
|
|
+ Page<ScenePro> sceneProPage = sceneProService.listSceneProAll(pageNum, pageSize, numList);
|
|
|
+ List<ScenePro> records = sceneProPage.getRecords();
|
|
|
+ if(CollUtil.isNotEmpty(records)){
|
|
|
+ records.parallelStream().forEach(v->{
|
|
|
+ String dataSource = v.getDataSource();
|
|
|
+ if(FileUtil.exist(dataSource)){
|
|
|
+ //上传cache/images
|
|
|
+ String path = dataSource + "/caches/images/";
|
|
|
+
|
|
|
+ String[] list = new File(path).list();
|
|
|
+ String ossBasePath = "scene_result_data/" + v.getNum() + "/caches/images/";
|
|
|
+// if(list != null && list.length > 0){
|
|
|
+// Arrays.stream(list).forEach(k-> fYunFileService.uploadFile(path + v, ossBasePath + v));
|
|
|
+// }
|
|
|
+
|
|
|
+ //重命名dataSource(因为不确定这个目录的文件是否还有其他用处,所以这里暂时重命名,运行一段时间后再进行删除处理)
|
|
|
+// FileUtil.move(new File(dataSource), new File(dataSource + "_bak"), true);
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ hasNext = sceneProPage.hasNext();
|
|
|
+ }while (hasNext);
|
|
|
+
|
|
|
+
|
|
|
+ XxlJobHelper.log("uploadCacheImagesHandler end.....");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|