|
|
@ -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 |
|
|
|