| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- import dayjs from 'dayjs';
- import { cloneDeep } from 'lodash-es';
- export const getMaxY = function (param) {
- let maxval=0
- if (param.length == 1) {
- maxval = Math.max(...param[0]);
- } else if (param.length == 2) {
- const max1 = Math.max(...param[0]);
- const max2 = Math.max(...param[1]);
- maxval = Math.max(max1,max2)
- } else if (param.length == 3) {
- const max1 = Math.max(...param[0]);
- const max2 = Math.max(...param[1]);
- const max3 = Math.max(...param[2]);
- maxval=Math.max(max1,max2,max3)
- }
- let yMax = (maxval * 1.6).toFixed(0);
- return yMax
- }
- export const getMinY = function (param) {
- let minval=0
- if (param.length == 1) {
- minval = Math.min(...param[0]);
- } else if (param.length == 2) {
- const min1 = Math.min(...param[0]);
- const min2 = Math.min(...param[1]);
- minval=Math.min(min1,min2)
- } else if (param.length == 3) {
- const min1 = Math.min(...param[0]);
- const min2 = Math.min(...param[1]);
- const min3 = Math.min(...param[2]);
- minval=Math.min(min1,min2,min3)
- }
- let yMin = (minval*0.7).toFixed(0);
- return yMin
- }
- export const airVolumeMonitorKey = [
- {
- code: 'name',
- value: '矿井名称',
- },
- {
- code: 'jin',
- value: '总进风量',
- },
- {
- code: 'hui',
- value: '总回风量',
- },
- {
- code: 'xufeng',
- value: '总需风量',
- },
- ];
- export const airVolumeMonitor = [
- {
- name: 'XXX',
- jin: 10215,
- hui: 10215,
- xufeng: 10215,
- },
- {
- name: 'XXX',
- jin: 10215,
- hui: 10215,
- xufeng: 10215,
- },
- {
- name: 'XXX',
- jin: 10215,
- hui: 10215,
- xufeng: 10215,
- },
- {
- name: 'XXX',
- jin: 10215,
- hui: 10215,
- xufeng: 10215,
- },
- {
- name: 'XXX',
- jin: 10215,
- hui: 10215,
- xufeng: 10215,
- },
- {
- name: 'XXX',
- jin: 10215,
- hui: 10215,
- xufeng: 10215,
- },
- {
- name: 'XXX',
- jin: 10215,
- hui: 10215,
- xufeng: 10215,
- },
- {
- name: 'XXX',
- jin: 10215,
- hui: 10215,
- xufeng: 10215,
- },
- {
- name: 'XXX',
- jin: 10215,
- hui: 10215,
- xufeng: 10215,
- },
- {
- name: 'XXX',
- jin: 10215,
- hui: 10215,
- xufeng: 10215,
- },
- {
- name: 'XXX',
- jin: 10215,
- hui: 10215,
- xufeng: 10215,
- },
- ];
- let latestData = [];
- let latestTime = 0;
- export function getDate(workData) {
- // debugger;
- if (workData.length <= 0) {
- return [];
- }
- const workTypeList = cloneDeep(workData);
- workData = latestData;
- const getTime = (val) => {
- const fiveSecondsAgo = dayjs().subtract(val, 'second');
- // 获取时分秒
- const hours = fiveSecondsAgo.hour();
- const minutes = fiveSecondsAgo.minute();
- const seconds = fiveSecondsAgo.second();
- return `${hours}:${minutes}:${seconds}`;
- };
- if (latestData.length == 0) {
- for (let j = 0; j < workTypeList.length; j++) {
- const itemData = {
- jin: '0',
- hui: '0',
- history: [],
- deviceName: workTypeList[j]['deviceName'],
- deviceID: workTypeList[j]['deviceID'],
- deviceType: 'sys_surface_caimei',
- };
- itemData['jin'] = (3403 + (Math.random() * 2 - 1 * 50)).toFixed(2);
- itemData['hui'] = (3424 + (Math.random() * 2 - 1 * 50)).toFixed(2);
- // 第一次模拟
- for (let i = 0; i < 5; i++) {
- const item = {
- jin: (3403 + (Math.random() * 2 - 1 * 50)).toFixed(2),
- hui: (3424 + (Math.random() * 2 - 1 * 50)).toFixed(2),
- time: getTime((i + 1) * 5),
- deviceName: workTypeList[j]['deviceName'],
- deviceID: workTypeList[j]['deviceID'],
- deviceType: 'sys_surface_caimei',
- };
- itemData['history'].unshift(item);
- }
- workData.push(itemData);
- }
- latestTime = new Date().getTime();
- } else {
- if (new Date().getTime() - latestTime >= 5000) {
- for (let j = 0; j < workTypeList.length; j++) {
- const now = dayjs(latestTime + 5000);
- // 获取时分秒
- const hours = now.hour() > 9 ? now.hour() : `0${now.hour()}`;
- const minutes = now.minute() > 9 ? now.minute() : `0${now.minute()}`;
- const seconds = now.second() > 9 ? now.second() : `0${now.second()}`;
- workData[j]['history'].shift();
- workData[j]['jin'] = (3403 + (Math.random() * 2 - 1 * 50)).toFixed(2);
- workData[j]['hui'] = (3424 + (Math.random() * 2 - 1 * 50)).toFixed(2);
- workData[j]['history'].push({
- jin: (3403 + (Math.random() * 2 - 1 * 50)).toFixed(2),
- hui: (3424 + (Math.random() * 2 - 1 * 50)).toFixed(2),
- time: `${hours}:${minutes}:${seconds}`,
- });
- }
- latestTime = new Date().getTime();
- }
- }
- latestData = workData;
- return workData;
- }
|