import { layuiObj,loginInfo } from "./index.js"; import { stationurl } from "../../../public/js/url.js"; import { getPoliceAlarmLast } from "./orgApi/getFaceAlarmLast.js"; import { getaiBehavioralEventList } from "./orgApi/getAiAlarmList.js"; import { getPushButtonAlarmList } from "./orgApi/getPushButtonAlarmList.js"; import { getAlarmListbyScope } from "./orgApi/getMdevAlarmList.js"; import { deviceHash,createMoveDeviceSos,clearMoveDeviceSos } from "../api/moveDeviceWebsocket.js"; import { setFaceAlarmRead } from "./orgApi/setFaceAlarmRead.js"; import { showStationIpcRightVideo } from "./schoolBaseInfo.js"; import { autoOpenRightSlide } from "./pageEventTool.js"; import { closemdevAlarmIndex, mdevAlarmHandleDrawCircle } from "./marker/moveDeviceMarker.js"; import { setMdevAlarmClose } from "./orgApi/setMdevAlarmClose.js"; import { setAiAlarmRead } from "./orgApi/setAiAlarmRead.js"; import { updatePushButtonClose } from "./orgApi/updatePushButtonClose.js"; import { pushButtonHandleData,delPushButtonEventMarker, drawPushButtonEventMarker, addPushButtonEventMarker } from "./marker/pushButtonEventMarker.js"; var policeAlarmList=[]; var aiAlarmList=[]; var pushbuttonAlarmList=[]; var mdevAlarmList=[]; var currentBottomnavName="policeEvent"; function showAlarmAllList(){ getPoliceAlarmListReq(); getaiBehavioralEventListReq(); getPushButtonAlarmListReq(); getAlarmListbyScopeReq(); addMainCenterBottomListEvent(); } //获取天网最新的20条数据 function getPoliceAlarmListReq(){ //天网 getPoliceAlarmLast().then(res=>{ var code=res["data"]["code"]; if(code==0){ var data=res["data"]["data"] if(data!=null){ policeAlarmList=data; policeAlarmList.reverse(); } } $(".policeAlarmCount").html(policeAlarmList.length); currentBottomnavName=$(".eventAlarmSelect").attr("name"); setMainCenterBottomTableShow(); }) } function getaiBehavioralEventListReq(){ //AI getaiBehavioralEventList().then(res=>{ var code=res["data"]["code"]; if(code==0){ var data=res["data"]["data"] if(data!=null){ aiAlarmList=data; aiAlarmList.reverse(); } } $(".aiAlarmCount").html(aiAlarmList.length); if(currentBottomnavName=="aiEvent"){ setMainCenterBottomTableShow(); } }) } function getPushButtonAlarmListReq(){ pushbuttonAlarmList=[]; //查询一键告警,没有处置的 getPushButtonAlarmList().then(res=>{ var code=res["data"]["code"]; if(code==0){ var data=res["data"]["data"] if(data!=null){ for(var i=0;i { addPushButtonEventMarker(item) }); showPushButtonEventPage(); } }) } function showPushButtonEventPage(){ $(".pushbuttonAlarmCount").html(pushbuttonAlarmList.length); if(currentBottomnavName=="pushButtonEvent"){ setMainCenterBottomTableShow(); } } function getAlarmListbyScopeReq(){ mdevAlarmList=[]; //移动告警 getAlarmListbyScope().then(res=>{ var code=res["data"]["code"]; if(code==0){ var data=res["data"]["data"] if(data!=null){ for(var j=0;j处置 ` }}, ]], limit:Number.MAX_VALUE // 数据表格默认全部显示 }); //监听行工具事件 layuiObj.layuitable.on('tool(eventUpload)', function(obj){ //监听行工具事件 var data=obj["data"]; var event=obj["event"]; switch(event){ case "policeAlarmHandle": case "aiAlarmHandle": autoOpenRightSlide(); showStationIpcRightVideo({station:data["station"]}) break; case "pushButtonAlarmHandle": pushButtonHandleData(data["eventId"]) break; case "mdevAlarmHandle": var deviceid=data["deviceid"]; autoOpenRightSlide() mdevAlarmHandleDrawCircle(deviceid) break; case "policeAlarmDetail": openPoliceAlarmInfo(data) break; case "policeAlarmResive": layer.confirm('确定需要解除吗?', {icon: 3, title:'提示'}, function(index){ var alarmid=data["alarmId"] setFaceAlarmRead(alarmid).then(res=>{ var code=res["data"]["code"]; if(code==0){ layer.msg('请求成功') getPoliceAlarmListReq(); }else{ layer.msg('请求失败') } }) }) break; case "aiAlarmDetail": openAIBehavioral(data); break; case "aiAlarmResive": layer.confirm('确定需要解除吗?', {icon: 3, title:'提示'}, function(index){ var warnId=data["warnId"] setAiAlarmRead(warnId).then(res=>{ var code=res["data"]["code"]; if(code==0){ layer.msg('请求成功') getaiBehavioralEventListReq(); }else{ layer.msg('请求失败') } }) }) break; case "pushButtonAlarmDetail": openPushbuttonAlarm(data); break; case "pushButtonAlarmResive": var eventId=data["eventId"]; pushButtonAlarmResiveReq(eventId); break; case "mdevAlarmResive": var deviceid = data["deviceid"]; var alarmid = data["alarmid"]; layer.confirm('确定需要解除吗?', {icon: 3, title:'提示'}, function(index){ setMdevAlarmResive(alarmid,deviceid); layuiObj.layer.close(index); }) break; default: console.log(data) break } }) } //通过eventId查找设备Id function pushButtonEventFindDeviceId(eventId){ var list=pushbuttonAlarmList.filter(item=>{ return item["eventId"]==eventId }) return list[0]; } //报警按钮的解除 function pushButtonAlarmResiveReq(eventId){ layer.confirm('确定需要解除吗?', {icon: 3, title:'提示'}, function(index){ var reqData={ eventId:eventId, newState:"close" } updatePushButtonClose(reqData).then(res=>{ var code=res["data"]["code"]; if(code==0){ //关闭打开框 closemdevAlarmIndex(); //更新UI delPushButtonEventMarker(eventId) //更新内存数据 pushbuttonAlarmList.forEach((item,index)=>{ if(item["eventId"]==eventId){ pushbuttonAlarmList.splice(index,1) } }) showPushButtonEventPage(); //重新获取数据 //getPushButtonAlarmListReq(); }else{ layer.msg('请求失败') } }) layer.close(index); }) } function setMdevAlarmResive(alarmid,deviceid){ var reqData={ alarmid:alarmid, deviceid:deviceid, operator:loginInfo["user_name"], status:"close", } setMdevAlarmClose(reqData).then(res=>{ var code=res["data"]["code"]; if(code==0){ clearMoveDeviceSos(deviceid); mdevAlarmList.forEach((item,index)=>{ if(item["deviceid"]==deviceid){ mdevAlarmList.splice(index,1); } }) showMdevAlarmData(); //getAlarmListbyScopeReq(); }else{ layer.msg('请求失败') } }) } function openPoliceAlarmInfo(data){ layuiObj.layer.open({ type: 1, title: "天网预警", //不显示标题栏 area: ['auto','auto'], shade: 0.6, id:new Date().getTime(), //设定一个id,防止重复弹出 btnAlign: 'c', moveType: 1, //拖拽模式,0或者1 content: `
${getPoliceAlarmDiv(data)}
` }); } function getPoliceAlarmDiv(item){ var personLibName=item["personLibName"]; var timestamp=item["timestamp"]; var station=item["station"]; var certificateTypeName=item["certificateTypeName"]; var certificateNumber=item["certificateNumber"]; var personName=item["personName"]; var cameraName=item["cameraName"]; var snappedPicUrl=item["snappedPicUrl"]; var alarmId=item["alarmId"]; var groupType=item["groupType"]; return `

[${personLibName}] 【${groupType == null?" ":groupType}】

时间: ${timestamp}

学校名称: ${station}

${certificateTypeName}: ${personName}/${certificateNumber}

位置: ${cameraName}

`; } function openAIBehavioral(item){ layuiObj.layer.open({ type: 1, title: "行为预警", //不显示标题栏 area: ['auto','auto'], shade: 0.6, id:new Date().getTime(), //设定一个id,防止重复弹出 btnAlign: 'c', moveType: 1, //拖拽模式,0或者1 content: `
${getAIBehavioralDiv(item)}
` }); } function openPushbuttonAlarm(item){ layuiObj.layer.open({ type: 1, title: "一键报警", //不显示标题栏 area: ['auto','auto'], shade: 0.6, id:new Date().getTime(), //设定一个id,防止重复弹出 btnAlign: 'c', moveType: 1, //拖拽模式,0或者1 content: `
${getPushbuttonInfoDiv(item)}
` }); } function getPushbuttonInfoDiv(item){ var station=item["station"]; var timestamp=item["timestamp"]; var address=item["address"]; var eventId=item["eventId"]; var user1Name=item["user1Name"]; var user1Phone=item["user1Phone"]; var user2Name=item["user2Name"]; var user2Phone=item["user2Phone"]; var user3Name=item["user3Name"]; var user3Phone=item["user3Phone"]; var deviceId=item["deviceId"]; return`

${station} 【${timestamp}】

位置:${address}

编号:${deviceId}

联系人1:${user1Name}/${user1Phone}

联系人2:${user2Name}/${user2Phone}

联系人3:${user3Name}/${user3Phone}

`; } function getAIBehavioralDiv(item){ var warnName=item["warnName"]; var station=item["station"]; var timestamp=item["receiveTime"]; var channelName=item["channelName"]; var deviceId=item["deviceId"]; var pic=`${stationurl}${item["imageUrl"]}`; var warnId=item["warnId"]; return `

【${channelName}】 ${station} ${timestamp}

行为: ${warnName}

设备ID:${deviceId}

`; } function showAiAlarmListTable(){ layuiObj.layuitable.render({ elem:'#eventUpload', data:aiAlarmList, cols: [[ {field:'station', width:"25%", title: '学校'}, {field:'warnName', width:"25%", title: '动作'}, {field:'receiveTime', width:"25%", title: '告警时间'}, {field:'opear', width:"25%", title: '操作',templet : function(data) { return ` ` }}, ]], limit:Number.MAX_VALUE // 数据表格默认全部显示 }); } function showPushButtonAlarmListTable(){ layuiObj.layuitable.render({ elem:'#eventUpload', data:pushbuttonAlarmList, cols: [[ {field:'station', width:"25%", title: '学校'}, {field:'address', width:"25%", title: '地址'}, {field:'timestamp', width:"25%", title: '告警时间'}, {field:'opear', width:"25%", title: '操作',templet : function(data) { return ` ` }}, ]], limit:Number.MAX_VALUE // 数据表格默认全部显示 }); } function showMdevAlarmListTable(){ layuiObj.layuitable.render({ elem:'#eventUpload', data:mdevAlarmList, cols: [[ {field:'deviecid', width:"20%", title: '学校',templet : function(data) { var deviceid=data["deviceid"]; if(deviceid in deviceHash){ var station=deviceHash[deviceid]["name"] } return station; }}, {field:'deviceid', width:"20%", title: '设备名称',templet : function(data) { var deviceid=data["deviceid"]; if(deviceid in deviceHash){ var showname=deviceHash[deviceid]["showname"] } return showname; }}, {field:'timestamp', width:"20%", title: '告警时间'}, {field:'address', width:"20%", title: '地址'}, {field:'opear', width:"20%", title: '操作',templet : function(data) { return` ` }}, ]], limit:Number.MAX_VALUE // 数据表格默认全部显示 }); } function addMainCenterBottomListEvent(){ $(".mainCenterBottomList>ul>li").on('click',function(){ $(this).attr("class","eventAlarmSelect"); $(this).siblings("li").removeClass("eventAlarmSelect"); currentBottomnavName=$(this).attr("name"); setMainCenterBottomTableShow(); }) } function setMainCenterBottomTableShow(){ switch(currentBottomnavName){ case "policeEvent"://天网 showPoliceAlarmListTable(); break; case "aiEvent"://行为预警 showAiAlarmListTable(); break; case "pushButtonEvent"://一键报警 showPushButtonAlarmListTable(); break; case "mdevEvent"://移动报警 showMdevAlarmListTable(); break; default: break; } } export { showAlarmAllList, getAlarmListbyScopeReq, setMdevAlarmResive, getPushButtonAlarmListReq, pushButtonAlarmResiveReq, pushbuttonAlarmList, showPushButtonEventPage }