免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1218 | 回复: 0
打印 上一主题 下一主题

department and catagory [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-08-20 12:02 |只看该作者 |倒序浏览
package com.wm.affnet.util;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import com.wm.affnet.dao.impl.AffDeptCatMapDao;
import com.wm.affnet.dataobj.AffDeptCatMap;
@SuppressWarnings("unchecked")
public class DeptCatMap {
public static Vector deptNames;
public static HashMap> deptCatMap;
public static HashMap deptNameIdMap;
public static HashMap catNameIdMap;
public static HashMap> deptCatNameMap;
public static Hashtable hashDeptCat;
static {
  deptNames = new Vector();
  deptCatMap = new HashMap>();
  deptNameIdMap = new HashMap();
  catNameIdMap = new HashMap();
  deptCatNameMap = new HashMap>();
  hashDeptCat = new Hashtable();
  String deptName = "";
  Long deptId = 0L;
  try {
   AffDeptCatMapDao affDeptCatMapDao = AffDeptCatMapDao.getInstance();
   List list = affDeptCatMapDao.findByStatus(Constants.DEPT_CAT_MAP_STATUS_ACTIVE);
   Vector[] deptCats = new Vector[list.size()];
   Vector[] deptCatNames = new Vector[list.size()];
   int i = 0;
   deptCats[0] = new Vector();
   deptCatNames[0] = new Vector();
   if (list != null && list.size() != 0) {
    for (AffDeptCatMap affDeptCatMap : list) {
     if (!deptName.equals("")) {
      if (!deptName.equals(affDeptCatMap.getDeptName())) {
       deptNames.add(deptName);
       deptCatMap.put(deptName, deptCats);
       deptNameIdMap.put(deptName, deptId);
       ++i;
       deptCats = new Vector();
       deptCatNames = new Vector();
      }
     }
     deptName = affDeptCatMap.getDeptName();
     deptId = affDeptCatMap.getDeptId();
     String catName = affDeptCatMap.getCatName();
     Long catId = affDeptCatMap.getCatId();
     deptCats.add(catId);
     deptCatNames.add(catName);
     catNameIdMap.put(catId, catName);
     hashDeptCat.put(String.valueOf(deptId), deptName);
     hashDeptCat.put(String.valueOf(catId), catName);
    }
    deptNames.add(deptName);
    deptCatMap.put(deptName, deptCats);
    deptNameIdMap.put(deptName, deptId);
    deptCatNameMap.put(deptName, deptCatNames);
   }
  } catch (Exception e) {
   e.printStackTrace();
  }
}
public static String getScript(HashMap> deptCatMap, String strFormName,
           String strDeptName, String strCatName) {
  String javaScriptOut = "";
  Iterator iterator = deptCatMap.keySet().iterator();
  int outerCount = 0;
  while (iterator.hasNext()) {
   String mapKey = iterator.next();
   Vector mapValue = deptCatMap.get(mapKey);
   int mapValueSize = mapValue.size();
   outerCount++;
   if (outerCount == 1) {
    javaScriptOut = "if(document." + strFormName + "." + strDeptName + ".value == '"
      + deptNameIdMap.get(mapKey) + "') {\n";
   } else {
    javaScriptOut = javaScriptOut + "else if(document." + strFormName + "." + strDeptName + ".value == '"
      + deptNameIdMap.get(mapKey) + "') {\n";
   }
   for (int j = 0; j
public static Hashtable getDeptCat() {
  return hashDeptCat;
}
}


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/103458/showart_2032713.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP