anxiao_web/pages/cmddispatch/js/showAlarmListTable.js

549 lines
18 KiB
JavaScript
Raw Normal View History

2024-07-24 09:22:32 +08:00
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<data.length;i++){
var alarmType=data[i]["alarmType"];
if(alarmType!="sos.mdev"){
pushbuttonAlarmList.unshift(data[i]);
}
}
}
pushbuttonAlarmList.forEach(item => {
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<data.length;j++){
var major=data[j]["major"];
if(major=="terminal.sos"){
mdevAlarmList.unshift(data[j]);
}
}
}
}
showMdevAlarmData();
})
}
function showMdevAlarmData(){
$(".mdevAlarmCount").html(mdevAlarmList.length);
if(currentBottomnavName=="mdevEvent"){
setMainCenterBottomTableShow();
}
for(var i=0;i<mdevAlarmList.length;i++){
createMoveDeviceSos(mdevAlarmList[i]);
}
}
function showPoliceAlarmListTable(){
layuiObj.layuitable.render({
elem:'#eventUpload',
data:policeAlarmList,
cols: [[
{field:'station', width:"25%", title: '学校'},
{field:'address', width:"25%", title: '证件信息',templet : function(data) {
return data["certificateTypeName"]+"/"+data["certificateNumber"]
}},
{field:'timestamp', width:"25%", title: '告警时间'},
{field:'opear', width:"25%", title: '操作',templet : function(data) {
return `
<button type="button" class="layui-btn layui-btn-normal" lay-event="policeAlarmHandle">处置</button>
<button type="button" class="layui-btn layui-btn-normal" lay-event="policeAlarmDetail">详情</button>
<button type="button" class="layui-btn layui-btn-normal" lay-event="policeAlarmResive">解除</button>
`
}},
]],
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: `<div class="aIBehavioralPop">
${getPoliceAlarmDiv(data)}
</div>`
});
}
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 `<div class="warnEventList" alarmId="${alarmId}">
<p>
<img src="${snappedPicUrl}" alt="">
</p>
<div>
<p>
<span>[${personLibName}]</span>
<span>${groupType == null?" ":groupType}</span>
</p>
<p>
<span>时间:</span>
<span>${timestamp}</span>
</p>
<p>
<span>学校名称:</span>
<span>${station}</span>
</p>
<p>
<span>${certificateTypeName}:</span>
<span>${personName}/${certificateNumber}</span>
</p>
<p>
<span>位置:</span>
<span>${cameraName}</span>
</p>
</div>
</div>`;
}
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: `<div style="padding:10px;color:#fff;background:#032357;height:calc(100% - 20px);overflow-y:auto;" class="aIBehavioralPop">
${getAIBehavioralDiv(item)}
</div>`
});
}
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: `<div style="padding:10px;color:#fff;background:#032357;height:calc(100% - 20px);overflow-y:auto;" class="aIBehavioralPop">
${getPushbuttonInfoDiv(item)}
</div>`
});
}
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`
<div eventId='${eventId}' class="pushButtonListInfo">
<div>
<p>
<span>${station}</span>
<span>${timestamp}</span>
</p>
<p>
<span>位置:${address}</span>
</p>
<p>
<span>编号:${deviceId}</span>
</p>
<p>
<span>联系人1:${user1Name}/${user1Phone}</span>
</p>
<p>
<span>联系人2:${user2Name}/${user2Phone}</span>
</p>
<p>
<span>联系人3:${user3Name}/${user3Phone}</span>
</p>
</div>
</div>`;
}
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 `
<div warnId='${warnId}'>
<p>
<img src="${pic}" alt="">
</p>
<div>
<p>
<span>${channelName}</span>
<span>${station}</span>
<span>${timestamp}</span>
</p>
<p>
<span>行为:</span>
<span>${warnName}</span>
</p>
<p>
<span>设备ID:${deviceId}</span>
</p>
</div>
</div>`;
}
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 `
<button type="button" class="layui-btn layui-btn-normal" lay-event="aiAlarmHandle">处置</button>
<button type="button" class="layui-btn layui-btn-normal" lay-event="aiAlarmDetail">详情</button>
<button type="button" class="layui-btn layui-btn-normal" lay-event="aiAlarmResive">解除</button>
`
}},
]],
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 `
<button type="button" class="layui-btn layui-btn-normal" lay-event="pushButtonAlarmHandle">处置</button>
<button type="button" class="layui-btn layui-btn-normal" lay-event="pushButtonAlarmDetail">详情</button>
<button type="button" class="layui-btn layui-btn-normal" lay-event="pushButtonAlarmResive">解除</button>
`
}},
]],
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`
<button type="button" class="layui-btn layui-btn-normal" lay-event="mdevAlarmHandle">处置</button>
<button type="button" class="layui-btn layui-btn-normal" lay-event="mdevAlarmResive">解除</button>
`
}},
]],
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
}