/*
   * 将前面产生的Prepare的BatchJob文件 添加上起始标志,并且重新生成新的文件,(不含Prepare的后缀了)
   * */
  public static void createAllOtherCityBatchJobReadyFile() {
    // 提取所有的城市和子域名的对应关系
    initCityAndSubdomainList();

    for (Pair pair : cityAndSubdomainList) {
      String URL_SUBDOMAIN = pair.getValue();
      String CITY_PINYING = URL_SUBDOMAIN.toUpperCase().charAt(0) + URL_SUBDOMAIN.substring(1);
      String BATCH_FILE_PREPARE_PATH =
          "./data/batch/"
              + SITE_NAME_PINYING
              + "/"
              + SITE_NAME_PINYING
              + CITY_PINYING
              + TYPE_PINYING
              + "BatchCreateJobFilePrepare.txt";
      String BATCH_FILE_READY_PATH =
          "./data/batch/"
              + SITE_NAME_PINYING
              + "/"
              + SITE_NAME_PINYING
              + CITY_PINYING
              + TYPE_PINYING
              + "BatchCreateJobFile.txt";

      String fileContent = FileUtil.getDataFile2StrKeepReturn(BATCH_FILE_PREPARE_PATH, "utf-8");
      fileContent = "^" + "\n" + fileContent + "$" + "\n";
      FileUtil.writeStr2File(fileContent, BATCH_FILE_READY_PATH, "utf-8");
      System.out.println(BATCH_FILE_READY_PATH + " is completed!");
    }
  }
  public static void createAllOtherCityBatchJobFile() {
    // 提取所有的城市和子域名的对应关系
    initCityAndSubdomainList();

    // 根据提取到的对应关系,进行所有城市的batchfile的创建
    for (Pair pair : cityAndSubdomainList) {
      AnjukeGenericRent genericRent = new AnjukeGenericRent(pair.getKey(), pair.getValue());
      genericRent.doAllProcessInOneFunction();
      System.out.println("/***************************************************************/");
      System.out.println(
          "city:" + pair.getKey() + ", subdomain:" + pair.getValue() + " is completed!");
      System.out.println("/***************************************************************/");
    }
  }
 public static ArrayList<String> getBatchJobFilePath4AllOtherCityRent() {
   // 提取所有的城市和子域名的对应关系
   initCityAndSubdomainList();
   ArrayList<String> filePathList = new ArrayList<String>();
   for (Pair pair : cityAndSubdomainList) {
     String URL_SUBDOMAIN = pair.getValue();
     String CITY_PINYING = URL_SUBDOMAIN.toUpperCase().charAt(0) + URL_SUBDOMAIN.substring(1);
     String BATCH_FILE_READY_PATH =
         "./data/batch/"
             + SITE_NAME_PINYING
             + "/"
             + SITE_NAME_PINYING
             + CITY_PINYING
             + TYPE_PINYING
             + "BatchCreateJobFile.txt";
     filePathList.add(BATCH_FILE_READY_PATH);
   }
   return filePathList;
 }
  // 提取所有的城市和子域名的对应关系
  public static void initCityAndSubdomainList() {
    String content = FileUtil.getDataFile2StrKeepReturn(ALL_OTHER_CITY_FILE_PATH, "utf-8");
    String[] lineArr = content.split("\n");
    cityAndSubdomainList = new ArrayList<Pair>();
    // 提取所有的城市和子域名的对应关系
    for (String line : lineArr) {
      String[] attrArr = line.split(",");
      String href = attrArr[0];
      String city = attrArr[1];
      String subDomain =
          href.substring(href.lastIndexOf("/") + 1, href.indexOf(".", href.lastIndexOf("/")));

      Pair pair = new Pair();
      pair.setKey(city);
      pair.setValue(subDomain);
      cityAndSubdomainList.add(pair);
      System.out.println(city + " : " + subDomain);
    }
    System.out.println("/----------------------------------------------------------------/");
    System.out.println("all cities and their subdomains extraction is completed!");
    System.out.println("/----------------------------------------------------------------/");
  }