|
@ -86,6 +86,12 @@ async function getThingsDeploy (ctx) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
//查询物联网卡相关信息
|
|
|
//查询物联网卡相关信息
|
|
|
|
|
|
// cs.PType as pType,
|
|
|
|
|
|
// cs.Status as status,
|
|
|
|
|
|
// cs.Total as total,
|
|
|
|
|
|
// cs.Allowance as allowance,
|
|
|
|
|
|
// cs.Time as time
|
|
|
|
|
|
// FROM alarm.CardStatus cs
|
|
|
async function getCardInfo (ctx) { |
|
|
async function getCardInfo (ctx) { |
|
|
try{ |
|
|
try{ |
|
|
let rlst = [] |
|
|
let rlst = [] |
|
@ -97,16 +103,21 @@ async function getCardInfo (ctx) { |
|
|
rlst = await clickHouse.dataAlarm.query(` |
|
|
rlst = await clickHouse.dataAlarm.query(` |
|
|
with tmp as ( SELECT cs.DeviceId as deviceId, |
|
|
with tmp as ( SELECT cs.DeviceId as deviceId, |
|
|
cs.CardNo as cardNo, |
|
|
cs.CardNo as cardNo, |
|
|
cs.PType as pType, |
|
|
MAX(cs.Time) as time |
|
|
cs.Status as status, |
|
|
|
|
|
cs.Total as total, |
|
|
|
|
|
cs.Allowance as allowance, |
|
|
|
|
|
cs.Time as time |
|
|
|
|
|
FROM alarm.CardStatus cs |
|
|
FROM alarm.CardStatus cs |
|
|
WHERE cs.DeviceId in ${id} |
|
|
WHERE cs.DeviceId in ${id} |
|
|
ORDER BY cs.Time DESC |
|
|
GROUP BY cs.DeviceId, cs.CardNo |
|
|
LIMIT 1) |
|
|
) |
|
|
SELECT t.*,d.thingId,d.name FROM tmp t |
|
|
SELECT t.*,d.thingId,d.name, |
|
|
|
|
|
q.CardNo as cardNo, |
|
|
|
|
|
q.PType as pType, |
|
|
|
|
|
q.Status as status, |
|
|
|
|
|
q.Total as total, |
|
|
|
|
|
q.Allowance as allowance |
|
|
|
|
|
FROM tmp t |
|
|
|
|
|
LEFT JOIN alarm.CardStatus q |
|
|
|
|
|
ON t.deviceId = q.DeviceId |
|
|
|
|
|
AND q.Time=t.time |
|
|
LEFT JOIN ${iota}.Device d |
|
|
LEFT JOIN ${iota}.Device d |
|
|
ON Device.id = t.deviceId` ).toPromise()
|
|
|
ON Device.id = t.deviceId` ).toPromise()
|
|
|
ctx.status = 200 |
|
|
ctx.status = 200 |
|
|