diff --git a/code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js b/code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js index bcc7143..72945c6 100644 --- a/code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js +++ b/code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js @@ -2,10 +2,14 @@ const schedule = require('node-schedule'); const moment = require('moment') module.exports = function (app, opts) { - const freshYingshiState = schedule.scheduleJob( - // '* * 4 * * *', - '*/10 * * * *', + const freshYingshiState = app.fs.scheduleInit( + { + // interval: '* * 4 * * *', + interval: '*/10 * * * *', + immediate: false, + }, async () => { + try { const startTime = moment() const { models } = app.fs.dc @@ -61,38 +65,6 @@ module.exports = function (app, opts) { online: storageD.online, 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 { const yingshiRes = await models.GbCamera.create(storageD) @@ -121,10 +93,13 @@ module.exports = function (app, opts) { } }); - const freshYingshiPlayUrl = schedule.scheduleJob( - // '0 0 4 */1 *', - // '*/30 * * * *', - '0 34 5 * * *', + const freshYingshiPlayUrl = app.fs.scheduleInit( + { + // interval: '0 0 4 */1 *', + // interval: '*/30 * * * *', + interval: '0 34 5 * * *', + immediate: true, + }, async () => { try { const { models } = app.fs.dc diff --git a/code/VideoAccess-VCMP/api/app/lib/schedule/index.js b/code/VideoAccess-VCMP/api/app/lib/schedule/index.js index beb2d3d..e97a1fc 100644 --- a/code/VideoAccess-VCMP/api/app/lib/schedule/index.js +++ b/code/VideoAccess-VCMP/api/app/lib/schedule/index.js @@ -3,27 +3,30 @@ const fs = require('fs'); 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) { + + 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) => { if (!['index.js'].some(f => filename == f)) { - const schedule = require(`./${filename}`)(app, opts) - for (let k of Object.keys(schedule)) { + const scheduleList = require(`./${filename}`)(app, opts) + for (let k of Object.keys(scheduleList)) { console.info(`定时任务 ${k} 启动`); } app.fs.schedule = { ...app.fs.schedule, - ...schedule, + ...scheduleList, } } }); diff --git a/code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoOperationTalk.jsx b/code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoOperationTalk.jsx index 5b2117a..1b153d9 100644 --- a/code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoOperationTalk.jsx +++ b/code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoOperationTalk.jsx @@ -1,6 +1,9 @@ import React, { useState, useEffect, useRef } from "react"; import { connect } from "react-redux"; import request from 'superagent' +import moment from "moment"; +import { Request } from "@peace/utils"; +import { ApiTable } from "$utils"; import './videoPlay.less'; import { DatePicker, Toast, ToastFactory, Space } from '@douyinfe/semi-ui'; import { checkAudioVideo, uploadVoice2Yingshi, sendVoice2YingshiCamera } from '$utils'; @@ -28,7 +31,6 @@ const VideoOperationTalk = ({ } const onStopTalk = async (data) => { - console.log('stopTalk', data.blob) setRecordState(RecordState.STOP) const { blob: audioData } = data; if (!audioData) return; @@ -46,14 +48,13 @@ const VideoOperationTalk = ({ channelNo: videoObj.channelNo, fileUrl: url }); - if (sendRes && sendRes.code == 200) { - ToastInCustomContainer.success('已发送'); + ToastInCustomContainer.success('已发送'); + } catch (error) { + if (error.msg) { + ToastInCustomContainer.error(error.msg); } else { - console.log(sendRes) + ToastInCustomContainer.error('发送失败'); } - } catch (error) { - console.error(error); - } } diff --git a/code/VideoAccess-VCMP/web/client/src/utils/videoCloudControl.js b/code/VideoAccess-VCMP/web/client/src/utils/videoCloudControl.js index 858c495..e44c338 100644 --- a/code/VideoAccess-VCMP/web/client/src/utils/videoCloudControl.js +++ b/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 stopReqBody = params - // let requestUrl = `https://open.ys7.com/api/lapp/device/ptz/` - let requestUrl = `/_yingshi/api/lapp/device/ptz/` + let requestUrl = `https://open.ys7.com/api/lapp/device/ptz/` superagent .post(requestUrl + 'start') .send(startReqBody) diff --git a/code/VideoAccess-VCMP/web/client/src/utils/videoVoice.js b/code/VideoAccess-VCMP/web/client/src/utils/videoVoice.js index ee825a6..8ee70ee 100644 --- a/code/VideoAccess-VCMP/web/client/src/utils/videoVoice.js +++ b/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("voiceName", voiceName || moment().format("YYYYMMDDHHmmssSSS")) fData.append("force", true) - console.log(fData); // TODO 代理转发为什么不行捏 // 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) { return sendRslt.data } else { diff --git a/code/VideoAccess-VCMP/web/client/src/utils/webapi.js b/code/VideoAccess-VCMP/web/client/src/utils/webapi.js index 1bbf81b..d5783d3 100644 --- a/code/VideoAccess-VCMP/web/client/src/utils/webapi.js +++ b/code/VideoAccess-VCMP/web/client/src/utils/webapi.js @@ -37,6 +37,7 @@ export const ApiTable = { postVerifyIpc: "camera/verify/ipc", //验证IPC摄像头信息 postVerifyCascade: "camera/verify/cascade", //验证级联摄像头信息 getCascadeStream: "/camera/cascade_stream", //获取级联视频流 + uploadYingshiVoice: 'camera/yingshi_voice/upload', //上传萤石语音 }; export const VideoServeApi = {