|
@ -1,11 +1,11 @@ |
|
|
import React, { useEffect, useState, useRef, useMemo } from 'react' |
|
|
import React, { useEffect, useState, useRef, useMemo } from 'react' |
|
|
import { connect } from 'react-redux' |
|
|
import { connect } from 'react-redux' |
|
|
import { Spin, Card, CardGroup, Form, Select, Input, Button, Table, Pagination, Tooltip,Modal } from 'antd' |
|
|
import { Spin, Card, CardGroup, Form, Select, Input, Button, Table, Pagination, Tooltip,Modal,Switch } from 'antd' |
|
|
import ExportData from '../components/export-data' |
|
|
import ExportData from '../components/export-data' |
|
|
import moment from 'moment' |
|
|
import moment from 'moment' |
|
|
|
|
|
|
|
|
const Network = props => { |
|
|
const Network = props => { |
|
|
const { dispatch, actions, user, clientHeight, thingId, deviceListAlarms, devicesCardStatusList, project, token, } = props |
|
|
const { dispatch, actions, user, clientHeight, thingId, deviceListAlarms, devicesCardStatusList, project, token,thingStatus } = props |
|
|
const { analysis } = actions |
|
|
const { analysis } = actions |
|
|
const form = useRef() //表单
|
|
|
const form = useRef() //表单
|
|
|
const [deployData, setDeployData] = useState([]) |
|
|
const [deployData, setDeployData] = useState([]) |
|
@ -19,10 +19,13 @@ const Network = props => { |
|
|
const [searchType, setSearchType] = useState('') |
|
|
const [searchType, setSearchType] = useState('') |
|
|
const [searchName, setSearchName] = useState('') |
|
|
const [searchName, setSearchName] = useState('') |
|
|
const [typeList, setTypeList] = useState([]) |
|
|
const [typeList, setTypeList] = useState([]) |
|
|
const [query, setQuery] = useState({ limit: 10, page: 0 }) //页码信息
|
|
|
|
|
|
const [deviceId,setDeviceId] = useState([]) |
|
|
const [deviceId,setDeviceId] = useState([]) |
|
|
const [modalVis,setModalVis]=useState(false) |
|
|
const [modalVis,setModalVis]=useState(false) |
|
|
const [loading,setLoading]=useState(true) |
|
|
const [loading,setLoading]=useState(true) |
|
|
|
|
|
const [status,setStatus]=useState(false)//空开设备开关状态
|
|
|
|
|
|
const [controlId,setControlId]=useState('') |
|
|
|
|
|
const [id,setId]=useState('')//设计设备的id
|
|
|
|
|
|
const [param,setParam]=useState('')//开与关
|
|
|
const DeviceTypes = { |
|
|
const DeviceTypes = { |
|
|
'DTU': 'DTU', |
|
|
'DTU': 'DTU', |
|
|
'gateway': '网关', |
|
|
'gateway': '网关', |
|
@ -72,16 +75,35 @@ const Network = props => { |
|
|
if (deviceMetaDeployed && dataList && deviceMetaDeployed.devices) { |
|
|
if (deviceMetaDeployed && dataList && deviceMetaDeployed.devices) { |
|
|
const sensorsId = [] |
|
|
const sensorsId = [] |
|
|
let deviceIds = [] //所有设备的id
|
|
|
let deviceIds = [] //所有设备的id
|
|
|
|
|
|
|
|
|
const sensorsDataItems = {} |
|
|
const sensorsDataItems = {} |
|
|
for (const id in dataList.instances) { |
|
|
for (const id in dataList.instances) { |
|
|
|
|
|
let searchId=''//查询e9c设备状态的id
|
|
|
|
|
|
let controlId=''//控制e9c设备开关的id
|
|
|
deviceIds.push(id) |
|
|
deviceIds.push(id) |
|
|
const instances = dataList.instances[id] |
|
|
const instances = dataList.instances[id] |
|
|
if (instances.type == 's.d' && instances.instance.properties.deviceType == 'sensor') { |
|
|
if (instances.type == 's.d' && instances.instance.properties.deviceType == 'sensor') { |
|
|
|
|
|
if(instances.instance.properties.model == 'E9C'){ |
|
|
|
|
|
for(const key in instances?.instance?.interfaces){ |
|
|
|
|
|
Object.keys(instances?.instance?.interfaces[key]?.capabilities).forEach( |
|
|
|
|
|
(kk,index)=>{ |
|
|
|
|
|
if(index===0){ |
|
|
|
|
|
searchId=instances?.instance?.interfaces[key]?.capabilities[kk]?.dimension?.id |
|
|
|
|
|
} |
|
|
|
|
|
if(index===1){ |
|
|
|
|
|
controlId=instances?.instance?.interfaces[key]?.capabilities[kk]?.dimension?.id |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
const meta = deviceMetaDeployed.devices.find(m => m.id == instances.instance.deviceMetaId) |
|
|
const meta = deviceMetaDeployed.devices.find(m => m.id == instances.instance.deviceMetaId) |
|
|
sensorsDataItems[id] = { |
|
|
sensorsDataItems[id] = { |
|
|
items: {}, |
|
|
items: {}, |
|
|
deviceName: instances.name, |
|
|
deviceName: instances.name, |
|
|
model:instances.instance.properties.productType |
|
|
model:instances.instance.properties.productType, |
|
|
|
|
|
searchId:instances.instance.properties.model == 'E9C'?searchId:null, |
|
|
|
|
|
controlId:instances.instance.properties.model == 'E9C'?controlId:null, |
|
|
} |
|
|
} |
|
|
if (meta) { |
|
|
if (meta) { |
|
|
sensorsDataItems[id].items = meta.capabilities[0].properties.reduce((p, n) => { |
|
|
sensorsDataItems[id].items = meta.capabilities[0].properties.reduce((p, n) => { |
|
@ -140,6 +162,8 @@ const Network = props => { |
|
|
sensorName: sensorName, |
|
|
sensorName: sensorName, |
|
|
collectTime: collectTime, |
|
|
collectTime: collectTime, |
|
|
model:sensorsDataItems[sd.sensorId]?.model, |
|
|
model:sensorsDataItems[sd.sensorId]?.model, |
|
|
|
|
|
searchId:sensorsDataItems[sd.sensorId]?.searchId, |
|
|
|
|
|
controlId:sensorsDataItems[sd.sensorId]?.controlId, |
|
|
data: dataStr, |
|
|
data: dataStr, |
|
|
deviceType: 'sensor', //传感器
|
|
|
deviceType: 'sensor', //传感器
|
|
|
iotCardStatus: '--', |
|
|
iotCardStatus: '--', |
|
@ -167,6 +191,8 @@ const Network = props => { |
|
|
data: objRslt ? objRslt.data : p.data, |
|
|
data: objRslt ? objRslt.data : p.data, |
|
|
deviceType: DeviceTypes[objRslt ? objRslt.deviceType : p.deviceType], |
|
|
deviceType: DeviceTypes[objRslt ? objRslt.deviceType : p.deviceType], |
|
|
model:objRslt?objRslt?.model:p.model, |
|
|
model:objRslt?objRslt?.model:p.model, |
|
|
|
|
|
searchId:objRslt?objRslt.searchId:'', |
|
|
|
|
|
controlId:objRslt?objRslt.controlId:'', |
|
|
iotCardStatus: |
|
|
iotCardStatus: |
|
|
res.payload.data && res.payload.data.length&&res.payload.data.find(v => v.deviceId == p.sensorId)?.status === 0 |
|
|
res.payload.data && res.payload.data.length&&res.payload.data.find(v => v.deviceId == p.sensorId)?.status === 0 |
|
|
? '正常' |
|
|
? '正常' |
|
@ -174,11 +200,9 @@ const Network = props => { |
|
|
? '未激活':res.payload.data.find(v => v.deviceId == p.sensorId)?.status === 2?'停机' |
|
|
? '未激活':res.payload.data.find(v => v.deviceId == p.sensorId)?.status === 2?'停机' |
|
|
: '--', |
|
|
: '--', |
|
|
status: |
|
|
status: |
|
|
deviceListAlarms && deviceListAlarms.length |
|
|
thingStatus && thingStatus.length |
|
|
? deviceListAlarms?.find(v => v.deviceId == p.sensorId) |
|
|
? thingStatus?.find(v => v.deviceId == p.sensorId)?.status===1?'在线':thingStatus?.find(v => v.deviceId == p.sensorId)?.status===0?'离线':'未知':'--', |
|
|
? '异常' |
|
|
|
|
|
: '正常' |
|
|
|
|
|
: '--', |
|
|
|
|
|
option: objRslt ? objRslt.option : p.option, |
|
|
option: objRslt ? objRslt.option : p.option, |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
@ -225,7 +249,26 @@ const Network = props => { |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
const searchStatusHandler=async (record)=>{ |
|
|
|
|
|
setControlId(record.controlId) |
|
|
|
|
|
setId(record.sensorId) |
|
|
|
|
|
setModalVis(true) |
|
|
|
|
|
let dimensionId = null |
|
|
|
|
|
let dtuId = null |
|
|
|
|
|
const values = { |
|
|
|
|
|
thingId, |
|
|
|
|
|
deviceId: record.sensorId, |
|
|
|
|
|
dimensionId, |
|
|
|
|
|
dimCapId:record.searchId, |
|
|
|
|
|
timeout: 60000 * 5, |
|
|
|
|
|
// param,
|
|
|
|
|
|
// userId: user.id,
|
|
|
|
|
|
dtuId, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const res= await dispatch(analysis.invokeCapability(values,token)) |
|
|
|
|
|
setStatus(res?.payload?.data?.data?.info?.includes('离线')?false:true) |
|
|
|
|
|
} |
|
|
const columns = [ |
|
|
const columns = [ |
|
|
{ |
|
|
{ |
|
|
title: '设备名称', |
|
|
title: '设备名称', |
|
@ -289,11 +332,36 @@ const Network = props => { |
|
|
render: (_, r) => { |
|
|
render: (_, r) => { |
|
|
return ( |
|
|
return ( |
|
|
//E9C,FS-WSD-01M
|
|
|
//E9C,FS-WSD-01M
|
|
|
<div> {r.model==='E9C'?<Button onClick={()=>{setModalVis(true)}}>查询</Button>: '--'}</div> |
|
|
<div> {r.model==='E9C'?<Button onClick={()=>{searchStatusHandler(r)}}>查询</Button>: '--'}</div> |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
] |
|
|
] |
|
|
|
|
|
const switchChange=(e)=>{ |
|
|
|
|
|
if(e){ |
|
|
|
|
|
setParam('开') |
|
|
|
|
|
}else{ |
|
|
|
|
|
setParam('关') |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//升级按钮
|
|
|
|
|
|
const okHandler=()=>{ |
|
|
|
|
|
let dimensionId = null |
|
|
|
|
|
let dtuId = null |
|
|
|
|
|
const values = { |
|
|
|
|
|
thingId, |
|
|
|
|
|
deviceId: id, |
|
|
|
|
|
dimensionId, |
|
|
|
|
|
dimCapId:controlId, |
|
|
|
|
|
timeout: 60000 * 5, |
|
|
|
|
|
param, |
|
|
|
|
|
// userId: user.id,
|
|
|
|
|
|
dtuId, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
dispatch(analysis.invokeCapability(values,token)) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
return ( |
|
|
return ( |
|
|
<> |
|
|
<> |
|
|
<Spin spinning={loading}> |
|
|
<Spin spinning={loading}> |
|
@ -339,21 +407,34 @@ const Network = props => { |
|
|
<Modal |
|
|
<Modal |
|
|
title='开关' |
|
|
title='开关' |
|
|
visible={modalVis} |
|
|
visible={modalVis} |
|
|
></Modal> |
|
|
onCancel={()=>{setModalVis(false)}} |
|
|
|
|
|
// sensorId={sensorId}
|
|
|
|
|
|
onOk={okHandler} |
|
|
|
|
|
okText='升级' |
|
|
|
|
|
> |
|
|
|
|
|
<Form> |
|
|
|
|
|
<Form.Item label='状态' name='status'> |
|
|
|
|
|
<Input disabled/> |
|
|
|
|
|
</Form.Item> |
|
|
|
|
|
<Form.Item label='开关' name='open'> |
|
|
|
|
|
<Switch disabled={status} onChange={switchChange}></Switch> |
|
|
|
|
|
</Form.Item> |
|
|
|
|
|
</Form> |
|
|
|
|
|
</Modal> |
|
|
</Spin> |
|
|
</Spin> |
|
|
</> |
|
|
</> |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function mapStateToProps (state) { |
|
|
function mapStateToProps (state) { |
|
|
const { auth, global, members, webSocket, deviceListAlarms, devicesCardStatus } = state |
|
|
const { auth, global, members, webSocket, deviceListAlarms, devicesCardStatus,thingStatus } = state |
|
|
return { |
|
|
return { |
|
|
user: auth.user, |
|
|
user: auth.user, |
|
|
actions: global.actions, |
|
|
actions: global.actions, |
|
|
clientHeight: global.clientHeight, |
|
|
clientHeight: global.clientHeight, |
|
|
deviceListAlarms: deviceListAlarms?.data || [], |
|
|
deviceListAlarms: deviceListAlarms?.data || [], |
|
|
devicesCardStatusList: devicesCardStatus?.data || [], |
|
|
devicesCardStatusList: devicesCardStatus?.data || [], |
|
|
|
|
|
thingStatus:thingStatus?.data||[] |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|