|
@@ -1,6 +1,8 @@
|
|
|
'use strict';
|
|
|
const moment = require('moment');
|
|
|
|
|
|
+exports.chargingCycleApi =
|
|
|
+ 'http://10.120.28.6:60080/test/fawiovconditionquery/iov/analysis/driving-behavior/charging-cycle';
|
|
|
// 实销用户id
|
|
|
exports.saledRoleId = 90;// '90'
|
|
|
// 远控行为ID
|
|
@@ -183,7 +185,6 @@ exports.getLocationMongo = () => {
|
|
|
};
|
|
|
|
|
|
|
|
|
-
|
|
|
// 获取年龄和性别分组语句 (之前的前置语句或者结果必须存在 元素属性: id_card,gender)
|
|
|
exports.getAggAndSexMongo = () => {
|
|
|
return [
|
|
@@ -489,17 +490,17 @@ exports.getAppActiveCond = ({ startTime, endTime }) => {
|
|
|
{ $match: { ...this.getTimeRangMatch(startTime, endTime, 'login_time'), login_state: 1 } },
|
|
|
{ $sort: { login_time: 1 } },
|
|
|
{ $group: {
|
|
|
- _id: '$user_Id',
|
|
|
- login_count: { $sum: 1 },
|
|
|
- provice_name: { $first: '$provice_name' }, city_name: { $first: '$city_name' },
|
|
|
- } },
|
|
|
+ _id: '$user_Id',
|
|
|
+ login_count: { $sum: 1 },
|
|
|
+ provice_name: { $first: '$provice_name' }, city_name: { $first: '$city_name' },
|
|
|
+ } },
|
|
|
{ $lookup: { from: 't_sync_county', localField: 'provice_name', foreignField: 'province_name', as: 'area' } },
|
|
|
{ $project: {
|
|
|
- login_count: 1,
|
|
|
- area_name: { $arrayElemAt: [ '$area.area_name', 0 ] },
|
|
|
- provice_name: '$provice_name',
|
|
|
- city_name: '$city_name',
|
|
|
- } },
|
|
|
+ login_count: 1,
|
|
|
+ area_name: { $arrayElemAt: [ '$area.area_name', 0 ] },
|
|
|
+ provice_name: '$provice_name',
|
|
|
+ city_name: '$city_name',
|
|
|
+ } },
|
|
|
{ $lookup:
|
|
|
{
|
|
|
from: 'app_behavior_record',
|
|
@@ -514,10 +515,10 @@ exports.getAppActiveCond = ({ startTime, endTime }) => {
|
|
|
},
|
|
|
{ $unwind: { path: '$behaviors', preserveNullAndEmptyArrays: true } },
|
|
|
{ $group: {
|
|
|
- _id: '$_id', login_count: { $first: '$login_count' },
|
|
|
- use_duration: { $sum: { $cond: [ '$behaviors.use_duration', '$behaviors.use_duration', 0 ] } },
|
|
|
- area_name: { $first: '$area_name' }, provice_name: { $first: '$provice_name' }, city_name: { $first: '$city_name' },
|
|
|
- } },
|
|
|
+ _id: '$_id', login_count: { $first: '$login_count' },
|
|
|
+ use_duration: { $sum: { $cond: [ '$behaviors.use_duration', '$behaviors.use_duration', 0 ] } },
|
|
|
+ area_name: { $first: '$area_name' }, provice_name: { $first: '$provice_name' }, city_name: { $first: '$city_name' },
|
|
|
+ } },
|
|
|
{ $match: { $or: [{ use_duration: { $gt: 30 * 60 * 1000 } }, { login_count: { $gte: 3 } }] } },
|
|
|
];
|
|
|
};
|
|
@@ -527,24 +528,24 @@ exports.getAppActiveCond = ({ startTime, endTime }) => {
|
|
|
exports.getCarActiveCond = ({ startTime, endTime }) => {
|
|
|
return [
|
|
|
{ $lookup: {
|
|
|
- from: 'driving_behavior_info',
|
|
|
- let: { vin: '$vin' },
|
|
|
- pipeline: [{ $match: { $expr: { $and:
|
|
|
+ from: 'driving_behavior_info',
|
|
|
+ let: { vin: '$vin' },
|
|
|
+ pipeline: [{ $match: { $expr: { $and:
|
|
|
[
|
|
|
{ $eq: [ '$vin', '$$vin' ] },
|
|
|
{ $gte: [ '$start_time', this.getMonthTop(startTime) ] },
|
|
|
{ $lt: [ '$start_time', endTime ] },
|
|
|
] } } }], as: 'drive',
|
|
|
- } },
|
|
|
+ } },
|
|
|
{ $unwind: { path: '$drive', preserveNullAndEmptyArrays: true } },
|
|
|
{ $group: {
|
|
|
- _id: '$vin',
|
|
|
- mileage: { $sum: { $cond: [ '$drive.mileage', { $toDouble: '$drive.mileage' }, 0 ] } },
|
|
|
- pro_code: { $first: '$pro_code' }, city_code: { $first: '$city_code' },
|
|
|
- is_saled_car: { $first: '$is_saled_car' }, sale_date: { $first: '$sale_date' },
|
|
|
- user_id: { $first: '$user_id' },
|
|
|
- series_code: { $first: '$series_code' }, model_code: { $first: '$model_code' },
|
|
|
- } },
|
|
|
+ _id: '$vin',
|
|
|
+ mileage: { $sum: { $cond: [ '$drive.mileage', { $toDouble: '$drive.mileage' }, 0 ] } },
|
|
|
+ pro_code: { $first: '$pro_code' }, city_code: { $first: '$city_code' },
|
|
|
+ is_saled_car: { $first: '$is_saled_car' }, sale_date: { $first: '$sale_date' },
|
|
|
+ user_id: { $first: '$user_id' },
|
|
|
+ series_code: { $first: '$series_code' }, model_code: { $first: '$model_code' },
|
|
|
+ } },
|
|
|
];
|
|
|
};
|
|
|
|