var layer;
var form;
var table;
var element;
var quantityData;
var quantityDto;
var player;
var warnList;
var timer;
$(function () {
layui.use(['layer', 'laydate', 'form', 'table', 'element'], function () {
element = layui.element;
form = layui.form;
layer = layui.layer;
table = layui.table;
form.render();
// 监听仓库选择
form.on('select(select_depotId)', function (obj) {
depotId = $("#depotId").val();
flushQuantity();
getCamera();
flushWarnData();
});
// 初始化WebSocket
initWS(deptId, bizType,null, userId);
//初始粮面图
render3D();
});
});
//页面初始化后调整背景图片
window.onload = function () {
// if (depotId) {
// $("#depotId").val(depotId);
// form.render();
// getCamera();
// }
};
/**
* 获取摄像头
*/
function getCamera() {
if (!depotId) {
layer.msg("请先选择仓库!");
return;
}
var data = {
depotId: depotId
};
$.ajax({
type: "POST",
url: "../../basic/quantity/quantity-camera",
dataType: "json",
contentType: "application/json;charset=UTF-8",
data: JSON.stringify(data),
success: function (result) {
if (result.code != "0000") {
layer.msg(result.msg,
{time: 3000, shift: 5, offset: "rb"},
function () {
});
} else {
quantityDto = result.data;
// 信息赋值
openVideo();
layer.msg("获取摄像头成功……",
{time: 3000, shift: 5, offset: "rb"},
function () {
});
}
},
error: function () {
layer.msg("根据当前条件获取数据失败!!");
}
});
}
/**
* 播放
*/
function openVideo() {
console.log(quantityDto);
var htm = "";
if (PlayType.VLC == quantityDto.playType) {
htm = "";
}
if (quantityDto.playAddr && PlayType.MEDIA_EASY == quantityDto.playType) {
htm = "";
//定时器-保活直播
if (timer) clearInterval(timer);
timer = setInterval(function () {
keepAlive();
}, 15*1000);
}
if (quantityDto.playAddr && PlayType.MEDIA == quantityDto.playType) {
htm = "";
}
$("#quantity_video").html(htm);
}
// socket信息返回處理
function socketOnMessage(pocket) {
if (pocket.orderResp == "MSG_SUCCESS") {// 信息解析成功刷新当前数据
flushQuantity();
}
// 表示是执行进度信息
if (pocket.orderResp == "ORDER_INPROGRESS") {
window.parent.sysNotify(pocket.data.msg);
layer.msg(pocket.data.msg, {
time: 3000 //20s后自动关闭
// ,offset: 'rb'
});
}
};
// 刷新数据
function flushQuantity() {
// depotId = $("#depotId").val();
if (!depotId) {
layer.msg("请先选择仓库!");
return;
}
var d = {
depotId: depotId,
};
$.ajax({
type: "POST",
url: "../../basic/quantity/query-data",
dataType: "json",
contentType: "application/json;charset=UTF-8",
data: JSON.stringify(d),
success: function (result) {
quantityData = result.data;
data = quantityData.points;
// 信息赋值
renderQuantityInfo();
if(data){
render3D();
}
// layer.msg("更新成功……");
},
error: function () {
layer.msg("根据当前条件获取数据失败!!");
}
});
};
/**
* 刷新警告数据
*/
function flushWarnData(){
var data = {
depotId: depotId,
};
$.ajax({
type: "POST",
url: "../../basic/quantity/quantity-warn",
dataType: "json",
contentType: "application/json;charset=UTF-8",
data: JSON.stringify(data),
success: function (result) {
warnList = result.data;
// 信息赋值
// layer.msg("获取数据成功……");
renderWarnInfo();
},
error: function () {
layer.msg("根据当前条件获取数据失败!!");
}
});
}
/**
* 渲染警告数据
*/
function renderWarnInfo(){
if(warnList){
var html = "";
for(var i = 0;i < warnList.length;i++){
html += "
\n" +
"" + warnList[i].name + " | \n" +
" " + warnList[i].time + " | \n" +
"
";
}
$("#warnList").html(html);
}
}
// 填写粮情信息
function renderQuantityInfo() {
if (!quantityData) {
return;
}
// 配置仓库卡片信息
var depotData = quantityData.depotData;
$("#depotTypeName").text(depotData.depotTypeName);
$("#storeKeeperName").text(depotData.storeKeeperName);
$("#storageReal").text(depotData.storageReal);
$("#foodVarietyName").text(depotData.foodVarietyName);
$("#foodLevelName").text(depotData.foodLevelName);
$("#foodTypeName").text(depotData.foodTypeName);
$("#foodYear").text(depotData.foodYear);
$("#bulk").text(quantityData.bulk);
$("#weight").text(quantityData.weight);
$("#receiveDate").text(quantityData.receiveDate);
if (quantityData.points) {
data = JSON.parse(quantityData.points);
render3D();
}
}
function checkQuantity() {
if (!depotId) {
layer.msg("请先选择仓库!");
return;
}
layer.msg("开始执行……");
var data = {
'depotId': depotId
};
$.ajax({
type: "POST",
url: "../../basic/quantity/check-single",
dataType: "json",
contentType: "application/json;charset=UTF-8",
data: JSON.stringify(data),
success: function (result) {
if (result.code != "ORDER_SUCCESS") {
if (result.msg) {
layer.msg(result.msg);
} else {
layer.msg("执行出现异常,请重试或联系管理员");
}
} else {
layer.msg("命令已经成功发送,待终端响应……");
}
},
error: function () {
layer.msg("检测出现异常,执行失败!");
}
});
}
function closeWarn() {
if (!depotId) {
layer.msg("请先选择仓库!");
return;
}
layer.msg("开始执行……");
var data = {
'depotId': depotId
};
$.ajax({
type: "POST",
url: "../../basic/quantity/close-warn",
dataType: "json",
contentType: "application/json;charset=UTF-8",
data: JSON.stringify(data),
success: function (result) {
if (result.code != "ORDER_SUCCESS") {
if (result.msg) {
layer.msg(result.msg);
} else {
layer.msg("执行出现异常,请重试或联系管理员");
}
} else {
layer.msg("命令已经成功发送,待响应……");
}
},
error: function () {
layer.msg("检测出现异常,执行失败!");
}
});
}
//--------------------------视频管理------------------------//
/**
* 保活,msg参数为了防止浏览器缓存
*/
function keepAlive() {
var data = {
playType: quantityDto.playType,
sn: quantityDto.cameraSn,
ip: quantityDto.ip,
msg: Math.random()
};
$.ajax({
type: 'POST',
url: "../../basic/security/keep-alive",
dataType: 'JSON',
contentType: "application/json;charset=UTF-8",
data: JSON.stringify(data),
success: function (result) {
},
error: function (result) {
}
});
}
/**
* 播放还是暂停
*/
function playStop() {
var videL = $('#easyPlayer');
if (videL.paused) {
videL.play();
} else {
videL.pause();
}
}
/**
* 云台控制 -转向控制
* @param tag 执行命令 1=上,2=下,3=左,4=右,5=左上,6=左下,7=右上,8=右下,0=停止,9=变倍小,10 = 变倍加
*
*/
function mouseDownPTZControl(tag) {
layer.msg("开始调用云平台……",
{time: 3000, shift: 5, offset: "rb"},
function () {
});
var data = {
playType: quantityDto.playType,
sn: quantityDto.cameraSn,
ip:quantityDto.ip,
portV:quantityDto.portWeb,
loginId:quantityDto.loginId,
pwd:quantityDto.pwd,
command: tag
};
var url = "";
if (PlayType.VLC == quantityDto.playType) {
url = "../../basic/security/ptz-onvif"
}
if (PlayType.MEDIA_EASY == quantityDto.playType) {
url = "../../basic/security/ptz-media"
}
$.ajax({
type: 'POST',
url: url,
dataType: 'JSON',
contentType: "application/json;charset=UTF-8",
data: JSON.stringify(data),
success: function (result) {
if ("ERROR" == result.code) {
layer.msg(result.msg,
{time: 3000, shift: 5, offset: "rb"},
function () {
});
} else {
layer.msg("执行成功……",
{time: 3000, shift: 5, offset: "rb"},
function () {
});
}
},
error: function (result) {
layer.msg(result.msg,
{time: 3000, shift: 5, offset: "rb"},
function () {
});
}
});
}
/**
* 云台控制 -转向停止
* @param tag
*/
function mouseUpPTZControl() {
var data = {
playType: quantityDto.playType,
sn: quantityDto.cameraSn,
ip:quantityDto.ip,
portV:quantityDto.portWeb,
loginId:quantityDto.loginId,
pwd:quantityDto.pwd,
command: "0"
};
var url = "";
if (PlayType.VLC == quantityDto.playType) {
url = "../../basic/security/ptz-onvif"
}
if (PlayType.MEDIA_EASY == quantityDto.playType) {
url = "../../basic/security/ptz-media"
}
$.ajax({
type: 'POST',
url: url,
dataType: 'JSON',
contentType: "application/json;charset=UTF-8",
data: JSON.stringify(data),
success: function (result) {
if ("ERROR" == result.code) {
layer.msg(result.msg,
{time: 3000, shift: 5, offset: "rb"},
function () {
});
}
},
error: function (result) {
layer.msg(result.msg,
{time: 3000, shift: 5, offset: "rb"},
function () {
});
}
});
}
/**
* 云台控制 -预置位置调用
*/
function clickGoPreset() {
layer.msg("开始调用云平台……",
{time: 3000, shift: 5, offset: "rb"},
function () {
});
var preset = $("#preset").val();
var data = {
playType: quantityDto.playType,
sn: quantityDto.cameraSn,
ip:quantityDto.ip,
portV:quantityDto.portWeb,
loginId:quantityDto.loginId,
pwd:quantityDto.pwd,
command: "2",
preset: preset
};
var url = "";
if (PlayType.VLC == quantityDto.playType) {
url = "../../basic/security/preset-onvif"
}
if (PlayType.MEDIA_EASY == quantityDto.playType) {
url = "../../basic/security/video-preset"
}
$.ajax({
type: 'POST',
url: url,
dataType: 'JSON',
contentType: "application/json;charset=UTF-8",
data: JSON.stringify(data),
success: function (result) {
if ("ERROR" == result.code) {
layer.msg(result.msg,
{time: 3000, shift: 5, offset: "rb"},
function () {
});
} else {
layer.msg("执行成功……",
{time: 3000, shift: 5, offset: "rb"},
function () {
});
}
},
error: function (result) {
layer.msg(result.msg,
{time: 3000, shift: 5, offset: "rb"},
function () {
});
}
});
}
/**
* PTZZoomout 变倍 +
* @constructor
*/
function PTZZoomout() {
layer.msg("开始调用云平台……",
{time: 3000, shift: 5, offset: "rb"},
function () {
});
var data = {
playType: quantityDto.playType,
sn: quantityDto.cameraSn,
ip:quantityDto.ip,
portV:quantityDto.portWeb,
loginId:quantityDto.loginId,
pwd:quantityDto.pwd,
command: "10"
};
var url = "";
if (PlayType.VLC == quantityDto.playType) {
url = "../../basic/security/ptz-onvif"
}
if (PlayType.MEDIA_EASY == quantityDto.playType) {
url = "../../basic/security/ptz-media"
}
$.ajax({
type: 'POST',
url: url,
dataType: 'JSON',
contentType: "application/json;charset=UTF-8",
data: JSON.stringify(data),
success: function (result) {
if ("ERROR" == result.code) {
layer.msg(result.msg,
{time: 3000, shift: 5, offset: "rb"},
function () {
});
} else {
layer.msg("执行成功……",
{time: 3000, shift: 5, offset: "rb"},
function () {
});
}
},
error: function (result) {
layer.msg(result.msg,
{time: 3000, shift: 5, offset: "rb"},
function () {
});
}
});
}
/**
* PTZZoomout 变倍 -
* @constructor
*/
function PTZZoomIn() {
layer.msg("开始调用云平台……",
{time: 3000, shift: 5, offset: "rb"},
function () {
});
var data = {
playType: quantityDto.playType,
sn: quantityDto.cameraSn,
ip:quantityDto.ip,
portV:quantityDto.portWeb,
loginId:quantityDto.loginId,
pwd:quantityDto.pwd,
command: "9"
};
var url = "";
if (PlayType.VLC == quantityDto.playType) {
url = "../../basic/security/ptz-onvif"
}
if (PlayType.MEDIA_EASY == quantityDto.playType) {
url = "../../basic/security/ptz-media"
}
$.ajax({
type: 'POST',
url: url,
dataType: 'JSON',
contentType: "application/json;charset=UTF-8",
data: JSON.stringify(data),
success: function (result) {
if ("ERROR" == result.code) {
layer.msg(result.msg,
{time: 3000, shift: 5, offset: "rb"},
function () {
});
} else {
layer.msg("执行成功……",
{time: 3000, shift: 5, offset: "rb"},
function () {
});
}
},
error: function (result) {
layer.msg(result.msg,
{time: 3000, shift: 5, offset: "rb"},
function () {
});
}
});
}
/**
* PTZZoomout 变倍停止
* @constructor
*/
function PTZZoomStop() {
}