|
@@ -34,18 +34,56 @@ class TVehicleOnlineInfoService extends Service {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- // TODO 获取当前车需要的所有数据
|
|
|
+
|
|
|
async liveStatus({ vin }) {
|
|
|
const { ctx, service } = this;
|
|
|
- const result = await service.redisService.hget(vin);
|
|
|
- return result;
|
|
|
+ const online_status = await service.redisService.hget(vin, 'ONLINE_STATUS');
|
|
|
+ const running_status = await service.redisService.hget(vin, 'RUNNING_STATUS');
|
|
|
+ const network_status = await service.redisService.hget(vin, 'NETWORK_STATUS');
|
|
|
+ const failure_status = await service.redisService.hget(vin, 'FAILURE_STATUS');
|
|
|
+ const electric_status = await service.redisService.hget(vin, 'ELECTRIC_STATUS');
|
|
|
+ const dsm_status = await service.redisService.hget(vin, 'ANALYSIS_DSM_STATUS');
|
|
|
+ const speeding_status = await service.redisService.hget(vin, 'ANALYSIS_SPEEDING_STATUS');
|
|
|
+ const un_tie_sb_status = await service.redisService.hget(vin, 'ANALYSIS_UN_TIE_SB_STATUS');
|
|
|
+ const leave_sw_status = await service.redisService.hget(vin, 'ANALYSIS_LEAVE_SW_STATUS');
|
|
|
+ const acceleration_status = await service.redisService.hget(vin, 'ANALYSIS_ACCELERATION_STATUS');
|
|
|
+ const decelerate_status = await service.redisService.hget(vin, 'ANALYSIS_DECELERATE_STATUS');
|
|
|
+ const turn_status = await service.redisService.hget(vin, 'ANALYSIS_TURN_STATUS');
|
|
|
+ const clu_status = await service.redisService.hget(vin, 'ANALYSIS_CLU_STATUS');
|
|
|
+ const safety_air_bag_status = await service.redisService.hget(vin, 'ANALYSIS_SAFETY_AIR_BAG_STATUS');
|
|
|
+ const lka_status = await service.redisService.hget(vin, 'ANALYSIS_LKA_STATUS');
|
|
|
+ const ldw_status = await service.redisService.hget(vin, 'ANALYSIS_LDW_STATUS');
|
|
|
+ const bsd_status = await service.redisService.hget(vin, 'ANALYSIS_BSD_STATUS');
|
|
|
+ const fcw_status = await service.redisService.hget(vin, 'ANALYSIS_FCW_STATUS');
|
|
|
+ const fault_status = await service.redisService.hget(vin, 'ANALYSIS_FAULT_STATUS');
|
|
|
+
|
|
|
+
|
|
|
+ const v_parking = await service.redisService.hget(vin, '_S0210');// 第一个数值 [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ]
|
|
|
+ const acc = await service.redisService.hget(vin, '_S0508');
|
|
|
+ let idriving_status = 0;
|
|
|
+ const v_dict = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ];
|
|
|
+ if ((acc && acc.length > 0) || (v_parking && v_parking.length > 0 && v_dict.indexOf(v_parking[1])!=-1) ){
|
|
|
+ idriving_status = 1;
|
|
|
+ }
|
|
|
+ const traffic = await service.redisService.hget(vin, '_S0558');// 第二个数值 0:无效;1:严重拥堵;2:中度拥堵;3:轻度拥堵;4:畅通拥堵;5:高速行驶
|
|
|
+ const event = await service.redisService.hget(vin, 'EVENT0818');
|
|
|
+ // 取event里_S0100 - _S0169 的对应值 0基本是正常,具体看文档
|
|
|
+ return { online_status, running_status, network_status, failure_status, electric_status, dsm_status, speeding_status,
|
|
|
+ un_tie_sb_status, leave_sw_status, acceleration_status, decelerate_status, turn_status, clu_status, safety_air_bag_status,
|
|
|
+ lka_status, ldw_status, bsd_status, fcw_status, fault_status, idriving_status, traffic, event };
|
|
|
}
|
|
|
|
|
|
- // TODO 获取当前车 历史轨迹
|
|
|
async travel({ vin, startTime, endTime }) {
|
|
|
const { ctx } = this;
|
|
|
- // const result = await ctx.model.RedisSerive.hget(vin);
|
|
|
- // return result;
|
|
|
+ const agg = [
|
|
|
+ { $match: { ...ctx.helper.getTimeRangMatch(startTime,
|
|
|
+ endTime, 'timeStamp'), vin, _S0000: { $exists: true } } },
|
|
|
+ { $project: {
|
|
|
+ longitude: { $arrayElemAt: [ '$_S0000', 1 ] },
|
|
|
+ latitude: { $arrayElemAt: [ '$_S0000', 2 ] },
|
|
|
+ } },
|
|
|
+ ];
|
|
|
+ return await this.app.getHistoryModel('2006').aggregate(agg);
|
|
|
}
|
|
|
|
|
|
|