日期:2014-05-18 浏览次数:20690 次
public void batchUpdate(){
//循环遍历所有INFOMATION_ARTICLE
Article article = new Article();
List<Article> batchList= new ArrayList<Article>();
String content=null;
List<Article> list= new ArrayList<Article>();
for(int i=0;i<700;i++){
article.setStartRow(i*1000);
article.setEndRow((i+1)*1000);
list = commonDao.queryForList("Article.getArticlePage", article);
for (Article art : list) {
content = art.getArticleContent();
int cou = 1;
List<Word> artWords = getWords(art.getId());
for (Word word : artWords) {
if (cou++ > 10) {
break;
}
try {
content=content.replace(word.getUrl(), word.getWordName());//去掉标签
content=content.replaceFirst(word.getWordName(), word.getUrl());//替换第一个
} catch (Exception e) {
}
}
Article a = new Article();
a.setId(art.getId());
a.setArticleContent(content);
batchList.add(a);
}
commonDao.batchUpdate("Article.update", batchList);
batchList.clear();
System.out.println(i);
}