Exemplo n.º 1
0
 /** @return 排序后的节点ID */
 private static String[] getSortedId() {
   if (sortedMenuNodeIds == null || sortMenuNodeIdTime < loadMenuTime) {
     log.debug("startSorting");
     sortedMenuNodeIds = MenusUtil.getSortedMenuids(getHtMenus());
     sortMenuNodeIdTime = System.currentTimeMillis();
   }
   return sortedMenuNodeIds;
 }
  /**
   * (non-Javadoc)
   *
   * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping,
   *     org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
   *     javax.servlet.http.HttpServletResponse)
   */
  public ActionForward executeme(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws IOException, ServletException {

    errors.clear();
    errors.add("header", new ActionError("errors.header"));
    errors.add("footer", new ActionError("errors.footer"));

    HttpSession hs = request.getSession();
    String uname = (String) hs.getAttribute("userid");

    // TODO 临时用来监测用
    long l_begin, l_end;
    l_begin = System.currentTimeMillis();
    commsearch.util.CommDate cdtemp = new commsearch.util.CommDate();
    commsearch.util.CommActionLog.setTempLog(
        Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
        uname,
        hs.getId(),
        "PrintEipdtl",
        "B",
        "LYC0000000",
        0);

    if (uname == null) {
      errors.add("errormessage", new ActionError("NoName"));
      saveErrors(request, errors);
      //							TODO 临时用来监测用
      l_end = System.currentTimeMillis();
      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "PrintEipdtl",
          "E",
          "LYC5555555",
          l_end - l_begin);
      return (mapping.findForward("success"));
    }
    if (uname.trim().equals("")) {
      errors.add("errormessage", new ActionError("NoName"));
      saveErrors(request, errors);
      //							TODO 临时用来监测用
      l_end = System.currentTimeMillis();
      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "PrintEipdtl",
          "E",
          "LYC6666666",
          l_end - l_begin);
      return (mapping.findForward("success"));
    }

    try {

      PropertyUtils.setSimpleProperty(form, "pagerow", "32");

      String temp = (String) request.getParameter("selectwhere");

      String stemp = temp;

      if (stemp == null) stemp = "";
      if (stemp.equals("")) {
        //							TODO 临时用来监测用
        l_end = System.currentTimeMillis();
        commsearch.util.CommActionLog.setTempLog(
            Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
            uname,
            hs.getId(),
            "PrintEipdtl",
            "E",
            "LYC3333333",
            l_end - l_begin);
        return (mapping.findForward("err"));
      }

      // temp=CommonTools.stringReplace(temp,"&#39;","'");
      DataBean dbBean = new DataBean();
      String ss = "";
      if (temp.indexOf("EIVIVN") != -1) {
        try {
          dbBean.executeSelect("select eivstr,eivnum,eivtyp from eivdtl where " + temp);
        } catch (Exception e) {
          errors.add("errormessage", new ActionError("Datebase.readdb"));
          saveErrors(request, errors);
          //								TODO 临时用来监测用
          l_end = System.currentTimeMillis();
          commsearch.util.CommActionLog.setTempLog(
              Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
              uname,
              hs.getId(),
              "PrintEipdtl",
              "C",
              "LYC9999991",
              l_end - l_begin);
          return (mapping.findForward("success"));
        }
        for (int i = 0; i < dbBean.getRowCount(); i++) {
          ss = ss + "OR (EIPSTR='" + dbBean.getElementValue(i, "eivstr").trim() + "' AND ";
          ss = ss + " EIPNUM='" + dbBean.getElementValue(i, "eivnum").trim() + "' AND ";
          ss = ss + " EIPTYP='" + dbBean.getElementValue(i, "eivtyp").trim() + "')";
        }
        ss = ss.substring(2);
        temp = ss;
      }

      PropertyUtils.setSimpleProperty(form, "selectwhere", temp);

      if (setFormbeen(form, request, temp, uname).equals("0")) {
        saveErrors(request, errors);
        //							TODO 临时用来监测用
        l_end = System.currentTimeMillis();
        commsearch.util.CommActionLog.setTempLog(
            Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
            uname,
            hs.getId(),
            "PrintEipdtl",
            "E",
            "LYC8888881",
            l_end - l_begin);
        return (mapping.findForward("success"));
      }
      log.debug("成功刷新页面");

      //						TODO 临时用来监测用
      l_end = System.currentTimeMillis();

      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "PrintEipdtl",
          "E",
          "LYC8888882",
          l_end - l_begin);
      return (mapping.findForward("success"));

    } catch (Exception e) {
      e.printStackTrace();
      //						TODO 临时用来监测用
      l_end = System.currentTimeMillis();

      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "PrintEipdtl",
          "C",
          "LYC9999999",
          l_end - l_begin);
      errors.add("errormessage", new ActionError("OrderIn.formbean"));
      saveErrors(request, errors);
      return (mapping.findForward("success"));
    }
  }
  /**
   * 将指定类代码内容传入显示FormBeen(小表格)
   *
   * @param ActionForm 显示FormBeen
   * @param String 工资卡号
   * @return String 1、成功;0、不成功;
   * @exception Exception
   */
  public String setFormbeen(ActionForm form, HttpServletRequest request, String where, String uname)
      throws Exception {

    CommDate cd = new CommDate();
    DataBean dbBean = new DataBean();

    String strsql = "";

    int maxpage = 0;
    int count = 0;
    strsql =
        "SELECT * FROM eipdtl LEFT OUTER JOIN eivdtl ON (eipstr = eivstr and eipnum=eivnum and eiptyp=eivtyp ) where eipflg='2' and  eipvdr='"
            + uname
            + "' order by EIPSTR,EIPNUM,EIPTYP";
    try {
      dbBean.executeSelect(strsql);
    } catch (Exception e) {
      e.printStackTrace();
      errors.add("errormessage", new ActionError("Datebase.readdb"));
      return "0";
    }
    log.debug("执行sql语句");

    String temp = "";
    String[] db = new String[dbBean.getRowCount()];
    for (int j = 0; j < dbBean.getRowCount(); j++) {
      temp = dbBean.getElementValue(j, "EIPSTR").trim();
      temp = temp + dbBean.getElementValue(j, "EIPNUM").trim();
      temp = temp + dbBean.getElementValue(j, "EIPTYP").trim();
      db[j] = temp;
    }

    String[] row = getArray(where, db);

    // count=dbBean.getRowCount();
    count = row.length;

    // count=dbBean.getRowCount();
    int pagerow = Integer.parseInt((String) PropertyUtils.getSimpleProperty(form, "pagerow"));

    // 计算分页显示的最大页数
    log.debug("数组大小" + String.valueOf(count + maxpage));
    String[] seq = new String[count + maxpage]; // 序号
    String[] eipstr = new String[count + maxpage]; // 商店号
    String[] eipnum = new String[count + maxpage]; // 单号
    String[] eipamt = new String[count + maxpage]; // 金额
    String[] eipdta = new String[count + maxpage]; // 交易日期
    String[] eiptyp = new String[count + maxpage]; // 交易类型
    String[] eipvdr = new String[count + maxpage]; // 供货商号
    String[] eipyta = new String[count + maxpage]; // 应付日期
    String[] eipflg = new String[count + maxpage]; // 标志

    String[] eivtrk = new String[count + maxpage]; // 	发票字轨
    String[] eivivn = new String[count + maxpage]; // 	发票号
    String[] eivamt = new String[count + maxpage]; // 	开票日期

    String[] eivtax = new String[count + maxpage]; // 应付日期

    int i = 0;
    int j = 0;

    String key = "";
    for (; i < count + maxpage; i++) {
      log.debug("数组循环" + String.valueOf(i));
      j = Integer.parseInt(row[i]);
      // if((i==jk*pagerow-1)||(i==count+maxpage-1)){
      //						if(!( tempstr.equals(dbBean.getElementValue(j,"eipstr"  ).trim()) &&
      // tempnum.equals(dbBean.getElementValue(j,"eipnum"  ).trim()) &&
      // temptyp.equals(dbBean.getElementValue(j,"eiptyp"  ).trim()))){
      //							seq[i]="";
      //							eipstr[i]="";
      //							eipnum[i]="";
      //							eipamt[i]="";
      //							eipdta[i]="";
      //							eiptyp[i]="";
      //							eipvdr[i]="";
      //							eipyta[i]="";
      //							eipflg[i]="";
      //
      //							eivtrk[i]="";
      //							eivivn[i]="";
      //							eivamt[i]="";
      //							eivtax[i]="";
      //
      //							tempstr=dbBean.getElementValue(j,"eipstr"  ).trim();
      //							tempnum=dbBean.getElementValue(j,"eipnum"  ).trim();
      //							temptyp=dbBean.getElementValue(j,"eiptyp"  ).trim();
      //
      //							i++;
      //							if(i >=count+maxpage){
      //								break;
      //							}
      //						}
      seq[i] = String.valueOf(i + 1);
      eipstr[i] = dbBean.getElementValue(j, "eipstr").trim();
      eipnum[i] = dbBean.getElementValue(j, "eipnum").trim();
      eipamt[i] = DecimalTools.format(dbBean.getElementValue(j, "eipamt").trim(), "###,##0.00");
      eipdta[i] = cd.dateFormat(dbBean.getElementValue(j, "eipdta").trim(), "L");
      eiptyp[i] = dbBean.getElementValue(j, "eiptyp").trim();
      if (!eiptyp[i].equals("")) eiptyp[i] = CodesManager.getCodeValue("20", eiptyp[i]);

      eipvdr[i] = dbBean.getElementValue(j, "eipvdr").trim();
      eipyta[i] = cd.dateFormat(dbBean.getElementValue(j, "eipyta").trim(), "L");
      eipflg[i] = dbBean.getElementValue(j, "eipflg").trim();

      eivtrk[i] = dbBean.getElementValue(j, "eivtrk").trim();
      eivivn[i] = dbBean.getElementValue(j, "eivivn").trim();
      eivtax[i] = dbBean.getElementValue(j, "eivtax").trim();
      key = dbBean.getElementValue(j, "eivser").trim();
      if (!dbBean.getElementValue(j, "eivamt").trim().equals(""))
        eivamt[i] = DecimalTools.format(dbBean.getElementValue(j, "eivamt").trim(), "###,##0.00");
    }

    log.debug("填充数组");
    PropertyUtils.setSimpleProperty(form, "seq", seq);
    PropertyUtils.setSimpleProperty(form, "eipstr", eipstr);
    PropertyUtils.setSimpleProperty(form, "eipnum", eipnum);
    PropertyUtils.setSimpleProperty(form, "eipamt", eipamt);
    PropertyUtils.setSimpleProperty(form, "eipdta", eipdta);
    PropertyUtils.setSimpleProperty(form, "eiptyp", eiptyp);
    PropertyUtils.setSimpleProperty(form, "eipvdr", eipvdr);
    PropertyUtils.setSimpleProperty(form, "eipyta", eipyta);

    PropertyUtils.setSimpleProperty(form, "eivtrk", eivtrk);
    PropertyUtils.setSimpleProperty(form, "eivivn", eivivn);
    PropertyUtils.setSimpleProperty(form, "eivamt", eivamt);
    PropertyUtils.setSimpleProperty(form, "eivtax", eivtax);

    strsql =
        "SELECT distinct eivser FROM eipdtl LEFT OUTER JOIN ( select eivstr,eivnum,eivtyp,eivdtl2.eivtrk,eivdtl2.eivivn,eivseq,eivdtl2.eivamt,eivdtl2.eivtax,eivdtl2.eivser,eivdtl2.eivdat  from eivdtl,eivdtl2 where eivdtl.eivser=eivdtl2.eivser) as a ON (eipstr = eivstr and eipnum=eivnum and eiptyp=eivtyp) where eipflg='2' and eivser='"
            + key
            + "' and  eipvdr='"
            + uname
            + "' ";
    try {
      dbBean.executeSelect(strsql);
    } catch (Exception e) {
      e.printStackTrace();
      errors.add("errormessage", new ActionError("Datebase.readdb"));
      return "0";
    }
    maxpage = dbBean.getRowCount();

    strsql =
        "SELECT distinct eivtrk,eivivn,eivseq,eivamt,eivtax,eivser,a.eivdat FROM eipdtl LEFT OUTER JOIN ( select eivstr,eivnum,eivtyp,eivdtl2.eivtrk,eivdtl2.eivivn,eivseq,eivdtl2.eivamt,eivdtl2.eivtax,eivdtl2.eivser ,eivdtl2.eivdat from eivdtl,eivdtl2 where eivdtl.eivser=eivdtl2.eivser) as a ON (eipstr = eivstr and eipnum=eivnum and eiptyp=eivtyp) where eipflg='2' and eivser='"
            + key
            + "' and eipvdr='"
            + uname
            + "' order by eivser,eivseq";
    try {
      dbBean.executeSelect(strsql);
    } catch (Exception e) {
      e.printStackTrace();
      errors.add("errormessage", new ActionError("Datebase.readdb"));
      return "0";
    }
    count = dbBean.getRowCount();
    String[] seqmx = new String[count + maxpage]; // 应付日期
    String[] eivtrkmx = new String[count + maxpage]; // 	发票字轨
    String[] eivivnmx = new String[count + maxpage]; // 	发票号
    String[] eivamtmx = new String[count + maxpage]; // 	开票日期
    String[] eivtaxmx = new String[count + maxpage]; // 应付日期
    String[] eivdat = new String[count + maxpage]; // 应付日期

    String tempser = dbBean.getElementValue(0, "eivser").trim();

    j = 0;
    i = 0;
    int k = 0;
    for (; i < count + maxpage; i++) {
      log.debug("数组循环" + String.valueOf(i));
      if (!(tempser.equals(dbBean.getElementValue(j, "eivser").trim()))) {
        seqmx[i] = "";
        eivtrkmx[i] = "";
        eivivnmx[i] = "";
        eivamtmx[i] = "";
        eivtaxmx[i] = "";
        eivdat[i] = "";

        tempser = dbBean.getElementValue(j, "eivser").trim();
        i++;
        if (i >= count + maxpage) {
          break;
        }
        k = 0;
      }
      seqmx[i] = String.valueOf(k + 1);

      eivtrkmx[i] = dbBean.getElementValue(j, "eivtrk").trim();
      eivivnmx[i] = dbBean.getElementValue(j, "eivivn").trim();
      if (!dbBean.getElementValue(j, "eivamt").trim().equals(""))
        eivamtmx[i] = DecimalTools.format(dbBean.getElementValue(j, "eivamt").trim(), "###,##0.00");
      eivtaxmx[i] = dbBean.getElementValue(j, "eivtax").trim();
      eivdat[i] = cd.dateFormat(dbBean.getElementValue(j, "eivdat").trim(), "L");
      j++;
      k++;
    }

    PropertyUtils.setSimpleProperty(form, "seqmx", seqmx);
    PropertyUtils.setSimpleProperty(form, "eivtrkmx", eivtrkmx);
    PropertyUtils.setSimpleProperty(form, "eivivnmx", eivivnmx);
    PropertyUtils.setSimpleProperty(form, "eivamtmx", eivamtmx);
    PropertyUtils.setSimpleProperty(form, "eivtaxmx", eivtaxmx);
    PropertyUtils.setSimpleProperty(form, "eivdat", eivdat);

    log.debug("填充formbeen");
    return "1";
  }
Exemplo n.º 4
0
  /** 加载菜单 */
  private static synchronized void loadMenus() {

    // 初始化
    if (contextPath == null) {
      log.error("请先设置应用程序上下文!");
      return;
    }
    htMenus = new Hashtable();
    htIndexById = new Hashtable();
    StringBuffer sbQuerySql =
        new StringBuffer("SELECT * FROM MENUALL WHERE (APPSYS = '99' OR APPSYS = '");
    sbQuerySql.append(PropertyManager.getProperty("appsys")).append("')");
    String strTempSqlwhere = PropertyManager.getProperty("menu.add.sqlwhere");
    if (sqlWhere == null || !sqlWhere.trim().equals("")) {
      if (strTempSqlwhere != null && !strTempSqlwhere.trim().equals("")) sqlWhere = strTempSqlwhere;
    } else {
      if (strTempSqlwhere != null && !strTempSqlwhere.trim().equals(""))
        sqlWhere = "(" + sqlWhere + ") AND (" + strTempSqlwhere + ")";
    }
    if (sqlWhere != null && sqlWhere.length() > 3) {
      log.debug("添加的Where条件:" + sqlWhere);
      sbQuerySql.append(" AND (").append(sqlWhere).append(") ");
    }
    sbQuerySql.append(" ORDER BY MENUID");
    DataBean db = new DataBean();
    DynaSqlBean dsb = new DynaSqlBean();
    dsb.setSql(sbQuerySql.toString());
    try {
      db.setCrs(dsb.executeQuery());
    } catch (SQLException e) {
      log.error(e.getMessage(), e);
      return;
    }
    log.debug("从数据库中取得菜单数:" + String.valueOf(db.getRowCount()));

    String strMenuNameEn;
    String strMenuNameCn;
    String strMenuId;
    String strUrl;
    String strPurview;

    // 所有菜单不用经过权限的检验,统一放到哈希表中,其中判断节点和
    // 菜单项的条件也改为仅与前一项的前两位字符相比较,如果不一样则
    // 为新的节点
    for (int i = 0; i < db.getRowCount(); i++) {
      strMenuId = db.getElementValue(i, "MENUID").trim();
      log.debug(strMenuId);
      strPurview = db.getElementValue(i, "MPURVIEW").trim();
      strMenuNameCn = db.getElementValue(i, "MNAMEC").trim();
      if (strMenuNameCn.indexOf("(&") > 0)
        strMenuNameCn = strMenuNameCn.substring(0, strMenuNameCn.indexOf("(&"));
      MenuNode mn = new MenuNode(strMenuId, strMenuNameCn);

      strMenuNameEn = db.getElementValue(i, "MNAMEE").trim();
      strUrl = db.getElementValue(i, "MFILEE").trim();
      if (strUrl.length() > 0) {
        if (strUrl.startsWith("/")) strUrl = getContextPath() + strUrl;
        strUrl = CommonTools.encodeUrl(strUrl);
      }
      mn.setUrl(strUrl);
      mn.setEnglishName(strMenuNameEn);
      mn.setPurview(strPurview);

      htIndexById.put(strMenuId, mn.getNodeId());

      // 填充主菜单
      while (i < db.getRowCount() - 1) {
        strMenuId = db.getElementValue(i + 1, "MENUID").trim();
        if (strMenuId.startsWith(mn.getNodeId().substring(0, 2))) {
          // 子菜单
          i++;
          log.debug(strMenuId);
          strPurview = db.getElementValue(i, "MPURVIEW").trim();
          //						if (!CommonTools.isMenuShow(strPurview, purview))
          //							continue;
          strMenuNameCn = db.getElementValue(i, "MNAMEC").trim();
          if (strMenuNameCn.indexOf("(&") > 0)
            strMenuNameCn = strMenuNameCn.substring(0, strMenuNameCn.indexOf("(&"));
          strMenuNameEn = db.getElementValue(i, "MNAMEE").trim();
          strUrl = db.getElementValue(i, "MFILEE").trim();
          if (strUrl.length() > 0) {
            if (strUrl.startsWith("/")) strUrl = getContextPath() + strUrl;
            strUrl = CommonTools.encodeUrl(strUrl);
          }
          MenuItem mi = new MenuItem();
          mi.setMenuId(strMenuId);
          mi.setChineseName(strMenuNameCn);
          mi.setEnglishName(strMenuNameEn);
          mi.setUrl(strUrl);
          mi.setPurview(strPurview);
          mn.addMenuItem(mi);
          htIndexById.put(strMenuId, mn.getNodeId());
        } else {
          break;
        }
      }
      htMenus.put(mn.getNodeId(), mn);
    }

    // 释放DATABEAN资源
    db.release();
    reload = false;
    loadMenuTime = System.currentTimeMillis();
    log.info(loadMenuTime);
  }