Selaa lähdekoodia

增加对ibms场景对象的支持

menglu 3 vuotta sitten
vanhempi
commit
4d277ea8ed

+ 2 - 2
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/ComputeUtil.java

@@ -36,8 +36,8 @@ public class ComputeUtil {
 			} else {
 				RWDLoadUtil.LoadAlarm(Repository, true);
 			}
-			log.warn("LoadIBMSPhysicalWorld");
-			RWDLoadUtil.LoadIBMSPhysicalWorld(Repository);
+			 log.warn("LoadIBMSPhysicalWorld");
+			 RWDLoadUtil.LoadIBMSPhysicalWorld(Repository);
 		} else {
 			Repository.objTypeMap = RepositoryBase.instance.objTypeMap;
 			Repository.code2objTypeMap = RepositoryBase.instance.code2objTypeMap;

+ 4 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/QueryUtil.java

@@ -551,6 +551,10 @@ public class QueryUtil {
 					result = new SceneDataSet(isSingleValueSet);
 					result.setRowChange(false);
 				}
+			} else if (Source.equals("ibms")) {
+				String product = (descSet.get("product")).toString();
+				String type = (descSet.get("type")).toString();
+				result = Repository.IBMSArrayDic.get(product).get(type);
 			} else if (Source.equals("alarm")) {
 				result = RepositoryBase.alarmArray;
 			} else if (Source.equals("ref")) {

+ 25 - 16
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RWDLoadUtil.java

@@ -1,6 +1,7 @@
 package com.persagy.ibms.data.sdk.util;
 
 import java.io.File;
+import java.io.FileFilter;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -470,23 +471,31 @@ public class RWDLoadUtil {
 
 	public static void LoadIBMSPhysicalWorld(Repository Repository) throws Exception {
 		String validPath = Constant.getLatestPath(Constant.ibms_physical_world, true);
-		String infoPath = validPath + Constant.getSeperator() + "NightscapeLighting";
-		Map<String, SceneDataSet> infoArrayDic = new HashMap<String, SceneDataSet>();
-		File root = new File(infoPath);
-		File[] files = root.listFiles();
-		for (File file : files) {
-			int index_ = file.getName().indexOf('.');
-			String code = file.getName().substring(0, index_);
-			log.debug(infoPath + Constant.getSeperator() + "" + file.getName());
-			try {
-				JSONArray array = FastJsonReaderUtil.Instance().ReadJSONArray(new File(infoPath + Constant.getSeperator() + "" + file.getName()));
-				SceneDataSet SceneDataSet = new SceneDataSet(false);
-				SceneDataSet.set = RWDUtil.array2SDOList(array);
-				infoArrayDic.put(code, SceneDataSet);
-			} catch (Exception e) {
-				log.warn(e.getMessage(), e);
+		File[] dirs = (new File(validPath)).listFiles(new FileFilter() {
+			@Override
+			public boolean accept(File pathname) {
+				return pathname.isDirectory();
+			}
+		});
+		for (File dir : dirs) {
+			String product = dir.getName();
+			Map<String, SceneDataSet> infoArrayDic = new HashMap<String, SceneDataSet>();
+			File[] files = dir.listFiles();
+			for (File file : files) {
+				int index_ = file.getName().indexOf('.');
+				String code = file.getName().substring(0, index_);
+				String infoPath = validPath + Constant.getSeperator() + product;
+				log.debug(infoPath + Constant.getSeperator() + file.getName());
+				try {
+					JSONArray array = FastJsonReaderUtil.Instance().ReadJSONArray(new File(infoPath + Constant.getSeperator() + file.getName()));
+					SceneDataSet SceneDataSet = new SceneDataSet(false);
+					SceneDataSet.set = RWDUtil.array2SDOList(array);
+					infoArrayDic.put(code, SceneDataSet);
+				} catch (Exception e) {
+					log.warn(e.getMessage(), e);
+				}
 			}
+			Repository.IBMSArrayDic.put(product, infoArrayDic);
 		}
-		Repository.IBMSArrayDic.put("NightscapeLighting", infoArrayDic);
 	}
 }

+ 42 - 8
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/ToolUtil.java

@@ -15,12 +15,31 @@ public class ToolUtil {
 		JSONObject paramObject = JSON.parseObject(param);
 		String type = (String) paramObject.get("type");
 		if (type.equals("NightscapeLighting")) {
-			result = NightscapeLighting();
+			result = Lighting(false);
+		} else if (type.equals("PublicLighting")) {
+			result = Lighting(true);
 		}
 		return result;
 	}
 
-	private static String NightscapeLighting() {
+	private static String Lighting(boolean is_public) {
+		Map<String, JSONObject> floorMap = new HashMap<String, JSONObject>();
+		JSONArray floorArray = getArray_object("floor", null);
+		for (int i = 0; i < floorArray.size(); i++) {
+			JSONObject item = (JSONObject) floorArray.get(i);
+			String id = (String) item.get("id");
+			floorMap.put(id, item);
+		}
+
+		JSONArray louceng = getArray_relation("MechInArch", "Eq2Fl");
+		Map<String, String> SELTCC2floor = new HashMap<String, String>();
+		for (int i = 0; i < louceng.size(); i++) {
+			JSONObject item = (JSONObject) louceng.get(i);
+			String objFrom = item.getString("objFrom");
+			String objTo = item.getString("objTo");
+			SELTCC2floor.put(objFrom, objTo);
+		}
+
 		JSONArray kongzhi = getArray_relation("MechCtrl", "EqCtrl");
 		Map<String, String> SELTCC2SELTCU = new HashMap<String, String>();
 		for (int i = 0; i < kongzhi.size(); i++) {
@@ -52,15 +71,20 @@ public class ToolUtil {
 		String[] types = { "A", "B", "A", "B" };
 		JSONArray result = new JSONArray();
 		for (String SELTCC : SELTCC2SELTCU.keySet()) {
+			if (!SELTCC2SELTCU.containsKey(SELTCC)) {
+				continue;
+			}
 			String SELTCU = SELTCC2SELTCU.get(SELTCC);
-			String SETDLS = null;
-			if (SELTCU != null && SELTCU2SETDLS.containsKey(SELTCU)) {
-				SETDLS = SELTCU2SETDLS.get(SELTCU);
+			if (!SELTCU2SETDLS.containsKey(SELTCU)) {
+				continue;
 			}
+			String SETDLS = SELTCU2SETDLS.get(SELTCU);
+
 			String GeneralZone = null;
 			if (SETDLS != null && SETDLS2GeneralZone.containsKey(SETDLS)) {
 				GeneralZone = SETDLS2GeneralZone.get(SETDLS);
 			}
+
 			int index = BKDRHash.getHashCode(SELTCC) % levels.length;
 			JSONObject item = new JSONObject();
 			item.put("回路编号", SELTCC);
@@ -68,9 +92,19 @@ public class ToolUtil {
 			item.put("配电箱编号", SETDLS);
 			item.put("电井编号", GeneralZone);
 			item.put("类型", types[index]);
-			item.put("二级编组", levels[index] + "-" + types[index]);
-			item.put("一级编组", levels[index]);
-			result.add(item);
+			if (is_public) {
+				String floor = SELTCC2floor.get(SELTCC);
+				if (floor != null) {
+					item.put("楼层", floor);
+					item.put("二级编组", levels[index] + "-" + floorMap.get(floor).get("localId") + "-" + types[index]);
+					item.put("一级编组", levels[index]);
+					result.add(item);
+				}
+			} else {
+				item.put("二级编组", levels[index] + "-" + types[index]);
+				item.put("一级编组", levels[index]);
+				result.add(item);
+			}
 		}
 
 		// JSONArray huilu = getArray_object("equipment", "SELTCC");