Browse Source

(*)告警导出限制7天

dev
wuqun 3 years ago
parent
commit
302a24780c
  1. 124
      web/client/src/sections/problem/components/tableData.jsx

124
web/client/src/sections/problem/components/tableData.jsx

@ -1,6 +1,6 @@
import React, { useState, useEffect, useRef } from "react";
import { connect } from "react-redux";
import { Button, Form, Modal, Skeleton, Pagination, Table } from "@douyinfe/semi-ui";
import { Button, Form, Modal, Skeleton, Pagination, Table, Tooltip, Toast } from "@douyinfe/semi-ui";
import { SkeletonScreen, } from "$components";
import moment from "moment";
import { validate } from "schema-utils";
@ -122,7 +122,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
useEffect(() => {
if (location) {
search.current = { ...search.current, ...location, state: 'new' }
api.current?.setValues({...location, state: 'new'})
api.current?.setValues({ ...location, state: 'new' })
}
if (route !== 'videoAbnormal' && route !== 'useAbnormal') {
dispatch(problem.getAlarmDataGroup()).then((res) => {
@ -159,29 +159,77 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
const handleExport = () => {
let url = ''
let { keywordTarget, keyword = '', errType = '', state = '', kindId = '', groupUnitId = '', confirmState = '', onlineState = '', sustainTimeStart = '', sustainTimeEnd = '' } = search.current
if (sustainTimeStart && sustainTimeEnd) {
let range = moment(sustainTimeEnd).diff(moment(sustainTimeStart), 'minutes')
if (range > 24 * 60 * 7) {
Toast.warning({
content: '导出自定义时间跨度不超过7天',
duration: 3,
})
return false;
}
} else {
sustainTimeStart = moment().add(-7, 'day').format("YYYY-MM-DD HH:mm:ss")
sustainTimeEnd = moment().format("YYYY-MM-DD HH:mm:ss")
}
switch (route) {
case 'useAbnormal':
url = `alarm/application/api?token=${user.token}&toExport=1&timestamp=${moment().valueOf()}&keyword=${keyword}&errType=${errType}
&state=${state}stainTimeStart=${sustainTimeStart}&sustainTimeEnd=${sustainTimeEnd}&pepProjectId=${pepProjectId || ''}`
dispatch(problem.getAlarmLnspectionApi({ ...search.current, limit: 1, sustainTimeStart, sustainTimeEnd, pepProjectId: pepProjectId })).then((res) => {
if (res.success) {
if (res.payload.data.count) {
url = `alarm/application/api?token=${user.token}&toExport=1&timestamp=${moment().valueOf()}&keyword=${keyword}&errType=${errType}
&state=${state}stainTimeStart=${sustainTimeStart}&sustainTimeEnd=${sustainTimeEnd}&pepProjectId=${pepProjectId || ''}`
setExportUrl(url);
} else {
Toast.info({
content: '暂无可导出的数据',
duration: 3,
})
}
}
})
break;
case 'videoAbnormal':
url = `alarm/video/list?token=${user.token}&toExport=1&timestamp=${moment().valueOf()}&keywordTarget=${keywordTarget}
&keyword=${keyword}&kindId=${kindId}&state=${state}&sustainTimeStart=${sustainTimeStart}&sustainTimeEnd=${sustainTimeEnd}
&pepProjectId=${pepProjectId || ''}`
dispatch(problem.getAlarmVideoList({ ...search.current, limit: 1, sustainTimeStart, sustainTimeEnd, pepProjectId: pepProjectId })).then((res) => {
if (res.success) {
if (res.payload.data.count) {
url = `alarm/video/list?token=${user.token}&toExport=1&timestamp=${moment().valueOf()}&keywordTarget=${keywordTarget}
&keyword=${keyword}&kindId=${kindId}&state=${state}&sustainTimeStart=${sustainTimeStart}&sustainTimeEnd=${sustainTimeEnd}
&pepProjectId=${pepProjectId || ''}`
setExportUrl(url);
} else {
Toast.info({
content: '暂无可导出的数据',
duration: 3,
})
}
}
})
break;
default:
let groups = {
"dataLnterrupt": "1",
"dataAbnormal": "2",
"strategyHit": "3",
"deviceAbnormal": "4,5"
}
url = `alarm/data/list?token=${user.token}&toExport=1&timestamp=${moment().valueOf()}&state=${state}&keywordTarget=${keywordTarget}&keyword=${keyword}&kindId=${kindId}
&groupUnitId=${groupUnitId}&errType=${errType}&confirmState=${confirmState}&onlineState=${onlineState}&sustainTimeStart=${sustainTimeStart}
&sustainTimeEnd=${sustainTimeEnd}&pepProjectId=${pepProjectId || ''}&groupId=${groups[route]}`
dispatch(problem.getAlarmDataList({ ...query, ...search.current, limit: 1, sustainTimeStart, sustainTimeEnd, groupId: groupId.current.map(v => v.id).join(), pepProjectId: pepProjectId })).then((res) => {
if (res.success) {
if (res.payload.data.count) {
let groups = {
"dataLnterrupt": "1",
"dataAbnormal": "2",
"strategyHit": "3",
"deviceAbnormal": "4,5"
}
url = `alarm/data/list?token=${user.token}&toExport=1&timestamp=${moment().valueOf()}&state=${state}&keywordTarget=${keywordTarget}&keyword=${keyword}&kindId=${kindId}
&groupUnitId=${groupUnitId}&errType=${errType}&confirmState=${confirmState}&onlineState=${onlineState}&sustainTimeStart=${sustainTimeStart}
&sustainTimeEnd=${sustainTimeEnd}&pepProjectId=${pepProjectId || ''}&groupId=${groups[route]}`
setExportUrl(url);
} else {
Toast.info({
content: '暂无可导出的数据',
duration: 3,
})
}
}
})
break;
}
setExportUrl(url);
}
return (
@ -269,25 +317,27 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
marginBottom: 16
}}
>
<img title='导出' src="/assets/images/problem/export.png" style={{ width: 20 }}
onClick={() => {
api.current.validate().then((v) => {
search.current = {
state: v.state,
keywordTarget: v.keywordTarget,
keyword: v.keyword,
kindId: v.kindId,
groupUnitId: v.groupUnitId,
errType: v.errType,
confirmState: v.confirmState,
onlineState: v.onlineState,
sustainTimeStart: v.time && v.time.length > 0 ? moment(v.time[0]).format("YYYY-MM-DD HH:mm:ss") : "",
sustainTimeEnd: v.time && v.time.length > 0 ? moment(v.time[1]).format("YYYY-MM-DD HH:mm:ss") : "",
}
handleExport();
});
}} />
<img title='设置' src="/assets/images/problem/setup.png" style={{ width: 20 }} onClick={() => setSetup(true)} />
<Tooltip content={'默认导出最近7天的数据,自定义时间跨度不超过7天'}>
<img title='导出' src="/assets/images/problem/export.png" style={{ width: 20, cursor: 'pointer' }}
onClick={() => {
api.current.validate().then((v) => {
search.current = {
state: v.state,
keywordTarget: v.keywordTarget,
keyword: v.keyword,
kindId: v.kindId,
groupUnitId: v.groupUnitId,
errType: v.errType,
confirmState: v.confirmState,
onlineState: v.onlineState,
sustainTimeStart: v.time && v.time.length > 0 ? moment(v.time[0]).format("YYYY-MM-DD HH:mm:ss") : "",
sustainTimeEnd: v.time && v.time.length > 0 ? moment(v.time[1]).format("YYYY-MM-DD HH:mm:ss") : "",
}
handleExport();
});
}} />
</Tooltip>
<img title='设置' src="/assets/images/problem/setup.png" style={{ width: 20, cursor: 'pointer' }} onClick={() => setSetup(true)} />
<Button
theme="solid"
type="primary"
@ -415,7 +465,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
}
function mapStateToProps (state) {
function mapStateToProps(state) {
const { auth, global, members } = state;
// console.log(global);
return {

Loading…
Cancel
Save