anxiao_web/pages/newIndex/js/index.js

278 lines
8.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { getBoroughInfo } from "./orgApi/getBoroughInfo.js";
import { getDetachmentInfo } from "./orgApi/getDetachmentInfo.js";
import { getstationcount,stationInfoPageReq } from "./orgApi/getStationInfo.js";
import { getSkynetIpcList } from "./orgApi/getSkynetIpcList.js";
import { getSignedSchools } from "./orgApi/getSignedSchools.js";
import { getStarRatingList } from "./orgApi/getStarRatingList.js";
import { getColorratingList } from "./orgApi/getColorratingList.js";
import { getAlarmEventDiff } from "./orgApi/getAlarmEventDiff.js";
import { getSkynetFaceAlarmLast } from "./orgApi/getSkynetFaceAlarmLast.js";
import { getAibehavioralEventLast } from "./orgApi/getAibehavioralEventLast.js";
import { getMdevAlarmByorgList } from "./orgApi/getMdevAlarmByorgList.js";
import { getSensorAlarmEventList } from "./orgApi/getSensorAlarmEventList.js";
import { getMdevCount,mdevInfoPageReq} from "./orgApi/getMdevList.js";
import { showSchoolDistribution } from "./pages/schooldistribution.js";
import { showStartRating } from "./pages/startRating.js";
import { showColorRating } from "./pages/threeColor.js";
import { showScholStyle } from "./pages/schoolStyle.js";
import { schoolVideoPolling } from "./pages/schoolVideoPolling.js";
import { showSchoolclockInData } from "./pages/schoolClockIn.js";
import { showIpcAlarmList } from "./pages/ipcAlarm.js";
import { showIntelligentAlarm } from "./pages/showIntelligentAlarm.js";
import { addNavEvent } from "./event.js";
import { getWeekDate,getCurrentTimeM } from "../../../public/js/timestamp.js";
import { setTokenActive } from "./session.js";
import { getYearStarTime,getYearColorTime } from "../../newIndex/js/orgApi/getYearTime.js";
import { serverIp } from "../../../public/js/url.js";
let boroughArr=[];
let detachmentArr=[];
let stationList=[];//学校列表
let moveDeviceHash={};//移动设备
let ipcSkyArr=[];//摄像头
let ipcSkyStationHash={};
let starRatingList=[];//获取星级评定的列表
let colorRatingList=[];//获取三色预警的列表
let signedSchoolsArr=[];//获取打卡的数据
let ipcAlarmList=[];//ipc告警的数据
let skynetFaceAlarmList=[];//查询天网告警最新的5条
let aiBehavioralEventList=[];//行为预警最近10条
let mdevAlarmByorgList=[];//移动告警,半年的
let sensorAlarmEventList=[];//一键告警pushbutton的,最近半年的
let layuiObj={};
var starYearTimeList=[];
var colorYearTimeList=[];
var unameInfoStr=null;
layui.use(['carousel','table','form','laydate','slider','element'],function() {
layuiObj["layer"] = layui.layer;
layuiObj["carousel"] = layui.carousel;
layuiObj["layuitable"] = layui.table;
layuiObj["rate"] = layui.rate;
layuiObj["layuiForm"] = layui.form;
layuiObj["laydate"] =layui.laydate;
layuiObj["slider"] =layui.slider;
layuiObj["element"] =layui.element;
unameInfoStr = JSON.parse(sessionStorage.getItem("unameInfoStr"));
initIndexApi();
})
async function initIndexApi(){
//1.给axios设置Authorization
setAuthorizationAxios();
//设置seesion有效时长
setTokenActive();
//获取评分时间
var yearReq=await getYearStarTime()
starYearTimeList=yearReq.data.data;
var yearReq=await getYearColorTime()
colorYearTimeList=yearReq.data.data;
await getBoroughList();
await getDetachmentList();
//获取所有的学校信息
await getStationList();
//获取学校的保安数据
await getMdevList();
//获取IPC
await getIpcList();
//获取打卡的数据
await getSignedSchoolsList()
//获取星级评定
await getStarRatingListReq();
//获取三色预警
await getColorratingListReq();
//获取告警的数据
await getAlarmList();
await getSkynetFaceAlarmReq();
await getAiBehavioralEventReq();
await getMdevAlarmByorgListReq();
await getSensorAlarmEventListReq();
//显示所有的数据
showIndexDataPage();
//显示系统的时间跟星期
showSystemTime();
//是否显示海康的视频
showHikVideoPage();
//添加弹出层点击事件
addNavEvent();
}
function showHikVideoPage(){
if(serverIp=="www.lonsungsh.com"){{
var oli=` <li class="hikVideo">
<img src="./image/10.png" alt="">
<span>实时视频</span>
</li>`;
$(".schoolNavContent>ul").append(oli)
}}
}
//显示系统的时间跟星期
function showSystemTime(){
$(".systemweek").html(getWeekDate());
$(".systemtime").html(getCurrentTimeM());
setInterval(()=>{
$(".systemtime").html(getCurrentTimeM());
},1000)
}
//获取派出所信息
async function getBoroughList(){
var boroughReq= await getBoroughInfo();
if(boroughReq.data.data!=null){
boroughArr=boroughReq.data.data;
}
}
//获取警务区
async function getDetachmentList(){
var detachmentRes= await getDetachmentInfo();
if(detachmentRes.data.data!=null){
detachmentArr=detachmentRes.data.data;
}
}
//获取所有的学校信息
async function getStationList(){
var stationcountRes=await getstationcount();
var stationcount=stationcountRes.data.data.count;
var stationlistRes= await stationInfoPageReq(stationcount)
stationlistRes.forEach(item=>{
var data=item.data.data;
for(let i=0;i<data.length;i++){
stationList.push(data[i]);
}
})
}
//获取所有的学校的保安信息
async function getMdevList(){
var mdevcountRes=await getMdevCount();
var mdevcount=mdevcountRes.data.data.count;
var mdevlistRes= await mdevInfoPageReq(mdevcount)
mdevlistRes.forEach(item=>{
var data=item.data.data;
for(let i=0;i<data.length;i++){
var deviceid=data[i]["deviceid"];
moveDeviceHash[deviceid]=data[i]
}
})
}
//获取IPC
async function getIpcList(){
var ipcSkyRes=await getSkynetIpcList();
if(ipcSkyRes.data.data!=null){
var data=ipcSkyRes.data.data;
ipcSkyArr=data;
for(var i=0;i<ipcSkyArr.length;i++){
var station=ipcSkyArr[i]["station"];
if(!(station in ipcSkyStationHash)){
ipcSkyStationHash[station]=[];
}
ipcSkyStationHash[station].push(ipcSkyArr[i])
}
}
}
//获取打卡的数据
async function getSignedSchoolsList(){
var signedSchoolsRes=await getSignedSchools();
if(signedSchoolsRes.data.data!=null){
signedSchoolsArr=signedSchoolsRes.data.data;
}
}
//获取星级评定
async function getStarRatingListReq(){
var starRatingReq = await getStarRatingList();
starRatingList=starRatingReq.data.data;
}
//获取三色预警
async function getColorratingListReq(){
var colorRatingReq = await getColorratingList();
colorRatingList=colorRatingReq.data.data;
}
//获取告警的数据
async function getAlarmList(){
var ipcAlarmReq = await getAlarmEventDiff();
if(ipcAlarmReq.data.data!=null){
ipcAlarmList=ipcAlarmReq.data.data;
}
}
//查询天网告警最新的5条
async function getSkynetFaceAlarmReq(){
var skyReq = await getSkynetFaceAlarmLast();
if(skyReq.data.data!=null){
skynetFaceAlarmList=skyReq.data.data;
}
}
//行为预警最近10条
async function getAiBehavioralEventReq(){
var aiReq = await getAibehavioralEventLast();
if(aiReq.data.data!=null){
aiBehavioralEventList=aiReq.data.data;
}
}
//移动告警,半年的
async function getMdevAlarmByorgListReq(){
var mdevReq = await getMdevAlarmByorgList();
if(mdevReq.data.data!=null){
mdevAlarmByorgList=mdevReq.data.data;
mdevAlarmByorgList.reverse();
}
}
//一键告警pushbutton的,最近半年的
async function getSensorAlarmEventListReq(){
var sensorReq = await getSensorAlarmEventList();
if(sensorReq.data.data!=null){
sensorAlarmEventList=sensorReq.data.data;
sensorAlarmEventList.reverse();
}
}
//显示所有的数据
function showIndexDataPage(){
showSchoolDistribution();
showScholStyle();
showStartRating();
showColorRating();
schoolVideoPolling();
showIpcAlarmList();
showSchoolclockInData();
showIntelligentAlarm();
}
function setAuthorizationAxios(){
var loginJson=sessionStorage.getItem("unameInfoStr");
var loginInfo=JSON.parse(loginJson);
axios.defaults.headers.common['Authorization'] = loginInfo["session"];
}
export {
layuiObj,
boroughArr,
detachmentArr,
stationList,
moveDeviceHash,
ipcSkyArr,
ipcSkyStationHash,
starRatingList,
colorRatingList,
signedSchoolsArr,
ipcAlarmList,
skynetFaceAlarmList,
aiBehavioralEventList,
mdevAlarmByorgList,
sensorAlarmEventList,
starYearTimeList,
colorYearTimeList,
unameInfoStr
}