⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dictionarycache.java

📁 管理公司合同
💻 JAVA
字号:
/*
 * Created on 2006-10-19 17:12:59
 *
 * By SinoBest
 * Copyright hnisi.com.cn, 2005-2006, All rights reserved.
 */

package cn.com.juneng.system.common.cache;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import cn.com.juneng.system.common.SpringBeanFactory;
import cn.com.juneng.system.vo.SysDicItemVOImpl;

/**
 * @author yehailong
 * 
 */

public class DictionaryCache extends AbstractCache {

	private static DictionaryCache instance;

	private DictionaryCache() {
	}

	public static DictionaryCache getInstance() {
		if (instance == null) {
			instance = new DictionaryCache();
		}
		return instance;
	}

	protected String getTableName() {
		return "sys_dic_item";
	}

	protected List loadDBData() throws Exception {
		String hql = "from SysDicItemVOImpl order by kind,code";
		return SpringBeanFactory.getCommonService().getHibernateTemplate()
				.find(hql);
	}

	private static List cacheData;

	protected List loadCacheData() {
		return cacheData;
	}

	protected void synchronzeCacheData() throws Exception {
		cacheData = loadDBData();
	}

	// 同步检查时间:秒
	protected int getCheckTime() {
		return 60;
	}

	/**
	 * 返回系统所有列表
	 * 
	 * @return
	 * @throws Exception
	 */
	public List getAllList() throws Exception {
		return this.getCacheData();
	}
	
	/**
	 * 某个字典种类的所有字典项
	 * 
	 * @param kind
	 * @return
	 * @throws Exception
	 */
	public List getKindList(String kind) throws Exception {
		List allList = this.getCacheData();
		if (allList == null) {
			return new ArrayList();
		}
		List kindList = new ArrayList();
		Map map = null;
		for (Iterator iter = allList.iterator(); iter.hasNext();) {
			SysDicItemVOImpl element = (SysDicItemVOImpl) iter
					.next();
			if (kind.equals(element.getKind())) {
				map = new HashMap();
				map.put("CODE", element.getCode());
				map.put("DETAIL", element.getDetail	());
				kindList.add(map);
			}
		}
		return kindList;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -