peng.peng 1 year ago
parent
commit
6d187a84da
  1. 158
      super-screen/client/src/sections/water-prevention/containers/homePage.js
  2. 31
      web/client/src/sections/dataService/containers/serviceManagement.js

158
super-screen/client/src/sections/water-prevention/containers/homePage.js

@ -46,92 +46,100 @@ function homePage(props) {
const currentContainer = SCREEN_COMPONENTS[tab]; const currentContainer = SCREEN_COMPONENTS[tab];
useEffect(() => { useEffect(() => {
getData(); getWaterData();
}, []) }, [])
const getData = () => { // 获取水务数据
// 水务 const getWaterData = async () => {
dispatch(waterLogin({ username: "123456", password: "123456", pcode: 'fce4afe2-5b6a-408a-ab18-a2afa7fa027c' })).then(loginRes => { const waterToken = sessionStorage.getItem('waterToken')
if (loginRes.success) { let token = waterToken;
const { token } = loginRes.payload.data; if (!token) {
sessionStorage.setItem('waterUser', JSON.stringify(loginRes.payload.data)); try {
// 水位趋势 const loginRes = await dispatch(waterLogin({ username: "123456", password: "123456", pcode: 'fce4afe2-5b6a-408a-ab18-a2afa7fa027c' }))
dispatch(getWaterLevelTrend({ orgId: 84, keyword: '', token })).then(trendRes => { if (loginRes.success) {
let fifterData = [] sessionStorage.setItem('waterToken', loginRes.payload.data.token);
if (trendRes.success) { token = loginRes.payload.data.token;
trendRes.payload.data.map((item, index) => { } else {
let alert = item.alert ? item.alert.replace('(', '').replace(')', '').split(',')[0] : '--' return;
let historyMax = item.historyMax ? item.historyMax.replace('(', '').replace(')', '').split(',')[0] : '--' }
let waterLevel = item.data.length != 0 ? item.data[item.data.length - 1].waterLevel : '' } catch (error) {
let lastWaterLevel = item.data.length != 0 ? item.data[item.data.length - 2].waterLevel : '' return;
let currentTime = item.data.length != 0 ? moment(item.data[item.data.length - 1].time).format('YYYY-MM-DD HH:mm:ss') : '' }
let currentState = item.data.length != 0 ? (item.alert && alert <= waterLevel ? '超警戒' : '正常') : '' }
let futureState = '' // 水位趋势
if (item.alert && item.futureData && item.futureData.length != 0) { dispatch(getWaterLevelTrend({ orgId: 84, keyword: '', token })).then(trendRes => {
item.futureData.map((futureItem) => { let fifterData = []
if (futureItem.value >= alert) { if (trendRes.success) {
futureState = `超警戒,预计${item.forecast_time}时水位抵达${(item.value).toFixed(2)}m` trendRes.payload.data.map((item, index) => {
} let alert = item.alert ? item.alert.replace('(', '').replace(')', '').split(',')[0] : '--'
}) let historyMax = item.historyMax ? item.historyMax.replace('(', '').replace(')', '').split(',')[0] : '--'
futureState = futureState != '' ? futureState : '正常' let waterLevel = item.data.length != 0 ? item.data[item.data.length - 1].waterLevel : ''
let lastWaterLevel = item.data.length != 0 ? item.data[item.data.length - 2].waterLevel : ''
let currentTime = item.data.length != 0 ? moment(item.data[item.data.length - 1].time).format('YYYY-MM-DD HH:mm:ss') : ''
let currentState = item.data.length != 0 ? (item.alert && alert <= waterLevel ? '超警戒' : '正常') : ''
let futureState = ''
if (item.alert && item.futureData && item.futureData.length != 0) {
item.futureData.map((futureItem) => {
if (futureItem.value >= alert) {
futureState = `超警戒,预计${item.forecast_time}时水位抵达${(item.value).toFixed(2)}m`
} }
fifterData.push({
index: index + 1,
name: item.name,
currentState,
waterLevel,
lastWaterLevel,
currentTime,
alert,
historyMax,
futureState,
lat: item.latitude,
lng: item.longitude,
id: item.id
})
}) })
futureState = futureState != '' ? futureState : '正常'
} }
setTrendData(fifterData) fifterData.push({
index: index + 1,
name: item.name,
currentState,
waterLevel,
lastWaterLevel,
currentTime,
alert,
historyMax,
futureState,
lat: item.latitude,
lng: item.longitude,
id: item.id
})
}) })
// 结构物 }
dispatch(getWaterStructures({ token })).then(structRes => { setTrendData(fifterData)
if (structRes.success) { })
setStructures(structRes.payload.data); // 结构物
// 视频 dispatch(getWaterStructures({ token })).then(structRes => {
let promiseArr = [ if (structRes.success) {
dispatch(getWaterVideoList(structRes.payload.data?.map(s => s.id).join(), { token })), setStructures(structRes.payload.data);
dispatch(getYsAccessToken({ token })) // 视频
]; let promiseArr = [
Promise.all(promiseArr).then(resArr => { dispatch(getWaterVideoList(structRes.payload.data?.map(s => s.id).join(), { token })),
if (resArr[0].success && resArr[1].success) { dispatch(getYsAccessToken({ token }))
const at = resArr[1].payload.data.accessToken; ];
const list = resArr[0].payload.data?.map(v => ({ url: v.yingshi.hlsAddress, name: v.name, structId: v.structId })); Promise.all(promiseArr).then(resArr => {
setAccessToken(at) if (resArr[0].success && resArr[1].success) {
setVideoList(list); const at = resArr[1].payload.data.accessToken;
} const list = resArr[0].payload.data?.map(v => ({ url: v.yingshi.hlsAddress, name: v.name, structId: v.structId }));
}) setAccessToken(at)
// 告警 setVideoList(list);
dispatch(getWaterAlarms({ token })).then(alarmRes => { }
if (alarmRes.success) { })
let levelAlarms = []; // 告警
alarmRes.payload.data.alarms.forEach(a => { dispatch(getWaterAlarms({ token })).then(alarmRes => {
let alarm = { ...a } if (alarmRes.success) {
for (const struct of structRes.payload.data) { let levelAlarms = [];
if (struct.id === a.structureId && struct.type.name === '河流') { alarmRes.payload.data.alarms.forEach(a => {
alarm.lng = struct.longitude; let alarm = { ...a }
alarm.lat = struct.latitude; for (const struct of structRes.payload.data) {
levelAlarms.push(alarm); if (struct.id === a.structureId && struct.type.name === '河流') {
} alarm.lng = struct.longitude;
}; alarm.lat = struct.latitude;
}) levelAlarms.push(alarm);
setWaterLevelAlarms(levelAlarms); }
} };
}) })
setWaterLevelAlarms(levelAlarms);
} }
}) })
} }
}) })
} }
const getPumpStatusData = async (structId) => { const getPumpStatusData = async (structId) => {

31
web/client/src/sections/dataService/containers/serviceManagement.js

@ -4,7 +4,7 @@ import moment from 'moment';
import { RouteRequest } from '@peace/utils'; import { RouteRequest } from '@peace/utils';
import { RouteTable } from '$utils' import { RouteTable } from '$utils'
import { Tabs, Form, Input, Space, Button, Table, Popconfirm } from 'antd'; import { Tabs, Form, Input, Space, Button, Table, Popconfirm, message } from 'antd';
const { Search } = Input; const { Search } = Input;
import EditModal from '../components/editModal'; import EditModal from '../components/editModal';
@ -65,19 +65,22 @@ function ServiceManagement ({ loading, clientHeight, actions, dispatch, }) {
}}>编辑</a> }}>编辑</a>
{/* {record?.enabled ? */} {/* {record?.enabled ? */}
<Popconfirm {record?.resourceConsumptions?.length > 0 ? <a onClick={() => {
title="是否确认删除该业务规则?" message.warning('已有关联数据,无法删除')
onConfirm={() => { }}>删除</a>
dispatch(dataService.delBusinessRules(record.id)).then(res => { : <Popconfirm
if (res.success) { title="是否确认删除该服务?"
setQuery({ limit: 10, page: 0 }); onConfirm={() => {
resourceData({ limit: 10, page: 0, keyword }) dispatch(dataService.delServiceManagement(record.id)).then(res => {
} if (res.success) {
}) setQuery({ limit: 10, page: 0 });
}} resourceData({ limit: 10, page: 0, keyword })
> }
<a >删除</a> })
</Popconfirm> }}
>
<a >删除</a>
</Popconfirm>}
{/* // } */} {/* // } */}
{record?.enabled ? {record?.enabled ?

Loading…
Cancel
Save