Browse Source

解决冲突

dev
wenlele 1 year ago
parent
commit
e6a5e19ecb
  1. 37
      api/app/lib/controllers/analysis/network.js
  2. 2
      web-network/client/src/sections/network/containers/tableShow.js

37
api/app/lib/controllers/analysis/network.js

@ -218,6 +218,7 @@ async function findSensorLastData (ctx) {
ctx.status = 200; ctx.status = 200;
ctx.body = rslt; ctx.body = rslt;
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`)
ctx.status = 400; ctx.status = 400;
ctx.body = { ctx.body = {
"name": "FindError", "name": "FindError",
@ -309,7 +310,7 @@ async function findDevicesCardStatus (ctx, next) {
if (deviceIds && deviceIds.length) { if (deviceIds && deviceIds.length) {
const id = `(${deviceIds.map(id => `'${id}'`).join(',')})` const id = `(${deviceIds.map(id => `'${id}'`).join(',')})`
rlst = await clickHouse.dataAlarm.query(` 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 FROM alarm.CardStatus cs
WHERE cs.DeviceId in ${id} WHERE cs.DeviceId in ${id}
GROUP BY cs.DeviceId,cs.Status`).toPromise() GROUP BY cs.DeviceId,cs.Status`).toPromise()
@ -421,7 +422,36 @@ async function findAlarmsDevice(ctx, next) {
ctx.body = rslt; 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 +465,6 @@ module.exports = {
findAlarmsDevices, findAlarmsDevices,
findDevicesCardStatus, findDevicesCardStatus,
getDevicesLlinkStatus, getDevicesLlinkStatus,
findAlarmsDevice findAlarmsDevice,
createInvoke
} }

2
web-network/client/src/sections/network/containers/tableShow.js

@ -92,7 +92,7 @@ const Network = props => {
} }
} }
dispatch(analysis.getDevicesAlarms(deviceIds, { limit: 5 }, token)) dispatch(analysis.getDevicesAlarms(deviceIds, { limit: 5 }, token))
dispatch(analysis.findDevicesCardStatus({ deviceIds: alarmSensorId }, token)) dispatch(analysis.findDevicesCardStatus({ deviceIds: deviceIds }, token))
setSensorsDataItems(sensorsDataItems) setSensorsDataItems(sensorsDataItems)
setSensorId(sensorsId) setSensorId(sensorsId)
setDeviceData(da) setDeviceData(da)

Loading…
Cancel
Save