diff --git a/api/.vscode/launch.json b/api/.vscode/launch.json index 5e3848a..c428d9e 100644 --- a/api/.vscode/launch.json +++ b/api/.vscode/launch.json @@ -57,7 +57,7 @@ // "--clickHouseIot iot", // 测试 - "--clickHouseAnxincloud anxinyun88", + "--clickHouseAnxincloud anxinyun1", "--clickHousePepEmis pepca8", "--clickHouseProjectManage peppm8", "--clickHouseVcmp video_access_dev", diff --git a/api/app/lib/controllers/project/index.js b/api/app/lib/controllers/project/index.js index 3b47b76..b04763b 100644 --- a/api/app/lib/controllers/project/index.js +++ b/api/app/lib/controllers/project/index.js @@ -284,7 +284,7 @@ async function strucWithPomsProject (ctx) { factor: nextFacor }) } else { - if (s.factorId) { + if (s.factorId && !corStrut.factor.some(v => v.id == s.factorId)) { corStrut.factor.push({ id: s.factorId, name: s.factorName diff --git a/api/app/lib/controllers/push/config.js b/api/app/lib/controllers/push/config.js index 9d11e33..43feb26 100644 --- a/api/app/lib/controllers/push/config.js +++ b/api/app/lib/controllers/push/config.js @@ -165,11 +165,11 @@ async function edit (ctx) { const models = ctx.fs.dc.models; const { userId, pepUserId } = ctx.fs.api const { pushId, name, pomsProjectId, alarmType = [], receiverPepUserId = [], timeType = [], disable, - strucId = [], tactics, tacticsParams, alarmSubType = {} } = ctx.request.body + strucId = [], tactics, tacticsParams, alarmSubType = {}, pomsStrucFactorId = {} } = ctx.request.body let storageData = { name, pomsProjectId, alarmType, receiverPepUserId, timeType, disable, - strucId, tactics, tacticsParams, alarmSubType + strucId, tactics, tacticsParams, alarmSubType, pomsStrucFactorId } let repeatOption = { diff --git a/web/client/src/sections/service/components/pushModal.jsx b/web/client/src/sections/service/components/pushModal.jsx index 464cab6..2754a4b 100644 --- a/web/client/src/sections/service/components/pushModal.jsx +++ b/web/client/src/sections/service/components/pushModal.jsx @@ -1,6 +1,6 @@ import React, { useState, useRef, useEffect } from "react"; import { connect } from "react-redux"; -import { Modal, Form, Notification } from "@douyinfe/semi-ui"; +import { Modal, Form, Notification, Tooltip } from "@douyinfe/semi-ui"; import { IconAlertCircle } from '@douyinfe/semi-icons'; import './pushModal.less' @@ -34,7 +34,7 @@ function pushModal (props) { const [interval3, setInterval3] = useState(undefined); // const [deviceProportion, setDeviceProportion] = useState(undefined); // const [subType, setSubType] = useState([]); //监听模块中的子类 - const [factor, setFactor] = useState([]); //结构物对应监测项 + const [factorShow, setFactorShow] = useState([]); //结构物对应监测项 //初始化 @@ -43,7 +43,7 @@ function pushModal (props) { getOrganizationUsersList()//获取全部未删除用户 getProjectPomsList()//获取已绑定项目 if (editObj.id) { - getProjectStructureList(editObj.pomsProjectId) + getProjectStructureList(editObj.pomsProjectId, editObj) let division = editObj?.pomsProject?.map(v => (v.pepProject?.id || 'POMS')) if (division.length == 1 && division?.includes('POMS')) { setProjectStatus([{ construction_status: 'POMS', id: 'POMS' }]) @@ -75,11 +75,12 @@ function pushModal (props) { } }) } - function getProjectStructureList (value) {//获取绑定项目下结构物 + function getProjectStructureList (value, alter) {//获取绑定项目下结构物 dispatch(service.getProjectStructure({ pomsProjectId: value.join(',') })).then((res) => { if (res.success) { let data = [] let ProjectId = [] + let factorId = [] res.payload?.data.map(v => { if (ProjectId.includes(v.id)) { } else { @@ -87,14 +88,15 @@ function pushModal (props) { data.push(v) } }) - - let mylist = [] - for (let i = 0; i < data.length; i++) { - mylist.push(data[i].id) - } setProjectStructure(data) - // setFactor() - form.current.setValue('strucId', mylist) + let FactorId = [] + for (let key in alter?.pomsStrucFactorId) { + FactorId.push(key) + } + setFactorShow(FactorId?.map(Number)) + if (!editObj.id) { + form.current.setValue('strucId', ProjectId) + } form.current.validate(['strucId', 'timeType']) setStructure(false) setTimeTypeDis(false) @@ -122,7 +124,6 @@ function pushModal (props) { 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, @@ -157,11 +158,14 @@ function pushModal (props) { timeType: v.timeType[0] == 'POMS' ? [] : v.timeType, receiverPepUserId: v.receiverPepUserId || [], disable: v.disable, - alarmSubType: {} + alarmSubType: {}, + pomsStrucFactorId: {} } 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] } + } else if (key.indexOf('factor') == 0) { + data.pomsStrucFactorId = { ...data.pomsStrucFactorId, [key.slice(6)]: v[key] } } } if (caution(data.tactics, data.tacticsParams.interval, data.tacticsParams.deviceProportion)) { @@ -190,10 +194,9 @@ function pushModal (props) { >
{ for (var key in field) { if (key == 'tactics') { @@ -203,8 +206,7 @@ function pushModal (props) { } else { setAbnormal(false) } - } - if (key == 'pomsProjectId') { + } else if (key == 'pomsProjectId') { if (values.pomsProjectId.length > 0) { getProjectStructureList(values.pomsProjectId)//获取绑定项目下结构物 let pepProjectId = [] @@ -228,8 +230,9 @@ function pushModal (props) { form.current.setValue('timeType', []) } - } - if (key == 'alarmType') { + } else if (key == 'strucId') { + setFactorShow(values.strucId) + } else if (key == 'alarmType') { setSubType(field['alarmType']) } } @@ -245,7 +248,7 @@ function pushModal (props) { label='策略名称:' maxLength={15} disabled={pushEdit} - style={{ width: 695 }} + style={{ width: 678 }} initValue={editObj?.name || ""} placeholder="请输入策略名称" showClear @@ -256,7 +259,7 @@ function pushModal (props) { label="请选择项目:" field="pomsProjectId" placeholder="请选择项目" - style={{ width: 695 }} + style={{ width: 678 }} rules={[{ required: true, message: "请选择项目" }]} initValue={editObj?.pomsProjectId || ""} multiple @@ -275,10 +278,13 @@ function pushModal (props) {
请选择结构物 + + + :} field="strucId" placeholder="请选择结构物" - style={{ width: 695 }} + style={{ width: 678 }} rules={[{ required: true, message: "请选择结构物" }]} initValue={editObj?.strucId || []} disabled={structure} @@ -297,6 +303,23 @@ function pushModal (props) { }) } + {projectStructure?.filter(v => (factorShow?.includes(v.id) && v.factor?.length > 0))?.map((u, index) => { + return + { + u.factor?.map((v, index) => + {v.name}) + } + + }) + }