context.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107
  1. 'use strict';
  2. const dateRange = require('../util/dateRange');
  3. const utils = require('../util/utils');
  4. module.exports = {
  5. kv: {
  6. mileageCnt: {
  7. 0: '0-30',
  8. 30: '30-60',
  9. 60: '60-90',
  10. 90: '90-120',
  11. 120: '120以上(次)',
  12. },
  13. mileageCntMonth: {
  14. 0: '0-30',
  15. 30: '30-60',
  16. 60: '60-90',
  17. 90: '90-120',
  18. 120: '120以上(次)',
  19. },
  20. mileageCntYear: {
  21. 0: '0-300',
  22. 300: '300-600',
  23. 600: '600-900',
  24. 900: '900-1200',
  25. 1200: '1200以上(次)',
  26. },
  27. mileage: {
  28. 0: '0-50',
  29. 50: '50-100',
  30. 100: '100-300',
  31. 300: '300-500',
  32. 500: '500-1000',
  33. 1000: '1000-1500',
  34. 1500: '1500-20000',
  35. 20000: '20000以上',
  36. },
  37. mileageMonth: {
  38. 0: '0-500',
  39. 500: '500-1000',
  40. 1000: '1000-1500',
  41. 1500: '1500-2000',
  42. 2000: '2000-3000',
  43. 3000: '3000-4000',
  44. 4000: '4000-5000',
  45. 5000: '5000以上',
  46. },
  47. mileageYear: {
  48. 0: '0-0.5万',
  49. 5000: '0.5-1万',
  50. 10000: '1万-1.5万',
  51. 15000: '1.5-2万',
  52. 20000: '2万-3万',
  53. 30000: '3万-4万',
  54. 40000: '4万-5万',
  55. 50000: '5万以上',
  56. },
  57. supplementaryCnt: {
  58. 0: '无补传',
  59. 1: '1-20次',
  60. 20: '20-30次',
  61. 30: '30-40次',
  62. 40: '40-50次',
  63. 50: '50次以上',
  64. },
  65. batterySoc: {
  66. 0: '60%以下',
  67. 60: '60%-70%',
  68. 70: '70%-80%',
  69. 80: '80%-90%',
  70. 90: '90%-100%',
  71. },
  72. engineSpeed: {
  73. 0: '2000rpm以下',
  74. 2000: '2000-3000rpm',
  75. 3000: '3000-4000rpm',
  76. 4000: '4000-5000rpm',
  77. 5000: '5000rpm以上',
  78. },
  79. insideTemperature: {
  80. '-1000': '30°C以下',
  81. 30: '30-35°C',
  82. 35: '35-40°C',
  83. 40: '40-45°C',
  84. 45: '45-50°C',
  85. },
  86. outsideTemperature: {
  87. '-1000': '0°C以下',
  88. 0: '0-10°C',
  89. 10: '10-20°C',
  90. 20: '20-30°C',
  91. 30: '30°C以上',
  92. },
  93. powerBatterySoc: {
  94. 0: '60%以下',
  95. 60: '60%-70%',
  96. 70: '70%-80%',
  97. 80: '80%-90%',
  98. 90: '90%-100%',
  99. },
  100. chargeDuration: {
  101. 0: '1h以下',
  102. 1: '1h-2h',
  103. 2: '2h-3h',
  104. 3: '3h-4h',
  105. 4: '4h以上',
  106. },
  107. chargeStartSoc: {
  108. 0: '0-10',
  109. 10: '10-20',
  110. 20: '20-30',
  111. 30: '30-40',
  112. 40: '40-50',
  113. 50: '50-60',
  114. 60: '60-70',
  115. 70: '70-80',
  116. 80: '80-90',
  117. 90: '90-100',
  118. },
  119. chargeEndSoc: {
  120. 0: '0-10',
  121. 10: '10-20',
  122. 20: '20-30',
  123. 30: '30-40',
  124. 40: '40-50',
  125. 50: '50-60',
  126. 60: '60-70',
  127. 70: '70-80',
  128. 80: '80-90',
  129. 90: '90-100',
  130. },
  131. chargePreStartMileage: {
  132. 0: '0-50',
  133. 50: '50-100',
  134. 100: '100-150',
  135. 150: '150-200',
  136. 200: '200-250',
  137. 250: '250-300',
  138. 300: '300-350',
  139. 350: '350-400',
  140. },
  141. chargeStartTime: {
  142. 0: '0:00-1:00',
  143. 1: '1:00-2:00',
  144. 2: '2:00-3:00',
  145. 3: '3:00-4:00',
  146. 4: '4:00-5:00',
  147. 5: '5:00-6:00',
  148. 6: '6:00-7:00',
  149. 7: '7:00-8:00',
  150. 8: '8:00-9:00',
  151. 9: '9:00-10:00',
  152. 10: '10:00-11:00',
  153. 11: '11:00-12:00',
  154. 12: '12:00-13:00',
  155. 13: '13:00-14:00',
  156. 14: '14:00-15:00',
  157. 15: '15:00-16:00',
  158. 16: '16:00-17:00',
  159. 17: '17:00-18:00',
  160. 18: '18:00-19:00',
  161. 19: '19:00-20:00',
  162. 20: '20:00-21:00',
  163. 21: '21:00-22:00',
  164. 22: '22:00-23:00',
  165. 23: '23:00-0:00',
  166. },
  167. chargeMileage: {
  168. 0: '0-50km',
  169. 50: '50-100km',
  170. 100: '100-150km',
  171. 150: '150-200km',
  172. 200: '200-250km',
  173. 250: '250-300km',
  174. 300: '300km以上',
  175. },
  176. avgSpeedPower: {
  177. 0: '0-10',
  178. 10: '10-20',
  179. 20: '20-30',
  180. 30: '30-40',
  181. 40: '40-50',
  182. 50: '50-60',
  183. 60: '60-70',
  184. 70: '70-80',
  185. 80: '80-90',
  186. 90: '90-100',
  187. 100: '100-110',
  188. 110: '110-120',
  189. 120: '120以上',
  190. },
  191. actualMileage: {
  192. 0: '100以下',
  193. 100: '100-120',
  194. 120: '120-140',
  195. 140: '140-160',
  196. 160: '160-180',
  197. 180: '180-200',
  198. 200: '200-220',
  199. 220: '220-240',
  200. 240: '240-260',
  201. 260: '260-280',
  202. 280: '280-300',
  203. 300: '300以上',
  204. },
  205. chargeCnt: {
  206. 0: '50次以下',
  207. 50: '50-100次',
  208. 100: '100-150次',
  209. 150: '150-200次',
  210. 200: '200次以上',
  211. },
  212. chargeCntMonth: {
  213. 0: '0-5次',
  214. 5: '5-10次',
  215. 10: '10-15次',
  216. 15: '15-20次',
  217. 20: '20次以上',
  218. },
  219. chargeCntYear: {
  220. 0: '50次以下',
  221. 50: '50-100次',
  222. 100: '100-150次',
  223. 150: '150-200次',
  224. 200: '200次以上',
  225. },
  226. skyDuration: {
  227. 0: '0-30min',
  228. 30: '30-60min',
  229. 60: '60-120min',
  230. 120: '120-180min',
  231. 180: '180min以上',
  232. },
  233. skyDurationMonth:{
  234. 0: '0-0.5h',
  235. 0.5: '0.5-1h',
  236. 1: '1-2h',
  237. 2: '2-3h',
  238. 3: '3h以上',
  239. },
  240. skyDurationYear:{
  241. 0: '0-5h',
  242. 5: '5-10h',
  243. 10: '10-20h',
  244. 20: '20-30h',
  245. 30: '30h以上',
  246. },
  247. headlightCnt: {
  248. 0: '0-30次',
  249. 30: '30-60次',
  250. 60: '60-90次',
  251. 90: '90-120次',
  252. 120: '120-150次',
  253. 150: '150-180次',
  254. 180: '180-210次',
  255. 210: '210-240次',
  256. 240: '240-270次',
  257. 270: '270-300次',
  258. 300: '300次以上',
  259. },
  260. headlightCntMonth: {
  261. 0: '0-30次',
  262. 30: '30-60次',
  263. 60: '60-90次',
  264. 90: '90-120次',
  265. 120: '120-150次',
  266. 150: '150-180次',
  267. 180: '180-210次',
  268. 210: '210-240次',
  269. 240: '240-270次',
  270. 270: '270-300次',
  271. 300: '300次以上',
  272. },
  273. headlightCntYear: {
  274. 0: '0-300次',
  275. 300: '300-600次',
  276. 600: '600-900次',
  277. 900: '900-1200次',
  278. 1200: '1200-1500次',
  279. 1500: '1500-1800次',
  280. 1800: '1800-2100次',
  281. 2100: '2100-2400次',
  282. 2400: '2400-2700次',
  283. 2700: '2700-3000次',
  284. 3000: '3000次以上',
  285. },
  286. headlightDuration: {
  287. 0: '0-0.5min',
  288. 0.5: '0.5-1min',
  289. 1: '1-3min',
  290. 3: '3-5min',
  291. 5: '5-8min',
  292. 8: '8-10min',
  293. 10: '10-15min',
  294. 15: '15-20min',
  295. 20: '20-25min',
  296. 25: '25-30min',
  297. 30: '30-40min',
  298. 40: '40-50min',
  299. 50: '50min以上',
  300. },
  301. headlightDurationMonth:{
  302. 0: '0-0.5h',
  303. 0.5: '0.5-1h',
  304. 1: '1-1.5h',
  305. 1.5: '1.5-2h',
  306. 2: '2-2.5h',
  307. 2.5: '2.5-3h',
  308. 3: '3-3.5h',
  309. 3.5: '3.5-4h',
  310. 4: '4-4.5h',
  311. 4.5: '4.5-5h',
  312. 5: '5-5.5h',
  313. 5.5: '5.5-6h',
  314. 6: '6h以上',
  315. },
  316. headlightDurationYear:{
  317. 0: '0-5h',
  318. 5: '5-10h',
  319. 10: '10-15h',
  320. 15: '15-20h',
  321. 20: '20-25h',
  322. 25: '25-30h',
  323. 30: '30-35h',
  324. 35: '35-40h',
  325. 40: '40-45h',
  326. 45: '45-50h',
  327. 50: '50-55h',
  328. 55: '55-60h',
  329. 60: '60h以上',
  330. },
  331. highBeamCnt: {
  332. 0: '0-30次',
  333. 30: '30-60次',
  334. 60: '60-90次',
  335. 90: '90-120次',
  336. 120: '120-150次',
  337. 150: '150-180次',
  338. 180: '180-210次',
  339. 210: '210-240次',
  340. 240: '240-270次',
  341. 270: '270-300次',
  342. 300: '300次以上',
  343. },
  344. highBeamCntMonth:{
  345. 0: '0-10次',
  346. 10: '10-20次',
  347. 20: '20-30次',
  348. 30: '30-40次',
  349. 40: '40-50次',
  350. 50: '50-60次',
  351. 60: '60-70次',
  352. 70: '70-80次',
  353. 80: '80-90次',
  354. 90: '90-100次',
  355. 100: '100次以上',
  356. },
  357. highBeamCntYear:{
  358. 0: '0-100次',
  359. 100: '100-200次',
  360. 200: '200-300次',
  361. 300: '300-400次',
  362. 400: '400-500次',
  363. 500: '500-600次',
  364. 600: '600-700次',
  365. 700: '700-800次',
  366. 800: '800-900次',
  367. 900: '900-1000次',
  368. 1000: '1000次以上',
  369. },
  370. highBeamDuration: {
  371. 0: '0-0.5min',
  372. 0.5: '0.5-1min',
  373. 1: '1-3min',
  374. 3: '3-5min',
  375. 5: '5-8min',
  376. 8: '8-10min',
  377. 10: '10-15min',
  378. 15: '15-20min',
  379. 20: '20-25min',
  380. 25: '25-30min',
  381. 30: '30-40min',
  382. 40: '40-50min',
  383. 50: '50min以上',
  384. },
  385. highBeamDurationMonth:{
  386. 0: '0-0.5h',
  387. 0.5: '0.5-1h',
  388. 1: '1-1.5h',
  389. 1.5: '1.5-2h',
  390. 2: '2-2.5h',
  391. 2.5: '2.5-3h',
  392. 3: '3-3.5h',
  393. 3.5: '3.5-4h',
  394. 4: '4-4.5h',
  395. 4.5: '4.5-5h',
  396. 5: '5-5.5h',
  397. 5.5: '5.5-6h',
  398. 6: '6h以上',
  399. },
  400. highBeamDurationYear:{
  401. 0: '0-5h',
  402. 5: '5-10h',
  403. 10: '10-15h',
  404. 15: '15-20h',
  405. 20: '20-25h',
  406. 25: '25-30h',
  407. 30: '30-35h',
  408. 35: '35-40h',
  409. 40: '40-45h',
  410. 45: '45-50h',
  411. 50: '50-55h',
  412. 55: '55-60h',
  413. 60: '60h以上',
  414. },
  415. mileageSingle: {
  416. 0: '0-10',
  417. 10: '10-20',
  418. 20: '20-30',
  419. 30: '30-40',
  420. 40: '40-50',
  421. },
  422. statsAcceCnt: {
  423. 1: '0-10%',
  424. 2: '10-20%',
  425. 3: '20-30%',
  426. 4: '30-40%',
  427. 5: '40-50%',
  428. 6: '50-60%',
  429. 7: '60-70%',
  430. 8: '70-80%',
  431. 9: '80-90%',
  432. 10: '90-100%',
  433. },
  434. statsSpRange: {
  435. 1: '0-10km/h',
  436. 2: '10-20km/h',
  437. 3: '20-30km/h',
  438. 4: '30-40km/h',
  439. 5: '40-50km/h',
  440. 6: '50-60km/h',
  441. 7: '60-70km/h',
  442. 8: '70-80km/h',
  443. 9: '80-90km/h',
  444. 10: '90-100km/h',
  445. 11: '100-110km/h',
  446. 12: '110-120km/h',
  447. 13: '120km/h以上',
  448. },
  449. spPowerConsumption: {
  450. 1: '0-10km/h',
  451. 2: '10-20km/h',
  452. 3: '20-30km/h',
  453. 4: '30-40km/h',
  454. 5: '40-50km/h',
  455. 6: '50-60km/h',
  456. 7: '60-70km/h',
  457. 8: '70-80km/h',
  458. 9: '80-90km/h',
  459. 10: '90-100km/h',
  460. 11: '100-110km/h',
  461. 12: '110-120km/h',
  462. 13: '120km/h以上',
  463. },
  464. statsDece: {
  465. 1: '0-0.04g',
  466. 2: '0.04-0.08g',
  467. 3: '0.08-0.12g',
  468. 4: '0.12-0.16g',
  469. 5: '0.16-0.2g',
  470. 6: '0.2-0.24g',
  471. 7: '0.24-0.28g',
  472. 8: '0.28-0.32g',
  473. 9: '0.32-0.36g',
  474. 10: '0.36-0.4g',
  475. },
  476. statsRotate: {
  477. 1: '3-10deg',
  478. 2: '10-50deg',
  479. 3: '50-100deg',
  480. 4: '100-200deg',
  481. 5: '200-300deg',
  482. 6: '300-400deg',
  483. 7: '400-500deg',
  484. 8: '500-550deg',
  485. },
  486. dece: {
  487. 0: '0-0.04',
  488. 1: '0.04-0.08',
  489. 2: '0.08-0.12',
  490. 3: '0.12-0.16',
  491. 4: '0.16-0.20',
  492. 5: '0.2-0.24',
  493. 6: '0.24-0.28',
  494. 7: '0.28-0.32',
  495. 8: '0.32-0.36',
  496. 9: '0.36-0.4',
  497. },
  498. statsSpRotate: {
  499. 1: '3-10deg',
  500. 2: '10-50deg',
  501. 3: '50-100deg',
  502. 4: '100-200deg',
  503. 5: '200-300deg',
  504. 6: '300-400deg',
  505. 7: '400-500deg',
  506. 8: '500-550deg',
  507. },
  508. maxAcce: {
  509. 0: '0-0.05g',
  510. 0.05: '0.05-0.1g',
  511. 0.1: '0.1-0.15g',
  512. 0.15: '0.15-0.2g',
  513. 0.2: '0.2-0.25g',
  514. 0.25: '0.25-0.3g',
  515. 0.3: '0.3-0.35g',
  516. 0.35: '0.35-0.4g',
  517. 0.4: '0.4-0.45g',
  518. 0.45: '0.45-0.5g',
  519. },
  520. yawPortraitAcces: {
  521. 1: '0-0.05g',
  522. 2: '0.05-0.1g',
  523. 3: '0.1-0.15g',
  524. 4: '0.15-0.2g',
  525. 5: '0.2-0.25g',
  526. 6: '0.25-0.3g',
  527. 7: '0.3-0.35g',
  528. 8: '0.35-0.4g',
  529. 9: '0.4-0.45g',
  530. 10: '0.45-0.5g',
  531. },
  532. sidePortraitAcces: {
  533. 1: '0-0.05g',
  534. 2: '0.05-0.1g',
  535. 3: '0.1-0.15g',
  536. 4: '0.15-0.2g',
  537. 5: '0.2-0.25g',
  538. 6: '0.25-0.3g',
  539. 7: '0.3-0.35g',
  540. 8: '0.35-0.4g',
  541. 9: '0.4-0.45g',
  542. 10: '0.45-0.5g',
  543. },
  544. maxDece: {
  545. 0: '0-0.05g',
  546. 0.05: '0.05-0.1g',
  547. 0.1: '0.1-0.15g',
  548. 0.15: '0.15-0.2g',
  549. 0.2: '0.2-0.25g',
  550. 0.25: '0.25-0.3g',
  551. 0.3: '0.3-0.35g',
  552. 0.35: '0.35-0.4g',
  553. 0.4: '0.4-0.45g',
  554. 0.45: '0.45-0.5g',
  555. 0.5: '0.5-0.55g',
  556. 0.55: '0.55-0.6g',
  557. 0.6: '0.6-0.65g',
  558. 0.65: '0.65-0.7g',
  559. 0.7: '0.7-0.75g',
  560. 0.75: '0.75-0.8g',
  561. },
  562. statsDeceOther: {
  563. 1: '0-0.05g',
  564. 2: '0.05-0.1g',
  565. 3: '0.1-0.15g',
  566. 4: '0.15-0.2g',
  567. 5: '0.2-0.25g',
  568. 6: '0.25-0.3g',
  569. 7: '0.3-0.35g',
  570. 8: '0.35-0.4g',
  571. 9: '0.4-0.45g',
  572. 10: '0.45-0.5g',
  573. 11: '0.5-0.55g',
  574. 12: '0.55-0.6g',
  575. 13: '0.6-0.65g',
  576. 14: '0.65-0.7g',
  577. 15: '0.7-0.75g',
  578. 16: '0.75-0.8g',
  579. },
  580. sideAcce: {
  581. 0: '0-0.05g',
  582. 0.05: '0.05-0.1g',
  583. 0.1: '0.1-0.15g',
  584. 0.15: '0.15-0.2g',
  585. 0.2: '0.2-0.25g',
  586. 0.25: '0.25-0.3g',
  587. 0.3: '0.3-0.35g',
  588. 0.35: '0.35-0.4g',
  589. 0.4: '0.4-0.45g',
  590. 0.45: '0.45-0.5g',
  591. },
  592. statsHighSp: {
  593. 1: '80-100km/h',
  594. 2: '100-120km/h',
  595. 3: '120km/h以上',
  596. },
  597. statsStartSp: {
  598. 1: '0-5km/h',
  599. 2: '5-10km/h',
  600. 3: '10-15km/h',
  601. 4: '15-20km/h',
  602. 5: '20-25km/h',
  603. 6: '25-30km/h',
  604. 7: '30-35km/h',
  605. 8: '35-40km/h',
  606. 9: '40-45km/h',
  607. 10: '45-50km/h',
  608. 11: '50-55km/h',
  609. 12: '55-60km/h',
  610. 13: '60-65km/h',
  611. 14: '65-70km/h',
  612. },
  613. },
  614. kv2: {
  615. mileageCnt2: {
  616. 1: '1',
  617. 2: '2',
  618. 3: '3',
  619. 4: '4',
  620. 5: '5',
  621. 6: '6',
  622. 7: '7以上',
  623. },
  624. avgSpeed: {
  625. 0: '0-20',
  626. 20: '20-30min',
  627. 30: '30-40min',
  628. 40: '40-50min',
  629. 50: '50以上',
  630. },
  631. mileage: {
  632. 0: '0-50',
  633. 50: '50-100',
  634. 100: '100-300',
  635. 300: '300-500',
  636. 500: '500-1000',
  637. 1000: '1000-1500',
  638. 1500: '1500-20000',
  639. 20000: '20000以上',
  640. },
  641. mileage2: {
  642. 0: '0-5',
  643. 5: '5-10',
  644. 10: '10-20',
  645. 20: '20-30',
  646. 30: '30-50',
  647. 50: '50-100',
  648. 100: '100-200',
  649. 200: '200以上',
  650. },
  651. driveDuration: {
  652. 0: '0-1',
  653. 1: '1-2',
  654. 2: '2-3',
  655. 3: '3-4',
  656. 4: '4以上',
  657. },
  658. },
  659. getOnlineCount() {
  660. return {
  661. count: utils.randomNumC(),
  662. offlineCount: utils.randomNumC(),
  663. saledCount: utils.randomNumC(),
  664. };
  665. },
  666. get3D(x, y) {
  667. const arry = [];
  668. for (let i = 0; i < x; i++) {
  669. for (let j = 0; j < y; j++) {
  670. arry.push([ i, j, utils.randomNumC() ]);
  671. }
  672. }
  673. return arry;
  674. },
  675. getBehavior(str) {
  676. return [
  677. { _id: 5001, behavior_name: '系统行为' },
  678. { _id: 6001, behavior_name: '登录注册' },
  679. { _id: 6002, behavior_name: '扫一扫' },
  680. { _id: 6004, behavior_name: '行车记录仪' },
  681. { _id: 6007, behavior_name: '电子围栏' },
  682. { _id: 6008, behavior_name: '出行' },
  683. { _id: 6010, behavior_name: '车况查询' },
  684. { _id: 6011, behavior_name: '快递到车' },
  685. { _id: 6012, behavior_name: '驾驶行为分析' },
  686. { _id: 6013, behavior_name: '车辆服务' },
  687. { _id: 6014, behavior_name: '消息中心' },
  688. { _id: 6015, behavior_name: '应用信息' },
  689. { _id: 6017, behavior_name: '个人信息' },
  690. { _id: 6018, behavior_name: '设置' },
  691. { _id: 6019, behavior_name: '我的爱车' },
  692. { _id: 6020, behavior_name: '出车泊车' },
  693. { _id: 6022, behavior_name: '后台运行' },
  694. ].map(item => {
  695. const obj = { _id: item._id };
  696. obj[str] = utils.randomNumC();
  697. return obj;
  698. });
  699. },
  700. getAppExt() {
  701. return {
  702. countMonth: utils.randomNumC(),
  703. countPreMonth: utils.randomNumC(),
  704. durationMonth: utils.randomNumC(),
  705. durationPreMonth: utils.randomNumC(),
  706. };
  707. },
  708. getAuto() {
  709. const array = [];
  710. for (let i = 0; i < 18; i++) {
  711. const num = utils.randomNumC();
  712. const num2 = num + utils.randomNumC();
  713. array.push({
  714. _id: i,
  715. count: num2,
  716. name: '远程配置' + i,
  717. failCount: num,
  718. });
  719. }
  720. return array;
  721. },
  722. getBehaviorExt() {
  723. return {
  724. fwMaxMonth: {
  725. _id: {
  726. month: 12,
  727. year: 2019,
  728. },
  729. count: utils.randomNumC(),
  730. },
  731. fwMaxYear: {
  732. _id: {
  733. month: 12,
  734. year: 2019,
  735. },
  736. count: utils.randomNumC(),
  737. },
  738. fwMinMonth: {
  739. _id: {
  740. month: 12,
  741. year: 2019,
  742. },
  743. count: utils.randomNumC(),
  744. },
  745. fwMinYear: {
  746. _id: {
  747. month: 12,
  748. year: 2019,
  749. },
  750. count: utils.randomNumC(),
  751. },
  752. musicMaxMonth: {
  753. _id: {
  754. month: 12,
  755. year: 2019,
  756. },
  757. count: utils.randomNumC(),
  758. },
  759. musicMaxYear: {
  760. _id: {
  761. month: 12,
  762. year: 2019,
  763. },
  764. count: utils.randomNumC(),
  765. },
  766. musicMinMonth: {
  767. _id: {
  768. month: 12,
  769. year: 2019,
  770. },
  771. count: utils.randomNumC(),
  772. },
  773. musicMinYear: {
  774. _id: {
  775. month: 12,
  776. year: 2019,
  777. },
  778. count: utils.randomNumC(),
  779. },
  780. videoMaxMonth: {
  781. _id: {
  782. month: 12,
  783. year: 2019,
  784. },
  785. count: utils.randomNumC(),
  786. },
  787. videoMaxYear: {
  788. _id: {
  789. month: 12,
  790. year: 2019,
  791. },
  792. count: utils.randomNumC(),
  793. },
  794. videoMinMonth: {
  795. _id: {
  796. month: 12,
  797. year: 2019,
  798. },
  799. count: utils.randomNumC(),
  800. },
  801. videoMinYear: {
  802. _id: {
  803. month: 12,
  804. year: 2019,
  805. },
  806. count: utils.randomNumC(),
  807. },
  808. };
  809. },
  810. getUserInfo() {
  811. const array = [];
  812. for (let i = 0; i < 10; i++) {
  813. array.push({
  814. user_id: '396931284284211200',
  815. gender: 'M',
  816. id_card: '220104198602181856',
  817. user_mobileno: '13478799455',
  818. user_name: '测试人员',
  819. user_real_name: 'wyy',
  820. });
  821. }
  822. return {
  823. list: array,
  824. total: 20,
  825. };
  826. },
  827. getMapP(count = 100) {
  828. const points = [];
  829. for (let i = 0; i < count; i++) {
  830. const latitude = utils.randomNum(21, 53);
  831. const longitude = utils.randomNum(73, 135);
  832. points[i] = {
  833. _id: 'VIN' + latitude,
  834. latitude,
  835. longitude,
  836. ag: 0,
  837. sp: 10,
  838. tm: i == 0 ? 1598341206 : 30,
  839. };
  840. }
  841. return points;
  842. },
  843. getSaledCity() {
  844. const array = [];
  845. const areas = utils.getAreas();
  846. for (let i = 0; i < 3; i++) {
  847. const a = areas[utils.randomNumC() % 5];
  848. let p = a.provinces[utils.randomNumC() % 5];
  849. if (!p) {
  850. p = a.provinces[0];
  851. }
  852. let c = p.cities[utils.randomNumC() % 5];
  853. if (!c) {
  854. c = p.cities[0];
  855. }
  856. array.push(
  857. {
  858. city_name: c.city_name,
  859. count: utils.randomNumC(),
  860. provice_name: p.provice_name,
  861. }
  862. );
  863. }
  864. return array;
  865. },
  866. getSaled() {
  867. const areas = utils.getAreas();
  868. areas.forEach(item => {
  869. item.count = utils.randomNumC();
  870. item.provinces.forEach(p => {
  871. p.count = utils.randomNumC();
  872. p.cities.forEach(c => {
  873. c.count = utils.randomNumC();
  874. });
  875. });
  876. });
  877. return { areas, count: utils.randomNumC() };
  878. },
  879. getActiveExt() {
  880. return {
  881. maxMonth: {
  882. _id: {
  883. month: 12,
  884. year: 2019,
  885. },
  886. activeCount: utils.randomNumC(),
  887. },
  888. maxYear: {
  889. _id: {
  890. year: 2019,
  891. },
  892. activeCount: utils.randomNumC(),
  893. },
  894. };
  895. },
  896. getAir() {
  897. return {
  898. airDuration: utils.randomNumT(),
  899. blowerRatingFourDuration: utils.randomNumT(6),
  900. blowerRatingOneDuration: utils.randomNumT(6),
  901. blowerRatingOtherDuration: utils.randomNumT(6),
  902. blowerRatingThreeDuration: utils.randomNumT(6),
  903. blowerRatingTwoDuration: utils.randomNumT(6),
  904. offAutoDuration: utils.randomNumT(2),
  905. offCompressorDuration: utils.randomNumT(2),
  906. onAutoDuration: utils.randomNumT(2),
  907. onCompressorDuration: utils.randomNumT(2),
  908. };
  909. },
  910. getLevel(payload) {
  911. let data;
  912. switch (payload.level) {
  913. case 'province':
  914. data = utils.getPC().province.map(item => {
  915. return { name: item.name, count: utils.randomNumC() };
  916. }).sort((a, b) => b.count - a.count).slice(0, 10);
  917. break;
  918. case 'city':
  919. data = utils.getPC().city.map(item => {
  920. return { name: item.name, count: utils.randomNumC() };
  921. }).sort((a, b) => b.count - a.count).slice(0, 10);
  922. break;
  923. default:
  924. break;
  925. }
  926. return data;
  927. },
  928. getData(payload, config) {
  929. return dateRange.rangeTest(payload.startTime, payload.endTime, payload.type, config);
  930. },
  931. getDataAdd(payload, config) {
  932. return dateRange.rangeTestAdd(payload.startTime, payload.endTime, payload.type, config);
  933. },
  934. getSum(kv) {
  935. return Object.keys(kv).map(item => {
  936. return { _id: item, count: utils.randomNumC() };
  937. });
  938. },
  939. getSaledExt() {
  940. return {
  941. maxDay: {
  942. _id: {
  943. day: 12,
  944. month: 6,
  945. year: 2019,
  946. },
  947. count: utils.randomNumC(),
  948. },
  949. maxMonth: {
  950. _id: {
  951. month: 7,
  952. year: 2019,
  953. },
  954. count: utils.randomNumC(),
  955. },
  956. saledAppTotal: utils.randomNumC(),
  957. saledIviTotal: utils.randomNumC(),
  958. saledTotal: utils.randomNumC(),
  959. appTotal: utils.randomNumC(),
  960. iviTotal: utils.randomNumC(),
  961. };
  962. },
  963. getOnlineExt() {
  964. return {
  965. appYear: utils.randomNumC(),
  966. maxApp: {
  967. _id: {
  968. day: 18,
  969. month: 12,
  970. year: 2019,
  971. },
  972. count: utils.randomNumC(),
  973. },
  974. maxMonthTBox: {
  975. _id: {
  976. month: 12,
  977. year: 2019,
  978. },
  979. count: utils.randomNumC(),
  980. },
  981. maxTBox: {
  982. _id: {
  983. day: 19,
  984. month: 12,
  985. year: 2019,
  986. },
  987. count: utils.randomNumC(),
  988. },
  989. minApp: {
  990. _id: {
  991. day: 30,
  992. month: 3,
  993. year: 2019,
  994. },
  995. count: utils.randomNumC(),
  996. },
  997. minTBox: {
  998. _id: {
  999. day: 30,
  1000. month: 3,
  1001. year: 2019,
  1002. },
  1003. count: utils.randomNumC(),
  1004. },
  1005. tBoxYear: utils.randomNumC(),
  1006. };
  1007. },
  1008. getSex2Age() {
  1009. const list = Object.keys({
  1010. 18: '18-25岁',
  1011. 25: '25-30岁',
  1012. 30: '30-35岁',
  1013. 35: '35-40岁',
  1014. 40: '40岁以上(年龄)',
  1015. }).map(item => {
  1016. return { _id: item, mCount: utils.randomNumC(), fCount: utils.randomNumC(), count: utils.randomNumC() };
  1017. });
  1018. return {list,time:'2020-09-01'}
  1019. },
  1020. getArea() {
  1021. const areas = utils.getAreas();
  1022. areas.forEach(item => {
  1023. item.count = utils.randomNumC();
  1024. item.provinces.forEach(p => {
  1025. p.count = utils.randomNumC();
  1026. p.cities.forEach(c => {
  1027. c.count = utils.randomNumC();
  1028. });
  1029. });
  1030. });
  1031. return {list:areas,time:'2020-09-01'};
  1032. },
  1033. getMix(payload, key) {
  1034. return dateRange.rangeTest2(payload.startTime, payload.endTime, payload.type, this.kv[key]);
  1035. },
  1036. getMix2(payload) {
  1037. return dateRange.rangeTest3(payload.startTime, payload.endTime, payload.type, {
  1038. 0: '0:00',
  1039. 1: '1:00',
  1040. 2: '2:00',
  1041. 3: '3:00',
  1042. 4: '4:00',
  1043. 5: '5:00',
  1044. 6: '6:00',
  1045. 7: '7:00',
  1046. 8: '8:00',
  1047. 9: '9:00',
  1048. 10: '10:00',
  1049. 11: '11:00',
  1050. 12: '12:00',
  1051. 13: '13:00',
  1052. 14: '14:00',
  1053. 15: '15:00',
  1054. 16: '16:00',
  1055. 17: '17:00',
  1056. 18: '18:00',
  1057. 19: '19:00',
  1058. 20: '20:00',
  1059. 21: '21:00',
  1060. 22: '22:00',
  1061. 23: '23:00',
  1062. });
  1063. },
  1064. getMix3(payload, key) {
  1065. return dateRange.rangeTest2(payload.startTime, payload.endTime, payload.type, this.kv2[key]);
  1066. },
  1067. // 通用验证规则
  1068. createCommonRule() {
  1069. return {
  1070. // { type: 'string', required: true, allowEmpty: false }
  1071. startTime: { type: 'number', min: 0 }, // 开始时间的时间戳 包含
  1072. endTime: { type: 'number', min: 0 }, // 结束时间的时间戳 不包含(客户端处理结束时间 下一日 ,下一月第一日 ,下一年第一日)
  1073. type: [ '0', '1', '2' ], // 类型分为 0日 1月 2年
  1074. };
  1075. },
  1076. validate(rules = this.createCommonRule(), data) {
  1077. data = data || this.query || this.request.body || {};
  1078. console.log('参数', data);
  1079. const errors = this.app.validator.validate(rules, data);
  1080. if (errors) {
  1081. this.throw(422, '参数校验失败', {
  1082. // code: 'invalid_param',
  1083. errors,
  1084. });
  1085. }
  1086. if (data.startTime && data.endTime && data.startTime > data.endTime) {
  1087. this.throw(400, '开始时间不能小于结束时间');
  1088. }
  1089. this.logger.debug('参数', data);
  1090. return data;
  1091. },
  1092. success({ data = null, msg = '请求成功' }) {
  1093. this.body = {
  1094. code: 0,
  1095. data,
  1096. msg,
  1097. };
  1098. this.status = 200;
  1099. },
  1100. };