'use strict'; module.exports = app => { const mongoose = app.mongoose; const Schema = mongoose.Schema; const conn = app.mongooseDB.get('etlLocalDB'); // 在线用户数据 (包含 app在线+tbox在线) 本地清洗 数据结构 const OnlineUserSchema = new Schema({ create_date: { type: Number }, // 统计的数据是哪一天的 year: { type: Number }, // 年 统计的数据 month: { type: Number }, // 月 统计的数据 day: { type: Number }, // 日 统计的数据 dateString: { type: String }, // 时间字符串 yyyy-MM-dd start_time: { type: Date }, // 开始统计时间 end_time: { type: Date, default: Date.now }, // 结束统计时间 total: { type: Number }, // 在线总数(APP+TBOX) appYear: { type: Number }, // app当年在线总数 去重 tBoxYear: { type: Number }, // tbox当年在线总数 去重 appTotal: { type: Number }, // APP在线总数 tBoxTotal: { type: Number }, // TBOX在线总数 appPlace: [ { area_name: { type: String }, provinces: [ { provice_name: { type: String }, cities: [ { city_name: { type: String }, count: { type: Number }, }, ], count: { type: Number }, }, ], count: { type: Number }, }, ], // app在线分布 tBoxPlace: [ { area_name: { type: String }, provinces: [ { provice_name: { type: String }, cities: [ { city_name: { type: String }, count: { type: Number }, }, ], count: { type: Number }, }, ], count: { type: Number }, }, ], // TBox在线分布 appLocation: [ { area_name: { type: String }, provinces: [ { provice_name: { type: String }, cities: [ { city_name: { type: String }, count: { type: Number }, }, ], count: { type: Number }, }, ], count: { type: Number }, }, ], // app位置 appNewLocation: [ { area_name: { type: String }, provinces: [ { provice_name: { type: String }, cities: [ { city_name: { type: String }, count: { type: Number }, }, ], count: { type: Number }, }, ], count: { type: Number }, }, ], // app新增位置 appActiveLocation: [ { area_name: { type: String }, provinces: [ { provice_name: { type: String }, cities: [ { city_name: { type: String }, count: { type: Number }, }, ], count: { type: Number }, }, ], count: { type: Number }, }, ], // app活跃位置 iviLocation: [ { area_name: { type: String }, provinces: [ { provice_name: { type: String }, cities: [ { city_name: { type: String }, count: { type: Number }, }, ], count: { type: Number }, }, ], count: { type: Number }, }, ], // ivi位置 iviNewLocation: [ { area_name: { type: String }, provinces: [ { provice_name: { type: String }, cities: [ { city_name: { type: String }, count: { type: Number }, }, ], count: { type: Number }, }, ], count: { type: Number }, }, ], // ivi新增位置 iviActiveLocation: [ { area_name: { type: String }, provinces: [ { provice_name: { type: String }, cities: [ { city_name: { type: String }, count: { type: Number }, }, ], count: { type: Number }, }, ], count: { type: Number }, }, ], // ivi活跃位置 faceTotal: { type: Number }, // 人脸登录总数 voiceTotal: { type: Number }, // 声纹登录总数 pwdTotal: { type: Number }, // 密码登录总数 codeTotal: { type: Number }, // 验证码登录总数 scanTotal: { type: Number }, // 二维码登录总数 iviTotal: { type: Number }, // ivi登录总数 carTotal: { type: Number }, // 车主登录总数 commonTotal: { type: Number }, // 普通用户角色登录总数 guestTotal: { type: Number }, // guest角色登录总数 successTotal: { type: Number }, // 登录成功总数 failTotal: { type: Number }, // 登录失败总数 }); OnlineUserSchema.index({ create_date: -1 }); return conn.model('OnlineUser', OnlineUserSchema, 'lc_online_user'); };