📄 accountmgmtcontroller.java
字号:
package tarena.netctoss.action;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
import tarena.netctoss.biz.IAccountMgmtBIZ;
import tarena.netctoss.model.Account;
import tarena.netctoss.model.AccountDetail;
public class AccountMgmtController extends MultiActionController {
private Log log;
private IAccountMgmtBIZ accountBiz;
private String yearView;
private String monthView;
private String detailYearView;
private String detailMonthView;
private String systemErrorView;
private String moduleName;
public AccountMgmtController() {
super();
}
public ModelAndView listAccount(HttpServletRequest request, HttpServletResponse response){
System.out.println("AccountMgmtController listAccount");
ModelAndView mv = new ModelAndView();;
Collection<Account> accounts = null;
String sign = request.getParameter("sign");
/**
* 流程控制
*/
if(sign != null && sign.equals("monthView")){
mv.setViewName(monthView);
return mv;
}else if(sign != null && sign.equals("yearView")){
mv.setViewName(yearView);
return mv;
}else if(sign != null && sign.equals("detailMonthView")){
mv.setViewName(detailMonthView);
return mv;
}else if(sign != null && sign.equals("detailYearView")){
mv.setViewName(detailYearView);
return mv;
}
int year = Integer.parseInt(request.getParameter("selectYear"));
int month = 0;
if(sign != null && sign.equals("month")){
month = Integer.parseInt(request.getParameter("selectMonth"));
}
if(sign != null && sign.equals("month")){
/**
* 按月查询
*/
accounts = accountBiz.findAllAccounts(year, month);
System.out.println(accounts);
mv.setViewName(monthView);
System.out.println("按月查");
}else if(sign != null && sign.equals("year")){
/**
* 按年查询
*/
accounts = accountBiz.findAllAccounts(year);
mv.setViewName(yearView);
}
mv.addObject("accounts", accounts);
request.setAttribute("year", year);
request.setAttribute("month", month);
System.out.println("Modelandview");
return mv;
}
public ModelAndView listAccountDetail(HttpServletRequest request,
HttpServletResponse response,
Account account){
ModelAndView mv = new ModelAndView();
Collection<Account> accounts = null;
Collection<AccountDetail> ad = null;
String sign = request.getParameter("sign");
String labIp = request.getParameter("labIp");
int year = Integer.parseInt(request.getParameter("year"));
int month = 0;
double timeDuration = 0.0;
if(sign != null && sign.equals("detailMonth")){
month = Integer.parseInt(request.getParameter("month"));
}
if(sign != null && sign.equals("detailYear")){
timeDuration = new Double(request.getParameter("timeDuration"));
}
if(sign != null && sign.equals("detailMonth")){
accounts = accountBiz.findAllAccounts(year, month);
ad = accountBiz.findAccountDetails(labIp, year, month);
request.setAttribute("year", year);
request.setAttribute("month", month);
System.out.println(labIp);
for(Account a : accounts){
if(a.getLabIp().equals(labIp)){
request.setAttribute("labIp", labIp);
request.setAttribute("timeDuration", a.getTimeDuration());
}
}
mv.addObject("accounts", accounts);
mv.addObject("ad", ad);
mv.setViewName(detailMonthView);
}else if(sign != null && sign.equals("detailYear")){
request.setAttribute("year", year);
request.setAttribute("labIp", labIp);
request.setAttribute("timeDuration", timeDuration);
accounts = accountBiz.findAccountDetails(labIp, year);
mv.addObject("accounts", accounts);
mv.setViewName(detailYearView);
}
return mv;
}
public IAccountMgmtBIZ getAccountBiz() {
return accountBiz;
}
public void setAccountBiz(IAccountMgmtBIZ accountBiz) {
this.accountBiz = accountBiz;
}
public String getYearView() {
return yearView;
}
public void setYearView(String yearView) {
this.yearView = yearView;
}
public String getMonthView() {
return monthView;
}
public void setMonthView(String monthView) {
this.monthView = monthView;
}
public String getDetailYearView() {
return detailYearView;
}
public void setDetailYearView(String detailYearView) {
this.detailYearView = detailYearView;
}
public String getDetailMonthView() {
return detailMonthView;
}
public void setDetailMonthView(String detailMonthView) {
this.detailMonthView = detailMonthView;
}
public String getSystemErrorView() {
return systemErrorView;
}
public void setSystemErrorView(String systemErrorView) {
this.systemErrorView = systemErrorView;
}
public String getModuleName() {
return moduleName;
}
public void setModuleName(String moduleName) {
this.moduleName = moduleName;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -