z332406259 преди 4 години
родител
ревизия
33dced60e0

+ 0 - 1
app/model/appBehaviorRecordModel.js

@@ -18,7 +18,6 @@ module.exports = app => {
     // OPEN/LOCK/UNLOCK/CLOSE
     op_type: { type: String },
     closeType: { type: String },
-    trigger_date: { type: String },
     rc_fail_type: { type: String }, // (远控制)失败类型 错误、车辆处于本地模式、车辆远程认证不匹配、tbox自身系统故障、动力系统启动失败
     // VEH.HMI.0198/VEH.HMI.0199(具体定义是什么需要问APP)
   });

+ 6 - 8
app/model/appOnlineUserModel.js

@@ -8,22 +8,20 @@ module.exports = app => {
     _id: { type: String }, // 主键,用户ID+年月日拼接+序号
     user_Id: { type: String }, // 用户ID
     user_name: { type: String }, // 登录账号
+    user_mobileno: { type: String }, // 用户手机号
     role_id: { type: String },
     // CAR_OWNER 是车主,user是使用人,POTENTIAL是潜客(粉丝) role_id:3 其他
     login_time: { type: Number }, // 登录时间戳
     longitude: { type: Number }, // 登录位置-经度
     latitude: { type: Number }, // 登录位置-纬度
-    area_code: { type: String }, // 登录位置-地区编码-
-    area_name: { type: String }, // 登录位置-地区名称-
-    provice_code: { type: String }, // 登录位置-省份编码-
+    // area_code: { type: String }, // 登录位置-地区编码- 实际数据无
+    // area_name: { type: String }, // 登录位置-地区名称- 实际数据无
+    provice_code: { type: String }, // 登录位置-省份编码 无用了
     provice_name: { type: String }, // 登录位置-省份名称
-    city_code: { type: String }, // 登录位置-城市编码-
+    city_code: { type: String }, // 登录位置-城市编码 无用了
     city_name: { type: String }, // 登录位置-城市名称
-    county_code: { type: String }, // 登录位置-行政区编码-
+    county_code: { type: String }, // 登录位置-行政区编码  无用了
     county_name: { type: String }, // 登录位置-行政区名称
-    // series_code: { type: String }, // 车系编码
-    // series_name: { type: String }, // 车系名称
-    // login_count: { type: Number }, // 日登录次数
     login_mode: { type: String }, // 登录方式
     // (1:人脸、2:声纹、3:密码、4:验证码、5:二维码)
     // FACE/SOUND/PASSWORD/VERIFICATION_CODE/QR

+ 1 - 1
app/model/iviBehaviorRecordModel.js

@@ -8,7 +8,7 @@ module.exports = app => {
     _id: { type: String }, // vin+behavior_id+ 日月年+序列号
     user_id: { type: String }, // IVI用户ID
     vin: { type: String }, // 车辆VIN
-    behavior_id: { type: String }, // 行为ID  听歌20020000,听电台20010000,看新闻20050000,看视频 20030000
+    behavior_id: { type: Number }, // 行为ID  听歌20020000,听电台20010000,看新闻20050000,看视频 20030000
     create_time: { type: Number }, // 行为开始时间
 
   });

+ 7 - 7
app/model/iviOnlineUserModel.js

@@ -11,23 +11,23 @@ module.exports = app => {
     user_mobileno: { type: String }, // 登录手机号
     vin: { type: String }, // vin
     role_id: { type: String },
-    // CAR_OWNER 是车主,user是使用人,POTENTIAL是潜客(粉丝)
+    // CAR_OWNER 是车主,user是使用人,POTENTIAL是潜客(粉丝)TODO 这边的角色和正常的不一样
     login_time: { type: Number }, // 登录时间戳
-    longitude: { type: Number }, // 登录位置-经度
+    longitude: { type: Number }, // 登录位置-经度  TODO 无
     latitude: { type: Number }, // 登录位置-纬度
     // area_code: { type: String }, // 登录位置-地区编码
     // area_name: { type: String }, // 登录位置-地区名称
     // provice_code: { type: String }, // 登录位置-省份编码
-    provice_name: { type: String }, // 登录位置-省份名称
+    provice_name: { type: String }, // 登录位置-省份名称 TODO 无
     // city_code: { type: String }, // 登录位置-城市编码
-    city_name: { type: String }, // 登录位置-城市名称
-    county_code: { type: String }, // 登录位置-行政区编码
-    county_name: { type: String }, // 登录位置-行政区名称
+    city_name: { type: String }, // 登录位置-城市名称 TODO 无
+    county_code: { type: String }, // 登录位置-行政区编码 TODO 无
+    county_name: { type: String }, // 登录位置-行政区名称 TODO 无
     // series_code: { type: String }, // 车系编码
     // series_name: { type: String }, // 车系名称
     login_mode: { type: String }, // 登录方式 (1:人脸、2:声纹、3:密码、4:验证码、5:二维码)
     // FACE/SOUND/PASSWORD/VERIFICATION_CODE/QR
-    login_state: { type: Number }, // 登录状态 (1:成功、2:失败)
+    login_state: { type: Number }, // 登录状态 (1:成功、2:失败) TODO 无
   });
   return conn.model('IviOnlineUser', IviOnlineUserSchema, 'ivi_online_user');
 };

+ 3 - 3
app/model/tRbacUserModel.js

@@ -13,9 +13,9 @@ module.exports = app => {
     user_orgin: { type: String }, // 用户来源(APP/IVI)origin
     // role_id: { type: String }, // 用户角色:2为潜客,其他为车主
     role_id: { type: Number }, // 用户角色:2为潜客,其他为车主
-    // role_id:2 潜客(你口中的粉丝)role_id:90(实销车车主) role_id:3 其他
-    gender: { type: String }, // 性别(F-女,M-男)
-    id_card: { type: String }, // 身份证号
+    // role_id:2 潜客(你口中的粉丝)role_id:90(实销车车主)
+    gender: { type: String }, // 性别(F-女,M-男) 可能没有
+    id_card: { type: String }, // 身份证号  可能没有
     create_date: { type: Number }, // 创建时间戳
     update_date: { type: Number }, // 更新时间戳
   });

+ 8 - 8
app/model/tVehicleOnlineInfoModel.js

@@ -18,14 +18,14 @@ module.exports = app => {
     latitude: { type: Number }, // 84坐标系纬度值
     location_time: { type: Number }, // GPS定位时间
     // 在线车辆  如果数据来源是TBOX 这个时候GPS 经纬值和纬度值 数值存在   地区,省份,城市,区县有可能不存在,解析不出来。
-    area_code: { type: String }, // 地区编码
-    area_name: { type: String }, // 地区名称
-    province_code: { type: String }, // 省份编码
-    province_name: { type: String }, // 省份名称
-    city_code: { type: String }, // 城市编码
-    city_name: { type: String }, // 城市名称
-    county_code: { type: String }, // 区县编码
-    county_name: { type: String }, // 区县名称
+    // area_code: { type: String }, // 地区编码
+    // area_name: { type: String }, // 地区名称
+    // province_code: { type: String }, // 省份编码
+    // province_name: { type: String }, // 省份名称
+    // city_code: { type: String }, // 城市编码
+    // city_name: { type: String }, // 城市名称
+    // county_code: { type: String }, // 区县编码
+    // county_name: { type: String }, // 区县名称
     real_speed: { type: Number }, // 实时车速
 
   });

+ 3 - 3
app/model/tVehicleRecordModel.js

@@ -13,10 +13,10 @@ module.exports = app => {
     is_saled_car: { type: Number }, // 车辆类型
     dealer_code: { type: String }, // 经销商CODE
     dealer_name: { type: String }, // 经销商名称
-    pro_code: { type: String }, // 省编码
-    city_code: { type: String }, // 市编码
+    pro_code: { type: String }, // 省编码  可能没有
+    city_code: { type: String }, // 市编码  可能没有
     tsp_status: { type: String }, // T服务开通状态
-    user_id: { type: Number }, // 用户ID
+    user_id: { type: Number }, // 用户ID  可能没有
     create_time: { type: Number }, // 创建时间,入网时间
     update_time: { type: Number }, // 更新时间戳
     model_code: { type: String }, // 车型CODE

+ 2 - 3
app/schedule/updateData.js

@@ -8,9 +8,8 @@ class UpdateData extends Subscription {
     return {
       // interval: '24h', // 1 分钟间隔
       cron: '0 30 3 * * ? ', // 每天凌晨3点
-      // cron: '0 10 17 * * ? ', // 每天凌晨3点
       type: 'all', // 指定所有的 worker 都需要执行
-      // immediate: true,
+      immediate: true,
       cronOptions: {
         tz: 'Asia/Shanghai',
       },
@@ -54,7 +53,7 @@ class UpdateData extends Subscription {
     this.isRunningTask = true;
 
     // 更新历史时间段数据 => 修改createBaseData的参数做循环请求即可
-    const satrtMoment = this.ctx.helper.momentDate('2020-01-01');
+    const satrtMoment = this.ctx.helper.momentDate('2020-06-01');
 
     // const satrtMoment = this.ctx.helper.momentDate('2020-06-01');
     // const endTime = this.ctx.helper.parse('2019-06-17');

+ 2 - 1
app/service/appBehaviorRecordService.js

@@ -149,7 +149,7 @@ class AppBehaviorRecordService extends Service {
   async behavior({ startTime, endTime }) {
     const { ctx } = this;
     const agg = [
-      { $match: ctx.helper.getTimeRangMatch(startTime, endTime, 'create_time') },
+      { $match: { ...ctx.helper.getTimeRangMatch(startTime, endTime, 'create_time') } },
       {
         $group: {
           _id: '$parent_behavior_id',
@@ -182,6 +182,7 @@ class AppBehaviorRecordService extends Service {
     const { ctx } = this;
     const agg = [
       { $match: { parent_behavior_id: ctx.helper.rcBehaviorId,
+        rc_fail_type: { $exists: true },
         $or: [
           { rc_execution_result: 'false' },
           { rc_execution_result: 'FAILED' },

+ 18 - 13
app/service/appExceptionRecordService.js

@@ -10,10 +10,12 @@ class AppExceptionRecordService extends Service {
 
     const agg = [
       { $match: ctx.helper.getTimeRangMatch(startTime, endTime) },
-      { $group: ctx.helper.getTimeGroup(type, { total: { $sum: '$total' },
-        sys_count: { $sum: '$sys_count' },
-        interface_exception_count: { $sum: '$interface_exception_count' },
-      }) },
+      { $group: ctx.helper.getTimeGroup(type,
+        { total: { $sum: '$total' },
+          sys_count: { $sum: '$sys_count' },
+          interface_exception_count: { $sum: '$interface_exception_count' },
+        }),
+      },
     ];
 
     return await ctx.model.Local.AppExceptionRecordModel.aggregate(agg);
@@ -27,32 +29,35 @@ class AppExceptionRecordService extends Service {
       return;
     }
     initData.start_time = new Date();
-    const sys_count = await this.total(timeRangData, 'sys_count');
-    const interface_exception_count = await this.total(timeRangData, 'interface_exception_count');
-    const total = sys_count + interface_exception_count;
+    const obj = await this.total(timeRangData);
 
     initData.end_time = new Date();
 
     await ctx.service.statisticsService.save(ctx.model.Local.AppExceptionRecordModel,
-      { ...initData, total, sys_count, interface_exception_count,
-      }, isForceUpdate);
+      { ...initData, ...obj }, isForceUpdate);
   }
 
-  async total({ startTime, endTime }, vString) {
+  async total({ startTime, endTime }) {
     const { ctx } = this;
     const agg = [
       { $match: ctx.helper.getTimeRangMatch(startTime, endTime, 'create_time') },
       { $group: {
         _id: null,
-        count: { $sum: `$${vString}` },
+        sys_count: { $sum: '$sys_count' },
+        interface_exception_count: { $sum: '$interface_exception_count' },
       },
       },
     ];
     const result = await ctx.model.AppExceptionRecordModel.aggregate(agg);
+    let sys_count = 0;
+    let interface_exception_count = 0;
+    let total = 0;
     if (result && result.length > 0) {
-      return result[0].count;
+      sys_count = result[0].sys_count;
+      interface_exception_count = result[0].interface_exception_count;
+      total = sys_count + interface_exception_count;
     }
-    return 0;
+    return { sys_count, interface_exception_count, total };
   }