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

📄 cpreportaction.java

📁 这个是完整的wap项目的源码 开发语言 Java 系统架构 Struts + hibernate + spring 数据库 Mysql5.0 应用服务器Tomcat5.0 开发工具 MyEc
💻 JAVA
字号:
package com.longtime.wap.module.cp.web.action;

import java.util.ArrayList;
import java.util.List;

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

import org.apache.commons.validator.GenericValidator;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.web.struts.DispatchActionSupport;

import com.longtime.wap.common.WapConstant;
import com.longtime.wap.common.web.Page;
import com.longtime.wap.common.web.PageConstant;
import com.longtime.wap.module.cp.service.CpService;
import com.longtime.wap.module.cp.web.form.CpReportForm;

/**
 * 处理统计报表页请求
 * 
 * @author liuzb
 * @date Nov 19, 2007
 */
public class CpReportAction extends DispatchActionSupport {

	private CpService cpService;

	/**
	 * 注入服务对象
	 * 
	 * @param cpService
	 *            服务对象
	 */
	public void setCpService(CpService cpService) {
		this.cpService = cpService;
	}

	/**
	 * 处理按单位统计报表的请求
	 * 
	 * @param mapping
	 *            ActionMapping对象
	 * @param form
	 *            ActionForm对象
	 * @param request
	 *            HttpServletRequest对象
	 * @param response
	 *            HttpServletResponse对象
	 * @return ActionForward对象
	 * @throws Exception
	 *             异常对象
	 */
	public ActionForward reportByCp(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		List<String> messages = new ArrayList<String>();
		try {
			CpReportForm cpForm = (CpReportForm) form;

			// 判断日期有效性
			if (cpForm.getFromDate() != null && cpForm.getToDate() != null) {
				if (cpForm.getFromDate().compareTo(cpForm.getToDate()) > 0) {
					messages.add("开始日期不能晚于终止日期!");
					cpForm.setFromDate(null);
					cpForm.setToDate(null);
				}
			}

			Page page = null;
			String pageNumber = request.getParameter(PageConstant.PARA_PAGE);

			if (GenericValidator.isBlankOrNull(pageNumber)) {
				if (GenericValidator.isBlankOrNull(cpForm.getCurrentPage())) {
					page = new Page(1);
				} else {
					page = new Page(Integer.parseInt(cpForm.getCurrentPage()));
				}
			} else {
				page = new Page(Integer.parseInt(pageNumber));
			}
			List list = cpService.getReportByCp(page, cpForm.getFromDate(),
					cpForm.getToDate());
			request.setAttribute("cps", list);
			request.setAttribute(PageConstant.ATTR_PAGE, page);
		} catch (Exception ex) {
			messages.add(ex.getMessage());
			ex.printStackTrace();
		}
		request.setAttribute(WapConstant.WAP_GLOBAL_MESSAGES, messages);
		return mapping.findForward("reportByCp");
	}

	/**
	 * 处理按业务统计报表的请求
	 * 
	 * @param mapping
	 *            ActionMapping对象
	 * @param form
	 *            ActionForm对象
	 * @param request
	 *            HttpServletRequest对象
	 * @param response
	 *            HttpServletResponse对象
	 * @return ActionForward对象
	 * @throws Exception
	 *             异常对象
	 */
	public ActionForward reportByService(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		List<String> messages = new ArrayList<String>();
		try {
			CpReportForm cpForm = (CpReportForm) form;

			// 判断日期有效性
			if (cpForm.getFromDate() != null && cpForm.getToDate() != null) {
				if (cpForm.getFromDate().compareTo(cpForm.getToDate()) > 0) {
					messages.add("开始日期不能晚于终止日期!");
					cpForm.setFromDate(null);
					cpForm.setToDate(null);
				}
			}

			Page page = null;
			String pageNumber = request.getParameter(PageConstant.PARA_PAGE);

			if (GenericValidator.isBlankOrNull(pageNumber)) {
				if (GenericValidator.isBlankOrNull(cpForm.getCurrentPage())) {
					page = new Page(1);
				} else {
					page = new Page(Integer.parseInt(cpForm.getCurrentPage()));
				}
			} else {
				page = new Page(Integer.parseInt(pageNumber));
			}
			List list = cpService.getReportByService(page,
					cpForm.getFromDate(), cpForm.getToDate());
			request.setAttribute("cps", list);
			request.setAttribute(PageConstant.ATTR_PAGE, page);
		} catch (Exception ex) {
			messages.add(ex.getMessage());
			ex.printStackTrace();
		}
		request.setAttribute(WapConstant.WAP_GLOBAL_MESSAGES, messages);
		return mapping.findForward("reportByService");
	}
}

⌨️ 快捷键说明

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