onlineUserModel.js 4.9 KB

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