hdw
2019-01-11 0cbbb7131e744ba9b8000da3086c5dce635fa582
gx_tieta/WebRoot/js/base.js
@@ -19,14 +19,14 @@
function exitUser(){
   $.post("LoginAction!exitUser",null,function(data){
      //console.info(data);
      window.location.replace("login.jsp");
   });
   window.location.replace("login.jsp");
}
// 检查当前用户是否在另一主机登陆
function checkUserlogin(){
   //console.info("check");
   console.info("check***********************");
   $.post("LoginAction_check",null,function(data){
      data = eval("(" + data.result + ")");
      user=data.uinf;
@@ -38,7 +38,7 @@
         window.location.href="login.jsp";         
      }else{
         clearInterval(timeID);
         timeID = setTimeout(checkUserlogin,5000);
         timeID = setTimeout(checkUserlogin,100);
      }
   }).error(function(){
      clearInterval(timeID);
@@ -380,17 +380,17 @@
      //data=eval("("+data+")");
      data=data.result;
      data=eval("("+data+")");
      console.info(data);
      //console.info(data);
      if(data.code==1){
         if(data.data.length>0){
            data=data.data[0];
            document.getElementById("StationId").innerHTML=data.StationId;               //机房id
            document.getElementById("StationName").innerHTML=data.StationName;            //机房名称
            document.getElementById("StationIP").innerHTML=data.StationIp;               //机房ip
            //document.getElementById("batt_group_id").innerHTML=data.BattGroupId;         //电池组ip
            document.getElementById("batt_group_id").innerHTML=data.BattGroupId;         //电池组ip
            
            document.getElementById("BattGroupName").innerHTML=data.BattGroupName;         //电池组名称
            document.getElementById("BattGroupNum").innerHTML=data.BattGroupNum;         //电池组序号
            document.getElementById("BattGroupNum").innerHTML=data.GroupIndexInFBSDevice+1;         //电池组序号
            document.getElementById("BattProducer").innerHTML=data.BattProducer;         //电池品牌
            document.getElementById("BattModel").innerHTML=data.BattModel;               //电池型号
            document.getElementById("MonCapStd").innerHTML=data.MonCapStd;               //标称容量
@@ -412,7 +412,7 @@
            //console.info(data);
            document.getElementById("FBSDeviceIp").innerHTML=data.FbsDeviceIp;         //设备Ip
            document.getElementById("GroupIndexInFBSDevice").innerHTML=data.GroupIndexInFBSDevice;         //Bindex
            document.getElementById("installUser").innerHTML= data.install_user;   // 安装人员
            
            //显示电池组机历卡
            $('#card_infor').show();
@@ -422,6 +422,64 @@
   });
}
//根据stationid查询基站的信息
function findStationInfoByStation(temp){
   //console.info(JSON.stringify(temp));
   $.ajax({
        type:"post",
        url: "Battinf_exAction!serchByCondition",
        async:true,
        dataType:'json',
        data:"json="+JSON.stringify(temp),
        success: function(data){
         var model = eval('('+data.result+')');
         //console.log(model);
         if(model.code == 1 && model.data.length>0){
            var station = model.data[0];
            //console.info(station);
            $('#station_stationid_ex').text(temp.StationId_ex);                                 //站点id
            $('#station_stationname').text(station.stationName);                              //机房名称
            $('#station_stationid').text(station.stationId);                                 //机房名称
            $('#station_affiliation').text(station.affiliation);                              //所属组织
            $('#station_dataSources').text(station.dataSources);                              //数据来源
            $('#station_stationType').text(station.stationType);                              //站址类型
            $('#station_jinweidu').text("经度:" + station.longitude+";纬度:"+station.latitude);         //经纬度
            $('#station_stationAddr').text(station.stationAddr);                              //所在地址
            $('#station_stationstate').text("站址等级:"+station.stationLevel+";维护状态:"+station.maintenanceState+";封锁状态:"+(station.blockedState==0?'否':'是'));         //机房状态
            $('#station_maintenanceCompany').text(station.maintenanceCompany);                                                                        //维护单位
            $('#station_stationscenario').text("业务场景:"+station.businessScenario+";覆盖场景:"+station.CoverScenario+";站址地形:"+station.siteTerrain);                  //站址场景
            $('#station_stationproperty').text("产权性质:"+station.propertyRights+";(原)产权单位:"+station.propertyUnit+";是否共享:"+(station.isShare==1?'是':'否'));         //站址产权
            $('#station_useUnit').text(station.useUnit);                              //使用单位
            $('#station_siteCode').text(station.siteCode);                              //物理站址编码
            $('#station_historySiteCode').text(station.historySiteCode);                  //历史物理站址编码
            $('#station_siteInternalNumber').text(station.siteInternalNumber);               //站址内部编号
            $('#station_sitePinyinReferred').text(station.sitePinyinReferred);               //站址拼音简称
            $('#station_siteChineseReferred').text(station.siteChineseReferred);            //中文简称
            $('#station_isOpenBusiness').text(station.isOpenBusiness);                     //是否开通业务
            $('#station_schoolPersonnel').text(station.schoolPersonnel);                  //录入人员
            $('#station_entryTime').text(station.entryTime);                           //录入时间
            $('#station_modifyPeople').text(station.modifyPeople);                        //修改人
            $('#station_modifyTime').text(station.modifyTime);                           //修改时间
            $('#station_note').text(station.note);                                    //备注
            $('#station_receiveorvalidity').text("站址接收标记:"+(station.siteReceivesMark==1?'是':'否')+";是否有效:"+(station.siteValidity==1?'是':'否'));                                    //备注
            $('#station_siteNameCMCC').text(station.siteNameCMCC);                        //移动站址名称
            $('#station_siteNameCTC').text(station.siteNameCTC);                        //联通站址名称
            $('#station_siteNameCUCC').text(station.siteNameCUCC);                        //电信站址名称
            $('#station_producer').text(station.producer);                              //品牌
            $('#station_lastTimeLong').text(station.lastTimeLong);                        //续航测算时长
            $('#station_lastTimeType').text(station.lastTimeType);                        //续航测算类别
            $('#station_lastTimeDate').text(station.lastTimeDate);                        //续航发生时间
            $('#station_shareInfo').text(station.shareInfo);                           //共享情况
            $('#station_electPower').text("移动购买:"+(station.electPowerCMCC==1?'是':'否')+";电信购买:"+(station.electPowerCTC==1?'是':'否')+";联通购买:"+(station.electPowerCUCC==1?'是':'否'));                           //共享情况
            $('#station_isCanElectPower').text(station.isCanElectPower==1?'是':'否');         //是否具备发电条件
            $('#station_upperStationRoute').text(station.upperStationRoute);               //上站路程
            $('#station_upperStationDifficult').text(station.upperStationDifficult);         //上站难易程度
            $('#station_clienteleErrorService').text(station.clienteleErrorService);         //客户问题库未完成蓄电池维修
         }
       }
   });
}
   
//根据num获取故障类型和故障排除方法
@@ -512,7 +570,7 @@
   return null; 
}
function createEleWarning(num){
function createEleWarning(num, muted){
   //清理告警框
   $('body').children('#eleWarning').remove();
   var __divCon=$('<div id="eleWarning"></div>');  //告警容器
@@ -529,6 +587,10 @@
   var __divContentCon=$('<div class="warning-content"></div>');   //告警内容容器
   /* 告警的音频*/
   var __divAudio=$('<audio autoplay="autoplay"></audio>');
   // 判断是否静音
   if(muted) {
      __divAudio=$('<audio autoplay="autoplay" muted></audio>');
   }
   var __divSourceWav=$('<source src="sound/warnings.wav" type="audio/wav" />');
   var __divSourceMp3=$('<source src="sound/warnings.mp3" type="audio/mpeg" />');
   __divAudio.append(__divSourceWav);
@@ -554,16 +616,27 @@
var totalAlm_num=Number.POSITIVE_INFINITY;
//查询告警数
function searchAlm(){
   //createEleWarning();
function searchAlm(isShowVoice){
   // 判断是否显示右下角的告警提示框
   if(!isShowVoice) {
      self.setTimeout("searchAlm()",10000);
      return;
   }
   // 请求后台查询最新出现的告警个数
   $.post("Battalarm_dataAction!serchRealTime",null,function(data){
      model=eval("("+data.result+")");
      if(model.code==1){
         $('#batt_alarm_num').text(model.sum);
         $('#batt_alarm_num .num').text(model.sum);
         if(totalAlm_num<model.sum){            
            createEleWarning(model.sum-totalAlm_num);
            var voiceStatus = checkPageVoiceStatus();
            createEleWarning(model.sum-totalAlm_num, !voiceStatus);
         }
         totalAlm_num=model.sum;
         // 5秒后关闭面板
         setTimeout(function() {
            $('body').children('#eleWarning').remove();
         }, 5000);
         
         self.setTimeout("searchAlm()",10000); 
      }
@@ -1092,52 +1165,6 @@
   }
}
/**
  检测服务器连接是否正常
  程序功能: 通过请求后台程序如果三次都请求失败认为服务器挂掉,跳转到登陆页面
*/
;(function ($) {
   var url = window.location.href;
   var loginPatt = /\/login.jsp/;
   // 判断当前页面不是登陆页面开始执行检测服务器状态
   if(!loginPatt.test(url)) {
      checkServer();
   }
   var linkNum = 0;    // 测试服务器连接计数 =3 跳转到登陆页面
   function checkServer() {
       $.ajax({
           url:'User_infAction!checkService',
           type: 'post',
           async: true,
           success: function(rs) {
               linkNum = 0;    // 初始化测试连接
               setTimeout(checkServer, 200);
           },
           error:function() {
                // 网络连接不正常
               if(!navigator.onLine) {
                    linkNum = 0;
                    setTimeout(checkServer, 200);
               }else{
                   linkNum++;
                    // 服务器连接不正常
                    if(linkNum == 3) {
                       console.info('出现第'+linkNum+"次测试服务器连接失败!跳转到登陆");
                       // 网络正常但服务器连续多次检测不正常跳转到登陆页面
                      alert('服务器运行异常,请查看服务器是否正在运行!');
                       window.location.replace("login.jsp");
                    }else {
                       console.info('出现第'+linkNum+"次测试服务器连接失败!");
                       checkServer();
                    }
               }
           }
       });
   }
})(jQuery);
/*****************常用判断数据类型*****************/
//是否为数字
@@ -1177,4 +1204,29 @@
// 判断是否为对象
function isObject(s) {
   return (typeof s === 'object' && !isArray(s));
}
//使用XMLHttpRequest的方式获取模板页
function getTpl(url) {
   var xmlhttp;   // 实例化XMLHttpRequest对象
   if(window.XMLHttpRequest) {
      xmlhttp = new XMLHttpRequest();
   }else {
      xmlhttp = new ActiveXObject('Mocrosoft.XMLHTTP');
   }
   // 设置请求
   xmlhttp.open('GET', url, false);
   // 发送请求
   xmlhttp.send();
   var tpl;
   if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      tpl = xmlhttp.responseText;
   }else {
      tpl = "";
   }
   return tpl;
}