コード例 #1
0
  public void test() throws ClassNotFoundException {
    if (null != dao) {
      System.out.println(" >> dao is not null");
      List<String[]> list = IMEIParser.getCSV("IMEI终端型号统计.csv");
      Tac tac = null;
      for (String[] s : list) {
        tac = new Tac();
        tac.setTac(s[0]);
        tac.setHsmanName(s[1]);
        tac.setHstypeName(s[2]);

        Tac tmp = dao.findByCondition(Tac.class, Cnd.where("d_tac", "=", tac.getTac()));
        if (null == tmp) {
          tac = dao.save(tac);
          System.out.println(" >> " + tac.getId());
        } else {
          System.out.println(" >> 已存在tac[" + tmp.getTac() + "]");
        }
        break;
      }
    } else {
      System.out.println(" >> dao is null");
    }
  }
コード例 #2
0
  public void t20110514() throws Exception {
    List<String[]> list = CvsFileParser.getCSV("input_2011-05-14.csv");
    StringBuffer sb = new StringBuffer();
    int i = 0;
    HashMap map = new HashMap();
    for (String[] s : list) {
      sb.append(s[0])
          .append(",")
          .append(s[1])
          .append(",")
          .append(s[2])
          .append(",")
          .append(s[3])
          .append(",")
          .append(s[4])
          .append(",")
          .append(s[5])
          .append(",")
          .append(s[6])
          .append(",");
      String tac = s[2];
      if (null != tac && !"".equals(tac)) {
        Tac tmp = dao.findByCondition(Tac.class, Cnd.where("d_tac", "=", tac));
        try {
          if (null != tmp.getHsmanName()) {
            map.put(tmp.getHstypeName(), tmp);
          } else {
            map.put(tmp.getHstypeNameEn(), tmp);
          }
          //						System.out.println(" >> "+tmp.getHsmanName()+"|"+tmp.getHstypeName());
          //						if(GoogleSearchTools.process(tmp.getHsmanName(), tmp.getHstypeName())){
          //							System.out.println(" >> 支持GPRS");
          //							sb.append("支持");
          //							i++;
          //						}else{
          //							sb.append("不支持");
          //						}
          //					}else{
          //						System.out.println(" >> "+tmp.getHsmanNameEn()+"|"+tmp.getHstypeNameEn());
          //						if(GoogleSearchTools.process(tmp.getHsmanNameEn(), tmp.getHstypeNameEn())){
          //							System.out.println(">> 支持GPRS");
          //							sb.append("支持");
          //							i++;
          //						}else{
          //							sb.append("不支持");
          //						}
          //					}
        } catch (Exception e) {
          sb.append("不支持");
        }
        //				Thread.sleep(50);
      }
      //			sb.append("\r\n");
    }
    Iterator it = map.keySet().iterator();
    while (it.hasNext()) {
      String key = (String) it.next();
      Object obj = map.get(key);
      //			System.out.println(" >> key:"+key);
      if (null != obj) {
        Tac value = (Tac) obj;
        System.out.println(
            " >> 该手机号在成功终端中已经存在:"
                + key
                + "|"
                + value.getHsmanName()
                + "|"
                + value.getHsmanNameEn()
                + "|"
                + value.getHstypeName()
                + "|"
                + value.getHstypeNameEn());
      }
    }
    //		System.out.println(sb.toString());
    //		IOUtil.createFile(sb.toString(), "2011-05-13-1052.csv");
    System.out.println(" >> 机型数量:" + map.size());

    System.gc();
  }
コード例 #3
0
  public void waplog() throws ClassNotFoundException {
    if (null != dao) {
      System.out.println(" >> dao is not null");
      List<String[]> list = IMEIParser.getCSV("wap19.csv");
      List<Tac> tlist = dao.search(Tac.class, Cnd.orderBy().asc("d_id"));
      Tac tac = null;
      int fo = 0;
      int offset = 0;
      for (String[] s : list) {
        tac = new Tac();
        try {
          if (null == s[2] || "".equals(s[2])) {
            continue;
          }
        } catch (Exception e) {
          continue;
        }
        tac.setTac(s[2]);
        String info = s[3].split("/")[0];
        info = info.replace("\"", "").replace("_CMCC", "").trim();
        if (info.startsWith("Nokia")) {
          int start = info.lastIndexOf("a");
          if (start > 0) {
            tac.setHsmanName("Nokia");
            tac.setHstypeName(info.substring(start + 1, info.length()));
          }
        } else if (info.startsWith("SonyEricsson")) {
          int start = info.lastIndexOf("n");
          if (start > 0) {
            tac.setHsmanName("SonyEricsson");
            tac.setHstypeName(info.substring(start + 1, info.length()));
          }
        } else if (info.startsWith("OPPO")) {

        } else {
          String[] hs = info.split("-");
          int length = hs.length;
          if (length < 2) {
            System.out.println(" >> info:" + info);
          } else {
            if (length == 2) {
              tac.setHsmanName(hs[0]);
              tac.setHstypeName(hs[1]);
            } else if (length == 3) {
              tac.setHsmanName(hs[0] + "-" + hs[1]);
              tac.setHstypeName(hs[2]);
            } else {
              fo++;
            }
          }
        }

        if (null == tac.getHsmanName() || "".equals(tac.getHsmanName())) {
          continue;
        }
        if (null == tac.getHstypeName() || "".equals(tac.getHstypeName())) {
          continue;
        }
        Tac tmp = dao.findByCondition(Tac.class, Cnd.where("d_tac", "=", tac.getTac()));
        if (null == tmp) {
          tac = dao.save(tac);
          //					System.out.println(" >> "+tac.getId());
          offset++;
        } else {
          //					System.out.println(" >> 已存在tac["+tmp.getTac()+"]");
        }
      }
      System.out.println(" >> fo:" + fo);
      System.out.println(" >> offset:" + offset);
    } else {
      System.out.println(" >> dao is null");
    }
  }