drivingBehaviorInfoModel2.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. 'use strict';
  2. module.exports = app => {
  3. const mongoose = app.mongoose;
  4. const Schema = mongoose.Schema;
  5. const conn = app.mongooseDB.get('etlLocalDB');
  6. // 驾驶行为数据结构 本地清洗 数据结构
  7. const DrivingBehaviorInfoSchema2 = new Schema({
  8. create_date: { type: Number }, // 统计的数据是哪一天的
  9. year: { type: Number }, // 年 统计的数据
  10. month: { type: Number }, // 月 统计的数据
  11. day: { type: Number }, // 日 统计的数据
  12. dateString: { type: String }, // 时间字符串 yyyy-MM-dd
  13. start_time: { type: Date }, // 开始统计时间
  14. end_time: { type: Date, default: Date.now }, // 结束统计时间
  15. data: [
  16. {
  17. _id: {
  18. series_code: { type: String }, model_code: { type: String },
  19. }, // 分组 车型 车系
  20. count: { type: Number }, // 有几辆车
  21. batterySoc: { type: Number }, // 蓄电池电量%
  22. engineSpeed: { type: Number }, // 发动机转速rpm
  23. insideTemperature: { type: Number }, // 室内温度°
  24. outsideTemperature: { type: Number }, // 室外温度°
  25. powerBatterySoc: { type: Number }, // 动力电池%
  26. chargeDuration: { type: Number }, // 充电时长h
  27. chargeCnt: { type: Number }, // 充电次数
  28. skyDuration: { type: Number }, // 天窗时长min
  29. headlightCnt: { type: Number }, // 近光次数
  30. highBeamCnt: { type: Number }, // 远光次数
  31. headlightDuration: { type: Number }, // 近光时长min
  32. highBeamDuration: { type: Number }, // 远光时长min
  33. airDuration: { type: Number }, // 空调使用时长(毫秒)
  34. onCompressorDuration: { type: Number }, // 空调状态和压缩机均打开使用时长(毫秒)
  35. offCompressorDuration: { type: Number }, // 空调状态开压缩机关使用时长(毫秒)
  36. onAutoDuration: { type: Number }, // 激活且空调开启时长(毫秒)
  37. offAutoDuration: { type: Number }, // 关闭且空调开启时长(毫秒)
  38. blowerRatingOneDuration: { type: Number }, // 吹风等级1时长(毫秒)
  39. blowerRatingTwoDuration: { type: Number }, // 吹风等级2时长(毫秒)
  40. blowerRatingThreeDuration: { type: Number }, // 吹风等级3时长(毫秒)
  41. blowerRatingFourDuration: { type: Number }, // 吹风等级4时长(毫秒)
  42. blowerRatingOtherDuration: { type: Number }, // 吹风等级其他时长(毫秒)
  43. dsmCnt: { type: Number }, // 疲劳驾驶次数
  44. atNightDriveCnt: { type: Number }, // 深夜出行次数
  45. atNightDriveDuration: { type: Number }, // 深夜出行时长h
  46. atNightDriveMileage: { type: Number }, // 深夜出行里程km
  47. morningPeakDuration: { type: Number }, // 早高峰时长h
  48. morningPeakMileage: { type: Number }, // 早高峰里程km
  49. eveningPeakDuration: { type: Number }, // 晚高峰时长h
  50. eveningPeakMileage: { type: Number }, // 晚高峰里程km
  51. },
  52. ],
  53. oilProvince: [{
  54. _id: {
  55. _id: { type: String }, // 省code
  56. series_code: { type: String }, model_code: { type: String },
  57. }, // 分组 车型 车系 和分段
  58. name: { type: String }, // 省名称
  59. oil: { type: Number }, // 总油耗
  60. mileage: { type: Number }, // 总公里
  61. }], // 油耗分布
  62. oilCity: [{
  63. _id: {
  64. _id: { type: String }, // 市code
  65. fid: { type: String }, // 省code
  66. series_code: { type: String }, model_code: { type: String },
  67. }, // 分组 车型 车系 和分段
  68. name: { type: String }, // 市名称
  69. oil: { type: Number }, // 总油耗
  70. mileage: { type: Number }, // 总公里
  71. }], // 油耗分布
  72. driveDuration: [
  73. {
  74. _id: {
  75. _id: { type: String },
  76. series_code: { type: String }, model_code: { type: String },
  77. }, // 分组 车型 车系 和分段
  78. count: { type: Number }, // 数量
  79. },
  80. ], // 驾驶时长
  81. avgSpeed: [
  82. {
  83. _id: {
  84. _id: { type: String },
  85. series_code: { type: String }, model_code: { type: String },
  86. }, // 分组 车型 车系 和分段
  87. count: { type: Number }, // 数量
  88. },
  89. ], // 平均车速
  90. mileageCnt2: [
  91. {
  92. _id: {
  93. _id: { type: String },
  94. series_code: { type: String }, model_code: { type: String },
  95. }, // 分组 车型 车系 和分段
  96. count: { type: Number }, // 数量
  97. },
  98. ], // 车辆行程次数 用于 周末和工作日统计
  99. mileage2: [
  100. {
  101. _id: {
  102. _id: { type: String },
  103. series_code: { type: String }, model_code: { type: String },
  104. }, // 分组 车型 车系 和分段
  105. count: { type: Number }, // 数量
  106. },
  107. ], // 日行驶里程
  108. mileageAvg: [
  109. {
  110. _id: {
  111. _id: { type: String },
  112. series_code: { type: String }, model_code: { type: String },
  113. }, // 分组 车型 车系 和分段
  114. count: { type: Number }, // 数量
  115. },
  116. ], // 平均行驶里程
  117. supplementaryCnt: [
  118. {
  119. _id: {
  120. _id: { type: String },
  121. series_code: { type: String }, model_code: { type: String },
  122. }, // 分组 车型 车系 和分段
  123. count: { type: Number }, // 数量
  124. },
  125. ], // 补传次数
  126. batterySoc: [
  127. {
  128. _id: {
  129. _id: { type: String },
  130. series_code: { type: String }, model_code: { type: String },
  131. }, // 分组 车型 车系 和分段
  132. count: { type: Number }, // 数量
  133. },
  134. ], // 蓄电池电量
  135. engineSpeed: [
  136. {
  137. _id: {
  138. _id: { type: String },
  139. series_code: { type: String }, model_code: { type: String },
  140. }, // 分组 车型 车系 和分段
  141. count: { type: Number }, // 数量
  142. },
  143. ], // 发动机转速
  144. insideTemperature: [
  145. {
  146. _id: {
  147. _id: { type: String },
  148. series_code: { type: String }, model_code: { type: String },
  149. }, // 分组 车型 车系 和分段
  150. count: { type: Number }, // 数量
  151. },
  152. ], // 室内温度
  153. outsideTemperature: [
  154. {
  155. _id: {
  156. _id: { type: String },
  157. series_code: { type: String }, model_code: { type: String },
  158. }, // 分组 车型 车系 和分段
  159. count: { type: Number }, // 数量
  160. },
  161. ], // 室外温度
  162. powerBatterySoc: [
  163. {
  164. _id: {
  165. _id: { type: String },
  166. series_code: { type: String }, model_code: { type: String },
  167. }, // 分组 车型 车系 和分段
  168. count: { type: Number }, // 数量
  169. },
  170. ], // 动力电池
  171. chargeDuration: [
  172. {
  173. _id: {
  174. _id: { type: String },
  175. series_code: { type: String }, model_code: { type: String },
  176. }, // 分组 车型 车系 和分段
  177. count: { type: Number }, // 数量
  178. },
  179. ], // 充电时长
  180. chargeStartSoc: [
  181. {
  182. _id: {
  183. _id: { type: String },
  184. series_code: { type: String }, model_code: { type: String },
  185. }, // 分组 车型 车系 和分段
  186. count: { type: Number }, // 数量
  187. },
  188. ], // 充电初始SOC
  189. chargeEndSoc: [
  190. {
  191. _id: {
  192. _id: { type: String },
  193. series_code: { type: String }, model_code: { type: String },
  194. }, // 分组 车型 车系 和分段
  195. count: { type: Number }, // 数量
  196. },
  197. ], // 充电结束SOC
  198. chargePreStartMileage: [
  199. {
  200. _id: {
  201. _id: { type: String },
  202. series_code: { type: String }, model_code: { type: String },
  203. }, // 分组 车型 车系 和分段
  204. count: { type: Number }, // 数量
  205. },
  206. ], // 充电时车辆可行驶里程
  207. chargeStartTime: [
  208. {
  209. _id: {
  210. _id: { type: String },
  211. series_code: { type: String }, model_code: { type: String },
  212. }, // 分组 车型 车系 和分段
  213. count: { type: Number }, // 数量
  214. },
  215. ], // 充电初始时刻
  216. chargeType: [
  217. {
  218. _id: {
  219. _id: { type: String },
  220. series_code: { type: String }, model_code: { type: String },
  221. }, // 分组 车型 车系 和分段
  222. count: { type: Number }, // 数量
  223. },
  224. ], // 充电模式分布
  225. chargeMileage: [
  226. {
  227. _id: {
  228. _id: { type: String },
  229. series_code: { type: String }, model_code: { type: String },
  230. }, // 分组 车型 车系 和分段
  231. count: { type: Number }, // 数量
  232. },
  233. ], // 两次充电间行驶里程分布
  234. avgSpeedPower: [
  235. {
  236. _id: {
  237. _id: { type: String },
  238. series_code: { type: String }, model_code: { type: String },
  239. }, // 分组 车型 车系 和分段
  240. count: { type: Number }, // 数量
  241. },
  242. ], // 不同车速区间耗电占比
  243. actualMileage: [
  244. {
  245. _id: {
  246. _id: { type: String },
  247. series_code: { type: String }, model_code: { type: String },
  248. }, // 分组 车型 车系 和分段
  249. count: { type: Number }, // 数量
  250. },
  251. ], // 实际续航里程分布
  252. mileageCnt: [
  253. {
  254. _id: {
  255. _id: { type: String },
  256. series_code: { type: String }, model_code: { type: String },
  257. }, // 分组 车型 车系 和分段
  258. count: { type: Number }, // 数量
  259. },
  260. ], // 车辆行程次数
  261. mileageCntMonth: [
  262. {
  263. _id: {
  264. _id: { type: String },
  265. series_code: { type: String }, model_code: { type: String },
  266. }, // 分组 车型 车系 和分段
  267. count: { type: Number }, // 数量
  268. },
  269. ], // 车辆行程月次数
  270. mileageCntYear: [
  271. {
  272. _id: {
  273. _id: { type: String },
  274. series_code: { type: String }, model_code: { type: String },
  275. }, // 分组 车型 车系 和分段
  276. count: { type: Number }, // 数量
  277. },
  278. ], // 车辆行程年次数
  279. mileage: [
  280. {
  281. _id: {
  282. _id: { type: String },
  283. series_code: { type: String }, model_code: { type: String },
  284. }, // 分组 车型 车系 和分段
  285. count: { type: Number }, // 数量
  286. },
  287. ], // 行驶里程
  288. mileageMonth: [
  289. {
  290. _id: {
  291. _id: { type: String },
  292. series_code: { type: String }, model_code: { type: String },
  293. }, // 分组 车型 车系 和分段
  294. count: { type: Number }, // 数量
  295. },
  296. ], // 月行驶里程
  297. mileageYear: [
  298. {
  299. _id: {
  300. _id: { type: String },
  301. series_code: { type: String }, model_code: { type: String },
  302. }, // 分组 车型 车系 和分段
  303. count: { type: Number }, // 数量
  304. },
  305. ], // 年行驶里程
  306. chargeCnt: [
  307. {
  308. _id: {
  309. _id: { type: String },
  310. series_code: { type: String }, model_code: { type: String },
  311. }, // 分组 车型 车系 和分段
  312. count: { type: Number }, // 数量
  313. },
  314. ], // 充电次数占比分布
  315. chargeCntMonth: [
  316. {
  317. _id: {
  318. _id: { type: String },
  319. series_code: { type: String }, model_code: { type: String },
  320. }, // 分组 车型 车系 和分段
  321. count: { type: Number }, // 数量
  322. },
  323. ], // 充电次数月占比分布
  324. chargeCntYear: [
  325. {
  326. _id: {
  327. _id: { type: String },
  328. series_code: { type: String }, model_code: { type: String },
  329. }, // 分组 车型 车系 和分段
  330. count: { type: Number }, // 数量
  331. },
  332. ], // 充电次数年占比分布
  333. skyDuration: [
  334. {
  335. _id: {
  336. _id: { type: String },
  337. series_code: { type: String }, model_code: { type: String },
  338. }, // 分组 车型 车系 和分段
  339. count: { type: Number }, // 数量
  340. },
  341. ], // 车辆天窗时长占比分布
  342. skyDurationMonth: [
  343. {
  344. _id: {
  345. _id: { type: String },
  346. series_code: { type: String }, model_code: { type: String },
  347. }, // 分组 车型 车系 和分段
  348. count: { type: Number }, // 数量
  349. },
  350. ], // 车辆天窗时长月占比分布
  351. skyDurationYear: [
  352. {
  353. _id: {
  354. _id: { type: String },
  355. series_code: { type: String }, model_code: { type: String },
  356. }, // 分组 车型 车系 和分段
  357. count: { type: Number }, // 数量
  358. },
  359. ], // 车辆天窗时长年占比分布
  360. headlightCnt: [
  361. {
  362. _id: {
  363. _id: { type: String },
  364. series_code: { type: String }, model_code: { type: String },
  365. }, // 分组 车型 车系 和分段
  366. count: { type: Number }, // 数量
  367. },
  368. ], // 近光使用次数占比分布
  369. headlightCntMonth: [
  370. {
  371. _id: {
  372. _id: { type: String },
  373. series_code: { type: String }, model_code: { type: String },
  374. }, // 分组 车型 车系 和分段
  375. count: { type: Number }, // 数量
  376. },
  377. ], // 近光使用次数月占比分布
  378. headlightCntYear: [
  379. {
  380. _id: {
  381. _id: { type: String },
  382. series_code: { type: String }, model_code: { type: String },
  383. }, // 分组 车型 车系 和分段
  384. count: { type: Number }, // 数量
  385. },
  386. ], // 近光使用次数年占比分布
  387. highBeamCnt: [
  388. {
  389. _id: {
  390. _id: { type: String },
  391. series_code: { type: String }, model_code: { type: String },
  392. }, // 分组 车型 车系 和分段
  393. count: { type: Number }, // 数量
  394. },
  395. ], // 远光使用次数占比分布
  396. highBeamCntMonth: [
  397. {
  398. _id: {
  399. _id: { type: String },
  400. series_code: { type: String }, model_code: { type: String },
  401. }, // 分组 车型 车系 和分段
  402. count: { type: Number }, // 数量
  403. },
  404. ], // 远光使用次数月占比分布
  405. highBeamCntYear: [
  406. {
  407. _id: {
  408. _id: { type: String },
  409. series_code: { type: String }, model_code: { type: String },
  410. }, // 分组 车型 车系 和分段
  411. count: { type: Number }, // 数量
  412. },
  413. ], // 远光使用次数年占比分布
  414. headlightDuration: [
  415. {
  416. _id: {
  417. _id: { type: String },
  418. series_code: { type: String }, model_code: { type: String },
  419. }, // 分组 车型 车系 和分段
  420. count: { type: Number }, // 数量
  421. },
  422. ], // 近光使用时长占比分布
  423. headlightDurationMonth: [
  424. {
  425. _id: {
  426. _id: { type: String },
  427. series_code: { type: String }, model_code: { type: String },
  428. }, // 分组 车型 车系 和分段
  429. count: { type: Number }, // 数量
  430. },
  431. ], // 近光使用时长月占比分布
  432. headlightDurationYear: [
  433. {
  434. _id: {
  435. _id: { type: String },
  436. series_code: { type: String }, model_code: { type: String },
  437. }, // 分组 车型 车系 和分段
  438. count: { type: Number }, // 数量
  439. },
  440. ], // 近光使用时长年占比分布
  441. highBeamDuration: [
  442. {
  443. _id: {
  444. _id: { type: String },
  445. series_code: { type: String }, model_code: { type: String },
  446. }, // 分组 车型 车系 和分段
  447. count: { type: Number }, // 数量
  448. },
  449. ], // 远光使用时长占比分布
  450. highBeamDurationMonth: [
  451. {
  452. _id: {
  453. _id: { type: String },
  454. series_code: { type: String }, model_code: { type: String },
  455. }, // 分组 车型 车系 和分段
  456. count: { type: Number }, // 数量
  457. },
  458. ], // 远光使用时长月占比分布
  459. highBeamDurationYear: [
  460. {
  461. _id: {
  462. _id: { type: String },
  463. series_code: { type: String }, model_code: { type: String },
  464. }, // 分组 车型 车系 和分段
  465. count: { type: Number }, // 数量
  466. },
  467. ], // 远光使用时长年占比分布
  468. mileageStartTimeAndDsm: [
  469. {
  470. _id: {
  471. _id: { type: String },
  472. series_code: { type: String }, model_code: { type: String },
  473. }, // 分组 车型 车系 和分段
  474. count: { type: Number }, // 数量
  475. dsmCount: { type: Number }, // 疲劳数量
  476. },
  477. ], // 用户出行时间/用户疲劳驾驶次数 占比
  478. mileageSingle: [
  479. {
  480. _id: {
  481. _id: { type: String },
  482. series_code: { type: String }, model_code: { type: String },
  483. }, // 分组 车型 车系 和分段
  484. count: { type: Number }, // 数量
  485. },
  486. ], // 单次行驶里程统计
  487. maxAcce: [
  488. {
  489. _id: {
  490. _id: { type: String },
  491. series_code: { type: String }, model_code: { type: String },
  492. }, // 分组 车型 车系 和分段
  493. count: { type: Number }, // 数量
  494. },
  495. ], // 单次行程中最大加速度
  496. maxDece: [
  497. {
  498. _id: {
  499. _id: { type: String },
  500. series_code: { type: String }, model_code: { type: String },
  501. }, // 分组 车型 车系 和分段
  502. count: { type: Number }, // 数量
  503. },
  504. ], // 单次行程中最大减速度
  505. sideAcce: [
  506. {
  507. _id: {
  508. _id: { type: String },
  509. series_code: { type: String }, model_code: { type: String },
  510. }, // 分组 车型 车系 和分段
  511. count: { type: Number }, // 数量
  512. },
  513. ], // 单次行程最大侧向加速度
  514. continuousDrive: [
  515. {
  516. _id: {
  517. _id: { type: String },
  518. series_code: { type: String }, model_code: { type: String },
  519. }, // 分组 车型 车系 和分段
  520. count: { type: Number }, // 数量
  521. },
  522. ], // 持续驾驶
  523. driveStyle: [
  524. {
  525. _id: {
  526. _id: { type: String },
  527. series_code: { type: String }, model_code: { type: String },
  528. }, // 分组 车型 车系 和分段
  529. count: { type: Number }, // 数量
  530. },
  531. ], // 驾驶风格
  532. drivingSafetyScore: [
  533. {
  534. _id: {
  535. _id: { type: String },
  536. series_code: { type: String }, model_code: { type: String },
  537. }, // 分组 车型 车系 和分段
  538. count: { type: Number }, // 数量
  539. },
  540. ], // 驾驶安全得分
  541. energyConservationScore: [
  542. {
  543. _id: {
  544. _id: { type: String },
  545. series_code: { type: String }, model_code: { type: String },
  546. }, // 分组 车型 车系 和分段
  547. count: { type: Number }, // 数量
  548. },
  549. ], // 日驾驶行为节能平均得分
  550. });
  551. DrivingBehaviorInfoSchema2.index({ create_date: -1 });
  552. return conn.model('DrivingBehaviorInfo2', DrivingBehaviorInfoSchema2, 'lc_driving_behavior_info');
  553. };