processSql.jsp 16.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/updateclient/systeminfo/init_wev8.jsp"%> 
<%@ page import="java.io.*"%>
<%@ page import="java.net.InetAddress"%>
<jsp:useBean id="suc" class="weaver.system.SysUpgradeCominfo" scope="page" />
<jsp:useBean id="baseBean" class="weaver.general.BaseBean" scope="page"/>
<html>
 <head>
	<title> E-cology升级程序</title>
<%
	int time = 10000;
	String titlename ="";
	
	int pagestatus = 999;
	int status = 999;
	String sqlpath = GCONST.getRootPath() + "sqlupgrade" + File.separatorChar;

    sqlpath = sqlpath + suc.getDBFileName();
	HashMap<String,String> infomap = suc.getUpgadeInfoMap();
	String errormsg = infomap.get("errormsg");//脚本报错信息
	String executesql = infomap.get("executesql");//正在执行的脚本
	
	String dburl = infomap.get("dburl");//数据库地址
	String dbname = infomap.get("dbname");//数据库名称
	String currentfile = infomap.get("currentfile");//已执行脚本数量
	String totalfile = infomap.get("totalfile");//脚本总数
	String runningfilename = infomap.get("runningfilename");//正在执行的脚本
	String percent = infomap.get("percent");//脚本执行进度
	String threadruning = infomap.get("threadruning"); //脚本线程是否在执行
	String continueflag = infomap.get("continueflag");//是否点击继续
	String deployMonitor = ""+suc.deployMonitor;//是否部署运维平台
	String hostaddr = ""+suc.hostaddr; 
	String mainControlIp = ""+suc.mainControlIp;
	String upgradetype = ""+suc.upgradetype;
	
	pagestatus=Util.getIntValue(infomap.get("pagestatus"),0);
	status=Util.getIntValue(infomap.get("status"),0);
	
	String skipnote = "";
	String dbmsg = "当前系统的数据库地址:"+dburl+",数据库名:"+dbname+",请确认是否正确";
	String sqlmsg = "";
	if(!"".equals(runningfilename)) {
		sqlmsg = "正在执行"+runningfilename+",共"+totalfile+"个,已执行"+currentfile+"个";
	}
	
	if(errormsg != null) {
		errormsg = errormsg.replace("<br>","\r\n");
	}
   boolean sqlfinished = false;
   boolean isMainNode = true;
   //集群判断是否是主节点  只有主节点才执行脚本
   if((!"".equals(mainControlIp)&&hostaddr.equals(mainControlIp))||"".equals(mainControlIp)) {
   	isMainNode = true;
   } else {
   	isMainNode = false;
   }
   File rundir = null;
   String[] runfilelist = null;
   if(isMainNode) {
   	 	rundir = new File(sqlpath);
   	    runfilelist = rundir.list();
   	    if(runfilelist!=null&&runfilelist.length > 0) {
   	    	
   	    } else {
   	    	sqlfinished  = true;
   	    	time = 20000;
   	    }
   } else {
   	sqlfinished  = true;
   	time = 20000;
   }
  
   
   if(pagestatus==0&&sqlfinished) {
   	response.sendRedirect("/updateclient/upgradesuccess.jsp");
   }
   if(status == 1 || status == 3) {
   	time = 20000;
   }
%>
<script type="text/javascript">
var timeout = null;
function myrefresh(){ 
	window.location.reload(); 
} 
$("document").ready(function(){
	$("#skipall").bind("click",skipall);
	$("#backup").bind("click",backup);
	if($(".divleft")) {
		var divleftheight = $(".divleft").height();
		var divrightheight = $(".divright").height();
		var height = divleftheight>divrightheight?divleftheight:divrightheight;
		$(".divleft").css("height",height);
		$(".divright").css("height",height);
		//$(".divleft").parent().css("width","99%");
		
		//$("#title").css("width","99%");
	} else {
		
	}

	
	timeout = setTimeout("myrefresh()",<%=time%>);

});

$(document).ready(function(){
	startMonitorMousedDown();
	setPosition();
});

var monitorMousedDown = true;//对鼠标点击事件进行监控
var hasPrompt = false;//提示正在升级  只有在第一次离开页面并点击才会提示
function startMonitorMousedDown(){
	$(window.document).mouseout(function(e){
	
   		var xx = 0;
        var yy = 0;
        if(e.pageX || e.pageY) {
        	xx = e.pageX;
        	yy = e.pageY;
        } else {
        	xx = e.clientX + document.body.scrollLeft - document.body.clientLeft;
			yy = e.clientY + document.body.scrollTop - document.body.clientTop;
        }
        

        if(!hasPrompt && (xx <= 0 || yy <= 0)) {
        	monitorMousedDown = true;
        } else {
        	monitorMousedDown = false;
        }
	});
	
	$(top.document).mousedown(function(e){
		//获得点击的元素
		//alert($(this).attr("class"));
		//e8_btn_top
		
		if(monitorMousedDown) {
			monitorMousedDown = false;
			top.Dialog.confirm("系统正在升级,请确认是否离开升级页面?如果确认离开,请点击“确定”并再次点击目标菜单。",
				function(){
					monitorMousedDown = false;
					hasPrompt = true;
					$(top.document).unbind('mousedown',this);
				},
				function(){
					monitorMousedDown = true;
					hasPrompt = false;
				}	
			);
		}
	});
}

$(window).resize(function(){
	setPosition();
});
function setPosition() {
	//var elediv = $(".divcenter");
	
	//$(".divcenter").css("top", ($(document).height() - elediv.height()) / 2 + $(document).scrollTop() + "px");
	//$(".divcenter").css("left", ($(document).width() - elediv.width()) / 2 + $(document).scrollLeft() + "px");
	//$(".divcenter").css("position","absolute");
	$(".divcenter").css("display","");
}
//确认信息
function operationConfirm(fun1,msg) {
	if("1" == fun1) {
		continueExcute(1);
	} else if("2" == fun1) {
		continueExcute(2);
	} else if("3" == fun1) {
		continueExcute(3);
	} else if("4" == fun1) {
		continueExcute(4);
	} else {
		continueExcute(fun1);
	}
	if(timeout != null) {
		clearTimeout(timeout);
	}
}
</script>
<style type="text/css">
.btnclass {
	margin-top:20px!important;
	margin-left:0px!important;
	margin-bottom:10px;
	width:200px;
	height:30px;
}
.btnclass { 	
		border:0px;cursor:pointer;
		background-color:#558ED5;
		color:white;
}
.updating {
	font-family:"Microsoft YaHei"!important;
	margin:0px 0 0 0!important;
}
#imagediv {
	float:left;
}
.updatingnew {
	font-family:"Microsoft YaHei"!important;
	border:1px solid #DBDBDB;
	margin:0px 0 0 0!important;
	width:49.7%;
	position:relative;
}
.divleft {
	float:left;
}
.divright{
	float:right;
}
.imagediv {
	text-align:center;
}
.divmargin {
	margin-top:20px!important;
}
.content {
	margin-left:15px;
	margin-right:15px;
	margin-top:10px;
}
#pro {
 float:left
}
.tips{
	width:100%;
	font-weight:bold;
	background-color:#FFFFE0;
	border-radius:15px;
	height:20px;
}

.operationmsg {
	background-color:rgb(255, 243, 220);
	border:1px solid;
	border-color:rgb(255, 204, 0);
	border-radius:3px;
	height:200px;
	overflow:auto;
	width:80%;
	margin: 0 auto;
	margin-top:20px;
	
}
.continuebtn{
	color:#FFFFFF;
	font-size: 14px;
	height: 40px;
	width: 170px;
	background-color:rgb(76, 177, 252);
	border: none;
	border-radius: 2px;
	cursor: pointer;
}
.sqlerrormsg {
	height:160px;
	width:80%;
	margin:0 auto;
	margin-top:10px;
}
.divmid {
	margin: 0 auto;
	text-align:center
}
.executesqlmsg {
	height:160px;
	width:80%;
	margin:0 auto;
	margin-top:10px;
}
.msgstyle1 {
	font-family: 微软雅黑;
	font-style: normal;
	font-size: 14px;
	text-align: center;
    line-height: normal;
    margin-top:20px;
}
.msgstyle2{
    color: #999999;
    text-align: center;
    font-family: 微软雅黑;
    font-style: normal;
    font-size: 12px;
    margin-top:10px;
}
.msgnote1 {
	color:#FF9200;
	margin-left:20px;
	font-family: 微软雅黑;
	font-style: normal;
	font-size: 14px;
	
}
.msgnote2 {
	color:#868686;
	margin-left:20px;
	margin-top:0px;
	margin-bottom:0px;
	font-family: 微软雅黑;
	font-style: normal;
	font-size: 14px;
}
html,body{height:100%}
a{
	text-decoration:underline!important;
}
</style>
 </head>
<jsp:include page="/updateclient/upgradeCheck.jsp"/>
<%@ include file="/updateclient/systeminfo/TopTitle_Upgrade.jsp" %>
<%@ include file="/updateclient/systeminfo/RightClickMenuConent_Upgrade.jsp" %>
<jsp:include page="/updateclient/systeminfo/commonTabHead.jsp?step=4">
			<jsp:param name="mouldID" value="upgrade" />
			<jsp:param name="navName" value="执行脚本" />
</jsp:include>
<%




if(status ==2) {
	RCMenu += "{"+SystemEnv.getHtmlLabelName(354 ,user.getLanguage())+",javascript:myrefresh(),_self} " ;
	RCMenuHeight += RCMenuHeightStep ;
} else {
	RCMenu += "{"+SystemEnv.getHtmlLabelName(354 ,user.getLanguage())+",javascript:myrefresh(),_self} " ;
	RCMenuHeight += RCMenuHeightStep ;
	if(status ==1) {
		RCMenu += "{"+SystemEnv.getHtmlLabelName(1256 ,user.getLanguage())+",javascript:continueExcute(2),_self} " ;
		RCMenuHeight += RCMenuHeightStep ;
		RCMenu += "{"+"跳过整个脚本"+",javascript:skipall(),_self}" ;
		RCMenuHeight += RCMenuHeightStep ;
		RCMenu += "{"+SystemEnv.getHtmlLabelName(589 ,user.getLanguage())+",javascript:backup(),_self} " ;
		RCMenuHeight += RCMenuHeightStep ;
	}

}


%>
<%@ include file="/updateclient/systeminfo/RightClickMenu_Upgrade.jsp" %>
<body style="height:100%;width:100%;">
<form>

<table id="topTitle" cellpadding="0" cellspacing="0">
	<tr>
		<td></td>
		<td class="rightSearchSpan" style="text-align:right; width:500px!important"><%--
		<%if(pagestatus==3){%>
			<input type="button" value="<%=SystemEnv.getHtmlLabelName(33703 ,user.getLanguage()) %>" class="e8_btn_top" onclick="continueExcute(0)"/>
			<input type="button" value="<%=SystemEnv.getHtmlLabelName(17416 ,user.getLanguage()) %>" class="e8_btn_top" onclick="exportFile()"/>
		<%} else {%>
			<input type="button" value="<%=SystemEnv.getHtmlLabelName(1256 ,user.getLanguage()) %>" class="e8_btn_top" onclick="continueExcute(2)"/>
		<%}%>
		--%>
		<input type="button" value="<%=SystemEnv.getHtmlLabelName(354 ,user.getLanguage()) %>" class="e8_btn_top" onclick="myrefresh()"/>
		<%if(status ==1 || status==3){ %>
			<input type="button" value="<%=SystemEnv.getHtmlLabelName(589 ,user.getLanguage()) %>" class="e8_btn_top" onclick="backup()"/>
		<%} %>
		</td>
	</tr>
</table>
<body style="height:100%;width:100%;"> 
<div style="width:24%;height:100%;float:left;background:#fcfcfc;">
<jsp:include page="step.jsp"></jsp:include>
</div>

<div style="width:75%;height:100%;float:right">
		<div  style="height:380px;">
			<div  style="height:370px;width:100%;float:right;margin-top:10px;">
				<div style="height:100%;width:100%;background:white;text-align:left;">
					<div style="width:100%;height:100%;font-size:18px;" >
					<div class="titleclass" id="title" style="margin:0 auto;width:80%;font-size:16px;color:white;height:30px;line-height:30px;">&nbsp;&nbsp;</div>	
						<%
							if(0 == status) {//系统正常
						%>
							<div class="divcenter" style="margin:0 auto;width:80%;display:none">
								<div class=updating style="text-align:center;font-size:20px;"><img src="/wui/theme/ecology9/image/upgrade/upgrading.gif"><br/><br/>
								<p style="font-size:14px;font-family: 微软雅黑;font-weight: 400;font-style: normal;">
									升级中...
								</p>
							</div>
						<%} else if(1 == status) {//脚本报错
						
						%>
							<div class=updating style="text-align:center;font-size:20px;"><img src="/wui/theme/ecology9/image/upgrade/error.png"><br/><br/>
								<span class="msgstyle1" style="">升级不成功,升级脚本错误</span>
								<br/>
							</div>
							<div class="msgstyle2" style="text-align:center;">错误详情(<a href="javascript:showSQLError()"><%=infomap.get("errorlog") %></a>)如下:</div>
							<div class="sqlerrormsg" style="">
								<textarea style="width:99%;height:100%;overflow:auto;font-size:14px;"><%=errormsg %></textarea>
							</div>
							<div class="operationmsg" style="line-height: 20px">
								<div style="margin:0 auto;line-height:20px;height:20px!important;margin-top:5px;margin-bottom:5px;">
									<img src="/wui/theme/ecologyBasic/skins/default/rightbox/userlog_warning_wev8.gif" style="width:20px;vertical-align:middle;"></img>
									<span style="color:#FF9200;line-height:20px!important;vertical-align:middle;font-weight:bold;font-size:14px">错误处理:</span>
								</div>
								<span class="msgnote1">请检查脚本,如果脚本是以下报错,则可忽略错误,<a href="javascript:operationConfirm(2,'请确认您已经查看错误日志,已核实该SQL语句可以直接跳过');" style="color:rgb(0, 0, 255)" type="button">点击这里继续执行</a></span><br>
								<span class="msgnote1">1、数据库中已存在这个表或试图;</span><br>
								<span class="msgnote1">2、数据库中字段已存在;</span><br>
								<p class="msgnote2">如果不是以上情况,请确认错误是否可忽略;如果不能忽略,请将错误的脚本手动修改完成后,手动在数据库中执行,并将该SQL脚本拷贝到“/ecology/data”目录下,完成后重启Resin继续升级。</p>
								<p class="msgnote2">如果忽略了某些错误,使脚本继续执行,请将该脚本提交到范围项目/客服人员,由泛微技术部进行审核确认。</p>
							</div>
						
						<%} else if(2 == status) {%>
								<%if("true".equals(threadruning) && !"".equals(runningfilename)){ %>
									<div class=updating style="text-align:center;font-size:20px;"><img src="/wui/theme/ecology9/image/upgrade/upgrading.gif"><br/><br/>
									<span class="msgstyle1" style="color:#7ed321;font-size:20px;font-weight:bold;"><%=percent %></span>
									<p style="font-size:14px;font-family: 微软雅黑;font-weight: 400;font-style: normal;"><%=sqlmsg %></p>
									</div>
									<%if(executesql != null && !"".equals(executesql)){ %>
										<div class="msgstyle2" style="text-align:center;">正在执行的sql语句</div>
										<div class="executesqlmsg" style="">
										<textarea style="width:99%;height:100%;overflow:auto;font-size:14px;"><%=executesql %></textarea>
										</div> 
									<%} %>
								<%} else {%>
									<%if(false) { %>
										<div style="margin:0 auto;width:80%">
											<div class=updating style="text-align:center;font-size:20px;"><img src="/wui/theme/ecology9/image/upgrade/error.png"><br/><br/>
												<span class="msgstyle1" style="">升级过程中服务器异常中止或者重启了Resin服务,请停止服务,并手动修改/WEB-INF/prop/Upgrade.properties的status值为0。<br>也可点击“继续”按钮进行升级。</span>
											</div>
							
											<div class="divmid continuebtn divmargin" style=""><input class="continuebtn" type="button" onclick="operationConfirm(5,'重置Upgrade.properties状态');" value="继续" style="width:100%;height:100%"></div></div>
											</div>
										</div>
									<%} else {%>
										<div class="divcenter" style="margin:0 auto;width:80%;display:none">
											<div class=updating style="text-align:center;font-size:20px;"><img src="/wui/theme/ecology9/image/upgrade/upgrading.gif"><br/><br/>
											<p style="font-size:14px;font-family: 微软雅黑;font-weight: 400;font-style: normal;">
												升级中...
											</p>
										</div>
									<%}%>
								<%}%>
						<%
						} else if(4 == status) {//数据库地址确认页面
						%>
							<div style="margin:0 auto;width:80%;vertical-align:middle;text-align: center;">
							
							<div class=updating style="text-align:center;font-size:20px;"><img src="/wui/theme/ecology9/image/upgrade/upgrading.png"><br/>
							<p style="font-size:14px;font-family: 微软雅黑;font-weight: 400;font-style: normal;">
							<%=dbmsg %>
							<br>
							如果错误请修改后重启服务,如果正确请点击“继续”进行升级
							</p>
							<div class="operationmsg" style="height:32px!important;font-size: 12px;color:#FF9200;width:420px;">
							<img src="/wui/theme/ecologyBasic/skins/default/rightbox/userlog_warning_wev8.gif" style="width:20px;vertical-align:middle;line-height:30px!important;"></img>
							<span style="color:#FF9200;line-height:30px!important;vertical-align:middle;">如果数据库连接错误,将导致脚本执行到其他数据库,请认真检查!</span>
							</div>
							<div class="divmid continuebtn divmargin" style=""><input class="continuebtn"  onclick="operationConfirm(4,'确认已检查数据库连接地址正确,开始执行脚本?')" type="button" value="继续" style="width:100%;height:100%"></div></div>
							</div>
						<%
						} else if(3 == status){
						%>
							<div class="divcenter" style="margin:0 auto;width:80%;display:none">
									<div class=updating style="text-align:center;font-size:20px;"><img src="/wui/theme/ecology9/image/upgrade/error.png"><br/>
										<p style="font-size:14px;font-family: 微软雅黑;font-weight: 400;font-style: normal;">
										升级不成功,请联系供应商
										</p>
									</div>
							</div>
						<%
						} else {%>
							<div class="divcenter" style="margin:0 auto;width:80%;height:100%;display:none">
							<div class=updating style="text-align:center;font-size:20px;"><img src="/wui/theme/ecology9/image/upgrade/upgrading.gif"><br/><br/>
							<p style="font-size:14px;font-family: 微软雅黑;font-weight: 400;font-style: normal;">
								升级中...
							</p>
							
							<br/>
							</div>
						<%}%>
							
			            
					</div>
				</div>
			</div>
		</div>
</div>

</body>
</html>