/**
   * 根据视角生成不同草图(干净的)
   *
   * <p>参数:1.视角 2.草图名称
   */
  private PhotoEntity generateSketch(String sketchName) {
    Bitmap bitmap = getBitmapFromFigure(figure, sketchName);

    // 将草图文件拷贝到指定目录
    try {
      Helper.copy(
          new File(AppCommon.utilDirectory + getBitmapNameFromFigure(figure, sketchName)),
          new File(AppCommon.photoDirectory + sketchName));
    } catch (IOException e) {
      e.printStackTrace();
    }

    PhotoEntity photoEntity = new PhotoEntity();

    // 修改时,将原来的index填写进去
    int index =
        CarCheckActivity.isModify()
            ? (sketchName.equals("fSketch") ? fSketchIndex : rSketchIndex)
            : PhotoLayout.photoIndex++;

    JSONObject jsonObject = new JSONObject();

    try {
      JSONObject photoJsonObject = new JSONObject();

      photoJsonObject.put("height", bitmap.getHeight());
      photoJsonObject.put("width", bitmap.getWidth());

      jsonObject.put("Group", "frame");
      jsonObject.put("Part", sketchName);
      jsonObject.put("PhotoData", photoJsonObject);
      jsonObject.put("UserId", UserInfo.getInstance().getId());
      jsonObject.put("Key", UserInfo.getInstance().getKey());
      jsonObject.put("CarId", BasicInfoLayout.carId);
      jsonObject.put("Action", photoEntity.getModifyAction());
      jsonObject.put("Index", photoEntity.getIndex());

      photoEntity =
          PhotoUtils.generatePhotoEntity(
              jsonObject,
              sketchName,
              sketchName,
              CarCheckActivity.isModify() ? Action.MODIFY : Action.NORMAL,
              index,
              "");
    } catch (JSONException e) {
      e.printStackTrace();
    }

    return photoEntity;
  }
  @Override
  protected Boolean doInBackground(Void... params) {
    boolean success = false;

    SoapService soapService = new SoapService();
    soapService.setUtils(
        Common.getSERVER_ADDRESS() + Common.CAR_CHECK_SERVICE, Common.UPLOAD_PICTURE);

    for (int i = 0; i < photoEntityList.size(); i++) {
      if (isCancelled()) {
        break;
      }

      PhotoEntity photoEntity = photoEntityList.get(i);

      // 获取照片的物理路径
      Bitmap bitmap;

      String fileName = photoEntity.getFileName();

      if (photoEntity.getModifyAction().equals(Action.DELETE)
          || photoEntity.getModifyAction().equals(Action.COMMENT)) {
        fileName = "";
      }

      Log.d(Common.TAG, "正在上传...");
      Log.d(Common.TAG, photoEntity.getJsonString());

      // 如果照片名为空串,表示要上传空照片
      if (fileName.equals("")) {
        success = soapService.uploadPicture(photoEntity.getJsonString());
      } else {
        bitmap = BitmapFactory.decodeFile(path + fileName);

        success = soapService.uploadPicture(bitmap, photoEntity.getJsonString());
      }

      if (success) {
        // 如果成功上传,推动进度条
        Log.d(Common.TAG, "上传成功!");
        publishProgress(i + 1);
      } else {
        i--;
      }
    }

    return success;
  }