From c09814ee3fa3dbd47d221d229fcdfc796314f7e8 Mon Sep 17 00:00:00 2001
From: LiJun <LiJun@192.168.10.10>
Date: 星期一, 22 十月 2018 14:32:22 +0800
Subject: [PATCH] 机房停电数显示基站状态中处于停电状态的机房数目,并且点击之后进入到所有基站状态查询页面

---
 gx_tieta/WebRoot/index.jsp |  362 ++++++++++++++++++++++++++++++++-------------------
 1 files changed, 228 insertions(+), 134 deletions(-)

diff --git a/gx_tieta/WebRoot/index.jsp b/gx_tieta/WebRoot/index.jsp
index b0aee9e..2ed62dc 100644
--- a/gx_tieta/WebRoot/index.jsp
+++ b/gx_tieta/WebRoot/index.jsp
@@ -75,6 +75,12 @@
 		.ui-resizable-s, .ui-resizable-se {
 			display: none !important;
 		}
+		
+		.ui-autocomplete {
+			height: 200px;
+			overflow-y: auto; 
+			overflow-x: hidden;
+    	}
 	</style>
 	<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
 	
@@ -93,9 +99,6 @@
 		<div id="content">
 			<div class="nav-map small">
 				<!-- 鐢垫睜鍒嗗竷鍥� -->
-				<div class="side-bar abs">
-					<div class="lside"></div>
-				</div>
 				<div class="china-map" id="map">
 					<div class="img-change" style="display:none;">
 						<div class="img-list">
@@ -600,7 +603,6 @@
 					
 					flushFourPie();		//鏇存柊鍥涚楗肩姸鍥�
 				});
-	
 				// 璁剧疆鍙抽敭鑿滃崟
 				var menu = new BMap.ContextMenu();
 				var txtMenuItem = [
@@ -635,17 +637,7 @@
 								enparams:[e]
 							});
 						}
-					},
-					/* {
-						text: '鏈烘埧瀹氫綅',
-						callback: function(e) {
-							panel.setPanelLayout();
-							panel.showPanel();
-							$('#map .panel-mask').bind('click', function() {
-								panel.hidePanel();
-							});
-						}
-					} */
+					}
 				];
 				//console.info(getPermit('taskchange_edit_permit', permits)+"*******");
 				if(getPermit('batt_map_edit_permit', permits)) {
@@ -1347,15 +1339,6 @@
 		});
 	});
 	
-	//  鐐瑰嚮鍦板浘鐨勬悳绱㈡寜閽畾浣嶅湴鍧�
-	$(function() {
-		$('#map').on('click', '.search .search-btn', function() {
-			var posTxt = $('#map .search .pos-txt').val();
-			addrAnalyze(posTxt);
-		});
-	});
-	
-	
 	$(window).resize(function() {
 		getMapHt();
 	});
@@ -1601,11 +1584,10 @@
 		// 閬嶅巻鏌ヨ鍐呭鐢熸垚瀵瑰簲鐨勫浘鏍�
 		for(var i = 0; i < dotList.length; i++) {
 			var dotIcon = new BMap.Icon(getMapStateImg(mapImages, dotList[i].msg), new BMap.Size(36, 30));	// 璁剧疆鍥剧墖
-
 			var pt = new BMap.Point(dotList[i].lng, dotList[i].lat);
 			
-			var mk = new BMap.Marker(pt, {icon:dotIcon});	// 瀹氫箟marker鐐�
-			addMenu(mk, mapDel);
+			var mk = new BMap.Marker(pt, {icon: dotIcon});	// 瀹氫箟marker鐐�
+			// addMenu(mk, mapDel);
 			deletePoint(map, dotList[i].title);
 			// 鍚憁k鐐规坊鍔爈abel
 			var home_name = new BMap.Label(dotList[i].title, {offset:new BMap.Size(20,-10)});
@@ -1620,10 +1602,10 @@
 				this.getLabel().setStyle({display: 'none'});					
 			});
 			
-			mk.addEventListener('click', function(e) {
+			/* mk.addEventListener('click', function(e) {
 				var target = e.target;
 				showMapPanel(target, dotList);
-			});
+			}); */
 			mkList.push(mk);
 			// 鍚戝湴鍥炬坊鍔犺鐩栫墿
 			map.addOverlay(mk);
@@ -1750,6 +1732,7 @@
 	
 	function showMapPanel(target, warnList) {
 		var point = target.point;
+		console.log(target.getLabel());
 		var searchInforWin = null;
 		for(var i = 0; i < warnList.length; i++) {
 			if(warnList[i].lng == point.lng && warnList[i].lat == point.lat) {
@@ -1969,12 +1952,130 @@
 		}
 	}
 	
-	searchStation();
-	var allStation;
+	// 璁剧疆椤甸潰涓殑鍙鍖哄煙鍥炬爣
+	;(function($, window, document, gl, undefined) {
+		// 璁剧疆鍛藉悕绌洪棿
+		gl.namespace('BMap');
+		// 鏍规嵁鍙鑼冨洿鏄剧ず鍧愭爣鐐�
+		var dots = [];
+		var currMarkers = {};
+		// 鏌ヨ褰撳墠鑼冨洿鍐呭鐨勫浘鏍�
+		function queryInRect(map, callback) {
+			var cp = map.getBounds(); // 杩斿洖map鍙鍖哄煙锛屼互鍦扮悊鍧愭爣琛ㄧず  
+	        var sw = cp.getSouthWest(); // 杩斿洖鐭╁舰鍖哄煙鐨勮タ鍗楄  
+	        var ne = cp.getNorthEast(); // 杩斿洖鐭╁舰鍖哄煙鐨勪笢鍖楄  
+	        //var zoom = map.getZoom(); //褰撳墠缂╂斁绾у埆 
+	        //console.log(dots);
+	        var mapDots = getDotsList(sw, ne);
+	        callback(map, mapDots);
+		}
+		
+		// 鑾峰彇dots鐨勯泦鍚�
+		function getDotsList(sw, ne) {
+			var rs = [];
+				swlng=sw.lng,  
+	            swlat=sw.lat,  
+	            nelng=ne.lng,  
+	            nelat=ne.lat;
+	            
+	            var maxLng = sw.lng>ne.lng?sw.lng:ne.lng;
+	            var minLng = sw.lng<ne.lng?sw.lng:ne.lng;
+	            
+	            var maxLat = sw.lat>ne.lat?sw.lat:ne.lat;
+	            var minLat = sw.lat<ne.lat?sw.lat:ne.lat;
+	            
+	            for(var i=0; i<dots.length; i++) {
+	            	var dot = dots[i];
+	            	var lat = dot.lat;
+	            	var lng = dot.lng;
+	            	var sId = dot.sId;
+	            	var isExist = checkMarker(sId);
+	            	
+	            	// 鏈娣诲姞杩�
+	            	if(!isExist) {
+	            		// 鍒ゆ柇缁忕含搴︽槸鍚﹀瓨鍦ㄨ鍖哄煙
+	            		if(lng<maxLng && lng>minLng && lat<maxLat && lat>minLat) {
+	            			currMarkers['markers'+sId] = sId;
+	            			rs.push(dot);
+	            		}
+	            	}
+	            }
+	            return rs;
+		}
+		
+		
+		// 妫�娴嬪綋鍓嶇偣鏄惁宸茬粡琚坊鍔犺繃
+		function checkMarker(id) {
+			var flag = false;
+			// 閬嶅巻宸茬粡娣诲姞鐨勭偣杩斿洖鏄惁宸茬粡琚坊鍔犺繃
+			Object.keys(currMarkers).forEach(function(key) {
+				if(currMarkers[key] == id) {
+					flag = true;
+				}
+			});
+			
+			return flag;
+		}
+		
+		// 璁剧疆dots闆嗗悎鐨勫��
+		function setDots(data) {
+			dots = data;
+		}
+		// 灏嗗彉閲忕粦瀹氬埌鍛藉悕绌洪棿涓�
+		gl.BMap.setDots = setDots;
+		
+		// 灏嗗嚱鏁扮粦瀹氬埌鍛藉悕绌洪棿涓�
+		gl.BMap.queryInRect = queryInRect;
+	})(jQuery, window, document, GLOBAL);
+	
+	
+	// 鍦板浘鏈烘埧鎼滅储妯″潡
+	;(function($, window, document, gl, undefined) {
+		// 璁剧疆鍛藉悕绌洪棿BMap.Search妯″潡
+		gl.namespace('BMap.Search');
+		
+		var homeInfor = [];
+		
+		// 璁剧疆homeInfor鐨勫��
+		function setHomeInfor(data) {
+			homeInfor = data;
+		}
+		// 灏嗗嚱鏁扮粦瀹氬埌鍛藉悕绌洪棿涓�
+		gl.BMap.Search.setHomeInfor = setHomeInfor;
+		
+		// 鏍规嵁homeInfor鐨勫�艰繑鍥瀐ome鍒楄〃
+		function getHomeList() {
+			var rs = [];
+			// 閬嶅巻homeInfor鐨勫��
+			for(var i=0; i<homeInfor.length; i++) {
+				rs.push(homeInfor[i].title);
+			}
+			return rs;
+		}
+		// 灏嗗嚱鏁扮粦瀹氬埌鍛藉悕绌洪棿涓�
+		gl.BMap.Search.getHomeList = getHomeList;
+	})(jQuery, window, document, GLOBAL);
+	
+	// 鏌ヨ骞惰缃満鎴跨殑鍥炬爣
+	$(function () {
+		searchStation(true);
+	});
+	
+	
+	var allStation = [];
+	var mapPages = {
+		pageSize:2, 				// 姣忛〉鐨勮鏁�
+		pageCurr:1,  				// 褰撳墠椤电爜鏁�
+		pageAll:1,					// 鏁扮洰
+		pageNum: 0,
+		pageNew: true
+	};
 	//鏌ヨ鏈烘埧
-	function searchStation(){
+	function searchStation(setRect){
 		var temp = createSearchParam();
 		var json = JSON.stringify(temp);
+		var bmap = GLOBAL.BMap;		// BMap鐨勫懡鍚嶇┖闂�
+		var bmap_s = bmap.Search;	// Search鐨勫懡鍚嶇┖闂�
 		commonDot = new Array();
 		warnDotList = new Array();
 		dischargeDotList = [];
@@ -1983,56 +2084,110 @@
 	        type: "post", 				
 	        //url: "BattMap_informationAction!searchAll",				
 	        url: "BattMap_informationAction!searchUserManageStation",				
-	        async:true,				
+	        async: true,				
 	        dataType:'text',
 	        data:"json="+json,		
 	        success: function(data){ 
 				data = eval('('+data+')');
-				var list = eval('('+data.result+')');
-				//console.info(list);
+				// 鑾峰彇缁撴灉闆�
+				var rs = JSON.parse(data.result);
+				var list = rs.data;
+				// console.log(list);
 				allStation = new Array();
 				if(list!=undefined && list.length>0){
+					// 璁剧疆鍒嗛〉淇℃伅
+					mapPages.pageAll = list.length;
+					setMapPages();
+					console.info(mapPages);
+					// 閬嶅巻鏌ヨ缁撴灉
 					for(var i=0;i<list.length;i++){
-						//console.info("绗�"+i+"娆�:"+model.data[i].binformation.num);
-						//setAllStation(model.data[i],allStation);
-						var tmp = {
-							binformation:list[i].data,
-							alarm_num:list[i].code,		//鍛婅鏁扮洰
-							low_num:list[i].sum,		//钀藉悗鏁扮洰
-							delay_num:list[i].newsum,	//寤舵椂鏁扮洰
-							msg: list[i].msg
-						};
-						allStation.push(analyzeData(tmp));
+						var _list = list[i];
+						allStation.push(formatAllStation(_list));
 					}
-					//console.info(allStation);
-					createMapDot(map, allStation);
 					
-					//setTimeout(searchStation, 4000);	
-				}
-				/* for(var i=0;i<allStation.length;i++){
-					if(allStation[i].low_num>0){							//钀藉悗鏁扮洰	
-						behindCellList.push(analyzeData(allStation[i]));
-						//console.info(analyzeData(allStation[i]));
-					}else if(allStation[i].alarm_num>0){					//鍛婅鏁扮洰
-						warnDotList.push(analyzeData(allStation[i]));
-					}else if(allStation[i].delay_num > 0){					//寤舵椂鏁扮洰	
-						dischargeDotList.push(analyzeData(allStation[i]));
-					}else{
-						commonDot.push(analyzeData(allStation[i]));
+					// 鏄剧ず鍖哄煙鐨勫浘鏍�
+					bmap.setDots(allStation);
+					bmap.queryInRect(map,createMapDot);
+					// 鏄惁绗竴娆℃墽琛�
+					if(setRect) {
+						map.addEventListener("moveend", bmap.queryInRect.bind({},map, createMapDot));  // 鎷栧姩
+						map.addEventListener("zoomend", bmap.queryInRect.bind({},map, createMapDot)); // 缂╂斁
+						updateStation();
 					}
 				}
-				
-				// 娓呯┖瑕嗙洊鐗╁拰瀵瑰簲鐨刴k鐐�
-				map.clearOverlays();
-				mkList = [];
-				
-				addCommonDotHome(commonDot);
-				createWarnDot(map, warnDotList);
-				dischargeTimeOut(map, dischargeDotList);
-				behindDotCell(map, behindCellList); */
         	} 				
 		});
 	}
+	
+	// 鏍煎紡鍖栨煡璇㈢粨鏋�
+	function formatAllStation(list) {
+		var obj = new Object();
+		// 鏋勯�犵粨鏋滈泦
+		obj.lng = list.longitude;
+		obj.lat = list.latitude;
+		obj.title = list.StationName;
+		obj.sId = list.StationId;
+		obj.fbsId = list.FBSDeviceId;
+		obj.addr = list.Address;
+		obj.msg = "";
+		return obj;
+	}
+	
+	// 璁剧疆鍒嗛〉鐨勪俊鎭�
+	function setMapPages() {
+		var pageNum = Math.ceil(mapPages.pageAll/mapPages.pageSize);
+		mapPages.pageNum = pageNum;
+	}
+	
+	// 杞鏇存柊鍦板浘鐨勭偣鏌ヨ
+	function updateStation() {
+		var updateStationData = [];
+		$.ajax({
+			type: "post",
+			url: "BattMap_informationAction!searchUserManageStation2",				
+	        async: true,				
+	        dataType:'json',
+	        data: "json="+JSON.stringify(mapPages),
+	        success: function(result) {
+	        	var data = JSON.parse(result.result);
+	        	for(var i=0; i<data.length; i++) {
+	        		var _data = data[i];
+	        		updateStationData.push(formatUpdateStation(_data));
+	        		
+	        		// 鍒ゆ柇鏄惁鏇存柊
+	        	}
+	        	
+	        	createMapDot(map, updateStationData);
+	        	
+	        	// 鏇存柊鍒嗛〉淇℃伅
+	        	mapPages.pageCurr++;
+	        	if(mapPages.pageCurr>mapPages.pageNum) {
+	        		mapPages.pageCurr=1;
+	        		mapPages.pageNew=false;
+	        	}
+	        	
+	        	setTimeout(updateStation, 4000);
+	        }
+		});
+	}
+	
+	// 鏍煎紡鍖栨煡璇㈢粨鏋�
+	function formatUpdateStation(list) {
+		var obj = {};
+		var data = list.data;
+		// 鏋勯�犵粨鏋滈泦
+		obj.lng = data.longitude;
+		obj.lat = data.latitude;
+		obj.title = data.StationName;
+		obj.sId = data.StationId;
+		obj.fbsId = data.FBSDeviceId;
+		obj.addr = data.Address;
+		obj.msg = list.msg;
+		return obj;
+	}
+	
+	// 鏇存柊鎵�鏈夋満鎴�
+	
 	
 	function setAllStation(obj,allstation){
 		//console.info(allstation);
@@ -3065,74 +3220,13 @@
     		img.attr('src', navImg);
     	}
     }
-    // siderbar妯″潡
+    
+    //  鐐瑰嚮鍦板浘鐨勬悳绱㈡寜閽畾浣嶅湴鍧�
 	$(function() {
-		var TreeView = GLOBAL.pages.TreeView;
-		var first = GLOBAL.pages.siderbar.first;	// 涓�绾у鑸�
-		var second = GLOBAL.pages.siderbar.second;	// 浜岀骇瀵艰埅
-		var thirdFile = GLOBAL.pages.siderbar.thirdFile;	// 涓夌骇瀵艰埅
-		var treeView = new TreeView($('.side-bar .lside'));
-		// 璁剧疆瀹瑰櫒鍙嫋鍔�
-		$('.side-bar').resizable({
-			handles: 'e',
-			maxWidth: 520,
-			minWidth: 200,
-			alsoResize: $('.side-bar .lside'),
-			resize:function() {
-				treeView.setContainer();
-			}
+		$('#map').on('click', '.search .search-btn', function() {
+			var posTxt = $('#map .search .pos-txt').val();
+			addrAnalyze(posTxt);
 		});
-		
-		// 鐢熸垚涓�绾у鑸�-鐪�
-		first(treeView, treeView.container);
-		
-		// 鐪�->甯�
-		treeView.ele.on('click', '.province', function() {
-			var province = $(this).data('attr');
-			second(treeView, $(this).parent(), province);
-		});
-		
-		// 甯�->鏈烘埧
-		treeView.ele.on('click', '.city', function() {
-			var city = $(this).data('attr');
-			thirdFile(treeView, $(this).parent(), city);
-		});
-		
-		// 鐐瑰嚮鏈烘埧瀹氫綅
-		treeView.ele.on('click', '.home', function() {
-			var home = $(this).data('attr');
-			var dev_id = home.FBSDeviceId;
-			
-			searchStationById(home.StationId);
-			// 鏍规嵁璁惧id璁剧疆涓嶅悓鐨勫浘鏍�
-			if(eType.regType(dev_id, eType.type.equip61850)) {
-				changeMapImgDesc($('#mapImgDesc'), '61850');
-			}else {
-				changeMapImgDesc($('#mapImgDesc'));
-			}
-		});
-		
-		$('#map').on('dblclick', function() {
-			setLside();
-			treeView.setContainer();
-		});
-		
-		// 璁剧疆lside鐨勯珮搴�
-		setLside();
-		treeView.setContainer();
-		setLside();
-		$(window).resize(function() {
-			setLside();
-		});
-		
-		// 璁剧疆lside鐨勯珮搴﹀嚱鏁�
-		function setLside() {
-			var sideBar = $('.side-bar');
-			var lside = $('.side-bar .lside');
-			// 璁剧疆瀹介珮
-			lside.width(sideBar.width());
-			lside.height(sideBar.height());
-		}
 	});
 	</script> 
 </html>

--
Gitblit v1.9.1