Sfoglia il codice sorgente

生成houseTypoe.json判断floorPlanUser中type,如果不是cad,不需要生成houseType.json

dengsixing 2 anni fa
parent
commit
30e43b2512

+ 17 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/CreateHouseJsonUtil.java

@@ -1,5 +1,7 @@
 package com.fdkankan.common.util;
 
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONUtil;
 import java.io.IOException;
 import java.util.Map;
 
@@ -17,7 +19,11 @@ public class CreateHouseJsonUtil {
 	public static JSONObject createHouseTypeJsonByUser(String filePath) {
 		JSONObject house = init();
 		JSONArray floors = house.getJSONArray("floors");
-		
+
+		String type = readType(filePath);
+		if(StrUtil.isEmpty(type) && !"cad".equals(type)){
+			return null;
+		}
 		JSONArray floorJson = readFloorJson(filePath);
 		for(int i=0;i<floorJson.size();++i) {
 			JSONObject floor = floorJson.getJSONObject(i);
@@ -49,6 +55,16 @@ public class CreateHouseJsonUtil {
 			return null;
 		}
 	}
+
+	private static String readType(String filePath) {
+		try {
+			JSONObject floorplanUser = FileUtil.readJson(filePath);
+			String type = floorplanUser.getString("type");
+			return type;
+		} catch (IOException e) {
+			return null;
+		}
+	}
 	
 	private static JSONObject convert(JSONObject floorJson,int floor) {
 		JSONArray rooms = floorJson.getJSONArray("rooms");