|
@@ -3,9 +3,13 @@ package com.fdkankan.contro.service.impl;
|
|
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.core.util.ObjectUtil;
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.fdkankan.common.constant.CommonStatus;
|
|
import com.fdkankan.contro.constant.DetectType;
|
|
import com.fdkankan.contro.constant.DetectType;
|
|
import com.fdkankan.contro.entity.SceneMarkShape;
|
|
import com.fdkankan.contro.entity.SceneMarkShape;
|
|
|
|
+import com.fdkankan.contro.entity.ScenePlus;
|
|
|
|
+import com.fdkankan.contro.entity.ScenePlusExt;
|
|
import com.fdkankan.contro.entity.SceneShapeEnum;
|
|
import com.fdkankan.contro.entity.SceneShapeEnum;
|
|
import com.fdkankan.contro.service.*;
|
|
import com.fdkankan.contro.service.*;
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
@@ -18,8 +22,10 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service
|
|
@Service
|
|
@@ -37,7 +43,7 @@ public class AiServiceImpl implements IAiService {
|
|
private ISceneMarkShapeService sceneMarkShapeService;
|
|
private ISceneMarkShapeService sceneMarkShapeService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void detectScenePano(String num, String path) {
|
|
|
|
|
|
+ public void detectScenePano(ScenePlus scenePlus, ScenePlusExt scenePlusExt, String path) {
|
|
|
|
|
|
String resultsPath = path + File.separator + "results" + File.separator;
|
|
String resultsPath = path + File.separator + "results" + File.separator;
|
|
String highPath = resultsPath + "high" + File.separator;
|
|
String highPath = resultsPath + "high" + File.separator;
|
|
@@ -60,8 +66,8 @@ public class AiServiceImpl implements IAiService {
|
|
}
|
|
}
|
|
SceneMarkShape sceneMarkShape = readDetectJson(detectPath);
|
|
SceneMarkShape sceneMarkShape = readDetectJson(detectPath);
|
|
if (ObjectUtil.isNotNull(sceneMarkShape)){
|
|
if (ObjectUtil.isNotNull(sceneMarkShape)){
|
|
- sceneMarkShape.setNum(num);
|
|
|
|
- SceneMarkShape shape = sceneMarkShapeService.findByNumAndImagePathAndType(num, sceneMarkShape.getImagePath(), DetectType.PANO.getCode());
|
|
|
|
|
|
+ sceneMarkShape.setNum(scenePlus.getNum());
|
|
|
|
+ SceneMarkShape shape = sceneMarkShapeService.findByNumAndImagePathAndType(scenePlus.getNum(), sceneMarkShape.getImagePath(), DetectType.PANO.getCode());
|
|
if (ObjectUtil.isNotNull(shape)){
|
|
if (ObjectUtil.isNotNull(shape)){
|
|
sceneMarkShape.setId(shape.getId());
|
|
sceneMarkShape.setId(shape.getId());
|
|
sceneMarkShape.setUpdateTime(new Date());
|
|
sceneMarkShape.setUpdateTime(new Date());
|
|
@@ -75,7 +81,7 @@ public class AiServiceImpl implements IAiService {
|
|
if (FileUtil.exist(cutImagesPath)){
|
|
if (FileUtil.exist(cutImagesPath)){
|
|
//上传这个文件夹所有的文件
|
|
//上传这个文件夹所有的文件
|
|
List<File> files = FileUtil.loopFiles(cutImagesPath);
|
|
List<File> files = FileUtil.loopFiles(cutImagesPath);
|
|
- String keyPath = String.format(UploadFilePath.IMG_VIEW_PATH, num) + "cut_images/";
|
|
|
|
|
|
+ String keyPath = String.format(UploadFilePath.IMG_VIEW_PATH, scenePlus.getNum()) + "cut_images/";
|
|
files.forEach(v -> fYunFileService.uploadFile(v.getAbsolutePath(),keyPath+v.getName()));
|
|
files.forEach(v -> fYunFileService.uploadFile(v.getAbsolutePath(),keyPath+v.getName()));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -85,9 +91,21 @@ public class AiServiceImpl implements IAiService {
|
|
}
|
|
}
|
|
|
|
|
|
//生成ai.json
|
|
//生成ai.json
|
|
- SceneMarkShape sceneMarkShapes = sceneMarkShapeService.findByNumAndType(num, DetectType.PANO.getCode());
|
|
|
|
|
|
+ List<SceneMarkShape> sceneMarkShapes = sceneMarkShapeService.findByNumAndType(scenePlus.getNum(), DetectType.PANO.getCode());
|
|
|
|
+ if(CollUtil.isNotEmpty(sceneMarkShapes)){
|
|
|
|
+ List<JSONObject> collect = sceneMarkShapes.stream().map(v -> {
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ jsonObject.put("index", FileUtil.getPrefix(v.getImagePath()));
|
|
|
|
+ jsonObject.put("shapes", v.getShapes());
|
|
|
|
+ return jsonObject;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
+ String ajJsonKey = String.format(UploadFilePath.IMG_VIEW_PATH, scenePlus.getNum()) + "ai.json";
|
|
|
|
+ fYunFileService.uploadFile(JSON.toJSONString(collect).getBytes(StandardCharsets.UTF_8), ajJsonKey);
|
|
|
|
+
|
|
|
|
+ scenePlusExt.setHasAi(CommonStatus.YES.code().intValue());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|