Jelajahi Sumber

关系改为可只加载一头,增加公共照明相关内容

menglu 3 tahun lalu
induk
melakukan
3ad720988d

+ 13 - 6
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/Constant.java

@@ -11,6 +11,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import org.dom4j.Attribute;
 import org.dom4j.Document;
 import org.dom4j.Element;
 import org.dom4j.io.SAXReader;
@@ -141,13 +142,19 @@ public class Constant {
 						}
 						ConfigRelation.objFrom = element.attribute("objFrom").getValue();
 						ConfigRelation.objTo = element.attribute("objTo").getValue();
-						ConfigRelation.nameInFrom = element.attribute("nameInFrom").getValue();
-						ConfigRelation.nameInTo = element.attribute("nameInTo").getValue();
-						if (element.attribute("multiplicityFrom") != null) {
-							ConfigRelation.multiplicityFrom = element.attribute("multiplicityFrom").getValue();
+						Attribute nameInFrom = element.attribute("nameInFrom");
+						if (nameInFrom != null) {
+							ConfigRelation.nameInFrom = nameInFrom.getValue();
+							if (element.attribute("multiplicityFrom") != null) {
+								ConfigRelation.multiplicityFrom = element.attribute("multiplicityFrom").getValue();
+							}
 						}
-						if (element.attribute("multiplicityTo") != null) {
-							ConfigRelation.multiplicityTo = element.attribute("multiplicityTo").getValue();
+						Attribute nameInTo = element.attribute("nameInTo");
+						if (nameInTo != null) {
+							ConfigRelation.nameInTo = nameInTo.getValue();
+							if (element.attribute("multiplicityTo") != null) {
+								ConfigRelation.multiplicityTo = element.attribute("multiplicityTo").getValue();
+							}
 						}
 						ConfigRelationList.add(ConfigRelation);
 						keyWordMap.put(ConfigRelation.nameInFrom, true);

+ 1 - 1
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RWDDownloadUtil.java

@@ -125,7 +125,7 @@ public class RWDDownloadUtil {
 					FastJsonUtil.toFormatString(infoArray));
 		}
 		Map<String, Map<String, Integer>> relDic = new HashMap<String, Map<String, Integer>>();
-		ExcelRelationUtil.ReadRel(Constant.GetPath() + Constant.getSeperator() + "2.6-relation.xlsx", relDic);
+		ExcelRelationUtil.ReadRel(Constant.GetPath() + Constant.getSeperator() + "relation.xlsx", relDic);
 		for (String graphCode : relDic.keySet().toArray(new String[0])) {
 			File graph = new File(path + Constant.getSeperator() + "relation" + Constant.getSeperator() + graphCode);
 			if (!graph.exists()) {

+ 31 - 20
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RWDLoadUtil.java

@@ -274,22 +274,26 @@ public class RWDLoadUtil {
 		for (ConfigRelation ConfigRelation : Constant.ConfigRelationList) {
 			Map<String, SceneDataObject> fromMap = Repository.objType2id2Value.get(ConfigRelation.objFrom);
 			Map<String, SceneDataObject> toMap = Repository.objType2id2Value.get(ConfigRelation.objTo);
-			for (String key : fromMap.keySet()) {
-				SceneDataObject sdv = fromMap.get(key);
-				if (!sdv.value_object.containsKey(ConfigRelation.nameInFrom)) {
-					SceneDataValue sdvInner = new SceneDataValue(Repository, sdv, ConfigRelation.nameInFrom, null);
-					sdvInner.value_array = new SceneDataSet(false);
-					sdvInner.value_array.set = new ArrayList<SceneDataObject>();
-					sdv.value_object.put(ConfigRelation.nameInFrom, sdvInner);
+			if (ConfigRelation.nameInFrom != null) {
+				for (String key : fromMap.keySet()) {
+					SceneDataObject sdv = fromMap.get(key);
+					if (!sdv.value_object.containsKey(ConfigRelation.nameInFrom)) {
+						SceneDataValue sdvInner = new SceneDataValue(Repository, sdv, ConfigRelation.nameInFrom, null);
+						sdvInner.value_array = new SceneDataSet(false);
+						sdvInner.value_array.set = new ArrayList<SceneDataObject>();
+						sdv.value_object.put(ConfigRelation.nameInFrom, sdvInner);
+					}
 				}
 			}
-			for (String key : toMap.keySet()) {
-				SceneDataObject sdv = toMap.get(key);
-				if (!sdv.value_object.containsKey(ConfigRelation.nameInTo)) {
-					SceneDataValue sdvInner = new SceneDataValue(Repository, sdv, ConfigRelation.nameInTo, null);
-					sdvInner.value_array = new SceneDataSet(false);
-					sdvInner.value_array.set = new ArrayList<SceneDataObject>();
-					sdv.value_object.put(ConfigRelation.nameInTo, sdvInner);
+			if (ConfigRelation.nameInTo != null) {
+				for (String key : toMap.keySet()) {
+					SceneDataObject sdv = toMap.get(key);
+					if (!sdv.value_object.containsKey(ConfigRelation.nameInTo)) {
+						SceneDataValue sdvInner = new SceneDataValue(Repository, sdv, ConfigRelation.nameInTo, null);
+						sdvInner.value_array = new SceneDataSet(false);
+						sdvInner.value_array.set = new ArrayList<SceneDataObject>();
+						sdv.value_object.put(ConfigRelation.nameInTo, sdvInner);
+					}
 				}
 			}
 		}
@@ -322,14 +326,18 @@ public class RWDLoadUtil {
 					continue;
 				}
 
-				SceneDataValue sdvFromItem = fromObject.value_object.get(ConfigRelation.nameInFrom);
-				SceneDataValue sdvToItem = toObject.value_object.get(ConfigRelation.nameInTo);
-				sdvFromItem.value_array.set.add(toObject);
-				sdvToItem.value_array.set.add(fromObject);
+				if (ConfigRelation.nameInFrom != null) {
+					SceneDataValue sdvFromItem = fromObject.value_object.get(ConfigRelation.nameInFrom);
+					sdvFromItem.value_array.set.add(toObject);
+				}
+				if (ConfigRelation.nameInTo != null) {
+					SceneDataValue sdvToItem = toObject.value_object.get(ConfigRelation.nameInTo);
+					sdvToItem.value_array.set.add(fromObject);
+				}
 			}
 		}
 		for (ConfigRelation ConfigRelation : Constant.ConfigRelationList) {
-			if (ConfigRelation.multiplicityFrom != null) {
+			if (ConfigRelation.nameInFrom != null && ConfigRelation.multiplicityFrom != null) {
 				Map<String, SceneDataObject> FromMap = Repository.objType2id2Value.get(ConfigRelation.objFrom);
 				for (String objFrom : FromMap.keySet()) {
 					SceneDataObject FromObject = FromMap.get(objFrom);
@@ -376,7 +384,7 @@ public class RWDLoadUtil {
 					}
 				}
 			}
-			if (ConfigRelation.multiplicityTo != null) {
+			if (ConfigRelation.nameInTo != null && ConfigRelation.multiplicityTo != null) {
 				Map<String, SceneDataObject> ToMap = Repository.objType2id2Value.get(ConfigRelation.objTo);
 				for (String objTo : ToMap.keySet()) {
 					SceneDataObject ToObject = ToMap.get(objTo);
@@ -516,6 +524,9 @@ public class RWDLoadUtil {
 						equipment.put("一级编组名称", sdo.get("一级编组名称"));
 						equipment.put("二级编组名称", sdo.get("二级编组名称"));
 						equipment.put("编组类型", sdo.get("编组类型"));
+						if (product.equals("PublicLighting")) {
+							equipment.put("楼层名称", sdo.get("楼层名称"));
+						}
 					}
 				}
 			}

+ 84 - 17
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/ToolUtil.java

@@ -64,10 +64,30 @@ public class ToolUtil {
 			SETDLS2GeneralZone.put(objFrom, objTo);
 		}
 
-		String[] ids = { "louti", "louti", "jingguan", "jingguan", "biaozhi", "biaozhi" };
-		String[] levels = { "楼体照明", "楼体照明", "景观照明", "景观照明", "标识照明", "标识照明" };
-		String[] types = { "A", "B", "A", "B", "A", "B" };
-		JSONArray result = new JSONArray();
+		String[] ids_yejing = { "louti", "jingguan", "biaozhi" };
+		String[] levels_yejing = { "楼体照明", "景观照明", "标识照明" };
+		String[] types_yejing = { "A", "B", "C", "D" };
+		String[] ids_gonggong = { "tingche", "buxing", "yule", "qiongding" };
+		String[] levels_gonggong = { "停车场照明", "步行街照明", "娱乐楼", "穹顶灯" };
+		String[] types_gonggong = { "A", "B", "C", "D" };
+		String[] ids;
+		String[] levels;
+		String[] types;
+		if (is_public) {
+			ids = ids_gonggong;
+			levels = levels_gonggong;
+			types = types_gonggong;
+		} else {
+			ids = ids_yejing;
+			levels = levels_yejing;
+			types = types_yejing;
+		}
+
+		JSONArray level1Array = new JSONArray();
+		JSONArray level2Array = new JSONArray();
+		Map<String, Boolean> level1Map = new HashMap<String, Boolean>();
+		Map<String, Boolean> level2Map = new HashMap<String, Boolean>();
+		JSONArray huiluArray = new JSONArray();
 		for (String SELTCC : SELTCC2SELTCU.keySet()) {
 			if (!SELTCC2SELTCU.containsKey(SELTCC)) {
 				continue;
@@ -83,7 +103,9 @@ public class ToolUtil {
 				GeneralZone = SETDLS2GeneralZone.get(SETDLS);
 			}
 
-			int index = BKDRHash.getHashCode(SELTCC) % levels.length;
+			int index = BKDRHash.getHashCode(SELTCC) % (levels.length * types.length);
+			int index_level = index / types.length;
+			int index_type = index % types.length;
 			JSONObject item = new JSONObject();
 			item.put("回路编号", SELTCC);
 			if (SELTCU != null && SELTCUMap.containsKey(SELTCU)) {
@@ -107,23 +129,64 @@ public class ToolUtil {
 				item.put("电井编号", null);
 				item.put("电井名称", null);
 			}
-			item.put("编组类型", types[index]);
+			item.put("编组类型", types[index_type]);
 			if (is_public) {
 				String floor = SELTCC2floor.get(SELTCC);
 				if (floor != null) {
-					item.put("楼层", floor);
-					item.put("二级编组", ids[index] + "-" + floorMap.get(floor).get("localId") + "-" + types[index]);
-					item.put("二级编组名称", levels[index] + "-" + floorMap.get(floor).get("localId") + "-" + types[index]);
-					item.put("一级编组", ids[index]);
-					item.put("一级编组名称", levels[index]);
-					result.add(item);
+					String floorName=(String)floorMap.get(floor).get("localName");
+					String level1id = ids[index_level];
+					String level1name = levels[index_level];
+					String level2id = ids[index_level] + "-" + floorMap.get(floor).get("localId") + "-" + types[index_type];
+					String level2name = levels[index_level] + "-" + floorMap.get(floor).get("localId") + "-" + types[index_type];
+					item.put("楼层编号", floor);
+					item.put("楼层名称", floorName);
+					item.put("二级编组", level2id);
+					item.put("二级编组名称", level2name);
+					item.put("一级编组", level1id);
+					item.put("一级编组名称", level1name); 
+					huiluArray.add(item);
+					if (!level1Map.containsKey(level1id)) {
+						level1Map.put(level1id, true);
+						JSONObject level1item = new JSONObject();
+						level1item.put("id", level1id);
+						level1item.put("name", level1name);
+						level1Array.add(level1item);
+					}
+					if (!level2Map.containsKey(level2id)) {
+						level2Map.put(level2id, true);
+						JSONObject level2item = new JSONObject();
+						level2item.put("id", level2id);
+						level2item.put("name", level2name);
+						level2item.put("一级编组", level1id);
+						level2item.put("楼层编号", floor);
+						level2Array.add(level2item);
+					}
 				}
 			} else {
-				item.put("二级编组", ids[index] + "-" + types[index]);
-				item.put("二级编组名称", levels[index] + "-" + types[index]);
-				item.put("一级编组", ids[index]);
-				item.put("一级编组名称", levels[index]);
-				result.add(item);
+				String level1id = ids[index_level];
+				String level1name = levels[index_level];
+				String level2id = ids[index_level] + "-" + types[index_type];
+				String level2name = levels[index_level] + "-" + types[index_type];
+				item.put("二级编组", level2id);
+				item.put("二级编组名称", level2name);
+				item.put("一级编组", level1id);
+				item.put("一级编组名称", level1name);
+				huiluArray.add(item);
+				if (!level1Map.containsKey(level1id)) {
+					level1Map.put(level1id, true);
+					JSONObject level1item = new JSONObject();
+					level1item.put("id", level1id);
+					level1item.put("name", level1name);
+					level1Array.add(level1item);
+				}
+				if (!level2Map.containsKey(level2id)) {
+					level2Map.put(level2id, true);
+					JSONObject level2item = new JSONObject();
+					level2item.put("id", level2id);
+					level2item.put("name", level2name);
+					level2item.put("一级编组", level1id);
+					level2Array.add(level2item);
+				}
 			}
 		}
 
@@ -132,6 +195,10 @@ public class ToolUtil {
 		// JSONArray peidianxiang = getArray_object("equipment", "SETDLS");
 		// JSONArray dianjing = getArray_object("space", "GeneralZone");
 
+		JSONObject result = new JSONObject();
+		result.put("回路", huiluArray);
+		result.put("一级编组", level1Array);
+		result.put("二级编组", level2Array);
 		return FastJsonUtil.toFormatString(result);
 	}
 

TEMPAT SAMPAH
ibms-data-sdk/src/main/resources/2.6-relation.xlsx


+ 6 - 4
ibms-data-sdk/src/main/resources/config.xml

@@ -20,14 +20,16 @@
 	<!-- 报警的websocket地址和服务地址 -->
 	<alarm enable="true" websocket="ws://39.102.43.179:9983/webSocketServer" rest="http://39.102.40.239:9970/zkt-alarm/"/>
 
-	<ConfigRelation graphCode="ArchSubset" relCode="Bd2Fl" objFrom="building" objTo="floor" nameInFrom="包含楼层" multiplicityFrom="n" nameInTo="所属建筑" multiplicityTo="1" />
-	<ConfigRelation graphCode="ArchSubset" relCode="Fl2Sp" objFrom="floor" objTo="space" nameInFrom="包含空间" multiplicityFrom="n" nameInTo="所属楼层" multiplicityTo="1" />
-	<ConfigRelation graphCode="MechInArch" relCode="Eq2Bd" objFrom="equipment" objTo="building" nameInFrom="所在建筑" multiplicityFrom="1" nameInTo="包含设备" multiplicityTo="n" />
-	<ConfigRelation graphCode="MechInArch" relCode="Eq2Fl" objFrom="equipment" objTo="floor" nameInFrom="所在楼层" multiplicityFrom="1" nameInTo="包含设备" multiplicityTo="n" />
+	<ConfigRelation graphCode="ArchSubset" relCode="Bd2Fl" objFrom="building" objTo="floor" nameInTo="所属建筑" multiplicityTo="1" />
+	<ConfigRelation graphCode="ArchSubset" relCode="Bd2Sp" objFrom="building" objTo="space" nameInTo="所属建筑" multiplicityTo="1" />
+	<ConfigRelation graphCode="ArchSubset" relCode="Fl2Sp" objFrom="floor" objTo="space" multiplicityFrom="n" nameInTo="所属楼层" multiplicityTo="1" />
+	<ConfigRelation graphCode="MechInArch" relCode="Eq2Bd" objFrom="equipment" objTo="building" nameInFrom="所在建筑" multiplicityFrom="1" />
+	<ConfigRelation graphCode="MechInArch" relCode="Eq2Fl" objFrom="equipment" objTo="floor" nameInFrom="所在楼层" multiplicityFrom="1" />
 	<ConfigRelation graphCode="MechInArch" relCode="Eq2Sp" relValue="GeneralZone" objFrom="equipment" objTo="space" nameInFrom="所在物业空间" multiplicityFrom="n" nameInTo="包含设备" multiplicityTo="n" />
 	<ConfigRelation graphCode="MechInArch" relCode="Eq2Sp" relValue="EnvironmentZone" objFrom="equipment" objTo="space" nameInFrom="所在环境空间" multiplicityFrom="n" nameInTo="包含设备" multiplicityTo="n" />
 	<ConfigRelation graphCode="MechForArch" relCode="Eq2Sp" objFrom="equipment" objTo="space" nameInFrom="服务于空间" multiplicityFrom="n" nameInTo="被设备服务" multiplicityTo="n" />
 	<ConfigRelation graphCode="MechCtrl" relCode="EqCtrl" objFrom="equipment" objTo="equipment" nameInFrom="控制设备" multiplicityFrom="n" nameInTo="被设备控制" multiplicityTo="n" />
 	<ConfigRelation graphCode="ValveRelationship" relCode="Vv2Eq" objFrom="equipment" objTo="equipment" nameInFrom="限制设备" multiplicityFrom="n" nameInTo="被设备限制" multiplicityTo="n" />
+	<ConfigRelation graphCode="ArchForArch" relCode="Sp2Sp" objFrom="space" objTo="space" nameInFrom="服务于空间" multiplicityFrom="n" nameInTo="被空间服务" multiplicityTo="n" />
 
 </root>

TEMPAT SAMPAH
ibms-data-sdk/src/main/resources/relation.xlsx