qunfadetail_jsp.java

来自「jsp_javabean+tomcat的web管理系统!」· Java 代码 · 共 238 行

JAVA
238
字号
package org.apache.jsp.megabusi.qunfa;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;
import msrv.NDate;

public final class qunfaDetail_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {


  public String getDateFormat(String str1){
     if(str1.length()<2) return "0"+str1;
	 else return str1;
  }

  private static java.util.Vector _jspx_dependants;

  public java.util.List getDependants() {
    return _jspx_dependants;
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html; charset=gb2312");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			"", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");
      out.write("\r\n");
      msrv.NDBConn conn = null;
      synchronized (_jspx_page_context) {
        conn = (msrv.NDBConn) _jspx_page_context.getAttribute("conn", PageContext.PAGE_SCOPE);
        if (conn == null){
          conn = new msrv.NDBConn();
          _jspx_page_context.setAttribute("conn", conn, PageContext.PAGE_SCOPE);
        }
      }
      out.write("\r\n");
      out.write("<html>\r\n");
      out.write("<head>\r\n");
      out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\r\n");
      out.write("<title>无标题文档</title>\r\n");
      out.write("<style type=\"text/css\">\r\n");
      out.write("<!--\r\n");
      out.write("body {\r\n");
      out.write("\tmargin-left: 0px;\r\n");
      out.write("\tmargin-top: 0px;\r\n");
      out.write("\tmargin-right: 0px;\r\n");
      out.write("\tmargin-bottom: 0px;\r\n");
      out.write("}\r\n");
      out.write("-->\r\n");
      out.write("</style></head>\r\n");
      out.write("<body>\r\n");
      out.write('\r');
      out.write('\n');

String qunfaSql="",sid="",longCode="",gateway="",msgContent="",startDate="",endDate="";
ResultSet qunfaRs=null;
if(request.getParameter("sid")!=null&&!request.getParameter("sid").equals("")){
   sid=request.getParameter("sid");
}else{ out.println("<script>window.history.back();</script>");return;}

qunfaSql="select send_longcode,send_gateway,send_content,convert(varchar,send_startdate,120),convert(varchar,send_enddate,120) from tb_qunfa where send_id="+sid;
try{
  qunfaRs=conn.executeQuery(qunfaSql);
}catch(SQLException ex){out.println(ex.getMessage());}

try{
  while(qunfaRs.next()){
    longCode=qunfaRs.getString(1);
	gateway=qunfaRs.getString(2);
	msgContent=qunfaRs.getString(3);
	startDate=qunfaRs.getString(4);
	endDate=qunfaRs.getString(5);
  }
}catch(SQLException ex){out.println(ex.getMessage());}
finally{
   if(qunfaRs!=null){
     qunfaRs.close();
	 qunfaRs=null;
   }
   conn.closeStatement();
}
   String sDate="",eDate="",sql="",subSql="",dataName="log_report.dbo.",
         mobileTableName="log_mobile_",xltTableName="log_xlt_",mobileDeliverTable="mobile_deliver_",
		 xltDeliverTable="xlt_deliver_";
   String gatewayType="",vTableNameSql="",newDate="",newDateStr="",sDateStr="",newTableName="";
   ResultSet rs=null,vTableNameRs=null;
   int vTableNameRows=0,sAmount=0,fAmount=0,nAmount=0,tAmount=0,noSendAmount=0,days=0;
   sDate=startDate;
   eDate=endDate;
  //起止时间相差天数
      days=NDate.dateDiff("dd",sDate,eDate);
	  String sysTableName="";
	  //验证表名是否存在///////////////////////////////////////////////////
		  vTableNameSql="select name from log_report.dbo.sysobjects where xtype='U' and PATINDEX('log_%',name)<>0";
		  try{
		      vTableNameRs=conn.executeQuery(vTableNameSql);
		  }catch(SQLException ex){out.println(ex.getMessage());}
		  try{
		    while(vTableNameRs.next()){
			  sysTableName+=vTableNameRs.getString(1)+"|";
			}
		  }catch(SQLException ex){out.println(ex.getMessage());}
		  finally{
		     if(vTableNameRs!=null){
			    vTableNameRs.close();
				vTableNameRs=null;
			 }
			 conn.closeStatement();
		  }
	   //////////////////////////////////////////////////////////////////////
	   int l=0;   //当找到第一个表时设置为一
	   for(int i=0;i<=days;i++){
	      vTableNameRows=0;
			if(i!=0){
			  newDate=NDate.dateAdd("dd",i,sDate);  
			}else newDate=sDate;
			newDateStr=Integer.toString(NDate.datePart("yy",newDate))+getDateFormat(Integer.toString(NDate.datePart("mm",newDate)))+getDateFormat(Integer.toString(NDate.datePart("dd",newDate)));
			   if(gateway.endsWith("cmcc")||gateway.endsWith("unicom")){
			   newTableName=mobileTableName+newDateStr;
			   subSql="select id,log_type,report_state,report_content from "+dataName+newTableName+" where ih_gateway='"+gateway+"' and insert_time>'"+sDate+"' and insert_time<'"+eDate+"'";
			   if(!longCode.equals("")) subSql+=" and src_terminal_id='"+longCode+"'";
			   if(!msgContent.equals("")) subSql+=" and convert(varchar,msg_content) like '%"+msgContent+"%'";
			   subSql+=" and ih_gateway='"+gateway+"' and log_type=1 and report_state<0";
			}else if(gateway.indexOf("wt")!=-1||gateway.indexOf("xlt")!=-1){
			   newTableName=xltTableName+newDateStr;
			   subSql="select id,log_type,report_state,report_content count(id) from "+dataName+newTableName+" where sGateway='"+gateway+"' and insert_time>'"+sDate+"' and insert_time<'"+eDate+"'";
			   if(!longCode.equals("")) subSql+=" and sSrcTermID='"+longCode+"'";
			   if(!msgContent.equals("")) subSql+=" and convert(varchar,sMsgContent) like '%"+msgContent+"%'";
			   subSql+=" and sGateway='"+gateway+"'";
			}
		  if(sysTableName.indexOf(newTableName)!=-1) vTableNameRows=1;
          if(vTableNameRows>0){
		  if(l>0) sql+=" union all ";
		    sql+=subSql;
		    l++;
		 }
	   }
	   if(!sql.equals("")){
	       if(request.getParameter("show").equals("1")) sql="select b.report_content,count(b.id) from ("+sql+") b where b.log_type=1 and b.report_state<0 group by b.report_content";
		   else if(request.getParameter("show").equals("2")) sql="select b.report_state,count(b.id) from ("+sql+") b where b.log_type=2 group by b.report_state";
		   out.println(sql);
		   try{
			  rs=conn.executeQuery(sql);
		   }catch(SQLException ex){out.println(ex.getMessage());return;}
	   }else{out.println("<script>alert('你选择了无效的时间段!');</script>");return;}

      out.write('\r');
      out.write('\n');

   StringBuffer str=new StringBuffer();
	  	str.append("<table width='100%'  border='0' cellpadding='0' cellspacing='1' bgcolor='#CCCCCC'>");
		str.append("<tr>");
		str.append("<td align='center' bgcolor='#F2F2F2'>&nbsp;</td>");
		str.append("<td align='center' bgcolor='#FFFFFF'>错误值</td>");
		str.append("<td align='center' bgcolor='#FFFFFF'>短信条数</td>");
		str.append("<td align='center' bgcolor='#F2F2F2'>&nbsp;</td>");
		str.append("</tr>");

      out.write("\r\n");
      out.write("\r\n");
      out.write("  ");

   try{
	  while(rs.next()){
	   str.append("<tr>");
	   str.append("<td width='100' align='center' bgcolor='#F2F2F2'>&nbsp;</td>");
	   str.append("<td width='245' align='center' bgcolor='#FFFFFF'>&nbsp;"+rs.getString(1)+"</td>");
	   str.append("<td width='366' align='center' bgcolor='#FFFFFF'>&nbsp;"+rs.getString(2)+"</td>");
	   str.append("<td width='85' align='center' bgcolor='#F2F2F2'>&nbsp;</td>");
	   str.append("</tr>");
      }
   }catch(SQLException ex){out.println(ex.getMessage());return;}
   finally{
	 if(rs!=null){
	   rs.close();
	   rs=null;
	 }
	 conn.closeStatement();
   }
   str.append("</table>");
   conn.close();
   if(request.getParameter("show").equals("1")){
   
      out.write("\r\n");
      out.write("   <script>parent.sendFailTD.innerHTML=\"");
      out.print(str.toString());
      out.write("\"</script>\r\n");
      out.write("   ");

   }else if(request.getParameter("show").equals("2")){
   
      out.write("\r\n");
      out.write("   <script>parent.noSendTD.innerHTML=\"");
      out.print(str.toString());
      out.write("\"</script>\r\n");
      out.write("   ");

   }
   
      out.write('\r');
      out.write('\n');
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}

⌨️ 快捷键说明

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