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

📄 selectrankaction.java

📁 中青会员消费排行榜-最终版 包括基于Struts+Hibernate的前台和简易后台
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package cn.zqnet8.rank.web.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.actions.DispatchAction;

import cn.zqnet8.rank.entity.RankInfo;
import cn.zqnet8.rank.entity.RankLevel;
import cn.zqnet8.rank.entity.RankMonth;
import cn.zqnet8.rank.util.CommonUtil;
import cn.zqnet8.rank.util.EncryptCustNo;
import cn.zqnet8.web.struts.form.SelectRankForm;

/** 
 * MyEclipse Struts
 * Creation date: 03-01-2009
 * 
 * XDoclet definition:
 * @struts.action parameter="oprate" validate="true"
 */
public class SelectRankAction extends DispatchAction {

	public ActionForward select(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		SelectRankForm srf=(SelectRankForm)form;
		System.out.println("是否精确查询:"+srf.getChkValue());

		StringBuffer sb=new StringBuffer("from RankInfo where 1=1 ");
		if(srf.getChkValue()==0){
			sb.append(" and custNo like '%"+srf.getCustNo()+"%'");
		}else{
			if(srf.getCustNo().length()==15|| srf.getCustNo().length()==18){
				sb.append(" and custNo='"+srf.getCustNo()+"'");
			}			
		}
		if(srf.getLevelID()!=0){
			sb.append(" and rankLevel.levelId="+srf.getLevelID());
		}
		if(srf.getMonth().equals("0")){
			sb.append(" and rankMonth.monthDate like '"+srf.getYear()+"%'");
		}else{
			sb.append(" and rankMonth.monthDate='"+srf.getYear()+srf.getMonth()+"'");
		}
		sb.append(" order by rankLevel.levelId asc");
		String hql=sb.toString();
		System.out.println("select HQL:"+hql);
		CommonUtil.closeSession();
		List list=CommonUtil.getAllByHQL(hql);
		
		System.out.println("——————————查询完成————————————————————");
		String custNo=srf.getCustNo();
		EncryptCustNo ecn=new EncryptCustNo();
		String [] custNos=null;
		if(null==list||list.size()==0){
			ActionErrors errors=new ActionErrors();
			errors.add("notFind", new ActionMessage("notSelected"));
			super.addErrors(request, errors);
			return mapping.getInputForward();
		}else{
			custNos=new String [list.size()];
			for(int i=0;i<list.size();i++){
				RankInfo ri=(RankInfo)list.get(i);
				//为每一个会员帐号信息加密,并对关键字进行红色标记显示
				custNos[i]=ecn.encryptCustNO(ri.getCustNo()).replaceAll(custNo, "<font color=red>"+custNo+"</font>");
//				RankMonth rankMonth=ri.getRankMonth();
//				StringBuffer sb2=new StringBuffer("");
//				rankMonth.setMonthDate(new StringBuffer().append(rankMonth.getMonthDate().substring(0,4)).append("年").append(rankMonth.getMonthDate().substring(4)).append("月").toString());
//				String year=ri.getRankMonth().getMonthDate().toString().substring(0,4);
//				String month=ri.getRankMonth().getMonthDate().toString().substring(4);
//				rankMonth.setMonthDate(year+"年"+month+"月");
//				ri.setRankMonth(rankMonth);
				
			}
		}
//		CommonUtil.closeSession();
		request.setAttribute("counts", list.size());//查询出来的记录条数
		request.setAttribute("selectValue", list);//查询出来的结果集
		request.setAttribute("custNos", custNos);
		return mapping.findForward("selected");
	}
}

⌨️ 快捷键说明

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