Browse Source

feat:fix bugs

dev
zhaobing’ 1 year ago
parent
commit
d3529f0205
  1. 6
      api/app/lib/controllers/dataCacl/index.js
  2. 86
      api/app/lib/controllers/monitor/index.js
  3. 6
      web/client/src/sections/install/components/TrendModal.jsx
  4. 6
      web/client/src/sections/install/components/burrModal.jsx
  5. 6
      web/client/src/sections/install/components/interruptModal.jsx
  6. 18
      web/client/src/sections/install/containers/burr.jsx
  7. 21
      web/client/src/sections/install/containers/cacl.jsx
  8. 19
      web/client/src/sections/install/containers/interrupt.jsx
  9. 18
      web/client/src/sections/install/containers/trend.jsx

6
api/app/lib/controllers/dataCacl/index.js

@ -26,14 +26,14 @@ async function findAbnMethods(ctx, next) {
} }
//获取异常参数配置 //获取异常参数配置
async function findAbnParamList(ctx) { async function findAbnParamList(ctx) {
const { sensorId } = ctx.query const { factorId } = ctx.query
const id=sensorId.split(',') const id=factorId.split(',')
let rslt = null; let rslt = null;
let error = { name: 'FindError', message: '异常参数配置获取失败' }; let error = { name: 'FindError', message: '异常参数配置获取失败' };
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
let abnParamList = await models.AbnReportParams.findAll({ let abnParamList = await models.AbnReportParams.findAll({
where: { sensorId:{$in:id} } where: { factorId:{$in:id} }
}) })
rslt = abnParamList.map(s => ({ rslt = abnParamList.map(s => ({
key: s.id, key: s.id,

86
api/app/lib/controllers/monitor/index.js

@ -22,48 +22,48 @@ async function getStructures (ctx) {
} }
} }
let undelStrucRes=[] let undelStrucRes=[]
if (bindRes) { // if (bindRes) {
undelStrucRes = anxinProjectIds.size ? // undelStrucRes = anxinProjectIds.size ?
await clickHouse.anxinyun.query( // await clickHouse.anxinyun.query(
` // `
SELECT // SELECT
t_structure.id AS strucId, // t_structure.id AS strucId,
t_structure.name AS strucName // t_structure.name AS strucName
FROM // FROM
t_project // t_project
LEFT JOIN // LEFT JOIN
t_project_structure // t_project_structure
ON t_project_structure.project = t_project.id // ON t_project_structure.project = t_project.id
LEFT JOIN // LEFT JOIN
t_project_structuregroup // t_project_structuregroup
ON t_project_structuregroup.project = t_project.id // ON t_project_structuregroup.project = t_project.id
LEFT JOIN // LEFT JOIN
t_structuregroup_structure // t_structuregroup_structure
ON t_structuregroup_structure.structuregroup = t_project_structuregroup.structuregroup // ON t_structuregroup_structure.structuregroup = t_project_structuregroup.structuregroup
LEFT JOIN // LEFT JOIN
t_project_construction // t_project_construction
ON t_project_construction.project = t_project.id // ON t_project_construction.project = t_project.id
LEFT JOIN // LEFT JOIN
t_structure_site // t_structure_site
ON t_structure_site.siteid = t_project_construction.construction // ON t_structure_site.siteid = t_project_construction.construction
RIGHT JOIN // RIGHT JOIN
t_structure // t_structure
ON t_structure.id = t_project_structure.structure // ON t_structure.id = t_project_structure.structure
OR t_structure.id = t_structuregroup_structure.structure // OR t_structure.id = t_structuregroup_structure.structure
OR t_structure.id = t_structure_site.structid // OR t_structure.id = t_structure_site.structid
WHERE // WHERE
project_state != -1 // project_state != -1
AND // AND
t_project.id IN (${[...anxinProjectIds].join(',')}, -1) // t_project.id IN (${[...anxinProjectIds].join(',')}, -1)
AND t_structure.external_platform is not null // AND t_structure.external_platform is not null
ORDER BY strucId // ORDER BY strucId
` // `
).toPromise() : // ).toPromise() :
[] // []
} // }
// undelStrucRes.push({strucId:4036,strucName:'象山港大桥'}) undelStrucRes.push({strucId:4036,strucName:'象山港大桥'})
// undelStrucRes.push({strucId:1,strucName:'象山港大'}) undelStrucRes.push({strucId:1,strucName:'象山港大'})
ctx.status = 200; ctx.status = 200;
ctx.body = undelStrucRes ctx.body = undelStrucRes
} catch (error) { } catch (error) {
@ -127,14 +127,14 @@ async function getMonitorData (ctx) {
const factorsList=await clickHouse.alarmLocal.query(`SELECT FactorID,Items,ItemNames,ItemUnits FROM factors const factorsList=await clickHouse.alarmLocal.query(`SELECT FactorID,Items,ItemNames,ItemUnits FROM factors
WHERE FactorID=${factorId} WHERE FactorID=${factorId}
`).toPromise()||[] `).toPromise()||[]
const id=sensorId&&sensorId.replace('-',':')
const monitorData=await clickHouse.alarmLocal.query(`SELECT SensorId,CollectTime,Values FROM themes 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('${startTime}')
AND CollectTime <= toDate('${endTime}') AND CollectTime <= toDate('${endTime}')
LIMIT ${limit} OFFSET ${offset} LIMIT ${limit} OFFSET ${offset}
`).toPromise()||[] `).toPromise()||[]
console.log('vmonitorDatamonitorDatamonitorData',monitorData) 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() const sensor=await clickHouse.alarmLocal.query(`SELECT distinct SensorId,SensorLocationDescription FROM sensors WHERE ID='${id}'`).toPromise()
//监测项 //监测项
let items={} let items={}

6
web/client/src/sections/install/components/TrendModal.jsx

@ -12,7 +12,7 @@ import PropTypes from 'prop-types';
const TrendModal = (props) => { 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{install}=actions
const [currStartTime, setCurrStartTime] = useState(moment().add('days', -1).format('YYYY-MM-DD HH:mm:ss')) 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 [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 => { dispatch(install.editAbnParams(data.id,pushData)).then(res => {
if (res.success) { if (res.success) {
const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') const id = [factorId, -1].join(',')
dispatch(install.getAbnParamList({ sensorId:id})) dispatch(install.getAbnParamList({ factorId: id }))
closeModal() closeModal()
} }
}) })

6
web/client/src/sections/install/components/burrModal.jsx

@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
const BurrModal = (props) => { const BurrModal = (props) => {
const form = useRef() 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 [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 [currEndTime, setcurrEndTime] = useState(moment().format('YYYY-MM-DD HH:mm:ss'))
const{install}=actions const{install}=actions
@ -33,8 +33,8 @@ const BurrModal = (props) => {
} }
dispatch(install.editAbnParams(data.id,pushData)).then(res => { dispatch(install.editAbnParams(data.id,pushData)).then(res => {
if (res.success) { if (res.success) {
const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') const id = [factorId, -1].join(',')
dispatch(install.getAbnParamList({ sensorId:id})) dispatch(install.getAbnParamList({ factorId: id }))
closeModal() closeModal()
} }
}) })

6
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 InterruptModal = (props) => {
const form = useRef() 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 {install}=actions
const [currStartTime, setCurrStartTime] = useState(moment().add('days', -1).format('YYYY-MM-DD HH:mm:ss')) 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 [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 => { dispatch(install.editAbnParams(data.id,pushData)).then(res => {
if (res.success) { if (res.success) {
const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') const id = [factorId, -1].join(',')
dispatch(install.getAbnParamList({ sensorId:id})) dispatch(install.getAbnParamList({ factorId: id }))
closeModal() closeModal()
} }
}) })

18
web/client/src/sections/install/containers/burr.jsx

@ -32,8 +32,8 @@ const Burr = (props) => {
const removeItem = e => { const removeItem = e => {
dispatch(install.deleteAbnParams(e)).then(res=>{ dispatch(install.deleteAbnParams(e)).then(res=>{
if(res.success){ if(res.success){
const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') const id = [factorId, -1].join(',')
dispatch(install.getAbnParamList({ sensorId:id})) dispatch(install.getAbnParamList({ factorId: id }))
} }
}) })
}; };
@ -61,8 +61,8 @@ const Burr = (props) => {
//or //or
dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{ dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{
if(res.success){ if(res.success){
const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') const id = [factorId, -1].join(',')
dispatch(install.getAbnParamList({ sensorId:id })) dispatch(install.getAbnParamList({ factorId: id }))
} }
}) })
} }
@ -73,8 +73,8 @@ const Burr = (props) => {
let ids = selectedRowKeys.join(','); let ids = selectedRowKeys.join(',');
dispatch(install.deleteAbnParams(ids)).then(res=>{ dispatch(install.deleteAbnParams(ids)).then(res=>{
if(res.success){ if(res.success){
const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') const id = [factorId, -1].join(',')
dispatch(install.getAbnParamList({ sensorId:id })) dispatch(install.getAbnParamList({ factorId: id }))
} }
}) })
@ -101,8 +101,8 @@ const Burr = (props) => {
// //
dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{ dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{
if(res.success){ if(res.success){
const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') const id = [factorId, -1].join(',')
dispatch(install.getAbnParamList({ sensorId:id })) dispatch(install.getAbnParamList({ factorId: id }))
} }
}) })
} else if (dataSource.length != 0) { } else if (dataSource.length != 0) {
@ -245,6 +245,8 @@ const Burr = (props) => {
modalData={modalData} modalData={modalData}
item={itName} item={itName}
sensorId={sensorId} sensorId={sensorId}
factorId={factorId}
/> : ''} /> : ''}
</Card> </Card>
) )

21
web/client/src/sections/install/containers/cacl.jsx

@ -27,7 +27,7 @@ const Calc = (props) => {
const [reCalcFactorId, setReCalcFactorId] = useState(null); const [reCalcFactorId, setReCalcFactorId] = useState(null);
const [msg, setMsg] = useState('') const [msg, setMsg] = useState('')
const [factosList, setFactorsList] = useState([])// const [factosList, setFactorsList] = useState([])//
const [factorId, setFactorId] = useState([]) const [factorId, setFactorId] = useState(null)
const [sensorList, setSensorList] = useState([])// const [sensorList, setSensorList] = useState([])//
const [sensorId, setSensorId] = useState([])//id' const [sensorId, setSensorId] = useState([])//id'
const [itemId, setItemId] = useState(null)// const [itemId, setItemId] = useState(null)//
@ -44,12 +44,13 @@ const Calc = (props) => {
// getData() // getData()
dispatch(install.getAbnMethods()) dispatch(install.getAbnMethods())
}, []) }, [])
console.log('factore111',factorId)
useEffect(() => { useEffect(() => {
if(project){ if(project&&factorId){
const id = [...sensorId?.map(item=>project+'-'+item), -1].join(',') const id = [factorId, -1].join(',')
dispatch(install.getAbnParamList({ sensorId: id })) dispatch(install.getAbnParamList({ factorId: id }))
} }
}, [sensorId, factorId,project]) }, [factorId,project])
// //
useEffect(() => { useEffect(() => {
@ -154,7 +155,7 @@ const Calc = (props) => {
} }
let pushData = data.sensorId.map(d => { let pushData = data.sensorId.map(d => {
return { return {
sensorId: project+'-'+d,// sensorId: project+':'+d,//
sensorName: sensorList.find(a => a.value == d).label, sensorName: sensorList.find(a => a.value == d).label,
factorId: factorId, factorId: factorId,
factorName: factosList.find(a => a.value == factorId).label, factorName: factosList.find(a => a.value == factorId).label,
@ -167,8 +168,8 @@ const Calc = (props) => {
}) })
dispatch(install.addAbnParam(pushData)).then(res => { dispatch(install.addAbnParam(pushData)).then(res => {
if (res.success) { if (res.success) {
const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') const id = [factorId, -1].join(',')
dispatch(install.getAbnParamList({ sensorId: id })) dispatch(install.getAbnParamList({ factorId: id }))
} }
}) })
if (ids.notToSave.length != 0) { if (ids.notToSave.length != 0) {
@ -429,8 +430,8 @@ const Calc = (props) => {
</Form.Cascader> </Form.Cascader>
</Col> </Col>
<Col span={6} > <Col span={6} >
<Form.Select showSearch filter multiple iSelect label="设备" field="point" value={sensorId} onChange={pointChange} <Form.Select showSearch filter multiple iSelect label="测点" field="point" value={sensorId} onChange={pointChange}
optionList={sensorList} placeholder="请选择设备" style={{ textAlign: 'left', width: 274 }} > optionList={sensorList} placeholder="测点" style={{ textAlign: 'left', width: 274 }} >
</Form.Select> </Form.Select>
</Col> </Col>
<Col span={6} > <Col span={6} >

19
web/client/src/sections/install/containers/interrupt.jsx

@ -30,8 +30,8 @@ const Interrupt = (props) => {
const removeItem = e => { const removeItem = e => {
dispatch(install.deleteAbnParams(e)).then(res=>{ dispatch(install.deleteAbnParams(e)).then(res=>{
if(res.success){ if(res.success){
const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') const id = [factorId, -1].join(',')
dispatch(install.getAbnParamList({ sensorId:id})) dispatch(install.getAbnParamList({ factorId: id }))
} }
}) })
} }
@ -58,8 +58,8 @@ const Interrupt = (props) => {
} }
dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{ dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{
if(res.success){ if(res.success){
const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') const id = [factorId, -1].join(',')
dispatch(install.getAbnParamList({ sensorId:id })) dispatch(install.getAbnParamList({ factorId: id }))
} }
}) })
@ -71,8 +71,8 @@ const Interrupt = (props) => {
let ids = selectedRowKeys.join(',') let ids = selectedRowKeys.join(',')
dispatch(install.deleteAbnParams(ids)).then(res=>{ dispatch(install.deleteAbnParams(ids)).then(res=>{
if(res.success){ if(res.success){
const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') const id = [factorId, -1].join(',')
dispatch(install.getAbnParamList({ sensorId:id})) dispatch(install.getAbnParamList({ factorId: id }))
} }
}) })
} else { } else {
@ -95,8 +95,8 @@ const Interrupt = (props) => {
dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{ dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{
if(res.success){ if(res.success){
const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') const id = [factorId, -1].join(',')
dispatch(install.getAbnParamList({ sensorId:id })) dispatch(install.getAbnParamList({ factorId: id }))
} }
}) })
} else if (dataSource.length != 0) { } else if (dataSource.length != 0) {
@ -204,7 +204,7 @@ const Interrupt = (props) => {
> >
<Row style={{ display: 'flex',alignItems:'center'}}> <Row style={{ display: 'flex',alignItems:'center'}}>
<Col span={5}> <Col span={5}>
<Form.Input field='keywords' noLabel={true} style={{ marginBottom: 0, width: '95%' }} placeholder="关键词:测点位置、监测" onChange={handleInputChange}> <Form.Input field='keywords' noLabel={true} style={{ marginBottom: 0, width: '95%' }} placeholder="关键词:测点位置、监测因素" onChange={handleInputChange}>
</Form.Input> </Form.Input>
</Col> </Col>
<Col span={2}> <Col span={2}>
@ -237,6 +237,7 @@ const Interrupt = (props) => {
sensorId={sensorId} sensorId={sensorId}
closeModal={modalCancel} closeModal={modalCancel}
modalData={modalData} modalData={modalData}
factorId={factorId}
/> : ''} /> : ''}
</Card> </Card>
) )

18
web/client/src/sections/install/containers/trend.jsx

@ -38,8 +38,8 @@ const Trend = (props) => {
const removeItem = e => { const removeItem = e => {
dispatch(install.deleteAbnParams(e)).then(res=>{ dispatch(install.deleteAbnParams(e)).then(res=>{
if(res.success){ if(res.success){
const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') const id = [factorId, -1].join(',')
dispatch(install.getAbnParamList({ sensorId:id})) dispatch(install.getAbnParamList({ factorId: id }))
} }
}) })
} }
@ -67,8 +67,8 @@ const Trend = (props) => {
// //
dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{ dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{
if(res.success){ if(res.success){
const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') const id = [factorId, -1].join(',')
dispatch(install.getAbnParamList({ sensorId:id})) dispatch(install.getAbnParamList({ factorId: id }))
} }
}) })
} }
@ -80,8 +80,8 @@ const Trend = (props) => {
// //
dispatch(install.deleteAbnParams(ids)).then(res=>{ dispatch(install.deleteAbnParams(ids)).then(res=>{
if(res.success){ if(res.success){
const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') const id = [factorId, -1].join(',')
dispatch(install.getAbnParamList({ sensorId:id })) dispatch(install.getAbnParamList({ factorId: id }))
} }
}) })
} else { } else {
@ -111,8 +111,8 @@ const Trend = (props) => {
dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{ dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{
if(res.success){ if(res.success){
const id=[...sensorId?.map(item=>project+'-'+item), -1].join(',') const id = [factorId, -1].join(',')
dispatch(install.getAbnParamList({ sensorId:id})) dispatch(install.getAbnParamList({ factorId: id }))
} }
}) })
} else if (dataSource.length != 0) { } else if (dataSource.length != 0) {
@ -406,6 +406,8 @@ const Trend = (props) => {
closeModal={modalCancel} closeModal={modalCancel}
modalData={modalData} modalData={modalData}
sensorId={sensorId} sensorId={sensorId}
factorId={factorId}
/> : ''} /> : ''}
</Card> </Card>
); );

Loading…
Cancel
Save