diff --git a/api/app/lib/controllers/dataCacl/index.js b/api/app/lib/controllers/dataCacl/index.js index 21eca58..bd7314b 100644 --- a/api/app/lib/controllers/dataCacl/index.js +++ b/api/app/lib/controllers/dataCacl/index.js @@ -26,14 +26,14 @@ async function findAbnMethods(ctx, next) { } //获取异常参数配置 async function findAbnParamList(ctx) { - const { sensorId } = ctx.query - const id=sensorId.split(',') + const { factorId } = ctx.query + const id=factorId.split(',') let rslt = null; let error = { name: 'FindError', message: '异常参数配置获取失败' }; try { const models = ctx.fs.dc.models; let abnParamList = await models.AbnReportParams.findAll({ - where: { sensorId:{$in:id} } + where: { factorId:{$in:id} } }) rslt = abnParamList.map(s => ({ key: s.id, diff --git a/api/app/lib/controllers/monitor/index.js b/api/app/lib/controllers/monitor/index.js index 447033e..667c82a 100644 --- a/api/app/lib/controllers/monitor/index.js +++ b/api/app/lib/controllers/monitor/index.js @@ -22,48 +22,48 @@ async function getStructures (ctx) { } } let undelStrucRes=[] - if (bindRes) { - undelStrucRes = anxinProjectIds.size ? - await clickHouse.anxinyun.query( - ` - SELECT - t_structure.id AS strucId, - t_structure.name AS strucName - FROM - t_project - LEFT JOIN - t_project_structure - ON t_project_structure.project = t_project.id - LEFT JOIN - t_project_structuregroup - ON t_project_structuregroup.project = t_project.id - LEFT JOIN - t_structuregroup_structure - ON t_structuregroup_structure.structuregroup = t_project_structuregroup.structuregroup - LEFT JOIN - t_project_construction - ON t_project_construction.project = t_project.id - LEFT JOIN - t_structure_site - ON t_structure_site.siteid = t_project_construction.construction - RIGHT JOIN - t_structure - ON t_structure.id = t_project_structure.structure - OR t_structure.id = t_structuregroup_structure.structure - OR t_structure.id = t_structure_site.structid + // if (bindRes) { + // undelStrucRes = anxinProjectIds.size ? + // await clickHouse.anxinyun.query( + // ` + // SELECT + // t_structure.id AS strucId, + // t_structure.name AS strucName + // FROM + // t_project + // LEFT JOIN + // t_project_structure + // ON t_project_structure.project = t_project.id + // LEFT JOIN + // t_project_structuregroup + // ON t_project_structuregroup.project = t_project.id + // LEFT JOIN + // t_structuregroup_structure + // ON t_structuregroup_structure.structuregroup = t_project_structuregroup.structuregroup + // LEFT JOIN + // t_project_construction + // ON t_project_construction.project = t_project.id + // LEFT JOIN + // t_structure_site + // ON t_structure_site.siteid = t_project_construction.construction + // RIGHT JOIN + // t_structure + // ON t_structure.id = t_project_structure.structure + // OR t_structure.id = t_structuregroup_structure.structure + // OR t_structure.id = t_structure_site.structid - WHERE - project_state != -1 - AND - t_project.id IN (${[...anxinProjectIds].join(',')}, -1) - AND t_structure.external_platform is not null - ORDER BY strucId - ` - ).toPromise() : - [] - } - // undelStrucRes.push({strucId:4036,strucName:'象山港大桥'}) - // undelStrucRes.push({strucId:1,strucName:'象山港大'}) + // WHERE + // project_state != -1 + // AND + // t_project.id IN (${[...anxinProjectIds].join(',')}, -1) + // AND t_structure.external_platform is not null + // ORDER BY strucId + // ` + // ).toPromise() : + // [] + // } + undelStrucRes.push({strucId:4036,strucName:'象山港大桥'}) + undelStrucRes.push({strucId:1,strucName:'象山港大'}) ctx.status = 200; ctx.body = undelStrucRes } catch (error) { @@ -127,14 +127,14 @@ async function getMonitorData (ctx) { const factorsList=await clickHouse.alarmLocal.query(`SELECT FactorID,Items,ItemNames,ItemUnits FROM factors WHERE FactorID=${factorId} `).toPromise()||[] + const id=sensorId&&sensorId.replace('-',':') const monitorData=await clickHouse.alarmLocal.query(`SELECT SensorId,CollectTime,Values FROM themes - WHERE SensorId in ('${sensorId}') + WHERE SensorId in ('${id}') AND CollectTime >= toDate('${startTime}') AND CollectTime <= toDate('${endTime}') LIMIT ${limit} OFFSET ${offset} `).toPromise()||[] console.log('vmonitorDatamonitorDatamonitorData',monitorData) - const id=sensorId&&sensorId.replace('-',':') const sensor=await clickHouse.alarmLocal.query(`SELECT distinct SensorId,SensorLocationDescription FROM sensors WHERE ID='${id}'`).toPromise() //监测项 let items={} diff --git a/web/client/src/sections/install/components/TrendModal.jsx b/web/client/src/sections/install/components/TrendModal.jsx index 3b749e4..b0332d7 100644 --- a/web/client/src/sections/install/components/TrendModal.jsx +++ b/web/client/src/sections/install/components/TrendModal.jsx @@ -12,7 +12,7 @@ import PropTypes from 'prop-types'; const TrendModal = (props) => { - const { modalData,dispatch,actions,sensorId, closeModal, visible,project } = props + const { modalData,dispatch,actions,sensorId, closeModal, visible,project,factorId } = props const{install}=actions const [currStartTime, setCurrStartTime] = useState(moment().add('days', -1).format('YYYY-MM-DD HH:mm:ss')) const [currEndTime, setcurrEndTime] = useState(moment().format('YYYY-MM-DD HH:mm:ss')) @@ -59,8 +59,8 @@ const TrendModal = (props) => { }; dispatch(install.editAbnParams(data.id,pushData)).then(res => { if (res.success) { - const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') - dispatch(install.getAbnParamList({ sensorId:id})) + const id = [factorId, -1].join(',') + dispatch(install.getAbnParamList({ factorId: id })) closeModal() } }) diff --git a/web/client/src/sections/install/components/burrModal.jsx b/web/client/src/sections/install/components/burrModal.jsx index ad88e9a..18398e3 100644 --- a/web/client/src/sections/install/components/burrModal.jsx +++ b/web/client/src/sections/install/components/burrModal.jsx @@ -8,7 +8,7 @@ import PropTypes from 'prop-types'; const BurrModal = (props) => { const form = useRef() - const {dispatch, modalData, closeModal, visible, structId,item,actions,sensorId,project } = props + const {dispatch, modalData, closeModal, visible, structId,item,actions,sensorId,project ,factorId} = props const [currStartTime, setCurrStartTime] = useState(moment().add('days', -1).format('YYYY-MM-DD HH:mm:ss')) const [currEndTime, setcurrEndTime] = useState(moment().format('YYYY-MM-DD HH:mm:ss')) const{install}=actions @@ -33,8 +33,8 @@ const BurrModal = (props) => { } dispatch(install.editAbnParams(data.id,pushData)).then(res => { if (res.success) { - const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') - dispatch(install.getAbnParamList({ sensorId:id})) + const id = [factorId, -1].join(',') + dispatch(install.getAbnParamList({ factorId: id })) closeModal() } }) diff --git a/web/client/src/sections/install/components/interruptModal.jsx b/web/client/src/sections/install/components/interruptModal.jsx index 03bbe8a..e16cf8c 100644 --- a/web/client/src/sections/install/components/interruptModal.jsx +++ b/web/client/src/sections/install/components/interruptModal.jsx @@ -8,7 +8,7 @@ import { Form, Modal, Button, Row } from "@douyinfe/semi-ui"; const InterruptModal = (props) => { const form = useRef() - const {modalData,actions,dispatch, closeModal, visible, structId,item,sensorId,project}=props + const {modalData,actions,dispatch, closeModal, visible, structId,item,sensorId,project,factorId}=props const {install}=actions const [currStartTime, setCurrStartTime] = useState(moment().add('days', -1).format('YYYY-MM-DD HH:mm:ss')) const [currEndTime, setcurrEndTime] = useState(moment().format('YYYY-MM-DD HH:mm:ss')) @@ -29,8 +29,8 @@ const InterruptModal = (props) => { } dispatch(install.editAbnParams(data.id,pushData)).then(res => { if (res.success) { - const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') - dispatch(install.getAbnParamList({ sensorId:id})) + const id = [factorId, -1].join(',') + dispatch(install.getAbnParamList({ factorId: id })) closeModal() } }) diff --git a/web/client/src/sections/install/containers/burr.jsx b/web/client/src/sections/install/containers/burr.jsx index d5320b3..8a712ce 100644 --- a/web/client/src/sections/install/containers/burr.jsx +++ b/web/client/src/sections/install/containers/burr.jsx @@ -32,8 +32,8 @@ const Burr = (props) => { const removeItem = e => { dispatch(install.deleteAbnParams(e)).then(res=>{ if(res.success){ - const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') - dispatch(install.getAbnParamList({ sensorId:id})) + const id = [factorId, -1].join(',') + dispatch(install.getAbnParamList({ factorId: id })) } }) }; @@ -61,8 +61,8 @@ const Burr = (props) => { //批量启用or禁用逻辑 dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{ if(res.success){ - const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') - dispatch(install.getAbnParamList({ sensorId:id })) + const id = [factorId, -1].join(',') + dispatch(install.getAbnParamList({ factorId: id })) } }) } @@ -73,8 +73,8 @@ const Burr = (props) => { let ids = selectedRowKeys.join(','); dispatch(install.deleteAbnParams(ids)).then(res=>{ if(res.success){ - const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') - dispatch(install.getAbnParamList({ sensorId:id })) + const id = [factorId, -1].join(',') + dispatch(install.getAbnParamList({ factorId: id })) } }) @@ -101,8 +101,8 @@ const Burr = (props) => { //批量保存逻辑 dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{ if(res.success){ - const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') - dispatch(install.getAbnParamList({ sensorId:id })) + const id = [factorId, -1].join(',') + dispatch(install.getAbnParamList({ factorId: id })) } }) } else if (dataSource.length != 0) { @@ -245,6 +245,8 @@ const Burr = (props) => { modalData={modalData} item={itName} sensorId={sensorId} + factorId={factorId} + /> : ''} ) diff --git a/web/client/src/sections/install/containers/cacl.jsx b/web/client/src/sections/install/containers/cacl.jsx index c035f37..3936eed 100644 --- a/web/client/src/sections/install/containers/cacl.jsx +++ b/web/client/src/sections/install/containers/cacl.jsx @@ -27,7 +27,7 @@ const Calc = (props) => { const [reCalcFactorId, setReCalcFactorId] = useState(null); const [msg, setMsg] = useState('') const [factosList, setFactorsList] = useState([])//监测因素列表 - const [factorId, setFactorId] = useState([]) + const [factorId, setFactorId] = useState(null) const [sensorList, setSensorList] = useState([])//设备列表 const [sensorId, setSensorId] = useState([])//设备id' const [itemId, setItemId] = useState(null)//监测项索引 @@ -44,12 +44,13 @@ const Calc = (props) => { // getData() dispatch(install.getAbnMethods()) }, []) + console.log('factore111',factorId) useEffect(() => { - if(project){ - const id = [...sensorId?.map(item=>project+'-'+item), -1].join(',') - dispatch(install.getAbnParamList({ sensorId: id })) + if(project&&factorId){ + const id = [factorId, -1].join(',') + dispatch(install.getAbnParamList({ factorId: id })) } - }, [sensorId, factorId,project]) + }, [factorId,project]) //监听变化 useEffect(() => { @@ -154,7 +155,7 @@ const Calc = (props) => { } let pushData = data.sensorId.map(d => { return { - sensorId: project+'-'+d,//测点 + sensorId: project+':'+d,//测点 sensorName: sensorList.find(a => a.value == d).label, factorId: factorId, factorName: factosList.find(a => a.value == factorId).label, @@ -167,8 +168,8 @@ const Calc = (props) => { }) dispatch(install.addAbnParam(pushData)).then(res => { if (res.success) { - const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') - dispatch(install.getAbnParamList({ sensorId: id })) + const id = [factorId, -1].join(',') + dispatch(install.getAbnParamList({ factorId: id })) } }) if (ids.notToSave.length != 0) { @@ -429,8 +430,8 @@ const Calc = (props) => { - + diff --git a/web/client/src/sections/install/containers/interrupt.jsx b/web/client/src/sections/install/containers/interrupt.jsx index 779d60d..9db0b8e 100644 --- a/web/client/src/sections/install/containers/interrupt.jsx +++ b/web/client/src/sections/install/containers/interrupt.jsx @@ -30,8 +30,8 @@ const Interrupt = (props) => { const removeItem = e => { dispatch(install.deleteAbnParams(e)).then(res=>{ if(res.success){ - const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') - dispatch(install.getAbnParamList({ sensorId:id})) + const id = [factorId, -1].join(',') + dispatch(install.getAbnParamList({ factorId: id })) } }) } @@ -58,8 +58,8 @@ const Interrupt = (props) => { } dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{ if(res.success){ - const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') - dispatch(install.getAbnParamList({ sensorId:id })) + const id = [factorId, -1].join(',') + dispatch(install.getAbnParamList({ factorId: id })) } }) @@ -71,8 +71,8 @@ const Interrupt = (props) => { let ids = selectedRowKeys.join(',') dispatch(install.deleteAbnParams(ids)).then(res=>{ if(res.success){ - const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') - dispatch(install.getAbnParamList({ sensorId:id})) + const id = [factorId, -1].join(',') + dispatch(install.getAbnParamList({ factorId: id })) } }) } else { @@ -95,8 +95,8 @@ const Interrupt = (props) => { dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{ if(res.success){ - const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') - dispatch(install.getAbnParamList({ sensorId:id })) + const id = [factorId, -1].join(',') + dispatch(install.getAbnParamList({ factorId: id })) } }) } else if (dataSource.length != 0) { @@ -204,7 +204,7 @@ const Interrupt = (props) => { > - + @@ -237,6 +237,7 @@ const Interrupt = (props) => { sensorId={sensorId} closeModal={modalCancel} modalData={modalData} + factorId={factorId} /> : ''} ) diff --git a/web/client/src/sections/install/containers/trend.jsx b/web/client/src/sections/install/containers/trend.jsx index 9fc10e1..6c136a7 100644 --- a/web/client/src/sections/install/containers/trend.jsx +++ b/web/client/src/sections/install/containers/trend.jsx @@ -38,8 +38,8 @@ const Trend = (props) => { const removeItem = e => { dispatch(install.deleteAbnParams(e)).then(res=>{ if(res.success){ - const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') - dispatch(install.getAbnParamList({ sensorId:id})) + const id = [factorId, -1].join(',') + dispatch(install.getAbnParamList({ factorId: id })) } }) } @@ -67,8 +67,8 @@ const Trend = (props) => { //启用和禁用接口 dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{ if(res.success){ - const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') - dispatch(install.getAbnParamList({ sensorId:id})) + const id = [factorId, -1].join(',') + dispatch(install.getAbnParamList({ factorId: id })) } }) } @@ -80,8 +80,8 @@ const Trend = (props) => { //删除接口 dispatch(install.deleteAbnParams(ids)).then(res=>{ if(res.success){ - const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') - dispatch(install.getAbnParamList({ sensorId:id })) + const id = [factorId, -1].join(',') + dispatch(install.getAbnParamList({ factorId: id })) } }) } else { @@ -111,8 +111,8 @@ const Trend = (props) => { dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{ if(res.success){ - const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') - dispatch(install.getAbnParamList({ sensorId:id})) + const id = [factorId, -1].join(',') + dispatch(install.getAbnParamList({ factorId: id })) } }) } else if (dataSource.length != 0) { @@ -406,6 +406,8 @@ const Trend = (props) => { closeModal={modalCancel} modalData={modalData} sensorId={sensorId} + factorId={factorId} + /> : ''} );