appBehaviorRecordModel.js 1.8 KB

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. module.exports = app => {
  3. const mongoose = app.mongoose;
  4. const Schema = mongoose.Schema;
  5. const conn = app.mongooseDB.get('etlDB');
  6. // APP功能统计数据结构 按日为维度提供单个用户单个行为以及对应行为使用时长元数据
  7. const AppBehaviorRecordSchema = new Schema({
  8. _id: { type: String }, // 日月年+序列号
  9. user_id: { type: String }, //
  10. parent_behavior_id: { type: Number }, // 一级功能行为id
  11. parent_name: { type: String }, // 一级功能行为描述
  12. behavior_id: { type: Number }, // 行为ID,APP功能
  13. use_duration: { type: Number }, // 当日单个功能使用时长 (单位:ms, 精度:1)
  14. create_time: { type: Number }, // 行为发生时间
  15. rc_execution_result: { type: String }, // (远控制)功能执行结果:
  16. // 成功/失败 FAILED/SUCCEED/true/false
  17. op: { type: String }, // (远控制)指令类型:解锁/上锁、启动/熄火、开启/关闭
  18. // OPEN/LOCK/UNLOCK/CLOSE
  19. op_type: { type: String },
  20. closeType: { type: String },
  21. rc_fail_type: { type: String }, // (远控制)失败类型 错误、车辆处于本地模式、车辆远程认证不匹配、tbox自身系统故障、动力系统启动失败
  22. // VEH.HMI.0198/VEH.HMI.0199(具体定义是什么需要问APP)
  23. });
  24. AppBehaviorRecordSchema.index({ create_time: -1 });
  25. AppBehaviorRecordSchema.index({ create_time: -1, parent_behavior_id: -1 });
  26. AppBehaviorRecordSchema.index({ create_time: -1, parent_behavior_id: -1, rc_execution_result: -1 });
  27. AppBehaviorRecordSchema.index({ create_time: -1, parent_behavior_id: -1, rc_execution_result: -1, rc_fail_type: -1 });
  28. AppBehaviorRecordSchema.index({ create_time: -1, user_id: -1 });
  29. return conn.model('AppBehaviorRecord', AppBehaviorRecordSchema, 'app_behavior_record');
  30. };