clique.data.ts 4.6 KB

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