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) {
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,

86
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={}

6
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()
}
})

6
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()
}
})

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 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()
}
})

18
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}
/> : ''}
</Card>
)

21
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) => {
</Form.Cascader>
</Col>
<Col span={6} >
<Form.Select showSearch filter multiple iSelect label="设备" field="point" value={sensorId} onChange={pointChange}
optionList={sensorList} placeholder="请选择设备" style={{ textAlign: 'left', width: 274 }} >
<Form.Select showSearch filter multiple iSelect label="测点" field="point" value={sensorId} onChange={pointChange}
optionList={sensorList} placeholder="测点" style={{ textAlign: 'left', width: 274 }} >
</Form.Select>
</Col>
<Col span={6} >

19
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) => {
>
<Row style={{ display: 'flex',alignItems:'center'}}>
<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>
</Col>
<Col span={2}>
@ -237,6 +237,7 @@ const Interrupt = (props) => {
sensorId={sensorId}
closeModal={modalCancel}
modalData={modalData}
factorId={factorId}
/> : ''}
</Card>
)

18
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}
/> : ''}
</Card>
);

Loading…
Cancel
Save