drivingBehaviorInfoModel2.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  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. avgOil: { type: Number }, // 平均油耗
  60. }], // 油耗分布
  61. oilCity: [{
  62. _id: {
  63. _id: { type: String }, // 市code
  64. fid: { type: String }, // 省code
  65. series_code: { type: String }, model_code: { type: String },
  66. }, // 分组 车型 车系 和分段
  67. name: { type: String }, // 市名称
  68. avgOil: { type: Number }, // 油耗
  69. }], // 油耗分布
  70. mileageCnt: [
  71. {
  72. _id: {
  73. _id: { type: String },
  74. series_code: { type: String }, model_code: { type: String },
  75. }, // 分组 车型 车系 和分段
  76. count: { type: Number }, // 数量
  77. },
  78. ], // 车辆行程次数
  79. driveDuration: [
  80. {
  81. _id: {
  82. _id: { type: String },
  83. series_code: { type: String }, model_code: { type: String },
  84. }, // 分组 车型 车系 和分段
  85. count: { type: Number }, // 数量
  86. },
  87. ], // 驾驶时长
  88. avgSpeed: [
  89. {
  90. _id: {
  91. _id: { type: String },
  92. series_code: { type: String }, model_code: { type: String },
  93. }, // 分组 车型 车系 和分段
  94. count: { type: Number }, // 数量
  95. },
  96. ], // 平均车速
  97. mileageCnt2: [
  98. {
  99. _id: {
  100. _id: { type: String },
  101. series_code: { type: String }, model_code: { type: String },
  102. }, // 分组 车型 车系 和分段
  103. count: { type: Number }, // 数量
  104. },
  105. ], // 车辆行程次数 用于 周末和工作日统计
  106. mileage: [
  107. {
  108. _id: {
  109. _id: { type: String },
  110. series_code: { type: String }, model_code: { type: String },
  111. }, // 分组 车型 车系 和分段
  112. count: { type: Number }, // 数量
  113. },
  114. ], // 行驶里程
  115. mileageAvg: [
  116. {
  117. _id: {
  118. _id: { type: String },
  119. series_code: { type: String }, model_code: { type: String },
  120. }, // 分组 车型 车系 和分段
  121. count: { type: Number }, // 数量
  122. },
  123. ], // 平均行驶里程
  124. supplementaryCnt: [
  125. {
  126. _id: {
  127. _id: { type: String },
  128. series_code: { type: String }, model_code: { type: String },
  129. }, // 分组 车型 车系 和分段
  130. count: { type: Number }, // 数量
  131. },
  132. ], // 补传次数
  133. batterySoc: [
  134. {
  135. _id: {
  136. _id: { type: String },
  137. series_code: { type: String }, model_code: { type: String },
  138. }, // 分组 车型 车系 和分段
  139. count: { type: Number }, // 数量
  140. },
  141. ], // 蓄电池电量
  142. engineSpeed: [
  143. {
  144. _id: {
  145. _id: { type: String },
  146. series_code: { type: String }, model_code: { type: String },
  147. }, // 分组 车型 车系 和分段
  148. count: { type: Number }, // 数量
  149. },
  150. ], // 发动机转速
  151. insideTemperature: [
  152. {
  153. _id: {
  154. _id: { type: String },
  155. series_code: { type: String }, model_code: { type: String },
  156. }, // 分组 车型 车系 和分段
  157. count: { type: Number }, // 数量
  158. },
  159. ], // 室内温度
  160. outsideTemperature: [
  161. {
  162. _id: {
  163. _id: { type: String },
  164. series_code: { type: String }, model_code: { type: String },
  165. }, // 分组 车型 车系 和分段
  166. count: { type: Number }, // 数量
  167. },
  168. ], // 室外温度
  169. powerBatterySoc: [
  170. {
  171. _id: {
  172. _id: { type: String },
  173. series_code: { type: String }, model_code: { type: String },
  174. }, // 分组 车型 车系 和分段
  175. count: { type: Number }, // 数量
  176. },
  177. ], // 动力电池
  178. chargeDuration: [
  179. {
  180. _id: {
  181. _id: { type: String },
  182. series_code: { type: String }, model_code: { type: String },
  183. }, // 分组 车型 车系 和分段
  184. count: { type: Number }, // 数量
  185. },
  186. ], // 充电时长
  187. chargeStartSoc: [
  188. {
  189. _id: {
  190. _id: { type: String },
  191. series_code: { type: String }, model_code: { type: String },
  192. }, // 分组 车型 车系 和分段
  193. count: { type: Number }, // 数量
  194. },
  195. ], // 充电初始SOC
  196. chargeEndSoc: [
  197. {
  198. _id: {
  199. _id: { type: String },
  200. series_code: { type: String }, model_code: { type: String },
  201. }, // 分组 车型 车系 和分段
  202. count: { type: Number }, // 数量
  203. },
  204. ], // 充电结束SOC
  205. chargePreStartMileage: [
  206. {
  207. _id: {
  208. _id: { type: String },
  209. series_code: { type: String }, model_code: { type: String },
  210. }, // 分组 车型 车系 和分段
  211. count: { type: Number }, // 数量
  212. },
  213. ], // 充电时车辆可行驶里程
  214. chargeStartTime: [
  215. {
  216. _id: {
  217. _id: { type: String },
  218. series_code: { type: String }, model_code: { type: String },
  219. }, // 分组 车型 车系 和分段
  220. count: { type: Number }, // 数量
  221. },
  222. ], // 充电初始时刻
  223. chargeType: [
  224. {
  225. _id: {
  226. _id: { type: String },
  227. series_code: { type: String }, model_code: { type: String },
  228. }, // 分组 车型 车系 和分段
  229. count: { type: Number }, // 数量
  230. },
  231. ], // 充电模式分布
  232. chargeMileage: [
  233. {
  234. _id: {
  235. _id: { type: String },
  236. series_code: { type: String }, model_code: { type: String },
  237. }, // 分组 车型 车系 和分段
  238. count: { type: Number }, // 数量
  239. },
  240. ], // 两次充电间行驶里程分布
  241. avgSpeedPower: [
  242. {
  243. _id: {
  244. _id: { type: String },
  245. series_code: { type: String }, model_code: { type: String },
  246. }, // 分组 车型 车系 和分段
  247. count: { type: Number }, // 数量
  248. },
  249. ], // 不同车速区间耗电占比
  250. actualMileage: [
  251. {
  252. _id: {
  253. _id: { type: String },
  254. series_code: { type: String }, model_code: { type: String },
  255. }, // 分组 车型 车系 和分段
  256. count: { type: Number }, // 数量
  257. },
  258. ], // 实际续航里程分布
  259. chargeCnt: [
  260. {
  261. _id: {
  262. _id: { type: String },
  263. series_code: { type: String }, model_code: { type: String },
  264. }, // 分组 车型 车系 和分段
  265. count: { type: Number }, // 数量
  266. },
  267. ], // 充电次数占比分布
  268. skyDuration: [
  269. {
  270. _id: {
  271. _id: { type: String },
  272. series_code: { type: String }, model_code: { type: String },
  273. }, // 分组 车型 车系 和分段
  274. count: { type: Number }, // 数量
  275. },
  276. ], // 车辆天窗时长占比分布
  277. headlightCnt: [
  278. {
  279. _id: {
  280. _id: { type: String },
  281. series_code: { type: String }, model_code: { type: String },
  282. }, // 分组 车型 车系 和分段
  283. count: { type: Number }, // 数量
  284. },
  285. ], // 近光使用次数占比分布
  286. highBeamCnt: [
  287. {
  288. _id: {
  289. _id: { type: String },
  290. series_code: { type: String }, model_code: { type: String },
  291. }, // 分组 车型 车系 和分段
  292. count: { type: Number }, // 数量
  293. },
  294. ], // 远光使用次数占比分布
  295. headlightDuration: [
  296. {
  297. _id: {
  298. _id: { type: String },
  299. series_code: { type: String }, model_code: { type: String },
  300. }, // 分组 车型 车系 和分段
  301. count: { type: Number }, // 数量
  302. },
  303. ], // 近光使用时长占比分布
  304. highBeamDuration: [
  305. {
  306. _id: {
  307. _id: { type: String },
  308. series_code: { type: String }, model_code: { type: String },
  309. }, // 分组 车型 车系 和分段
  310. count: { type: Number }, // 数量
  311. },
  312. ], // 远光使用时长占比分布
  313. mileageStartTimeAndDsm: [
  314. {
  315. _id: {
  316. _id: { type: String },
  317. series_code: { type: String }, model_code: { type: String },
  318. }, // 分组 车型 车系 和分段
  319. count: { type: Number }, // 数量
  320. dsmCount: { type: Number }, // 疲劳数量
  321. },
  322. ], // 用户出行时间/用户疲劳驾驶次数 占比
  323. mileageSingle: [
  324. {
  325. _id: {
  326. _id: { type: String },
  327. series_code: { type: String }, model_code: { type: String },
  328. }, // 分组 车型 车系 和分段
  329. count: { type: Number }, // 数量
  330. },
  331. ], // 单次行驶里程统计
  332. maxAcce: [
  333. {
  334. _id: {
  335. _id: { type: String },
  336. series_code: { type: String }, model_code: { type: String },
  337. }, // 分组 车型 车系 和分段
  338. count: { type: Number }, // 数量
  339. },
  340. ], // 单次行程中最大加速度
  341. maxDece: [
  342. {
  343. _id: {
  344. _id: { type: String },
  345. series_code: { type: String }, model_code: { type: String },
  346. }, // 分组 车型 车系 和分段
  347. count: { type: Number }, // 数量
  348. },
  349. ], // 单次行程中最大减速度
  350. sideAcce: [
  351. {
  352. _id: {
  353. _id: { type: String },
  354. series_code: { type: String }, model_code: { type: String },
  355. }, // 分组 车型 车系 和分段
  356. count: { type: Number }, // 数量
  357. },
  358. ], // 单次行程最大侧向加速度
  359. continuousDrive: [
  360. {
  361. _id: {
  362. _id: { type: String },
  363. series_code: { type: String }, model_code: { type: String },
  364. }, // 分组 车型 车系 和分段
  365. count: { type: Number }, // 数量
  366. },
  367. ], // 持续驾驶
  368. driveStyle: [
  369. {
  370. _id: {
  371. _id: { type: String },
  372. series_code: { type: String }, model_code: { type: String },
  373. }, // 分组 车型 车系 和分段
  374. count: { type: Number }, // 数量
  375. },
  376. ], // 驾驶风格
  377. drivingSafetyScore: [
  378. {
  379. _id: {
  380. _id: { type: String },
  381. series_code: { type: String }, model_code: { type: String },
  382. }, // 分组 车型 车系 和分段
  383. count: { type: Number }, // 数量
  384. },
  385. ], // 驾驶安全得分
  386. energyConservationScore: [
  387. {
  388. _id: {
  389. _id: { type: String },
  390. series_code: { type: String }, model_code: { type: String },
  391. }, // 分组 车型 车系 和分段
  392. count: { type: Number }, // 数量
  393. },
  394. ], // 日驾驶行为节能平均得分
  395. });
  396. DrivingBehaviorInfoSchema2.index({ create_date: -1 });
  397. return conn.model('DrivingBehaviorInfo2', DrivingBehaviorInfoSchema2, 'lc_driving_behavior_info');
  398. };