📄 tagarrange.java
字号:
package jm.form.msn.action;
import java.io.File;
import java.io.FileOutputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import jm.JM;
import jm.entity.ESM000200;
import jm.entity.ESM000500;
import jm.form.msn.bean.BusinessUser;
import jm.form.msn.config.JMMRConfigConstants;
import jm.form.msn.ctrl.MsgSegmenter;
import jm.form.msn.util.Command;
import jm.form.msn.util.Manager;
import jm.framework.util.DBOutValue;
import jm.framework.util.SimpleEntityTable;
import jm.util.JMCheck;
import jm.util.JMEntity;
import jm.util.JMVector;
/**
* 字典整理线程
* 梦界家园MSNP15
* @author ISHome
* @since 0.5.0.2
* @version 0.5.0.2.1
*/
public class TagArrange implements Command,JMMRConfigConstants{
/**
* 整理结果
*/
private boolean arrangement = false;
@Override
public String getCommandHelp() {
// TODO Auto-generated method stub
return null;
}
/**
* 运行线程
*/
public String invoker(BusinessUser u, Manager manager) {
try {
HashMap<String, String> dic = new HashMap<String, String>(1000);
{
dic.putAll(talkPrepared());
dic.putAll(faqPrepared());
}
//保存文件
String dicFile = MsgSegmenter.DIC_FILE;
File dicOut = new File(this.getClass().getClassLoader().getSystemResource(dicFile).toURI());
dicOut.createNewFile();
FileOutputStream outfile = new FileOutputStream(dicOut);
Map.Entry entry = null;
for (Iterator iter = dic.entrySet().iterator(); iter.hasNext();) {
entry = (Map.Entry) iter.next();
if (!JMCheck.isNull(entry.getKey())) {
outfile.write(("" + entry.getKey() + "\r\n").getBytes());
}
}
outfile.close();
arrangement = true;
} catch (Exception ex) {
ex.printStackTrace();
return manager.getConfigMap().get(LANG_TAG_FORM_FAILED);
}
return manager.getConfigMap().get(LANG_TAG_FORM_SUCCESS);
}
/**
* 整理对话字典
* @return
*/
private HashMap<String, String> talkPrepared() throws Exception {
HashMap<String, String> dic = new HashMap<String, String>(1000);
//读取数据库全部TALK
ESM000200 talk = new ESM000200();
SimpleEntityTable _set = new SimpleEntityTable(talk, true);
DBOutValue _out = _set.select();
if (_out.getResultCount() > 0) {
//整理列表
JMVector lists = _out.getResultList();
String[] tags;
for (int i = 0; i < lists.size(); i++) {
try {
talk = (ESM000200) lists.get(i);
tags = talk.getTag().split(JMEntity.SPLIT);
for (int m = 0; m < tags.length; m++) {
dic.put(tags[m], JM.Author);
}
} catch (Exception e) {
//
}
}
}
return dic;
}
/**
* 整理FAQ字典
* @return
*/
private HashMap<String, String> faqPrepared() throws Exception {
HashMap<String, String> dic = new HashMap<String, String>(1000);
//读取数据库全部TAG
ESM000500 faq = new ESM000500();
SimpleEntityTable _set = new SimpleEntityTable(faq, true);
DBOutValue _out = _set.select();
if (_out.getResultCount() > 0) {
//整理列表
JMVector lists = _out.getResultList();
String[] tags;
for (int i = 0; i < lists.size(); i++) {
try {
faq = (ESM000500) lists.get(i);
tags = faq.getTag().split(JMEntity.SPLIT);
for (int m = 0; m < tags.length; m++) {
dic.put(tags[m], JM.Group);
}
} catch (Exception e) {
//
}
}
}
return dic;
}
public boolean isArrangement() {
return arrangement;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -