|
@@ -3,6 +3,7 @@ package com.fdkankan.contro.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.io.FileUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -16,6 +17,7 @@ import com.fdkankan.common.constant.SceneStatus;
|
|
import com.fdkankan.common.constant.SpaceType;
|
|
import com.fdkankan.common.constant.SpaceType;
|
|
import com.fdkankan.common.util.FileUtils;
|
|
import com.fdkankan.common.util.FileUtils;
|
|
import com.fdkankan.contro.bean.SceneJsonBean;
|
|
import com.fdkankan.contro.bean.SceneJsonBean;
|
|
|
|
+import com.fdkankan.contro.controller.DetectType;
|
|
import com.fdkankan.contro.entity.*;
|
|
import com.fdkankan.contro.entity.*;
|
|
import com.fdkankan.contro.factory.UserEditData.UserEditDataHandler;
|
|
import com.fdkankan.contro.factory.UserEditData.UserEditDataHandler;
|
|
import com.fdkankan.contro.factory.UserEditData.UserEditDataHandlerFactory;
|
|
import com.fdkankan.contro.factory.UserEditData.UserEditDataHandlerFactory;
|
|
@@ -43,6 +45,7 @@ import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -116,6 +119,10 @@ public class CommonServiceImpl implements ICommonService {
|
|
private RabbitMqProducer rabbitMqProducer;
|
|
private RabbitMqProducer rabbitMqProducer;
|
|
@Autowired
|
|
@Autowired
|
|
private ISceneInfoSyncMqConfigService sceneInfoSyncMqConfigService;
|
|
private ISceneInfoSyncMqConfigService sceneInfoSyncMqConfigService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISceneMarkShapeService sceneMarkShapeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SceneShapeEnumService sceneShapeEnumService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void uploadBuildResultData(String num, String dataSource, String version) {
|
|
public void uploadBuildResultData(String num, String dataSource, String version) {
|
|
@@ -569,16 +576,72 @@ public class CommonServiceImpl implements ICommonService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void uploadFloorplanAi(String num, String path) {
|
|
|
|
|
|
+ public void uploadFloorplanAi(String num, String path) throws IOException {
|
|
String floorplanPath = path + "/results/floorplan/";
|
|
String floorplanPath = path + "/results/floorplan/";
|
|
List<File> files = FileUtil.loopFiles(floorplanPath);
|
|
List<File> files = FileUtil.loopFiles(floorplanPath);
|
|
- if(CollUtil.isEmpty(files)){
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
String ossPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "floorplan/";
|
|
String ossPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "floorplan/";
|
|
- for (File file : files) {
|
|
|
|
- fYunFileService.uploadFile(file.getAbsolutePath(), file.getAbsolutePath().replace(floorplanPath, ossPath));
|
|
|
|
|
|
+ if(CollUtil.isNotEmpty(files)){
|
|
|
|
+ for (File file : files) {
|
|
|
|
+ fYunFileService.uploadFile(file.getAbsolutePath(), file.getAbsolutePath().replace(floorplanPath, ossPath));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean detFloorPlanAi(String num, String path, boolean detFloorplan) throws IOException {
|
|
|
|
+ String workDir = path + "/detFloorplan/";
|
|
|
|
+ String detectPath = workDir + "detect.json";
|
|
|
|
+ try {
|
|
|
|
+ if (detFloorplan) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ SceneMarkShape sceneMarkShape = sceneMarkShapeService.readDetectJson(detectPath);
|
|
|
|
+ if (ObjectUtil.isNull(sceneMarkShape)){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ sceneMarkShape.setNum(num);
|
|
|
|
+ SceneMarkShape shape = sceneMarkShapeService.findByNumAndImagePathAndType(num, sceneMarkShape.getImagePath(), DetectType.PLAN.getCode());
|
|
|
|
+ if (ObjectUtil.isNotNull(shape)){
|
|
|
|
+ sceneMarkShape.setId(shape.getId());
|
|
|
|
+ sceneMarkShape.setUpdateTime(new Date());
|
|
|
|
+ sceneMarkShapeService.updateById(sceneMarkShape);
|
|
|
|
+ }else {
|
|
|
|
+ sceneMarkShape.setCreateTime(new Date());
|
|
|
|
+ sceneMarkShape.setType(DetectType.PLAN.getCode());
|
|
|
|
+ sceneMarkShapeService.save(sceneMarkShape);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<SceneMarkShape> sceneMarkShapes = sceneMarkShapeService.findByNumAndType(num, DetectType.PLAN.getCode());
|
|
|
|
+ for (SceneMarkShape ms : sceneMarkShapes) {
|
|
|
|
+ if (ObjectUtil.isNotEmpty(ms.getShapes())){
|
|
|
|
+ for (JSONObject s : ms.getShapes()) {
|
|
|
|
+ String category = s.getString("category");
|
|
|
|
+ SceneShapeEnum sceneShapeEnum = sceneShapeEnumService.findByClassName(category);
|
|
|
|
+ if (ObjectUtil.isNotNull(sceneShapeEnum)){
|
|
|
|
+ s.put("name",sceneShapeEnum.getName());
|
|
|
|
+ }
|
|
|
|
+ if (category.contains("Tag_")){
|
|
|
|
+ s.put("category","Tag");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ String aiJsonKey = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "floorplan/ai.json";
|
|
|
|
+ if(CollUtil.isNotEmpty(sceneMarkShapes)){
|
|
|
|
+ fYunFileService.uploadFile(JSON.toJSONString(sceneMarkShapes).getBytes(StandardCharsets.UTF_8), aiJsonKey);
|
|
|
|
+ return true;
|
|
|
|
+ }else{
|
|
|
|
+ fYunFileService.deleteFile(aiJsonKey);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.error("平面图ai识别处理报错", e);
|
|
|
|
+ return false;
|
|
|
|
+ }finally {
|
|
|
|
+ FileUtil.del(workDir);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|