|
|
@ -15,9 +15,10 @@ function pushModal (props) { |
|
|
|
actions, |
|
|
|
pushEdit,//是否是编辑 |
|
|
|
editObj, |
|
|
|
user |
|
|
|
user, |
|
|
|
subTypeData |
|
|
|
} = props; |
|
|
|
const { service } = actions; |
|
|
|
const { service, problem } = actions; |
|
|
|
const form = useRef();//表单 |
|
|
|
const [abnormal, setAbnormal] = useState(false); //异常率推送机制disable |
|
|
|
const [usersList, setUsersList] = useState([]); //获取全部未删除用户 |
|
|
@ -32,20 +33,19 @@ function pushModal (props) { |
|
|
|
const [interval2, setInterval2] = useState(undefined); // |
|
|
|
const [interval3, setInterval3] = useState(undefined); // |
|
|
|
const [deviceProportion, setDeviceProportion] = useState(undefined); // |
|
|
|
|
|
|
|
|
|
|
|
const [subType, setSubType] = useState([]); //监听模块中的子类 |
|
|
|
|
|
|
|
|
|
|
|
//初始化 |
|
|
|
useEffect(() => { |
|
|
|
if (editObj?.alarmType) setSubType(editObj?.alarmType) |
|
|
|
getOrganizationUsersList()//获取全部未删除用户 |
|
|
|
getProjectPomsList()//获取已绑定项目 |
|
|
|
if (editObj.id) { |
|
|
|
getProjectStructureList(editObj.pomsProjectId) |
|
|
|
if (editObj.pomsProject?.pepProjectId) { |
|
|
|
getProjectStatusList()//获取项目状态列表 |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
setProjectStatus([{ construction_status: 'POMS', id: 'POMS' }]) |
|
|
|
timeTypePOMS.current = ['POMS'] |
|
|
|
} |
|
|
@ -58,7 +58,7 @@ function pushModal (props) { |
|
|
|
setDeviceProportion(editObj.tacticsParams?.deviceProportion) |
|
|
|
} |
|
|
|
} |
|
|
|
}, []); |
|
|
|
}, []) |
|
|
|
function getOrganizationUsersList () {//获取全部未删除用户 |
|
|
|
dispatch(service.getOrganizationUsers()).then((res) => { |
|
|
|
if (res.success) { |
|
|
@ -101,278 +101,58 @@ function pushModal (props) { |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
function caution (tactics, interval, deviceProportion) { |
|
|
|
let regu = /^[0-9]*[1-9][0-9]*$/; |
|
|
|
let title = tactics == 'immediately' ? '即时' : tactics == 'continue' ? '持续时长' : '异常率' |
|
|
|
if (!regu.test(interval) || (tactics == 'abnormal_rate' && interval > 720) || interval > 1440) { |
|
|
|
console.log(interval); |
|
|
|
Notification.error({ |
|
|
|
content: title + (interval ? `推送时间不能大于${tactics == 'abnormal_rate' ? 720 : 1440}分钟` : '推送时间应为正整数'), |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
return false |
|
|
|
} |
|
|
|
if (!deviceProportion || deviceProportion > 100) { |
|
|
|
Notification.error({ |
|
|
|
content: '异常率推送异常率应为正整数且不超过100%', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
return false |
|
|
|
} |
|
|
|
return true |
|
|
|
} |
|
|
|
|
|
|
|
function handleOk () { |
|
|
|
//点击弹框确定 右边按钮 |
|
|
|
form.current |
|
|
|
.validate() |
|
|
|
.then((values) => { |
|
|
|
if (pushEdit) { |
|
|
|
let obj = JSON.parse(JSON.stringify(values)) |
|
|
|
if (obj.timeType[0] == 'POMS') { |
|
|
|
obj.timeType = [] |
|
|
|
} |
|
|
|
let regu = /^[0-9]*[1-9][0-9]*$/; |
|
|
|
if (obj.tactics == 'immediately') { |
|
|
|
if (obj.interval1) { |
|
|
|
if (regu.test(obj.interval1)) { |
|
|
|
if (obj.interval1 <= 1440) { |
|
|
|
obj.tacticsParams = { |
|
|
|
interval: obj.interval1 |
|
|
|
} |
|
|
|
delete obj.interval1 |
|
|
|
delete obj.interval2 |
|
|
|
delete obj.interval3 |
|
|
|
delete obj.deviceProportion |
|
|
|
dispatch(service.postPush({ pushId: editObj.id, ...obj, msg: '编辑推送配置' })).then((res) => {//获取项企(PEP)全部部门及其下用户 |
|
|
|
if (res.success) { |
|
|
|
close(); |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
Notification.error({ |
|
|
|
content: '即时推送时间不能大于1440分钟', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
Notification.error({ |
|
|
|
content: '即时推送时间应为正整数', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
Notification.error({ |
|
|
|
content: '即时推送时间应为正整数', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
else if (obj.tactics == 'continue') { |
|
|
|
if (obj.interval2) { |
|
|
|
if (regu.test(obj.interval2)) { |
|
|
|
if (obj.interval2 <= 1440) { |
|
|
|
obj.tacticsParams = { |
|
|
|
interval: obj.interval2 |
|
|
|
} |
|
|
|
delete obj.interval1 |
|
|
|
delete obj.interval2 |
|
|
|
delete obj.interval3 |
|
|
|
delete obj.deviceProportion |
|
|
|
dispatch(service.postPush({ pushId: editObj.id, ...obj, msg: '编辑推送配置' })).then((res) => {//获取项企(PEP)全部部门及其下用户 |
|
|
|
if (res.success) { |
|
|
|
close(); |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
Notification.error({ |
|
|
|
content: '持续时长推送时间不能大于1440分钟', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
Notification.error({ |
|
|
|
content: '持续时长推送时间应为正整数', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
Notification.error({ |
|
|
|
content: '持续时长推送时间应为正整数', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
if (regu.test(obj.interval3) && regu.test(obj.deviceProportion)) { |
|
|
|
if (obj.interval3 <= 720 && obj.deviceProportion <= 100) { |
|
|
|
obj.tacticsParams = { |
|
|
|
interval: obj.interval3, |
|
|
|
deviceProportion: obj.deviceProportion |
|
|
|
} |
|
|
|
delete obj.interval1 |
|
|
|
delete obj.interval2 |
|
|
|
delete obj.interval3 |
|
|
|
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) { |
|
|
|
Notification.error({ |
|
|
|
content: '异常率推送异常率不能超过100%', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} else if (obj.interval3 > 720 && obj.deviceProportion <= 100) { |
|
|
|
Notification.error({ |
|
|
|
content: '异常率推送时间不能超过720小时', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} else { |
|
|
|
Notification.error({ |
|
|
|
content: '异常率推送时间不能超过720小时', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
Notification.error({ |
|
|
|
content: '异常率推送异常率不能超过100%', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} |
|
|
|
} else if (regu.test(obj.interval3) && !regu.test(obj.deviceProportion)) { |
|
|
|
Notification.error({ |
|
|
|
content: '异常率推送异常率应为正整数', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} else if (!regu.test(obj.interval3) && regu.test(obj.deviceProportion)) { |
|
|
|
Notification.error({ |
|
|
|
content: '异常率推送时间应为正整数', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} else { |
|
|
|
Notification.error({ |
|
|
|
content: '异常率推送异常率应为正整数', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
Notification.error({ |
|
|
|
content: '异常率推送时间应为正整数', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
.then((v) => { |
|
|
|
let data = { |
|
|
|
name: v.name, |
|
|
|
pomsProjectId: v.pomsProjectId, |
|
|
|
strucId: v.strucId || [], |
|
|
|
tactics: v.tactics, |
|
|
|
tacticsParams: { |
|
|
|
interval: v.tactics == 'immediately' ? v.interval1 : (v.tactics == 'continue' ? v.interval2 : v.interval3), |
|
|
|
deviceProportion: v.deviceProportion |
|
|
|
}, |
|
|
|
alarmType: v.alarmType, |
|
|
|
timeType: v.timeType[0] == 'POMS' ? [] : v.timeType, |
|
|
|
receiverPepUserId: v.receiverPepUserId || [], |
|
|
|
disable: v.disable, |
|
|
|
alarmSubType: {} |
|
|
|
} |
|
|
|
else { |
|
|
|
let obj = JSON.parse(JSON.stringify(values)) |
|
|
|
if (obj.timeType[0] == 'POMS') { |
|
|
|
obj.timeType = [] |
|
|
|
for (let key in v) { |
|
|
|
if (['app_exception', 'data_exception', 'data_outages', 'device_exception', 'video_exception', 'strategy_hit'].includes(key)) { |
|
|
|
data.alarmSubType = { ...data.alarmSubType, [key]: v[key] } |
|
|
|
} |
|
|
|
let regu = /^[0-9]*[1-9][0-9]*$/; |
|
|
|
if (obj.tactics == 'immediately') { |
|
|
|
if (obj.interval1) { |
|
|
|
if (regu.test(obj.interval1)) { |
|
|
|
if (obj.interval1 <= 1440) { |
|
|
|
obj.tacticsParams = { |
|
|
|
interval: obj.interval1 |
|
|
|
} |
|
|
|
delete obj.interval1 |
|
|
|
delete obj.interval2 |
|
|
|
delete obj.interval3 |
|
|
|
delete obj.deviceProportion |
|
|
|
dispatch(service.postPush({ ...obj, msg: '新增推送配置' })).then((res) => {//获取项企(PEP)全部部门及其下用户 |
|
|
|
if (res.success) { |
|
|
|
close(); |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
Notification.error({ |
|
|
|
content: '即时推送时间不能大于1440分钟', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
Notification.error({ |
|
|
|
content: '即时推送时间应为正整数', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
Notification.error({ |
|
|
|
content: '即时推送时间应为正整数', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
else if (obj.tactics == 'continue') { |
|
|
|
if (obj.interval2) { |
|
|
|
if (regu.test(obj.interval2)) { |
|
|
|
if (obj.interval2 <= 1440) { |
|
|
|
obj.tacticsParams = { |
|
|
|
interval: obj.interval2 |
|
|
|
} |
|
|
|
delete obj.interval1 |
|
|
|
delete obj.interval2 |
|
|
|
delete obj.interval3 |
|
|
|
delete obj.deviceProportion |
|
|
|
dispatch(service.postPush({ ...obj, msg: '新增推送配置' })).then((res) => {//获取项企(PEP)全部部门及其下用户 |
|
|
|
if (res.success) { |
|
|
|
close(); |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
Notification.error({ |
|
|
|
content: '持续时长推送时间不能大于1440分钟', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
Notification.error({ |
|
|
|
content: '持续时长推送时间应为正整数', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
Notification.error({ |
|
|
|
content: '持续时长推送时间应为正整数', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
if (regu.test(obj.interval3) && regu.test(obj.deviceProportion)) { |
|
|
|
if (obj.interval3 <= 720 && obj.deviceProportion <= 100) { |
|
|
|
obj.tacticsParams = { |
|
|
|
interval: obj.interval3, |
|
|
|
deviceProportion: obj.deviceProportion |
|
|
|
} |
|
|
|
delete obj.interval1 |
|
|
|
delete obj.interval2 |
|
|
|
delete obj.interval3 |
|
|
|
delete obj.deviceProportion |
|
|
|
dispatch(service.postPush({ ...obj, msg: '新增推送配置' })).then((res) => {//获取项企(PEP)全部部门及其下用户 |
|
|
|
if (res.success) { |
|
|
|
close(); |
|
|
|
} |
|
|
|
}) |
|
|
|
} else if (obj.interval3 <= 720 && obj.deviceProportion > 100) { |
|
|
|
Notification.error({ |
|
|
|
content: '异常率推送异常率不能超过100%', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} else if (obj.interval3 > 720 && obj.deviceProportion <= 100) { |
|
|
|
Notification.error({ |
|
|
|
content: '异常率推送时间不能超过720小时', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} else { |
|
|
|
Notification.error({ |
|
|
|
content: '异常率推送时间不能超过720小时', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
Notification.error({ |
|
|
|
content: '异常率推送异常率不能超过100%', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} |
|
|
|
} else if (regu.test(obj.interval3) && !regu.test(obj.deviceProportion)) { |
|
|
|
Notification.error({ |
|
|
|
content: '异常率推送异常率应为正整数', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} else if (!regu.test(obj.interval3) && regu.test(obj.deviceProportion)) { |
|
|
|
Notification.error({ |
|
|
|
content: '异常率推送时间应为正整数', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} else { |
|
|
|
Notification.error({ |
|
|
|
content: '异常率推送异常率应为正整数', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
Notification.error({ |
|
|
|
content: '异常率推送时间应为正整数', |
|
|
|
duration: 2, |
|
|
|
}) |
|
|
|
} |
|
|
|
if (caution(data.tactics, data.tacticsParams.interval, data.tacticsParams.deviceProportion)) { |
|
|
|
dispatch(service.postPush({ pushId: editObj.id, ...data, msg: pushEdit ? '编辑推送配置' : "新增推送策略" })).then((res) => {//获取项企(PEP)全部部门及其下用户 |
|
|
|
if (res.success) { |
|
|
|
close(); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
@ -403,8 +183,7 @@ function pushModal (props) { |
|
|
|
if (values.tactics == 'abnormal_rate') { |
|
|
|
form.current.setValue('alarmType', undefined) |
|
|
|
setAbnormal(true) |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
setAbnormal(false) |
|
|
|
} |
|
|
|
} |
|
|
@ -423,6 +202,9 @@ function pushModal (props) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (key == 'alarmType') { |
|
|
|
setSubType(field['alarmType']) |
|
|
|
} |
|
|
|
} |
|
|
|
}} |
|
|
|
getFormApi={(formApi) => (form.current = formApi)} |
|
|
@ -496,9 +278,10 @@ function pushModal (props) { |
|
|
|
direction='horizontal' |
|
|
|
initValue={editObj?.tactics || ''} |
|
|
|
rules={[{ required: true, message: '请选择推送策略' }]}> |
|
|
|
<div style={{display: 'flex',alignItems: 'flex-start'}}> |
|
|
|
<div style={{ display: 'flex', alignItems: 'flex-start' }}> |
|
|
|
<Form.Radio |
|
|
|
value='immediately' |
|
|
|
|
|
|
|
extra={ |
|
|
|
<span style={{ fontSize: 13 }}> |
|
|
|
中台每分钟查询,若有告警源新增,则每 |
|
|
@ -512,7 +295,7 @@ function pushModal (props) { |
|
|
|
分钟通过【信鸽服务】发送一条通知信息。 |
|
|
|
</span> |
|
|
|
} |
|
|
|
style={{ width: 198 }}> |
|
|
|
style={{ width: 217 }}> |
|
|
|
即时推送机制 |
|
|
|
</Form.Radio> |
|
|
|
<Form.Radio |
|
|
@ -573,13 +356,45 @@ function pushModal (props) { |
|
|
|
direction='horizontal' |
|
|
|
showClear |
|
|
|
> |
|
|
|
<Form.Checkbox value="data_outages">数据中断</Form.Checkbox> |
|
|
|
<Form.Checkbox value="data_exception">数据异常</Form.Checkbox> |
|
|
|
<Form.Checkbox value="strategy_hit" disabled={abnormal}>策略命中</Form.Checkbox> |
|
|
|
<Form.Checkbox value="video_exception">视频异常</Form.Checkbox> |
|
|
|
<Form.Checkbox value="app_exception" disabled={abnormal}>应用异常</Form.Checkbox> |
|
|
|
<Form.Checkbox value="device_exception">设备异常</Form.Checkbox> |
|
|
|
{ |
|
|
|
[ |
|
|
|
{ name: '数据中断', value: "data_outages" }, |
|
|
|
{ name: '数据异常', value: "data_exception" }, |
|
|
|
{ name: '策略命中', value: "strategy_hit" }, |
|
|
|
{ name: '视频异常', value: "video_exception" }, |
|
|
|
{ name: '应用异常', value: "app_exception" }, |
|
|
|
{ name: '设备异常', value: "device_exception" }, |
|
|
|
].map((v, index) => |
|
|
|
<Form.Checkbox value={v.value} |
|
|
|
key={v.value} |
|
|
|
disabled={index == 2 || index == 4 ? abnormal : false}> |
|
|
|
{v.name}</Form.Checkbox>) |
|
|
|
} |
|
|
|
</Form.CheckboxGroup> |
|
|
|
{[ |
|
|
|
{ name: '数据中断', value: "data_outages", data: subTypeData['data_outages'][0] }, |
|
|
|
{ name: '数据异常', value: "data_exception", data: subTypeData['data_exception'][0] }, |
|
|
|
{ name: '策略命中', value: "strategy_hit", data: subTypeData['strategy_hit'][0] }, |
|
|
|
{ name: '视频异常', value: "video_exception", data: subTypeData['video_exception'][0]?.map(v => ({ id: v.id, name: v.kind })) }, |
|
|
|
{ name: '应用异常', value: "app_exception", data: subTypeData['app_exception'][0] }, |
|
|
|
{ name: '设备异常', value: "device_exception", data: [...subTypeData['device_exception'][0], ...subTypeData['device_exception'][1]] }, |
|
|
|
].filter(v => subType?.includes(v.value))?.map((u, index) => { |
|
|
|
return <Form.CheckboxGroup |
|
|
|
label={u.name + ':'} |
|
|
|
key={u.name + u.index} |
|
|
|
field={u.value} |
|
|
|
style={{ width: 695 }} |
|
|
|
initValue={(editObj?.id && (editObj?.alarmSubType && editObj?.alarmSubType[u.value]) || u.data.map(v => v.id)) || []} |
|
|
|
direction='horizontal' |
|
|
|
showClear |
|
|
|
> |
|
|
|
{ |
|
|
|
u.data?.map((v, index) => |
|
|
|
<Form.Checkbox value={v.id} key={v.id} style={{ width: 150 }}>{v.name}</Form.Checkbox>) |
|
|
|
} |
|
|
|
</Form.CheckboxGroup> |
|
|
|
}) |
|
|
|
} |
|
|
|
</div> |
|
|
|
<div style={{ color: '#4A4A4A', fontSize: 14, fontWeight: 600, marginLeft: 6 }}> |
|
|
|
接收信息配置 |
|
|
|