wuqun 2 years ago
parent
commit
a782575468
  1. 2
      api/app/lib/controllers/control/data.js
  2. 15
      api/app/lib/controllers/push/config.js
  3. 98
      web/client/src/sections/control/containers/control.jsx
  4. 4
      web/client/src/sections/problem/components/tableData.jsx
  5. 42
      web/client/src/sections/service/components/pushModal.jsx
  6. 22
      web/client/src/sections/service/containers/emPush.jsx

2
api/app/lib/controllers/control/data.js

@ -336,7 +336,7 @@ async function getLatestDynamic(ctx) {
} }
if (d.emailSendId) { if (d.emailSendId) {
notice.push({ notice.push({
userName: userPepRes.find(u => d.emailSendLog.toPepUserIds.indexOf(u.id) != -1), userName: userPepRes.filter(u => d.emailSendLog.toPepUserIds.indexOf(u.id) != -1),
projectName, projectName,
...d.emailSendLog.dataValues ...d.emailSendLog.dataValues
}); });

15
api/app/lib/controllers/push/config.js

@ -171,6 +171,21 @@ async function edit (ctx) {
name, pomsProjectId, alarmType, receiverPepUserId, timeType, disable, name, pomsProjectId, alarmType, receiverPepUserId, timeType, disable,
strucId, tactics, tacticsParams strucId, tactics, tacticsParams
} }
let repeatOption = {
where: {
name,
del: false,
}
}
if (pushId) {
repeatOption.where.id = { $ne: pushId }
}
let repeatRes = await models.AlarmPushConfig.findOne(repeatOption)
if (repeatRes) {
throw `已有名称为[${name}]的同名策略`
}
if (pushId) { if (pushId) {
await models.AlarmPushConfig.update(storageData, { await models.AlarmPushConfig.update(storageData, {
where: { where: {

98
web/client/src/sections/control/containers/control.jsx

@ -8,6 +8,7 @@ import repairFQA from '../../means/containers/repairFQA';
import { Setup, OutHidden } from "$components"; import { Setup, OutHidden } from "$components";
import ReactECharts from 'echarts-for-react'; import ReactECharts from 'echarts-for-react';
import moment from "moment"; import moment from "moment";
import { log } from 'ezuikit-js';
let newScrollbar; let newScrollbar;
let overviewScrollbar; let overviewScrollbar;
@ -52,6 +53,7 @@ const Control = (props) => {
const exhibition = useRef({ workbench: [], statistical: [] }) // const exhibition = useRef({ workbench: [], statistical: [] }) //
const FormApi = useRef() const FormApi = useRef()
// const query={ limit: 10, page: 0, projectCorrelationId: '', types: '1,2,3,4' } //
// websocket 使 // websocket 使
useEffect(() => { useEffect(() => {
@ -87,7 +89,6 @@ const Control = (props) => {
}) })
}, []) }, [])
useEffect(() => { useEffect(() => {
@ -154,13 +155,12 @@ const Control = (props) => {
}) })
}, [pepProjectId, projectId]) }, [pepProjectId, projectId])
// console.log(exhibition?.current?.dynamic);
useEffect(() => { useEffect(() => {
// //
if (exhibition?.current?.dynamic?.length > 0) { if (exhibition?.current?.dynamic?.length > 0) {
dispatch(control.getLatestDynamic({ ...query, projectCorrelationId: pepProjectId })).then(res => { dispatch(control.getLatestDynamic({ ...query, projectCorrelationId: pepProjectId })).then(res => {
console.log(res.payload.data); let data = querydata
let data = []
if (res.success) { if (res.success) {
if (exhibition?.current?.dynamic?.find(v => v.key == 'discovery')) { if (exhibition?.current?.dynamic?.find(v => v.key == 'discovery')) {
res.payload.data?.appear?.map(v => data.push({ res.payload.data?.appear?.map(v => data.push({
@ -182,6 +182,18 @@ const Control = (props) => {
// confirmContent:v.confirmContent, // confirmContent:v.confirmContent,
})) }))
} }
if (exhibition?.current?.dynamic?.find(v => v.key == 'notice')) {
res.payload.data?.notice?.map(v => data.push({
seed: 'notice',
time: v.time,
project: v.projectName,
userName: v.userName?.map(u => u.name),
alarmPushConfig: v.alarmPushConfig?.name,
tactics: v.tactics,
interval: v.tacticsParams?.interval,
deviceProportion: v.tacticsParams?.deviceProportion,
}))
}
data.sort((a, b) => { data.sort((a, b) => {
if (moment(a.time).isBefore(b.time)) { if (moment(a.time).isBefore(b.time)) {
return 1 return 1
@ -189,12 +201,21 @@ const Control = (props) => {
return -1 return -1
} }
}) })
console.log(data);
setQueryData(data) setQueryData(data)
} }
}) })
} else { }
setQueryData([])
const line = document.getElementById("line")
const news = document.getElementById("news")
if (line && news) {
news.onscroll = () => {
// console.log(news.scrollTop)
// console.log(line.clientHeight)
if ((line.clientHeight - 600) < news.scrollTop) {
setQuery({ ...query, page: query.page + 1 })
}
}
} }
}, [pepProjectId, query, exhibition.current]) }, [pepProjectId, query, exhibition.current])
@ -388,7 +409,7 @@ const Control = (props) => {
exhibition.current = { ...exhibition.current, [title]: TableDisplay } exhibition.current = { ...exhibition.current, [title]: TableDisplay }
setTableSetup([{ list: data }]) setTableSetup([{ list: data }])
} }
console.log(memberList)
return ( return (
<> <>
@ -920,31 +941,42 @@ const Control = (props) => {
</div> </div>
</div> </div>
<div id='news' style={{ height: 578, position: 'relative', marginTop: 10, }}> <div id='news' style={{ height: 578, position: 'relative', marginTop: 10, }}>
<Timeline mode="center" style={{ marginLeft: '-56px', width: 400 }}> <div id='line' style={{ width: '100%' }}>
{querydata?.map((v, index) => { <Timeline mode="center" style={{ marginLeft: '-56px', width: 400 }}>
let title = v.seed == 'discovery' ? {querydata?.map((v, index) => {
v.project + '项目' + v.sources + v.type : let title = ''
v.seed == 'confirm' ? if (v.seed == 'discovery') {
v.userName + '确认并关闭' + v.project + v.sources + v.type + '的问题' : "" title = v.project + v.sources + ',诊断为' + v.type
return ( } else if (v.seed == 'confirm') {
<Timeline.Item key={index + 'time'} position='left' time={moment(v.time).format("YYYY-MM-DD HH:mm:ss")} className={index % 2 == 0 ? 'even' : 'odd'} > title = v.userName + '确认并关闭' + v.project + v.sources + v.type + '的问题'
<Tooltip content={title}> } else {
<div className='Tooltip' style={{ title = '【信鸽-' + v.alarmPushConfig + '】已邮件通知' +
width: 170, v.userName?.map((u, i) => (i > 0 ? ',' + u : u)) + '【' + v.project + '】【' +
height: '', (v.tactics == 'immediately' ?
display: '-webkit-box', '发现在' + v.interval + '分钟内,有告警源新增' :
overflow: 'hidden', (v.tactics == 'continue' ? '告警源持续产生时间超过' + v.interval + '分钟' : '异常设备数量达到项目或结构物内设备总数量的' +
textOverflow: 'ellipsis', v.deviceProportion + '%,且持续时长超过' + v.interval + '小时' + '】-【' + v.time + '】'))
color: '', }
background: '', return (
}}> <Timeline.Item key={index + 'time'} position='left' time={moment(v.time).format("YYYY-MM-DD HH:mm:ss")} className={index % 2 == 0 ? 'even' : 'odd'} >
{title} <Tooltip content={title}>
</div> <div className='Tooltip' style={{
</Tooltip> width: 170,
</Timeline.Item> height: '',
) display: '-webkit-box',
})} overflow: 'hidden',
</Timeline> textOverflow: 'ellipsis',
color: '',
background: '',
}}>
{title}
</div>
</Tooltip>
</Timeline.Item>
)
})}
</Timeline>
</div>
</div> </div>
</div> </div>
{/* 我常用的工具 */} {/* 我常用的工具 */}

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

@ -138,8 +138,8 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
}, [query, search, pepProjectId]) }, [query, search, pepProjectId])
console.log(exhibition); // console.log(exhibition);
console.log(tableData); // console.log(tableData);
return ( return (
<> <>

42
web/client/src/sections/service/components/pushModal.jsx

@ -123,6 +123,11 @@ function pushModal (props) {
delete obj.interval2 delete obj.interval2
delete obj.interval3 delete obj.interval3
delete obj.deviceProportion delete obj.deviceProportion
dispatch(service.postPush({ pushId: editObj.id, ...obj, msg: '编辑推送配置' })).then((res) => {//(PEP)
if (res.success) {
close();
}
})
} else { } else {
Notification.error({ Notification.error({
content: '即时推送时间不能大于1440分钟', content: '即时推送时间不能大于1440分钟',
@ -153,6 +158,11 @@ function pushModal (props) {
delete obj.interval2 delete obj.interval2
delete obj.interval3 delete obj.interval3
delete obj.deviceProportion delete obj.deviceProportion
dispatch(service.postPush({ pushId: editObj.id, ...obj, msg: '编辑推送配置' })).then((res) => {//(PEP)
if (res.success) {
close();
}
})
} else { } else {
Notification.error({ Notification.error({
content: '持续时长推送时间不能大于1440分钟', content: '持续时长推送时间不能大于1440分钟',
@ -183,6 +193,11 @@ function pushModal (props) {
delete obj.interval2 delete obj.interval2
delete obj.interval3 delete obj.interval3
delete obj.deviceProportion delete obj.deviceProportion
dispatch(service.postPush({ pushId: editObj.id, ...obj, msg: '编辑推送配置' })).then((res) => {//(PEP)
if (res.success) {
close();
}
})
} else if (obj.interval3 <= 720 && obj.deviceProportion > 100) { } else if (obj.interval3 <= 720 && obj.deviceProportion > 100) {
Notification.error({ Notification.error({
content: '异常率推送异常率不能超过100%', content: '异常率推送异常率不能超过100%',
@ -224,11 +239,6 @@ function pushModal (props) {
}) })
} }
} }
dispatch(service.postPush({ pushId: editObj.id, ...obj, msg: '编辑推送配置' })).then((res) => {//(PEP)
if (res.success) {
close();
}
})
} }
else { else {
let obj = JSON.parse(JSON.stringify(values)) let obj = JSON.parse(JSON.stringify(values))
@ -247,6 +257,11 @@ function pushModal (props) {
delete obj.interval2 delete obj.interval2
delete obj.interval3 delete obj.interval3
delete obj.deviceProportion delete obj.deviceProportion
dispatch(service.postPush({ ...obj, msg: '新增推送配置' })).then((res) => {//(PEP)
if (res.success) {
close();
}
})
} else { } else {
Notification.error({ Notification.error({
content: '即时推送时间不能大于1440分钟', content: '即时推送时间不能大于1440分钟',
@ -277,6 +292,11 @@ function pushModal (props) {
delete obj.interval2 delete obj.interval2
delete obj.interval3 delete obj.interval3
delete obj.deviceProportion delete obj.deviceProportion
dispatch(service.postPush({ ...obj, msg: '新增推送配置' })).then((res) => {//(PEP)
if (res.success) {
close();
}
})
} else { } else {
Notification.error({ Notification.error({
content: '持续时长推送时间不能大于1440分钟', content: '持续时长推送时间不能大于1440分钟',
@ -307,6 +327,11 @@ function pushModal (props) {
delete obj.interval2 delete obj.interval2
delete obj.interval3 delete obj.interval3
delete obj.deviceProportion delete obj.deviceProportion
dispatch(service.postPush({ ...obj, msg: '新增推送配置' })).then((res) => {//(PEP)
if (res.success) {
close();
}
})
} else if (obj.interval3 <= 720 && obj.deviceProportion > 100) { } else if (obj.interval3 <= 720 && obj.deviceProportion > 100) {
Notification.error({ Notification.error({
content: '异常率推送异常率不能超过100%', content: '异常率推送异常率不能超过100%',
@ -348,11 +373,6 @@ function pushModal (props) {
}) })
} }
} }
dispatch(service.postPush({ ...obj, msg: '新增推送配置' })).then((res) => {//(PEP)
if (res.success) {
close();
}
})
} }
}) })
} }
@ -414,6 +434,8 @@ function pushModal (props) {
<Form.Input <Form.Input
field="name" field="name"
label='策略名称:' label='策略名称:'
maxLength={15}
disabled={pushEdit}
style={{ width: 695 }} style={{ width: 695 }}
initValue={editObj?.name || ""} initValue={editObj?.name || ""}
placeholder="请输入策略名称" placeholder="请输入策略名称"

22
web/client/src/sections/service/containers/emPush.jsx

@ -182,14 +182,17 @@ const EmPush = (props) => {
] ]
function expandRowRender (record, index) { function expandRowRender (record, index) {
return ( return (
<div style={{ display: 'flex' }}> <div style={{}}>
结构物 结构物
{ {
record.structure?.map((item, index) => { record.structure?.map((item, index) => {
return ( return (
<div key={index} style={{ marginRight: 5, padding: '1px 17px', color: '#0F7EFB', background: 'rgba(221,237,255,0.38)' }}> <span key={index} style={{
marginRight: 5, padding: '1px 17px', color: '#0F7EFB',
display: 'inline-block', marginBottom: 5
}}>
{item.name} {item.name}
</div> </span>
) )
}) })
} }
@ -558,20 +561,17 @@ const EmPush = (props) => {
placeholder="请输入或选择关键词" placeholder="请输入或选择关键词"
/> />
<Form.Select <Form.Select
label='推送类型:' label='推送机制:'
labelPosition="left" labelPosition="left"
field='alarmType' field='tactics'
style={{ width: 116, marginRight: 10, color: "#F9F9F9", }} style={{ width: 116, marginRight: 10, color: "#F9F9F9", }}
placeholder="全部" placeholder="全部"
filter filter
showClear showClear
> >
<Form.Select.Option value="data_outages">数据中断</Form.Select.Option> <Form.Select.Option value="immediately">即时推送机制</Form.Select.Option>
<Form.Select.Option value="data_exception">数据异常</Form.Select.Option> <Form.Select.Option value="continue">持续时长推送机制</Form.Select.Option>
<Form.Select.Option value="strategy_hit">策略命中</Form.Select.Option> <Form.Select.Option value="abnormal_rate">异常率推送机制</Form.Select.Option>
<Form.Select.Option value="video_exception">视频异常</Form.Select.Option>
<Form.Select.Option value="app_exception">应用异常</Form.Select.Option>
<Form.Select.Option value="device_exception">设备异常</Form.Select.Option>
</Form.Select> </Form.Select>
<Form.Select <Form.Select
label='启用状态:' label='启用状态:'

Loading…
Cancel
Save