|
@@ -3,26 +3,24 @@ package com.fdkankan.contro.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.fdkankan.common.constant.CommonStatus;
|
|
|
import com.fdkankan.common.constant.PayStatus;
|
|
|
-import com.fdkankan.common.constant.SceneStatus;
|
|
|
import com.fdkankan.common.constant.SpaceType;
|
|
|
-import com.fdkankan.common.util.FileUtils;
|
|
|
import com.fdkankan.contro.bean.SceneJsonBean;
|
|
|
+import com.fdkankan.contro.constant.DetectType;
|
|
|
import com.fdkankan.contro.entity.*;
|
|
|
import com.fdkankan.contro.factory.UserEditData.UserEditDataHandler;
|
|
|
import com.fdkankan.contro.factory.UserEditData.UserEditDataHandlerFactory;
|
|
|
import com.fdkankan.contro.service.ICommonService;
|
|
|
import com.fdkankan.contro.service.*;
|
|
|
import com.fdkankan.contro.vo.SceneEditControlsVO;
|
|
|
-import com.fdkankan.contro.vo.ScenePlusVO;
|
|
|
import com.fdkankan.fyun.config.FYunFileConfig;
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
@@ -42,12 +40,13 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
-import java.util.Objects;
|
|
|
import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
@@ -107,6 +106,10 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
private RabbitMqProducer rabbitMqProducer;
|
|
|
@Autowired
|
|
|
private ISceneInfoSyncMqConfigService sceneInfoSyncMqConfigService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneMarkShapeService sceneMarkShapeService;
|
|
|
+ @Autowired
|
|
|
+ private SceneShapeEnumService sceneShapeEnumService;
|
|
|
|
|
|
@Override
|
|
|
public void uploadBuildResultData(String num, String dataSource, String version) {
|
|
@@ -516,4 +519,73 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
rabbitMqProducer.sendByWorkQueue(config.getQueueName(), content);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void uploadFloorplanAi(String num, String path) throws IOException {
|
|
|
+ String floorplanPath = path + "/results/floorplan/";
|
|
|
+ List<File> files = FileUtil.loopFiles(floorplanPath);
|
|
|
+ String ossPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "floorplan/";
|
|
|
+ if(CollUtil.isNotEmpty(files)){
|
|
|
+ for (File file : files) {
|
|
|
+ fYunFileServiceInterface.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)){
|
|
|
+ fYunFileServiceInterface.uploadFile(JSON.toJSONString(sceneMarkShapes).getBytes(StandardCharsets.UTF_8), aiJsonKey);
|
|
|
+ return true;
|
|
|
+ }else{
|
|
|
+ fYunFileServiceInterface.deleteFile(aiJsonKey);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("平面图ai识别处理报错", e);
|
|
|
+ return false;
|
|
|
+ }finally {
|
|
|
+// FileUtil.del(workDir);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|