| 
					
				 | 
			
			
				@@ -2,11 +2,13 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 var prescriptionPrintWebsocket = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 var lockReconnect = false; //避免ws重复连接 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 var lastPatient = ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+var number = 0;//重连次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+var ip = '172.16.32.160:8089'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 function openSocket(type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //判断当前浏览器是否支持WebSocket 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if ('WebSocket' in window) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            prescriptionPrintWebsocket = new WebSocket("ws://" + window.location.host + "/thmz/prescriptionPrintSocket/" + type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            prescriptionPrintWebsocket = new WebSocket("ws://" + ip + "/thmz/prescriptionPrintSocket/" + type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             alert('当前浏览器不支持WebSocket,请更换浏览器'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -22,6 +24,7 @@ function openSocket(type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //连接成功建立的回调方法 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     prescriptionPrintWebsocket.onopen = function (event) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        number = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         console.log(type+"连接prescriptionPrintSocket连接成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(type == 'PY' && $("#aotuPrint").is(':checked')){//配药处方自动打印 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             printPrescriptions(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -44,6 +47,14 @@ function openSocket(type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     prescriptionPrintWebsocket.onclose = function (event) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         console.log(type+"连接prescriptionPrintSocket连接关闭 code:"+event.code+",原因:"+event.reason+",是否正常关闭:"+event.wasClean); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(event.code == '1001' || event.code == '1006'){//1001:终端离开, 可能因为服务端错误 1006:没有发送关闭帧 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            number += 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(number > 10){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(ip == '172.16.32.160:8089'){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ip = '172.16.32.161:8089' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ip = '172.16.32.160:8089' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             reconnect(type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }; 
			 |