Пример #1
0
  /** 发送车辆故障信息 */
  private void sendVehicleProblem(String faultCodes) {
    String userNo =
        getSharedPreferences(BaseActivity.SETTING_INFOS, 0).getString(BaseActivity.NAME, "");

    String url = INFO.HTTP_HEAD + INFO.HOST_IP + "/vehicle/fault";
    CommonParser commonParser = new CommonParser();
    ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("faultCode", faultCodes));
    nameValuePairs.add(new BasicNameValuePair("userNo", userNo));
    nameValuePairs.add(
        new BasicNameValuePair("vehicleId", TongGouApplication.connetedVehicleID)); // 车辆唯一标识号
    nameValuePairs.add(
        new BasicNameValuePair("vehicleVin", TongGouApplication.connetedVIN)); // 车辆唯一标识号
    nameValuePairs.add(
        new BasicNameValuePair("obdSN", TongGouApplication.connetedObdSN)); // obd唯一标识号
    nameValuePairs.add(new BasicNameValuePair("reportTime", System.currentTimeMillis() + ""));

    NetworkState ns =
        Network.getNetwork(this).httpPostUpdateString(url, nameValuePairs, commonParser);
  }
Пример #2
0
  /**
   * 发送车况信息
   *
   * @param oilWear 油耗
   * @param currentMileage 里程
   * @param instantOilWear 瞬时油耗
   * @param oilWearPerHundred 百公里油耗
   * @param oilMassStr 油量
   * @param engineCoolantTemperature 发动机冷却液
   * @param batteryVoltage 电瓶电压
   */
  private void sendVehicleCondition(
      String oilWear,
      String currentMileage,
      String instantOilWear,
      String oilWearPerHundred,
      String oilMassStr,
      String engineCoolantTemperature,
      String batteryVoltage) {
    String vehicleVin = TongGouApplication.connetedVIN;
    String userNo =
        getSharedPreferences(BaseActivity.SETTING_INFOS, 0).getString(BaseActivity.NAME, "");
    String obdSN = TongGouApplication.connetedObdSN;
    String vehicleId = TongGouApplication.connetedVehicleID;

    long reportTime = System.currentTimeMillis();

    String oilStr = "";
    if (oilWear != null && !"".equals(oilWear) && !"N/A".equals(oilWear)) {
      oilStr = ",\"oilWear\":" + Double.valueOf(oilWear);
    }
    String currentMilStr = "";
    if (currentMileage != null && !"".equals(currentMileage) && !"N/A".equals(currentMileage)) {
      currentMilStr = ",\"currentMileage\":" + Integer.valueOf(currentMileage);
    }
    String instantOilWearStr = "";
    if (instantOilWear != null && !"".equals(instantOilWear) && !"N/A".equals(instantOilWear)) {
      instantOilWearStr = ",\"instantOilWear\":" + Double.valueOf(instantOilWear);
    }
    String oilWearPerHundredStr = "";
    if (oilWearPerHundred != null
        && !"".equals(oilWearPerHundred)
        && !"N/A".equals(oilWearPerHundred)) {
      oilWearPerHundredStr = ",\"oilWearPerHundred\":" + Double.valueOf(oilWearPerHundred);
    }
    String oilMassStrs = "";
    if (oilMassStr != null && !"%".equals(oilMassStr) && !"N/A%".equals(oilMassStr)) {
      oilMassStrs = ",\"oilMass\":\"" + oilMassStr + "\"";
    }
    String engineCoolantTemStr = "";
    if (engineCoolantTemperature != null
        && !"".equals(engineCoolantTemperature)
        && !"N/A".equals(engineCoolantTemperature)) {
      engineCoolantTemStr =
          ",\"engineCoolantTemperature\":" + Double.valueOf(engineCoolantTemperature);
    }
    String batteryVoltageStr = "";
    if (batteryVoltage != null && !"".equals(batteryVoltage) && !"N/A".equals(batteryVoltage)) {
      batteryVoltageStr = ",\"batteryVoltage\":" + Double.valueOf(batteryVoltage);
    }

    String url = INFO.HTTP_HEAD + INFO.HOST_IP + "/vehicle/condition";
    CommonParser commonParser = new CommonParser();
    long vehicleIdLong = 0;
    try {
      vehicleIdLong = Long.valueOf(vehicleId);
    } catch (NumberFormatException e) {
      TongGouApplication.showLog("车辆 id 没有获取到");
    }
    String valuePairs =
        "{\"vehicleId\":"
            + vehicleIdLong
            + ",\"vehicleVin\":\""
            + vehicleVin
            + "\""
            + ",\"userNo\":\""
            + userNo
            + "\""
            + ",\"obdSN\":\""
            + obdSN
            + "\""
            + oilStr
            + currentMilStr
            + instantOilWearStr
            + oilWearPerHundredStr
            + oilMassStrs
            + engineCoolantTemStr
            + batteryVoltageStr
            + ",\"reportTime\":"
            + reportTime
            + "}";
    TongGouApplication.showLog("发送报告参数:     ---  " + valuePairs);
    Network.getNetwork(this).httpPutUpdateString(url, valuePairs.getBytes(), commonParser);
  }