onlineUserModel.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. // 在线用户数据 (包含 app在线+tbox在线) 本地清洗 数据结构
  7. const OnlineUserSchema = 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. total: { type: Number }, // 在线总数(APP+TBOX)
  16. appYear: { type: Number }, // app当年在线总数 去重
  17. tBoxYear: { type: Number }, // tbox当年在线总数 去重
  18. appTotal: { type: Number }, // APP在线总数
  19. tBoxTotal: { type: Number }, // TBOX在线总数
  20. appPlace: [
  21. {
  22. area_name: { type: String },
  23. provinces: [
  24. {
  25. provice_name: { type: String },
  26. cities: [
  27. {
  28. city_name: { type: String },
  29. count: { type: Number },
  30. },
  31. ],
  32. count: { type: Number },
  33. },
  34. ],
  35. count: { type: Number },
  36. },
  37. ], // app在线分布
  38. tBoxPlace: [
  39. {
  40. area_name: { type: String },
  41. provinces: [
  42. {
  43. provice_name: { type: String },
  44. cities: [
  45. {
  46. city_name: { type: String },
  47. count: { type: Number },
  48. },
  49. ],
  50. count: { type: Number },
  51. },
  52. ],
  53. count: { type: Number },
  54. },
  55. ], // TBox在线分布
  56. appLocation: [
  57. {
  58. area_name: { type: String },
  59. provinces: [
  60. {
  61. provice_name: { type: String },
  62. cities: [
  63. {
  64. city_name: { type: String },
  65. count: { type: Number },
  66. },
  67. ],
  68. count: { type: Number },
  69. },
  70. ],
  71. count: { type: Number },
  72. },
  73. ], // app位置
  74. appNewLocation: [
  75. {
  76. area_name: { type: String },
  77. provinces: [
  78. {
  79. provice_name: { type: String },
  80. cities: [
  81. {
  82. city_name: { type: String },
  83. count: { type: Number },
  84. },
  85. ],
  86. count: { type: Number },
  87. },
  88. ],
  89. count: { type: Number },
  90. },
  91. ], // app新增位置
  92. appActiveLocation: [
  93. {
  94. area_name: { type: String },
  95. provinces: [
  96. {
  97. provice_name: { type: String },
  98. cities: [
  99. {
  100. city_name: { type: String },
  101. count: { type: Number },
  102. },
  103. ],
  104. count: { type: Number },
  105. },
  106. ],
  107. count: { type: Number },
  108. },
  109. ], // app活跃位置
  110. iviLocation: [
  111. {
  112. area_name: { type: String },
  113. provinces: [
  114. {
  115. provice_name: { type: String },
  116. cities: [
  117. {
  118. city_name: { type: String },
  119. count: { type: Number },
  120. },
  121. ],
  122. count: { type: Number },
  123. },
  124. ],
  125. count: { type: Number },
  126. },
  127. ], // ivi位置
  128. iviNewLocation: [
  129. {
  130. area_name: { type: String },
  131. provinces: [
  132. {
  133. provice_name: { type: String },
  134. cities: [
  135. {
  136. city_name: { type: String },
  137. count: { type: Number },
  138. },
  139. ],
  140. count: { type: Number },
  141. },
  142. ],
  143. count: { type: Number },
  144. },
  145. ], // ivi新增位置
  146. iviActiveLocation: [
  147. {
  148. area_name: { type: String },
  149. provinces: [
  150. {
  151. provice_name: { type: String },
  152. cities: [
  153. {
  154. city_name: { type: String },
  155. count: { type: Number },
  156. },
  157. ],
  158. count: { type: Number },
  159. },
  160. ],
  161. count: { type: Number },
  162. },
  163. ], // ivi活跃位置
  164. faceTotal: { type: Number }, // 人脸登录总数
  165. voiceTotal: { type: Number }, // 声纹登录总数
  166. pwdTotal: { type: Number }, // 密码登录总数
  167. codeTotal: { type: Number }, // 验证码登录总数
  168. scanTotal: { type: Number }, // 二维码登录总数
  169. iviTotal: { type: Number }, // ivi登录总数
  170. carTotal: { type: Number }, // 车主登录总数
  171. commonTotal: { type: Number }, // 普通用户角色登录总数
  172. guestTotal: { type: Number }, // guest角色登录总数
  173. successTotal: { type: Number }, // 登录成功总数
  174. failTotal: { type: Number }, // 登录失败总数
  175. });
  176. OnlineUserSchema.index({ create_date: -1 });
  177. return conn.model('OnlineUser', OnlineUserSchema, 'lc_online_user');
  178. };