|
|
@ -122,6 +122,7 @@ async function edit (ctx) { |
|
|
|
async function getStatusPushList (ctx) { |
|
|
|
try { |
|
|
|
const models = ctx.fs.dc.models; |
|
|
|
const sequelize = ctx.fs.dc.ORM; |
|
|
|
const { userId, token } = ctx.fs.api |
|
|
|
const { limit, page, orderBy, orderDirection, name, pushWay } = ctx.query |
|
|
|
|
|
|
@ -157,6 +158,7 @@ async function getStatusPushList (ctx) { |
|
|
|
findOption.order = [ |
|
|
|
[orderBy || 'id', orderDirection || 'DESC'] |
|
|
|
] |
|
|
|
|
|
|
|
findOption.include = [ |
|
|
|
{ |
|
|
|
model: models.CameraStatusPushMonitor, |
|
|
@ -168,12 +170,6 @@ async function getStatusPushList (ctx) { |
|
|
|
attributes: ['name'], |
|
|
|
}] |
|
|
|
}, |
|
|
|
{ |
|
|
|
model: models.CameraStatusPushLog, |
|
|
|
attributes: ['id'], |
|
|
|
duplicating: false, |
|
|
|
required: false, |
|
|
|
}, |
|
|
|
{ |
|
|
|
model: models.CameraStatusPushReceiver, |
|
|
|
attributes: ['receiver'], |
|
|
@ -189,9 +185,22 @@ async function getStatusPushList (ctx) { |
|
|
|
delete findOption.where.id |
|
|
|
const count = await models.CameraStatusPushConfig.count(findOption) |
|
|
|
|
|
|
|
// 获取所有id
|
|
|
|
const pushLogCountRes = await models.CameraStatusPushLog.findAll({ |
|
|
|
attributes: [ |
|
|
|
'pushConfigId', |
|
|
|
[sequelize.fn('COUNT', sequelize.col('id')), 'count'] |
|
|
|
], |
|
|
|
where: { |
|
|
|
pushConfigId: { $in: configIds } |
|
|
|
}, |
|
|
|
group: ['pushConfigId'] |
|
|
|
}) |
|
|
|
|
|
|
|
for (let { dataValues: c } of configRes) { |
|
|
|
c.monitorCount = c.cameraStatusPushMonitors.length; |
|
|
|
c.logCount = c.cameraStatusPushLogs.length; |
|
|
|
let corLofCount = pushLogCountRes.find(p => p.dataValues.pushConfigId == c.id) |
|
|
|
c.logCount = corLofCount ? corLofCount.dataValues.count : 0 |
|
|
|
delete c.cameraStatusPushLogs |
|
|
|
} |
|
|
|
|
|
|
|