|
@@ -18,6 +18,7 @@ import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.common.util.FileMd5Util;
|
|
|
import com.fdkankan.common.util.FileSizeUtil;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
+import com.fdkankan.dxf.parse.utils.FdJsonToDxfUtil;
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
import com.fdkankan.model.constants.UploadFilePath;
|
|
@@ -672,6 +673,50 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public ResultData saveCadDxf(MultipartFile file, String num) throws Exception {
|
|
|
+
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+
|
|
|
+ String extName = FileUtil.extName(file.getOriginalFilename());
|
|
|
+ if(!"dfx".equals(extName)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_7007.code(), ErrorCode.FAILURE_CODE_7007.formatMessage("dfx"));
|
|
|
+ }
|
|
|
+ String dfxPath = ConstantFilePath.SCENE_USER_PATH_V4 + UUID.randomUUID() + "." + extName;
|
|
|
+ String floorplanUserPath = ConstantFilePath.SCENE_USER_PATH_V4 + UUID.randomUUID() + ".json";
|
|
|
+ file.transferTo(new File(dfxPath));
|
|
|
+ try {
|
|
|
+ String editUserPath = String.format(UploadFilePath.USER_EDIT_PATH, num);
|
|
|
+ FdJsonToDxfUtil.dxfToFdJson(dfxPath, floorplanUserPath);
|
|
|
+ fYunFileService.uploadFile(scenePlusExt.getYunFileBucket(), floorplanUserPath, editUserPath + "floorplan.json");
|
|
|
+ JSONObject houseTypeJson = CreateHouseJsonUtil
|
|
|
+ .createHouseTypeJsonByUser(floorplanUserPath);
|
|
|
+ if(Objects.nonNull(houseTypeJson)) {
|
|
|
+ fYunFileService.uploadFile(scenePlusExt.getYunFileBucket(), houseTypeJson.toJSONString().getBytes(), editUserPath + "houseType.json");
|
|
|
+ }
|
|
|
+
|
|
|
+ SceneEditInfo sceneEditInfoDb = this.getByScenePlusId(scenePlus.getId());
|
|
|
+ this.update(new LambdaUpdateWrapper<SceneEditInfo>()
|
|
|
+ .setSql("version=version+" + 1)
|
|
|
+ .set(SceneEditInfo::getFloorPlanUser, 1)
|
|
|
+ .eq(SceneEditInfo::getId, sceneEditInfoDb.getId()));
|
|
|
+
|
|
|
+ SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfoDb.getId());
|
|
|
+ sceneEditInfoExt.setFloorPlanAngle(0f);
|
|
|
+ sceneEditInfoExt.setFloorPlanCompass(0f);
|
|
|
+ sceneEditInfoExtService.saveOrUpdate(sceneEditInfoExt);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("cad文件转换失败");
|
|
|
+ ResultData.error(ErrorCode.FAILURE_CODE_7013);
|
|
|
+ }finally {
|
|
|
+ FileUtil.del(dfxPath);
|
|
|
+ FileUtil.del(floorplanUserPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public ResultData resetCad(String num) throws IOException {
|
|
|
|
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|