|
@@ -2,6 +2,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.net.multipart.UploadFile;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -663,6 +664,39 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public ResultData renameCad(RenameCadParamVO param) throws IOException {
|
|
|
|
+
|
|
|
|
+ String key = String.format(UploadFilePath.DATA_VIEW_PATH, param.getNum()) + "floorplan_cad.json";
|
|
|
|
+ String floorplanCadJson = uploadToOssUtil.getObjectContent(this.bucket, key);
|
|
|
|
+ if(StrUtil.isEmpty(floorplanCadJson)){
|
|
|
|
+ return ResultData.ok();
|
|
|
|
+ }
|
|
|
|
+ Map<Integer, String> renameMap = new HashMap<>();
|
|
|
|
+ param.getFloors().stream().forEach(floor->{
|
|
|
|
+ renameMap.put(floor.getSubgroup(), floor.getName());
|
|
|
|
+ });
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(floorplanCadJson);
|
|
|
|
+ if(Objects.isNull(jsonObject)){
|
|
|
|
+ return ResultData.ok();
|
|
|
|
+ }
|
|
|
|
+ JSONArray floorArr = jsonObject.getJSONArray("floors");
|
|
|
|
+ if(CollUtil.isEmpty(floorArr)){
|
|
|
|
+ return ResultData.ok();
|
|
|
|
+ }
|
|
|
|
+ for (Object o : floorArr) {
|
|
|
|
+ JSONObject item = (JSONObject)o;
|
|
|
|
+ int subgroup = item.getIntValue("subgroup");
|
|
|
|
+ String name = renameMap.get(subgroup);
|
|
|
|
+ if(StrUtil.isEmpty(name)){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ item.put("name", name);
|
|
|
|
+ }
|
|
|
|
+ uploadToOssUtil.upload(jsonObject.toJSONString().getBytes(), key);
|
|
|
|
+ return ResultData.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
private JSONObject updateFloorName(String sourceFloors, String targeFloors){
|
|
private JSONObject updateFloorName(String sourceFloors, String targeFloors){
|
|
JSONArray sourceFloorsJson = JSON.parseArray(sourceFloors);
|
|
JSONArray sourceFloorsJson = JSON.parseArray(sourceFloors);
|
|
JSONObject targeFloorsJson = JSONObject.parseObject(targeFloors);
|
|
JSONObject targeFloorsJson = JSONObject.parseObject(targeFloors);
|