📄 intergralyearsearchaction.java
字号:
package com.jn0801.intergral.detail;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
/**
* 年度积分查询的Action
*
* @author jzh
*
*/
public class IntergralYearSearchAction extends DispatchAction {
/**
* 显示年度积分查询的界面
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward show(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
IntergralYearSearchForm intergralYearSearchForm = (IntergralYearSearchForm) form;
//显示年份
List yearlist = new ArrayList();
for (int i = 2007; i <= 2020; i++) {
Map map = new HashMap();
map.put("year", i);
yearlist.add(map);
}
request.setAttribute("yearlist", yearlist);
return mapping.findForward("show");
}
/**
* 查询
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward search(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
IntergralYearSearchForm intergralYearSearchForm = (IntergralYearSearchForm) form;
//显示年份
List yearlist = new ArrayList();
for (int i = 2007; i <= 2020; i++) {
Map map = new HashMap();
map.put("year", i);
yearlist.add(map);
}
request.setAttribute("yearlist", yearlist);
//查找归属地
String phone = intergralYearSearchForm.getPhone();
IntergralSearchInf isi = new IntergralSearchImp();
String city = isi.searchCity(phone);
//获取查询年份
int year_start
= Integer.parseInt(intergralYearSearchForm.getYear_start());
int year_end
= Integer.parseInt(intergralYearSearchForm.getYear_end());
//获取积分范围
int intergral_start = intergralYearSearchForm.getIntergral_start();
int intergral_end = intergralYearSearchForm.getIntergral_end();
List<YearIntergral> list = new ArrayList<YearIntergral>();
for(int i=year_start;i<=year_end;i++){
String year = String.valueOf(i);
YearIntergral yi = isi.searchYearIntergral(phone,year,intergral_start,intergral_end);
if (yi != null) {
yi.setCity(city);
yi.setPhone(phone);
yi.setYear(year + "年");
list.add(yi);
}
}
//计算合计
int sum_consume = 0 ; //消费合计
int sum_online = 0; //在网合计
int sum_total = 0; //总计
for (YearIntergral year_inter : list) {
sum_consume = sum_consume + year_inter.getYear_consume();
sum_online = sum_online + year_inter.getYear_online();
}
sum_total = sum_consume + sum_online;
request.setAttribute("intergrallist", list);
request.setAttribute("sum_consume", sum_consume);
request.setAttribute("sum_online",sum_online);
request.setAttribute("sum_total", sum_total);
return mapping.findForward("show");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -