From ff14147b6cb24f39b0b7f74c385939d6f1d91255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhaobing=E2=80=99?= Date: Fri, 15 Dec 2023 17:38:05 +0800 Subject: [PATCH] feat:fix bugs --- .../controllers/AIOTOverview/AIOTOverview.js | 29 +++++++++++++------ weapp/package/AIOTOverview/AIOTOverview.js | 3 +- .../electricityMonitoring.js | 2 ++ .../electricityMonitoring.wxml | 8 ++--- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/api/app/lib/controllers/AIOTOverview/AIOTOverview.js b/api/app/lib/controllers/AIOTOverview/AIOTOverview.js index 4b34781..0fce7df 100644 --- a/api/app/lib/controllers/AIOTOverview/AIOTOverview.js +++ b/api/app/lib/controllers/AIOTOverview/AIOTOverview.js @@ -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) { try{ let rlst = [] @@ -97,16 +103,21 @@ async function getCardInfo (ctx) { rlst = await clickHouse.dataAlarm.query(` with tmp as ( SELECT cs.DeviceId as deviceId, cs.CardNo as cardNo, - cs.PType as pType, - cs.Status as status, - cs.Total as total, - cs.Allowance as allowance, - cs.Time as time - FROM alarm.CardStatus cs + MAX(cs.Time) as time + FROM alarm.CardStatus cs WHERE cs.DeviceId in ${id} - ORDER BY cs.Time DESC - LIMIT 1) - SELECT t.*,d.thingId,d.name FROM tmp t + GROUP BY cs.DeviceId, cs.CardNo + ) + 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 ON Device.id = t.deviceId` ).toPromise() ctx.status = 200 diff --git a/weapp/package/AIOTOverview/AIOTOverview.js b/weapp/package/AIOTOverview/AIOTOverview.js index f8e5bb4..d057bf4 100644 --- a/weapp/package/AIOTOverview/AIOTOverview.js +++ b/weapp/package/AIOTOverview/AIOTOverview.js @@ -67,7 +67,6 @@ Page({ } } } - } if (status && status.length) { const data = deviceId.map(item => { @@ -79,7 +78,7 @@ Page({ xjId:item.xjId } }) - deviceAll.push({ id: '012ccc98-c99d-445e-8397-6da1b4567533', name: '设备二', structId: 'df48d7c5-d902-47b1-b671-d88d546ba3e4' }) + // deviceAll.push({ id: '012ccc98-c99d-445e-8397-6da1b4567533', name: '设备二', structId: 'df48d7c5-d902-47b1-b671-d88d546ba3e4' }) if (deviceAll && deviceAll.length) { Request.post(getCardInfo(), { structIds: deviceAll }).then(res => { if (res) { diff --git a/weapp/package/AIOTOverview/electricityMonitoring/electricityMonitoring.js b/weapp/package/AIOTOverview/electricityMonitoring/electricityMonitoring.js index b74e9fa..f7762b5 100644 --- a/weapp/package/AIOTOverview/electricityMonitoring/electricityMonitoring.js +++ b/weapp/package/AIOTOverview/electricityMonitoring/electricityMonitoring.js @@ -62,6 +62,7 @@ Page({ let listt=[] //智能断路器的设备的状态 const res1 =await Request.post(createInvoke(),data) + // console.log('resss',res1) //获取结构物列表(巡检) // console.log('getProjectList',getProjectList) const res=await Request.get(getProjectList()) @@ -84,6 +85,7 @@ Page({ }) } data.unshift({text: '全部', value: 'all' }) + // console.log('listt',listt) this.setData({ structList:data, list:listt, diff --git a/weapp/package/AIOTOverview/electricityMonitoring/electricityMonitoring.wxml b/weapp/package/AIOTOverview/electricityMonitoring/electricityMonitoring.wxml index 0c45f54..01e423b 100644 --- a/weapp/package/AIOTOverview/electricityMonitoring/electricityMonitoring.wxml +++ b/weapp/package/AIOTOverview/electricityMonitoring/electricityMonitoring.wxml @@ -26,14 +26,14 @@ 运行状态 {{'离线'}} - {{'离线'}} - {{'正常'}} + {{'离线'}} + {{'正常'}} 电源状态 {{'离线'}} - {{'离线'}} - {{'正常'}} + {{'离线'}} + {{'正常'}}