anxiao_web/pages/intelligenceEarlyWarning/js/showPoliceAlarm.js

312 lines
9.9 KiB
JavaScript
Raw Permalink Normal View History

2024-07-24 09:22:32 +08:00
import { getPoliceAlarm } from "../api/getPoliceAlarm.js"
import { layuiObj,eventMap} from "./index.js";
import {drawAlarmEventMarker,drawPersonEventMarker} from "./marker/schoolMarker.js";
import { timestampFormatTime } from "../../../public/js/timestamp.js";
import { getskynetfence } from "../api/getSkyNetfence.js";
import { getTime } from "./time.js";
import { brigade } from "../../../public/js/url.js";
import { sendFacealarmBroadcast } from "../api/sendFacealarmBroadcast.js";
let policeAlarmList=[];
var currentStation="";
var currnetAlarmTarget="";
var skynetfenceObj={}
var polygonArr=[];
function showPoliceAlarm(){
var time=getTime();
var reqdata={
brigade,
pageindex: 0,
pagesize: 2000,
readState:"unread",
start:time["startTime"],
end:time["endTime"]
}
getPoliceAlarm(reqdata).then(res=>{
var code=res["data"]["code"];
if(code==0){
var data=res["data"]["data"];
if(data!=null){
policeAlarmList=data;
policeAlarmList.reverse();
}
}
showPoliceAlarmDiv();
})
}
function showPoliceAlarmDiv(){
var div="";
for(var i=0;i<policeAlarmList.length;i++){
div+=getAlarmPersonInfoDiv(policeAlarmList[i],"broadCast")
}
$(".warnInfoListall").html(div);
addAlarmEventClick();
}
function addAlarmEventClick(){
$(".warnInfoListall>div").on('click',function(){
var eventId=$(this).attr("eventId");
$(".currentSchoolAlarmListAllBox").html("");
$(".schoolAlarmInfo>p:nth-child(1)").html("预警信息");
for(var i=0;i<policeAlarmList.length;i++){
if(eventId==policeAlarmList[i]["alarmId"]){
currnetAlarmTarget=policeAlarmList[i]["personName"];
currentStation=policeAlarmList[i]["station"];
drawAlarmEventMarker([policeAlarmList[i]]);
showSchoolInfoBox(policeAlarmList[i])
break;
}
}
})
$(".warnInfoListall>div>div .broadCastMsgBtn").on('click',function(){
var alarmId=$(this).parent().parent().parent().attr("eventId");
layer.confirm('确定需要广播吗?', {icon: 3, title:'提示'}, function(index){
sendFacealarmBroadcast(alarmId).then(res=>{
var code=res["data"]["code"];
if(code==0){
layer.msg("推送成功")
}else{
layer.msg("推送失败")
}
})
layer.close(index);
});
})
$(".warnInfoListall>div>div .policeDetailBtn").on('click',function(){
var alarmId=$(this).parent().parent().parent().attr("eventId");
for(var i=0;i<policeAlarmList.length;i++){
if(alarmId==policeAlarmList[i]["alarmId"]){
openPoliceAlarm(policeAlarmList[i]);
break;
}
}
})
}
function openPoliceAlarm(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">
${getAlarmPersonInfoDiv(item,"noBroadCast")}
</div>`,
success: function(layero){
console.log(item);
}
});
}
function showSchoolInfoBox(item,type){
var div=`
<div>
<p>
<span>学校名称:</span>
<span>${item["station"]}</span>
</p>
</div>
<div>
<p>
<span>派出所:</span>
<span>${item["borough"]}</span>
</p>
<p>
<span>警务区:</span>
<span>${item["detachment"]}</span>
</p>
</div>
<div>
<p>
<span>校长:</span>
<span>王娟(15211120788)</span>
</p>
<p>
<span>校区民警:</span>
<span>王娟(15211120788)</span>
</p>
</div>
<p>
<button type="button" class="layui-btn currentSchoolInfo">学校预警信息</button>
<button type="button" class="layui-btn currentPersonInfo">人员预警信息</button>
</p>`;
$(".schoolInfoBox").html(div)
addSchoolInfoBoxEvent();
}
function addSchoolInfoBoxEvent(){
$(".currentSchoolInfo").on('click',function(){
var tempArr=[];
for(var i=0;i<policeAlarmList.length;i++){
if(currentStation==policeAlarmList[i]["station"]){
tempArr.push(policeAlarmList[i])
}
}
drawAlarmEventMarker(tempArr);
showSchoolWarnAlarmInfo(tempArr);
$(".schoolAlarmInfo>p:nth-child(1)").html(currentStation+" 预警信息");
showSkynetFence();
})
$(".currentPersonInfo").on('click',function(){
var tempArr=[];
for(var i=0;i<policeAlarmList.length;i++){
if(currnetAlarmTarget==policeAlarmList[i]["personName"]){
tempArr.push(policeAlarmList[i])
}
}
drawPersonEventMarker(tempArr);
showSchoolWarnAlarmInfo(tempArr);
$(".schoolAlarmInfo>p:nth-child(1)").html(currnetAlarmTarget+" 预警信息");
})
}
function showSkynetFence(){
if(!(currentStation in skynetfenceObj)){
getskynetfence(currentStation).then(res=>{
var code=res["data"]["code"];
if(code==0){
var data=res["data"]["data"];
var station=data["station"]
skynetfenceObj[station]=data;
}else{
layuiObj.layer.msg("无围栏信息");
}
drawPolygon();
})
}else{
drawPolygon();
}
}
function getAlarmPersonInfoDiv(item,type){
var personLibName=item["personLibName"];
var station=item["station"];
var alarmTime=timestampFormatTime(new Date(item["alarmTime"]).getTime());
var address=item["cameraName"];
var eventId=item["alarmId"];
var pic=item["snappedPicUrl"]
var blackType=item["certificateTypeName"]
var idNumber=item["certificateNumber"];
var blackName=item["personName"];
var groupType=item["groupType"];
var div=`
<div eventId='${eventId}'>
<p>
<img src="${pic}" alt="">
</p>
<div>
<p>
<span>[${personLibName}]</span>
<span>${groupType == null?" ":groupType}</span>
</p>
<p>
<span>告警时间:</span>
<span>${alarmTime}</span>
</p>
<p>
<span>学校名称:</span>
<span>${station}</span>
</p>
<p>
<span>${blackType}:</span>
<span>${blackName}/${idNumber}</span>
</p>
<p>
<span>位置:</span>
<span>${address}</span>
</p>
`
if(type!="noBroadCast"){
div+=`<p>
<button class="layui-btn layui-btn-normal broadCastMsgBtn">广播</button>
<button class="layui-btn layui-btn-normal policeDetailBtn">详情</button>
</p>`;
}
div+=`</div></div>`;
return div;
}
function showSchoolWarnAlarmInfo(arr){
var div="";
for(var i=0;i<arr.length;i++){
div+=getAlarmPersonInfoDiv(arr[i],"noBroadCast")
}
$(".currentSchoolAlarmListAllBox").html(div);
}
function emptyPoygon(){
for(var i=0;i<polygonArr.length;i++){
eventMap.removeLayer(polygonArr[i])
}
}
function drawPolygon(){
emptyPoygon();
if(currentStation in skynetfenceObj){
var redData=JSON.parse(skynetfenceObj[currentStation]["redData"]);//最里层
var orangeData=JSON.parse(skynetfenceObj[currentStation]["orangeData"]);//中间成
var yellowData=JSON.parse(skynetfenceObj[currentStation]["yellowData"]);//最外层
var stationFence=JSON.parse(skynetfenceObj[currentStation]["stationFence"]);//学校
var oneArr=[];
var twoArr=[];
var threeArr=[];
var fourArr=[];
for(var i=0;i<redData.length;i++){
oneArr.push([redData[i]["latitude"],redData[i]["longitude"]]);
}
for(var j=0;j<orangeData.length;j++){
twoArr.push([orangeData[j]["latitude"],orangeData[j]["longitude"]]);
}
for(var k=0;k<yellowData.length;k++){
threeArr.push([yellowData[k]["latitude"],yellowData[k]["longitude"]]);
}
for(var z=0;z<stationFence.length;z++){
fourArr.push([stationFence[z]["latitude"],stationFence[z]["longitude"]]);
}
var yellowArr=[[threeArr],[twoArr]];
var orangeArr=[[twoArr],[oneArr]];
var redArr=[[oneArr],[fourArr]];
var stationArr=[[fourArr]];
var polygon_yellow = L.polygon(yellowArr, {weight:4,color: '#f4d81b',fillOpacity:"0.8"});
var polygon_orange = L.polygon(orangeArr, {weight:4,color: '#ff9c00',fillOpacity:"0.7"});
var polygon_red = L.polygon(redArr, {weight:4,color: '#ed4040',fillOpacity:"0.6"});
var polygon_station = L.polygon(stationArr, {weight:4,color: '#21ecc8',fillOpacity:"0.3"});
eventMap.addLayer(polygon_yellow);
eventMap.addLayer(polygon_orange);
eventMap.addLayer(polygon_red);
eventMap.addLayer(polygon_station);
polygonArr.push(polygon_yellow);
polygonArr.push(polygon_orange);
polygonArr.push(polygon_red);
polygonArr.push(polygon_station);
// 将地图放大到多边形的位置
eventMap.fitBounds(polygon_yellow.getBounds());
//eventMap.fitBounds(polygon.getBounds());
}
}
export {
showPoliceAlarm,
policeAlarmList,
emptyPoygon
}