|
@@ -1,6 +1,8 @@
|
|
|
package com.fdkankan.model.utils;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -25,14 +27,20 @@ public class CreateHouseJsonUtil {
|
|
|
public static JSONObject createHouseTypeJsonByUser(String filePath) {
|
|
|
JSONObject house = init();
|
|
|
JSONArray floors = house.getJSONArray("floors");
|
|
|
-
|
|
|
- JSONArray floorJson = readFloorJson(filePath);
|
|
|
- for(int i=0;i<floorJson.size();++i) {
|
|
|
- JSONObject floor = floorJson.getJSONObject(i);
|
|
|
- JSONObject floorData = convert(floor,i);
|
|
|
- floors.add(floorData);
|
|
|
+ String type = readType(filePath);
|
|
|
+ if (!StrUtil.isEmpty(type) && "cad".equals(type)) {
|
|
|
+ JSONArray floorJson = readFloorJson(filePath);
|
|
|
+
|
|
|
+ for(int i = 0; i < floorJson.size(); ++i) {
|
|
|
+ JSONObject floor = floorJson.getJSONObject(i);
|
|
|
+ JSONObject floorData = convert(floor, i);
|
|
|
+ floors.add(floorData);
|
|
|
+ }
|
|
|
+
|
|
|
+ return house;
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
}
|
|
|
- return house;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -68,6 +76,16 @@ public class CreateHouseJsonUtil {
|
|
|
return house;
|
|
|
}
|
|
|
|
|
|
+ private static String readType(String filePath) {
|
|
|
+ try {
|
|
|
+ JSONObject floorplanUser = FileUtils.readJson(filePath);
|
|
|
+ String type = floorplanUser.getString("type");
|
|
|
+ return type;
|
|
|
+ } catch (IOException var3) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private static JSONArray[] createHouseTypeJsonHandler(JSONObject floor){
|
|
|
|
|
|
JSONArray[] result = new JSONArray[2];
|