Browse Source

fix 推送数量

dev_trial
巴林闲侠 2 years ago
parent
commit
8e7f0d994e
  1. 5
      code/VideoAccess-VCMP/api/.vscode/launch.json
  2. 23
      code/VideoAccess-VCMP/api/app/lib/controllers/status/push.js

5
code/VideoAccess-VCMP/api/.vscode/launch.json

@ -15,12 +15,13 @@
"args": [
"-p 4000",
"-f http://localhost:4000",
// "-g postgres://postgres:123@10.8.30.166:5432/video_access",
"-g postgres://postgres:123@10.8.30.166:5432/video_access-dev",
"-g postgres://postgres:123@10.8.30.166:5432/video-access",
// "-g postgres://postgres:123@10.8.30.166:5432/video_access-dev",
"--redisHost 10.8.30.112",
"--redisPort 6379",
"--axyApiUrl http://127.0.0.1:4100",
"--iotAuthApi http://127.0.0.1:4200",
"--pomsApiUrl http://127.0.0.1:4600",
"--godUrl https://restapi.amap.com/v3",
"--godKey 21c2d970e1646bb9a795900dd00093ce",
"--mqttVideoServer mqtt://10.8.30.71:30883",

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

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

Loading…
Cancel
Save