软测单独项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

183 lines
7.2 KiB

function startMqttServer() {
if (!window.WebSocket) {
$("#connect").html("\
<h1>Get a new Web Browser!</h1>\
<p>\
Your browser does not support WebSockets. This example will not work properly.<br>\
Please use a Web Browser with WebSockets support (WebKit or Google Chrome).\
</p>\
");
} 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("<li>" + msg + "</li>");
var html = '';
if (_use_page == 'people' && objMsg.TYPE=="0") {
var type = '园区人员';
if (objMsg.TYPE == 0) {
type = '访客';
}
html += '<tr id="ch_tr_' + objMsg.ID + '"onclick="getData.init(\'' + objMsg.ID + '\',\'' + objMsg.PHONE + '\')">' +
'<td>' + objMsg.NAME + '</td>' +
'<td>' + objMsg.ID_NUM + '</td>' +
'<td>' + objMsg.IN_TIME + '</td>' +
'<td>' + type + '</td>' +
'<td>' + objMsg.REASON + '</td>' +
'<td>' + objMsg.VED_DEPT + '</td>' +
'<td>' + objMsg.VED_MAN + '</td>' +
'<td>' + objMsg.STATE + '</td>' +
'</tr>';
$("#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 = '<tr id="ch_tr_' + objMsg.ID + '" onclick="init(\'' + objMsg.ID + '\',\'' + objMsg.EXTEND2 + '\')"><td title="' + objMsg.CAR_PLATE + '">' + objMsg.CAR_PLATE +
'</td><td title="' + objMsg.CAR_NAME + '">' + objMsg.CAR_NAME +
'</td><td title="' + objMsg.START_TIME + '">' + objMsg.START_TIME +
'</td><td title="' + fangxiang + '">' + fangxiang +
'</td><td title="' + objMsg.WATERNUM + '">' + objMsg.WATERNUM +
'</td><td title="' + objMsg.DRYPOWDER + '">' + objMsg.DRYPOWDER +
'</td><td title="' + objMsg.HEIGHTBOARDINGCAR + '">' + objMsg.HEIGHTBOARDINGCAR +
'</td><td title="' + objMsg.FROTHAMOUNT + '">' + objMsg.FROTHAMOUNT +
'</td><td title="操作"><button onclick="gjhfClick(\'' + objMsg.CAR_PLATE + '\')" type="button" class="layui-btn"' +
'style="float: left; background-color:#0060bf;">轨迹回放</button>' +
'<button type="button" onclick="vedioClick(\'' + objMsg.CAR_PLATE + '\')" class="layui-btn"' +
'style="float: right;background-color:#0060bf;">车载视频</button></p></td></tr>';
$(".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 = '<tr id="ch_tr_' + objMsg.ID + '" onclick="officialinit(\'' + objMsg.ID + '\',\'' + objMsg.EXTEND2 + '\')"><td title="' + objMsg.CAR_PLATE + '">' + objMsg.CAR_PLATE +
'</td><td title="' + objMsg.CAR_NAME + '">' + objMsg.CAR_NAME +
'</td><td title="' + objMsg.START_TIME + '">' + objMsg.START_TIME +
'</td><td title="' + fangxiang + '">' + fangxiang +
'</td><td title="' + objMsg.WATERNUM + '">' + objMsg.WATERNUM +
'</td><td title="' + objMsg.DRYPOWDER + '">' + objMsg.DRYPOWDER +
'</td><td title="' + objMsg.HEIGHTBOARDINGCAR + '">' + objMsg.HEIGHTBOARDINGCAR +
'</td><td title="' + objMsg.FROTHAMOUNT + '">' + objMsg.FROTHAMOUNT +
'</td><td title="操作"><button onclick="gjhfClick(\'' + objMsg.CAR_PLATE + '\')" type="button" class="layui-btn"' +
'style="float: left; background-color:#0060bf;">轨迹回放</button>' +
'<button type="button" onclick="vedioClick(\'' + objMsg.CAR_PLATE + '\')" class="layui-btn"' +
'style="float: right;background-color:#0060bf;">车载视频</button></p></td></tr>';
$(".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 = '<tr style="cursor: pointer;" id="ch_tr_' + objMsg.ID + '" onclick="getData.init(\'' + objMsg.ID + '\',\'' + objMsg.PICSRC + '\')"><input type="hidden" id="' + objMsg.ID +
'" value=\'' + JSON.stringify(objMsg) + '\'/>' +
' <td>' + type + '</td>' +
'<td>' + objMsg.ADDR + '</td>' +
'<td>' + objMsg.TIME + '</td>' +
'<td>' + objMsg.ALARM_DES + '</td>' +
'</tr>';
$("#cam-alarm-data").prepend(html);
getData.init(objMsg.ID, objMsg.PICSRC);
}
}