Browse Source

actions 组网请求修改

dev
wenlele 1 year ago
parent
commit
ec2be660da
  1. 15
      api/config.js
  2. 8
      web-network/client/assets/js/g6/index.js
  3. 10
      web-network/client/index.ejs
  4. 12
      web-network/client/index.html
  5. 19
      web-network/client/src/sections/network/actions/network.js
  6. 2
      web-network/client/src/sections/network/components/device-tree/edit-map.js
  7. 2
      web-network/client/src/sections/network/components/device-tree/zuwang-main.js
  8. 50
      web-network/client/src/sections/network/containers/device-monitor.js
  9. 341
      web-network/client/src/sections/network/containers/tableShow.js
  10. 2
      web-network/client/src/sections/network/index.js

15
api/config.js

@ -228,7 +228,20 @@ const product = {
{ p: '/project/group/list', o: 'GET' }, { p: '/project/group/list', o: 'GET' },
{ p: '/project/group/:groupId/detail', o: 'GET' }, { p: '/project/group/:groupId/detail', o: 'GET' },
{ p: '/project/workOrders/repairRank', o: 'GET' }, { p: '/project/workOrders/repairRank', o: 'GET' },
{ p: '/project/workOrders', o: 'GET' } { p: '/project/workOrders', o: 'GET' },
{ p: '/organizations/:pepProjectId/struc', o: 'GET' },
{ p: '/things/:iotaThingId/deploys', o: 'GET' },
{ p: '/meta/things/:iotaThingId/devices', o: 'GET' },
{ p: '/metrics/things/:iotaThingId/devices/link_status', o: 'GET' },
{ p: '/things/:iotaThingId/deploy', o: 'GET' },
{ p: '/sensors/last/data', o: 'POST' },
{ p: '/meta/things/:iotaThingId/devices', o: 'GET' },
{ p: '/devices/alarms', o: 'POST' },
{ p: '/devices/cardStatus', o: 'POST' },
{ p: '/metrics/devices/:deviceId/link_status', o: 'GET' },
{ p: '/device/:deviceId/alarms', o: 'GET' },
], // 不做认证的路由,也可以使用 exclude: ["*"] 跳过所有路由 ], // 不做认证的路由,也可以使用 exclude: ["*"] 跳过所有路由
apMergeDeVeAnxinProjectId: AP_MERGE_DEVE_ANXINPROJECT_ID, apMergeDeVeAnxinProjectId: AP_MERGE_DEVE_ANXINPROJECT_ID,
anxinCloud: { anxinCloud: {

8
web-network/client/assets/js/g6/index.js

File diff suppressed because one or more lines are too long

10
web-network/client/index.ejs

@ -10,14 +10,7 @@
<script src="/assets/js/OlMap/OlMapTool.umd.min.js"></script> <script src="/assets/js/OlMap/OlMapTool.umd.min.js"></script>
<link rel="stylesheet" href="/assets/js/OlMap/OlMapTool.css"> <link rel="stylesheet" href="/assets/js/OlMap/OlMapTool.css">
<!-- --> <!-- -->
<script type="text/javascript">
window._AMapSecurityConfig = {
securityJsCode: 'e955cd5ddfc3a752aa27d1e1c67d182d',
}
</script>
<script
src="https://webapi.amap.com/maps?v=2.0&key=00f9a29dedcdbd8befec3dfe0cef5003&plugin=AMap.Adaptor,AMap.Scale,AMap.ToolBar,AMap.DistrictSearch,AMap.Geocoder,AMap.CustomLayer,Map3D,ElasticMarker"></script>
<script src="https://webapi.amap.com/loca?v=2.0.0&key=00f9a29dedcdbd8befec3dfe0cef5003"></script>
</head> </head>
<body style="background: transparent"> <body style="background: transparent">
@ -34,6 +27,7 @@
env: "production", env: "production",
}; };
</script> </script>
<script type="text/javascript" src="/assets/js/g6/index.js"></script>
<script type="text/javascript" src="/assets/js/less/less.min.js"></script> <script type="text/javascript" src="/assets/js/less/less.min.js"></script>
<div id="App"></div> <div id="App"></div>
</body> </body>

12
web-network/client/index.html

@ -11,14 +11,8 @@
<script src="/assets/js/OlMap/OlMapTool.umd.min.js"></script> <script src="/assets/js/OlMap/OlMapTool.umd.min.js"></script>
<link rel="stylesheet" href="/assets/js/OlMap/OlMapTool.css"> <link rel="stylesheet" href="/assets/js/OlMap/OlMapTool.css">
<!-- --> <!-- -->
<script type="text/javascript">
window._AMapSecurityConfig = {
securityJsCode: 'e955cd5ddfc3a752aa27d1e1c67d182d',
}
</script>
<script
src="https://webapi.amap.com/maps?v=2.0&key=00f9a29dedcdbd8befec3dfe0cef5003&plugin=AMap.Adaptor,AMap.Scale,AMap.ToolBar,AMap.DistrictSearch,AMap.Geocoder,AMap.CustomLayer,Map3D,ElasticMarker"></script>
<script src="https://webapi.amap.com/loca?v=2.0.0&key=00f9a29dedcdbd8befec3dfe0cef5003"></script>
</head> </head>
<body> <body>
@ -29,6 +23,8 @@
env: "production", env: "production",
}; };
</script> </script>
<script type="text/javascript" src="/assets/js/g6/index.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/less.js/2.7.2/less.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/less.js/2.7.2/less.min.js"></script>
<div id="App"></div> <div id="App"></div>
<script type="text/javascript" src="http://localhost:5001/client/build/app.js"></script> <script type="text/javascript" src="http://localhost:5001/client/build/app.js"></script>

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

@ -1,6 +1,7 @@
'use strict'; 'use strict';
import { ApiTable, basicAction } from '$utils' import { basicAction } from '@peace/utils';
import { ApiTable } from '$utils';
export function getOrganizationsStruc (id) { export function getOrganizationsStruc (id) {
@ -129,3 +130,19 @@ export function findAlarmsDevice (id) {
}) })
} }
export default {
getOrganizationsStruc,
getThingsDeploy,
getDeviceMetaDeployed,
getIotaThingsLlinkStatus,
getIotaThingsLlinkStatus,
findDeviceMetaDeployed,
findSensorLastData,
getDevicesAlarms,
findDevicesCardStatus,
getDevicesLlinkStatus,
findAlarmsDevice,
}

2
web-network/client/src/sections/network/components/device-tree/edit-map.js

@ -1,7 +1,7 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { PinyinHelper } from '@peace/utils'; import { PinyinHelper } from '@peace/utils';
const { G6 } = window; // const { G6 } = window;
let uniqueId = 0; let uniqueId = 0;
function generateUniqueId() { function generateUniqueId() {

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

@ -34,7 +34,7 @@ export default function ({ ...props }) {
// const da = useThingsLinkStatus(struct?.iotaThingId); // const da = useThingsLinkStatus(struct?.iotaThingId);
const getThingsLinkStatus = (isCycle = false) => { const getThingsLinkStatus = (isCycle = false) => {
const iotaThingId = struct?.iotaThingId; const iotaThingId = struct?.thingId;
if (iotaThingId) { if (iotaThingId) {
const url = ApiTable.getIotaThingsLlinkStatus.replace('{iotaThingId}', iotaThingId); const url = ApiTable.getIotaThingsLlinkStatus.replace('{iotaThingId}', iotaThingId);
Request.get(url).then((res) => { Request.get(url).then((res) => {

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

@ -14,13 +14,14 @@ import { DeviceTypes } from '../constant';
import qs from "qs"; import qs from "qs";
import '../style.less'; import '../style.less';
import TableShow from './tableShow' // import TableShow from './tableShow'
function DeviceMonitor({ ...props }) { function DeviceMonitor ({ ...props }) {
const { const {
dispatch, actions, user, clientWidth, clientHeight, loading, dispatch, actions, user, clientWidth, clientHeight, loading,
myStructList, deviceMetasWithFollow, devices, dimensions, deviceListAlarms, factorStations, myStructList, deviceMetasWithFollow, devices, dimensions, deviceListAlarms, factorStations,
} = props; } = props;
console.log(3213,actions);
const { analysis } = actions
const [params, setParams] = useState({}); const [params, setParams] = useState({});
const [selectStructure, setSelectStructure] = useState(null); const [selectStructure, setSelectStructure] = useState(null);
@ -34,17 +35,10 @@ function DeviceMonitor({ ...props }) {
useEffect(() => { useEffect(() => {
if (strucParam?.thingId) {
dispatch(analysis.getThingsDeploy(strucParam?.thingId))
// dispatch(actions.dataMonitor.getDeviceMeta()); dispatch(analysis.getDeviceMetaDeployed(strucParam?.thingId))
// dispatch(actions.dataMonitor.getMyStructList(user?.orgId)).then((res) => { }
// if (res.success) {
// const data = res?.payload?.data || [];
// if (data.length > 0) {
// setSelectStructure(data[0]?.id);
// }
// }
// });
}, []); }, []);
useEffect(() => { useEffect(() => {
@ -66,10 +60,7 @@ function DeviceMonitor({ ...props }) {
} }
}, [selectStructure]); }, [selectStructure]);
// 结构物切换
const sturctureChange = (value) => {
setSelectStructure(value);
};
// 展示切换 // 展示切换
const onExtraChange = (e) => { const onExtraChange = (e) => {
setExtraType(e.target.value); setExtraType(e.target.value);
@ -191,38 +182,25 @@ function DeviceMonitor({ ...props }) {
// <div>div</div> // <div>div</div>
// <LayoutContent> // <LayoutContent>
<Spin spinning={false}> <Spin spinning={false}>
<Select
allowClear
placeholder="选择结构物"
style={{ minWidth: 300, marginBottom: 15 }}
getPopupContainer={(triggerNode) => triggerNode.parentNode}
value={selectStructure}
onChange={sturctureChange}
optionFilterProp="children"
showSearch
filterOption={PeaceFunc.selectFilterOption}
>
{myStructList.map((v) => <Select.Option key={v.id} value={v.id}>{v.name}</Select.Option>)}
</Select>
<ProCard title={renderTitle()} extra={renderExtra()} headerBordered> <ProCard title={renderTitle()} extra={renderExtra()} headerBordered>
{ {
extraType === 'tree' extraType === 'tree'
? (myStructList.find((v) => v.id === selectStructure) ? deviceMetasWithFollow?.devices?.length > 0
&& deviceMetasWithFollow?.devices?.length > 0 && devices.instances
&& devices.instances)
? ( ? (
<DeviceTree <DeviceTree
deviceMetasWithFollow={deviceMetasWithFollow} deviceMetasWithFollow={deviceMetasWithFollow}
deviceList={devices} deviceList={devices}
dimensionlist={dimensions} dimensionlist={dimensions}
dispatch={dispatch} dispatch={dispatch}
struct={myStructList.find((v) => v.id === selectStructure)} struct={strucParam}
clientHeight={clientHeight} clientHeight={clientHeight}
clientWidth={clientWidth} clientWidth={clientWidth}
/> />
) : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> ) : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
: ( : (
<TableShow thingId={strucParam.thingId} project={strucParam.projectId}/> <div></div>
// <TableShow thingId={strucParam.thingId} project={strucParam.projectId}/>
) )
} }
</ProCard> </ProCard>

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

@ -1,341 +0,0 @@
import React, { useEffect, useState, useRef, useMemo } from 'react'
import { connect } from 'react-redux'
import { Spin, Card, CardGroup, Form, Button, Table, Pagination, Tooltip } from '@douyinfe/semi-ui'
import { ExportData } from '@peace/components';
import moment from 'moment'
const Network = props => {
const { dispatch, actions, user, clientHeight, thingId, deviceListAlarms, devicesCardStatusList, project } = props
const { analysis } = actions
const form = useRef() //表单
const [deployData, setDeployData] = useState([])
const [deviceData, setDeviceData] = useState([])
const [deviceMetasDeployed, setDeviceMetasDeployed] = useState([])
const [sensorId, setSensorId] = useState([])
const [sensorsDataItems, setSensorsDataItems] = useState({})
const [tableData, setTableData] = useState([]) //最新一次的数据
const [lastData, setLastData] = useState([]) //最终数据
const [lastDataCopy, setLastDataCopy] = useState([]) //最终数据
const [searchType, setSearchType] = useState('')
const [searchName, setSearchName] = useState('')
const [typeList, setTypeList] = useState([])
const [query, setQuery] = useState({ limit: 10, page: 0 }) //页码信息
const DeviceTypes = {
'DTU': 'DTU',
'gateway': '网关',
'sensor': '传感器',
'acqUnit': '采集单元',
'dau.gateway': '分布式智能云采集网关',
'dau.node': '分布式智能云采集节点',
'tcp.dtu': '工作站',
}
useEffect(() => {
setLastData([])
setLastDataCopy([])
}, [project])
useEffect(() => {
if (thingId) {
let dataList = []
dispatch(analysis.getThingsDeploy(thingId)).then(rs => {
if (rs.success) {
setDeployData(rs.payload.data)
dataList = rs.payload.data
//列表渲染数据
let da = []
if (dataList.instances) {
Object.keys(dataList.instances).forEach(i => {
if (dataList.instances[i].type == 's.d') {
da.push({
sensorId: i,
sensorName: dataList.instances[i]?.name,
deviceType: dataList?.instances[i]?.instance?.properties?.deviceType,
collectTime: '--',
data: '--',
iotCardStatus: '--',
status: '--',
option: '--',
})
}
})
}
dispatch(analysis.findDeviceMetaDeployed(thingId)).then(res => {
if (res.success) {
setDeviceMetasDeployed(res.payload.data)
const deviceMetaDeployed = res.payload.data
if (deviceMetaDeployed && dataList && deviceMetaDeployed.devices) {
const sensorsId = []
let alarmSensorId = [] //所有设备的id
const sensorsDataItems = {}
for (const id in dataList.instances) {
alarmSensorId.push(id)
const instances = dataList.instances[id]
if (instances.type == 's.d' && instances.instance.properties.deviceType == 'sensor') {
const meta = deviceMetaDeployed.devices.find(m => m.id == instances.instance.deviceMetaId)
sensorsDataItems[id] = {
items: {},
deviceName: instances.name,
}
if (meta) {
sensorsDataItems[id].items = meta.capabilities[0].properties.reduce((p, n) => {
if (n.category == 'Output') {
p[n.name] = { name: n.showName, unit: n.unit }
}
return p
}, {})
}
sensorsId.push(id)
}
}
dispatch(analysis.getDevicesAlarms({ deviceIds: alarmSensorId }, { limit: 5 }))
dispatch(analysis.findDevicesCardStatus({ deviceIds: alarmSensorId }))
setSensorsDataItems(sensorsDataItems)
setSensorId(sensorsId)
setDeviceData(da)
}
}
})
}
})
}
}, [thingId])
useEffect(async () => {
if (sensorId && sensorId.length && sensorsDataItems) {
const rs = await dispatch(analysis.findSensorLastData(sensorId))
const tableData = []
if (rs.success) {
rs.payload.data.forEach(sd => {
if (Object.keys(sensorsDataItems).length) {
let sensorDataItem = sensorsDataItems[sd.sensorId]
let sensorName = sensorDataItem && sensorDataItem.deviceName ? sensorDataItem.deviceName : ''
let msg = sd.data.length
? sd.data[0]
: {
collectTime: null,
sensorName: sensorName,
data: { noData: '暂无数据' },
}
let dataStr = ''
let dataKeys = Object.keys(msg.data)
dataKeys.forEach(k => {
let item = sensorDataItem && sensorDataItem.items ? sensorDataItem.items[k] : null
if (item) {
dataStr += `${item.name}${msg.data[k]}${item.unit}); `
} else if (k == 'noData') {
dataStr += msg.data[k]
} else {
dataStr += `${k}${msg.data[k]}`
}
})
let collectTime = msg.collectTime ? moment(msg.collectTime).format('YYYY-MM-DD HH:mm:ss') : '--'
tableData.push({
sensorId: sd.sensorId,
sensorName: sensorName,
collectTime: collectTime,
data: dataStr,
deviceType: 'sensor', //传感器
iotCardStatus: '--',
status: '--',
option: '--',
})
}
})
}
setTableData(tableData)
}
}, [sensorId])
useEffect(() => {
if (deviceData && deviceData.length ) {
const dataD = deviceData?.map(p => {
const objRslt = tableData?.find(q => q.sensorId == p.sensorId)
return {
sensorId: objRslt ? objRslt.sensorId : p.sensorId,
sensorName: objRslt ? objRslt.sensorName : p.sensorName,
collectTime: objRslt ? objRslt.collectTime : p.collectTime,
data: objRslt ? objRslt.data : p.data,
deviceType: DeviceTypes[objRslt ? objRslt.deviceType : p.deviceType],
iotCardStatus:
devicesCardStatusList && devicesCardStatusList.length
? devicesCardStatusList.find(v => v.deviceId == p.sensorId).status === 0
? '正常'
: devicesCardStatusList.find(v => v.deviceId == p.sensorId).status === 1
? '未激活'
: '停机'
: '--',
status:
deviceListAlarms && deviceListAlarms.length
? deviceListAlarms?.find(v => v.deviceId == p.sensorId)
? '异常'
: '正常'
: '--',
option: objRslt ? objRslt.option : p.option,
}
})
const typeList = dataD.reduce((p, c) => {
let isExist = p.some(q => q.label === c.deviceType)
if (!isExist) {
p.push({ label: c.deviceType, value: c.sensorId })
}
return p
}, [])
setTypeList(typeList)
setLastData(dataD)
setLastDataCopy(dataD)
}
}, [deviceData])
// const lastDataCopy=useMemo(()=>{
// return lastData
// },[thingId])
const scroll = useMemo(() => ({ y:clientHeight-600+175 }), [])
//名称回调事件
const inputChange = e => {
setSearchName(e)
}
//选择设备类型下拉框回调
const selectChange = e => {
let rslt=typeList.find(f => f.value == e)
setSearchType(rslt?rslt.label:undefined)
}
//查询事件回调
const searchHandler = () => {
setLastData(
lastDataCopy.filter(f =>
(searchName === undefined || f.sensorName.includes(searchName)) &&
(searchType === undefined || f.deviceType===searchType)
)
)
}
const columns = [
{
title: '设备名称',
dataIndex: 'sensorName',
width: '20%',
key: 'sensorName',
render: (_, r) => {
return (
<>
<Tooltip content={r.sensorName}>
<div>{r.sensorName.length > 7 ? `${r.sensorName.substr(0, 7)}...` : r.sensorName}</div>
</Tooltip>
</>
)
},
},
{
title: '设备类型',
dataIndex: 'deviceType',
width: '15%',
key: 'deviceType',
},
{
title: '最后采集时间',
dataIndex: 'collectTime',
width: '15%',
key: 'collectTime',
},
{
title: '数据',
dataIndex: 'data',
width: '20%',
key: 'data',
render: (_, r) => {
return (
<>
<Tooltip content={r.data}>
<div>{r.data.length > 6 ? `${r.data.substr(0, 6)}...` : r.data}</div>
</Tooltip>
</>
)
},
},
{
title: '物联网卡状态',
width: '15%',
dataIndex: 'iotCardStatus',
key: 'iotCardStatus',
},
{
title: '状态',
width: '10%',
dataIndex: 'status',
key: 'status',
},
{
title: '操作',
width: '10%',
dataIndex: 'option',
key: 'option',
},
]
return (
<>
<div style={{ marginBottom: 12, display: 'flex' }}>
<div>
<Form>
<Form.Input
// suffix={<IconSearch />}
field='name'
pure
showClear
label='名称'
style={{ width: 260, marginRight: 12 }}
placeholder='请输入设备名称'
onChange={inputChange}
/>
<Form.Select
optionList={typeList}
field='type'
pure
showClear
label='设备类型'
onChange={selectChange}
style={{ width: 260, marginLeft: 12, marginRight: 12 }}
placeholder='请选择设备类型'
/>
<Button theme='solid' type='primary' htmlType='submit' onClick={searchHandler}>
查询
</Button>
</Form>
</div>
<div style={{ marginLeft: 10 }}>
{' '}
{lastData.length ? (
<ExportData
// showIcon
fileName='设备列表'
exportType='fileSaver'
data={lastData}
columns={columns}
key='export'
/>
) : (
''
)}
</div>
</div>
<Table
scroll={scroll}
columns={columns}
dataSource={lastData}></Table>
</>
)
}
function mapStateToProps(state) {
const { auth, global, members, webSocket, deviceListAlarms, devicesCardStatus } = state
return {
user: auth.user,
actions: global.actions,
clientHeight: global.clientHeight,
deviceListAlarms: deviceListAlarms?.data || [],
devicesCardStatusList: devicesCardStatus?.data || [],
}
}
export default connect(mapStateToProps)(Network)

2
web-network/client/src/sections/network/index.js

@ -6,7 +6,7 @@ import actions from './actions';
import { getNavItem } from './nav-item'; import { getNavItem } from './nav-item';
export default { export default {
key: 'dataMonitor', key: 'analysis',
name: '实时监控', name: '实时监控',
reducers: reducers, reducers: reducers,
routes: routes, routes: routes,

Loading…
Cancel
Save