YxyMailCountAction.java 9.1 KB
package com.espeed.action;
 
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;

import com.espeed.centre.pojo.YxyUserInfo;
import com.espeed.log.LogClass;
import com.espeed.service.YxyMailCountService;
import com.espeed.service.YxySysParamaterService;
import com.opensymphony.xwork2.ActionContext;

/**
 * 程序名称:    	EspeedMail_时速邮箱
 * 程序版本:    	V1.0
 * 作    者:    	深圳市科飞时速网络技术有限公司(0755-88843776)
 * 版权所有:    	深圳市科飞时速网络技术有限公司
 * 技术支持:    	Tech@21gmail.com
 * 单元名称:     邮件统计action(营销邮)
 * 开始时间:    	2013.12.09
 * 程 序 员:    	谢勇
 * 最后修改:    
 * 备    注:		统计邮件发送量(营销邮)    
 */
public class YxyMailCountAction extends BaseAction{
	private static final long serialVersionUID = 1L;
	
	/**首页统计信息(块块色表)*/
	public String findCountHome(){
		try {
			//获取用户session
			ActionContext ac = ActionContext.getContext();
			Map<String,Object> sess = ac.getSession();			
			YxyUserInfo user=(YxyUserInfo) sess.get("yxyuser");
			loginid=user.getLogin_id();//用户账号
			domain=user.getDomain();//用户所属域名
			countall=yxymailcountservice.findCountHome(loginid,domain);
		} catch (Exception e) {
			StringWriter sw = new StringWriter();
			e.printStackTrace(new PrintWriter(sw, true));
	        String str = sw.toString();
	        LogClass.errolog(str,loginid+"@"+domain);
		}
		return "countmap";
	}
	
	/**首页用户月统计图*/
	public String findUserMonthCount(){
		try {
			//获取用户session
			ActionContext ac = ActionContext.getContext();
			Map<String,Object> sess = ac.getSession();			
			YxyUserInfo user=(YxyUserInfo) sess.get("yxyuser");
			loginid=user.getLogin_id();//用户账号
			domain=user.getDomain();//用户所属域名
			countall=yxymailcountservice.findUserMonthCount(loginid, domain);
		} catch (Exception e) {
			StringWriter sw = new StringWriter();
			e.printStackTrace(new PrintWriter(sw, true));
	        String str = sw.toString();
	        LogClass.errolog(str,loginid+"@"+domain);
		}
		return "count";
	}
		
	/**用户已发送,设定值统计信息*/
	public String findUserSendCount(){
		try {
			//获取用户session
			ActionContext ac = ActionContext.getContext();
			Map<String,Object> sess = ac.getSession();			
			YxyUserInfo user=(YxyUserInfo) sess.get("yxyuser");
			if("".equals(loginid)||"erro".equals(loginid)){
				loginid=user.getLogin_id();//用户账号
			}
			domain=user.getDomain();//用户所属域名
			//查询用户控制参数
			Map<String,String> usergraph=yxysysparamaterservice.findParamaterByLevel(4,loginid,domain);
			//查询已发统计值
			countall=yxymailcountservice.findCountPageTop(loginid,domain);
			//日发量限制
			int daysendBig=0;
			if(usergraph.get("yxy_day_send_mail_limit")!=null){
				daysendBig=Integer.parseInt(usergraph.get("yxy_day_send_mail_limit").toString());//日最大量
			}
			countall.put("daymax",daysendBig);
			//月发量限制
			int monthsendBig=0;
			if(usergraph.get("yxy_month_send_mail_limit")!=null){
				monthsendBig=Integer.parseInt(usergraph.get("yxy_month_send_mail_limit").toString());//月最大量	
			} 
			countall.put("monthmax",monthsendBig);
			//总发量限制
			int tolsendBig=0;
			if(usergraph.get("yxy_sum_send")!=null){
				tolsendBig=Integer.parseInt(usergraph.get("yxy_sum_send").toString());//总最大量	
			}
			countall.put("tolmax",tolsendBig);

		} catch (Exception e) {
			StringWriter sw = new StringWriter();
			e.printStackTrace(new PrintWriter(sw, true));
	        String str = sw.toString();
	        LogClass.errolog(str,loginid+"@"+domain);
		}
		return "countmap";
	}
	
	/**域统计信息*/
	public String findCountDomain(){
		try {
			//获取用户session
			ActionContext ac = ActionContext.getContext();
			Map<String,Object> sess = ac.getSession();			
			YxyUserInfo user=(YxyUserInfo)sess.get("yxyuser");
			loginid=user.getLogin_id();//用户账号
			domain=user.getDomain();//用户所属域名
			countall=yxymailcountservice.findCountDomain(user);
		} catch (Exception e) {
			StringWriter sw = new StringWriter();
			e.printStackTrace(new PrintWriter(sw, true));
	        String str = sw.toString();
	        LogClass.errolog(str,loginid+"@"+domain);
		}
		return "countmap";
	}
	
	/**根据年查询每个月统计*/
	public String findYearMonthCount(){
		try {
			//获取用户session
			ActionContext ac = ActionContext.getContext();
			Map<String,Object> sess = ac.getSession();			
			YxyUserInfo user=(YxyUserInfo) sess.get("yxyuser");
			if(loginid==null||"".equals(loginid)){
				loginid=user.getLogin_id();//用户账号
			}
			domain=user.getDomain();//用户所属域名
			countallmap=yxymailcountservice.findYearMonthCount(loginid, domain, condition, conditionvalue,user);
		} catch (Exception e) {
			StringWriter sw = new StringWriter();
			e.printStackTrace(new PrintWriter(sw, true));
	        String str = sw.toString();
	        LogClass.errolog(str,loginid+"@"+domain);
		}
		return "monthcountmap";
	}
	
	/**用户今日统计*/
	public String findNowDayCount(){
		try {
			//获取用户session
			ActionContext ac = ActionContext.getContext();
			Map<String,Object> sess = ac.getSession();			
			YxyUserInfo user=(YxyUserInfo) sess.get("yxyuser");
			domain=user.getDomain();//用户所属域名
			loginid=user.getLogin_id();//用户账号
			countall=yxymailcountservice.findNowDayCount(loginid, domain);
		} catch (Exception e) {
			StringWriter sw = new StringWriter();
			e.printStackTrace(new PrintWriter(sw, true));
	        String str = sw.toString();
	        LogClass.errolog(str,loginid+"@"+domain);
		}
		return "countmap";
	}
	
	/**域剩余统计*/
	public String findDomainUseCount(){
		try {
			//获取用户session
			ActionContext ac = ActionContext.getContext();
			Map<String,Object> sess = ac.getSession();			
			YxyUserInfo user=(YxyUserInfo) sess.get("yxyuser");
			loginid=user.getLogin_id();//用户账号
			domain=user.getDomain();//用户所属域名
			//域总发送次量tolsendci
			//域总发送总量tolsend
			//域总点读量clicktol
			//域总未读量noclick
			//域总回复tolreply
			//域总退订tolun
			//countall=yxymailcountservice.findCountDomain(domain);
			countall=yxymailcountservice.findCountDomain(user);
			
			//查询企业控制参数
			Map<String,String> usergraph=yxysysparamaterservice.findParamaterByLevel(1,loginid,domain);
			//域分配总量
			int tolsendbig=Integer.parseInt(usergraph.get("yxy_domain_send").toString());
			countall.put("tolsendbig",tolsendbig);
			//已分配
			//int usecount=yxysysparamaterservice.findTolFenPeiCount(loginid, domain);
			int usecount=yxysysparamaterservice.findTolFenPeiCount(user);
			countall.put("usecount",usecount);
			//待分配
			if(tolsendbig==-1){
				countall.put("daifeipei",-1);
			}else{
				if(tolsendbig-usecount>0)
				{
					countall.put("daifeipei",tolsendbig-usecount);
				}
				else
				{
					countall.put("daifeipei",0);
				}
				//countall.put("daifeipei",tolsendbig-usecount);
			}
			return "countmap";
		} catch (Exception e) {
			StringWriter sw = new StringWriter();
			e.printStackTrace(new PrintWriter(sw, true));
	        String str = sw.toString();
	        LogClass.errolog(str,loginid+"@"+domain);
		}
		return "countmap";
	}

	private YxySysParamaterService yxysysparamaterservice;//控制参数service
	private YxyMailCountService yxymailcountservice;//统计service
	private Map<String,Integer> countall=new HashMap<String,Integer>();//域总统计返回值
	private Map<String,Map<String,Integer>> countallmap=new HashMap<String,Map<String,Integer>>();//每月统计返回值
	private String loginid="erro";
	private String domain="erro";
	private int condition;//条件
	private String conditionvalue;//条件值
	public YxySysParamaterService getYxysysparamaterservice() {
		return yxysysparamaterservice;
	}
	public void setYxysysparamaterservice(
			YxySysParamaterService yxysysparamaterservice) {
		this.yxysysparamaterservice = yxysysparamaterservice;
	}
	public YxyMailCountService getYxymailcountservice() {
		return yxymailcountservice;
	}
	public void setYxymailcountservice(YxyMailCountService yxymailcountservice) {
		this.yxymailcountservice = yxymailcountservice;
	}
	public Map<String, Integer> getCountall() {
		return countall;
	}
	public void setCountall(Map<String, Integer> countall) {
		this.countall = countall;
	}
	public Map<String, Map<String, Integer>> getCountallmap() {
		return countallmap;
	}
	public void setCountallmap(Map<String, Map<String, Integer>> countallmap) {
		this.countallmap = countallmap;
	}
	public String getLoginid() {
		return loginid;
	}
	public void setLoginid(String loginid) {
		this.loginid = loginid;
	}
	public String getDomain() {
		return domain;
	}
	public void setDomain(String domain) {
		this.domain = domain;
	}
	public int getCondition() {
		return condition;
	}
	public void setCondition(int condition) {
		this.condition = condition;
	}
	public String getConditionvalue() {
		return conditionvalue;
	}
	public void setConditionvalue(String conditionvalue) {
		this.conditionvalue = conditionvalue;
	}
}