Browse Source

信鸽故障fix

release_1.1.2
巴林闲侠 3 years ago
parent
commit
03c69cedc8
  1. 12
      code/VideoAccess-VCMP/api/app/lib/controllers/status/index.js
  2. 98
      code/VideoAccess-VCMP/api/app/lib/controllers/status/push.js
  3. 2
      code/VideoAccess-VCMP/api/app/lib/routes/status/index.js

12
code/VideoAccess-VCMP/api/app/lib/controllers/status/index.js

@ -73,10 +73,20 @@ async function get (ctx) {
} }
if (paraphraseCustom) { if (paraphraseCustom) {
if (paraphraseCustom === 'true') { if (paraphraseCustom === 'true') {
findOption.where.paraphraseCustom = null findOption.where.paraphraseCustom = {
$or: [{
$eq: null
}, {
$eq: ''
}]
}
} else if (paraphraseCustom === 'false') { } else if (paraphraseCustom === 'false') {
findOption.where.paraphraseCustom = { findOption.where.paraphraseCustom = {
$and: [{
$ne: null $ne: null
}, {
$ne: ''
}]
} }
} }
} }

98
code/VideoAccess-VCMP/api/app/lib/controllers/status/push.js

@ -19,7 +19,7 @@ async function edit (ctx) {
name, pushWay, noticeWay, timing name, pushWay, noticeWay, timing
} }
if (configId) { if (configId) {
const configRes = await models.CameraStatusConfig.findOne({ const configRes = await models.CameraStatusPushConfig.findOne({
where: { where: {
id: configId id: configId
} }
@ -93,30 +93,54 @@ async function get (ctx) {
const sequelize = ctx.fs.dc.ORM; const sequelize = ctx.fs.dc.ORM;
let findOption = { let findOption = {
attributes: {
include: [
[sequelize.fn('COUNT', sequelize.col('cameraStatusPushMonitors.id')), 'monitorCount'],
[sequelize.fn('COUNT', sequelize.col('cameraStatusPushLogs.id')), 'logCount']
],
},
where: {}, where: {},
order: [ order: [
[orderBy || 'id', orderDirection || 'DESC'] [orderBy || 'id', orderDirection || 'DESC']
]
}
if (limit) {
findOption.limit = limit
}
if (page && limit) {
findOption.offset = page * limit
}
if (keyword) {
findOption.where['$or'] = {
name: {
$like: `%${keyword}%`
},
}
}
const configLimitRes = await models.CameraStatusPushConfig.findAll(findOption)
delete findOption.limit
delete findOption.offset
const configIds = configLimitRes.map(c => c.id)
findOption.where.id = { $in: configIds }
findOption.attributes = {
include: [
[sequelize.fn('COUNT', sequelize.col('cameraStatusPushMonitors.id')), 'monitorCount'],
[sequelize.fn('COUNT', sequelize.col('cameraStatusPushLogs.id')), 'logCount']
], ],
distinct: true, }
subQuery: false, findOption.distinct = true
group: [ findOption.subQuery = false
findOption.group = [
'cameraStatusPushConfig.id', 'cameraStatusPushConfig.id',
'cameraStatusPushMonitors.id', 'cameraStatusPushMonitors.id',
'cameraStatusPushLogs.id', 'cameraStatusPushLogs.id',
'cameraStatusPushReceivers.id', 'cameraStatusPushReceivers.id',
], ]
include: [ findOption.order = [
[orderBy || 'id', orderDirection || 'DESC']
]
findOption.include = [
{ {
model: models.CameraStatusPushMonitor, model: models.CameraStatusPushMonitor,
attributes: ['cameraId'], attributes: ['cameraId'],
required: false, required: false,
duplicating: true duplicating: true,
}, },
{ {
model: models.CameraStatusPushLog, model: models.CameraStatusPushLog,
@ -130,26 +154,23 @@ async function get (ctx) {
duplicating: false, duplicating: false,
required: false, required: false,
}, },
], ]
}
if (limit) {
findOption.limit = limit
}
if (page && limit) {
findOption.offset = page * limit
}
if (keyword) {
findOption.where['$or'] = {
name: {
$like: `%${keyword}%`
},
}
}
const configRes = await models.CameraStatusPushConfig.findAll(findOption) const configRes = await models.CameraStatusPushConfig.findAll(findOption)
delete findOption.attributes
delete findOption.group
delete findOption.order
delete findOption.distinct
delete findOption.subQuery
delete findOption.include
delete findOption.where.id
const count = await models.CameraStatusPushConfig.count(findOption)
ctx.status = 200; ctx.status = 200;
ctx.body = configRes ctx.body = {
count: count,
rows: configRes
}
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400; ctx.status = 400;
@ -255,11 +276,11 @@ async function copy (ctx) {
let copyConfig = JSON.parse(JSON.stringify(configRes.dataValues)) let copyConfig = JSON.parse(JSON.stringify(configRes.dataValues))
let returnConfig = JSON.parse(JSON.stringify(configRes.dataValues)) let returnConfig = JSON.parse(JSON.stringify(configRes.dataValues))
delete copyConfig.id delete copyConfig.id
delete copyConfig.id
let cameraStatusPushMonitors = copyConfig.cameraStatusPushMonitors let cameraStatusPushMonitors = copyConfig.cameraStatusPushMonitors
let cameraStatusPushReceiver = copyConfig.cameraStatusPushReceivers let cameraStatusPushReceiver = copyConfig.cameraStatusPushReceivers
delete copyConfig.cameraStatusPushMonitors delete copyConfig.cameraStatusPushMonitors
delete copyConfig.cameraStatusPushReceivers delete copyConfig.cameraStatusPushReceivers
copyConfig.name += '-副本'
copyConfig.createUser = userId copyConfig.createUser = userId
let newConfig = await models.CameraStatusPushConfig.create(copyConfig, { let newConfig = await models.CameraStatusPushConfig.create(copyConfig, {
transaction transaction
@ -316,6 +337,23 @@ async function pushLog (ctx) {
order: [['time', 'DESC']], order: [['time', 'DESC']],
}) })
let cameraIds = new Set()
for (let lr of logRes) {
for (let c of lr.camera) {
cameraIds.add(c)
}
}
let cameraRes = await models.Camera.findAll({
attributes: ['id', 'name'],
where: {
id: { $in: Array.from(cameraIds) }
}
})
for (let lr of logRes) {
let camera = cameraRes.filter(c => lr.camera.some(lrc => lrc == c.id))
lr.camera = camera
}
ctx.status = 200; ctx.status = 200;
ctx.body = logRes ctx.body = logRes
} catch (error) { } catch (error) {

2
code/VideoAccess-VCMP/api/app/lib/routes/status/index.js

@ -24,7 +24,7 @@ module.exports = function (app, router, opts) {
// 信鸽推送 // 信鸽推送
app.fs.api.logAttr['PUT/status/push'] = { content: '编辑推送配置', visible: false }; app.fs.api.logAttr['PUT/status/push'] = { content: '编辑推送配置', visible: false };
router.put('/sasdtatus/push', push.edit); router.put('/status/push', push.edit);
app.fs.api.logAttr['GET/status/push'] = { content: '获取推送配置', visible: false }; app.fs.api.logAttr['GET/status/push'] = { content: '获取推送配置', visible: false };
router.get('/status/push', push.get); router.get('/status/push', push.get);

Loading…
Cancel
Save