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

📄 treemenublh.java

📁 以前做的一个j2ee的项目
💻 JAVA
字号:
package gov.gdlt.ssgly.taxcore.taxblh.gzda.service;

import java.io.*;
import java.sql.*;
import java.util.*;
import org.apache.xerces.framework.XMLParser;
import org.apache.xerces.parsers.DOMParser;
import org.w3c.dom.*;
import org.xml.sax.InputSource;

import gov.gdlt.ssgly.taxcore.taxblh.gzda.service.xmlinterface.impl.*;
import gov.gdlt.ssgly.taxcore.taxblh.gzda.service.xmlinterface.*;
import gov.gdlt.ssgly.taxcore.comm.blh.BaseBizLogicHandler;
import gov.gdlt.ssgly.taxcore.comm.exception.TaxBaseBizException;
import gov.gdlt.ssgly.taxcore.comm.exception.TaxBaseSystemException;
import gov.gdlt.ssgly.taxcore.comm.event.ResponseEvent;
import gov.gdlt.ssgly.taxcore.comm.event.RequestEvent;
import gov.gdlt.ssgly.taxweb.mbean.UserBean;
import gov.gdlt.ssgly.taxweb.comm.util.WebUtil;

import gov.gdlt.ssgly.taxcore.comm.dao.*;
import gov.gdlt.ssgly.taxcore.comm.servicelocator.SqlMapLocator;
import gov.gdlt.ssgly.taxcore.comm.config.ApplicationContext;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.common.util.PaginatedList;
import gov.gdlt.ssgly.taxcore.comm.servicelocator.*;
public class TreeMenuBLH extends BaseBizLogicHandler implements Command{
           public static final int DOC_STRING = 1;
       public static final int DOC_FILE = 2;
           private int statue;
           public TreeMenuBLH() {
             statue=0;
           }
           public String getFrameXML(String operid,String type)	{
             StringBuffer text = new StringBuffer();
             int levyLength = 100;
             String sql = "";
             //sql=" SELECT CODE, NAME, URL,TYPE, DESCTIBE ,LEVE  FROM T_GZDA_FILEMANAGERABSTR "+
             //       " WHERE  operid like '"+operid+"' and  ((filestatue='0') or (filetype='0' )) and trim(URL)='A'"+
             //       " ORDER BY LEVE ";
             sql=" select  CODE, NAME, URL,TYPE, DESCTIBE ,LEVE from ( "+
                 "      SELECT CODE, NAME, URL,TYPE, DESCTIBE ,LEVE  FROM T_GZDA_FILEMANAGERABSTR  "+
                 "      WHERE  operid like '%%' and  ((filestatue='0') or (filetype='0' )) and trim(URL)='A' "+
                 "      and (ismb is null or ismb='1' or trim(ismb)='') "+
                 "           union  "+
                 "      SELECT CODE, NAME, URL,TYPE, DESCTIBE ,LEVE  FROM T_GZDA_FILEMANAGERABSTR  "+
                 "      WHERE  operid like '%%' and  ((filestatue='0') or (filetype='0' )) and trim(URL)='A' "+
                 "      and ismb='2'  "+
                 "      and tpayerid in ( "+
                 "                     select a.nsrnbm from t_flgl_nsrflxx a ,t_flgl_flxx b where a.fl_xh=b.fl_xh "+
                 "                     and b.lrry_dm='"+operid+"' "+
                 "      ) "+
                 " ) "+
                " ORDER BY LEVE " ;


             text.append("<?xml version=\"1.0\" encoding=\"gb2312\"?>\n<tree>\n");
             Connection connection = null;

             try
             {
                 connection=JDBCLocator.getInstance().getJDBCConnection();
                 if(connection == null)
                     System.out.println("连接数据库不存功");
                 PreparedStatement ps = connection.prepareStatement(sql);
                 ResultSet rs = ps.executeQuery();
                 int oldlevel = 0;
                 while(rs.next())
                 {
                     String temp = "";
                     String tempname = "";
                     String describe = "";
                     String id="";
                     String typ="";
                     String url="";
                     temp = rs.getString("CODE").trim();
                     tempname = rs.getString("NAME") == null ? "" : rs.getString("NAME");
                     describe = rs.getString("DESCTIBE") == null ? "" : rs.getString("DESCTIBE");
                     id = rs.getString("LEVE").trim();
                     typ = rs.getString("TYPE") == null ? "" : rs.getString("TYPE");
                     url=rs.getString("URL").trim();
                     int currentlevel = temp.length();
                     if(currentlevel > oldlevel)
                     {
                         if(url.equalsIgnoreCase("A"))
                         {
                             text.append(String.valueOf(String.valueOf((new StringBuffer("<entity id=\"item")).append(currentlevel).append("#"+id).append("@"+temp).append("\">\n"))));
                             text.append(String.valueOf(String.valueOf((new StringBuffer("<description>")).append(tempname).append("</description>\n"))));
                             text.append("<oncontextmenu />\n");
                             text.append("<image>images/book.gif</image>\n");
                             text.append("<imageOpen>images/open.gif</imageOpen>\n");
                             text.append("<contents>\n");
                         } else
                         {
                             text.append(String.valueOf(String.valueOf((new StringBuffer("<entity id=\"")).append(rs.getString("URL")).append("$"+temp+"@"+tempname).append("#"+id).append("%"+typ).append("\">\n"))));
                             text.append(String.valueOf(String.valueOf((new StringBuffer("<description>")).append(tempname).append("</description>\n"))));
                             text.append("<oncontextmenu />\n");
                             text.append("<image>images/paper.gif</image>\n");
                             text.append("<imageOpen>images/paper.gif</imageOpen>\n");
                             text.append("<contents>\n");
                         }
                         oldlevel = currentlevel;
                     } else
                     if(currentlevel == oldlevel)
                     {
                         text.append("</contents>\n");
                         text.append("</entity>\n");
                         if(url.equalsIgnoreCase("A"))
                         {
                             text.append(String.valueOf(String.valueOf((new StringBuffer("<entity id=\"item")).append(currentlevel).append("#"+id).append("@"+temp).append("\">\n"))));
                             text.append(String.valueOf(String.valueOf((new StringBuffer("<description>")).append(tempname).append("</description>\n"))));
                             text.append("<oncontextmenu />\n");
                             text.append("<image>images/book.gif</image>\n");
                             text.append("<imageOpen>images/open.gif</imageOpen>\n");
                             text.append("<contents>\n");
                         } else
                         {
                             text.append(String.valueOf(String.valueOf((new StringBuffer("<entity id=\"")).append(rs.getString("URL")).append("$"+temp+"@"+tempname).append("#"+id).append("%"+typ).append("\">\n"))));
                             text.append(String.valueOf(String.valueOf((new StringBuffer("<description>")).append(tempname).append("</description>\n"))));
                             text.append("<oncontextmenu />\n");
                             text.append("<image>images/paper.gif</image>\n");
                             text.append("<imageOpen>images/paper.gif</imageOpen>\n");
                             text.append("<contents>\n");
                         }
                         text.append("\n");
                     } else
                     {
                         for(; oldlevel >= currentlevel; oldlevel--)
                         {
                             text.append("</contents>\n");
                             text.append("</entity>\n");
                         }

                         if(url.equalsIgnoreCase("A"))
                         {
                             text.append(String.valueOf(String.valueOf((new StringBuffer("<entity id=\"item")).append(currentlevel).append("#"+id).append("@"+temp).append("\">\n"))));
                             text.append(String.valueOf(String.valueOf((new StringBuffer("<description>")).append(tempname).append("</description>\n"))));
                             text.append("<oncontextmenu />\n");
                             text.append("<image>images/book.gif</image>\n");
                             text.append("<imageOpen>images/open.gif</imageOpen>\n");
                             text.append("<contents>\n");
                         } else
                         {
                             text.append(String.valueOf(String.valueOf((new StringBuffer("<entity id=\"")).append(rs.getString("URL")).append("$"+temp+"@"+tempname).append("#"+id).append("%"+typ).append("\">\n"))));
                             text.append(String.valueOf(String.valueOf((new StringBuffer("<description>")).append(tempname).append("</description>\n"))));
                             text.append("<oncontextmenu />\n");
                             text.append("<image>images/paper.gif</image>\n");
                             text.append("<imageOpen>images/paper.gif</imageOpen>\n");
                             text.append("<contents>\n");
                         }
                         oldlevel = currentlevel;
                     }
                 }
                 for(; oldlevel > 0; oldlevel--)
                 {
                     text.append("</contents>\n");
                     text.append("</entity>\n");
                 }
                 text.append("</tree>\n");
             }
             catch(SQLException ex)
             {
                 System.out.println(ex.getMessage());
                 //String s = null;
                 //return s;
             }
             finally
             {
                 try
                 {   //sqlMap.endTransaction();
                     if(connection != null)

                         connection.close();
                 }
                 catch(SQLException sqlexception) { }
             }
             return text.toString();
         }

           public String execute( RequestHelper helper ){
                 //取到传入的XML参数。
                 String xml=helper.getParaXml();
                 //String operid=WebUtil.getParameterFromContextMap("userID");
                 //String operid=(String)WebUtil.eval("#{user.userID}");
                // UserBean user=new UserBean();
                // String operid=user.getUserID();
                 //System.out.println("AAAAAAAAAAAAAAA="+operid);
                 Document doc = null;
                 XmlGetter xmlGetter = new XmlGetter();
                 try {
                     doc = xmlGetter.getXmlDoc(xml);
                 }       catch(Exception e)       {
                     System.out.println("传入的参数造型成Dom出错".concat(String.valueOf(String.valueOf(e.toString()))));
                 }
                 Element ele = doc.getDocumentElement();

                 NodeList treelist = ele.getElementsByTagName("tree");
                 Node acsn = treelist.item(0);
                 String id=(String)acsn.getLastChild().getNodeValue();

                 return  getFrameXML(id,"s");

	  }

          protected ResponseEvent validateData(RequestEvent req) throws      Exception {
             return null;
          }

          protected ResponseEvent performTask(RequestEvent req) throws
                     TaxBaseBizException, TaxBaseSystemException {

                     String dealMethod = req.getDealMethod();
                     ResponseEvent resEvn = new ResponseEvent();
                     return resEvn;
          }

         public static void main(String[] args) {
             String xml="<?xml version=\"1.0\" encoding=\"gb2312\"?><root><tree>23tygh444</tree></root>";
             Document doc = null;
             XmlGetter xmlGetter = new XmlGetter();
             try {
                 doc = xmlGetter.getXmlDoc(xml);
             }       catch(Exception e)       {
                 System.out.println("传入的参数造型成Dom出错".concat(String.valueOf(String.valueOf(e.toString()))));
             }
             Element ele = doc.getDocumentElement();
             NodeList treelist = ele.getElementsByTagName("tree");
             Node acsn = treelist.item(0);
             String oid=acsn.getLastChild().getNodeValue();
            System.out.println(oid);

        }
}

⌨️ 快捷键说明

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