Browse Source

数据在线率和中断排名数据定时更新

dev
wenlele 1 year ago
parent
commit
6bdde941af
  1. 162
      web/client/src/sections/projectGroup/containers/bigscreen.jsx

162
web/client/src/sections/projectGroup/containers/bigscreen.jsx

@ -34,6 +34,8 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou
useEffect(() => {
let groupId = JSON.parse(localStorage.getItem('project_group'))?.find(v => user?.id == v.userId)?.projectGroupId
statisticOnline(groupId)
//
timeRequest(groupId)
dispatch(actions.projectGroup.groupStatisticAlarm({ groupId })).then(res => {
if (res.success) {
setMockData(res.payload.data)
@ -63,86 +65,7 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou
}
}, [])
// const mockData=[
// {
// "name": "西",
// "id": 2957,
// "alarmCount": 6,
// "dealAlarmCount": 0
// },
// {
// "name": "-绿",
// "id": 2966,
// "alarmCount": 1,
// "dealAlarmCount": 0
// },
// {
// "name": "-绿",
// "id": 2967,
// "alarmCount": 3,
// "dealAlarmCount": 0
// },
// {
// "name": "",
// "id": 2973,
// "alarmCount": 0,
// "dealAlarmCount": 0
// },
// {
// "name": "",
// "id": 2975,
// "alarmCount": 0,
// "dealAlarmCount": 0
// },
// {
// "name": "",
// "id": 2977,
// "alarmCount": 0,
// "dealAlarmCount": 0
// },
// {
// "name": "",
// "id": 2988,
// "alarmCount": 0,
// "dealAlarmCount": 0
// },
// {
// "name": "",
// "id": 3004,
// "alarmCount": 0,
// "dealAlarmCount": 0
// },
// {
// "name": "驿",
// "id": 3007,
// "alarmCount": 0,
// "dealAlarmCount": 0
// },
// {
// "name": "",
// "id": 3004,
// "alarmCount": 0,
// "dealAlarmCount": 0
// },
// {
// "name": "驿",
// "id": 3007,
// "alarmCount": 0,
// "dealAlarmCount": 0
// },
// {
// "name": "",
// "id": 3004,
// "alarmCount": 0,
// "dealAlarmCount": 0
// },
// {
// "name": "驿",
// "id": 3007,
// "alarmCount": 0,
// "dealAlarmCount": 0
// },
// ]
useEffect(() => {
const overview = document.getElementById("alarmRank");
if (overview) {
@ -192,31 +115,6 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou
}
}, [mockData])
// const mockData=[
// {id: 1,name: '',alarmCount: 200,dealAlarmCount: 23},
// {id: 2,name: '2',alarmCount: 300,dealAlarmCount: 22},
// {id: 3,name: '3',alarmCount: 140,dealAlarmCount: 21},
// {id: 4,name: '4',alarmCount: 120,dealAlarmCount: 23},
// {id: 5,name: '5',alarmCount: 110,dealAlarmCount: 22},
// {id: 6,name: '6',alarmCount: 109,dealAlarmCount: 21},
// {id: 7,name: '7',alarmCount: 100,dealAlarmCount: 23},
// {id: 8,name: '8',alarmCount: 99,dealAlarmCount: 22},
// {id: 9,name: '9',alarmCount: 98,dealAlarmCount: 21},
// {id: 10,name: '10',alarmCount: 97,dealAlarmCount: 23},
// {id: 11,name: '11',alarmCount: 96,dealAlarmCount: 22},
// {id: 12,name: '12',alarmCount: 95,dealAlarmCount: 21},
// {id: 13,name: '13',alarmCount: 100,dealAlarmCount: 23},
// {id: 14,name: '14',alarmCount: 49,dealAlarmCount: 22},
// {id: 15,name: '15',alarmCount: 48,dealAlarmCount: 21},
// {id: 16,name: '16',alarmCount: 47,dealAlarmCount: 23},
// {id: 17,name: '17',alarmCount: 46,dealAlarmCount: 22},
// {id: 18,name: '18',alarmCount: 45,dealAlarmCount: 21},
// {id: 19,name: '19',alarmCount: 30,dealAlarmCount: 22},
// {id: 20,name: '20',alarmCount: 29,dealAlarmCount: 21},
// {id: 21,name: '21',alarmCount: 28,dealAlarmCount: 23},
// {id: 22,name: '22',alarmCount: 27,dealAlarmCount: 22},
// {id: 23,name: '23',alarmCount: 26,dealAlarmCount: 21},
// ]
let statisticOnline = (groupId) => {
dispatch(actions.projectGroup.groupStatisticOnline({ groupId })).then(res => {
if (res.success) {
@ -230,53 +128,21 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou
setInterruptRank(Interrupt)
setOnline(res.payload.data?.slice(0, 10) || [])
setValue(res.payload.data?.map(v => v.id)?.slice(0, 10) || [])
// eChartsData(res.payload.data || [], res.payload.data?.map(v => v.id) || [])
}
})
}
// const eChartsData = (data, value) => {
// //
// let timeNodes = getTimeNodes()
// let dataList = []
// data?.forEach(v => {
// if (value?.includes(v.id)) {
// v.timeNodes = []
// timeNodes?.forEach(s => {
// if (v.online?.find(d => moment(d.collect_time).format('YYYY-MM-DD HH') == s)?.structure) {
// v.timeNodes.push([s,])
// } else {
// v.timeNodes.push([s,null])
// }
// })
// }
// })
// }
function formatDate (date) {
var year = date.getFullYear();
var month = String(date.getMonth() + 1).padStart(2, '0');
var day = String(date.getDate()).padStart(2, '0');
var hour = String(date.getHours()).padStart(2, '0');
return year + '-' + month + '-' + day + ' ' + hour;
}
function getTimeNodes () {
var currentTime = new Date(); //
var timeNodes = [];
for (var i = 0; i < 24; i++) {
var timeNode = formatDate(currentTime);
timeNodes.push(timeNode);
currentTime.setHours(currentTime.getHours() - 1); // 1
}
return timeNodes;
const timeRequest = (groupId) => {
//
const currentTime = moment();
//
const nextHour = moment().add(1, 'hour').startOf('hour');
//
const minuteDifference = nextHour.diff(currentTime, 'minutes');
setTimeout(function () {
statisticOnline(groupId)
timeRequest(groupId)
}, 1000 * 60 * (minuteDifference + 1 || 61));
}

Loading…
Cancel
Save