From 1dc145aab7bbf5128d5c75d52ba4e03f1fc2725b Mon Sep 17 00:00:00 2001
From: xufenglei <xufenglei>
Date: Mon, 17 Jun 2019 14:59:55 +0800
Subject: [PATCH] 更新 设备状态

---
 src/main/webapp/img/ico_coo09.png |    0 
 src/main/webapp/img/ico09.png     |    0 
 src/main/webapp/js/moralmap.js    |   52 +++++++++++++++++++++++++
 src/main/webapp/view/map.jsp      |   16 -------
 4 files changed, 52 insertions(+), 16 deletions(-)

diff --git a/src/main/webapp/img/ico09.png b/src/main/webapp/img/ico09.png
new file mode 100644
index 0000000..e7e0523
--- /dev/null
+++ b/src/main/webapp/img/ico09.png
Binary files differ
diff --git a/src/main/webapp/img/ico_coo09.png b/src/main/webapp/img/ico_coo09.png
new file mode 100644
index 0000000..c426f90
--- /dev/null
+++ b/src/main/webapp/img/ico_coo09.png
Binary files differ
diff --git a/src/main/webapp/js/moralmap.js b/src/main/webapp/js/moralmap.js
index 35bb72c..313ae6e 100644
--- a/src/main/webapp/js/moralmap.js
+++ b/src/main/webapp/js/moralmap.js
@@ -508,7 +508,8 @@
 		function _getMapIcon(state) {
 			state = state == null ? 0 : state;
 			var icon = _option["icon"];
-			var url = icon["stateIcons"][state];
+			//var url = icon["stateIcons"][state];
+			var url = icon["url"] + state + ".png";
 			return new BMap.Icon(url, new BMap.Size(icon["width"], icon["height"]), {
 				imageSize: new BMap.Size(icon["width"], icon["height"])
 			});
@@ -551,8 +552,17 @@
 	moralMap.MoralMarker.prototype = new BMap.Marker();
 	//��������������� ������Mark������
 	moralMap.Monitorpoint = function(option) {
+		if(monitorPointStates){
+			for(var i in monitorPointStates){
+		    	var state = monitorPointStates[i];
+		    	if(state.id == option.id){
+		    		option.state = state.state;
+		    	}
+			}
+		}
 		var icon = {};
 		icon["stateIcons"] = ["/img/ico00.png", "/img/ico01.png", "/img/ico02.png", "/img/ico03.png", "/img/ico04.png"];
+		icon["url"] = "/img/ico0";
 		icon["width"] = 50;
 		icon["height"] = 50;
 		option["icon"] = icon;
@@ -639,8 +649,17 @@
 	//���������mac���key������
 	//��������������� ������MoralMark������
 	moralMap.Equipment = function(option) {
+		if(deviceStates){
+			for(var i in deviceStates){
+		    	var state = deviceStates[i];
+		    	if(state.id == option.id){
+		    		option.state = state.state;
+		    	}
+			}
+		}
 		var icon = {};
 		icon["stateIcons"] = ["/img/ico_coo00.png", "/img/ico_coo01.png", "/img/ico_coo02.png", "/img/ico_coo03.png", "/img/ico_coo04.png"];
+		icon["url"] = "/img/ico_coo0";
 		icon["width"] = 50;
 		icon["height"] = 60;
 		option["icon"] = icon;
@@ -975,6 +994,37 @@
     	
 	}
 
+    var deviceStates ;
+    var monitorPointStates;
+	moralMap.refreshState = function(states) {
+		if (!monitorPointStates) {
+			monitorPointStates = states;
+			deviceStates = [];
+			for (var i in states) {
+				var state = states[i];
+				for (var j in state.devices) {
+					var device = state.devices[j];
+					deviceStates.push(device);
+				}
+			}
+		}
+		for (var i in states) {
+			var state = states[i];
+			var mpoint = moralMap.getMpoint(state.id);
+			if (mpoint) {
+				mpoint.refreshState(state.state);
+			}
+			for (var j in state.devices) {
+				var marker = state.devices[j];
+				var marker_mac = marker["mac"];
+				var equipment = moralMap.getEquipment(marker_mac);
+				if (equipment) {
+					equipment.refreshState(marker);
+				}
+			}
+		}
+	}
+
 
 	window.moralMap = moralMap;
 })(jQuery, BMap, window);
\ No newline at end of file
diff --git a/src/main/webapp/view/map.jsp b/src/main/webapp/view/map.jsp
index 97427ad..3869532 100644
--- a/src/main/webapp/view/map.jsp
+++ b/src/main/webapp/view/map.jsp
@@ -673,21 +673,7 @@
 		} else if ("RefreshState" == methodName) {
 			//$("#searchParam").val(JSON.stringify(jsonData));
 			var states = jsonData.states;
-			for(var i in states){
-		    	var state = states[i];
-		    	var mpoint = moralMap.getMpoint(state.id);
-                if(mpoint!=null){
-                    mpoint.refreshState(state.state);
-                }
-		    	for(var j in state.devices){
-					var marker = state.devices[j];
-                    var marker_mac = marker["mac"];
-                    var equipment = moralMap.getEquipment(marker_mac);
-                    if(equipment!=null){
-                        equipment.refreshState(marker);
-                    }		    
-	            }
-	    	}
+			moralMap.refreshState(states);
 		}
 	}
 </script>

--
Gitblit v1.8.0