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

📄 reportcategoryaction.java

📁 基于Sturts+Spring+Hibernate的一个高级销售管理系统。内容丰富
💻 JAVA
字号:
package com.yuanchung.sales.struts.report.action;

import java.util.Iterator;
import java.util.List;
import java.util.Set;

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

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.yuanchung.sales.model.report.Report;
import com.yuanchung.sales.model.report.ReportCategory;
import com.yuanchung.sales.service.resport.ReportMgr;

/**
 * 报表类别Action
 * @author gzq
 *
 */
public class ReportCategoryAction extends DispatchAction {
	private static final Log log = LogFactory.getLog(ReportCategoryAction.class);
	private ReportMgr reportMgr;
	
	public void setReportMgr(ReportMgr reportMgr) {
		this.reportMgr = reportMgr;
	}
	public ActionForward toReportCategoryTree(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		return mapping.findForward("toReportCategoryTree");
	}
	public ActionForward toReportMain(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		return mapping.findForward("toReportMain");
	}
	
	public ActionForward getReportCategory(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		List<ReportCategory> lstRC = reportMgr.getReportCategory();
		StringBuilder sb = new StringBuilder("[");
		if(lstRC != null && lstRC.size() > 0){
			Iterator it = lstRC.iterator();
			boolean hasReportCategory = false;
			while(it.hasNext()){
				ReportCategory rc = (ReportCategory)it.next();
				sb.append("{id:'");
				//yctech连上category的ID作为树形节点的ID
				sb.append("yctech");
				sb.append(rc.getId());
				sb.append("',text:'");
				sb.append(rc.getName());
				sb.append("',cls:'folder'");
				List<Report> lstRT = reportMgr.findReportByReportCategoryId(rc.getId());
				if(lstRT != null && lstRT.size() > 0){
					Iterator itRT = lstRT.iterator();
					sb.append(",children:[");
					boolean hasReport = false;
					while(itRT.hasNext()){
						Report rt = (Report)itRT.next();
						sb.append("{id:'report");
						sb.append(rt.getId());
						sb.append("',text:'");
						sb.append(rt.getName());
						sb.append("',defaultCondition:");
						sb.append(rt.getDefaultCondition());
						sb.append(",cls:'file',leaf:true},");
						hasReport = true;
					}
					if(hasReport){
						sb.deleteCharAt(sb.length() - 1);
					}
					sb.append("]");
				}else{
					sb.append(",leaf:true");
				}
				hasReportCategory = true;
				sb.append("},");
			}
			if(hasReportCategory){
				sb.deleteCharAt(sb.length() - 1);
			}
		}
		sb.append("]");
		response.getWriter().write(sb.toString());
		
		return null;
	}
	
}

⌨️ 快捷键说明

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