|
@@ -0,0 +1,65 @@
|
|
|
+package com.fdkankan.contro.factory.UserEditData;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.fdkankan.contro.entity.SceneEditInfo;
|
|
|
+import com.fdkankan.contro.entity.ScenePlus;
|
|
|
+import com.fdkankan.contro.service.ISceneEditInfoService;
|
|
|
+import com.fdkankan.contro.service.IScenePlusService;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.model.constants.UploadFilePath;
|
|
|
+import com.fdkankan.redis.constant.RedisKey;
|
|
|
+import com.fdkankan.redis.util.RedisUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 初始化空间模型
|
|
|
+ */
|
|
|
+@Component("boxModelHandler")
|
|
|
+public class BoxModelHandler implements UserEditDataHandler {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneEditInfoService sceneEditInfoService;
|
|
|
+ @Autowired
|
|
|
+ private FYunFileServiceInterface fYunFileService;
|
|
|
+ @Autowired
|
|
|
+ private RedisUtil redisUtil;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void init(String num, Map<String, Object> params) {
|
|
|
+ String modelEditPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "boxModels";
|
|
|
+ String modelViewPath = String.format(UploadFilePath.USER_VIEW_PATH, num) + "boxModels";
|
|
|
+ String sceneJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json";
|
|
|
+
|
|
|
+ //修改数据库,将boxModels字段置为空
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
+ SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
|
|
|
+ sceneEditInfoService.update(new LambdaUpdateWrapper<SceneEditInfo>().set(SceneEditInfo::getBoxModels, null).eq(SceneEditInfo::getId, sceneEditInfo.getId()));
|
|
|
+
|
|
|
+ //更新scene.json
|
|
|
+ if(fYunFileService.fileExist(sceneJsonPath)){
|
|
|
+ String sceneJsonStr = fYunFileService.getFileContent(sceneJsonPath);
|
|
|
+ JSONObject sceneJson = JSON.parseObject(sceneJsonStr);
|
|
|
+ sceneJson.remove("boxModels");
|
|
|
+ sceneJsonStr = sceneJson.toJSONString();
|
|
|
+ fYunFileService.uploadFile(sceneJsonStr.getBytes(StandardCharsets.UTF_8), sceneJsonPath);
|
|
|
+ //scenejson写入缓存
|
|
|
+ redisUtil.set(String.format(RedisKey.SCENE_JSON, num), sceneJsonStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除oss资源
|
|
|
+ if(fYunFileService.fileExist(modelEditPath)){
|
|
|
+ fYunFileService.deleteFolder(modelEditPath);
|
|
|
+ }
|
|
|
+ if(fYunFileService.fileExist(modelViewPath)){
|
|
|
+ fYunFileService.deleteFolder(modelViewPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|