|
@@ -3,17 +3,16 @@ 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.ObjUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
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.fdkankan.common.util.FileUtils;
|
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.fdkankan.common.constant.CommonStatus;
|
|
import com.fdkankan.common.constant.CommonStatus;
|
|
import com.fdkankan.common.constant.PayStatus;
|
|
import com.fdkankan.common.constant.PayStatus;
|
|
-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;
|
|
@@ -21,10 +20,8 @@ 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;
|
|
-import com.fdkankan.contro.service.ICommonService;
|
|
|
|
import com.fdkankan.contro.service.*;
|
|
import com.fdkankan.contro.service.*;
|
|
import com.fdkankan.contro.vo.SceneEditControlsVO;
|
|
import com.fdkankan.contro.vo.SceneEditControlsVO;
|
|
-import com.fdkankan.contro.vo.ScenePlusVO;
|
|
|
|
import com.fdkankan.fyun.config.FYunFileConfig;
|
|
import com.fdkankan.fyun.config.FYunFileConfig;
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
@@ -42,16 +39,9 @@ import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-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.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.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -124,6 +114,17 @@ public class CommonServiceImpl implements ICommonService {
|
|
@Autowired
|
|
@Autowired
|
|
private SceneShapeEnumService sceneShapeEnumService;
|
|
private SceneShapeEnumService sceneShapeEnumService;
|
|
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+ String infoJsonPath = "D:\\test\\info.json";
|
|
|
|
+ String s = FileUtil.readUtf8String(infoJsonPath);
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(s);
|
|
|
|
+ JSONArray infoArr = jsonObject.getJSONArray("floors");
|
|
|
|
+ for (Object o : infoArr) {
|
|
|
|
+ JSONObject item = (JSONObject)o;
|
|
|
|
+ System.out.println(item.getInteger("subgroup"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void uploadBuildResultData(String num, String dataSource, String version) {
|
|
public void uploadBuildResultData(String num, String dataSource, String version) {
|
|
|
|
|
|
@@ -589,27 +590,53 @@ public class CommonServiceImpl implements ICommonService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public boolean detFloorPlanAi(String num, String path, boolean detFloorplan) throws IOException {
|
|
|
|
- String workDir = path + "/detFloorplan/";
|
|
|
|
- String detectPath = workDir + "detect.json";
|
|
|
|
|
|
+ public boolean detFloorPlanAi(String num, String path, LinkedHashMap<Integer, Boolean> detFloorplan) throws IOException {
|
|
|
|
+
|
|
try {
|
|
try {
|
|
- if (!detFloorplan) {
|
|
|
|
- return false;
|
|
|
|
|
|
+ String aiJsonKey = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "floorplan/ai.json";
|
|
|
|
+ //先清空历史数据,因为数据格式改动很多个版本,已经无法按照规律进行过滤删除,所以这里先删除历史数据,而后再根据算法生成去插入数据
|
|
|
|
+ sceneMarkShapeService.remove(new LambdaQueryWrapper<SceneMarkShape>().eq(SceneMarkShape::getNum, num).eq(SceneMarkShape::getType, DetectType.PLAN.getCode()));
|
|
|
|
+ if(fYunFileService.fileExist(aiJsonKey)){
|
|
|
|
+ fYunFileService.deleteFile(aiJsonKey);
|
|
}
|
|
}
|
|
- SceneMarkShape sceneMarkShape = sceneMarkShapeService.readDetectJson(detectPath);
|
|
|
|
- if (ObjectUtil.isNull(sceneMarkShape)){
|
|
|
|
|
|
+ if(CollUtil.isEmpty(detFloorplan)){
|
|
return false;
|
|
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 {
|
|
|
|
|
|
+ boolean hasFloorplanAi = false;
|
|
|
|
+ String workDir = path + "/detFloorplan/";
|
|
|
|
+ for (Integer subgroup : detFloorplan.keySet()) {
|
|
|
|
+ Boolean yes = detFloorplan.get(subgroup);
|
|
|
|
+ SceneMarkShape sceneMarkShape = null;
|
|
|
|
+ if(yes){
|
|
|
|
+ String detectPath = workDir + subgroup + "/detect.json";
|
|
|
|
+ sceneMarkShape = sceneMarkShapeService.readDetectJson(detectPath);
|
|
|
|
+ }
|
|
|
|
+ if (ObjUtil.isNull(sceneMarkShape)){
|
|
|
|
+ sceneMarkShape = new SceneMarkShape();
|
|
|
|
+ String infoJsonPath = path + "/results/floorplan/info.json";
|
|
|
|
+ JSONObject infoObj = JSON.parseObject(FileUtil.readUtf8String(infoJsonPath));
|
|
|
|
+ JSONArray floors = infoObj.getJSONArray("floors");
|
|
|
|
+ for (Object floor : floors) {
|
|
|
|
+ JSONObject floorObj = (JSONObject)floor;
|
|
|
|
+ Integer group = floorObj.getInteger("subgroup");
|
|
|
|
+ if(!subgroup.equals(group)){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ JSONObject resolution = floorObj.getJSONObject("resolution");
|
|
|
|
+ sceneMarkShape.setImageWidth(resolution.getInteger("width"));
|
|
|
|
+ sceneMarkShape.setImageHeight(resolution.getInteger("height"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(Objects.isNull(sceneMarkShape.getShapes())){
|
|
|
|
+ sceneMarkShape.setShapes(new ArrayList<>());
|
|
|
|
+ }
|
|
|
|
+ sceneMarkShape.setNum(num);
|
|
sceneMarkShape.setCreateTime(new Date());
|
|
sceneMarkShape.setCreateTime(new Date());
|
|
sceneMarkShape.setType(DetectType.PLAN.getCode());
|
|
sceneMarkShape.setType(DetectType.PLAN.getCode());
|
|
sceneMarkShapeService.save(sceneMarkShape);
|
|
sceneMarkShapeService.save(sceneMarkShape);
|
|
|
|
+ if(CollUtil.isNotEmpty(sceneMarkShape.getShapes())){
|
|
|
|
+ hasFloorplanAi = true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
List<SceneMarkShape> sceneMarkShapes = sceneMarkShapeService.findByNumAndType(num, DetectType.PLAN.getCode());
|
|
List<SceneMarkShape> sceneMarkShapes = sceneMarkShapeService.findByNumAndType(num, DetectType.PLAN.getCode());
|
|
@@ -624,14 +651,9 @@ public class CommonServiceImpl implements ICommonService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- 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;
|
|
|
|
- }
|
|
|
|
|
|
+ fYunFileService.uploadFile(JSON.toJSONString(sceneMarkShapes).getBytes(StandardCharsets.UTF_8), aiJsonKey);
|
|
|
|
+
|
|
|
|
+ return hasFloorplanAi;
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
log.error("平面图ai识别处理报错", e);
|
|
log.error("平面图ai识别处理报错", e);
|
|
return false;
|
|
return false;
|