public void find() { String tac = "01058001"; int c = 0; IndexParser.init(); HashMap<String, String[]> map = IndexParser.getTacMap(); Iterator it = map.keySet().iterator(); while (it.hasNext()) { String key = (String) it.next(); Tac t = dao.getByTac(key); String[] str = map.get(key); if (null != t) { t.setTac(key); t.setHsmanNameEn(str[1]); t.setHsmanName(str[1]); t.setHstypeNameEn(str[2]); t.setHstypeName(str[2]); t.setModifytime(new Date()); if (dao.update(t)) { System.out.println(" >> Update Success!"); } } else { t = new Tac(); t.setTac(key); t.setHsmanNameEn(str[1]); t.setHstypeNameEn(str[2]); System.out.println(" >> 添加数据:" + Json.toJson(t)); t = dao.save(t); if (t.getId() > 0) { c++; System.out.println(Json.toJson(t)); } } } System.out.println(" >> c:" + c); }
public void waplogPatch() throws ClassNotFoundException { if (null != dao) { System.out.println(" >> dao is not null"); List<Tac> tlist = dao.search(Tac.class, Cnd.orderBy().asc("d_id")); int fo = 0; int offset = 0; for (Tac s : tlist) { if (!s.getHsmanName().equals("参照机型名称(英文)")) { continue; } if (null == s.getHstypeName() || s.getHstypeName().equals("")) { continue; } String info = s.getHstypeName().split("/")[0]; info = info.replace("\"", "").replace("_CMCC", "").trim(); if (info.startsWith("Nokia")) { int start = info.lastIndexOf("a"); if (start > 0) { s.setHsmanName("Nokia"); s.setHsmanNameEn("Nokia"); s.setHstypeName(info.substring(start + 1, info.length())); s.setHstypeNameEn(info.substring(start + 1, info.length())); } } else if (info.startsWith("SonyEricsson")) { int start = info.lastIndexOf("n"); if (start > 0) { s.setHsmanName("SonyEricsson"); s.setHsmanNameEn("SonyEricsson"); s.setHstypeName(info.substring(start + 1, info.length())); s.setHstypeNameEn(info.substring(start + 1, info.length())); } } else { String[] hs = info.split("-"); int length = hs.length; if (length < 2) { System.out.println(" >> info:" + info); } else { if (length == 2) { s.setHsmanName(hs[0]); s.setHsmanNameEn(hs[0]); s.setHstypeName(hs[1]); s.setHstypeNameEn(hs[1]); } else if (length == 3) { s.setHsmanName(hs[0] + "-" + hs[1]); s.setHsmanNameEn(hs[0] + "-" + hs[1]); s.setHstypeName(hs[2]); s.setHstypeNameEn(hs[2]); } else { fo++; } } } if (null == s.getHsmanName() || "".equals(s.getHsmanName())) { continue; } if (null == s.getHstypeName() || "".equals(s.getHstypeName())) { continue; } if (dao.update(s)) { offset++; } // Tac tmp = dao.findByCondition(Tac.class, Cnd.where("d_tac", "=", tac.getTac())); // if(null == tmp){ // tac = dao.save(tac); // offset++; // } } System.out.println(" >> fo:" + fo); System.out.println(" >> offset:" + offset); } else { System.out.println(" >> dao is null"); } }