Browse Source

feat:fix bugs

dev
zhaobing’ 1 year ago
parent
commit
51d9e69597
  1. 175
      api/app/lib/controllers/monitor/index.js
  2. 2
      web/client/src/sections/install/containers/burr.jsx
  3. 2
      web/client/src/sections/install/containers/interrupt.jsx
  4. 471
      web/client/src/sections/install/containers/trend.jsx

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

@ -1,10 +1,9 @@
const moment = require('moment') const moment = require('moment')
const fs = require('fs') const fs = require('fs')
async function getStructures(ctx) { async function getStructures(ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc
const { clickHouse } = ctx.app.fs const { clickHouse } = ctx.app.fs
const { pomsProjectId } = ctx.query const { pomsProjectId } = ctx.query
let bindRes = [] let bindRes = []
@ -24,8 +23,9 @@ 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,
@ -60,86 +60,119 @@ async function getStructures(ctx) {
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) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: error`)
ctx.status = 400; ctx.status = 400
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined,
} }
} }
} }
async function getFactors(ctx) { async function getFactors(ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc
const { clickHouse } = ctx.app.fs const { clickHouse } = ctx.app.fs
const { structId, cacl } = ctx.query const { structId, cacl } = ctx.query
let list = [] let list = []
if (cacl) { if (cacl) {
const factorList = await clickHouse.alarmLocal.query(`select distinct SafetyFactorTypeId, SafetyFactorTypeName from sensors where PlatformStructureId =${structId}`).toPromise() const factorList = await clickHouse.dataAlarm
.query(`select SafetyFactorTypeId, SafetyFactorTypeName from sensors where PlatformStructureId = ${structId}`)
.toPromise()
const project = await clickHouse.dataAlarm
.query(`select Project from sensors where PlatformStructureId =${structId} limit 1 `)
.toPromise()
let fList = factorList.map(m => m.SafetyFactorTypeId) let fList = factorList.map(m => m.SafetyFactorTypeId)
list = await clickHouse.alarmLocal.query(`select distinct FactorID, Name,Items,ItemNames from factors where FactorID in (${[...fList, -1].join(',')})`).toPromise() list = await clickHouse.dataAlarm
.query(
`select distinct FactorID, Name,Items,ItemNames from factors
where FactorID in (${[...fList, -1].join(',')})
and Project = '${[...project, 0][0].Project}'
`
)
.toPromise()
} else { } else {
list = await clickHouse.alarmLocal.query(`select distinct SafetyFactorTypeId, SafetyFactorTypeName from sensors where PlatformStructureId =${structId}`).toPromise() list = await clickHouse.dataAlarm
.query(
`select distinct SafetyFactorTypeId, SafetyFactorTypeName from sensors where PlatformStructureId =${structId}`
)
.toPromise()
} }
ctx.body = list ctx.body = list
ctx.status = 200 ctx.status = 200
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: error`)
ctx.status = 400; ctx.status = 400
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined,
} }
} }
} }
//查询设备 //查询设备
async function getSensors(ctx) { async function getSensors(ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc
const { clickHouse } = ctx.app.fs const { clickHouse } = ctx.app.fs
const { structId, SafetyFactorTypeId } = ctx.query const { structId, SafetyFactorTypeId } = ctx.query
const list = await clickHouse.alarmLocal.query(` const list = await clickHouse.dataAlarm
.query(
`
select distinct SensorId,SensorLocationDescription,Project select distinct SensorId,SensorLocationDescription,Project
from sensors where PlatformStructureId =${structId} from sensors where PlatformStructureId =${structId}
and SafetyFactorTypeId=${SafetyFactorTypeId}`).toPromise() and SafetyFactorTypeId=${SafetyFactorTypeId}`
)
.toPromise()
ctx.body = list ctx.body = list
ctx.status = 200 ctx.status = 200
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: error`)
ctx.status = 400; ctx.status = 400
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined,
} }
} }
} }
//根据设备id和监测因素id查询监测数据 //根据设备id和监测因素id查询监测数据
async function getMonitorData(ctx) { async function getMonitorData(ctx) {
try { try {
const { clickHouse } = ctx.app.fs const { clickHouse } = ctx.app.fs
const { factorId, sensorId, startTime, endTime,toExport } = ctx.query const { factorId, sensorId, startTime, endTime, toExport } = ctx.query
const projectId = sensorId.split('-')[0] const projectId = sensorId.split('-')[0]
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} AND Project='${projectId}' WHERE FactorID=${factorId} AND Project='${projectId}'
`).toPromise() || [] `
)
.toPromise()) || []
const dataArray = sensorId.split(',') const dataArray = sensorId.split(',')
const transformedArray = dataArray.map(item => { const transformedArray = dataArray.map(item => {
return item.replace('-', ':') + '' return item.replace('-', ':') + ''
}) })
const id = `(${transformedArray.map(id => `'${id}'`).join(',')})` const id = `(${transformedArray.map(id => `'${id}'`).join(',')})`
const monitorData = await clickHouse.alarmLocal.query(`SELECT distinct SensorId,CollectTime,Values FROM themes const monitorData =
(await clickHouse.alarmLocal
.query(
`SELECT distinct SensorId,CollectTime,Values FROM themes
WHERE SensorId in ${id} WHERE SensorId in ${id}
AND CollectTime >= toDate('${startTime}') AND CollectTime >= toDate('${startTime}')
AND CollectTime <= toDate('${endTime}') AND CollectTime <= toDate('${endTime}')
`).toPromise() || [] `
const sensor = await clickHouse.alarmLocal.query(`SELECT distinct ID, SensorId,SensorLocationDescription FROM sensors WHERE ID in ${id}`).toPromise() )
.toPromise()) || []
const sensor = await clickHouse.alarmLocal
.query(`SELECT distinct ID, SensorId,SensorLocationDescription FROM sensors WHERE ID in ${id}`)
.toPromise()
//监测项 //监测项
let items = {} let items = {}
if (factorsList && factorsList.length > 0) { if (factorsList && factorsList.length > 0) {
@ -162,40 +195,40 @@ async function getMonitorData(ctx) {
let sensors = [] let sensors = []
let data = [] let data = []
if (sensor && monitorData && sensor.length && monitorData.length) { if (sensor && monitorData && sensor.length && monitorData.length) {
sensor.forEach((item) => { sensor.forEach(item => {
// 过滤与当前传感器相关的数据 // 过滤与当前传感器相关的数据
const sensorDataArray = monitorData.filter((d) => d.SensorId == item.ID) const sensorDataArray = monitorData.filter(d => d.SensorId == item.ID)
// 构建最终的传感器数据结构 // 构建最终的传感器数据结构
const sensorDataItem = { const sensorDataItem = {
id: item.ID, id: item.ID,
name: item.SensorLocationDescription, name: item.SensorLocationDescription,
data: sensorDataArray.map((d) => { data: sensorDataArray.map(d => {
// 根据 item 对象进行映射 // 根据 item 对象进行映射
const values = {}; const values = {}
itemKeys = Object.keys(items) itemKeys = Object.keys(items)
itemKeys.forEach((key, index) => { itemKeys.forEach((key, index) => {
values[key] = d.Values[index]; values[key] = d.Values[index]
}); })
return { return {
time: d.CollectTime, time: d.CollectTime,
values: values values: values,
}; }
}) }),
}; }
data.push(sensorDataItem) data.push(sensorDataItem)
}) })
} }
//导出相关 //导出相关
if (toExport) { if (toExport) {
let arr=items let arr = items
let columns = [] let columns = []
columns.push({ columns.push({
title: '设备位置', title: '设备位置',
dataIndex: 'position', dataIndex: 'position',
key: 'position', key: 'position',
}); })
for (let index in arr) { for (let index in arr) {
columns.push({ columns.push({
title: arr[index].name + '(' + arr[index].unit + ')', title: arr[index].name + '(' + arr[index].unit + ')',
@ -203,54 +236,51 @@ async function getMonitorData(ctx) {
sorter: (a, b) => b[index] - a[index], sorter: (a, b) => b[index] - a[index],
key: index, key: index,
}) })
}; }
columns.push({ columns.push({
title: '采集时间', title: '采集时间',
dataIndex: 'acqTime', dataIndex: 'acqTime',
sorter: (a, b) => b['realTime'] - a['realTime'], sorter: (a, b) => b['realTime'] - a['realTime'],
key: 'acqTime', key: 'acqTime',
}); })
//设备 //设备
let data1 = [] let data1 = []
let themeStations = data let themeStations = data
for (let i = 0; i < themeStations.length; i++) { for (let i = 0; i < themeStations.length; i++) {
for (let k = 0; k < themeStations[i].data.length; k++) { for (let k = 0; k < themeStations[i].data.length; k++) {
let cdataT = {} let cdataT = {}
let startT = ""; let startT = ''
let endT = ""; let endT = ''
let dataTS = themeStations[i].data[k]; let dataTS = themeStations[i].data[k]
cdataT.key = `station-${themeStations[i].id}-${k}`; cdataT.key = `station-${themeStations[i].id}-${k}`
cdataT.position = themeStations[i].name; cdataT.position = themeStations[i].name
cdataT.acqTime = moment(dataTS.time).format('YYYY-MM-DD HH:mm:ss'); cdataT.acqTime = moment(dataTS.time).format('YYYY-MM-DD HH:mm:ss')
cdataT.realTime = moment(dataTS.time).valueOf(); cdataT.realTime = moment(dataTS.time).valueOf()
if (startT == "") { if (startT == '') {
startT = dataTS.time; startT = dataTS.time
endT = dataTS.time; endT = dataTS.time
} else { } else {
if (moment(startT) >= moment(dataTS.time)) if (moment(startT) >= moment(dataTS.time)) startT = dataTS.time
startT = dataTS.time; if (moment(endT) <= moment(dataTS.time)) endT = dataTS.time
if (moment(endT) <= moment(dataTS.time))
endT = dataTS.time;
} }
//动态列的值 //动态列的值
for (let themeItem in arr) { for (let themeItem in arr) {
cdataT[themeItem] = dataTS.values[themeItem]; cdataT[themeItem] = dataTS.values[themeItem]
} }
data1.push(cdataT) data1.push(cdataT)
} }
} }
await exportMaterialEnterList(ctx, data1, columns) await exportMaterialEnterList(ctx, data1, columns)
} }
if(!toExport){ if (!toExport) {
ctx.body = { items, sensors: data } ctx.body = { items, sensors: data }
ctx.status = 200 ctx.status = 200
} }
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: error`)
ctx.status = 400; ctx.status = 400
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined,
} }
} }
} }
@ -261,7 +291,9 @@ async function exportMaterialEnterList(ctx, data, columns) {
columns.forEach(item => { columns.forEach(item => {
header.push({ title: item.title, key: item.key }) header.push({ title: item.title, key: item.key })
}) })
const { utils: { simpleExcelDown } } = ctx.app.fs const {
utils: { simpleExcelDown },
} = ctx.app.fs
// let exportData = [] // let exportData = []
// let item={} // let item={}
// console.log(dataList[0].dataValues) // console.log(dataList[0].dataValues)
@ -294,7 +326,7 @@ async function exportMaterialEnterList(ctx, data, columns) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`)
ctx.status = 400 ctx.status = 400
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined,
} }
} }
} }
@ -307,14 +339,15 @@ async function exportFile(ctx) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`)
ctx.status = 400 ctx.status = 400
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined,
} }
} }
} }
module.exports = { module.exports = {
getStructures, getFactors, getSensors, getMonitorData, exportFile getStructures,
getFactors,
getSensors,
getMonitorData,
exportFile,
} }

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

@ -274,7 +274,7 @@ const Burr = (props) => {
pageSizeOpts={[10, 20, 30, 40]} pageSizeOpts={[10, 20, 30, 40]}
onChange={(currentPage, pageSize) => { onChange={(currentPage, pageSize) => {
changeQuery( pageSize, currentPage - 1) changeQuery( pageSize, currentPage - 1)
page.current = currentPage - 1 // page.current = currentPage - 1
}} }}
/> />
</div> </div>

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

@ -267,7 +267,7 @@ const Interrupt = (props) => {
pageSizeOpts={[10, 20, 30, 40]} pageSizeOpts={[10, 20, 30, 40]}
onChange={(currentPage, pageSize) => { onChange={(currentPage, pageSize) => {
changeQuery( pageSize, currentPage - 1) changeQuery( pageSize, currentPage - 1)
page.current = currentPage - 1 // page.current = currentPage - 1
}} }}
/> />
</div> </div>

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

@ -1,15 +1,26 @@
'use strict'; 'use strict'
import React, { Component, useRef,useState } from 'react'; import React, { Component, useRef, useState } from 'react'
import { connect } from 'react-redux'; import { connect } from 'react-redux'
import { Row, Col, Button, Table, Card, Popconfirm, Tag, Notification, Form, Select,Pagination } from '@douyinfe/semi-ui' import {
import {IconPlus} from "@douyinfe/semi-icons" Row,
import TrendModal from '../components/TrendModal'; Col,
Button,
Table,
Card,
Popconfirm,
Tag,
Notification,
Form,
Select,
Pagination,
} from '@douyinfe/semi-ui'
import { IconPlus } from '@douyinfe/semi-icons'
import TrendModal from '../components/TrendModal'
const Trend = props => {
const { abnParam, factorId, itName, actions, dispatch, sensorId, project, limits, query, changeQuery, limitChange } =
const Trend = (props) => { props
const { abnParam, factorId,itName,actions,dispatch,sensorId,project,limits,query,changeQuery,limitChange } = props
const form = useRef() const form = useRef()
const [selectedRowKeys, setSelectedRowKeys] = useState([]) const [selectedRowKeys, setSelectedRowKeys] = useState([])
const [filterFunc, setFilterFunc] = useState({}) const [filterFunc, setFilterFunc] = useState({})
@ -24,8 +35,9 @@ const Trend = (props) => {
const [graValue, setGraValue] = useState('') const [graValue, setGraValue] = useState('')
const [modalData, setModalData] = useState(null) const [modalData, setModalData] = useState(null)
const filterSet = { sensorName: null, factorName: null } const filterSet = { sensorName: null, factorName: null }
const {install}=actions const { install } = actions
const onSelectChange = (selectedRowKeys) => { console.log('query', query)
const onSelectChange = selectedRowKeys => {
setSelectedRowKeys(selectedRowKeys) setSelectedRowKeys(selectedRowKeys)
} }
const compareAndEdit = (e, record) => { const compareAndEdit = (e, record) => {
@ -34,14 +46,14 @@ const Trend = (props) => {
} }
const modalCancel = e => { const modalCancel = e => {
setModalVisible(false) setModalVisible(false)
}; }
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 = [factorId, -1].join(',') const id = [factorId, -1].join(',')
changeQuery(10,0) changeQuery(10, 0)
dispatch(install.getAbnParamList({ factorId: id,limit:10, page: 0,type:3})).then(rs=>{ dispatch(install.getAbnParamList({ factorId: id, limit: 10, page: 0, type: 3 })).then(rs => {
if(rs.success){ if (rs.success) {
limitChange(rs.payload.data.count) limitChange(rs.payload.data.count)
} }
}) })
@ -51,9 +63,15 @@ const Trend = (props) => {
const handleInputChange = e => { const handleInputChange = e => {
if (e != null) { if (e != null) {
const value = e const value = e
let func = (ep => (s => (s.sensorName).search(ep) > -1))(value) let func = (
ep => s =>
s.sensorName.search(ep) > -1
)(value)
filterSet.sensorName = func filterSet.sensorName = func
func = (ep => (s => (s.factorName).search(ep) > -1))(value) func = (
ep => s =>
s.factorName.search(ep) > -1
)(value)
filterSet.factorName = func filterSet.factorName = func
} else { } else {
filterSet.sensorName = null filterSet.sensorName = null
@ -62,20 +80,20 @@ const Trend = (props) => {
setFilterFunc(filterSet) setFilterFunc(filterSet)
} }
//or //or
const onSwitchChange = (e) => { const onSwitchChange = e => {
if (selectedRowKeys.length != 0) { if (selectedRowKeys.length != 0) {
let ids = selectedRowKeys.join(','); let ids = selectedRowKeys.join(',')
let data = { let data = {
enabled: e, enabled: e,
use: 'switch' use: 'switch',
}; }
// //
dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{ dispatch(install.batchCfgAbnParams(ids, data)).then(res => {
if(res.success){ if (res.success) {
const id = [factorId, -1].join(',') const id = [factorId, -1].join(',')
changeQuery(10,0) changeQuery(10, 0)
dispatch(install.getAbnParamList({ factorId: id,limit:10, page: 0,type:3})).then(rs=>{ dispatch(install.getAbnParamList({ factorId: id, limit: 10, page: 0, type: 3 })).then(rs => {
if(rs.success){ if (rs.success) {
limitChange(rs.payload.data.count) limitChange(rs.payload.data.count)
} }
}) })
@ -86,14 +104,14 @@ const Trend = (props) => {
// //
const batchDelete = () => { const batchDelete = () => {
if (selectedRowKeys.length != 0) { if (selectedRowKeys.length != 0) {
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 = [factorId, -1].join(',') const id = [factorId, -1].join(',')
changeQuery(10,0) changeQuery(10, 0)
dispatch(install.getAbnParamList({ factorId: id,limit:10, page: 0,type:3})).then(rs=>{ dispatch(install.getAbnParamList({ factorId: id, limit: 10, page: 0, type: 3 })).then(rs => {
if(rs.success){ if (rs.success) {
limitChange(rs.payload.data.count) limitChange(rs.payload.data.count)
} }
}) })
@ -103,33 +121,34 @@ const Trend = (props) => {
Notification.warning({ Notification.warning({
content: '您尚未勾选任何参数配置!', content: '您尚未勾选任何参数配置!',
duration: 3, duration: 3,
}) } })
}
} }
// //
const batchSave = () => { const batchSave = () => {
form.current.validate().then(value=>{ form.current.validate().then(value => {
let dataSource = abnParam.filter(a => a.abnType == 3 && a.factorId == factorId) let dataSource = abnParam.filter(a => a.abnType == 3 && a.factorId == factorId)
if (selectedRowKeys.length != 0) { if (selectedRowKeys.length != 0) {
let ids = selectedRowKeys.join(',') let ids = selectedRowKeys.join(',')
let data = { let data = {
paramJson: { paramJson: {
"thr_der": deValue, // thr_der: deValue, //
"win_avg": reCoef,// win_avg: reCoef, //
"win_med": winSize,// win_med: winSize, //
"thr_burr": bvBatch,// thr_burr: bvBatch, //
"thr_grad": graValue,// thr_grad: graValue, //
"win_grad": graPoint,// win_grad: graPoint, //
"days_Last": timeRange// days_Last: timeRange, //
}, },
use: 'notSwitch', use: 'notSwitch',
}; }
dispatch(install.batchCfgAbnParams(ids,data)).then(res=>{ dispatch(install.batchCfgAbnParams(ids, data)).then(res => {
if(res.success){ if (res.success) {
const id = [factorId, -1].join(',') const id = [factorId, -1].join(',')
changeQuery(10,0) changeQuery(10, 0)
dispatch(install.getAbnParamList({ factorId: id,limit:10, page: 0,type:3})).then(rs=>{ dispatch(install.getAbnParamList({ factorId: id, limit: 10, page: 0, type: 3 })).then(rs => {
if(rs.success){ if (rs.success) {
limitChange(rs.payload.data.count) limitChange(rs.payload.data.count)
} }
}) })
@ -145,30 +164,30 @@ const Trend = (props) => {
} }
const iconClick = () => { const iconClick = () => {
if (!showBatchConfig) { if (!showBatchConfig) {
setShowBatchConfig(true); setShowBatchConfig(true)
} else { } else {
setShowBatchConfig(false); setShowBatchConfig(false)
} }
} }
const rangeChange = (value) => { const rangeChange = value => {
setTimeRange(value) setTimeRange(value)
} }
const bvValueBatch = (value) => { const bvValueBatch = value => {
setBvBatch(value) setBvBatch(value)
} }
const winSizeBatch = (value) => { const winSizeBatch = value => {
setWinSize(value) setWinSize(value)
} }
const reCoefBatch = (value) => { const reCoefBatch = value => {
setReCoef(value) setReCoef(value)
} }
const deValueBatch = (value) => { const deValueBatch = value => {
setDeValue(value) setDeValue(value)
} }
const graPointBatch = (value) => { const graPointBatch = value => {
setGraPoint(value) setGraPoint(value)
} }
const graValueBatch = (value) => { const graValueBatch = value => {
setGraValue(value) setGraValue(value)
} }
const checkInterger = (rule, val) => { const checkInterger = (rule, val) => {
@ -179,10 +198,9 @@ const Trend = (props) => {
} }
return false return false
// } // }
}
};
const checkPoint = (rule, value) => { const checkPoint = (rule, value) => {
const pattern = /^[1-9]*[1-9][0-9]*$/; const pattern = /^[1-9]*[1-9][0-9]*$/
if (pattern.test(value) && value != 1) { if (pattern.test(value) && value != 1) {
return true return true
} }
@ -194,276 +212,337 @@ const Trend = (props) => {
return true return true
} }
return false return false
} }
let dataSource = abnParam.filter(a => a.abnType == 3 && a.factorId == factorId) let dataSource = abnParam.filter(a => a.abnType == 3 && a.factorId == factorId)
const rowSelection = { const rowSelection = {
selectedRowKeys: selectedRowKeys, selectedRowKeys: selectedRowKeys,
onChange: onSelectChange, onChange: onSelectChange,
}; }
let filterData = dataSource; let filterData = dataSource
let flag = false; let flag = false
let keyArr = []; let keyArr = []
let tmpds = []; let tmpds = []
let dataPush = []; let dataPush = []
Object.keys(filterFunc).forEach(key => { Object.keys(filterFunc).forEach(key => {
const filter = filterFunc[key]; const filter = filterFunc[key]
filterData = dataSource; filterData = dataSource
if (filter != null) { if (filter != null) {
flag = true; flag = true
filterData = filterData.filter(filter) filterData = filterData.filter(filter)
if (filterData.length > 0) { if (filterData.length > 0) {
filterData.map(s => { filterData.map(s => {
if (keyArr.indexOf(s.id) == -1) { if (keyArr.indexOf(s.id) == -1) {
keyArr.push(s.id); keyArr.push(s.id)
dataPush.push(s); dataPush.push(s)
} }
}) })
} }
} }
}) })
tmpds = flag ? dataPush.sort((a, b) => a.id - b.id) : dataSource.sort((a, b) => a.id - b.id); tmpds = flag ? dataPush.sort((a, b) => a.id - b.id) : dataSource.sort((a, b) => a.id - b.id)
let columns = [ let columns = [
{ {
title: "测点位置", title: '测点位置',
dataIndex: "sensorName", dataIndex: 'sensorName',
key: "sensorName", key: 'sensorName',
width: '9%' width: '9%',
}, },
{ {
title: "监测项", title: '监测项',
dataIndex: "factorName", dataIndex: 'factorName',
key: "factorName", key: 'factorName',
width: '10%', width: '10%',
render: (text, record) => ( render: (text, record) => record.factorName + '/' + itName,
record.factorName + "/" + itName
),
}, },
{ {
title: "分析时段", title: '分析时段',
dataIndex: "params", dataIndex: 'params',
key: "params1", key: 'params1',
width: '9%', width: '9%',
render: text => text.days_Last + "个月" render: text => text.days_Last + '个月',
}, },
{ {
title: "毛刺阈值", title: '毛刺阈值',
dataIndex: "params", dataIndex: 'params',
key: "params2", key: 'params2',
width: '9%', width: '9%',
render: text => text.thr_burr render: text => text.thr_burr,
}, },
{ {
title: "窗口数", title: '窗口数',
dataIndex: "params", dataIndex: 'params',
key: "params3", key: 'params3',
width: '9%', width: '9%',
render: text => text.win_med render: text => text.win_med,
}, },
{ {
title: "回归系数", title: '回归系数',
dataIndex: "params", dataIndex: 'params',
key: "params4", key: 'params4',
width: '9%', width: '9%',
render: text => text.win_avg render: text => text.win_avg,
}, },
{ {
title: "导数阈值", title: '导数阈值',
dataIndex: "params", dataIndex: 'params',
key: "params5", key: 'params5',
width: '9%', width: '9%',
render: text => text.thr_der render: text => text.thr_der,
}, },
{ {
title: "渐变点个数", title: '渐变点个数',
dataIndex: "params", dataIndex: 'params',
key: "params6", key: 'params6',
width: '9%', width: '9%',
render: text => text.win_grad render: text => text.win_grad,
}, },
{ {
title: "渐变阈值", title: '渐变阈值',
dataIndex: "params", dataIndex: 'params',
key: "params7", key: 'params7',
width: '9%', width: '9%',
render: text => text.thr_grad render: text => text.thr_grad,
}, },
{ {
title: "启用状态", title: '启用状态',
dataIndex: "enabled", dataIndex: 'enabled',
key: "enabled", key: 'enabled',
width: '9%', width: '9%',
render: (text, record) => ( render: (text, record) => (record.enabled ? <Tag color='blue'>已启用</Tag> : <Tag>已禁用</Tag>),
record.enabled ? <Tag color="blue">已启用</Tag> : <Tag>已禁用</Tag>
)
}, },
{ {
title: "操作", title: '操作',
key: "action", key: 'action',
width: '9%', width: '9%',
render: (text, record) => ( render: (text, record) => (
<span> <span>
<Button theme='borderless' type='primary' onClick={(e) => compareAndEdit(e, record)}>编辑</Button> <Button theme='borderless' type='primary' onClick={e => compareAndEdit(e, record)}>
<span className="ant-divider"></span> 编辑
<Popconfirm title="确认删除该参数配置?" id={record.id} onConfirm={() => { removeItem(record.id) }}> </Button>
<Button theme='borderless' type='danger' >删除</Button> <span className='ant-divider'></span>
<Popconfirm
title='确认删除该参数配置?'
id={record.id}
onConfirm={() => {
removeItem(record.id)
}}>
<Button theme='borderless' type='danger'>
删除
</Button>
</Popconfirm> </Popconfirm>
</span> </span>
), ),
} },
] ]
return (<Card style={{ marginTop: 15 }}> return (
<Form style={{ marginBottom: 15 }} labelPosition='left' getFormApi={formApi => { <Card style={{ marginTop: 15 }}>
<Form
style={{ marginBottom: 15 }}
labelPosition='left'
getFormApi={formApi => {
form.current = formApi form.current = formApi
}}> }}>
<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
</Form.Input> field='keywords'
noLabel={true}
style={{ marginBottom: 0, width: '95%' }}
placeholder='关键词:测点位置、监测因素'
onChange={handleInputChange}></Form.Input>
</Col> </Col>
<Col span={2}> <Col span={2}>
<Form.Switch label='是否启用' field='switch' style={{ marginBottom: 0 }} checked onChange={onSwitchChange} > <Form.Switch
</Form.Switch> label='是否启用'
field='switch'
style={{ marginBottom: 0 }}
checked
onChange={onSwitchChange}></Form.Switch>
</Col> </Col>
<Col span={2}> <Col span={2}>
<Popconfirm style={{ marginBottom: 0 }} title="确认批量删除选中的参数配置?" onConfirm={batchDelete}> <Popconfirm style={{ marginBottom: 0 }} title='确认批量删除选中的参数配置?' onConfirm={batchDelete}>
<Button style={{ fontSize: 13 }} theme='solid' type='danger'>批量删除</Button> <Button style={{ fontSize: 13 }} theme='solid' type='danger'>
批量删除
</Button>
</Popconfirm> </Popconfirm>
</Col> </Col>
<Col span={2}> <Col span={2}>
<IconPlus style={{ paddingTop: 9 }} onClick={iconClick} /> <IconPlus style={{ paddingTop: 9 }} onClick={iconClick} />
</Col> </Col>
</Row> </Row>
{showBatchConfig ? {showBatchConfig ? (
<Row style={{ display: 'flex',alignItems:'center',marginTop: 10}}> <Row style={{ display: 'flex', alignItems: 'center', marginTop: 10 }}>
<Col span={3}> <Col span={3}>
<Form.Select showSearch filter noLabel={true} field="timeRange" onChange={rangeChange} <Form.Select
placeholder="请选择分析时长" style={{ width: '93%', marginBottom: 0 }}> showSearch
<Select.Option value="1">1个月</Select.Option> filter
<Select.Option value="2">2个月</Select.Option> noLabel={true}
<Select.Option value="3">3个月</Select.Option> field='timeRange'
onChange={rangeChange}
placeholder='请选择分析时长'
style={{ width: '93%', marginBottom: 0 }}>
<Select.Option value='1'>1个月</Select.Option>
<Select.Option value='2'>2个月</Select.Option>
<Select.Option value='3'>3个月</Select.Option>
</Form.Select> </Form.Select>
</Col> </Col>
<Col span={3}> <Col span={3}>
<Form.Input style={{ marginBottom: 0, width: '93%' }} <Form.Input
style={{ marginBottom: 0, width: '93%' }}
field='bv' field='bv'
noLabel={true} noLabel={true}
placeholder="毛刺阈值:数字" placeholder='毛刺阈值:数字'
onChange={e => bvValueBatch(e)} onChange={e => bvValueBatch(e)}
rules={[{ rules={[
required: true, message: "请输入正整数", validator: checkInterger {
}]} trigger='blur'/> required: true,
message: '请输入正整数',
validator: checkInterger,
},
]}
trigger='blur'
/>
</Col> </Col>
<Col span={3}> <Col span={3}>
<Form.Input <Form.Input
style={{ marginBottom: 0, width: '93%' }} style={{ marginBottom: 0, width: '93%' }}
field='ws' field='ws'
placeholder="滑动中值:正值" placeholder='滑动中值:正值'
noLabel={true} noLabel={true}
rules={[{ rules={[
required: true, message: "请输入正整数", validator: checkInterger {
}]} required: true,
message: '请输入正整数',
validator: checkInterger,
},
]}
onChange={e => winSizeBatch(e)} onChange={e => winSizeBatch(e)}
trigger='blur'/> trigger='blur'
/>
</Col> </Col>
<Col span={3}> <Col span={3}>
<Form.Input <Form.Input
style={{ marginBottom: 0, width: '93%' }} style={{ marginBottom: 0, width: '93%' }}
field='rc' field='rc'
placeholder="滑动均值:正值" placeholder='滑动均值:正值'
noLabel={true} rules={[{ noLabel={true}
required: true, message: "请输入正整数", validator: checkInterger rules={[
}]} {
required: true,
message: '请输入正整数',
validator: checkInterger,
},
]}
onChange={e => reCoefBatch(e)} onChange={e => reCoefBatch(e)}
trigger='blur'/> trigger='blur'
/>
</Col> </Col>
<Col span={3}> <Col span={3}>
<Form.Input <Form.Input
style={{ marginBottom: 0, width: '93%' }} style={{ marginBottom: 0, width: '93%' }}
field='dv' field='dv'
placeholder="导数阈值:数字" placeholder='导数阈值:数字'
noLabel={true} noLabel={true}
rules={[{ rules={[
required: true, message: "请输入正整数", validator: checkNumber {
}]} required: true,
message: '请输入正整数',
validator: checkNumber,
},
]}
onChange={e => deValueBatch(e)} onChange={e => deValueBatch(e)}
trigger='blur'/> trigger='blur'
/>
</Col> </Col>
<Col span={3}> <Col span={3}>
<Form.Input <Form.Input
style={{ marginBottom: 0, width: '93%' }} style={{ marginBottom: 0, width: '93%' }}
field='pn' field='pn'
placeholder="渐变点个数:正值" placeholder='渐变点个数:正值'
noLabel={true} rules={[{ noLabel={true}
required: true, message: "请输入正整数", validator: checkPoint rules={[
}]} {
required: true,
message: '请输入正整数',
validator: checkPoint,
},
]}
onChange={e => graPointBatch(e)} onChange={e => graPointBatch(e)}
trigger='blur'/> trigger='blur'
/>
</Col> </Col>
<Col span={3}> <Col span={3}>
<Form.Input <Form.Input
style={{ marginBottom: 0, width: '93%' }} style={{ marginBottom: 0, width: '93%' }}
field='gv' field='gv'
placeholder="渐变阈值:数字" placeholder='渐变阈值:数字'
noLabel={true} rules={[{ noLabel={true}
required: true, message: "请输入正整数", validator: checkNumber rules={[
}]} {
required: true,
message: '请输入正整数',
validator: checkNumber,
},
]}
onChange={e => graValueBatch(e)} onChange={e => graValueBatch(e)}
trigger='blur'/> trigger='blur'
/>
</Col> </Col>
<Col span={2}> <Col span={2}>
<Button onClick={batchSave} theme='solid' type='primary'>批量保存</Button> <Button onClick={batchSave} theme='solid' type='primary'>
批量保存
</Button>
</Col> </Col>
</Row> : ''} </Row>
) : (
''
)}
</Form> </Form>
<Table rowSelection={rowSelection} columns={columns} dataSource={tmpds} pagination={false}/> <Table rowSelection={rowSelection} columns={columns} dataSource={tmpds} pagination={false} />
<div <div
style={{ style={{
display: "flex", display: 'flex',
justifyContent: "flex-end", justifyContent: 'flex-end',
padding: "20px 20px", padding: '20px 20px',
}} }}>
> <span style={{ lineHeight: '30px', fontSize: 13, color: 'rgba(0,90,189,0.8)' }}>{limits}条信息</span>
<span style={{ lineHeight: "30px", fontSize: 13, color: 'rgba(0,90,189,0.8)' }}>
{limits}条信息
</span>
<Pagination <Pagination
total={limits} total={limits}
showSizeChanger showSizeChanger
currentPage={query.page + 1} currentPage={query.page + 1}
pageSizeOpts={[10, 20, 30, 40]} pageSizeOpts={[10, 20, 30, 40]}
onChange={(currentPage, pageSize) => { onChange={(currentPage, pageSize) => {
changeQuery( pageSize, currentPage - 1) changeQuery(pageSize, currentPage - 1)
page.current = currentPage - 1 // page.current = currentPage - 1
}} }}
/> />
</div> </div>
{modalVisible ? <TrendModal {modalVisible ? (
<TrendModal
// structId={structId} // structId={structId}
visible={true} visible={true}
project={ project} project={project}
closeModal={modalCancel} closeModal={modalCancel}
modalData={modalData} modalData={modalData}
sensorId={sensorId} sensorId={sensorId}
factorId={factorId} factorId={factorId}
/>
/> : ''} ) : (
''
)}
</Card> </Card>
); )
} }
function mapStateToProps(state) { function mapStateToProps(state) {
const { abnParam,global } = state const { abnParam, global } = state
// let isRequesting = abnParamState?.isRequesting; // let isRequesting = abnParamState?.isRequesting;
return { return {
isRequesting: false,// isRequesting: false, //
abnParam: abnParam?.data?.rows || [], abnParam: abnParam?.data?.rows || [],
actions:global.actions actions: global.actions,
} }
} }
export default connect(mapStateToProps)(Trend) export default connect(mapStateToProps)(Trend)

Loading…
Cancel
Save