upgradeCheck.jsp 34.7 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 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="weaver.general.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.text.Format" %>
<%@ page import="java.text.DecimalFormat" %>
<%@ page import="java.lang.reflect.Method" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="org.json.JSONObject" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.system.SysUpgradeCominfo" %>
<%@ page import="weaver.file.FileBackup" %>
<%@ page import="weaver.system.ThreadWorkTimer" %>
<%@ page import="java.lang.reflect.Constructor" %>
<%@ page import="weaver.system.ThreadWork" %>
<%
        String operationtype=Util.null2String(request.getParameter("operationtype"));
//        try{
//            Thread.sleep(1000);
//        }catch(Exception e){
//
//        }
        if("upgradeendecomfirm".equals(operationtype)){
            User weaver_confirm = (User) request.getSession(true).getAttribute("weaver_upgradeConfirm");
            User user = HrmUserVarify.getUser (request , response) ;
            int userid = 0;
            boolean isadmin = false;
            if(user==null) {
                //return;
            } else {
                if(weaver_confirm == null) {
                    return;
                }
                userid = user.getUID();
                String loginid = user.getLoginid();
                request.getSession(true).removeAttribute("weaver_user@bean");
                RecordSet rs2 = new RecordSet();
                rs2.executeQuery("select 1 from hrmresourcemanager where loginid = ?",loginid);
                if(rs2.next()) {
                    isadmin = true;
                }

            }
            if(!isadmin){
            %>
<HTML>
<BODY style="width:100%;height:100%;position:relative;">
<div class="contentdiv" style="text-align:center">
    <img id="img" src="/images/ecology8/noright_wev8.png" />
    <div style="margin-top:20px;" id="message">请先使用管理员账号登录,确认升级信息;再重新登录。</div>
</div>
</body>
</HTML>
<%} else {
            /**
             * 获取路径的信息
             */
            //文件的路径
            String filepath="";
            //文件的备份路径
            String fileBakPath="";
            BaseBean basebean=new BaseBean();
            String isnoneedbakupset=Util.null2String(basebean.getPropValue("upgradesetting","isnoneedbakupset"));//是否不需要备份周期
            String  filesystembackuptime="";
            RecordSet rs1=new RecordSet();
            rs1.execute("select  filesystem,filesystembackup,filesystembackuptime from systemset");
            if(rs1.next()) {
                filepath = Util.null2String(rs1.getString("filesystem"));
                fileBakPath = Util.null2String(rs1.getString("filesystembackup"));
                filesystembackuptime = Util.null2String(rs1.getString("filesystembackuptime"));
            }
            if("0".equals(filesystembackuptime)){
                filesystembackuptime="";
            }
            if( filepath.equals("") ){
                filepath = GCONST.getSysFilePath() ;
            }
            if(!"".equals(filesystembackuptime)){
                if( fileBakPath.equals("") ){
                    fileBakPath = GCONST.getSysFileBackupPath() ;
                }

                try{
                    long backuptime=Util.getIntValue(filesystembackuptime);
                    if(backuptime>(60*24)){
                        rs1.execute("update SystemSet set filesystembackuptime='"+(60*24)+"' ");
                        filesystembackuptime=60*24+"";
                        FileBackup fileBackup=new FileBackup();
                        Class class1=Class.forName("weaver.system.ThreadWorkTimer");
                        if(class1!=null){
                            Constructor c = class1.getConstructor(long.class,ThreadWork.class);
                            if(c!=null){
                                ThreadWorkTimer threadWork=(ThreadWorkTimer)c.newInstance(24*60*60,fileBackup);
                                if(threadWork!=null){
                                    threadWork.start();
                                }
                            }
                        }
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
//	if(!filesystembackuptime.equals("")){
//	    int bakuptime=Integer.parseInt(filesystembackuptime);
//		bakuptime=bakuptime/60;
//		if(bakuptime<0){
//			bakuptime=0;
//		}
//		if(bakuptime>24){
//			bakuptime=24;
//		}
//		filesystembackuptime=""+bakuptime;
//	}




/**
 * 检测补丁包跳包情况
 *
 **/
            List<String> packageList=new ArrayList<String>();
            String latestPackageNo="";
            String systemInfo="";//补丁包编号信息
            String allmissPackageNo="";//全部缺失的补丁号信息
            String missPackageNo="";//缺失的补丁号信息
            boolean showinfodetail=false;
            RecordSet rs=new RecordSet();

            rs.execute("select label from ecologyuplist order by label desc");

            while(rs.next()){
                packageList.add(rs.getString(1));
            }
            if(packageList.size()>=1){
                latestPackageNo = packageList.get(0);
            }


/**
 * 是否部署运维平台
 */
            boolean haveOperationMaintance=false;
            try{
                String path=GCONST.getRootPath()+File.separatorChar+"join"+File.separatorChar+"Ln.jsp";
                File file=new File(path);
                if(file.exists()){
                    haveOperationMaintance=true;
                }
            }catch(Exception e){
                new BaseBean().writeLog("判断运维平台是否存在失败");
            }


            if(!latestPackageNo.equals("")){
// 	latestPackageNo=(String)packageList.get(0);
                systemInfo+="  当前系统最新补丁包编号:<span style=\"color:red\">"+latestPackageNo+"</span>";
                Format f1 = new DecimalFormat("000");
                int lastpacknumer=Integer.valueOf(latestPackageNo);
                for(int i=1;i<6;i++){
                    if(!packageList.contains(f1.format(lastpacknumer-i))){
                        missPackageNo+=f1.format(lastpacknumer-i)+"、";
                    }
                }
                if(!missPackageNo.equals("")){
                    missPackageNo = missPackageNo.substring(0, missPackageNo.length()-1);
                    allmissPackageNo=allmissPackageNo+missPackageNo;
                    if(missPackageNo.length()>31){
                        //allmissPackageNo=allmissPackageNo+missPackageNo;
                        missPackageNo=missPackageNo.substring(0,30);
                        missPackageNo=missPackageNo.substring(0,missPackageNo.lastIndexOf("、"))+"....";
                    }
                    systemInfo+=";补丁包出现跳包,跳包情况(<a href='javascript:showpackinfo()'>"+missPackageNo+"</a>)";
                }else{
                    systemInfo+="  补丁包打包情况:正常";
                }
            }else{
                systemInfo+="  未获取到当前系统最新补丁包编号";
            }
    %>
<html>
<head>
    <title>升级完成确认页面</title>
</head>
<style type="text/css">
    *{
        margin:0 auto;
        padding:0;
    }
    body{
        background-color: #F0F5FF;
        width: 100%;
        height: 100%;
    }
    .container{
        margin:0 auto;
        width: 100%;
        height: auto;
        background-color: white;

    }
    .borderlink{
        font-size: 12px;
        margin-bottom: 10px;
        border-bottom: 1px solid #e0e0e0;
    }

    .titleclass{
        font-size: 14px;
        font-weight: bold;
        color: #384009;
    }
</style>

<script src="/js/updateclient/jquery-1.8.3.min_wev8.js"></script>
<body class="allbackground" style="width:70%;background-color: white">
<div class="container">
    <table style="width:100%;height: auto;rules:rows;" cellspacing="0" cellpadding="0">
        <tr style="height: 50px;">
            <td style="background-color:#eaeaea;font-weight: bolder; color: #384009;width: 100%;border-bottom: 1px solid #e0e0e0;">
                &nbsp;升级完成确认页面
            </td>

        </tr>

        <tr style="height: 30px;"  >
            <td class="titleclass" >
                &nbsp;文件自动备份信息
            </td>
        </tr>
        <tr style="height: 100px;;font-size: 12px" >
            <td  class="borderlink" >
                <div style="margin-bottom: 20px;margin-left: 100px">
                    <table  width="100%" height="100%" style="border-collapse:separate; border-spacing:10px;font-size: 12px;">
                        <tr>
                            <td style=" width: 200px;color: #333;">文件存放目录</td>
                            <%
                                if(filesystembackuptime.equals("")){
                            %>
                            <%--<td><input type="text" id="filepath" name="filepath" style="width: 500px;" value="<%=filepath%>"/></td>--%>
                            <td><%=filepath%></td>
                            <%
                            }else{%>
                            <td><%=filepath%></td>
                            <%}%>
                        </tr>
                        <tr>
                            <td style="width: 200px;color: #333;">文件备份目录</td>
                            <%
                                if(filesystembackuptime.equals("")){
                            %>
                            <td><input type="text" id="filebakpath" name="filebakpath" style="width: 500px;"  value="<%=fileBakPath%>" /></td>
                            <%
                            }else{%>
                            <td><%=fileBakPath%></td>
                            <%}%>
                        </tr>
                        <tr>
                            <td style="width: 200px;color: #333;">文件备份周期</td>
                            <td>
                                <%--<input type="number" id="timenuber" name="timenuber" style="width: 100px;" min="0" max="24" value="<%=filesystembackuptime%>"/>--%>

                                <%
                                    if(filesystembackuptime.equals("")){
                                        String isselect="";
//												isselect=filesystembackuptime.equals(i+"")?" selected = \"selected\"":"";
                                %><select name="filesystembackuptime" id="filesystembackuptime" value="<%=filesystembackuptime%>" style="width: 100px;">
                                <option value=""></option>
                                <%for(int i=1;i<=24;i++){%>
                                <option value="<%=i%>"><%=i%>小时</option>

                                <%}%>
                            </select>
                                <%--<span style="color:red;font-size: 10px">(文件备份周期需要重启才能生效)</span>--%>
                                <%
                                }else{%>
                                <%=filesystembackuptime%>分钟
                                <%}%>
                                <%--<button type="button" onclick="dosave()" style="color: #fff;border-radius: 2px;padding:2px 10px;background-color: #2db7f5;border-color: #2db7f5;font-weight: 500;text-align: center"> </button>--%>
                            </td>
                        </tr>
                    </table>
                    <div style="width: 90%;margin: 0 auto; font-size: 10px;color: red;margin-left: 60px;">
                        <span style="float: left;">信息:</span>
                        <ul  style="list-style: none;width: 80%;float: left;">
                              <li style="float: left;width: 80%;" >
                                   1.已备份文件:<span id="bakSpaceSize">计算中</span>;自动备份所需的空间:<span id="needBakFileSize">计算中</span>;请确认文件备份目录空间大于自动备份目录空间的1.5倍。<br/>
                               </li>
                               <li style="width: 80%;float: left">
                                    2.强烈建议设置“文件备份周期”开启自动备份功能,防止文件数据丢失,也可以在“后端应用中心-系统设置页面”修改配置。</br>
                               </li>
                           </ul>

                        </p>
                        <br/>
                    </div>
                </div>
            </td>
        </tr>






        <tr style="height: 30px;margin-top: 20px" >
            <td class="titleclass">
                &nbsp;升级记录
            </td>
        </tr>
        <tr style="height: auto;font-size: 12px" >
            <td   class="borderlink"  width="100%;" height="auto">
                <div width="95%" style="margin-bottom: 10px;margin-left: 100px">
                    <ul style="list-style: none;line-height: 30px">
                        <%
                            rs.execute("select * from ecologyuplist order by label desc");
                            if(rs.next()){
                                String packagelabel=Util.null2String(rs.getString("label"));
                                String packagename=Util.null2String(rs.getString("versionNo"));

                        %>

                        <li style="position: relative;width: 80%;float: left;">
                            最新补丁包编号:<%=packagelabel%>
                        </li>
                        <li style="position: relative;width: 80%;float: left;">
                            最新补丁包名称:<%=packagename%>
                        </li>

                        <%}else{%>
                        <li style="position: relative;width: 80%;float: left;">
                            未有补丁包升级记录
                        </li>
                        <%}%>
                    </ul>
                </div>
            </td>
        </tr>
        <tr style="height: 30px;margin-top: 40px" >
            <td class="titleclass">
                &nbsp;安全补丁包版本
            </td>
        </tr>
        <tr style="height: 100px;font-size: 12px" >
            <td  class="borderlink" style="">
                <div style="width: 95%;color: #333; font-size: 12px;margin-left: 100px">
                    <div id="issercurityloading">
                        <span>正在加载安全补丁包信息!</span>
                    </div>
                    <div id="issercurity"style="display:none">
                        <ul style="list-style: none;line-height: 30px">
                            <li style="position: relative;width: 80%;float: left;">
                                客户端安全包软件版本:<span id="securityversion"></span>
                            </li>
                            <li style="position: relative;width: 80%;float: left;">
                                客户端安全包规则库版本:<span id="securityRuleVersion"></span>
                            </li>
                            <li style="position: relative;width: 80%;float: left;">
                                泛微官网安全包软件版本:<span id="securityNeweversion"></span>
                            </li>
                            <li style="position: relative;width:80%;float: left;">
                                泛微官网安全包规则库版本:<span id="securityRuleNewversion"></span>
                            </li>
                            <li style="position: relative;width: 80%;float: left;">
                                <span style="">安全补丁包下载地址:https://www.weaver.com.cn/cs/securityDownload.asp</span>
                            </li>
                        </ul>
                    </div>
                    <div id="isnosercurity" style="display:none">
                        <h5>当前系统未覆盖安全补丁包!</h5>
                        <br/>
                        <span >安全补丁包下载地址:https://www.weaver.com.cn/cs/securityDownload.asp</span>
                    </div>
                </div>
            </td>
        </tr>

        <tr style="height: 30px;margin-top: 20px" >
            <td class="titleclass">
                &nbsp;是否部署运维平台
            </td>
        </tr>
        <tr style="height: 40px;font-size: 12px" >
            <td   style="">
                <div style="width: 100%;margin-left: 100px;line-height: 20px" >
                    <%if(haveOperationMaintance){%>
                    <h5>当前系统已部署运维平台</h5>
                    <%}else{%>
                    <h5>当前系统未部署运维平台</h5>
                    <%}%>
                    <span >运维平台下载地址:https://www.weaver.com.cn/cs/monitorDownload.asp</span>
                </div>

            </td>
        </tr>


        <tr style="height: auto;font-size: 12px;" >
            <td style="" width="100%;" height="auto" >
                <div style="width: 100%;margin-left: 100px;margin-top: 20px">
                    <button type="button" onclick="dosubmit()"style="color: #fff;border-radius: 2px;padding:2px 10px;background-color: #2c91E6;font-size:20px;text-align: center">
                        确认升级完成
                    </button>
                </div>
            </td>
        </tr>

        </tbody>
    </table>
</div>
</body>

<script language="javascript" type="text/javascript">

    function dosubmit(){
        <% if(filesystembackuptime.equals("")){%>
          dosave();
        <%}else{%>
         donext();
        <%}%>
    }

    function donext(){
        window.location.href = "/login/upgradeCheck.jsp?operationtype=upgradefinished";
        return
    }
    /**
     * 获取安全补丁包信息
     */
    function getSercurity(){
        jQuery.ajax({
            type:"POST",
            url:'/login/upgradeCheck.jsp',
            dataType:"json",
            data:{
                operationtype:'getsecurityinfo',
            },
            success:function(data){
                if(data.status=="1"){//已部署安全补丁包
                    $("#issercurityloading").css('display','none');//隐藏
                    $("#issercurity").css('display','block');//显示
                    $("#isnosercurity").css('display','none');//显示
                    $("#securityversion").text(data.securityversion);
                    $("#securityRuleVersion").text(data.securityRuleVersion);
                    $("#securityNeweversion").text(data.securityNeweversion);
                    $("#securityRuleNewversion").text(data.securityRuleNewversion);
                }else{
                    $("#issercurityloading").css('display','none');
                    $("#issercurity").css('display','none');//显示
                    $("#isnosercurity").css('display','block');//显示
                }
                $("#bakSpaceSize").text(data.bakSpaceSize+"M");
                $("#needBakFileSize").text(data.needBakFileSize+"M");
            }
        })
    }

    function dosave(){
        var str = jQuery("#filesystembackuptime").val();
        // var filepath=jQuery("#filepath").val();
        var filebakpath=jQuery("#filebakpath").val();
        if(str=="" ||str=="0"){
            <% if(isnoneedbakupset.equals("1")){%>
                if(confirm('文件备份周期未选择,确定继续吗?')){
                    donext();
                }
            <%}else{%>
                  alert("文件备份周期未选择");
            <%}%>

        }else{
            if(confirm('将更新文件备份周期和目录,可在后端系统设置页面进行修改!')){
                jQuery.ajax({
                    type:"POST",
                    url:'/login/upgradeCheck.jsp',
                    dataType:"json",
                    data:{
                        filesystembackuptime:str,
                        operationtype:'upgradeendecomfirmsave',
                        filebakpath:filebakpath
                    },
                    success:function(data){
                        if(data.status=="1"){
                            alert(data.message);
                        }else{
                            donext();
                        }
                    }
                })
            }

        }
    }
    jQuery(document).ready(function(){
        getSercurity();
        // getsysinfo();
    });
</script>
</html>
    <%}%>
<%}else if("getsecurityinfo".equals(operationtype)) {
    JSONObject json=new JSONObject();
    String securityversion="";//本机安全补丁包版本
    String securityRuleVersion="";//本机规则版本
    String securityNeweversion="";//新的安全补丁包版本
    String securityRuleNewversion="";//新的规则版本
    boolean issecurity=true;
    try{
        Class class1=Class.forName("weaver.filter.msg.CheckSecurityUpdateInfo");
        if(class1!=null){
            Object checksevurityUpdateInfo=class1.newInstance();
            Method getRemoteServerVersion=class1.getMethod("getRemoteServerVersion");
            if(getRemoteServerVersion!=null){
                getRemoteServerVersion.invoke(checksevurityUpdateInfo);//获取安全补丁版本
            }
            Method getVersion=class1.getMethod("getVersion");
            if(getVersion!=null){
                securityversion=(String)getVersion.invoke(checksevurityUpdateInfo);//安全补丁包版本
            }
            Method getRuleVersion=class1.getMethod("getRuleVersion");
            if(getRuleVersion!=null){
                securityRuleVersion=(String)getRuleVersion.invoke(checksevurityUpdateInfo);//安全补丁包版本

            }

            Method getNewversion=class1.getMethod("getNewversion");
            if(getNewversion!=null){
                securityNeweversion=(String)getNewversion.invoke(checksevurityUpdateInfo);//安全补丁包版本

            }
            Method getRuleNewVersion=class1.getMethod("getRuleNewVersion");
            if(getRuleNewVersion!=null){
                securityRuleNewversion=(String)getRuleNewVersion.invoke(checksevurityUpdateInfo);//安全补丁包版本
            }
            json.put("status","1");
            json.put("securityversion",securityversion);
            json.put("securityRuleVersion",securityRuleVersion);
            json.put("securityNeweversion",securityNeweversion);
            json.put("securityRuleNewversion",securityRuleNewversion);
        }else{
            json.put("status","0");

            //issecurity=false;
        }

    }catch(Exception e){
        e.printStackTrace();
        new BaseBean().writeLog("系统未部署安全补丁包");
        json.put("status","0");
    }

    long  needBakFileSize=0;//需要备份的文件大小
    long bakSpaceSize=0;//已经备份的文件大小

    RecordSet rs1=new RecordSet();

    /**
     * 计算需要备份文件的大小
     */
    StringBuffer bakFileIds=new StringBuffer();
    int index=0;
    //计算已经备份的空间的大小
    rs1.executeQuery(" select distinct imageFileId from ImageFileBackUp ");

    while(rs1.next()){
        index++;
        if(bakFileIds.length()>0){
            bakFileIds.append(",'"+Util.null2String(rs1.getString("imageFileId"))+"'");
        }else{
            bakFileIds.append("'"+Util.null2String(rs1.getString("imageFileId"))+"'");
        }
        if(index>100){
            RecordSet rstemp=new RecordSet();
            rstemp.executeQuery("select  fileSize from imagefile where imagefileid in("+bakFileIds+")");
            while(rstemp.next()){
                try{
                    String tem=Util.null2String(rstemp.getString("fileSize"));
                    if(tem.equals("")||tem.equals("-1")){
                        continue;
                    }

                    needBakFileSize=needBakFileSize+Integer.parseInt(tem);
                }catch(Exception e){
                    e.printStackTrace();
                }
            }
            bakFileIds=new StringBuffer();
            index=0;
        }
    }

    bakFileIds=new StringBuffer();
    index=0;
    rs1.executeQuery(" select distinct mailResourceFileid from MailResourceFileBackup ");
    while(rs1.next()){
        index++;
        if(bakFileIds.length()>0){
            bakFileIds.append(",'"+Util.null2String(rs1.getString("mailResourceFileid"))+"'");
        }else{
            bakFileIds.append("'"+Util.null2String(rs1.getString("mailResourceFileid"))+"'");
        }
        if(index>100){
            RecordSet rstemp=new RecordSet();
            rstemp.executeQuery("select  filesize from MailResourceFile where id in("+bakFileIds+")");
            while(rstemp.next()){
                try{
                    String tem=Util.null2String(rstemp.getString("fileSize"));
                    if(tem.equals("")||tem.equals("-1")){
                        continue;
                    }
                    needBakFileSize=needBakFileSize+Integer.parseInt(tem);
                }catch(Exception e){
                    e.printStackTrace();
                }
            }
            bakFileIds=new StringBuffer();
            index=0;
        }
    }


    rs1.executeQuery("select  lastbackupimagefileid,lastbackupmailfileid from FileBackupIndex");
    String lastbackupimagefileid="";//知识最后备份的id
    String  lastbackupmailfileid="";//邮件最后备份的id
    if(rs1.next()){
        lastbackupimagefileid=Util.null2String(rs1.getString("lastbackupimagefileid"));
        lastbackupmailfileid=Util.null2String(rs1.getString("lastbackupmailfileid"));
    }
    if(lastbackupimagefileid.equals("")){
        lastbackupimagefileid="0";
    }
    if(lastbackupmailfileid.equals("")){
        lastbackupmailfileid="0";
    }
    //   new  BaseBean().writeLog("执行的sql:"+" select filesize from imagefile where imageFileId>"+lastbackupimagefileid);
    rs1.executeQuery(" select filesize from imagefile where imageFileId>?",lastbackupimagefileid);
    while(rs1.next()){
        try{
            String tem=Util.null2String(rs1.getString("fileSize"));
            if(tem.equals("")||tem.equals("-1")){
                continue;
            }
            needBakFileSize=needBakFileSize+Integer.parseInt(tem);
        }catch(Exception e){
            e.printStackTrace();
        }
    }
    rs1.executeQuery(" select  filesize from MailResourceFile where id>?",lastbackupmailfileid);
    // new  BaseBean().writeLog(needBakFileSize+"执行的sql:"+" select  filesize from MailResourceFile where id>"+lastbackupmailfileid);
    while(rs1.next()){
        try{
            String tem=Util.null2String(rs1.getString("filesize"));
            if(tem.equals("")||tem.equals("-1")){
                continue;
            }
            needBakFileSize=needBakFileSize+Integer.parseInt(tem);

        }catch(Exception e){
            e.printStackTrace();
        }
    }


    /**
     * 计算已经备份的文件大小
     */

    rs1.executeQuery(" select filesize from imagefile where imageFileId<=?",lastbackupimagefileid);
    while(rs1.next()){
        try{
            String tem=Util.null2String(rs1.getString("fileSize"));
            if(tem.equals("")||tem.equals("-1")){
                continue;
            }
            bakSpaceSize=bakSpaceSize+Integer.parseInt(tem);
        }catch(Exception e){
            e.printStackTrace();
        }
    }
    rs1.executeQuery(" select  filesize from MailResourceFile where id<=?",lastbackupmailfileid);
    // new  BaseBean().writeLog(needBakFileSize+"执行的sql:"+" select  filesize from MailResourceFile where id>"+lastbackupmailfileid);
    while(rs1.next()){
        try{
            String tem=Util.null2String(rs1.getString("filesize"));
            if(tem.equals("")||tem.equals("-1")){
                continue;
            }
            bakSpaceSize=bakSpaceSize+Integer.parseInt(tem);

        }catch(Exception e){
            e.printStackTrace();
        }
    }

    if(needBakFileSize<=0){
        needBakFileSize=0;
    }else{
        needBakFileSize= (int)Math.ceil(needBakFileSize*1.000000/(1024*1024));
    }
    if(bakSpaceSize<=0){
        bakSpaceSize=0;
    }else{
        bakSpaceSize=(int)Math.ceil(bakSpaceSize*1.000000/(1024*1024));
    }
    //new  BaseBean().writeLog("已经备份的:"+bakSpaceSize+"-----------------需要备份的---"+needBakFileSize);
    json.put("needBakFileSize",needBakFileSize);
    json.put("bakSpaceSize",bakSpaceSize);




    response.getWriter().print(json.toString());
    return;
}else if("upgradeendecomfirmsave".equals(operationtype)) {
    User weaver_confirm = (User) request.getSession(true).getAttribute("weaver_upgradeConfirm");

    if(weaver_confirm == null) {
        return;
    }
    /**
     * 执行保存系统周期的操作
     */
    JSONObject json=new JSONObject();

    String filesystembackuptime=Util.null2String(request.getParameter("filesystembackuptime"));
    String filebakpath=Util.null2String(request.getParameter("filebakpath"));
   // String filepath = Util.null2String(request.getParameter("filepath"));
    new BaseBean().writeLog("文件备份周期:"+filesystembackuptime);
    if(filesystembackuptime.equals("")){
        json.put("status","1");
        json.put("message","文件备份周期不能为空");
    }else{
        try{
            int backuptime=Integer.parseInt(filesystembackuptime);
            if(backuptime<0||backuptime>24){
                json.put("status","1");
                json.put("message","文件备份周期不符合规则");
            }else{

                if(!"".equals(filebakpath)){
                    File file=new File(filebakpath);
                    if(!file.exists() || !file.isDirectory()){
                        json.put("status","1");
                        json.put("message","文件备份目录不存在");
                        response.getWriter().print(json.toString());
                        return;
                    }
                }

                backuptime=backuptime*60;
                RecordSet rs=new RecordSet();
                String sql="update SystemSet set filesystembackuptime='"+backuptime+"' ";

                if(!"".equals(filebakpath)){
                        sql=sql+" ,filesystembackup='"+filebakpath+"'";
                }
                rs.execute(sql);
                //使用反射的方法然设置及时生效
                try{
                    FileBackup fileBackup=new FileBackup();
                    Class class1=Class.forName("weaver.system.ThreadWorkTimer");
                    if(class1!=null){
                        Constructor c = class1.getConstructor(long.class,ThreadWork.class);
                        if(c!=null){
                            ThreadWorkTimer threadWork=(ThreadWorkTimer)c.newInstance(backuptime*60,fileBackup);
                            if(threadWork!=null){
                                threadWork.start();
                            }
                        }
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }

                json.put("status","0");
            }
        }catch(Exception e){
            e.printStackTrace();
            json.put("status","1");
            json.put("message","文件备份周期保存出错,请联系技术人员进行解决");
        }
    }
    response.getWriter().print(json.toString());
    return;
} else if("upgradefinished".equals(operationtype)){
    User weaver_confirm = (User) request.getSession(true).getAttribute("weaver_upgradeConfirm");

    if(weaver_confirm != null) {
        SysUpgradeCominfo.hasUpgradeConfirm = "1";
        RecordSet rs3 = new RecordSet();
        rs3.executeUpdate("update UpgradeCheckInfo set upgradeconfirm='1'");
        request.getSession(true).setAttribute("weaver_user@bean",weaver_confirm);
        response.sendRedirect("/wui/index.html?#/main");
        return;
    }
}else{%>
<head>
<style>
.btnclass {
	margin-top:50px;
	margin-left:50px;
	widht:300px;
	height:30px;
}
</style>

<script type="text/javascript">
var returnflage = 0;
function continueExcute(obj) {
	if(obj == 1) {
		if(true){
			$.ajax({
				url:"/login/continueExcute.jsp",
				type:"post",
				datatype:"json",
				success:function(data){
					if(data) {
						window.location.href="/login/Upgrade.jsp";
					}
					
				}
			});
		} 
	}else if(obj == 2){
		if(true){
			$.ajax({
				url:"/login/continueExcute.jsp",
				type:"post",
				datatype:"json",
				success:function(data){
					if(data) {
						window.location.href="/login/Upgrade.jsp";
					}
				}
			});
		} 
	} else if(obj == 4){
		if(true){
			$.ajax({
				url:"/login/continueExcute.jsp?type=checkecologydburl",
				type:"post",
				datatype:"json",
				success:function(data){
					if(data) {
					    if(data != undefined && data.indexOf("systemupgrade-threaderror") > -1) {
					        alert("启动异常导致升级状态异常,请重启一次oa服务");
					        return;
                        } else {
                            window.location.href="/login/Upgrade.jsp";
                        }

					}
				}
			});
		} 
	}else {
		$.ajax({
			url:"/login/continueExcute.jsp",
			type:"post",
			datatype:"json",
			success:function(data){
				if(data) {
					window.location.href="/login/Login.jsp";
				}
			}
		});
	}
}

function showSQLError() {
	$("#alllog").val(0);//只显示sql报错信息
	document.form1.submit();
}
function stopExcute(obj){
	alert('请关闭Resin!')
}
function exportFile() {
       //var form = $("<form name='formdow'>");   //定义一个form表单
       //form.attr('style','display:none');   //在form表单中添加查询参数
       //form.attr('target','');
       //form.attr('method','post');
       //form.attr('action',"exportFile.jsp"); 
       //$('body').append(form);  //将表单放置在web中
      //form.append(input1);   //将查询参数控件提交到表单上
      $("#alllog").val(1);
       document.form1.submit();
}

function showLog(path) {
	doOpen("/login/errorMessage.jsp?path="+path,"升级错误日志");
}

var dWidth = 600;
var dHeight = 500;
function doOpen(url,title){
	if(typeof dialog  == 'undefined' || dialog==null){
		dialog = new window.top.Dialog();
	}
	dialog.currentWindow = window;
	dialog.Title = title;
	dialog.Width =  dWidth || 500;
	dialog.Height =  dWidth || 300;
	dialog.Drag = true;
	dialog.maxiumnable = true;
	dialog.URL = url;
	
	dialog.show();
}
function skipall(sqlname) {
	if(confirm('请确认这个脚本已在数据库手动执行,否则不能直接跳过!')){
		$.ajax({
			url:"/login/continueExcute.jsp?skipall=1",
			type:"post",
			datatype:"json",
			success:function(data){
				if(data) {
					window.location.href="/login/Upgrade.jsp";
				}
				
			}
		});
	}
}
</script>
</head>
<form name="form1" action="exportFile.jsp" type="post">
<input type="hidden" id="alllog" name="alllog" value="1"></input>
</form>
<%}%>