Browse Source

Merge branch 'dev_trial' of https://gitea.free-sun.vip/free-sun/FS-IOT into dev_trial

release_0.0.2
wenlele 2 years ago
parent
commit
06fc355304
  1. 53
      code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js
  2. 29
      code/VideoAccess-VCMP/api/app/lib/schedule/index.js
  3. 15
      code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoOperationTalk.jsx
  4. 3
      code/VideoAccess-VCMP/web/client/src/utils/videoCloudControl.js
  5. 2
      code/VideoAccess-VCMP/web/client/src/utils/videoVoice.js
  6. 1
      code/VideoAccess-VCMP/web/client/src/utils/webapi.js

53
code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js

@ -2,10 +2,14 @@ const schedule = require('node-schedule');
const moment = require('moment') const moment = require('moment')
module.exports = function (app, opts) { module.exports = function (app, opts) {
const freshYingshiState = schedule.scheduleJob( const freshYingshiState = app.fs.scheduleInit(
// '* * 4 * * *', {
'*/10 * * * *', // interval: '* * 4 * * *',
interval: '*/10 * * * *',
immediate: false,
},
async () => { async () => {
try { try {
const startTime = moment() const startTime = moment()
const { models } = app.fs.dc const { models } = app.fs.dc
@ -61,38 +65,6 @@ module.exports = function (app, opts) {
online: storageD.online, online: storageD.online,
ipctype: storageD.ipctype, ipctype: storageD.ipctype,
}) })
// const { connected } = app.socket.sockets
// const roomId = 'ROOM_' + Math.random() + '_' + d.deviceSerial
// let cameraName = ''
// if (connected) {
// for (let c in connected) {
// const { client: { conn: { request: { _query } } } } = connected[c]
// if (_query && _query.token) {
// let userInfo = await app.redis.hget(_query.token, 'userInfo');
// if (userInfo) {
// userInfo = JSON.parse(userInfo)
// const corCameraRes = await models.Camera.findOne({
// where: {
// gbId: existD.id,
// createUserId: userInfo.id
// }
// })
// // TODO 管理员判断
// if (corCameraRes) {
// cameraName = corCameraRes.name
// connected[c].join(roomId)
// }
// }
// }
// }
// app.socket.to(roomId).emit('CAMERA_ONLINE', {
// ipctype: 'yingshi',
// online: storageD.online,
// gbId: existD.id,
// name: cameraName
// })
// }
} }
} else { } else {
const yingshiRes = await models.GbCamera.create(storageD) const yingshiRes = await models.GbCamera.create(storageD)
@ -121,10 +93,13 @@ module.exports = function (app, opts) {
} }
}); });
const freshYingshiPlayUrl = schedule.scheduleJob( const freshYingshiPlayUrl = app.fs.scheduleInit(
// '0 0 4 */1 *', {
// '*/30 * * * *', // interval: '0 0 4 */1 *',
'0 34 5 * * *', // interval: '*/30 * * * *',
interval: '0 34 5 * * *',
immediate: true,
},
async () => { async () => {
try { try {
const { models } = app.fs.dc const { models } = app.fs.dc

29
code/VideoAccess-VCMP/api/app/lib/schedule/index.js

@ -3,27 +3,30 @@
const fs = require('fs'); const fs = require('fs');
const nodeSchedule = require('node-schedule'); const nodeSchedule = require('node-schedule');
const schedule = ({
interval, immediate
}, callback) => {
const j = nodeSchedule.scheduleJob(interval, callback);
if (immediate) {
j.run();
}
return j;
}
// 将定时任务汇集未来可根据需要选取操作 // 将定时任务汇集未来可根据需要选取操作
module.exports = async function (app, opts) { module.exports = async function (app, opts) {
const scheduleInit = ({
interval, immediate
}, callback) => {
const j = nodeSchedule.scheduleJob(interval, callback);
if (immediate) {
setTimeout(callback, 0)
}
return j;
}
app.fs.scheduleInit = scheduleInit
fs.readdirSync(__dirname).forEach((filename) => { fs.readdirSync(__dirname).forEach((filename) => {
if (!['index.js'].some(f => filename == f)) { if (!['index.js'].some(f => filename == f)) {
const schedule = require(`./${filename}`)(app, opts) const scheduleList = require(`./${filename}`)(app, opts)
for (let k of Object.keys(schedule)) { for (let k of Object.keys(scheduleList)) {
console.info(`定时任务 ${k} 启动`); console.info(`定时任务 ${k} 启动`);
} }
app.fs.schedule = { app.fs.schedule = {
...app.fs.schedule, ...app.fs.schedule,
...schedule, ...scheduleList,
} }
} }
}); });

15
code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoOperationTalk.jsx

@ -1,6 +1,9 @@
import React, { useState, useEffect, useRef } from "react"; import React, { useState, useEffect, useRef } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import request from 'superagent' import request from 'superagent'
import moment from "moment";
import { Request } from "@peace/utils";
import { ApiTable } from "$utils";
import './videoPlay.less'; import './videoPlay.less';
import { DatePicker, Toast, ToastFactory, Space } from '@douyinfe/semi-ui'; import { DatePicker, Toast, ToastFactory, Space } from '@douyinfe/semi-ui';
import { checkAudioVideo, uploadVoice2Yingshi, sendVoice2YingshiCamera } from '$utils'; import { checkAudioVideo, uploadVoice2Yingshi, sendVoice2YingshiCamera } from '$utils';
@ -28,7 +31,6 @@ const VideoOperationTalk = ({
} }
const onStopTalk = async (data) => { const onStopTalk = async (data) => {
console.log('stopTalk', data.blob)
setRecordState(RecordState.STOP) setRecordState(RecordState.STOP)
const { blob: audioData } = data; const { blob: audioData } = data;
if (!audioData) return; if (!audioData) return;
@ -46,14 +48,13 @@ const VideoOperationTalk = ({
channelNo: videoObj.channelNo, channelNo: videoObj.channelNo,
fileUrl: url fileUrl: url
}); });
if (sendRes && sendRes.code == 200) { ToastInCustomContainer.success('已发送');
ToastInCustomContainer.success('已发送'); } catch (error) {
if (error.msg) {
ToastInCustomContainer.error(error.msg);
} else { } else {
console.log(sendRes) ToastInCustomContainer.error('发送失败');
} }
} catch (error) {
console.error(error);
} }
} }

3
code/VideoAccess-VCMP/web/client/src/utils/videoCloudControl.js

@ -28,8 +28,7 @@ export function ysptz (ac, { serialNo, yingshiToken, channelNo }) {
} }
let startReqBody = Object.assign({}, params, { speed: 1 }) let startReqBody = Object.assign({}, params, { speed: 1 })
let stopReqBody = params let stopReqBody = params
// let requestUrl = `https://open.ys7.com/api/lapp/device/ptz/` let requestUrl = `https://open.ys7.com/api/lapp/device/ptz/`
let requestUrl = `/_yingshi/api/lapp/device/ptz/`
superagent superagent
.post(requestUrl + 'start') .post(requestUrl + 'start')
.send(startReqBody) .send(startReqBody)

2
code/VideoAccess-VCMP/web/client/src/utils/videoVoice.js

@ -9,7 +9,6 @@ export const uploadVoice2Yingshi = async ({ voiceFile, accessToken, voiceName, }
fData.append("accessToken", accessToken) fData.append("accessToken", accessToken)
fData.append("voiceName", voiceName || moment().format("YYYYMMDDHHmmssSSS")) fData.append("voiceName", voiceName || moment().format("YYYYMMDDHHmmssSSS"))
fData.append("force", true) fData.append("force", true)
console.log(fData);
// TODO 代理转发为什么不行捏 // TODO 代理转发为什么不行捏
// const upRslt = await YingshiRequest.post('api/lapp/voice/upload', fData) // const upRslt = await YingshiRequest.post('api/lapp/voice/upload', fData)
@ -52,7 +51,6 @@ export const sendVoice2YingshiCamera = async ({ accessToken, deviceSerial, chann
} }
}) })
}) })
console.log(sendRslt);
if (sendRslt.code === 200) { if (sendRslt.code === 200) {
return sendRslt.data return sendRslt.data
} else { } else {

1
code/VideoAccess-VCMP/web/client/src/utils/webapi.js

@ -37,6 +37,7 @@ export const ApiTable = {
postVerifyIpc: "camera/verify/ipc", //验证IPC摄像头信息 postVerifyIpc: "camera/verify/ipc", //验证IPC摄像头信息
postVerifyCascade: "camera/verify/cascade", //验证级联摄像头信息 postVerifyCascade: "camera/verify/cascade", //验证级联摄像头信息
getCascadeStream: "/camera/cascade_stream", //获取级联视频流 getCascadeStream: "/camera/cascade_stream", //获取级联视频流
uploadYingshiVoice: 'camera/yingshi_voice/upload', //上传萤石语音
}; };
export const VideoServeApi = { export const VideoServeApi = {

Loading…
Cancel
Save