Browse Source

更换uat充电周期地址,修改状态机相关业务最大情况分段逻辑

z332406259 4 years ago
parent
commit
9587f13ba9

+ 1 - 1
app/schedule/updateData.js

@@ -9,7 +9,7 @@ class UpdateData extends Subscription {
       // interval: '24h', // 1 分钟间隔
       cron: '0 0 5 * * ? ', // 每天凌晨5点
       type: 'worker', //  all 指定所有的都需要执行  worker 其中一个
-      immediate: true,
+      // immediate: true,
       cronOptions: {
         tz: 'Asia/Shanghai',
       },

+ 2 - 2
app/schedule/updateData2.js

@@ -7,9 +7,9 @@ class UpdateData extends Subscription {
   static get schedule() {
     return {
       // interval: '24h', // 1 分钟间隔
-      cron: '0 0 0 * * ? ', // 每天凌晨5
+      cron: '0 0 0 * * ? ', // 每天凌晨0
       type: 'worker', //  all 指定所有的都需要执行  worker 其中一个
-      immediate: true,
+      // immediate: true,
       cronOptions: {
         tz: 'Asia/Shanghai',
       },

+ 2 - 2
app/service/TVehicleOnlineInfoService.js

@@ -291,13 +291,13 @@ class TVehicleOnlineInfoService extends Service {
     const agg = [
       // { $addFields: { create_date: { $toLong: { $arrayElemAt: [{ $split: [ '$_id', '$vin' ] }, 1 ] } } } },
       { $match: { ...ctx.helper.getTimeRangMatch(startTime,
-        endTime, 'timeStamp'), vin, _S0000: { $exists: true } } },
+        endTime, 'timeStamp'), vin, '_S0000.8': { $exists: true } } },
       { $project: {
         longitude: { $arrayElemAt: [ '$_S0000', 8 ] },
         latitude: { $arrayElemAt: [ '$_S0000', 6 ] },
       } },
     ];
-    return await this.app.getHistoryModel('2006').aggregate(agg);
+    return await this.app.getHistoryModel(ctx.helper.formatTime3(startTime)).aggregate(agg);
   }
 
 

+ 2 - 0
app/service/chargingCycleService.js

@@ -47,6 +47,8 @@ class ChargingCycleService extends Service {
         // 明确告诉 HttpClient 以 JSON 格式处理返回的响应 body
         dataType: 'json',
       });
+
+    console.log('结果', result);
     let data;
     if (result.status == 200) {
       if (result.data.code == 200) {

+ 6 - 1
app/service/iviBehaviorRecordService.js

@@ -226,7 +226,12 @@ class IviBehaviorRecordService extends Service {
       },
       { $unwind: '$ivi' },
       { $group: {
-        _id: '$ivi.behavior_id',
+        _id: '$mileage_list.start_time',
+        behavior_id: { $addToSet: '$ivi.behavior_id' },
+      } },
+      { $unwind: '$behavior_id' },
+      { $group: {
+        _id: '$behavior_id',
         count: { $sum: 1 },
       } },
     ];

+ 11 - 1
app/service/statisticsService.js

@@ -83,6 +83,16 @@ class StatisticsService extends Service {
   async task(flag, startTime, endTime) { // flag  "cond"  "do"
     const { ctx } = this;
     // 更新历史时间段数据 => 修改createBaseData的参数做循环请求即可
+    // if (this.app.redis) { // 分布式锁 防止重复执行定时任务
+    //   const result = await this.app.redis.setnx(`chart_task_${moment().format('YYYY-MM-DD')}`, '1');
+    //   await this.app.redis.expire(`chart_task_${moment().format('YYYY-MM-DD')}`, 60 * 60);
+    //   if (!result) {
+    //     return;
+    //   }
+    // } else {
+    //   return;
+    // }
+
     let satrtMoment;
     if (startTime) {
       satrtMoment = moment(startTime);
@@ -103,7 +113,7 @@ class StatisticsService extends Service {
     }
     if (!satrtMoment) {
       // satrtMoment = moment(this.ctx.helper.yesterday());
-      satrtMoment = moment('2020-07-08');
+      satrtMoment = moment('2020-07-29');
     }
     endTime = endTime || this.ctx.helper.today();
     while (satrtMoment.valueOf() < endTime) {

+ 206 - 167
app/service/tFsmHitoryService.js

@@ -134,17 +134,8 @@ class TFsmHitoryService extends Service {
       return;
     }
     initData.start_time = new Date();
-
-    // const length = 100;
-    // let startNum = 0;
-    // const vinArray = [];
-    // while (startNum % 100 == 0) {
-    //   // const v = await this.group(startNum, length, timeRangData);
-    //   vinArray.push(v);
-    //   startNum += v.length;
-    // }
     const vins = await this.group(timeRangData);
-
+    const other = await this.other(timeRangData);
     initData.end_time = new Date();
 
 
@@ -163,133 +154,196 @@ class TFsmHitoryService extends Service {
       await ctx.service.statisticsService.save(ctx.model.Local.TFsmHitoryModel,
         { ...initData, vins }, isForceUpdate);
     }
+    if (other.length > 1000) {
+      let end = 0;
+      while (end < other.length) {
+        const end2 = end + 1000;
+        const v = other.filter((item, index) => {
+          return index >= end && index < end2;
+        });
+        await ctx.service.statisticsService.save(ctx.model.Local.TFsmHitoryModel,
+          { ...initData, vins: v }, isForceUpdate);
+        end = end2;
+      }
+    } else {
+      if (other.length != 0) {
+        await ctx.service.statisticsService.save(ctx.model.Local.TFsmHitoryModel,
+          { ...initData, vins: other }, isForceUpdate);
+      }
+    }
 
   }
 
   // startNum = 0, lenth = 100,
   async group({ startTime, endTime }) {
     const { ctx } = this;
-    const agg = [
-      // { $addFields: { create_date: { $toLong: { $arrayElemAt: [{ $split: [ '$_id', '$vin' ] }, 1 ] } } } },
-      { $match: ctx.helper.getTimeRangMatch(startTime, endTime, 'timeStamp') },
-      { $group: { _id: '$vin',
-        danger_drive_cnt: { $sum: { $cond: [{ $or: [
-          { $eq: [ '$ANALYSIS_LDW_STATUS', '1' ] },
-          { $eq: [ '$ANALYSIS_BSD_STATUS', '1' ] },
-          { $eq: [ '$ANALYSIS_FCW_STATUS', '1' ] },
-          { $eq: [ '$ANALYSIS_LKA_STATUS', '1' ] },
-        ] }, 1, 0 ] } },
-        safety_air_bag_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_SAFETY_AIR_BAG_STATUS', '1' ] }, 1, 0 ] } },
-        fault_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_FAULT_STATUS', '1' ] }, 1, 0 ] } },
-        long_drive_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_DSM_STATUS', '1' ] }, 1, 0 ] } },
-        speeding_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_SPEEDING_STATUS', '1' ] }, 1, 0 ] } },
-        un_tie_sb_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_UN_TIE_SB_STATUS', '1' ] }, 1, 0 ] } },
-        leave_sw_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_LEAVE_SW_STATUS', '1' ] }, 1, 0 ] } },
-        acceleration_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_ACCELERATION_STATUS', '1' ] }, 1, 0 ] } },
-        decelerate_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_DECELERATE_STATUS', '1' ] }, 1, 0 ] } },
-        turn_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_TURN_STATUS', '1' ] }, 1, 0 ] } },
-        clu_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_CLU_STATUS', '1' ] }, 1, 0 ] } },
+    let vins = [];
+    let aggStart = startTime;
+    while (aggStart < endTime) {
+      const aggEnd = aggStart + 30 * 60 * 1000;
+      const agg = [
+        { $match: ctx.helper.getTimeRangMatch(aggStart, aggEnd, 'timeStamp') },
+        { $group: { _id: '$vin',
+          danger_drive_cnt: { $sum: { $cond: [{ $or: [
+            { $eq: [ '$ANALYSIS_LDW_STATUS', '1' ] },
+            { $eq: [ '$ANALYSIS_BSD_STATUS', '1' ] },
+            { $eq: [ '$ANALYSIS_FCW_STATUS', '1' ] },
+            { $eq: [ '$ANALYSIS_LKA_STATUS', '1' ] },
+          ] }, 1, 0 ] } },
+          safety_air_bag_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_SAFETY_AIR_BAG_STATUS', '1' ] }, 1, 0 ] } },
+          fault_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_FAULT_STATUS', '1' ] }, 1, 0 ] } },
+          long_drive_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_DSM_STATUS', '1' ] }, 1, 0 ] } },
+          speeding_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_SPEEDING_STATUS', '1' ] }, 1, 0 ] } },
+          un_tie_sb_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_UN_TIE_SB_STATUS', '1' ] }, 1, 0 ] } },
+          leave_sw_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_LEAVE_SW_STATUS', '1' ] }, 1, 0 ] } },
+          acceleration_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_ACCELERATION_STATUS', '1' ] }, 1, 0 ] } },
+          decelerate_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_DECELERATE_STATUS', '1' ] }, 1, 0 ] } },
+          turn_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_TURN_STATUS', '1' ] }, 1, 0 ] } },
+          clu_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_CLU_STATUS', '1' ] }, 1, 0 ] } },
 
-        fault_type1: { $sum: { $cond: [{ $or: [
-          { $eq: [{ $arrayElemAt: [ '$_S0100', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0102', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0116', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0107', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0152', 1 ] }, '1' ] },
-        ] }, 1, 0 ] } },
-        fault_type2: { $sum: { $cond: [{ $or: [
-          { $eq: [{ $arrayElemAt: [ '$_S0149', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0148', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0110', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0123', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0136', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0164', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0147', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0130', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0135', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0118', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0169', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0104', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0114', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0162', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0170', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0165', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0171', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0172', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0127', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0131', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0132', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0159', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0160', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0166', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0167', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0168', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0126', 1 ] }, '1' ] },
-        ] }, 1, 0 ] } },
-        fault_type3: { $sum: { $cond: [{ $or: [
-          { $eq: [{ $arrayElemAt: [ '$_S0101', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0158', 1 ] }, '1' ] },
-        ] }, 1, 0 ] } },
-        fault_type4: { $sum: { $cond: [{ $or: [
-          { $eq: [{ $arrayElemAt: [ '$_S0106', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0115', 1 ] }, '1' ] },
-        ] }, 1, 0 ] } },
-        fault_type5: { $sum: { $cond: [{ $or: [
-          { $eq: [{ $arrayElemAt: [ '$_S0105', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0109', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0111', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0157', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0145', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0113', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0117', 1 ] }, '1' ] },
-        ] }, 1, 0 ] } },
-        fault_type6: { $sum: { $cond: [{ $or: [
-          { $eq: [{ $arrayElemAt: [ '$_S0141', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0112', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0161', 1 ] }, '1' ] },
-        ] }, 1, 0 ] } },
-        fault_type7: { $sum: { $cond: [{ $or: [
-          { $eq: [{ $arrayElemAt: [ '$_S0103', 1 ] }, '1' ] },
-          { $eq: [{ $arrayElemAt: [ '$_S0143', 1 ] }, '1' ] },
-        ] }, 1, 0 ] } },
-        v_parking_cnt: { $sum: { $cond: [{ $in: [{ $arrayElemAt: [ '$_S0210', 1 ] },
-          [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ]] }, 1, 0 ] } },
-        acc_cnt: { $sum: { $cond: [{ $arrayElemAt: [ '$_S0508', 1 ] }, 1, 0 ] } },
-      } },
-      // { $skip: startNum },
-      // { $limit: lenth },
-      // { $group: {
-      //   _id: null,
-      //   vins: { $push: '$$ROOT' },
-      // } },
-      {
-        $bucketAuto: {
-          groupBy: '$_id',
-          buckets: 100,
-          output: {
-            vins: { $push: '$$ROOT' },
+          fault_type1: { $sum: { $cond: [{ $or: [
+            { $eq: [{ $arrayElemAt: [ '$_S0100', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0102', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0116', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0107', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0152', 1 ] }, '1' ] },
+          ] }, 1, 0 ] } },
+          fault_type2: { $sum: { $cond: [{ $or: [
+            { $eq: [{ $arrayElemAt: [ '$_S0149', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0148', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0110', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0123', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0136', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0164', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0147', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0130', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0135', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0118', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0169', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0104', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0114', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0162', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0170', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0165', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0171', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0172', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0127', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0131', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0132', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0159', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0160', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0166', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0167', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0168', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0126', 1 ] }, '1' ] },
+          ] }, 1, 0 ] } },
+          fault_type3: { $sum: { $cond: [{ $or: [
+            { $eq: [{ $arrayElemAt: [ '$_S0101', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0158', 1 ] }, '1' ] },
+          ] }, 1, 0 ] } },
+          fault_type4: { $sum: { $cond: [{ $or: [
+            { $eq: [{ $arrayElemAt: [ '$_S0106', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0115', 1 ] }, '1' ] },
+          ] }, 1, 0 ] } },
+          fault_type5: { $sum: { $cond: [{ $or: [
+            { $eq: [{ $arrayElemAt: [ '$_S0105', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0109', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0111', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0157', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0145', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0113', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0117', 1 ] }, '1' ] },
+          ] }, 1, 0 ] } },
+          fault_type6: { $sum: { $cond: [{ $or: [
+            { $eq: [{ $arrayElemAt: [ '$_S0141', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0112', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0161', 1 ] }, '1' ] },
+          ] }, 1, 0 ] } },
+          fault_type7: { $sum: { $cond: [{ $or: [
+            { $eq: [{ $arrayElemAt: [ '$_S0103', 1 ] }, '1' ] },
+            { $eq: [{ $arrayElemAt: [ '$_S0143', 1 ] }, '1' ] },
+          ] }, 1, 0 ] } },
+          v_parking_cnt: { $sum: { $cond: [{ $in: [{ $arrayElemAt: [ '$_S0210', 1 ] },
+            [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ]] }, 1, 0 ] } },
+          acc_cnt: { $sum: { $cond: [{ $gte: [{ $size: { $ifNull: [ '$_S0508', []] } }, 1 ] }, 1, 0 ] } },
+        } },
+        {
+          $bucketAuto: {
+            groupBy: '$_id',
+            buckets: 100,
+            output: {
+              vins: { $push: '$$ROOT' },
+            },
           },
         },
-      },
-    ];
-    // const vins = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime)).aggregate(agg)
-    //   .allowDiskUse(true);
+      ];
+      const obj = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime)).aggregate(agg)
+        .allowDiskUse(true);
+      for (const o of obj) {
+        vins = vins.concat(o.vins);
+      }
+      console.log('time', aggStart, vins.length);
+      aggStart = aggEnd;
+    }
+    return vins;
+  }
+
+  async other({ startTime, endTime }) {
+    const { ctx } = this;
+    // TODO 目前这个agg 查询非常费劲 在7.29以及以后
     let vins = [];
-    const obj = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime)).aggregate(agg)
-      .allowDiskUse(true);
-    for (const o of obj) {
-      vins = vins.concat(o.vins);
+    let pvins = [];
+    let avins = [];
+    let aggStart = startTime;
+    while (aggStart < endTime) {
+      const aggEnd = aggStart + 30 * 60 * 1000;
+      const agg = [
+        { $match: { ...ctx.helper.getTimeRangMatch(aggStart, aggEnd, 'timeStamp'),
+          '_S0210.1': { $in: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ] },
+        } },
+        { $group: { _id: '$vin' } },
+        {
+          $bucketAuto: {
+            groupBy: '$_id',
+            buckets: 100,
+            output: {
+              vins: { $push: '$$ROOT' },
+            },
+          },
+        },
+      ];
+      const agg2 = [
+        { $match: { ...ctx.helper.getTimeRangMatch(aggStart, aggEnd, 'timeStamp'),
+          '_S0508.1': { $exists: true } },
+        },
+        { $group: { _id: '$vin' } },
+        {
+          $bucketAuto: {
+            groupBy: '$_id',
+            buckets: 100,
+            output: {
+              vins: { $push: '$$ROOT' },
+            },
+          },
+        },
+      ];
+      const obj = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime)).aggregate(agg)
+        .allowDiskUse(true);
+      const obj2 = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime)).aggregate(agg2)
+        .allowDiskUse(true);
+      for (const o of obj) {
+        pvins = pvins.concat(o.vins.map(item => item._id));
+      }
+      for (const o of obj2) {
+        avins = avins.concat(o.vins.map(item => item._id));
+      }
+      aggStart = aggEnd;
     }
+    vins = [ ...new Set(pvins.concat(avins)) ];
     console.log('size', vins.length);
-
-    const packAll = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime))
-      .findOne({ timeStamp: { $gte: startTime, $lt: endTime },
-        '_S0210.1': { $in: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ] },
-      });
-    const accAll = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime))
-      .findOne({ timeStamp: { $gte: startTime, $lt: endTime },
-        '_S0508.1': { $exists: true },
-      });
+    if (vins.length == 0) {
+      return [];
+    }
     let num = 0;
     for (const vin of vins) {
       num++;
@@ -302,50 +356,35 @@ class TFsmHitoryService extends Service {
       let accCount = 0;
       let start = startTime - 1;
       console.log('pointList', pointList.length);
-      let packOne = null;
-      let accOne = null;
-      if (packAll) {
-        packOne = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime))
-          .findOne({ timeStamp: { $gte: startTime, $lt: endTime }, vin: vin._id,
-            '_S0210.1': { $in: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ] },
-          });
-      }
-      if (accAll) {
-        accOne = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime))
-          .findOne({ timeStamp: { $gte: startTime, $lt: endTime }, vin: vin._id,
-            '_S0508.1': { $exists: true },
-          });
-      }
-      if (packOne || accOne) {
-        for (let i = 0; i < pointList.length; i++) {
-          const end = pointList[i].timeStamp;
-          let pack = null;
-          let acc = null;
-          if (packOne) {
-            pack = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime))
-              .findOne({ timeStamp: { $gt: start, $lte: end }, vin: vin._id,
-                '_S0210.1': { $in: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ] },
-              });
-          }
-          if (accOne) {
-            acc = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime))
-              .findOne({
-                timeStamp: { $gt: start, $lte: end }, vin: vin._id,
-                '_S0508.1': { $exists: true },
-              });
-          }
-          if (pack || acc) {
-            intelCount++;
-          }
-          if (pack) {
-            packCount++;
-          }
-          if (acc) {
-            accCount++;
-          }
-          start = end;
+      for (let i = 0; i < pointList.length; i++) {
+        const end = pointList[i].timeStamp;
+        let pack = null;
+        let acc = null;
+        if (pvins.indexOf(vin)!=-1) {
+          pack = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime))
+            .findOne({ timeStamp: { $gt: start, $lte: end }, vin: vin._id,
+              '_S0210.1': { $in: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ] },
+            });
         }
+        if (avins.indexOf(vin)!=-1) {
+          acc = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime))
+            .findOne({
+              timeStamp: { $gt: start, $lte: end }, vin: vin._id,
+              '_S0508.1': { $exists: true },
+            });
+        }
+        if (pack || acc) {
+          intelCount++;
+        }
+        if (pack) {
+          packCount++;
+        }
+        if (acc) {
+          accCount++;
+        }
+        start = end;
       }
+
       vin.intel = intelCount;
       vin.pack = packCount;
       vin.acc = accCount;

+ 361 - 0
app/service/tFsmHitoryService2.js

@@ -0,0 +1,361 @@
+'use strict';
+
+const Service = require('egg').Service;
+
+// 状态机历史数据服务
+class TFsmHitoryService extends Service {
+
+  async danger({ type, startTime, endTime, vin }) {
+    const { ctx } = this;
+    let cond = [];
+    if (vin) {
+      cond = [{ $match: {} }];
+      cond[0].$match = { 'vins._id': vin };
+    }
+    const agg = [
+      { $match: ctx.helper.getTimeRangMatch(startTime, endTime) },
+      { $unwind: '$vins' },
+      ...cond,
+      { $group: ctx.helper.getTimeGroup(type,
+        { danger_drive_cnt: { $sum: '$vins.danger_drive_cnt' },
+          safety_air_bag_cnt: { $sum: '$vins.safety_air_bag_cnt' },
+          fault_cnt: { $sum: '$vins.fault_cnt' },
+        }),
+      },
+    ];
+
+    return await ctx.model.Local.TFsmHitoryModel.aggregate(agg);
+  }
+
+  async normal({ type, startTime, endTime, vin }) {
+    const { ctx } = this;
+    const cond = [{ $match: {} }];
+    if (vin) {
+      cond[0].$match = { 'vins._id': vin };
+    }
+    const agg = [
+      { $match: ctx.helper.getTimeRangMatch(startTime, endTime) },
+      { $unwind: '$vins' },
+      ...cond,
+      { $group: ctx.helper.getTimeGroup(type,
+        {
+          long_drive_cnt: { $sum: '$vins.long_drive_cnt' }, // 长时行驶次数
+          speeding_cnt: { $sum: '$vins.speeding_cnt' }, // 超速行驶次数
+          un_tie_sb_cnt: { $sum: '$vins.un_tie_sb_cnt' }, // 未系安全带次数
+          leave_sw_cnt: { $sum: '$vins.leave_sw_cnt' }, // 双手离开方向盘次数
+          acceleration_cnt: { $sum: '$vins.acceleration_cnt' }, // 急加速次数
+          decelerate_cnt: { $sum: '$vins.decelerate_cnt' }, // 加减速次数
+          turn_cnt: { $sum: '$vins.turn_cnt' }, // 急转弯次数
+          clu_cnt: { $sum: '$vins.clu_cnt' }, // 急换道次数
+        }),
+      },
+    ];
+
+    return await ctx.model.Local.TFsmHitoryModel.aggregate(agg);
+  }
+
+  async fault({ type, startTime, endTime, vin }) {
+    const { ctx } = this;
+    const cond = [{ $match: {} }];
+    if (vin) {
+      cond[0].$match = { 'vins._id': vin };
+    }
+    const agg = [
+      { $match: ctx.helper.getTimeRangMatch(startTime, endTime) },
+      { $unwind: '$vins' },
+      ...cond,
+      { $group: ctx.helper.getTimeGroup(type,
+        {
+          fault_type1: { $sum: '$vins.fault_type1' }, // 故障类型1
+          fault_type2: { $sum: '$vins.fault_type2' }, // 故障类型2
+          fault_type3: { $sum: '$vins.fault_type3' }, // 故障类型3
+          fault_type4: { $sum: '$vins.fault_type4' }, // 故障类型4
+          fault_type5: { $sum: '$vins.fault_type5' }, // 故障类型5
+          fault_type6: { $sum: '$vins.fault_type6' }, // 故障类型6
+          fault_type7: { $sum: '$vins.fault_type7' }, // 故障类型7
+        }),
+      },
+    ];
+
+    return await ctx.model.Local.TFsmHitoryModel.aggregate(agg);
+  }
+
+  async intelligence({ type, startTime, endTime, vin }) {
+    const { ctx } = this;
+    const cond = [{ $match: {} }];
+    if (vin) {
+      cond[0].$match = { 'vins._id': vin };
+    }
+    const agg = [
+      { $match: ctx.helper.getTimeRangMatch(startTime, endTime) },
+      { $unwind: '$vins' },
+      ...cond,
+      { $group: ctx.helper.getTimeGroup(type,
+        {
+          v_parking_cnt: { $sum: '$vins.v_parking_cnt' }, // 代客泊车次数
+          acc_cnt: { $sum: '$vins.acc_cnt' }, // ACC次数
+        }),
+      },
+    ];
+
+    return await ctx.model.Local.TFsmHitoryModel.aggregate(agg);
+  }
+
+  async intelligenceMix({ type, startTime, endTime, vin }) {
+    const { ctx } = this;
+    const cond = [{ $match: {} }];
+    if (vin) {
+      cond[0].$match = { 'vins._id': vin };
+    }
+    const agg = [
+      { $match: ctx.helper.getTimeRangMatch(startTime, endTime) },
+      { $unwind: '$vins' },
+      ...cond,
+      { $group: ctx.helper.getTimeGroup(type,
+        {
+          intel: { $sum: '$vins.intel' }, // 智能行程
+          pack: { $sum: '$vins.pack' }, // 智能行程
+          acc: { $sum: '$vins.acc' }, // 智能行程
+          mileage_cnt: { $sum: '$vins.mileage_cnt' }, // 总行程
+        }),
+      },
+    ];
+
+    return await ctx.model.Local.TFsmHitoryModel.aggregate(agg);
+  }
+
+
+  async statistics({ timeRangData, initData, isForceUpdate }) {
+    const { ctx } = this;
+
+    const hasData = await ctx.service.statisticsService.saveBefore(ctx.model.Local.TFsmHitoryModel,
+      { ...initData });
+    if (hasData && !isForceUpdate) {
+      return;
+    }
+    initData.start_time = new Date();
+
+    // const length = 100;
+    // let startNum = 0;
+    // const vinArray = [];
+    // while (startNum % 100 == 0) {
+    //   // const v = await this.group(startNum, length, timeRangData);
+    //   vinArray.push(v);
+    //   startNum += v.length;
+    // }
+    const vins = await this.group(timeRangData);
+
+    initData.end_time = new Date();
+
+
+    if (vins.length > 1000) {
+      let end = 0;
+      while (end < vins.length) {
+        const end2 = end + 1000;
+        const v = vins.filter((item, index) => {
+          return index >= end && index < end2;
+        });
+        await ctx.service.statisticsService.save(ctx.model.Local.TFsmHitoryModel,
+          { ...initData, vins: v }, isForceUpdate);
+        end = end2;
+      }
+    } else {
+      await ctx.service.statisticsService.save(ctx.model.Local.TFsmHitoryModel,
+        { ...initData, vins }, isForceUpdate);
+    }
+
+  }
+
+  // startNum = 0, lenth = 100,
+  async group({ startTime, endTime }) {
+    const { ctx } = this;
+    const agg = [
+      // { $addFields: { create_date: { $toLong: { $arrayElemAt: [{ $split: [ '$_id', '$vin' ] }, 1 ] } } } },
+      { $match: ctx.helper.getTimeRangMatch(startTime, endTime, 'timeStamp') },
+      { $group: { _id: '$vin',
+        danger_drive_cnt: { $sum: { $cond: [{ $or: [
+          { $eq: [ '$ANALYSIS_LDW_STATUS', '1' ] },
+          { $eq: [ '$ANALYSIS_BSD_STATUS', '1' ] },
+          { $eq: [ '$ANALYSIS_FCW_STATUS', '1' ] },
+          { $eq: [ '$ANALYSIS_LKA_STATUS', '1' ] },
+        ] }, 1, 0 ] } },
+        safety_air_bag_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_SAFETY_AIR_BAG_STATUS', '1' ] }, 1, 0 ] } },
+        fault_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_FAULT_STATUS', '1' ] }, 1, 0 ] } },
+        long_drive_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_DSM_STATUS', '1' ] }, 1, 0 ] } },
+        speeding_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_SPEEDING_STATUS', '1' ] }, 1, 0 ] } },
+        un_tie_sb_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_UN_TIE_SB_STATUS', '1' ] }, 1, 0 ] } },
+        leave_sw_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_LEAVE_SW_STATUS', '1' ] }, 1, 0 ] } },
+        acceleration_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_ACCELERATION_STATUS', '1' ] }, 1, 0 ] } },
+        decelerate_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_DECELERATE_STATUS', '1' ] }, 1, 0 ] } },
+        turn_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_TURN_STATUS', '1' ] }, 1, 0 ] } },
+        clu_cnt: { $sum: { $cond: [{ $eq: [ '$ANALYSIS_CLU_STATUS', '1' ] }, 1, 0 ] } },
+
+        fault_type1: { $sum: { $cond: [{ $or: [
+          { $eq: [{ $arrayElemAt: [ '$_S0100', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0102', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0116', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0107', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0152', 1 ] }, '1' ] },
+        ] }, 1, 0 ] } },
+        fault_type2: { $sum: { $cond: [{ $or: [
+          { $eq: [{ $arrayElemAt: [ '$_S0149', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0148', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0110', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0123', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0136', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0164', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0147', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0130', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0135', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0118', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0169', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0104', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0114', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0162', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0170', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0165', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0171', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0172', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0127', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0131', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0132', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0159', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0160', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0166', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0167', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0168', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0126', 1 ] }, '1' ] },
+        ] }, 1, 0 ] } },
+        fault_type3: { $sum: { $cond: [{ $or: [
+          { $eq: [{ $arrayElemAt: [ '$_S0101', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0158', 1 ] }, '1' ] },
+        ] }, 1, 0 ] } },
+        fault_type4: { $sum: { $cond: [{ $or: [
+          { $eq: [{ $arrayElemAt: [ '$_S0106', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0115', 1 ] }, '1' ] },
+        ] }, 1, 0 ] } },
+        fault_type5: { $sum: { $cond: [{ $or: [
+          { $eq: [{ $arrayElemAt: [ '$_S0105', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0109', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0111', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0157', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0145', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0113', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0117', 1 ] }, '1' ] },
+        ] }, 1, 0 ] } },
+        fault_type6: { $sum: { $cond: [{ $or: [
+          { $eq: [{ $arrayElemAt: [ '$_S0141', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0112', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0161', 1 ] }, '1' ] },
+        ] }, 1, 0 ] } },
+        fault_type7: { $sum: { $cond: [{ $or: [
+          { $eq: [{ $arrayElemAt: [ '$_S0103', 1 ] }, '1' ] },
+          { $eq: [{ $arrayElemAt: [ '$_S0143', 1 ] }, '1' ] },
+        ] }, 1, 0 ] } },
+        v_parking_cnt: { $sum: { $cond: [{ $in: [{ $arrayElemAt: [ '$_S0210', 1 ] },
+          [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ]] }, 1, 0 ] } },
+        acc_cnt: { $sum: { $cond: [{ $arrayElemAt: [ '$_S0508', 1 ] }, 1, 0 ] } },
+      } },
+      // { $skip: startNum },
+      // { $limit: lenth },
+      // { $group: {
+      //   _id: null,
+      //   vins: { $push: '$$ROOT' },
+      // } },
+      {
+        $bucketAuto: {
+          groupBy: '$_id',
+          buckets: 100,
+          output: {
+            vins: { $push: '$$ROOT' },
+          },
+        },
+      },
+    ];
+    // const vins = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime)).aggregate(agg)
+    //   .allowDiskUse(true);
+    let vins = [];
+    const obj = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime)).aggregate(agg)
+      .allowDiskUse(true);
+    for (const o of obj) {
+      vins = vins.concat(o.vins);
+    }
+    console.log('size', vins.length);
+
+    const packAll = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime))
+      .findOne({ timeStamp: { $gte: startTime, $lt: endTime },
+        '_S0210.1': { $in: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ] },
+      });
+    const accAll = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime))
+      .findOne({ timeStamp: { $gte: startTime, $lt: endTime },
+        '_S0508.1': { $exists: true },
+      });
+    let num = 0;
+    for (const vin of vins) {
+      num++;
+      console.log('vin', vin._id, num);
+      // 分别去查每个行程
+      const pointList = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime))
+        .find({ vin: vin._id, TRAVEL_STATUS: '1' }).batchSize(100000);
+      let intelCount = 0;
+      let packCount = 0;
+      let accCount = 0;
+      let start = startTime - 1;
+      console.log('pointList', pointList.length);
+      let packOne = null;
+      let accOne = null;
+      if (packAll) {
+        packOne = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime))
+          .findOne({ timeStamp: { $gte: startTime, $lt: endTime }, vin: vin._id,
+            '_S0210.1': { $in: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ] },
+          });
+      }
+      if (accAll) {
+        accOne = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime))
+          .findOne({ timeStamp: { $gte: startTime, $lt: endTime }, vin: vin._id,
+            '_S0508.1': { $exists: true },
+          });
+      }
+      if (packOne || accOne) {
+        for (let i = 0; i < pointList.length; i++) {
+          const end = pointList[i].timeStamp;
+          let pack = null;
+          let acc = null;
+          if (packOne) {
+            pack = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime))
+              .findOne({ timeStamp: { $gt: start, $lte: end }, vin: vin._id,
+                '_S0210.1': { $in: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ] },
+              });
+          }
+          if (accOne) {
+            acc = await this.app.getHistoryModel(ctx.helper.formatTime3(startTime))
+              .findOne({
+                timeStamp: { $gt: start, $lte: end }, vin: vin._id,
+                '_S0508.1': { $exists: true },
+              });
+          }
+          if (pack || acc) {
+            intelCount++;
+          }
+          if (pack) {
+            packCount++;
+          }
+          if (acc) {
+            accCount++;
+          }
+          start = end;
+        }
+      }
+      vin.intel = intelCount;
+      vin.pack = packCount;
+      vin.acc = accCount;
+      vin.mileage_cnt = pointList.length;
+    }
+    return vins;
+  }
+
+
+}
+
+module.exports = TFsmHitoryService;
+

+ 1 - 1
config/config.local.js

@@ -14,7 +14,7 @@ module.exports = () => {
 
   const userConfig = {
     chargingCycleApi: // uat
-      'http://10.120.28.6:60080/test/fawiovconditionquery/iov/analysis/driving-behavior/charging-cycle',
+      'http://10.124.20.2:60083/fawtsp/fawiovconditionquery/iov/analysis/driving-behavior/charging-cycle',
   };
 
   config.mongoose = {

+ 6 - 0
config/config.prod3.js

@@ -12,11 +12,17 @@ module.exports = appInfo => {
    **/
   const config = exports = {};
 
+  const userConfig = {
+    chargingCycleApi: // uat
+        'http://10.120.28.6:60080/test/fawiovconditionquery/iov/analysis/driving-behavior/charging-cycle',
+  };
+
   config.logger = {
     dir: `/opt/logs/${appInfo.name}`,
   };
 
   return {
     ...config,
+    ...userConfig,
   };
 };

+ 1 - 1
config/config.sit.js

@@ -16,7 +16,7 @@ module.exports = appInfo => {
 
   const userConfig = {// uat
     chargingCycleApi:
-        'http://10.120.28.6:60080/test/fawiovconditionquery/iov/analysis/driving-behavior/charging-cycle',
+        'http://10.124.20.2:60083/fawtsp/fawiovconditionquery/iov/analysis/driving-behavior/charging-cycle',
   };
 
   config.mongoose = {