Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/work/hisCameraView.jsp
2026-01-16 14:13:44 +08:00

180 lines
9.2 KiB
Plaintext

<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page import="com.sipai.entity.base.ServerObject" %>
<%@ taglib uri="http://www.springsecurity.org/jsp" prefix="security" %>
<!DOCTYPE html>
<head>
<title><%= ServerObject.atttable.get("TOPTITLE")%>
</title>
<!-- 引用页头及CSS页-->
<jsp:include page="/jsp/inc.jsp"></jsp:include>
<link rel="stylesheet" href="<%=request.getContextPath()%>/plugins/bootstrap-daterangepicker/daterangepicker.css"/>
<script type="text/javascript" src="<%=request.getContextPath()%>/plugins/bootstrap-daterangepicker/moment.min.js"
charset="utf-8"></script>
<script type="text/javascript"
src="<%=request.getContextPath()%>/plugins/bootstrap-daterangepicker/daterangepicker.js"
charset="utf-8"></script>
<style type="text/css">
</style>
<script type="text/javascript">
var websocket = null;
var beginTimeStore = '';
var endTimeStore = '';
$(function () {
var width = $(window).width();
var height = $(window).height();
$('#videos').css('width', width);
$('#videos').css('height', height);
if ('${time}' != "") {
beginTimeStore = '${time}'
} else {
//定义locale汉化插件
beginTimeStore = moment().subtract(1, 'days').format('YYYY-MM-DD HH:mm');
}
// endTimeStore = moment().format('YYYY-MM-DD HH:mm');
var locale = {
"format": 'YYYY-MM-DD HH:mm',
"separator": " ~ ",
"applyLabel": "确定",
"cancelLabel": "取消",
"fromLabel": "起始时间",
"toLabel": "结束时间'",
"customRangeLabel": "自定义",
"weekLabel": "W",
"daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
"monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
"firstDay": 1
};
$('#reservationtime').daterangepicker({
"timePicker": true,
"timePicker24Hour": true,
// "timePickerIncrement": 10,
"singleDatePicker": true,
"locale": locale,
// //汉化按钮部分
// ranges: {
// '今日': [moment().subtract(1, 'days'), moment()],
// '昨日': [moment().subtract(2, 'days'), moment().subtract(1, 'days')],
// '最近7日': [moment().subtract(7, 'days'), moment()],
// '本月': [moment().startOf('month'), moment().endOf('month')],
// '上月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
// },
startDate: beginTimeStore,
// endDate: endTimeStore
}, function (start, end, label) {
beginTimeStore = start.format(this.locale.format);
// endTimeStore = end.format(this.locale.format);
if (!this.startDate) {
this.element.val('');
} else {
this.element.val(this.startDate.format(this.locale.format));
}
websocket.close();
viewThisCamera('${id}', '${online}');
});
$('#reservationtime').val(beginTimeStore);
viewThisCamera('${id}', '${online}');
})
$(window).resize(function () {
var width = $(window).width();
var height = $(window).height();
$('#videos').css('width', width);
$('#videos').css('height', height);
});
function viewThisCamera(id, online) {
// console.log(id + '---' + online);
if (!online) {
swal('该摄像头无法连接。');
return;
}
var restartDialog;
//判断当前浏览器是否支持WebSocket
if ('WebSocket' in window) {
var time = beginTimeStore;
console.log("time is ", time)
$.post(ext.contextPath + '/work/camera/getCameraById.do', {
id: id
}, function (data) {
var camera = JSON.parse(data);
$.ajax({
type: 'GET',
url: ext.contextPath + "/work/camera/isNet.do?nowUrl=" + window.location.host,
async: false,
globle: false,
dataType: 'json',
error: function () {
return false;
},
success: function (data) {
let hostUrl = window.location.href;
if (hostUrl.substring(0, 5) == 'https') {
data.url = data.url.replace('ws', 'wss');
}
if (camera.cameraNVR == '' || camera.cameraNVR == null) {
cameraUrl = "" + data.url + "/videoWebSocket/" + camera.type + "/" + camera.url + "/" + camera.username + "/" + camera.password + "/" + camera.channel + "/" + time + "/${uuid}" + "/${param.definitionSt}";
} else {
cameraUrl = "" + data.url + "/videoWebSocket/" + camera.type + "/" + camera.cameraNVR.ip + "/" + camera.cameraNVR.username + "/" + camera.cameraNVR.password + "/" + camera.cameraNVR.channel + "/" + time + "/${uuid}" + "/${param.definitionSt}";
}
websocket = new WebSocket(cameraUrl);
<%--websocket = new WebSocket("" + data.url + "/videoWebSocket/" + camera.type + "/" + camera.cameraNVR.ip + "/" + camera.cameraNVR.username + "/" + camera.cameraNVR.password + "/" + camera.cameraNVR.channel + "/" + time + "/${uuid}" + "/${param.definitionSt}");--%>
<%--console.log("" + data.url + "/videoWebSocket/" + camera.type + "/" + camera.url + "/" + camera.username + "/" + camera.password + "/" + camera.channel + "/" + time + "/${uuid}" + "/${param.definitionSt}")--%>
<%--if (data.type == '1') {--%>
<%-- websocket = new WebSocket("" + data.url + "/videoWebSocket/" + camera.type + "/" + camera.url + "/" + camera.username + "/" + camera.password + "/" + camera.channel + "/" + time + "/${uuid}" + "/${param.definitionSt}");--%>
<%--} else if (data.type == '2') {--%>
<%-- websocket = new WebSocket("" + data.url + "/videoWebSocket/" + camera.type + "/" + camera.netUrl + "/" + camera.username + "/" + camera.password + "/" + camera.channel + "/" + time + "/${uuid}" + "/${param.definitionSt}");--%>
<%--}--%>
}
});
websocket.onerror = function () {
};
//连接成功建立的回调方法
websocket.onopen = function () {
console.info('消息滚动websocker开启');
}
//接收到消息的回调方法
websocket.onmessage = function (event) {
// var result = JSON.parse(event.data);
$("#show_video_his").attr("src", event.data);
}
})
<%--websocket = new WebSocket(ext.basePath.replace("http", "ws") + "/videoWebSocket/" + id + "/" + time + "/${uuid}");--%>
} else {
alert('当前浏览器 Not support websocket')
}
}
</script>
</head>
<body style="background-color: rgb(23, 39, 55);">
<div id="videos" style="float: left;background-color: rgb(23, 39, 55);">
<div style="width: 100%;height: 34px;float: left;background-color: rgb(23, 39, 55);">
<label style="color: #FFFFFF;float: left;margin-left: 5px;line-height: 34px;">回放时间</label>
<input type="text" class="form-control pull-left" id="reservationtime"
style="width:150px;background-color: rgb(23, 39, 55);color: #FFFFFF;margin-left: 5px;">
<%-- <div class="input-group-btn pull-left">--%>
<%-- <button style="background-color: rgb(23, 39, 55);color: #FFFFFF" type="button" class="btn btn-default"--%>
<%-- onclick="showHisCamera();"><i--%>
<%-- class="fa fa-search"></i> 查询--%>
<%-- </button>--%>
<%-- </div>--%>
</div>
<div style="width: 100%;height: calc(100% - 34px);float: left;background-color: rgb(23, 39, 55);" id="video_1">
<img id="show_video_his" style="width: 100%;height: 100%;" src="">
</div>
</div>
</body>
</html>