Browse Source

信鸽故障fix

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

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

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

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

@ -19,7 +19,7 @@ async function edit (ctx) {
name, pushWay, noticeWay, timing
}
if (configId) {
const configRes = await models.CameraStatusConfig.findOne({
const configRes = await models.CameraStatusPushConfig.findOne({
where: {
id: configId
}
@ -93,44 +93,10 @@ async function get (ctx) {
const sequelize = ctx.fs.dc.ORM;
let findOption = {
attributes: {
include: [
[sequelize.fn('COUNT', sequelize.col('cameraStatusPushMonitors.id')), 'monitorCount'],
[sequelize.fn('COUNT', sequelize.col('cameraStatusPushLogs.id')), 'logCount']
],
},
where: {},
order: [
[orderBy || 'id', orderDirection || 'DESC']
],
distinct: true,
subQuery: false,
group: [
'cameraStatusPushConfig.id',
'cameraStatusPushMonitors.id',
'cameraStatusPushLogs.id',
'cameraStatusPushReceivers.id',
],
include: [
{
model: models.CameraStatusPushMonitor,
attributes: ['cameraId'],
required: false,
duplicating: true
},
{
model: models.CameraStatusPushLog,
attributes: [],
duplicating: false,
required: false,
},
{
model: models.CameraStatusPushReceiver,
attributes: ['receiver'],
duplicating: false,
required: false,
},
],
]
}
if (limit) {
findOption.limit = limit
@ -146,10 +112,65 @@ async function get (ctx) {
}
}
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']
],
}
findOption.distinct = true
findOption.subQuery = false
findOption.group = [
'cameraStatusPushConfig.id',
'cameraStatusPushMonitors.id',
'cameraStatusPushLogs.id',
'cameraStatusPushReceivers.id',
]
findOption.order = [
[orderBy || 'id', orderDirection || 'DESC']
]
findOption.include = [
{
model: models.CameraStatusPushMonitor,
attributes: ['cameraId'],
required: false,
duplicating: true,
},
{
model: models.CameraStatusPushLog,
attributes: [],
duplicating: false,
required: false,
},
{
model: models.CameraStatusPushReceiver,
attributes: ['receiver'],
duplicating: false,
required: false,
},
]
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.body = configRes
ctx.body = {
count: count,
rows: configRes
}
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
@ -255,11 +276,11 @@ async function copy (ctx) {
let copyConfig = JSON.parse(JSON.stringify(configRes.dataValues))
let returnConfig = JSON.parse(JSON.stringify(configRes.dataValues))
delete copyConfig.id
delete copyConfig.id
let cameraStatusPushMonitors = copyConfig.cameraStatusPushMonitors
let cameraStatusPushReceiver = copyConfig.cameraStatusPushReceivers
delete copyConfig.cameraStatusPushMonitors
delete copyConfig.cameraStatusPushReceivers
copyConfig.name += '-副本'
copyConfig.createUser = userId
let newConfig = await models.CameraStatusPushConfig.create(copyConfig, {
transaction
@ -316,6 +337,23 @@ async function pushLog (ctx) {
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.body = logRes
} 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 };
router.put('/sasdtatus/push', push.edit);
router.put('/status/push', push.edit);
app.fs.api.logAttr['GET/status/push'] = { content: '获取推送配置', visible: false };
router.get('/status/push', push.get);

Loading…
Cancel
Save