Browse Source

完善sdk的info-replace

menglu 3 years ago
parent
commit
85a4a20a07

+ 12 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/Constant.java

@@ -64,6 +64,8 @@ public class Constant {
 
 	public static Map<String, String> SceneCode2TabName = new ConcurrentHashMap<String, String>();
 
+	public static Map<String, Map<String, String>> info_replaceMap = new ConcurrentHashMap<String, Map<String, String>>();
+
 	public static Map<String, Boolean> objType_hasRelation = new ConcurrentHashMap<String, Boolean>();
 	public static List<ConfigRelation> ConfigRelationList = new ArrayList<ConfigRelation>();
 	public static Map<String, ConfigRedirect> ConfigRedirectMap = new ConcurrentHashMap<String, ConfigRedirect>();
@@ -209,6 +211,16 @@ public class Constant {
 					SceneCode2TabName.put(sceneCode, tabName);
 				}
 
+				iter = document.selectNodes("/root/info_replace").iterator();
+				while (iter.hasNext()) {
+					element = (Element) iter.next();
+					String objType = element.attribute("objType").getValue();
+					String from = element.attribute("from").getValue();
+					String to = element.attribute("to").getValue();
+					info_replaceMap.putIfAbsent(objType, new ConcurrentHashMap<String, String>());
+					info_replaceMap.get(objType).put(from, to);
+				}
+
 				iter = document.selectNodes("/root/ConfigRelation").iterator();
 				while (iter.hasNext()) {
 					element = (Element) iter.next();

+ 69 - 18
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RWDLoadUtil.java

@@ -159,6 +159,43 @@ public class RWDLoadUtil {
 						}
 					}
 				}
+				// info_replace
+				if (Repository.code2objTypeMap.containsKey(code)) {
+					String objType = Repository.code2objTypeMap.get(code);
+					if (Constant.info_replaceMap.containsKey(objType)) {
+						Map<String, String> info_replace = Constant.info_replaceMap.get(objType);
+						for (int ii = 0; ii < array.size(); ii++) {
+							JSONObject arrayItem = (JSONObject) array.get(ii);
+							for (String info_from : info_replace.keySet()) {
+								String info_to = info_replace.get(info_from);
+								if (arrayItem.containsKey(info_from)) {
+									Object info_fromValue = arrayItem.get(info_from);
+									arrayItem.put(info_to, info_fromValue);
+								} else {
+									arrayItem.put(info_to, null);
+								}
+							}
+						}
+					}
+				}
+				if (Repository.objTypeMap.containsKey(code)) {
+					String objType = code;
+					if (Constant.info_replaceMap.containsKey(objType)) {
+						Map<String, String> info_replace = Constant.info_replaceMap.get(objType);
+						for (int ii = 0; ii < array.size(); ii++) {
+							JSONObject arrayItem = (JSONObject) array.get(ii);
+							for (String info_from : info_replace.keySet()) {
+								String info_to = info_replace.get(info_from);
+								if (arrayItem.containsKey(info_from)) {
+									Object info_fromValue = arrayItem.get(info_from);
+									arrayItem.put(info_to, info_fromValue);
+								} else {
+									arrayItem.put(info_to, null);
+								}
+							}
+						}
+					}
+				}
 				for (int i = 0; i < array.size(); i++) {
 					JSONObject arrayItem = array.getJSONObject(i);
 					String id = (String) arrayItem.get("id");
@@ -423,27 +460,34 @@ public class RWDLoadUtil {
 					SceneDataValue sdvFromItem = FromObject.value_object.get(ConfigRelation.nameInFrom);
 					if (sdvFromItem != null && sdvFromItem.value_array != null) {
 						if (ConfigRelation.multiplicityFrom.equalsIgnoreCase("1")) {
-							SceneDataValue sdvInner = new SceneDataValue(Repository, FromObject, ConfigRelation.nameInFrom + "-id", null);
-							sdvInner.finish = true;
-							sdvInner.value_prim = new SceneDataPrimitive();
+							SceneDataValue sdvInner_id = new SceneDataValue(Repository, FromObject, ConfigRelation.nameInFrom + "-id", null);
+							sdvInner_id.finish = true;
+							sdvInner_id.value_prim = new SceneDataPrimitive();
+							SceneDataValue sdvInner_name = new SceneDataValue(Repository, FromObject, ConfigRelation.nameInFrom + "名称", null);
+							sdvInner_name.finish = true;
+							sdvInner_name.value_prim = new SceneDataPrimitive();
 							if (sdvFromItem.value_array.set.size() == 0) {
 							} else if (sdvFromItem.value_array.set.size() == 1) {
-								sdvInner.value_prim.value = ((SceneDataObject) sdvFromItem.value_array.set.get(0)).get("id").value_prim.value;
+								sdvInner_id.value_prim.value = ((SceneDataObject) sdvFromItem.value_array.set.get(0)).get("id").value_prim.value;
+								sdvInner_name.value_prim.value = ((SceneDataObject) sdvFromItem.value_array.set.get(0))
+										.get("ibmsxianshimingcheng").value_prim.value;
 							} else {
 								for (SceneDataObject sdbInner : sdvFromItem.value_array.set) {
 									SceneDataObject sdoInner = (SceneDataObject) sdbInner;
-									if (sdvInner.value_prim.value == null) {
-										sdvInner.value_prim.value = sdoInner.get("id").value_prim.value;
+									if (sdvInner_id.value_prim.value == null) {
+										sdvInner_id.value_prim.value = sdoInner.get("id").value_prim.value;
+										sdvInner_name.value_prim.value = sdoInner.get("ibmsxianshimingcheng").value_prim.value;
 									} else {
-										if (!sdvInner.value_prim.value.equals(sdoInner.get("id").value_prim.value)) {
+										if (!sdvInner_id.value_prim.value.equals(sdoInner.get("id").value_prim.value)) {
 											log.error(ConfigRelation.graphCode + "\t" + ConfigRelation.relCode + "\t"
 													+ FromObject.value_object.get("id") + " " + "有多个" + " " + ConfigRelation.nameInFrom + "\t"
-													+ sdvInner.value_prim.value + "\t" + sdoInner.get("id").value_prim.value);
+													+ sdvInner_id.value_prim.value + "\t" + sdoInner.get("id").value_prim.value);
 										}
 									}
 								}
 							}
-							FromObject.value_object.put(ConfigRelation.nameInFrom + "-id", sdvInner);
+							FromObject.value_object.put(ConfigRelation.nameInFrom + "-id", sdvInner_id);
+							FromObject.value_object.put(ConfigRelation.nameInFrom + "名称", sdvInner_name);
 						} else {
 							SceneDataValue sdvInner = new SceneDataValue(Repository, FromObject, ConfigRelation.nameInFrom + "-id清单", null);
 							sdvInner.finish = true;
@@ -469,27 +513,34 @@ public class RWDLoadUtil {
 					SceneDataValue sdvToItem = ToObject.value_object.get(ConfigRelation.nameInTo);
 					if (sdvToItem != null && sdvToItem.value_array != null) {
 						if (ConfigRelation.multiplicityTo.equalsIgnoreCase("1")) {
-							SceneDataValue sdvInner = new SceneDataValue(Repository, ToObject, ConfigRelation.nameInTo + "-id", null);
-							sdvInner.finish = true;
-							sdvInner.value_prim = new SceneDataPrimitive();
+							SceneDataValue sdvInner_id = new SceneDataValue(Repository, ToObject, ConfigRelation.nameInTo + "-id", null);
+							sdvInner_id.finish = true;
+							sdvInner_id.value_prim = new SceneDataPrimitive();
+							SceneDataValue sdvInner_name = new SceneDataValue(Repository, ToObject, ConfigRelation.nameInTo + "名称", null);
+							sdvInner_name.finish = true;
+							sdvInner_name.value_prim = new SceneDataPrimitive();
 							if (sdvToItem.value_array.set.size() == 0) {
 							} else if (sdvToItem.value_array.set.size() == 1) {
-								sdvInner.value_prim.value = ((SceneDataObject) sdvToItem.value_array.set.get(0)).get("id").value_prim.value;
+								sdvInner_id.value_prim.value = ((SceneDataObject) sdvToItem.value_array.set.get(0)).get("id").value_prim.value;
+								sdvInner_name.value_prim.value = ((SceneDataObject) sdvToItem.value_array.set.get(0))
+										.get("ibmsxianshimingcheng").value_prim.value;
 							} else {
 								for (SceneDataObject sdbInner : sdvToItem.value_array.set) {
 									SceneDataObject sdoInner = (SceneDataObject) sdbInner;
-									if (sdvInner.value_prim.value == null) {
-										sdvInner.value_prim.value = sdoInner.get("id").value_prim.value;
+									if (sdvInner_id.value_prim.value == null) {
+										sdvInner_id.value_prim.value = sdoInner.get("id").value_prim.value;
+										sdvInner_name.value_prim.value = sdoInner.get("ibmsxianshimingcheng").value_prim.value;
 									} else {
-										if (!sdvInner.value_prim.value.equals(sdoInner.get("id").value_prim.value)) {
+										if (!sdvInner_id.value_prim.value.equals(sdoInner.get("id").value_prim.value)) {
 											log.error(ConfigRelation.graphCode + "\t" + ConfigRelation.relCode + "\t"
 													+ ToObject.value_object.get("id") + " " + "有多个" + " " + ConfigRelation.nameInTo + "\t"
-													+ sdvInner.value_prim.value + "\t" + sdoInner.get("id").value_prim.value);
+													+ sdvInner_id.value_prim.value + "\t" + sdoInner.get("id").value_prim.value);
 										}
 									}
 								}
 							}
-							ToObject.value_object.put(ConfigRelation.nameInTo + "-id", sdvInner);
+							ToObject.value_object.put(ConfigRelation.nameInTo + "-id", sdvInner_id);
+							ToObject.value_object.put(ConfigRelation.nameInTo + "名称", sdvInner_name);
 						} else {
 							SceneDataValue sdvInner = new SceneDataValue(Repository, ToObject, ConfigRelation.nameInTo + "-id清单", null);
 							sdvInner.finish = true;

+ 9 - 0
ibms-data-sdk/src/main/resources/config.xml

@@ -35,6 +35,15 @@
 	<!-- 场景/产品模块编码与后台tab页名称的对应关系 -->
 	<SceneCode2TabName sceneCode="ggzm" tabName="公共照明" />
 	<SceneCode2TabName sceneCode="yjzm" tabName="夜景照明" />
+	
+	<info_replace objType="building" from="localId" to="ibmsxianshibianma" />
+	<info_replace objType="building" from="localName" to="ibmsxianshimingcheng" />
+	<info_replace objType="floor" from="localId" to="ibmsxianshibianma" />
+	<info_replace objType="floor" from="localName" to="ibmsxianshimingcheng" />
+	<info_replace objType="space" from="wD_huiyunbendibianma" to="ibmsxianshibianma" />
+	<info_replace objType="space" from="wD_huiyunbendimingcheng" to="ibmsxianshimingcheng" />
+	<info_replace objType="equipment" from="wD_huiyunbendibianma" to="ibmsxianshibianma" />
+	<info_replace objType="equipment" from="wD_huiyunbendimingcheng" to="ibmsxianshimingcheng" />
 
 	<!-- 数据中台物理世界对象初始加载的关系,供SDK配置中使用 -->
 	<ConfigRelation graphCode="ArchSubset" relCode="Bd2Fl" objFrom="building" objTo="floor" nameInTo="所属建筑" multiplicityTo="1" />