zhaobing’ 1 year ago
parent
commit
1c39128f3f
  1. 24
      api/app/lib/controllers/analysis/network.js
  2. 2
      api/app/lib/controllers/firmwareUpgrade/index.js
  3. 2
      api/app/lib/routes/analysis/network.js
  4. 20
      web-network/client/src/sections/network/actions/network.js
  5. 1
      web-network/client/src/sections/network/components/device-tree/zuwang-main.js
  6. 16
      web-network/client/src/sections/network/containers/device-monitor.js
  7. 1
      web/client/src/sections/analysis/containers/network.jsx

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

@ -350,7 +350,7 @@ async function getDevicesLlinkStatus (ctx, next) {
} }
}; };
async function findAlarmsDevice(ctx, next) { async function findAlarmsDevice (ctx, next) {
let error = { name: 'FindError', message: '告警信息获取失败' }; let error = { name: 'FindError', message: '告警信息获取失败' };
let rslt = null; let rslt = null;
const { deviceId } = ctx.params; const { deviceId } = ctx.params;
@ -396,7 +396,7 @@ async function findAlarmsDevice(ctx, next) {
params.size = 9999; params.size = 9999;
let historyAlarm = await client.search(params); let historyAlarm = await client.search(params);
const timer = ctx.app.fs.timer; const timer = ctx.app.fs.timer;
function filterAlarmMsg(oriMsg) { function filterAlarmMsg (oriMsg) {
let msg = []; let msg = [];
for (let s of oriMsg) { for (let s of oriMsg) {
msg.push({ msg.push({
@ -454,6 +454,23 @@ async function createInvoke (ctx, next) {
}; };
async function getThingStatus (ctx) {
let res = []
try {
const { thingId } = ctx.query
let res = await ctx.app.fs.craw.get('thing/status', { query: { thingId } })
ctx.status = 200
if (res) {
ctx.body = JSON.parse(res)
}
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`)
ctx.status = 200
ctx.body = []
}
}
module.exports = { module.exports = {
getOrganizationsStruc, getOrganizationsStruc,
@ -466,5 +483,6 @@ module.exports = {
findDevicesCardStatus, findDevicesCardStatus,
getDevicesLlinkStatus, getDevicesLlinkStatus,
findAlarmsDevice, findAlarmsDevice,
createInvoke createInvoke,
getThingStatus,
} }

2
api/app/lib/controllers/firmwareUpgrade/index.js

@ -264,7 +264,7 @@ async function deleteFirmware(ctx){
try{ try{
await ctx.app.fs.craw.delete(ApiTable.firmwareUpgrade,{query:{version,device_meta_id,token:tokenup}}) await ctx.app.fs.craw.delete(ApiTable.firmwareUpgrade,{query:{version,device_meta_id,token:tokenup}})
ctx.status=204 ctx.status=204
}catch(eror){ }catch(error){
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`)
ctx.status = 400 ctx.status = 400
ctx.body = { ctx.body = {

2
api/app/lib/routes/analysis/network.js

@ -32,4 +32,6 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['GET/device/:deviceId/alarms'] = { content: '获取设备告警信息', visible: true }; app.fs.api.logAttr['GET/device/:deviceId/alarms'] = { content: '获取设备告警信息', visible: true };
router.get('/device/:deviceId/alarms', network.findAlarmsDevice); router.get('/device/:deviceId/alarms', network.findAlarmsDevice);
app.fs.api.logAttr['GET/thing/status'] = { content: '获取设备在离线', visible: true };
router.get('/thing/status', network.getThingStatus);
} }

20
web-network/client/src/sections/network/actions/network.js

@ -136,6 +136,24 @@ export function findAlarmsDevice (deviceIds, query, token) {
}); });
} }
export function getThingStatus (query, token) {
return dispatch => basicAction({
type: 'get',
dispatch: dispatch,
query: query,
actionType: 'GET_THING_STATUS',
url: `thing/status?token=${token}`,
msg: {
error: '获取设备在离线失败'
},
reducer: {
name: 'thingStatus'
}
});
}
export default { export default {
getOrganizationsStruc, getOrganizationsStruc,
getThingsDeploy, getThingsDeploy,
@ -148,6 +166,6 @@ export default {
findDevicesCardStatus, findDevicesCardStatus,
getDevicesLlinkStatus, getDevicesLlinkStatus,
findAlarmsDevice, findAlarmsDevice,
getThingStatus
} }

1
web-network/client/src/sections/network/components/device-tree/zuwang-main.js

@ -8,6 +8,7 @@ import {
} from 'antd'; } from 'antd';
import Ps from 'perfect-scrollbar'; import Ps from 'perfect-scrollbar';
import createG6 from './edit-map'; import createG6 from './edit-map';
import moment from 'moment'
// import { useThingsLinkStatus } from '../../actions/hooks'; // import { useThingsLinkStatus } from '../../actions/hooks';

16
web-network/client/src/sections/network/containers/device-monitor.js

@ -36,15 +36,17 @@ function DeviceMonitor ({ ...props }) {
useEffect(() => { useEffect(() => {
if (strucParam?.thingId) { if (strucParam?.thingId) {
dispatch(analysis.getThingsDeploy(strucParam?.thingId, token)).then(res => { dispatch(analysis.getThingsDeploy(strucParam?.thingId, token)).then(res => {
if (res.success) { // if (res.success) {
const instances = res?.payload?.data?.instances; // const instances = res?.payload?.data?.instances;
if (instances) { // if (instances) {
const deviceIds = Object.keys(instances).filter((k) => instances[k]?.type == 's.d'); // const deviceIds = Object.keys(instances).filter((k) => instances[k]?.type == 's.d');
dispatch(analysis.getDevicesAlarms(deviceIds, { limit: 5 }, token)); // dispatch(analysis.getDevicesAlarms(deviceIds, { limit: 5 }, token));
} // }
} // }
}) })
dispatch(analysis.getDeviceMetaDeployed(strucParam?.thingId, token)) dispatch(analysis.getDeviceMetaDeployed(strucParam?.thingId, token))
dispatch(analysis.getThingStatus({ thingId: strucParam?.thingId }, token));
} }
}, []); }, []);

1
web/client/src/sections/analysis/containers/network.jsx

@ -24,6 +24,7 @@ const Network = ({
useEffect(() => { useEffect(() => {
setSpinning(true)
let projectData = [] let projectData = []
let project = projectPoms.filter(v => v.pepProjectIsDelete != 1) let project = projectPoms.filter(v => v.pepProjectIsDelete != 1)
if (projectPoms?.length) { if (projectPoms?.length) {

Loading…
Cancel
Save