Procházet zdrojové kódy

update:对接ibms-config 服务
添加项目化配置模式 network

zhangweixin před 2 roky
rodič
revize
8499ddc2e6

+ 6 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/DaemonThread.java

@@ -164,6 +164,12 @@ public class DaemonThread extends Thread {
 					dir_all_valid = false;
 				}
 			}
+			if (Constant.info_point_enable && Constant.info_point_version.equals("network")) {
+				String tmp_dir = Constant.getLatestPath(Constant.info_point, true, true);
+				if (tmp_dir == null) {
+					dir_all_valid = false;
+				}
+			}
 			if (!dir_all_valid) {
 				continue;
 			}

+ 12 - 2
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/DownloadThread_info_point.java

@@ -58,9 +58,15 @@ public class DownloadThread_info_point extends Thread {
 			} catch (InterruptedException e) {
 				log.error(e.getMessage(), e);
 			}
-			if (!Constant.info_point_version.equals("new")) {
+
+			if (Constant.info_point_version.equals("new")||Constant.info_point_version.equals("network")){
+				/** 不做处理 */
+			}else {
 				continue;
 			}
+//			if (!Constant.info_point_version.equals("new")&&!Constant.info_point_version.equals("network")) {
+//
+//			}
 			if (!ConfigRefresh.enable) {
 				continue;
 			}
@@ -101,7 +107,11 @@ public class DownloadThread_info_point extends Thread {
 		String validPath = Constant.getLatestPath(Constant.info_point, true);
 
 		String tmpPath = Constant.info_point + Constant.getSeperator() + "tmp1";
-		RWDDownloadUtil.Load_info_point_new(tmpPath, LogOfDownload);
+		if (Constant.info_point_version.equals("new")){
+			RWDDownloadUtil.Load_info_point_new(tmpPath, LogOfDownload);
+		}else  {
+			RWDDownloadUtil.Load_info_point_network(tmpPath, LogOfDownload);
+		}
 		File tmp = new File(tmpPath);
 
 		boolean compare_valid = false;

+ 1 - 1
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/RefreshThread.java

@@ -114,7 +114,7 @@ public class RefreshThread extends Thread {
 					changed_ibms_physical_world = true;
 				}
 			}
-			if (Constant.info_point_enable && Constant.info_point_version.equals("new")) {
+			if (Constant.info_point_enable && (Constant.info_point_version.equals("new")||Constant.info_point_version.equals("network"))) {
 				String tmp_dir = Constant.getLatestPath(Constant.info_point, true, true);
 				if (tmp_dir != null && tmp_dir.compareTo(RepositoryContainer.RepositoryProject.resourceMap_try.get("info_point")) > 0) {
 					changed_info_point = true;

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

@@ -56,6 +56,8 @@ public class Constant {
 	public static String info_point;
 	public static boolean info_point_enable;
 	public static String info_point_version;
+	public static String ibms_config_url;
+	public static boolean ibms_config_enable;
 	public static List<String> iot_websocket_url = new ArrayList<String>();
 	public static String iot_collect_url;
 	public static String iot_project_url;
@@ -94,7 +96,7 @@ public class Constant {
 			suffixMap.put("-" + "meter-funcid", true);
 		}
 
-		try (InputStream stream = getStream("config.xml")) {
+		try (InputStream stream = getStream("config_zs.xml")) {
 			SAXReader saxReader = new SAXReader();
 			Document document = saxReader.read(stream);
 			if (document != null) {
@@ -186,7 +188,13 @@ public class Constant {
 					scaleplate_url = element.attribute("url").getValue();
 					scaleplate_url = StrUtil.removeSuffix(scaleplate_url, "/");
 				}
-
+				iter = document.selectNodes("/root/ibms_config").iterator();
+				if (iter.hasNext()) {
+					element = (Element) iter.next();
+					ibms_config_enable = element.attribute("enable").getValue().equalsIgnoreCase("true");
+					ibms_config_url = element.attribute("url").getValue();
+					ibms_config_url = StrUtil.removeSuffix(ibms_config_url, "/");
+				}
 				iter = document.selectNodes("/root/config").iterator();
 				if (iter.hasNext()) {
 					element = (Element) iter.next();

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

@@ -78,7 +78,7 @@ public class ExeclReadEquipStaticInfoUtil {
 			}
 			fis.close();
 		}
-		else if (Constant.info_point_version.equals("new")) {
+		else if (Constant.info_point_version.equals("new")||Constant.info_point_version.equals("network")) {
 			String infoClass = "基本参数";
 			JSONArray dic = new JSONArray();
 			for (SceneDataObject sdo : Repository.InfoPointListArray.set) {
@@ -185,7 +185,7 @@ public class ExeclReadEquipStaticInfoUtil {
 			}
 			fis.close();
 		}
-		else if (Constant.info_point_version.equals("new")) {
+		else if (Constant.info_point_version.equals("new")||Constant.info_point_version.equals("network")) {
 			JSONArray infoArray = Repository.infoArrayJson.get(classCode);
 			String infoClass = "基本参数";
 			JSONArray dic = new JSONArray();

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

@@ -205,6 +205,162 @@ public class RWDDownloadUtil {
 		}
 	}
 
+	/**
+	 * 网络获取管理范围信息
+	 *
+	 * @param path				 路径
+	 * @param LogOfDownload      存储信息
+	 * @throws Exception         错误信息
+	 */
+	public static void Load_info_point_network(String path, LogOfDownload LogOfDownload) throws Exception {
+		FileUtil.deleteRecursive(new File(path));
+		{
+			File root = new File(path);
+			if (!root.exists()) {
+				root.mkdir();
+			}
+		}
+		/** 信息点集合 */
+//		JSONArray InfoPointListArray = new JSONArray();
+		/** 控制反馈点集合 */
+//		JSONArray InfoPointRelationArray = new JSONArray();
+//		Map<String, ExcelSheet> sheetMap = ExcelCommonUtil.Read(Constant.getStream("info-point-new.xlsx"), true);
+//		for (String sheetName : sheetMap.keySet()) {
+//			ExcelSheet sheet = sheetMap.get(sheetName);
+//			for (int i = 1; i < sheet.contentListList.size(); i++) {
+//				String ibmsSceneCode = ExcelCommonUtil.getContentInner(sheet, "模块编码", i);
+//				String ibmsClassCode = ExcelCommonUtil.getContentInner(sheet, "IBMS编码", i);
+//				String infoType = ExcelCommonUtil.getContentInner(sheet, "信息点类型", i);
+//				String infoCode = ExcelCommonUtil.getContentInner(sheet, "信息点编码", i);
+//				String infoName = ExcelCommonUtil.getContentInner(sheet, "信息点名称", i);
+//				String infoAlias = ExcelCommonUtil.getContentInner(sheet, "信息点别名", i);
+//				String isVisible = ExcelCommonUtil.getContentInner(sheet, "是否显示", i);
+//				String isKeyPoint = ExcelCommonUtil.getContentInner(sheet, "是否关键参数", i);
+//				String isBatchControlParam = ExcelCommonUtil.getContentInner(sheet, "是否批量控制", i);
+//				String feedback = ExcelCommonUtil.getContentInner(sheet, "控制反馈点编码", i);
+//				String force = ExcelCommonUtil.getContentInner(sheet, "强制模式", i);
+//				String force_feedback = ExcelCommonUtil.getContentInner(sheet, "强制模式反馈", i);
+//				ibmsSceneCode = ibmsSceneCode == null ? null : ibmsSceneCode.trim();
+//				ibmsClassCode = ibmsClassCode == null ? null : ibmsClassCode.trim();
+//				infoType = infoType == null ? null : infoType.trim();
+//				infoCode = infoCode == null ? null : infoCode.trim();
+//				infoName = infoName == null ? null : infoName.trim();
+//				infoAlias = infoAlias == null ? null : infoAlias.trim();
+//				isVisible = isVisible == null ? null : isVisible.trim();
+//				isKeyPoint = isKeyPoint == null ? null : isKeyPoint.trim();
+//				isBatchControlParam = isBatchControlParam == null ? null : isBatchControlParam.trim();
+//				feedback = feedback == null ? null : feedback.trim();
+//				force = force == null ? null : force.trim();
+//				force_feedback = force_feedback == null ? null : force_feedback.trim();
+//				if (ibmsSceneCode == null || ibmsSceneCode.length() == 0) {
+//					continue;
+//				}
+//				if (ibmsClassCode == null || ibmsClassCode.length() == 0) {
+//					continue;
+//				}
+//				if (infoType == null || infoType.length() == 0) {
+//					continue;
+//				}
+//				if (infoCode == null || infoCode.length() == 0) {
+//					continue;
+//				}
+//				{
+//					infoCode = infoCode.substring(0, 1).toLowerCase() + infoCode.substring(1);
+//				}
+//				if (feedback != null && feedback.length() > 0) {
+//					feedback = feedback.substring(0, 1).toLowerCase() + feedback.substring(1);
+//				}
+//				if (force != null && force.length() > 0) {
+//					force = force.substring(0, 1).toLowerCase() + force.substring(1);
+//				}
+//				if (force_feedback != null && force_feedback.length() > 0) {
+//					force_feedback = force_feedback.substring(0, 1).toLowerCase() + force_feedback.substring(1);
+//				}
+//				{
+//					JSONObject pointListItem = new JSONObject();
+//					pointListItem.put("sequenceNo", i);
+//					pointListItem.put("ibmsSceneCode", ibmsSceneCode);
+//					pointListItem.put("ibmsClassCode", ibmsClassCode);
+//					pointListItem.put("infoCode", infoCode);
+//					pointListItem.put("infoType", infoType);
+//					pointListItem.put("infoName", infoName != null && infoName.length() > 0 ? infoName : null);
+//					pointListItem.put("infoAlias", infoAlias != null && infoAlias.length() > 0 ? infoAlias : null);
+//					pointListItem.put("isKeyPoint", (isKeyPoint != null && isKeyPoint.equals("Y")) ? true : false);
+//					pointListItem.put("isBatchControlParam", (isBatchControlParam != null && isBatchControlParam.equals("Y")) ? true : false);
+//					pointListItem.put("isVisible", (isVisible != null && isVisible.equals("Y")) ? true : false);
+//					InfoPointListArray.add(pointListItem);
+//				}
+//				{
+//					JSONObject pointRelationItem = new JSONObject();
+//					if (feedback != null) {
+//						pointRelationItem.put("控制反馈点", feedback);
+//					}
+//					if (force != null) {
+//						pointRelationItem.put("强制模式", force);
+//					}
+//					if (force_feedback != null) {
+//						pointRelationItem.put("强制模式反馈", force_feedback);
+//					}
+//					if (pointRelationItem.size() > 0) {
+//						pointRelationItem.put("ibmsSceneCode", ibmsSceneCode);
+//						pointRelationItem.put("ibmsClassCode", ibmsClassCode);
+//						pointRelationItem.put("控制点", infoCode);
+//						InfoPointRelationArray.add(pointRelationItem);
+//					}
+//				}
+//			}
+//		}
+		/** 查询数据信息 */
+		JSONObject paramNetwork = new JSONObject();
+		paramNetwork.put("groupCode", RepositoryContainer.RepositoryProject.groupCode);
+		paramNetwork.put("projectId", RepositoryContainer.RepositoryProject.projectId);
+
+		String post_network_result = HttpClientUtil.instance("ibms_config").post(Constant.ibms_config_url + "/sdkStatistics/listInfoPointWithProject",
+				paramNetwork.toJSONString());
+		JSONObject resultJSONNetwork = JSON.parseObject(post_network_result);
+		JSONArray contentNetwork = (JSONArray) resultJSONNetwork.get("content");
+
+		String get_network_result = HttpClientUtil.instance("ibms_config").get(Constant.ibms_config_url + "/sdkStatistics/listLatestInfoPointRelation");
+		JSONObject resultJSONNetworkRelation = JSON.parseObject(get_network_result);
+		JSONArray contentNetworkRelation = (JSONArray) resultJSONNetworkRelation.get("content");
+
+		FileUtil.Save(path + Constant.getSeperator() + "info-point-list" + ".json", FastJsonUtil.toFormatString(contentNetwork));
+		FileUtil.Save(path + Constant.getSeperator() + "info-point-relation" + ".json", FastJsonUtil.toFormatString(contentNetworkRelation));
+
+		if(Constant.scaleplate_enable){
+			String[] typeCodes = { "tdb", "rH", "cO2", "cO", "pM2d5" };
+			{
+				JSONArray array = new JSONArray();
+				int value = 29;
+				for (String typeCode : typeCodes) {
+					JSONObject param = new JSONObject();
+					param.put("groupCode", RepositoryContainer.RepositoryProject.groupCode);
+					param.put("projectId", RepositoryContainer.RepositoryProject.projectId);
+					param.put("typeCode", typeCode);
+					String post_result = HttpClientUtil.instance("scaleplate").post(Constant.scaleplate_url + "/listDyeScaleplateByType",
+							param.toJSONString());
+					JSONObject resultJSON = JSON.parseObject(post_result);
+					JSONArray content = (JSONArray) resultJSON.get("content");
+					for (int i = 0; i < content.size(); i++) {
+						JSONObject contentItem = content.getJSONObject(i);
+						String upperLimit = contentItem.getString("upperLimit");
+						String lowerLimit = contentItem.getString("lowerLimit");
+						JSONObject arrayItem = new JSONObject();
+						arrayItem.put("typeCode", typeCode);
+						arrayItem.put("id", contentItem.get("id"));
+						arrayItem.put("数值", value++);
+						arrayItem.put("名称", contentItem.get("name"));
+						arrayItem.put("颜色", contentItem.get("colorValue"));
+						arrayItem.put("上限", (upperLimit == null || upperLimit.length() == 0) ? null : Double.parseDouble(upperLimit));
+						arrayItem.put("下限", (lowerLimit == null || lowerLimit.length() == 0) ? null : Double.parseDouble(lowerLimit));
+						array.add(arrayItem);
+					}
+				}
+				FileUtil.Save(path + Constant.getSeperator() + "scaleplate" + ".json", FastJsonUtil.toFormatString(array));
+			}
+		}
+	}
+
 	public static boolean Process_physical_world(LogOfDownload LogOfDownload) throws Exception {
 		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
 		String validPath = Constant.getLatestPath(Constant.physical_world, true);

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

@@ -44,7 +44,7 @@ public class RWDRepositoryUtil {
 				log.warn("********************************" + "\t" + "LoadInfoPoint");
 				if (Constant.info_point_version.equals("old")) {
 					RWDLoadUtil.Load_info_point_old(Repository);
-				} else if (Constant.info_point_version.equals("new")) {
+				} else if (Constant.info_point_version.equals("new")||Constant.info_point_version.equals("network")) {
 					RWDLoadUtil.Load_info_point_new(LogOfRun, Repository);
 				}
 			}
@@ -99,6 +99,14 @@ public class RWDRepositoryUtil {
 				log.error(e.getMessage(), e);
 			}
 		}
+		if (Constant.info_point_version.equals("network")){
+			try {
+				process_info_alias(Repository);
+			} catch (Exception e) {
+				log.error(e.getMessage(), e);
+			}
+		}
+
 		Repository.sceneObject = sceneObject;
 
 		Repository.property2SDV_enable = true;

binární
ibms-data-sdk/src/main/resources/info-point-new.xlsx