clique.data.ts 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. import dayjs from 'dayjs';
  2. import { cloneDeep } from 'lodash-es';
  3. export const getMaxY = function (param) {
  4. let maxval=0
  5. if (param.length == 1) {
  6. maxval = Math.max(...param[0]);
  7. } else if (param.length == 2) {
  8. const max1 = Math.max(...param[0]);
  9. const max2 = Math.max(...param[1]);
  10. maxval = Math.max(max1,max2)
  11. } else if (param.length == 3) {
  12. const max1 = Math.max(...param[0]);
  13. const max2 = Math.max(...param[1]);
  14. const max3 = Math.max(...param[2]);
  15. maxval=Math.max(max1,max2,max3)
  16. }
  17. let yMax = (maxval * 1.6).toFixed(0);
  18. return yMax
  19. }
  20. export const getMinY = function (param) {
  21. let minval=0
  22. if (param.length == 1) {
  23. minval = Math.min(...param[0]);
  24. } else if (param.length == 2) {
  25. const min1 = Math.min(...param[0]);
  26. const min2 = Math.min(...param[1]);
  27. minval=Math.min(min1,min2)
  28. } else if (param.length == 3) {
  29. const min1 = Math.min(...param[0]);
  30. const min2 = Math.min(...param[1]);
  31. const min3 = Math.min(...param[2]);
  32. minval=Math.min(min1,min2,min3)
  33. }
  34. let yMin = (minval*0.7).toFixed(0);
  35. return yMin
  36. }
  37. export const airVolumeMonitorKey = [
  38. {
  39. code: 'name',
  40. value: '矿井名称',
  41. },
  42. {
  43. code: 'jin',
  44. value: '总进风量',
  45. },
  46. {
  47. code: 'hui',
  48. value: '总回风量',
  49. },
  50. {
  51. code: 'xufeng',
  52. value: '总需风量',
  53. },
  54. ];
  55. export const airVolumeMonitor = [
  56. {
  57. name: 'XXX',
  58. jin: 10215,
  59. hui: 10215,
  60. xufeng: 10215,
  61. },
  62. {
  63. name: 'XXX',
  64. jin: 10215,
  65. hui: 10215,
  66. xufeng: 10215,
  67. },
  68. {
  69. name: 'XXX',
  70. jin: 10215,
  71. hui: 10215,
  72. xufeng: 10215,
  73. },
  74. {
  75. name: 'XXX',
  76. jin: 10215,
  77. hui: 10215,
  78. xufeng: 10215,
  79. },
  80. {
  81. name: 'XXX',
  82. jin: 10215,
  83. hui: 10215,
  84. xufeng: 10215,
  85. },
  86. {
  87. name: 'XXX',
  88. jin: 10215,
  89. hui: 10215,
  90. xufeng: 10215,
  91. },
  92. {
  93. name: 'XXX',
  94. jin: 10215,
  95. hui: 10215,
  96. xufeng: 10215,
  97. },
  98. {
  99. name: 'XXX',
  100. jin: 10215,
  101. hui: 10215,
  102. xufeng: 10215,
  103. },
  104. {
  105. name: 'XXX',
  106. jin: 10215,
  107. hui: 10215,
  108. xufeng: 10215,
  109. },
  110. {
  111. name: 'XXX',
  112. jin: 10215,
  113. hui: 10215,
  114. xufeng: 10215,
  115. },
  116. {
  117. name: 'XXX',
  118. jin: 10215,
  119. hui: 10215,
  120. xufeng: 10215,
  121. },
  122. ];
  123. let latestData = [];
  124. let latestTime = 0;
  125. export function getDate(workData) {
  126. // debugger;
  127. if (workData.length <= 0) {
  128. return [];
  129. }
  130. const workTypeList = cloneDeep(workData);
  131. workData = latestData;
  132. const getTime = (val) => {
  133. const fiveSecondsAgo = dayjs().subtract(val, 'second');
  134. // 获取时分秒
  135. const hours = fiveSecondsAgo.hour();
  136. const minutes = fiveSecondsAgo.minute();
  137. const seconds = fiveSecondsAgo.second();
  138. return `${hours}:${minutes}:${seconds}`;
  139. };
  140. if (latestData.length == 0) {
  141. for (let j = 0; j < workTypeList.length; j++) {
  142. const itemData = {
  143. jin: '0',
  144. hui: '0',
  145. history: [],
  146. deviceName: workTypeList[j]['deviceName'],
  147. deviceID: workTypeList[j]['deviceID'],
  148. deviceType: 'sys_surface_caimei',
  149. };
  150. itemData['jin'] = (3403 + (Math.random() * 2 - 1 * 50)).toFixed(2);
  151. itemData['hui'] = (3424 + (Math.random() * 2 - 1 * 50)).toFixed(2);
  152. // 第一次模拟
  153. for (let i = 0; i < 5; i++) {
  154. const item = {
  155. jin: (3403 + (Math.random() * 2 - 1 * 50)).toFixed(2),
  156. hui: (3424 + (Math.random() * 2 - 1 * 50)).toFixed(2),
  157. time: getTime((i + 1) * 5),
  158. deviceName: workTypeList[j]['deviceName'],
  159. deviceID: workTypeList[j]['deviceID'],
  160. deviceType: 'sys_surface_caimei',
  161. };
  162. itemData['history'].unshift(item);
  163. }
  164. workData.push(itemData);
  165. }
  166. latestTime = new Date().getTime();
  167. } else {
  168. if (new Date().getTime() - latestTime >= 5000) {
  169. for (let j = 0; j < workTypeList.length; j++) {
  170. const now = dayjs(latestTime + 5000);
  171. // 获取时分秒
  172. const hours = now.hour() > 9 ? now.hour() : `0${now.hour()}`;
  173. const minutes = now.minute() > 9 ? now.minute() : `0${now.minute()}`;
  174. const seconds = now.second() > 9 ? now.second() : `0${now.second()}`;
  175. workData[j]['history'].shift();
  176. workData[j]['jin'] = (3403 + (Math.random() * 2 - 1 * 50)).toFixed(2);
  177. workData[j]['hui'] = (3424 + (Math.random() * 2 - 1 * 50)).toFixed(2);
  178. workData[j]['history'].push({
  179. jin: (3403 + (Math.random() * 2 - 1 * 50)).toFixed(2),
  180. hui: (3424 + (Math.random() * 2 - 1 * 50)).toFixed(2),
  181. time: `${hours}:${minutes}:${seconds}`,
  182. });
  183. }
  184. latestTime = new Date().getTime();
  185. }
  186. }
  187. latestData = workData;
  188. return workData;
  189. }