80e24d6e4b90c4bb218b5edae6dc9cb76204c3d2.svn-base 25.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696
package com.espeed.yxy.service.impl;

import java.io.File;
import java.io.FileWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;

import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.springframework.beans.BeanUtils;

import com.espeed.centre.pojo.CentreTrackSet;
import com.espeed.centre.pojo.CentreYxyedmNewcustomer;
import com.espeed.centre.pojo.CentreYxyedmOldcustomer;
import com.espeed.yxy.dao.CentreTrackSetDao;
import com.espeed.yxy.dao.CentreUserDao;
import com.espeed.yxy.dao.CentreYxyedmNewcustomerDao;
import com.espeed.yxy.dao.CentreYxyedmOldcustomerDao;
import com.espeed.yxy.dao.YxyParamaterDao;
import com.espeed.yxy.dao.YxyReplyInfoDao;
import com.espeed.yxy.dao.YxySendFilterAddressDao;
import com.espeed.yxy.dao.YxySendMailDetailDao;
import com.espeed.yxy.dao.YxySendMailMasterBaseDao;
import com.espeed.yxy.dao.YxySendMailMasterDao;
import com.espeed.yxy.dao.YxySendSmtpInfoDao;
import com.espeed.yxy.dao.YxySmtpSendSelfOversetDao;
import com.espeed.yxy.dao.YxySmtpSendSelfSetDao;
import com.espeed.yxy.dao.YxySmtpSendSetDao;
import com.espeed.yxy.dao.YxySmtpSuffixSetDao;
import com.espeed.yxy.dao.YxySysParamatersValueDao;
import com.espeed.yxy.pojo.YxyReplyInfo;
import com.espeed.yxy.pojo.YxySendFilterAddress;
import com.espeed.yxy.pojo.YxySendMailDetail;
import com.espeed.yxy.pojo.YxySendMailMaster;
import com.espeed.yxy.pojo.YxySendMailMasterBase;
import com.espeed.yxy.pojo.YxySendSmtpInfo;
import com.espeed.yxy.pojo.YxySmtpSendSelfOverset;
import com.espeed.yxy.pojo.YxySmtpSendSelfSet;
import com.espeed.yxy.pojo.YxySmtpSendSet;
import com.espeed.yxy.pojo.YxySmtpSuffixSet;
import com.espeed.yxy.pojo.YxySysParamaters;
import com.espeed.yxy.pojo.YxySysParamatersValue;
import com.espeed.yxy.pojo.YxyUserAddress;
import com.espeed.yxy.service.YxySendMailService;
import com.espeed.yxy.tool.ConfigPath;
import com.espeed.yxy.tool.DateFormat;
import com.espeed.yxy.tool.createAndDeleteFile;
/**
 * 程序名称:    	EspeedMail_时速邮箱
 * 程序版本:    	V1.0
 * 作    者:    	深圳市科飞时速网络技术有限公司(0755-88843776)
 * 版权所有:    	深圳市科飞时速网络技术有限公司
 * 技术支持:    	Tech@21gmail.com
 * 单元名称:    邮件发送service业务接口实现类(营销游)
 * 开始时间:    	2013.12.09
 * 程 序 员:    	谢勇
 * 最后修改:    
 * 备    注:		如需修改请通知程序员    
 */
public class YxySendMailServiceImpl implements YxySendMailService{

	//------------------------待发邮件操作模块-----------------------------	
	/**查询所有待发邮件*/
	public List<YxySendMailMaster> findByMailNum(int mailNum) throws Exception {
		//正常可用的对象集合
		List<YxySendMailMaster> copymail=new ArrayList<YxySendMailMaster>();
		//数据库返回的结果集
		String hql="from YxySendMailMaster where isuse=0 and (status=0 or status=2) order by create_time";
		List<YxySendMailMaster> sendmailList=yxysendmailmasterdao.findByHql(hql);
		if(sendmailList.size()>0){
			//当前时间
			SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String nowdate=df.format(new Date());
			//相隔分数
			long minytelcha=0;
			//判断是不是定时邮件
			for(int i=0;i<sendmailList.size();i++){
				//如果等于指定条的相同则不在比较
				if(copymail.size()==mailNum){
					break;
				}
				if(sendmailList.get(i).getPlans_send()==1){//是定时邮件
					//判断是否定时时间到了当前时间
					minytelcha= DateFormat.minute1s(nowdate,sendmailList.get(i).getPlans_send_time());
					if(minytelcha<0){//如果在此时间内则加入该对象
						copymail.add(sendmailList.get(i));
					}
				}else{//不是定时邮件
					copymail.add(sendmailList.get(i));
				}
			}
			return copymail;
		}else{
			return	sendmailList;
		}
	}
	
	/**修改邮件使用状态*/
	public void updateMailUseStatus(int mailid, int isuse,String timer) throws Exception {	
		String hql="";
		if(!timer.equals("")){
			hql="update YxySendMailMaster set isuse="+isuse+",result_remark='"+timer+"' where send_mail_id="+mailid;
		}else{
			hql="update YxySendMailMaster set isuse="+isuse+" where send_mail_id="+mailid;
		}		
		yxysendmailmasterdao.updateByHql(hql);
	}
	
	/**修改邮件异常量*/
	public void updateMailExpStatus(int mailid, int expnum) throws Exception {		
		String hql="update YxySendMailMaster set exptionnum="+expnum+",isuse=0 where send_mail_id="+mailid;
		yxysendmailmasterdao.updateByHql(hql);
	}
	/**同时修改待发邮件状态与基本邮件信息状态*/
	public void updateMailStatus(int status,int mailid, String mailuid) throws Exception {
		String hql="update YxySendMailMaster set status="+status+" where send_mail_id="+mailid;
		String sql="update yxy_send_mail_master_base set status="+status+" where mail_uid='"+mailuid+"'";		
		yxysendmailmasterdao.updateByHql(hql);
		yxysendmailmasterdao.updateBySql(sql);
	}
	
	/**加入待发邮件*/
	public void addMailMaster(YxySendMailMaster master,List<YxyUserAddress> addresslist,int planid,int plan_differen)throws Exception {
		String loginid=master.getUser_loginid();
		String domain=master.getUser_domain();

		String customerids = "";//客户的id
		//定义邮件基本信息实体
		YxySendMailMasterBase masterbase=new YxySendMailMasterBase();
		//复制对象
		BeanUtils.copyProperties(master,masterbase);
		//插入待发邮件
		//int mailid=yxysendmailmasterdao.addPojo(master);
		//插入基本邮件信息
		//int baseid=mailmasterbasedao.addPojo(masterbase);
		//待发地址
		List<YxySendMailDetail> detaillist=new ArrayList<YxySendMailDetail>();
		//查询回复
		String hql="from YxyReplyInfo where loginid='"+loginid+"' and domain='"+domain+"'";
		List<YxyReplyInfo> replylist=replydao.findByHql(hql);
		//查询过滤
		String filterhql="from YxySendFilterAddress where filteraddrloginid='"+loginid+"' and filteraddrdomain='"+domain+"'";
		List<YxySendFilterAddress> filterlist=filterdao.findByHql(filterhql);
		//待发地址处理(去掉回复的,用户过滤的)
		for(int i=0;i<addresslist.size();i++){
			String email=addresslist.get(i).getUser_addr_email();//地址
			for(int j=0;j<replylist.size();j++){
				if(email.equals(replylist.get(j).getReplyemail())){
					break;
				}
			}
			for(int s=0;s<filterlist.size();s++){
				if(email.indexOf(filterlist.get(s).getFilteraddress())!=-1){
					break;
				}
			}
			
			customerids += addresslist.get(i).getUser_addr_id()+",";//当有多个地址进行拼接
			
			//待发地址对象
			YxySendMailDetail detail=new YxySendMailDetail();
			detail.setCompany_variable(addresslist.get(i).getCompany_variable());
			detail.setEmail(email);
			detail.setEmail_suffix("");
			detail.setIsexp(0);
			detail.setPlanid(planid);
			detail.setPlans_send_time(null);
			detail.setReceiver(addresslist.get(i).getUser_addr_name());
			detail.setStatus(0);
			detail.setLoginid(loginid);
			detail.setDomain(domain);
			//加入集合
			detaillist.add(detail);
		}
		//赋值
		masterbase.setSend_num(detaillist.size());
		
		//将地址生成txt文件(存放路径:域名+用户名+当前时间)
		StringBuffer writestr=new StringBuffer();
		if(detaillist.size()>0){
			writestr.append(masterbase.getCreate_time()+"发送的邮件地址\r\n");
			for(int i=0;i<detaillist.size();i++){
				writestr.append(detaillist.get(i).getEmail()+"\r\n");
			}
			//项目路进(默认是易外销的营销邮)
			String pathew = ConfigPath.getYxyServicePath();
			if(plan_differen == 0){//如果是本地库则切换成单独营销邮的路径
				pathew = ConfigPath.getYxyServicePath2();
			}
			SimpleDateFormat dfs=new SimpleDateFormat("yyyyMMddHHmmssSSS");
			String nowFilename=dfs.format(new Date());
			String filename=nowFilename+".txt";
			String txtsavepath=pathew+"\\userSaveFile\\"+domain+"\\"+loginid+"\\"+filename;
			File f=new File(pathew+"\\userSaveFile\\"+domain+"\\"+loginid);
			if(!f.exists()){
				f.mkdirs();
			}
			createAndDeleteFile.createFile(txtsavepath);
			System.out.println(txtsavepath);
			//写入文件
			FileWriter w = new FileWriter(txtsavepath, true);
			w.write(writestr.toString());
			w.close();
			
			masterbase.setTxtaddresspath(filename);
		}
		
		//插入待发邮件
		int mailid=yxysendmailmasterdao.addPojo(master);
		//插入基本邮件信息
		int baseid=mailmasterbasedao.addPojo(masterbase);
		
		for(YxySendMailDetail detail : detaillist)
		{
			detail.setBase_mail_id(baseid);
			detail.setSend_mail_id(mailid);
		}
		
		//plan_differen > 0 是客户管理的,否则就是本地库的
		if(plan_differen > 0)
		{
			//判断客户id
			if(!"".equals(customerids)){//不能为空,当有多个
				customerids = customerids.substring(0,customerids.length()-1);
			}
			try{
				//访问webmail接口URL
				String url =ConfigPath.getWebmailInterfaceUrl()+"/webmailWebservice/yxyaddfollowupwebservice?wsdl";
				JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); 
				org.apache.cxf.endpoint.Client client = dcf.createClient(url); 
				client.invoke("addFollowup",customerids,0,loginid,domain,masterbase.getSubject(),baseid);
			}catch (Exception e) {
				System.out.println("添加跟进记录异常...");
				e.printStackTrace();
			}
		}
		
		yxysendmaildetaildao.addPiPojo(detaillist);
	}
	
	/**更新待发邮件图片与附件路径*/
	public void updatepicattrpath(int masterid, String picpath, String attrpath)throws Exception {
		String hql="";
		if(!"".equals(picpath)&&!"".equals(attrpath)){
			hql="update YxySendMailMaster set image_path='"+picpath+"',attarchment_path='"+attrpath+"' where send_mail_id="+masterid;
			yxysendmailmasterdao.updateByHql(hql);
		}else if(!"".equals(picpath)){
			hql="update YxySendMailMaster set image_path='"+picpath+"' where send_mail_id="+masterid;
			yxysendmailmasterdao.updateByHql(hql);
		}else if(!"".equals(attrpath)){
			hql="update YxySendMailMaster set attarchment_path='"+attrpath+"' where send_mail_id="+masterid;
			yxysendmailmasterdao.updateByHql(hql);
		}
	}

	/**根据hql获取待发邮件*/
	public List<YxySendMailMaster> getMailMasterByHql(String hql)throws Exception{
		return yxysendmailmasterdao.findByHql(hql);
	}
	
	//------------------------待发地址操作模块-----------------------------	
	/**查询指定条待发地址*/
	public List<YxySendMailDetail> findAddressByMailID(int mailid) throws Exception {
		String hql="from YxySendMailDetail where status=0 and send_mail_id="+mailid;
		return yxysendmaildetaildao.findByHql(hql);
	}
	/**修改此地址为已发送*/
	public void updateMailDetailstatus(int addressid) throws Exception {
		String hql="update YxySendMailDetail set status=1 where mail_id="+addressid;
		yxysendmaildetaildao.updateByHql(hql);
	}
	/**更新地址状态为异常地址*/
	public void updateExp(int addressid,int expnum) throws Exception {
		if(expnum>=ConfigPath.getSendExpNum()){//该收件地址异常数量已经大于配置文件中的数量
			String hql="update YxySendMailDetail set status=1,isexp="+expnum+" where mail_id="+addressid;
			yxysendmaildetaildao.updateByHql(hql);
		}else{//不大于
			String hql="update YxySendMailDetail set isexp="+expnum+" where mail_id="+addressid;
			yxysendmaildetaildao.updateByHql(hql);
		}
	}
	/**根据邮件ID查询是否还存在待发地址*/
	public boolean isHaveAddress(int mailid) throws Exception {
		String hql="select count(*) from YxySendMailDetail where send_mail_id="+mailid+" and status=0";
		List resultlist=yxysendmaildetaildao.findByHql(hql);
		int num=0;
		if(resultlist.size()>0){
			Object obj=resultlist.get(0);
			num=Integer.parseInt(obj.toString());
		}
		if(num>0){
			return true;
		}else{
			return false;
		}
	}
	//------------------------SMTP操作模块---------------------------------
	/**查询可用SMTP*/
	public List<YxySendSmtpInfo> findSmtpInfoSetNum() throws Exception {
		
		//当前时间
//		SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//		String nowdate=df.format(new Date());
		
		//集合定义
		List<YxySendSmtpInfo> resmtp=new ArrayList<YxySendSmtpInfo>();
		//查询SMTP信息
		//String hql="from YxySendSmtpInfo where smtp_service_isuse=0 or smtp_service_isuse=1 order by smtp_service_userdate";
		String hql="from YxySendSmtpInfo where smtp_service_isuse=0";
		return yxysendsmtpinfodao.findByHql(hql);
		
//		String useDate="";
//		long timers=0;
//		
//		//判断SMTP是否可用
//		for(int i=0;i<smtplist.size();i++){
//			//如果是正在使用中的话判断是否是可用了
//			if(smtplist.get(i).getSmtp_service_isuse()==0){//有未使用的直接返回未使用的
//				resmtp.add(smtplist.get(i));
//			}else{//正在使用中的
//				useDate =smtplist.get(i).getSmtp_service_userdate();//SMTP最后使用的时间
//				//判断两时间的相差量
//				timers=DateFormat.minute1s(useDate, nowdate); 
//				if(timers>120){//如果两个小时都没使用则在次使用
//					//String hql1="update YxySendSmtpInfo set smtp_service_isuse=0 where smtp_service_id="+smtplist.get(i).getSmtp_service_id();
//					//yxysendsmtpinfodao.updateByHql(hql1);
//					resmtp.add(smtplist.get(i));
//				}else{
//					continue;
//				}
//			}
//		}
//		return resmtp; 
	}
	
	
	/**更新smtp使用状态*/
	public void updateSmtpUseStatus(int status,int smtpid,String nowdate) throws Exception {
		String hql1="";
		if(nowdate.equals("")){
			hql1="update YxySendSmtpInfo set smtp_service_isuse="+status+" where smtp_service_id="+smtpid;
		}else{
			hql1="update YxySendSmtpInfo set smtp_service_isuse="+status+",smtp_service_userdate='"+nowdate+"' where smtp_service_id="+smtpid;
		}
		
		yxysendsmtpinfodao.updateByHql(hql1);
	}
	
	/**更新smtp状态所有的*/
	public void updatesmtpstatus()throws Exception{
		String hql="update YxySendSmtpInfo set smtp_service_isuse=1 where smtp_service_isuse=0";
		yxysendsmtpinfodao.updateByHql(hql);
	}
	
	/**根据客户类型查询smtp*/
	public YxySendSmtpInfo findSmtpInfoByCusType(List<YxySendSmtpInfo> smtp_list,int cus_type)throws Exception
	{
		YxySendSmtpInfo smtpinfo = null;
		
		for(int i = 0; i < smtp_list.size(); i++)
		{
			if(cus_type == 0)//新客户营销
			{
				//该smtp是新客户营销且是可用的
				if(smtp_list.get(i).getSmtp_service_type() == 0)
				{
					smtpinfo = smtp_list.get(i);
					
					break;
				}
			}
			else if(cus_type == 1)//老客户跟进
			{
				//该smtp是老客户跟进且是可用的
				if(smtp_list.get(i).getSmtp_service_type() == 1)
				{
					smtpinfo = smtp_list.get(i);
					
					break;
				}
			}
		}
		
		return smtpinfo;
	}
	
	/**查找自主域名投递的smtp*/
	public YxySendSmtpInfo findSmtpInfoByCusType2(List<YxySendSmtpInfo> smtp_list,YxySendMailMaster master)throws Exception
	{
		YxySendSmtpInfo smtpinfo = null;
		
		String loginid = master.getUser_loginid();//邮件所属帐号
		
		String domain = master.getUser_domain();//邮件所属域名
		
		//保存满足的smtp集合
		List<YxySendSmtpInfo> new_smtp_list = new ArrayList<YxySendSmtpInfo>();
		
		for(YxySendSmtpInfo info : smtp_list)
		{
			String smtp_user_loginid = info.getSmtp_user_loginid();//smtp所属帐号
			
			String smtp_user_domain = info.getSmtp_user_domain();//smtp所属域名
			
			int smtp_service_type = info.getSmtp_service_type();//smtp类型
			
			//smtp类型是自主域名投递且smtp是当前邮件所属用户且域名
			if(smtp_service_type == 2 && 
					loginid.equals(smtp_user_loginid) && domain.equals(smtp_user_domain))
			{
				//把发第一封的时间为Null的smtp设置为空字符串否则下面进行排序时会出现空指针异常
				if(info.getSmtp_service_userdate() == null)
				{
					info.setSmtp_service_userdate("");
				}
				
				//添加到集合中
				new_smtp_list.add(info);
			}
		}
		
		//判断满足集合是否有元素
		if(new_smtp_list.size() > 0)
		{
			//按时间进行排序,时间后的排最后
			Collections.sort(new_smtp_list, new Comparator<YxySendSmtpInfo>(){
				@Override
				public int compare(YxySendSmtpInfo o1, YxySendSmtpInfo o2) {
					return o1.getSmtp_service_userdate().compareTo(o2.getSmtp_service_userdate()); 
				}
			});
			
			//取第一个smtp即最先使用的smtp
			smtpinfo = new_smtp_list.get(0);
		}
		
		return smtpinfo;
	}
	
	//------------------------SMTP后缀设置参数模块-------------------------
	/**查询后缀信息*/
	public List<YxySmtpSuffixSet> findAllSmtpSuffixSet() throws Exception {
		String hql="from YxySmtpSuffixSet";
		return yxysmtpsuffixsetdao.findByHql(hql);
	}
	//------------------------SMTP后缀发送量模块----------------------------
	/**查询该smtp对应后缀在时间段的发送量*/
	public List<YxySmtpSendSet> findAllSmtpSendSet(String smtpservice,String nowDay) throws Exception {
		String hql="from YxySmtpSendSet where smtp_send_set_service='"+smtpservice+"' and smtp_send_set_daydate='"+nowDay+"'";		
		return yxysmtpsendsetdao.findByHql(hql);
	}
	
	/**删除后缀已发量信息*/
	public void delmSmtpSet(String smtpService) throws Exception {
		String hql="delete YxySmtpSendSet where smtp_send_set_service='"+smtpService+"'";
		yxysmtpsendsetdao.updateByHql(hql);
	}
	
	/**更新发送量信息*/
	public void updateSmtpSet(List<YxySmtpSendSet> o) throws Exception {
		yxysmtpsendsetdao.addPiPojo(o);
		
	}
	//------------------------控制参数模块---------------------------------
	/**查询控制参数通过传的是系统级还是用户级*/
	public String findCompanyParamByCode(String code,String loginid,String domain) throws Exception {
		//查询此code的paramid
		String hql="from YxySysParamaters where para_code='"+code+"'";
		List<YxySysParamaters> paraslist=yxysysparamaterdao.findByHql(hql);
		if(paraslist.size()>0){
			int paramid=paraslist.get(0).getPara_id();
			int level=paraslist.get(0).getOwner_type();//所属等级
			String defaultvalue=paraslist.get(0).getDefault_value();//默认值
			if(level==4){//用户级
				//查询参数值
				String hql1="from YxySysParamatersValue where para_id="+paramid+" and owner_loginid='"+loginid+"' and company_domain='"+domain+"'";
				List<YxySysParamatersValue> paraValue=yxysysparamatersvaluedao.findByHql(hql1);
				if(paraValue.size()>0){
					return paraValue.get(0).getPara_value();
				}else{
					return defaultvalue;
				}
			}else{//系统级
				//查询参数值
				String hql1="from YxySysParamatersValue where para_id="+paramid+" and company_domain='"+domain+"'";
				List<YxySysParamatersValue> paraValue=yxysysparamatersvaluedao.findByHql(hql1);
				if(paraValue.size()>0){
					return paraValue.get(0).getPara_value();
				}else{
					return defaultvalue;
				}
			}
			
		}else{
			return "-1";
		}
	}
	
	/**paraid查询企业级控制参数*/
	public List<YxySysParamatersValue> findCompanyParamValues(String domian,int para_id)throws Exception
	{
		String hql = "from YxySysParamatersValue where owner_type = 1 and company_domain = '"+domian+"' and para_id = "+para_id;
		
		return yxysysparamatersvaluedao.findByHql(hql);
	}
	
	//------------------------自配SMTP发送量模块-----------------------------
	/**通过smtpID查询此smtp的发送参数*/
	public List<YxySmtpSendSelfSet> findSendSelfSetByService(String smtpservice)throws Exception {
		String hql="from YxySmtpSendSelfSet where smtp_send_self_set_account='"+smtpservice+"' or smtp_send_self_set_account='domain'";
		return yxysmtpsendselfsetdao.findByHql(hql);
	}
	/**查询自配账号的已发送量信息*/
	public List<YxySmtpSendSelfOverset> findBySmtpAccount(String account)
			throws Exception {
		String hql="from YxySmtpSendSelfOverset where smtp_send_self_over_account='"+account+"'";
		return yxysmtpsendselfoversetdao.findByHql(hql);
	}
	/**添加自配的已发量信息*/
	public void addSendSelfSet(YxySmtpSendSelfOverset o) throws Exception {
		yxysmtpsendselfoversetdao.addPojo(o);
	}
	/**更新已发量*/
	public void updateSendSelfSet(YxySmtpSendSelfOverset o) throws Exception {
		yxysmtpsendselfoversetdao.addPojo(o);
		
	}
	
	/**查询SMTP判断是否阻塞*/
	public void updateinitsmtpstatus()throws Exception{
		//查询smtp
		String hql="from YxySendSmtpInfo where smtp_service_isuse=1";
		List<YxySendSmtpInfo> smtplist=yxysendsmtpinfodao.findByHql(hql);
		
		//当前时间
		SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String nowdate=df.format(new Date());
		
		//循环判断
		String usetime="";
		int smtpid=0;
		for(int i=0;i<smtplist.size();i++){
			smtpid=smtplist.get(i).getSmtp_service_id();
			//判断使用时间是否超过一个小时
			usetime=smtplist.get(i).getSmtp_service_userdate();
			if(usetime!=null&&!"".equals(usetime)){
				long cha=DateFormat.minute1s(usetime, nowdate);
				//大于一个小时则改状态为0
				if(cha>=60){
					String updatehql="update YxySendSmtpInfo set smtp_service_isuse=0 where smtp_service_id="+smtpid;
					yxysendsmtpinfodao.updateByHql(updatehql);
				}
			}
		}
	}
	
	/**获取跟踪配置信息*/
	public List<CentreTrackSet> getTrackSetByHql(String hql)throws Exception{
		return centretracksetdao.findByHql(hql);
	}
	
	/**获取开发客户配置信息*/
	public List<CentreYxyedmNewcustomer> getNewCustomerSet(String hql)throws Exception{
		return centreyxyedmnewcustomerdao.findByHql(hql);
	}
	
	/**获取盘活客户配置信息*/
	public List<CentreYxyedmOldcustomer> getOldCustomerSet(String hql)throws Exception{
		return centreyxyedmoldcustomerdao.findByHql(hql);
	}
	
	/**获取用户信息*/
	public List<Object> getUserInfoBySql(String sql)throws Exception{
		return centreuserdao.findBySqlFind(sql);
	}
	
	private YxySendMailMasterDao yxysendmailmasterdao;//待发邮件dao
	private YxySendMailMasterBaseDao mailmasterbasedao;//邮件基本信息dao
	private YxySendMailDetailDao yxysendmaildetaildao;//待发地址dao
	private YxySendSmtpInfoDao	yxysendsmtpinfodao;//smtp dao
	private YxySmtpSuffixSetDao yxysmtpsuffixsetdao;//smtp 后缀dao
	private YxySmtpSendSetDao yxysmtpsendsetdao;//smtp后缀发送量
	private YxySmtpSendSelfSetDao yxysmtpsendselfsetdao;//自配smtp发送量限制
	private YxySmtpSendSelfOversetDao yxysmtpsendselfoversetdao;//自配smtp已发送量信息.
	private YxyParamaterDao yxysysparamaterdao;
	private YxySysParamatersValueDao yxysysparamatersvaluedao;
	private YxyReplyInfoDao replydao;//回复dao
	private YxySendFilterAddressDao filterdao;//过滤dao
	private CentreTrackSetDao centretracksetdao;//跟踪配置dao
	private CentreYxyedmNewcustomerDao centreyxyedmnewcustomerdao;//营销开发客户配置dao
	private CentreYxyedmOldcustomerDao centreyxyedmoldcustomerdao;//营销盘活客户配置dao
	private CentreUserDao centreuserdao;//用户dao
	public YxySendMailMasterDao getYxysendmailmasterdao() {
		return yxysendmailmasterdao;
	}
	public void setYxysendmailmasterdao(YxySendMailMasterDao yxysendmailmasterdao) {
		this.yxysendmailmasterdao = yxysendmailmasterdao;
	}
	public YxySendMailDetailDao getYxysendmaildetaildao() {
		return yxysendmaildetaildao;
	}
	public void setYxysendmaildetaildao(YxySendMailDetailDao yxysendmaildetaildao) {
		this.yxysendmaildetaildao = yxysendmaildetaildao;
	}
	public YxySendSmtpInfoDao getYxysendsmtpinfodao() {
		return yxysendsmtpinfodao;
	}
	public void setYxysendsmtpinfodao(YxySendSmtpInfoDao yxysendsmtpinfodao) {
		this.yxysendsmtpinfodao = yxysendsmtpinfodao;
	}
	public YxySmtpSuffixSetDao getYxysmtpsuffixsetdao() {
		return yxysmtpsuffixsetdao;
	}
	public void setYxysmtpsuffixsetdao(YxySmtpSuffixSetDao yxysmtpsuffixsetdao) {
		this.yxysmtpsuffixsetdao = yxysmtpsuffixsetdao;
	}
	public YxySmtpSendSetDao getYxysmtpsendsetdao() {
		return yxysmtpsendsetdao;
	}
	public void setYxysmtpsendsetdao(YxySmtpSendSetDao yxysmtpsendsetdao) {
		this.yxysmtpsendsetdao = yxysmtpsendsetdao;
	}
	public YxySmtpSendSelfSetDao getYxysmtpsendselfsetdao() {
		return yxysmtpsendselfsetdao;
	}
	public void setYxysmtpsendselfsetdao(YxySmtpSendSelfSetDao yxysmtpsendselfsetdao) {
		this.yxysmtpsendselfsetdao = yxysmtpsendselfsetdao;
	}
	public YxySmtpSendSelfOversetDao getYxysmtpsendselfoversetdao() {
		return yxysmtpsendselfoversetdao;
	}
	public void setYxysmtpsendselfoversetdao(
			YxySmtpSendSelfOversetDao yxysmtpsendselfoversetdao) {
		this.yxysmtpsendselfoversetdao = yxysmtpsendselfoversetdao;
	}
	public YxyParamaterDao getYxysysparamaterdao() {
		return yxysysparamaterdao;
	}
	public void setYxysysparamaterdao(YxyParamaterDao yxysysparamaterdao) {
		this.yxysysparamaterdao = yxysysparamaterdao;
	}
	public YxySysParamatersValueDao getYxysysparamatersvaluedao() {
		return yxysysparamatersvaluedao;
	}
	public void setYxysysparamatersvaluedao(
			YxySysParamatersValueDao yxysysparamatersvaluedao) {
		this.yxysysparamatersvaluedao = yxysysparamatersvaluedao;
	}
	public YxySendMailMasterBaseDao getMailmasterbasedao() {
		return mailmasterbasedao;
	}
	public void setMailmasterbasedao(YxySendMailMasterBaseDao mailmasterbasedao) {
		this.mailmasterbasedao = mailmasterbasedao;
	}
	public YxyReplyInfoDao getReplydao() {
		return replydao;
	}
	public void setReplydao(YxyReplyInfoDao replydao) {
		this.replydao = replydao;
	}
	public YxySendFilterAddressDao getFilterdao() {
		return filterdao;
	}
	public void setFilterdao(YxySendFilterAddressDao filterdao) {
		this.filterdao = filterdao;
	}
	public CentreTrackSetDao getCentretracksetdao() {
		return centretracksetdao;
	}
	public void setCentretracksetdao(CentreTrackSetDao centretracksetdao) {
		this.centretracksetdao = centretracksetdao;
	}
	public CentreYxyedmNewcustomerDao getCentreyxyedmnewcustomerdao() {
		return centreyxyedmnewcustomerdao;
	}
	public void setCentreyxyedmnewcustomerdao(
			CentreYxyedmNewcustomerDao centreyxyedmnewcustomerdao) {
		this.centreyxyedmnewcustomerdao = centreyxyedmnewcustomerdao;
	}
	public CentreYxyedmOldcustomerDao getCentreyxyedmoldcustomerdao() {
		return centreyxyedmoldcustomerdao;
	}
	public void setCentreyxyedmoldcustomerdao(
			CentreYxyedmOldcustomerDao centreyxyedmoldcustomerdao) {
		this.centreyxyedmoldcustomerdao = centreyxyedmoldcustomerdao;
	}
	public CentreUserDao getCentreuserdao() {
		return centreuserdao;
	}
	public void setCentreuserdao(CentreUserDao centreuserdao) {
		this.centreuserdao = centreuserdao;
	}
}