@Override
  public void calculateBaseValue(List<GpsHistory> gpsHistoryList) {
    if (gpsHistoryList != null && gpsHistoryList.size() > 0) {
      GpsHistory startGps = gpsHistoryList.get(0);
      GpsHistory endGps = gpsHistoryList.get(gpsHistoryList.size() - 1);

      VehicleRegisterRecord startBase =
          vehicleRegisterDao.getLatestVehicleRegisterRecordBeforeTime(
              startGps.getHcVehicleId(), new Date(startGps.getTime()));
      VehicleRegisterRecord endBase =
          vehicleRegisterDao.getLatestVehicleRegisterRecordBeforeTime(
              startGps.getHcVehicleId(), new Date(endGps.getTime()));

      List<VehicleRegisterRecord> baseList =
          vehicleRegisterDao.getVehicleRegisterRecordListByHcVehicleId(
              startGps.getHcVehicleId(),
              startBase == null ? null : startBase.getMsgTime(),
              endBase == null ? null : endBase.getMsgTime());

      if (baseList != null && baseList.size() != 0) {
        for (GpsHistory gps : gpsHistoryList) {
          for (VehicleRegisterRecord baseValue : baseList) {
            if (baseValue.getMsgTime() < gps.getTime()) {
              gps.setOilBaseValue(
                  baseValue.getBenchmarkOilConsumption() == null
                      ? null
                      : baseValue.getBenchmarkOilConsumption().doubleValue());
              gps.setMileageBaseValue(baseValue.getBenchmarkMileage());
            }
          }
        }
      }
    }
  }
  private TrackGps convertEntityGpsToTrackGps(GpsHistory gps) {
    if (gps == null) {
      return null;
    }
    TrackGps track = new TrackGps();
    track.setId(gps.getId().toString()); // gps id
    track.setTime(
        gps.getTime() != null ? DateUtil.dateTime2String(new Date(gps.getTime())) : null); //
    track.setVehicleId(gps.getHcVehicleId()); //
    if (gps.getCardNo() != null) gps.setCardNo(gps.getCardNo().replaceAll("\\u0000", ""));
    track.setCardNo(gps.getCardNo()); //
    track.setCardBalance(null); //
    track.setPlateNo(gps.getPlateNo()); //
    track.setSpeed(gps.getSpeed()); //

    track.setMileageDayCumulative(gps.getCurrentMileageCumulative()); // 当日累积里程
    track.setOilDayCumulative(gps.getCurrentOilCumulative()); // 当日累积油耗

    track.setAltitude(gps.getAltitude()); //
    if (gps.getCardStatus() != null) {
      switch (gps.getCardStatus()) {
        case OFF_LINE:
          track.setCardStatus(CardStatus.OFFLINE);
          break;
        case ON_LINE:
          track.setCardStatus(CardStatus.ONLINE);
          break;
        default:
          track.setCardStatus(null);
      }
    }
    if (gps.getAccStatus() != null) {
      switch (gps.getAccStatus()) {
        case IGNITION:
          track.setAccStatus(AccStatus.IGNITION);
          break;
        case FLAMEOUT:
          track.setAccStatus(AccStatus.STALL);
          break;
        default:
          track.setAccStatus(null);
      }
    }
    track.setLongitude(gps.getLongitude()); //
    track.setLatitude(gps.getLatitude()); //
    if (gps.getVehicleStatus() != null) {
      track.setVehicleStatus(VehicleStatus.valueOf(gps.getVehicleStatus().name()));
    } else if (gps.getAccStatus() != null) {
      switch (gps.getAccStatus()) {
        case IGNITION:
          track.setVehicleStatus(VehicleStatus.IGNITION);
          break;
        case FLAMEOUT:
          track.setVehicleStatus(VehicleStatus.STALL);
          break;
        default:
          track.setAccStatus(null);
      }
    }
    track.setDeviceId(gps.getDeviceId()); // HSBOX 编号
    if (gps.getEnableGps() == null) {
      track.setTag(gps.getEnableGps() ? GpsTag.VALID : GpsTag.INVALID); // gps 是否有效A有效V无效
    }
    track.setSatelliteNum(gps.getSatelliteNum()); // 卫星数量

    track.setOilCumulative(gps.getOilCumulative());
    track.setMileageCumulative(
        gps.getMileageCumulative() != null ? gps.getMileageCumulative() / 1000D : null);
    return track;
  }