|
|
@ -1,32 +1,70 @@ |
|
|
|
'use strict' |
|
|
|
import React, { Component } from 'react'; |
|
|
|
import { Row, Col, Tooltip } from 'antd'; |
|
|
|
import AutoRollComponent from './autorollcomponent'; |
|
|
|
import { connect } from 'react-redux'; |
|
|
|
import AutoRollComponent from './autorollcomponent' |
|
|
|
import moment from 'moment'; |
|
|
|
class AlarmStatistics extends Component { |
|
|
|
constructor(props) { |
|
|
|
super(props); |
|
|
|
this.state = { |
|
|
|
alarmList: [ |
|
|
|
{ item: '点位1', count: 214 }, |
|
|
|
{ item: '点位2', count: 135 }, |
|
|
|
{ item: '点位3', count: 88 }, |
|
|
|
{ item: '点位4', count: 63 }, |
|
|
|
{ item: '点位5', count: 56 }, |
|
|
|
{ item: '点位6', count: 115 }, |
|
|
|
{ item: '点位7', count: 67 }, |
|
|
|
{ item: '点位8', count: 144 }, |
|
|
|
{ item: '点位9', count: 21 }, |
|
|
|
{ item: '点位10', count: 83 }, |
|
|
|
// { item: '点位1', count: 214 },
|
|
|
|
// { item: '点位2', count: 135 },
|
|
|
|
// { item: '点位3', count: 88 },
|
|
|
|
// { item: '点位4', count: 63 },
|
|
|
|
// { item: '点位5', count: 56 },
|
|
|
|
// { item: '点位6', count: 115 },
|
|
|
|
// { item: '点位7', count: 67 },
|
|
|
|
// { item: '点位8', count: 144 },
|
|
|
|
// { item: '点位9', count: 21 },
|
|
|
|
// { item: '点位10', count: 83 },
|
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async componentDidMount(){ |
|
|
|
const { dispatch, user,actions,depUser} = this.props; |
|
|
|
const { patrolManage } = actions |
|
|
|
const times = [moment().subtract(70, 'years').format(format), moment().format(format)]; |
|
|
|
const format = 'YYYY-MM-DD HH:mm:ss'; |
|
|
|
const res = await dispatch(patrolManage.records(`patrolRecord/all/${times[0]}/${times[1]}/true/null`)); |
|
|
|
const data = res?.payload?.data?.filter(i=>{ |
|
|
|
return i?.patrolRecordIssueHandles[0]?.yanshoucishu>2&&i?.patrolRecordIssueHandles[0]?.isgaojing!==true |
|
|
|
&&res?.payload?.data?.filter(j=>j?.pointId===i?.pointId&&j?.points?.project?.id===i?.points?.project?.id |
|
|
|
&&j?.patrolRecordIssueHandles[0]?.yujingshijian |
|
|
|
&&i?.patrolRecordIssueHandles[0]?.yujingshijian&& |
|
|
|
parseInt(moment(i?.patrolRecordIssueHandles[0].yujingshijian).format('YYYYMMDDHHMMSS'))<parseInt(moment(j?.patrolRecordIssueHandles[0]?.yujingshijian).format('YYYYMMDDHHMMSS')) |
|
|
|
).length===0 |
|
|
|
}) |
|
|
|
const obj = {}; |
|
|
|
data.map((i)=>{ |
|
|
|
if(obj[i.pointId]){ |
|
|
|
obj[i.pointId] = {name:i.points.itemData.name,count:obj[i.pointId].count+1} |
|
|
|
// return ({name:i.points.itemData.name,count:obj[i.pointId].count+1})
|
|
|
|
|
|
|
|
} |
|
|
|
else{ |
|
|
|
obj[i.pointId] = {name:i.points.itemData.name,count:1} |
|
|
|
} |
|
|
|
}) |
|
|
|
console.log(data,'data') |
|
|
|
const dd= Object.keys(obj).map(i=>{ |
|
|
|
return ({item:obj[i].name,count:obj[i].count}) |
|
|
|
}) |
|
|
|
console.log(obj,'obj') |
|
|
|
this.setState({ |
|
|
|
alarmList:dd |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
render() { |
|
|
|
const { height } = this.props; |
|
|
|
const { alarmList } = this.state; |
|
|
|
let max = null, content = null; |
|
|
|
let data = alarmList.sort((a, b) => b.count - a.count); |
|
|
|
max = data[0].count; |
|
|
|
let data = alarmList.sort((a, b) => b?.count - a?.count); |
|
|
|
max = data[0]?.count; |
|
|
|
// console.log(alarmList,'alarmList')
|
|
|
|
content = <div style={{ padding: '0px 10px 30px 30px' }}> |
|
|
|
{ |
|
|
|
alarmList.map((wd, i) => { |
|
|
@ -56,5 +94,13 @@ class AlarmStatistics extends Component { |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export default AlarmStatistics; |
|
|
|
function mapStateToProps (state) { |
|
|
|
const { auth, global ,depUser} = state |
|
|
|
return { |
|
|
|
user: auth.user, |
|
|
|
actions: global.actions, |
|
|
|
depUser: depUser.data || [], |
|
|
|
} |
|
|
|
} |
|
|
|
export default connect(mapStateToProps)(AlarmStatistics); |
|
|
|
// export default AlarmStatistics;
|