function startMqttServer() { if (!window.WebSocket) { $("#connect").html("\

Get a new Web Browser!

\

\ Your browser does not support WebSockets. This example will not work properly.
\ Please use a Web Browser with WebSockets support (WebKit or Google Chrome).\

\ "); } else { // console.log(JSON.parse(window.sessionStorage.getItem("userInfo")).UserCode); // if (JSON.parse(window.sessionStorage.getItem("userInfo")).UserCode != undefined) { initmqtt(); // } } } function initmqtt() { var destination = ["mqtt/ZHYQ/"+this._orgId+"/DOCManageAPP/swks"]; //订阅主题 iotpush = CreateIOTPushObject(); //iotpush.clientId = iotpush.guid().replace(/\-/g, ""); iotpush.clientId = iotpush.uuid(16, 16); iotpush.destination = destination; iotpush.setClient(); iotpush.client.onMessageArrived = onMessageArrived; //信息接收 iotpush.setConnect(); } //消息发送 function sendMessage(title, content, usercode) { var jsonstr = "{\"Title\":\"" + title + "\",\"Type\":\"APPROVAL\",\"Content\":\"" + content + "\"}"; var destinationName = ["mqtt/ZHYQ/"+this._orgId+"/DOCManageAPP/sentry"]; //订阅主题 iotpush.send(jsonstr, destinationName); } //信息接收 function onMessageArrived(message) { setRealWarnList(message.payloadString); } function setRealWarnList(objMsg) { objMsg = JSON.parse(objMsg); // console.log(objMsg); var msg = objMsg; $("#item").html(msg); $("#list").append("
  • " + msg + "
  • "); var html = ''; if (_use_page == 'people' && objMsg.TYPE=="0") { var type = '园区人员'; if (objMsg.TYPE == 0) { type = '访客'; } html += '' + '' + objMsg.NAME + '' + '' + objMsg.ID_NUM + '' + '' + objMsg.IN_TIME + '' + '' + type + '' + '' + objMsg.REASON + '' + '' + objMsg.VED_DEPT + '' + '' + objMsg.VED_MAN + '' + '' + objMsg.STATE + '' + ''; $("#tb-outper").prepend(html); getData.init(objMsg.ID, objMsg.PHONE); //统计加一 dev2 +=1; getData.time(); getData.zhuxingtu(timeFlag); //进出人员气泡 // var bubble = new Bubble(_viewer.scene, "ejectImg"); // var position = _viewer.entities.getById(objMsg.ID)._position._value; // bubble.showAt(position); // camera_flyToBoundingSphereD(position, 30, 1); // var index = $.inArray(pickedFeature.id._id, peoList); // if (index >= 0) {//人 // updateEntity_billboardImg(peoList, pickedFeature.id._id, "icon/ditu-ry-icon1h.png", "icon/ditu-ry-icon1.png"); // updateEntity_billboardImg(fkList, pickedFeature.id._id, "icon/ditu-fk-icon1h.png", "icon/ditu-fk-icon1.png"); // } else { // updateEntity_billboardImg(fkList, pickedFeature.id._id, "icon/ditu-fk-icon1h.png", "icon/ditu-fk-icon1.png"); // updateEntity_billboardImg(peoList, pickedFeature.id._id, "icon/ditu-ry-icon1h.png", "icon/ditu-ry-icon1.png"); // } //3S后消失 } if (_use_page == 'vehicleDuty' && objMsg.TYPE=="1") { var fangxiang = ''; if (objMsg.INOROUT == "0") { fangxiang = '进入'; } else if (objMsg.INOROUT == "1") { fangxiang = '离开'; } else { fangxiang = '未知'; } html = '' + objMsg.CAR_PLATE + '' + objMsg.CAR_NAME + '' + objMsg.START_TIME + '' + fangxiang + '' + objMsg.WATERNUM + '' + objMsg.DRYPOWDER + '' + objMsg.HEIGHTBOARDINGCAR + '' + objMsg.FROTHAMOUNT + '' + '

    '; $(".dutyList").prepend(html); init(objMsg.ID, objMsg.EXTEND2); } if (_use_page == 'vehicleOfficial' && objMsg.TYPE=="2") { var fangxiang = ''; if (objMsg.INOROUT == "0") { fangxiang = '进入'; } else if (objMsg.INOROUT == "1") { fangxiang = '离开'; } else { fangxiang = '未知'; } html = '' + objMsg.CAR_PLATE + '' + objMsg.CAR_NAME + '' + objMsg.START_TIME + '' + fangxiang + '' + objMsg.WATERNUM + '' + objMsg.DRYPOWDER + '' + objMsg.HEIGHTBOARDINGCAR + '' + objMsg.FROTHAMOUNT + '' + '

    '; $(".officialList").prepend(html); officialinit(objMsg.ID, objMsg.EXTEND2); } if (_use_page == 'camera' && objMsg.TYPE=="3") { var type = ''; if (dobjMsg.TYPE == "0") { type = '周界报警'; } else type = '聚集报警'; html = '' + ' ' + type + '' + '' + objMsg.ADDR + '' + '' + objMsg.TIME + '' + '' + objMsg.ALARM_DES + '' + ''; $("#cam-alarm-data").prepend(html); getData.init(objMsg.ID, objMsg.PICSRC); } }