|
@@ -3,6 +3,7 @@ package com.fdkankan.scene.service.impl;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -12,6 +13,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.fdkankan.common.constant.*;
|
|
import com.fdkankan.common.constant.*;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.response.ResultData;
|
|
import com.fdkankan.common.response.ResultData;
|
|
|
|
+import com.fdkankan.common.util.FileUtils;
|
|
import com.fdkankan.fyun.oss.UploadToOssUtil;
|
|
import com.fdkankan.fyun.oss.UploadToOssUtil;
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
@@ -19,6 +21,7 @@ import com.fdkankan.scene.bean.SceneJsonBean;
|
|
import com.fdkankan.scene.entity.SceneEditControls;
|
|
import com.fdkankan.scene.entity.SceneEditControls;
|
|
import com.fdkankan.scene.entity.SceneEditInfo;
|
|
import com.fdkankan.scene.entity.SceneEditInfo;
|
|
import com.fdkankan.scene.entity.ScenePro;
|
|
import com.fdkankan.scene.entity.ScenePro;
|
|
|
|
+import com.fdkankan.scene.entity.SceneProExt;
|
|
import com.fdkankan.scene.factory.FloorLogoHandlerFactory;
|
|
import com.fdkankan.scene.factory.FloorLogoHandlerFactory;
|
|
import com.fdkankan.scene.factory.FloorPlanHandlerFactory;
|
|
import com.fdkankan.scene.factory.FloorPlanHandlerFactory;
|
|
import com.fdkankan.scene.factory.MusicHandlerFactory;
|
|
import com.fdkankan.scene.factory.MusicHandlerFactory;
|
|
@@ -26,6 +29,7 @@ import com.fdkankan.scene.factory.ScreenshotHandlerFactory;
|
|
import com.fdkankan.scene.mapper.ISceneEditInfoMapper;
|
|
import com.fdkankan.scene.mapper.ISceneEditInfoMapper;
|
|
import com.fdkankan.scene.service.ISceneEditControlsService;
|
|
import com.fdkankan.scene.service.ISceneEditControlsService;
|
|
import com.fdkankan.scene.service.ISceneEditInfoService;
|
|
import com.fdkankan.scene.service.ISceneEditInfoService;
|
|
|
|
+import com.fdkankan.scene.service.ISceneProExtService;
|
|
import com.fdkankan.scene.service.ISceneProService;
|
|
import com.fdkankan.scene.service.ISceneProService;
|
|
import com.fdkankan.scene.vo.*;
|
|
import com.fdkankan.scene.vo.*;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
@@ -66,6 +70,8 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
private UploadToOssUtil uploadToOssUtil;
|
|
private UploadToOssUtil uploadToOssUtil;
|
|
@Autowired
|
|
@Autowired
|
|
RedisUtil redisUtil;
|
|
RedisUtil redisUtil;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISceneProExtService sceneProExtService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -266,8 +272,8 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
return new MusicHandlerFactory().getHandler().save(num, fileInfo);
|
|
return new MusicHandlerFactory().getHandler().save(num, fileInfo);
|
|
case FLOOR_LOGO:
|
|
case FLOOR_LOGO:
|
|
return new FloorLogoHandlerFactory().getHandler().save(num, fileInfo);
|
|
return new FloorLogoHandlerFactory().getHandler().save(num, fileInfo);
|
|
- case FLOOR_PLAN:
|
|
|
|
- return new FloorPlanHandlerFactory().getHandler().save(num, fileInfo);
|
|
|
|
|
|
+// case FLOOR_PLAN:
|
|
|
|
+// return new FloorPlanHandlerFactory().getHandler().save(num, fileInfo);
|
|
case SCREENSHOT:
|
|
case SCREENSHOT:
|
|
return new ScreenshotHandlerFactory().getHandler().save(num, fileInfo);
|
|
return new ScreenshotHandlerFactory().getHandler().save(num, fileInfo);
|
|
|
|
|
|
@@ -278,6 +284,76 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ public ResultData saveCad(BaseDataParamVO param) throws Exception {
|
|
|
|
+
|
|
|
|
+ String num = param.getNum();
|
|
|
|
+ ScenePro scenePro = sceneProService.findBySceneNum(num);
|
|
|
|
+ if(Objects.isNull(scenePro))
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
|
+ JSONObject fileInfoJson = JSON.parseObject(param.getData());
|
|
|
|
+ //户型图文件路径
|
|
|
|
+ String cadInfo = fileInfoJson.getString("cadInfo");
|
|
|
|
+ String floorJsonData = fileInfoJson.getString("floorJsonData");
|
|
|
|
+
|
|
|
|
+ String filePaths = fileInfoJson.getString("filePaths");
|
|
|
|
+ cn.hutool.json.JSONArray filePathsArrs = JSONUtil.parseArray(filePaths);
|
|
|
|
+ List<String> filePathsList = filePathsArrs.toList(String.class);
|
|
|
|
+ StringBuilder filePathBuilder = new StringBuilder();
|
|
|
|
+ filePathsList.parallelStream().forEach(path -> {
|
|
|
|
+ filePathBuilder.append(",").append(path);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //写入数据库
|
|
|
|
+ SceneEditInfo sceneEditInfoDb = this.getBySceneProId(scenePro.getId());
|
|
|
|
+ if(Objects.nonNull(sceneEditInfoDb)){
|
|
|
|
+ this.update(new LambdaUpdateWrapper<SceneEditInfo>()
|
|
|
|
+ .setSql("version=version+"+1)
|
|
|
|
+ .set(SceneEditInfo::getFloorPlanPath, filePathBuilder.substring(1))
|
|
|
|
+ .set(SceneEditInfo::getCadInfo, cadInfo)
|
|
|
|
+ .eq(SceneEditInfo::getId, sceneEditInfoDb.getId()));
|
|
|
|
+ }else{
|
|
|
|
+ sceneEditInfoDb = new SceneEditInfo();
|
|
|
|
+ sceneEditInfoDb.setSceneProId(scenePro.getId());
|
|
|
|
+ sceneEditInfoDb.setFloorPlanPath(filePaths);
|
|
|
|
+ sceneEditInfoDb.setCadInfo(cadInfo);
|
|
|
|
+ this.save(sceneEditInfoDb);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //上传houst_floor.json文件
|
|
|
|
+ String localDataPath = String.format(ConstantFilePath.DATABUFFER_FORMAT, num);
|
|
|
|
+ String dataPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
|
|
|
|
+
|
|
|
|
+ // TODO: 2022/1/27 旧版本目录,待删除
|
|
|
|
+ String oldDataPath = String.format(ConstantFilePath.DATA_PATH_FORMAT, num);
|
|
|
|
+
|
|
|
|
+ if(StrUtil.isEmpty(floorJsonData)){
|
|
|
|
+ if(scenePro == null){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
|
+ }
|
|
|
|
+ SceneProExt sceneProExt = sceneProExtService.findBySceneProId(scenePro.getId());
|
|
|
|
+ // TODO: 2022/1/27 老版本数据目录挂在nas,新版本目前流程尚不清楚,先暂时按照老版本写,以后再调整
|
|
|
|
+ FileUtils.copyFile(sceneProExt.getDataSource() + "/results/floor.json", localDataPath + "houst_floor.json", true);
|
|
|
|
+ uploadToOssUtil.upload(localDataPath + "houst_floor.json", dataPath + "houst_floor.json");
|
|
|
|
+
|
|
|
|
+ // TODO: 2022/1/27 老版本上传目录 待删除
|
|
|
|
+ uploadToOssUtil.upload(localDataPath + "houst_floor.json", oldDataPath + "houst_floor.json");
|
|
|
|
+
|
|
|
|
+ String result = FileUtils.readFile(localDataPath + "houst_floor.json");
|
|
|
|
+ return ResultData.ok(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FileUtils.writeFile(localDataPath + "houst_floor.json", floorJsonData);
|
|
|
|
+ uploadToOssUtil.upload(localDataPath + "houst_floor.json", dataPath + "houst_floor.json");
|
|
|
|
+
|
|
|
|
+ // TODO: 2022/1/27 老版本上传目录 待删除
|
|
|
|
+ uploadToOssUtil.upload(localDataPath + "houst_floor.json", oldDataPath + "houst_floor.json");
|
|
|
|
+
|
|
|
|
+ return ResultData.ok();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
public void upgradeVersionById(Long id) {
|
|
public void upgradeVersionById(Long id) {
|
|
this.update(new LambdaUpdateWrapper<SceneEditInfo>()
|
|
this.update(new LambdaUpdateWrapper<SceneEditInfo>()
|
|
.setSql("version=version+" + 1)
|
|
.setSql("version=version+" + 1)
|