|
@@ -2,13 +2,20 @@ package com.fdkankan.modeling.receiver;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.io.watch.WatchMonitor;
|
|
|
+import cn.hutool.core.io.watch.Watcher;
|
|
|
+import cn.hutool.core.lang.Console;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkankan.common.constant.ModelingBuildStatus;
|
|
|
+import com.fdkankan.common.util.CmdUtils;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
import com.fdkankan.model.utils.ComputerUtil;
|
|
|
import com.fdkankan.model.utils.CreateObjUtil;
|
|
|
import com.fdkankan.modeling.bean.BuildSceneResultBean;
|
|
|
+import com.fdkankan.modeling.constants.CmdConstant;
|
|
|
import com.fdkankan.modeling.constants.RedisKey;
|
|
|
import com.fdkankan.modeling.constants.SysConstants;
|
|
|
import com.fdkankan.modeling.entity.BuildLog;
|
|
@@ -39,10 +46,9 @@ import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.WatchEvent;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.Future;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.concurrent.TimeoutException;
|
|
@@ -331,9 +337,88 @@ public class RabbitMqListener {
|
|
|
log.error("未检测到计算结果文件:upload.json");
|
|
|
return ModelingBuildStatus.FAILED;
|
|
|
}
|
|
|
+
|
|
|
+ //平面图ai识别
|
|
|
+ buildSceneResult.setDetFloorplan(this.detFloorplan(path));
|
|
|
+
|
|
|
return ModelingBuildStatus.SUCCESS;
|
|
|
}
|
|
|
|
|
|
+ private LinkedHashMap<Integer, Boolean> detFloorplan(String path) throws Exception {
|
|
|
+ LinkedHashMap<Integer, Boolean> result = new LinkedHashMap<>();
|
|
|
+ String workDir = path + "/detFloorplan/";
|
|
|
+ if(FileUtil.exist(workDir)){
|
|
|
+ FileUtil.del(workDir);
|
|
|
+ }
|
|
|
+ String infoJsonPath = path + "/results/floorplan/info.json";
|
|
|
+ if(!FileUtil.exist(infoJsonPath)){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject infoObj = JSON.parseObject(FileUtil.readUtf8String(infoJsonPath));
|
|
|
+ JSONArray floors = infoObj.getJSONArray("floors");
|
|
|
+ if(CollUtil.isEmpty(floors)){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ for (Object o : floors) {
|
|
|
+ JSONObject floor = (JSONObject) o;
|
|
|
+ Integer subgroup = floor.getInteger("subgroup");
|
|
|
+ String detectPath = workDir + subgroup + "/detect.json";
|
|
|
+ String floorKeyPath = path + "/results/floorplan/floor_" + subgroup + ".png";
|
|
|
+ String parent = FileUtil.getParent(detectPath, 1);
|
|
|
+ FileUtil.mkdir(parent);
|
|
|
+ result.put(subgroup, false);
|
|
|
+ if(!FileUtil.exist(floorKeyPath)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String cmd = CmdConstant.LAYOUT_DETECT;
|
|
|
+ cmd = cmd.replace("@in", floorKeyPath);
|
|
|
+ cmd = cmd.replace("@out", detectPath);
|
|
|
+ CmdUtils.callLine(cmd, 50);
|
|
|
+ if (ComputerUtil.checkComputeCompleted(detectPath,5, 500)) {
|
|
|
+ result.put(subgroup, true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ File file = FileUtil.file("D:\\test\\111.txt");
|
|
|
+//这里只监听文件或目录的修改事件
|
|
|
+ WatchMonitor watchMonitor = WatchMonitor.create(file);
|
|
|
+ watchMonitor.setWatcher(new Watcher(){
|
|
|
+ @Override
|
|
|
+ public void onCreate(WatchEvent<?> event, Path currentPath) {
|
|
|
+ Object obj = event.context();
|
|
|
+ Console.log("创建:{}-> {}", currentPath, obj);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onModify(WatchEvent<?> event, Path currentPath) {
|
|
|
+ Object obj = event.context();
|
|
|
+ Console.log("修改:{}-> {}", currentPath, obj);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDelete(WatchEvent<?> event, Path currentPath) {
|
|
|
+ Object obj = event.context();
|
|
|
+ Console.log("删除:{}-> {}", currentPath, obj);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onOverflow(WatchEvent<?> event, Path currentPath) {
|
|
|
+ Object obj = event.context();
|
|
|
+ Console.log("Overflow:{}-> {}", currentPath, obj);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ watchMonitor.start();
|
|
|
+ for (int i= 0; i< 10; i++ ){
|
|
|
+ System.out.println(i);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private void afterBuild(BuildSceneCallMessage message, BuildSceneResultBean buildSceneResult, BuildLog buildLog){
|
|
|
ModelingBuildStatus buildStatus = null;
|
|
|
try {
|