|
@@ -1,11 +1,14 @@
|
|
|
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.ObjectUtil;
|
|
|
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.CommonOperStatus;
|
|
|
import com.fdkankan.common.constant.ModelingBuildStatus;
|
|
@@ -291,34 +294,48 @@ public class RabbitMqListener {
|
|
|
}
|
|
|
|
|
|
//平面图ai识别
|
|
|
- boolean detFloorplan = this.detFloorplan(path);
|
|
|
- buildSceneResult.setDetFloorplan(detFloorplan);
|
|
|
+ buildSceneResult.setDetFloorplan(this.detFloorplan(path));
|
|
|
|
|
|
return ModelingBuildStatus.SUCCESS;
|
|
|
}
|
|
|
|
|
|
- private boolean detFloorplan(String path) throws Exception {
|
|
|
+ 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 detectPath = workDir + "detect.json";
|
|
|
- String imgPath = workDir + "final_freespace.png";
|
|
|
- String keyPath = path + "/results/laserData/cover/final_freespace.png";
|
|
|
- String floorKeyPath = path + "/results/floorplan/floor_0.png";
|
|
|
- if(!FileUtil.exist(floorKeyPath)){
|
|
|
- return false;
|
|
|
+ String infoJsonPath = path + "/results/floorplan/info.json";
|
|
|
+ if(!FileUtil.exist(infoJsonPath)){
|
|
|
+ return result;
|
|
|
}
|
|
|
- FileUtil.copyContent(new File(floorKeyPath), new File(imgPath), true);
|
|
|
- String cmd = CmdConstant.LAYOUT_DETECT;
|
|
|
- cmd = cmd.replace("@in", imgPath);
|
|
|
- cmd = cmd.replace("@out", detectPath);
|
|
|
- CmdUtils.callLine(cmd, 50);
|
|
|
- if (ComputerUtil.checkComputeCompleted(detectPath,5, 500)) {
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
+
|
|
|
+ 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;
|
|
|
}
|
|
|
|
|
|
|