From a1c39f0ddd22709dc237e492d118d275629727ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhaobing=E2=80=99?= Date: Wed, 6 Dec 2023 10:58:16 +0800 Subject: [PATCH 1/3] feat:fix bugs --- web-network/client/src/sections/network/containers/tableShow.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-network/client/src/sections/network/containers/tableShow.js b/web-network/client/src/sections/network/containers/tableShow.js index b23afc9..e208cfc 100644 --- a/web-network/client/src/sections/network/containers/tableShow.js +++ b/web-network/client/src/sections/network/containers/tableShow.js @@ -92,7 +92,7 @@ const Network = props => { } } dispatch(analysis.getDevicesAlarms(deviceIds , { limit: 5 })) - dispatch(analysis.findDevicesCardStatus({ deviceIds: alarmSensorId })) + dispatch(analysis.findDevicesCardStatus({ deviceIds })) setSensorsDataItems(sensorsDataItems) setSensorId(sensorsId) setDeviceData(da) From 2bb79e29f280e069d687094983fb74ab3acdbdc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhaobing=E2=80=99?= Date: Wed, 6 Dec 2023 13:34:11 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:fix=20bugs=EF=BC=88DeviceId=E6=94=B9de?= =?UTF-8?q?viceId=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/analysis/network.js | 36 +++++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/api/app/lib/controllers/analysis/network.js b/api/app/lib/controllers/analysis/network.js index 1f0be9e..cd95794 100644 --- a/api/app/lib/controllers/analysis/network.js +++ b/api/app/lib/controllers/analysis/network.js @@ -309,7 +309,7 @@ async function findDevicesCardStatus (ctx, next) { if (deviceIds && deviceIds.length) { const id = `(${deviceIds.map(id => `'${id}'`).join(',')})` rlst = await clickHouse.dataAlarm.query(` - SELECT cs.DeviceId,cs.Status,MAX(cs.Time) + SELECT cs.DeviceId as deviceId,cs.Status as status,MAX(cs.Time) FROM alarm.CardStatus cs WHERE cs.DeviceId in ${id} GROUP BY cs.DeviceId,cs.Status`).toPromise() @@ -421,7 +421,36 @@ async function findAlarmsDevice(ctx, next) { ctx.body = rslt; } } - +//查询智能 +async function createInvoke (ctx, next) { + let error = { name: 'CreateError', message: '命令下发失败' }; + const data = ctx.request.body + let rslt = null, code = null, issuccess = false, text = null; + if (data) { + try { + const models = ctx.fs.dc.models; + let iotaThingId = data.thingId; + let structure = await models.Structure.findOne({ where: { iotaThingId } }); + if (structure) { + const dataToIota = data; + let iotaResponse = await ctx.app.fs.iotRequest.post(`/capabilities/invoke`, dataToIota) + rslt = JSON.parse(iotaResponse) + error = null; + } else { + error = { name: 'NotFound', message: `不存在{iotaThingId=${iotaThingId}}的结构物` }; + } + } catch (err) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${err}`); + } + } + if (error) { + ctx.status = 400; + ctx.body = error; + } else { + ctx.status = 200; + ctx.body = rslt; + } +}; @@ -435,5 +464,6 @@ module.exports = { findAlarmsDevices, findDevicesCardStatus, getDevicesLlinkStatus, - findAlarmsDevice + findAlarmsDevice, + createInvoke } \ No newline at end of file From 115f03ee3b77e0395f39de57befa608ce472bfb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhaobing=E2=80=99?= Date: Wed, 6 Dec 2023 13:55:06 +0800 Subject: [PATCH 3/3] feat:fix bugs --- api/app/lib/controllers/analysis/network.js | 1 + 1 file changed, 1 insertion(+) diff --git a/api/app/lib/controllers/analysis/network.js b/api/app/lib/controllers/analysis/network.js index cd95794..14fe404 100644 --- a/api/app/lib/controllers/analysis/network.js +++ b/api/app/lib/controllers/analysis/network.js @@ -218,6 +218,7 @@ async function findSensorLastData (ctx) { ctx.status = 200; ctx.body = rslt; } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) ctx.status = 400; ctx.body = { "name": "FindError",