Merge pull request !25 from 打豆豆/master
This commit is contained in:
打豆豆 2024-04-08 01:19:48 +00:00 committed by Gitee
commit a4cdf09ca1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
14 changed files with 506 additions and 709 deletions

View File

@ -44,9 +44,12 @@
"dhtmlx-gantt": "^7.1.11", "dhtmlx-gantt": "^7.1.11",
"echarts": "4.9.0", "echarts": "4.9.0",
"element-ui": "2.15.6", "element-ui": "2.15.6",
"ezuikit-js": "^0.7.2",
"file-saver": "2.0.5", "file-saver": "2.0.5",
"flv.js": "^1.6.2",
"fuse.js": "6.4.3", "fuse.js": "6.4.3",
"highlight.js": "9.18.5", "highlight.js": "9.18.5",
"jquery": "^3.7.1",
"js-beautify": "1.13.0", "js-beautify": "1.13.0",
"js-cookie": "3.0.1", "js-cookie": "3.0.1",
"jsencrypt": "3.0.0-rc.1", "jsencrypt": "3.0.0-rc.1",

View File

@ -205,8 +205,5 @@
<div class="load_title">正在加载系统资源,请耐心等待</div> <div class="load_title">正在加载系统资源,请耐心等待</div>
</div> </div>
</div> </div>
<script type="text/javascript" src="./static/haikang/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="./static/haikang/jsencrypt.min.js"></script>
<script type="text/javascript" src="./static/haikang/web-control_1.2.5.min.js"></script>
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -37,9 +37,10 @@
{{ this.title }} {{ this.title }}
</div> </div>
<div <div
style="color: rgb(9 207 255); font-size: 21px; margin-bottom: 4%" style="color: rgb(9 207 255); font-size: 18px; margin-bottom: 4%"
> >
2024.01.11 09:18:18 <span>{{ this.dateYear }}</span> {{ this.dateDay }}
<span>{{ this.dateWeek }}</span>
</div> </div>
</el-col> </el-col>
<el-col :span="10" <el-col :span="10"
@ -367,6 +368,7 @@
</template> </template>
<script> <script>
import dayjs from "dayjs";
// import * as statisServer from "@/api/statistics"; // import * as statisServer from "@/api/statistics";
// import { getInfo } from "@/api/user"; // import { getInfo } from "@/api/user";
import screenfull from "screenfull"; import screenfull from "screenfull";
@ -378,9 +380,31 @@ import roboticRate from "./components/roboticRate.vue";
import AGVrate from "./components/AGVrate.vue"; import AGVrate from "./components/AGVrate.vue";
export default { export default {
components: { online, offline, fault, onlineRate, roboticRate, AGVrate }, components: {
online,
offline,
fault,
onlineRate,
roboticRate,
AGVrate,
dayjs,
},
data() { data() {
return { return {
dateDay: null,
dateYear: null,
dateWeek: null,
weekday: [
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六",
],
timer: null,
screenfull: false, screenfull: false,
title: "设备监控分析", title: "设备监控分析",
titleVisible: false, titleVisible: false,
@ -414,6 +438,12 @@ export default {
}, },
created() { created() {
this.timer = setInterval(() => {
const date = dayjs(new Date());
this.dateDay = date.format("HH:mm:ss");
this.dateYear = date.format("YYYY-MM-DD");
this.dateWeek = date.format(this.weekday[date.day()]);
}, 1000);
// //
window.addEventListener("resize", this.onresize); window.addEventListener("resize", this.onresize);
this.getList(); this.getList();
@ -426,10 +456,13 @@ export default {
this.factorNumber(); this.factorNumber();
}, },
// beforeDestroy() { beforeDestroy() {
// // if (this.timer) {
// window.removeEventListener("resize", this.onresize); clearInterval(this.timer);
// }, }
//
window.removeEventListener("resize", this.onresize);
},
methods: { methods: {
// //
onresize(event) { onresize(event) {

View File

@ -97,16 +97,16 @@ export default {
type: "category", type: "category",
boundaryGap: true, // boundaryGap: true, //
data: [ data: [
"2023-03",
"2023-04",
"2023-05",
"2023-06",
"2023-07", "2023-07",
"2023-08", "2023-08",
"2023-09", "2023-09",
"2023-10", "2023-10",
"2023-11", "2023-11",
"2023-12", "2023-12",
"2024-01",
"2024-02",
"2024-03",
"2024-04",
], ],
axisLabel: { axisLabel: {
// //

View File

@ -46,19 +46,19 @@ export default {
var scale = 1; var scale = 1;
var echartData = [ var echartData = [
{ {
value: 50, value: 5,
name: "材料不良", name: "材料不良",
}, },
{ {
value: 100, value: 1,
name: "工序不良", name: "工序不良",
}, },
{ {
value: 300, value: 2,
name: "尺寸不良", name: "尺寸不良",
}, },
{ {
value: 50, value: 1,
name: "其他不良", name: "其他不良",
}, },
]; ];

View File

@ -1,91 +0,0 @@
import { getPubKey, setEncrypt } from './pubKey'
var initCount = 0;
var oWebControl;
/**
*
* @param {*} id :组件容器id
* @param {*} iWidth :组件容器宽
* @param {*} iHeight :组件容器高
* @param {*}cbIntegrationCallBack消息推送回调函数
* @param {*} argument:初始化api参数
* @param {*} completeCallBack初始化成功回调函数
* @param {*} plugErrorCallBack插件启动失败回调函数
*/
const initPlugin = (id, iWidth, iHeight, argument, cbIntegrationCallBack = () => { }, completeCallBack = () => { }, plugErrorCallBack = () => { }) => {
// eslint-disable-next-line no-undef
oWebControl = new WebControl({
szPluginContainer: id, // 指定容器id
iServicePortStart: 15900, // 指定起止端口号,建议使用该值
iServicePortEnd: 15909,
szClassId: "23BF3B0A-2C56-4D97-9C03-0CB103AA8F11", // 用于IE10使用ActiveX的clsid
cbConnectSuccess: function () { // 创建WebControl实例成功
oWebControl.JS_StartService("window", { // WebControl实例创建成功后需要启动服务
dllPath: "./VideoPluginConnect.dll" // 值"./VideoPluginConnect.dll"写死
}).then(function () { // 启动插件服务成功
oWebControl.JS_SetWindowControlCallback({ // 设置消息回调
cbIntegrationCallBack: cbIntegrationCallBack
});
oWebControl.JS_CreateWnd(id, iWidth, iHeight).then(function () { //JS_CreateWnd创建视频播放窗口宽高可设定
init(argument, iWidth, iHeight,completeCallBack()); // 创建播放实例成功后初始化
});
}, function () { // 启动插件服务失败
});
},
// eslint-disable-next-line no-unused-vars
cbConnectError: function (e) { // 创建WebControl实例失败
oWebControl = null;
// eslint-disable-next-line no-undef
// $(id).html("插件未启动,正在尝试启动,请稍候...");
// eslint-disable-next-line no-undef
WebControl.JS_WakeUp("VideoWebPlugin://"); // 程序未启动时执行error函数采用wakeup来启动程序
initCount++;
if (initCount < 2) {
setTimeout(function () {
initPlugin(id, iWidth, iHeight, argument, cbIntegrationCallBack,completeCallBack,plugErrorCallBack);
}, 1000)
} else {
// eslint-disable-next-line no-undef
// $(id).html("插件启动失败,请检查插件是否安装!");
plugErrorCallBack()
}
},
// eslint-disable-next-line no-unused-vars
cbConnectClose: function (bNormalClose) {
// 异常断开bNormalClose = false
// JS_Disconnect正常断开bNormalClose = true
console.log("cbConnectClose");
oWebControl = null;
}
});
return oWebControl
}
//初始化
function init(argument, iWidth, iHeight,callback=()=>{}) {
getPubKey(oWebControl, function () {
oWebControl.JS_RequestInterface({
funcName: "init",
argument: JSON.stringify({
...argument,
secret: setEncrypt(argument.secret)
})
// eslint-disable-next-line no-unused-vars
}).then(function (oData) {
callback()
//oWebControl.JS_Resize(iWidth, iHeight); // 初始化后resize一次规避firefox下首次显示窗口后插件窗口未与DIV窗口重合问题
});
})
}
export default initPlugin

View File

@ -1,24 +0,0 @@
var pubKey;
//获取公钥
export function getPubKey(oWebControl,callback) {
// eslint-disable-next-line no-undef
oWebControl.JS_RequestInterface({
funcName: "getRSAPubKey",
argument: JSON.stringify({
keyLength: 1024
})
}).then(function (oData) {
if (oData.responseMsg.data) {
pubKey = oData.responseMsg.data;
callback()
}
})
}
//RSA加密
export function setEncrypt(value) {
// eslint-disable-next-line no-undef
var encrypt = new JSEncrypt();
encrypt.setPublicKey(pubKey);
return encrypt.encrypt(value);
}

View File

@ -1,495 +1,115 @@
<template> <template>
<div class="hk-video-container" id="playWnd"> <div style="overflow-y: scroll; overflow-x: hidden; height: 100%">
<!-- 下载插件提示框 --> <section
<el-dialog style="display: flex; justify-content: space-around; flex-wrap: wrap"
v-if="downloadDialog"
title="提示"
:visible.sync="dialogVisible"
width="30%"
> >
<span <span
>{{downloadText}}</span class="video_warp_item"
v-for="(item, index) in liveAddress"
v-if="index < 3"
:key="index"
> >
<span slot="footer" class="dialog-footer"> <div :id="'video-player-' + index"></div>
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="handleDownloadExe">下载</el-button>
</span> </span>
</el-dialog> </section>
</div> </div>
</template> </template>
<script> <script>
import initPlugin from "./lib/initPlugin"; import $ from "jquery"; // npm i jquery
import EZUIKit from "ezuikit-js";
export default { export default {
name: "hkVideo", name: "dashboard",
props: {
width: {
type: Number,
default: 500,
},
height: {
type: Number,
default: 300,
},
//
// appkey: appkey, //APIappkey
// secret: secret, //APIsecret
// ip: ip, //APIIP
// playMode: playMode, //
// port: port, //
// snapDir: snapDir, //
// videoDir: videoDir, //
// layout: layout, //
// enableHTTPS: enableHTTPS, //HTTPS
// encryptedFields: encryptedFields, //
// showToolbar: showToolbar, //
// showSmart: showSmart, //
// buttonIDs: buttonIDs //
argument: {
type: Object,
default: () => {},
},
//01
playMode: {
type: Number,
default: 0,
},
//
autoResize: {
type: Boolean,
default: true,
},
//
downloadDialog: {
type: Boolean,
default: false,
},
//url
downloadUrl: {
type: String,
default: "",
},
downloadText:{
type:String,
default:'插件启动失败,请检查插件是否安装,如果未安装请点击下载安装,安装后刷新页面'
}
},
data() { data() {
return { return {
curWindIndex: 1, //1 accessToken: "",
oWebControl: null, // liveAddress: [],
iWidth: "", // diveType: "",
iHeight: "", // players: [],
options: {
appkey: "admin", //APIappkey
secret: "mygymygy.", //APIsecret
ip: "192.168.2.107", //APIIP
playMode: 0, //
port: 443, //
snapDir: "D:\\SnapDir", //
videoDir: "D:\\VideoDir", //
layout: "3x3", //
enableHTTPS: 1, //HTTPS
encryptedFields: "secret", //
showToolbar: 1,
showSmart: 1,
buttonIDs:
"0,1,16,256,257,258,259,260,512,513,514,515,516,517,768,769,770", //
},
rate: 0, //
isInitComolete: false, //
dialogVisible: false,
}; };
}, },
watch: {
width: { created() {
handler(val) { this.getbagndianID();
this.iWidth = val;
if (this.isInitComolete) {
this.setRate();
this.setResize(this.iWidth, this.iHeight);
}
},
immediate: true,
},
height: {
handler(val) {
this.iHeight = val;
if (this.isInitComolete) {
this.setRate();
this.setResize(this.iWidth, this.iHeight);
}
},
immediate: true,
},
playMode() {
this.reInit();
},
},
mounted() {
this.init();
this.handleWindEvent();
this.$nextTick(() => {
this.setRate();
});
},
beforeDestroy() {
if (this.oWebControl != null) {
this.oWebControl.JS_HideWnd(); //
this.oWebControl.JS_Disconnect().then(
function () {
//
},
function () {
//
}
);
}
}, },
methods: { methods: {
// // ID
init() { getbagndianID() {
let argument = { const This = this;
...this.options, // accessToken
...this.argument, $.ajax({
}; url: "https://open.ys7.com/api/lapp/token/get",
if (this.playMode > -1 && this.playMode < 2) { type: "POST",
argument.playMode = this.playMode; dataType: "json",
} data: {
// eslint-disable-next-line no-undef appKey: "4aea64fb66cd46e8ae2ded25e6dbf5bf", //String appKey Y
this.iWidth = Math.min(this.iWidth, $(window).width()); appSecret: "9011246f97d2d65ce33ab7c23e7a72de", // String appSecret Y
this.oWebControl = initPlugin(
"playWnd",
this.iWidth,
this.iHeight,
argument,
this.cbIntegrationCallBack,
() => {
this.setRate();
this.setResize(this.iWidth, this.iHeight);
this.isInitComolete = true;
this.$emit("initFinish");
}, },
() => { cache: false,
if (this.downloadDialog) { success: function (response) {
this.dialogVisible = true; This.accessToken = response.data.accessToken;
} $.ajax({
this.$emit("pluginError"); url: "https://open.ys7.com/api/lapp/camera/list",
} header: {
); "Content-Type": "application/x-www-form-urlencoded",
}, },
// type: "POST",
reInit() { dataType: "json",
if (this.oWebControl) { data: {
this.oWebControl accessToken: This.accessToken, // String access_token Y
.JS_RequestInterface({ pageStart: 0,
funcName: "uninit", pageSize: 10,
})
.then(() => {
this.init();
});
}
}, },
setRate() { cache: false,
// eslint-disable-next-line no-undef success: function (response) {
var iWidth = $(window).width(); var arr = [];
this.rate = this.iWidth / iWidth; response.data.forEach((item, index) => {
}, if (item.channelNo == 3 || item.channelNo == 4) {
//
handleWindEvent() {
// resize使DIV
// eslint-disable-next-line no-undef
if (this.autoResize) {
// eslint-disable-next-line no-undef
$(window).resize(() => {
if (this.oWebControl) {
// eslint-disable-next-line no-undef
var iWidth = $(window).width();
// eslint-disable-next-line no-undef
this.iWidth = iWidth * this.rate;
this.oWebControl.JS_Resize(this.iWidth, this.iHeight);
this.setWndCover();
}
});
}
// scroll使
// eslint-disable-next-line no-undef
$(window).scroll(() => {
if (this.oWebControl) {
this.oWebControl.JS_Resize(this.iWidth, this.iHeight);
this.setWndCover();
}
});
},
//
cbIntegrationCallBack(oData) {
if (oData?.responseMsg?.type) {
let data = oData.responseMsg;
switch (data.type) {
//
case 1:
if (this.curWindIndex !== data.msg.wndId) {
this.curWindIndex = data.msg.wndId;
this.$emit("windowChange", this.curWindIndex);
}
break;
//
case 6:
this.$emit("layoutChange", data.msg);
break;
}
}
},
// JS_CuttingPartWindow
setWndCover() {
// eslint-disable-next-line no-undef
var iWidth = $(window).width();
// eslint-disable-next-line no-undef
var iHeight = $(window).height();
// eslint-disable-next-line no-undef
var oDivRect = $("#playWnd").get(0).getBoundingClientRect();
var iCoverLeft = oDivRect.left < 0 ? Math.abs(oDivRect.left) : 0;
var iCoverTop = oDivRect.top < 0 ? Math.abs(oDivRect.top) : 0;
var iCoverRight =
oDivRect.right - iWidth > 0 ? Math.round(oDivRect.right - iWidth) : 0;
var iCoverBottom =
oDivRect.bottom - iHeight > 0
? Math.round(oDivRect.bottom - iHeight)
: 0;
iCoverLeft = iCoverLeft > this.iWidth ? this.iWidth : iCoverLeft;
iCoverTop = iCoverTop > this.iHeight ? this.iHeight : iCoverTop;
iCoverRight = iCoverRight > this.iWidth ? this.iWidth : iCoverRight;
iCoverBottom = iCoverBottom > this.iHeight ? this.iHeight : iCoverBottom;
this.oWebControl.JS_RepairPartWindow(
0,
0,
this.iWidth + 1,
this.iHeight + 1
); // 1
if (iCoverLeft != 0) {
this.oWebControl.JS_CuttingPartWindow(0, 0, iCoverLeft, this.iHeight);
}
if (iCoverTop != 0) {
this.oWebControl.JS_CuttingPartWindow(
0,
0,
this.iWidth + 1,
iCoverTop + 1
); //
}
if (iCoverRight != 0) {
this.oWebControl.JS_CuttingPartWindow(
this.iWidth - iCoverRight,
0,
iCoverRight,
this.iHeight
);
}
if (iCoverBottom != 0) {
this.oWebControl.JS_CuttingPartWindow(
0,
this.iHeight - iCoverBottom,
this.iWidth,
iCoverBottom
);
}
},
/**
* @param {*} cameraIndexCode :获取输入的监控点编号值必填
* @param {*} argument:api参数,
* argument属性cameraIndexCode优先级高于函数参数cameraIndexCode
*/
startPreview(cameraIndexCode, argument = {}) {
if (this.oWebControl) {
let params = {
cameraIndexCode: cameraIndexCode, //
streamMode: 0, //
transMode: 1, //
gpuMode: 1, //GPU
wndId: -1,
};
this.oWebControl
.JS_RequestInterface({
funcName: "startPreview",
argument: JSON.stringify({
...params,
...argument,
}),
})
.then(() => {});
}
},
//
stopAllPreview() {
this.oWebControl.JS_RequestInterface({
funcName: "stopAllPreview",
});
},
//()
/**
* idArr:播放窗口序号数组
*/
stopListPreview(idArr) {
let list = idArr.map((item) => {
return {
wndId: item,
};
});
this.oWebControl.JS_RequestInterface({
funcName: "stopMultiPlay",
argument: {
list,
},
});
},
/**
* @param {*} cameraIndexCode :获取输入的监控点编号值必填
* @param {*} startTime:开始时间
* @param {*} endTime:结束时间
* @param {*} recordLocation://0-1-
* @param {*} argument:api参数
* argument属性cameraIndexCode优先级高于函数参数cameraIndexCode
*/
startPlayBack(
cameraIndexCode,
startTime,
endTime,
recordLocation = 0,
argument = {}
) {
var startTimeStamp = new Date(
startTime.replace("-", "/").replace("-", "/")
).getTime(); //
var endTimeStamp = new Date(
endTime.replace("-", "/").replace("-", "/")
).getTime(); //
// var recordLocation = 0; //0-1-
var transMode = 1; //0-UDP1-TCP
var gpuMode = 0; //GPU0-1-
var wndId = -1; //2x2
this.oWebControl.JS_RequestInterface({
funcName: "startPlayback",
argument: JSON.stringify({
cameraIndexCode: cameraIndexCode, //
startTimeStamp: Math.floor(startTimeStamp / 1000).toString(), //
endTimeStamp: Math.floor(endTimeStamp / 1000).toString(), //
recordLocation: recordLocation, //0-1-
transMode: transMode, //0-UDP1-TCP
gpuMode: gpuMode, //GPU0-1-
wndId: wndId, //
...argument,
}),
});
},
//
stopAllPlayBack() {
this.oWebControl.JS_RequestInterface({
funcName: "stopAllPlayback",
});
},
//
//latyou2x2
setLayout(layout) {
this.oWebControl.JS_RequestInterface({
funcName: " setLayout",
argument: {
layout,
},
});
},
/**
* @param {*} text :文字
* @param {*} x:相对播放窗口左上角的横坐标起点
* @param {*} y:相对播放窗口左上角的纵坐标起点
* @param {*} fontSize:字体大小
* @param {*} color:字体颜色默认白色
* @param {*} argument:api参数
* argument属性cameraIndexCode优先级高于函数参数cameraIndexCode
*/
drawText(
text,
x = 5,
y = 5,
fontSize = 20,
color = 16777215,
argument = {}
) {
this.oWebControl.JS_RequestInterface({
funcName: "drawOSD",
argument: {
text,
x,
y,
fontSize,
color,
...argument,
},
});
},
//
setFullScreen() {
this.oWebControl.JS_RequestInterface({
funcName: "setFullScreen",
});
},
//退
exitFullScreen() {
this.oWebControl.JS_RequestInterface({
funcName: "exitFullScreen",
});
},
//
snapShot(argument = {}) {
this.oWebControl.JS_RequestInterface({
funcName: "snapShot",
argument,
});
},
//
hideWindow() {
this.oWebControl.JS_HideWnd();
},
//
showWindow() {
this.oWebControl.JS_ShowWnd();
},
//
setResize(width, height) {
this.oWebControl.JS_Resize(width, height);
this.setWndCover();
},
//
handleDownloadExe() {
this.dialogVisible = false;
if (this.downloadUrl) {
this.downloadFile(this.downloadUrl);
} else { } else {
console.log("下载地址为空"); arr.push(item);
} }
this.$emit("clickDownload"); });
console.log(arr);
arr.forEach((item, index) => {
$.ajax({
url: "https://open.ys7.com/api/lapp/v2/live/address/get",
type: "POST",
dataType: "json",
data: {
accessToken: This.accessToken, // String access_token Y
deviceSerial: item.deviceSerial,
channelNo: item.channelNo,
}, },
// cache: false,
downloadFile(url, fileName = "") { success: (response) => {
const a = document.createElement("a"); let player = new EZUIKit.EZUIKitPlayer({
a.style.display = "none"; id: "video-player-" + index, // ID
if (fileName) { accessToken: This.accessToken,
a.setAttribute("download", fileName); url: response.data.url,
template: "voice", // simple - ;standard-;security - ();voice-; theme-
audio: 0, // 0 - 1 -
autoplay: false,
width: 190,
height: 150,
});
This.liveAddress.push(player);
console.log(This.liveAddress);
},
});
});
},
});
},
});
},
},
//
destroyed() {
for (var j = 0; j < this.players.length; j++) {
this.liveAddress[j].stop();
} }
a.setAttribute("href", url);
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(a.href);
document.body.removeChild(a);
},
}, },
}; };
</script> </script>
<style scoped>
</style>

View File

@ -0,0 +1,306 @@
var WebRtcStreamer = (function() {
/**
* Interface with WebRTC-streamer API
* @constructor
* @param {string} videoElement - id of the video element tag
* @param {string} srvurl - url of webrtc-streamer (default is current location)
*/
var WebRtcStreamer = function WebRtcStreamer (videoElement, srvurl) {
if (typeof videoElement === "string") {
this.videoElement = document.getElementById(videoElement);
} else {
this.videoElement = videoElement;
}
this.srvurl = srvurl || location.protocol+"//"+window.location.hostname+":"+window.location.port;
this.pc = null;
this.mediaConstraints = { offerToReceiveAudio: true, offerToReceiveVideo: true };
this.iceServers = null;
this.earlyCandidates = [];
}
WebRtcStreamer.prototype._handleHttpErrors = function (response) {
if (!response.ok) {
throw Error(response.statusText);
}
return response;
}
/**
* Connect a WebRTC Stream to videoElement
* @param {string} videourl - id of WebRTC video stream
* @param {string} audiourl - id of WebRTC audio stream
* @param {string} options - options of WebRTC call
* @param {string} stream - local stream to send
*/
WebRtcStreamer.prototype.connect = function(videourl, audiourl, options, localstream) {
this.disconnect();
// getIceServers is not already received
if (!this.iceServers) {
console.log("Get IceServers");
fetch(this.srvurl + "/api/getIceServers")
.then(this._handleHttpErrors)
.then( (response) => (response.json()) )
.then( (response) => this.onReceiveGetIceServers(response, videourl, audiourl, options, localstream))
.catch( (error) => this.onError("getIceServers " + error ))
} else {
this.onReceiveGetIceServers(this.iceServers, videourl, audiourl, options, localstream);
}
}
/**
* Disconnect a WebRTC Stream and clear videoElement source
*/
WebRtcStreamer.prototype.disconnect = function() {
if (this.videoElement?.srcObject) {
this.videoElement.srcObject.getTracks().forEach(track => {
track.stop()
this.videoElement.srcObject.removeTrack(track);
});
}
if (this.pc) {
fetch(this.srvurl + "/api/hangup?peerid=" + this.pc.peerid)
.then(this._handleHttpErrors)
.catch( (error) => this.onError("hangup " + error ))
try {
this.pc.close();
}
catch (e) {
console.log ("Failure close peer connection:" + e);
}
this.pc = null;
}
}
/*
* GetIceServers callback
*/
WebRtcStreamer.prototype.onReceiveGetIceServers = function(iceServers, videourl, audiourl, options, stream) {
this.iceServers = iceServers;
this.pcConfig = iceServers || {"iceServers": [] };
try {
this.createPeerConnection();
var callurl = this.srvurl + "/api/call?peerid=" + this.pc.peerid + "&url=" + encodeURIComponent(videourl);
if (audiourl) {
callurl += "&audiourl="+encodeURIComponent(audiourl);
}
if (options) {
callurl += "&options="+encodeURIComponent(options);
}
if (stream) {
this.pc.addStream(stream);
}
// clear early candidates
this.earlyCandidates.length = 0;
// create Offer
this.pc.createOffer(this.mediaConstraints).then((sessionDescription) => {
console.log("Create offer:" + JSON.stringify(sessionDescription));
this.pc.setLocalDescription(sessionDescription)
.then(() => {
fetch(callurl, { method: "POST", body: JSON.stringify(sessionDescription) })
.then(this._handleHttpErrors)
.then( (response) => (response.json()) )
.catch( (error) => this.onError("call " + error ))
.then( (response) => this.onReceiveCall(response) )
.catch( (error) => this.onError("call " + error ))
}, (error) => {
console.log ("setLocalDescription error:" + JSON.stringify(error));
});
}, (error) => {
alert("Create offer error:" + JSON.stringify(error));
});
} catch (e) {
this.disconnect();
alert("connect error: " + e);
}
}
WebRtcStreamer.prototype.getIceCandidate = function() {
fetch(this.srvurl + "/api/getIceCandidate?peerid=" + this.pc.peerid)
.then(this._handleHttpErrors)
.then( (response) => (response.json()) )
.then( (response) => this.onReceiveCandidate(response))
.catch( (error) => this.onError("getIceCandidate " + error ))
}
/*
* create RTCPeerConnection
*/
WebRtcStreamer.prototype.createPeerConnection = function() {
console.log("createPeerConnection config: " + JSON.stringify(this.pcConfig));
this.pc = new RTCPeerConnection(this.pcConfig);
var pc = this.pc;
pc.peerid = Math.random();
pc.onicecandidate = (evt) => this.onIceCandidate(evt);
pc.onaddstream = (evt) => this.onAddStream(evt);
pc.oniceconnectionstatechange = (evt) => {
console.log("oniceconnectionstatechange state: " + pc.iceConnectionState);
if (this.videoElement) {
if (pc.iceConnectionState === "connected") {
this.videoElement.style.opacity = "1.0";
}
else if (pc.iceConnectionState === "disconnected") {
this.videoElement.style.opacity = "0.25";
}
else if ( (pc.iceConnectionState === "failed") || (pc.iceConnectionState === "closed") ) {
this.videoElement.style.opacity = "0.5";
} else if (pc.iceConnectionState === "new") {
this.getIceCandidate();
}
}
}
pc.ondatachannel = function(evt) {
console.log("remote datachannel created:"+JSON.stringify(evt));
evt.channel.onopen = function () {
console.log("remote datachannel open");
this.send("remote channel openned");
}
evt.channel.onmessage = function (event) {
console.log("remote datachannel recv:"+JSON.stringify(event.data));
}
}
pc.onicegatheringstatechange = function() {
if (pc.iceGatheringState === "complete") {
const recvs = pc.getReceivers();
recvs.forEach((recv) => {
if (recv.track && recv.track.kind === "video") {
console.log("codecs:" + JSON.stringify(recv.getParameters().codecs))
}
});
}
}
try {
var dataChannel = pc.createDataChannel("ClientDataChannel");
dataChannel.onopen = function() {
console.log("local datachannel open");
this.send("local channel openned");
}
dataChannel.onmessage = function(evt) {
console.log("local datachannel recv:"+JSON.stringify(evt.data));
}
} catch (e) {
console.log("Cannor create datachannel error: " + e);
}
console.log("Created RTCPeerConnnection with config: " + JSON.stringify(this.pcConfig) );
return pc;
}
/*
* RTCPeerConnection IceCandidate callback
*/
WebRtcStreamer.prototype.onIceCandidate = function (event) {
if (event.candidate) {
if (this.pc.currentRemoteDescription) {
this.addIceCandidate(this.pc.peerid, event.candidate);
} else {
this.earlyCandidates.push(event.candidate);
}
}
else {
console.log("End of candidates.");
}
}
WebRtcStreamer.prototype.addIceCandidate = function(peerid, candidate) {
fetch(this.srvurl + "/api/addIceCandidate?peerid="+peerid, { method: "POST", body: JSON.stringify(candidate) })
.then(this._handleHttpErrors)
.then( (response) => (response.json()) )
.then( (response) => {console.log("addIceCandidate ok:" + response)})
.catch( (error) => this.onError("addIceCandidate " + error ))
}
/*
* RTCPeerConnection AddTrack callback
*/
WebRtcStreamer.prototype.onAddStream = function(event) {
console.log("Remote track added:" + JSON.stringify(event));
this.videoElement.srcObject = event.stream;
var promise = this.videoElement.play();
if (promise !== undefined) {
promise.catch((error) => {
console.warn("error:"+error);
this.videoElement.setAttribute("controls", true);
});
}
}
/*
* AJAX /call callback
*/
WebRtcStreamer.prototype.onReceiveCall = function(dataJson) {
console.log("offer: " + JSON.stringify(dataJson));
var descr = new RTCSessionDescription(dataJson);
this.pc.setRemoteDescription(descr).then(() => {
console.log ("setRemoteDescription ok");
while (this.earlyCandidates.length) {
var candidate = this.earlyCandidates.shift();
this.addIceCandidate(this.pc.peerid, candidate);
}
this.getIceCandidate()
}
, (error) => {
console.log ("setRemoteDescription error:" + JSON.stringify(error));
});
}
/*
* AJAX /getIceCandidate callback
*/
WebRtcStreamer.prototype.onReceiveCandidate = function(dataJson) {
console.log("candidate: " + JSON.stringify(dataJson));
if (dataJson) {
for (var i=0; i<dataJson.length; i++) {
var candidate = new RTCIceCandidate(dataJson[i]);
console.log("Adding ICE candidate :" + JSON.stringify(candidate) );
this.pc.addIceCandidate(candidate).then( () => { console.log ("addIceCandidate OK"); }
, (error) => { console.log ("addIceCandidate error:" + JSON.stringify(error)); } );
}
this.pc.addIceCandidate();
}
}
/*
* AJAX callback for Error
*/
WebRtcStreamer.prototype.onError = function(status) {
console.log("onError:" + status);
}
return WebRtcStreamer;
})();
if (typeof window !== 'undefined' && typeof window.document !== 'undefined') {
window.WebRtcStreamer = WebRtcStreamer;
}
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = WebRtcStreamer;
}

View File

@ -37,9 +37,10 @@
{{ this.title }} {{ this.title }}
</div> </div>
<div <div
style="color: rgb(9 207 255); font-size: 21px; margin-bottom: 4%" style="color: rgb(9 207 255); font-size: 18px; margin-bottom: 4%"
> >
2024.02.27 14:11:00 <span>{{ this.dateYear }}</span> {{ this.dateDay }}
<span>{{ this.dateWeek }}</span>
</div> </div>
</el-col> </el-col>
<el-col :span="10" <el-col :span="10"
@ -105,7 +106,7 @@
class="grid-content bg-purple" class="grid-content bg-purple"
style="margin: 10% 10% 10% 37%" style="margin: 10% 10% 10% 37%"
> >
50% 80%
</div></el-col </div></el-col
> >
<el-col :span="4" <el-col :span="4"
@ -113,7 +114,7 @@
class="grid-content bg-purple" class="grid-content bg-purple"
style="margin: 10% 10% 10% 44%" style="margin: 10% 10% 10% 44%"
> >
121 9
</div></el-col </div></el-col
> >
<el-col :span="4" <el-col :span="4"
@ -146,7 +147,7 @@
<defective :message="this.defectiveData" /> <defective :message="this.defectiveData" />
</div> </div>
<div style="width: 30%; margin-top: 50px"> <div style="width: 30%; margin-top: 50px">
<hkVideo :monitoringNumber="cameraIndexCode"></hkVideo> <ezuikit></ezuikit>
</div> </div>
</div> </div>
<div style="height: 50%; display: flex"> <div style="height: 50%; display: flex">
@ -247,6 +248,7 @@
</template> </template>
<script> <script>
import dayjs from "dayjs";
import axios from "axios"; import axios from "axios";
import { listWorkorder } from "@/api/mes/pro/workorder"; import { listWorkorder } from "@/api/mes/pro/workorder";
@ -256,24 +258,28 @@ import screenfull from "screenfull";
import defective from "./components/defective.vue"; import defective from "./components/defective.vue";
import complete from "./components/complete.vue"; import complete from "./components/complete.vue";
import ticket from "./components/ticket.vue"; import ticket from "./components/ticket.vue";
import hkVideo from "./components/video.vue"; import ezuikit from "./components/video.vue";
export default { export default {
components: { defective, complete, ticket, hkVideo }, components: { defective, complete, ticket, ezuikit, dayjs },
data() { data() {
return { return {
cameraIndexCode: "1a033f81-a404-4a66-aabf-cb0ead6cc2be", //wed dateDay: null,
//wed dateYear: null,
objData: { dateWeek: null,
appkey: "", //appkey weekday: [
ip: "", //IP "星期日",
secret: "", //secret "星期一",
port: 443, //HTTPS443 "星期二",
playMode: 0, // 0 1 "星期三",
layout: "2x2", //16 "星期四",
showToolbar: 1, //0-0- "星期五",
}, "星期六",
],
timer: null,
rtSp1: "",
screenfull: false, screenfull: false,
title: "生产监控分析", title: "生产监控分析",
titleVisible: false, titleVisible: false,
@ -300,10 +306,18 @@ export default {
thisYear: false, thisYear: false,
isFullscreen: false, isFullscreen: false,
radio4: 1, radio4: 1,
monitorPoints: [],
}; };
}, },
created() { created() {
this.timer = setInterval(() => {
const date = dayjs(new Date());
this.dateDay = date.format("HH:mm:ss");
this.dateYear = date.format("YYYY-MM-DD");
this.dateWeek = date.format(this.weekday[date.day()]);
}, 1000);
// //
window.addEventListener("resize", this.onresize); window.addEventListener("resize", this.onresize);
this.getList(); this.getList();
@ -316,10 +330,13 @@ export default {
this.factorNumber(); this.factorNumber();
}, },
// beforeDestroy() { beforeDestroy() {
// // if (this.timer) {
// window.removeEventListener("resize", this.onresize); clearInterval(this.timer);
// }, }
//
window.removeEventListener("resize", this.onresize);
},
methods: { methods: {
// //
onresize(event) { onresize(event) {

View File

@ -526,6 +526,8 @@ export default {
}, },
// //
form: {}, form: {},
arrquantityRecived: "",
arraccepted: "",
// //
rules: { rules: {
recptCode: [ recptCode: [
@ -685,13 +687,22 @@ export default {
// //
handleExecute(row) { handleExecute(row) {
console.log(row); this.remainingquantity = 0;
this.recptIdsData = row.recptId; this.recptIdsData = row.recptId;
this.perform.recptId = row.recptId; this.perform.recptId = row.recptId;
this.warehousing = true; this.warehousing = true;
// //
listItemrecptline({ recptId: row.recptId }).then((response) => { listItemrecptline({ recptId: row.recptId }).then((response) => {
this.itemrecptlineList = response.rows; this.itemrecptlineList = response.rows;
response.rows.forEach((item) => {
var arr = 0;
this.arrquantityRecived = arr + item.quantityRecived;
});
response.rows.forEach((item) => {
var arr1 = 0;
this.arraccepted = arr1 + item.accepted;
});
this.remainingquantity = this.arrquantityRecived - this.arraccepted;
}); });
var queryParams = { var queryParams = {
pageNum: 1, pageNum: 1,
@ -719,10 +730,12 @@ export default {
submitFileForm() { submitFileForm() {
if (this.remainingquantity != 0) { if (this.remainingquantity != 0) {
axios axios
.get("http://192.168.2.104:8077/manage/matter/storageItem", { // .get("http://192.168.2.104:8077/manage/matter/storageItem", {
params: this.perform, .post(
}) "http://192.168.2.7:8077/manage/matter/storageItem",
.then((res) => { this.perform
)
.then(function (res) {
if (res.data.code === 200) { if (res.data.code === 200) {
this.$modal.msgSuccess("入库成功"); this.$modal.msgSuccess("入库成功");
this.warehousing = false; this.warehousing = false;