|
@@ -0,0 +1,111 @@
|
|
|
+package com.fdkankan.job.job;
|
|
|
+
|
|
|
+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.fdkankan.common.util.FileUtils;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.job.entity.ScenePlus;
|
|
|
+import com.fdkankan.job.entity.ScenePlusExt;
|
|
|
+import com.fdkankan.job.service.IScenePlusExtService;
|
|
|
+import com.fdkankan.job.service.IScenePlusService;
|
|
|
+import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
+import com.fdkankan.model.constants.UploadFilePath;
|
|
|
+import com.fdkankan.model.utils.FloorPlanUserUtil;
|
|
|
+import com.fdkankan.model.utils.SceneUtil;
|
|
|
+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 java.io.File;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 根据floorplan_cad.json生成floorpan.json
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author dengsixing
|
|
|
+ * @since 2022/12/16
|
|
|
+ **/
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class FloorpanHandler {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusExtService scenePlusExtService;
|
|
|
+ @Autowired
|
|
|
+ private FYunFileServiceInterface fYunFileService;
|
|
|
+
|
|
|
+ @XxlJob("createFloorpan")
|
|
|
+ private void repairModelKind(){
|
|
|
+ XxlJobHelper.log("createFloorpan start.....");
|
|
|
+
|
|
|
+ List<String> faildNumList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<String> numList = null;
|
|
|
+ String nums = XxlJobHelper.getJobParam();
|
|
|
+ if(StrUtil.isNotEmpty(nums)){
|
|
|
+ numList = Arrays.asList(nums.split(","));
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaQueryWrapper<ScenePlus> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ if(CollUtil.isNotEmpty(numList)){
|
|
|
+ queryWrapper.in(ScenePlus::getNum, numList);
|
|
|
+ }
|
|
|
+ List<ScenePlus> list = scenePlusService.list(queryWrapper);
|
|
|
+
|
|
|
+ if(CollUtil.isNotEmpty(list)){
|
|
|
+ list.parallelStream().forEach(plus->{
|
|
|
+ String num = plus.getNum();
|
|
|
+ try {
|
|
|
+
|
|
|
+ //生成原始
|
|
|
+ String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
|
|
|
+ String floorplanCadPath = String.format(ConstantFilePath.SCENE_DATA_PATH_V4, num) + "floorplan_cad.json";
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(plus.getId());
|
|
|
+ String dataSource = scenePlusExt.getDataSource();
|
|
|
+ fYunFileService.downloadFile(dataViewPath + "floorplan_cad.json", floorplanCadPath);
|
|
|
+ if (!new File(floorplanCadPath).exists()) {
|
|
|
+ throw new Exception("生成floorplan.json失败,cadPath:" + floorplanCadPath);
|
|
|
+ }
|
|
|
+ JSONObject json = FloorPlanUserUtil.createFloorPlanUserJson(floorplanCadPath);
|
|
|
+ if(Objects.isNull(json)){
|
|
|
+ throw new Exception("生成floorplan.json失败,cadPath:" + floorplanCadPath);
|
|
|
+ }
|
|
|
+ String floorplanJsonPath = dataViewPath + "floorplan.json";
|
|
|
+ fYunFileService.uploadFile(json.toJSONString().getBytes(), floorplanJsonPath);
|
|
|
+
|
|
|
+ //生成用户编辑
|
|
|
+ String editFloorplanUserPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "floorplan_user.json";
|
|
|
+ String targetEditFloorplanUserPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "floorplan.json";
|
|
|
+ if(fYunFileService.fileExist(editFloorplanUserPath)){
|
|
|
+ fYunFileService.copyFileInBucket(editFloorplanUserPath, targetEditFloorplanUserPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ String viewFloorplanUserPath = String.format(UploadFilePath.USER_VIEW_PATH, num) + "floorplan_user.json";
|
|
|
+ String targetViewFloorplanUserPath = String.format(UploadFilePath.USER_VIEW_PATH, num) + "floorplan.json";
|
|
|
+ if(fYunFileService.fileExist(viewFloorplanUserPath)){
|
|
|
+ fYunFileService.copyFileInBucket(viewFloorplanUserPath, targetViewFloorplanUserPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("生成floorplan.json失败" + num, e);
|
|
|
+ faildNumList.add(plus.getNum());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ XxlJobHelper.log("createFloorpan end.....");
|
|
|
+ XxlJobHelper.log("生成floorplan.json失败:" + JSON.toJSONString(faildNumList));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|