b797a1aff8779d539c36c417f4b6f12f9df8e452.svn-base
26.6 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
package com.espeed.service.impl;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.espeed.centre.pojo.YxyUserInfo;
import com.espeed.dao.YxyMailCountDao;
import com.espeed.dao.YxyMailDayCountDao;
import com.espeed.dao.YxyMailMonthCountDao;
import com.espeed.dao.YxyReadingCountDao;
import com.espeed.dao.YxyReadingInfoDao;
import com.espeed.dao.YxyReplyInfoDao;
import com.espeed.dao.YxySendMailMasterBaseDao;
import com.espeed.dao.YxyTimeCountDao;
import com.espeed.dao.YxyUnsubscribeInfoDao;
import com.espeed.dao.YxyUserAddressDao;
import com.espeed.dao.YxyUserInfoDao;
import com.espeed.pojo.YxyMailCount;
import com.espeed.pojo.YxyMailDayCount;
import com.espeed.pojo.YxyMailMonthCount;
import com.espeed.service.YxyMailCountService;
/**
* 程序名称: EspeedMail_时速邮箱
* 程序版本: V1.0
* 作 者: 深圳市科飞时速网络技术有限公司(0755-88843776)
* 版权所有: 深圳市科飞时速网络技术有限公司
* 技术支持: Tech@21gmail.com
* 单元名称: 邮件统计service实现类(营销游)
* 开始时间: 2013.12.09
* 程 序 员: 谢勇
* 最后修改:
* 备 注: 如需修改请通知程序员
*/
public class YxyMailCountServiceImpl implements YxyMailCountService{
/**查询用户首页统计信息*/
public Map<String,Integer> findCountHome(String loginid,String domain) throws Exception {
//返回值
Map<String,Integer> result=new HashMap<String, Integer>();
//总发送量
String hql1="select SUM(yxy_count_tol_num+yxy_count_nocount) from YxyMailCount where yxy_count_loginid='"+loginid+"' and yxy_count_domain='"+domain+"'";
result.put("tolsend",yxymailcountdao.findByHqlCount(hql1));
//总待发送量
//String hql2="select count(*) from YxySendMailDetail where status=0 and isexp<3 and uid="+uid;
//String hql2="select count(*) from YxySendMailDetail where status=0 and isexp<3 and loginid = '"+loginid+"' and domain = '"+domain+"'";
//result.put("daisend",yxymailcountdao.findByHqlCount(hql2));
int daisend = 0;
String sql = "select send_mail_id from yxy_send_mail_master_base where user_loginid = '"+loginid+"' and user_domain = '"+domain+"' and (status = 0 or status = 2)";
List<Object> objects = yxysendmailmasterbasedao.findBySqlQuery(sql);
if(objects.size() > 0){
for(Object obj : objects){
if(null != obj){
int base_mail_id = Integer.parseInt(obj.toString());
String hql2="select count(*) from YxySendMailDetail where status=0 and isexp<3 and base_mail_id="+base_mail_id;
daisend+=yxymailcountdao.findByHqlCount(hql2);
}
}
}
//总待发送量
result.put("daisend",daisend);
//查询点总击量
String hql3="select count(*) from YxyReadingInfo where yxy_reading_domain='"+domain+"' and yxy_reading_loginid='"+loginid+"'";
int clicktol=yxyreadinginfodao.findCountHql(hql3);
result.put("clicktol",clicktol);
//未点读量
result.put("noclicktol",result.get("tolsend")-result.get("clicktol"));
//退订量
String unsql="select count(*) from YxyUnsubscribeInfo where unsubscribe_loginid='"+loginid+"' and unsubscribe_domain='"+domain+"'";
int unTol=yxyunsubscribeinfodao.findByHqlCount(unsql);
result.put("untol",unTol);
//回复
String replyhql="select count(*) from YxyReplyInfo where loginid='"+loginid+"' and domain='"+domain+"'";
int replyTol=yxyreplyinfodao.findByHqlCount(replyhql);
result.put("replytol",replyTol);
return result;
}
/**首页用户月统计图*/
public Map<String,Integer> findUserMonthCount(String loginid, String domain)throws Exception {
//返回值
Map<String,Integer> result=new HashMap<String, Integer>();
//当前年
SimpleDateFormat df=new SimpleDateFormat("yyyy");
String year=df.format(new Date());
//查询
String hql="from YxyMailMonthCount where yxy_month_count_loginid='"+loginid+"' and yxy_month_count_domain='"+domain+"' and yxy_month_count_date like'%"+year+"%'";
List<YxyMailMonthCount> list=yxymailmonthcountdao.findByHql(hql);
String[] timer=null;
for(int i=0;i<list.size();i++){
//取时间
timer=list.get(i).getYxy_month_count_date().split("-");
result.put(timer[1], list.get(i).getYxy_month_count_tol_num());
}
return result;
}
/**查询域统计信息*/
//public Map<String,Integer> findCountDomain(String domain) throws Exception {
public Map<String,Integer> findCountDomain(YxyUserInfo user)throws Exception{
//返回值
Map<String,Integer> result=new HashMap<String, Integer>();
//域总发送量
//String sql1="select yxy_count_ci_num,yxy_count_tol_num from yxy_mail_count where yxy_count_domain='"+domain+"'";
String sql1 = "";
if(user.getUser_role()==1)//系统管理员
{
sql1="select sum(yxy_count_ci_num) as counts1,sum(yxy_count_tol_num) as counts from yxy_mail_count where yxy_count_domain='"+user.getDomain()+"'";
}
else if(user.getUser_role()==2){//部门管理员
String ids = "";
//获取子部门
String sql="select dept_id from centre_department where parent_dept_id = "+user.getDept_id();
List<Object> objects = yxyuserinfodao.findBySqlQuery(sql);
if(objects.size() > 0){
for(Object obj : objects){
ids += obj.toString() + ",";
}
ids += String.valueOf(user.getDept_id());
}else{
ids = String.valueOf(user.getDept_id());
}
String hql1="from YxyUserInfo where company_id="+user.getCompany_id()+" and dept_id in("+ids+") ORDER BY enrol_time desc";
List<YxyUserInfo> users = yxyuserinfodao.findByHql(hql1);
String loginids = "";
for(YxyUserInfo pojo : users){
loginids += "'"+pojo.getLogin_id()+"'"+",";
}
loginids=loginids.substring(0,loginids.length()-1);
sql1="select sum(yxy_count_ci_num) as counts1,sum(yxy_count_tol_num) as counts from yxy_mail_count " +
"where yxy_count_domain='"+user.getDomain()+"' and yxy_count_loginid in("+loginids+") ";
}
else//非系统管理员查询自己
{
sql1="select sum(yxy_count_ci_num) as counts1,sum(yxy_count_tol_num) as counts from yxy_mail_count " +
"where yxy_count_domain='"+user.getDomain()+"' and yxy_count_loginid ='"+user.getLogin_id()+"'";
}
List<Object> objlist=yxymailcountdao.findBySqlQuery(sql1);
if(objlist.size()>0){
Object[] obj=(Object[]) objlist.get(0);
if(obj[0]!=null&&!"".equals(obj[0])){
result.put("tolsendci",Integer.parseInt(obj[0].toString()));
}else{
result.put("tolsendci",0);
}
if(obj[1]!=null&&!"".equals(obj[1])){
result.put("tolsend",Integer.parseInt(obj[1].toString()));
}else{
result.put("tolsend",0);
}
}else{
result.put("tolsendci",0);
result.put("tolsend",0);
}
//域总点读量
//String hql2="select sum(day_count) from YxyTimeCount where count_id=10 and domain='"+domain+"'";
String hql2="";
if(user.getUser_role()==1)//系统管理员
{
hql2="select sum(day_count) from YxyTimeCount where count_id=10 and domain='"+user.getDomain()+"'";
}
else if(user.getUser_role()==2){//部门管理员
String ids = "";
//获取子部门
String sql="select dept_id from centre_department where parent_dept_id = "+user.getDept_id();
List<Object> objects = yxyuserinfodao.findBySqlQuery(sql);
if(objects.size() > 0){
for(Object obj : objects){
ids += obj.toString() + ",";
}
ids += String.valueOf(user.getDept_id());
}else{
ids = String.valueOf(user.getDept_id());
}
String hql1="from YxyUserInfo where company_id="+user.getCompany_id()+" and dept_id in("+ids+") ORDER BY enrol_time desc";
List<YxyUserInfo> users = yxyuserinfodao.findByHql(hql1);
String loginids = "";
for(YxyUserInfo pojo : users){
loginids += "'"+pojo.getLogin_id()+"'"+",";
}
loginids=loginids.substring(0,loginids.length()-1);
hql2="select sum(day_count) from YxyTimeCount where count_id=10 " +
"and domain='"+user.getDomain()+"' and login_id in("+loginids+") ";
}
else
{
hql2="select sum(day_count) from YxyTimeCount where count_id=10 " +
"and domain='"+user.getDomain()+"' and login_id ='"+user.getLogin_id()+"'";
}
int clicktol=timecountdao.findByHqlCount(hql2);
result.put("clicktol",clicktol);
//域总未读量
if(result.get("tolsend")-clicktol<0)
{
result.put("noclick",0);
}
else
{
result.put("noclick",result.get("tolsend")-clicktol);
}
//result.put("noclick",result.get("tolsend")-clicktol);
//域总回复
//String replyhql="select count(*) from YxyReplyInfo where domain='"+domain+"'";
String replyhql="";
if(user.getUser_role()==1)//系统管理员
{
replyhql="select count(*) from YxyReplyInfo where domain='"+user.getDomain()+"'";
}
else if(user.getUser_role()==2){//部门管理员
String ids = "";
//获取子部门
String sql="select dept_id from centre_department where parent_dept_id = "+user.getDept_id();
List<Object> objects = yxyuserinfodao.findBySqlQuery(sql);
if(objects.size() > 0){
for(Object obj : objects){
ids += obj.toString() + ",";
}
ids += String.valueOf(user.getDept_id());
}else{
ids = String.valueOf(user.getDept_id());
}
String hql1="from YxyUserInfo where company_id="+user.getCompany_id()+" and dept_id in("+ids+") ORDER BY enrol_time desc";
List<YxyUserInfo> users = yxyuserinfodao.findByHql(hql1);
String loginids = "";
for(YxyUserInfo pojo : users){
loginids += "'"+pojo.getLogin_id()+"'"+",";
}
loginids=loginids.substring(0,loginids.length()-1);
replyhql="select count(*) from YxyReplyInfo where domain='"+user.getDomain()+"' and loginid in("+loginids+") ";
}
else
{
replyhql="select count(*) from YxyReplyInfo where domain='"+user.getDomain()+"' and loginid ='"+user.getLogin_id()+"'";
}
int tolreply=yxyreplyinfodao.findByHqlCount(replyhql);
result.put("tolreply",tolreply);
//域总退订
//String unsql="select count(*) from YxyUnsubscribeInfo where unsubscribe_domain='"+domain+"'";
String unsql="";
if(user.getUser_role()==1)//系统管理员
{
unsql="select count(*) from YxyUnsubscribeInfo where unsubscribe_domain='"+user.getDomain()+"'";
}
else if(user.getUser_role()==2){//部门管理员
String ids = "";
//获取子部门
String sql="select dept_id from centre_department where parent_dept_id = "+user.getDept_id();
List<Object> objects = yxyuserinfodao.findBySqlQuery(sql);
if(objects.size() > 0){
for(Object obj : objects){
ids += obj.toString() + ",";
}
ids += String.valueOf(user.getDept_id());
}else{
ids = String.valueOf(user.getDept_id());
}
String hql1="from YxyUserInfo where company_id="+user.getCompany_id()+" and dept_id in("+ids+") ORDER BY enrol_time desc";
List<YxyUserInfo> users = yxyuserinfodao.findByHql(hql1);
String loginids = "";
for(YxyUserInfo pojo : users){
loginids += "'"+pojo.getLogin_id()+"'"+",";
}
loginids=loginids.substring(0,loginids.length()-1);
unsql="select count(*) from YxyUnsubscribeInfo where unsubscribe_domain='"+user.getDomain()+"' and unsubscribe_loginid in("+loginids+") ";
}
else
{
unsql="select count(*) from YxyUnsubscribeInfo where unsubscribe_domain='"+user.getDomain()+"' and unsubscribe_loginid ='"+user.getLogin_id()+"'";
}
int tolun=yxyunsubscribeinfodao.findByHqlCount(unsql);
result.put("tolun",tolun);
return result;
}
/**查询用户已发送量*/
public Map<String,Integer> findCountPageTop(String loginid,String domain) throws Exception{
//当前时间日
SimpleDateFormat daytimer=new SimpleDateFormat("yyyy-MM-dd");
String nowDay=daytimer.format(new Date());
//当前时间月
SimpleDateFormat monthtimer=new SimpleDateFormat("yyyy-MM");
String nowmonth=monthtimer.format(new Date());
//返回值
Map<String,Integer> result=new HashMap<String, Integer>();
//日已发量
String dayhql="from YxyMailDayCount where yxy_day_count_loiginid='"+loginid+"' and yxy_day_count_domain='"+domain+"' and yxy_day_count_date='"+nowDay+"'";
List<YxyMailDayCount> daylist=yxymaildaycountdao.findByHql(dayhql);
if(daylist.size()>0){
result.put("daysendnum", daylist.get(0).getYxy_day_count_tol_num());
}else{
result.put("daysendnum",0);
}
//月已发量
String monthhql="from YxyMailMonthCount where yxy_month_count_loginid='"+loginid+"' and yxy_month_count_domain='"+domain+"' and yxy_month_count_date='"+nowmonth+"'";
List<YxyMailMonthCount> monthlist=yxymailmonthcountdao.findByHql(monthhql);
if(monthlist.size()>0){
result.put("monthsendnum",monthlist.get(0).getYxy_month_count_tol_num());
}else{
result.put("monthsendnum",0);
}
//总发量
String tolhql="from YxyMailCount where yxy_count_loginid='"+loginid+"' and yxy_count_domain='"+domain+"'";
List<YxyMailCount> tollist=yxymailcountdao.findByHql(tolhql);
if(tollist.size()>0){
result.put("tolsendnum",tollist.get(0).getYxy_count_tol_num());
}else{
result.put("tolsendnum",0);
}
return result;
}
/**根据年查询每个月统计*/
public Map<String,Map<String,Integer>> findYearMonthCount(String loginid,String domain,int condition,
String conditionvalue,YxyUserInfo user)throws Exception{
//时间
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM");
String nowyearmonth=df.format(new Date());
String[] timearry=nowyearmonth.split("-");
String nowyear=timearry[0].toString();
//String nowmonth=timearry[1].toString();
//返回值
Map<String,Map<String,Integer>> result=new HashMap<String, Map<String,Integer>>();//统计项(发送量,点击量,回复量,退订量)
result.put("monthsend",null);
result.put("monthclick",null);
result.put("monthreply",null);
result.put("monthun",null);
//每月统计(发送)
Map<String,Integer> sendcountcolum=new HashMap<String, Integer>();
sendcountcolum.put("1", 0);
sendcountcolum.put("2", 0);
sendcountcolum.put("3", 0);
sendcountcolum.put("4", 0);
sendcountcolum.put("5", 0);
sendcountcolum.put("6", 0);
sendcountcolum.put("7", 0);
sendcountcolum.put("8", 0);
sendcountcolum.put("9", 0);
sendcountcolum.put("10", 0);
sendcountcolum.put("11", 0);
sendcountcolum.put("12", 0);
//每月统计(点读)
Map<String,Integer> clickcountcolum=new HashMap<String, Integer>();
clickcountcolum.put("1", 0);
clickcountcolum.put("2", 0);
clickcountcolum.put("3", 0);
clickcountcolum.put("4", 0);
clickcountcolum.put("5", 0);
clickcountcolum.put("6", 0);
clickcountcolum.put("7", 0);
clickcountcolum.put("8", 0);
clickcountcolum.put("9", 0);
clickcountcolum.put("10", 0);
clickcountcolum.put("11", 0);
clickcountcolum.put("12", 0);
//每月统计(回复)
Map<String,Integer> replycountcolum=new HashMap<String, Integer>();
replycountcolum.put("1", 0);
replycountcolum.put("2", 0);
replycountcolum.put("3", 0);
replycountcolum.put("4", 0);
replycountcolum.put("5", 0);
replycountcolum.put("6", 0);
replycountcolum.put("7", 0);
replycountcolum.put("8", 0);
replycountcolum.put("9", 0);
replycountcolum.put("10", 0);
replycountcolum.put("11", 0);
replycountcolum.put("12", 0);
//每月统计(退订)
Map<String,Integer> uncountcolum=new HashMap<String, Integer>();
uncountcolum.put("1", 0);
uncountcolum.put("2", 0);
uncountcolum.put("3", 0);
uncountcolum.put("4", 0);
uncountcolum.put("5", 0);
uncountcolum.put("6", 0);
uncountcolum.put("7", 0);
uncountcolum.put("8", 0);
uncountcolum.put("9", 0);
uncountcolum.put("10", 0);
uncountcolum.put("11", 0);
uncountcolum.put("12", 0);
List<Object> sendobjlist=new ArrayList<Object>();//发送量结果集合
List<Object> clickobjlist=new ArrayList<Object>();//点读量结果集合
List<Object> replyobjlist=new ArrayList<Object>();//回复量结果集合
List<Object> unobjlist=new ArrayList<Object>();//退订量结果集合
String sql1="";//发送sql
String sql2="";//点读sql
String sql3="";//回复sql
String sql4="";//退订sql
//条件片段
if(condition==0){//默认该域下当前年份,所有用户
if(conditionvalue!=null&&!"".equals(conditionvalue)){
nowyear=conditionvalue;
}
if(user.getUser_role()==1)//系统管理员
{
//查询各个月的发送量
sql1="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and domain='"+domain+"' AND count_id=9 GROUP BY month;";
//查询各个月点读量
sql2="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and domain='"+domain+"' AND count_id=10 GROUP BY month;";
//查询各个月回复量
sql3="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and domain='"+domain+"' AND count_id=12 GROUP BY month;";
//查询各个月退订量
sql4="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and domain='"+domain+"' AND count_id=11 GROUP BY month;";
}
else if(user.getUser_role()==2){//部门管理员
String ids = "";
//获取子部门
String sql="select dept_id from centre_department where parent_dept_id = "+user.getDept_id();
List<Object> objects = yxyuserinfodao.findBySqlQuery(sql);
if(objects.size() > 0){
for(Object obj : objects){
ids += obj.toString() + ",";
}
ids += String.valueOf(user.getDept_id());
}else{
ids = String.valueOf(user.getDept_id());
}
String hql1="from YxyUserInfo where company_id="+user.getCompany_id()+" and dept_id in("+ids+") ORDER BY enrol_time desc";
List<YxyUserInfo> users = yxyuserinfodao.findByHql(hql1);
String loginids = "";
for(YxyUserInfo pojo : users){
loginids += "'"+pojo.getLogin_id()+"'"+",";
}
loginids=loginids.substring(0,loginids.length()-1);
//查询各个月的发送量
sql1="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and domain='"+domain+"' AND login_id in("+loginids+") AND count_id=9 GROUP BY month;";
//查询各个月点读量
sql2="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and domain='"+domain+"' AND login_id in("+loginids+") AND count_id=10 GROUP BY month;";
//查询各个月回复量
sql3="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and domain='"+domain+"' AND login_id in("+loginids+") AND count_id=12 GROUP BY month;";
//查询各个月退订量
sql4="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and domain='"+domain+"' AND login_id in("+loginids+") AND count_id=11 GROUP BY month;";
}
else
{
//查询各个月的发送量
sql1="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and domain='"+domain+"' AND login_id ='"+user.getLogin_id()+"' AND count_id=9 GROUP BY month;";
//查询各个月点读量
sql2="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and domain='"+domain+"' AND login_id ='"+user.getLogin_id()+"' AND count_id=10 GROUP BY month;";
//查询各个月回复量
sql3="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and domain='"+domain+"' AND login_id ='"+user.getLogin_id()+"' AND count_id=12 GROUP BY month;";
//查询各个月退订量
sql4="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and domain='"+domain+"' AND login_id ='"+user.getLogin_id()+"' AND count_id=11 GROUP BY month;";
}
//查询各个月的发送量
//sql1="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and domain='"+domain+"' AND count_id=9 GROUP BY month;";
//查询各个月点读量
//sql2="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and domain='"+domain+"' AND count_id=10 GROUP BY month;";
//查询各个月回复量
//sql3="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and domain='"+domain+"' AND count_id=12 GROUP BY month;";
//查询各个月退订量
//sql4="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and domain='"+domain+"' AND count_id=11 GROUP BY month;";
}else if(condition==1){//选择用户
if(!"".equals(conditionvalue)){
nowyear=conditionvalue;
}
//查询各个月的发送量
sql1="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and login_id='"+loginid+"' and domain='"+domain+"' AND count_id=9 GROUP BY month;";
//查询各个月点读量
sql2="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and login_id='"+loginid+"' and domain='"+domain+"' AND count_id=10 GROUP BY month;";
//查询各个月回复量
sql3="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and login_id='"+loginid+"' and domain='"+domain+"' AND count_id=12 GROUP BY month;";
//查询各个月退订量
sql4="SELECT month,SUM(day_count) FROM timer_count_yxy WHERE year="+nowyear+" and login_id='"+loginid+"' and domain='"+domain+"' AND count_id=11 GROUP BY month;";
}
//查询
sendobjlist=timecountdao.findBySqlQuery(sql1);
clickobjlist=timecountdao.findBySqlQuery(sql2);
replyobjlist=timecountdao.findBySqlQuery(sql3);
unobjlist=timecountdao.findBySqlQuery(sql4);
//发送量加入集合
if(sendobjlist.size()>0){
for(int i=0;i<sendobjlist.size();i++){
Object [] objArry=(Object[]) sendobjlist.get(i);
//月份
String month=objArry[0].toString().split("-")[0];
//加入Map
sendcountcolum.put(Integer.parseInt(month)+"",Integer.parseInt(objArry[1].toString()));
}
}
//加入返回值
result.put("monthsend",sendcountcolum);
//点击量加入集合
if(clickobjlist.size()>0){
for(int i=0;i<clickobjlist.size();i++){
Object [] objArry=(Object[]) clickobjlist.get(i);
//月份
String month=objArry[0].toString().split("-")[0];
//加入Map
clickcountcolum.put(Integer.parseInt(month)+"",Integer.parseInt(objArry[1].toString()));
}
}
result.put("monthclick",clickcountcolum);
//回复量加入集合
if(replyobjlist.size()>0){
for(int i=0;i<replyobjlist.size();i++){
Object [] objArry=(Object[]) replyobjlist.get(i);
//月份
String month=objArry[0].toString().split("-")[0];
//加入Map
replycountcolum.put(Integer.parseInt(month)+"",Integer.parseInt(objArry[1].toString()));
}
}
result.put("monthreply",replycountcolum);
//退订量加入集合
if(unobjlist.size()>0){
for(int i=0;i<unobjlist.size();i++){
Object [] objArry=(Object[]) unobjlist.get(i);
//月份
String month=objArry[0].toString().split("-")[0];
//加入Map
uncountcolum.put(Integer.parseInt(month)+"",Integer.parseInt(objArry[1].toString()));
}
}
result.put("monthun",uncountcolum);
return result;
}
/**用户今日统计*/
public Map<String,Integer> findNowDayCount(String loginid,String domain)throws Exception{
Map<String,Integer> result=new HashMap<String, Integer>();
//当前时间
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String nowtime=df.format(new Date());
String nowday=nowtime.split(" ")[0];
//今日发送
String hql1="select yxy_day_count_tol_num from YxyMailDayCount where yxy_day_count_loiginid='"+loginid+"' and yxy_day_count_domain='"+domain+"' and yxy_day_count_date='"+nowday+"'";
int daysend=yxymaildaycountdao.findByHqlCount(hql1);
result.put("daysend", daysend);
//今日点读
String hql2="select count(*) from YxyReadingInfo where yxy_reading_loginid='"+loginid+"' and yxy_reading_domain='"+domain+"' and yxy_reading_date like '%"+nowday+"%'";
int dayclick=yxyreadinginfodao.findCountHql(hql2);
result.put("dayclick", dayclick);
//今日回复
String hql3="select count(*) from YxyReplyInfo where loginid='"+loginid+"' and domain='"+domain+"' and replydate like '%"+nowday+"%'";
int dayreply=yxyreplyinfodao.findByHqlCount(hql3);
result.put("dayreply", dayreply);
//今日退订
String hql4="select count(*) from YxyUnsubscribeInfo where unsubscribe_loginid='"+loginid+"' and unsubscribe_domain='"+domain+"' and unsubscribe_date like '%"+nowday+"%'";
int dayun=yxyunsubscribeinfodao.findByHqlCount(hql4);
result.put("dayun", dayun);
return result;
}
private YxyUserInfoDao yxyuserinfodao;
private YxyMailDayCountDao yxymaildaycountdao;//日统计
private YxyMailMonthCountDao yxymailmonthcountdao;//月统计
private YxyMailCountDao yxymailcountdao;//总统计
private YxyUnsubscribeInfoDao yxyunsubscribeinfodao;//退订dao
private YxyReadingCountDao yxyreadingcountdao;//点读统计dao
private YxyReadingInfoDao yxyreadinginfodao;//点读信息dao
private YxySendMailMasterBaseDao yxysendmailmasterbasedao;//邮件基本信息dao
private YxyUserAddressDao yxyuseraddressdao;//用户地址dao
private YxyReplyInfoDao yxyreplyinfodao;//回复dao
private YxyTimeCountDao timecountdao;//统计dao
public YxyMailDayCountDao getYxymaildaycountdao() {
return yxymaildaycountdao;
}
public void setYxymaildaycountdao(YxyMailDayCountDao yxymaildaycountdao) {
this.yxymaildaycountdao = yxymaildaycountdao;
}
public YxyMailMonthCountDao getYxymailmonthcountdao() {
return yxymailmonthcountdao;
}
public void setYxymailmonthcountdao(YxyMailMonthCountDao yxymailmonthcountdao) {
this.yxymailmonthcountdao = yxymailmonthcountdao;
}
public YxyMailCountDao getYxymailcountdao() {
return yxymailcountdao;
}
public void setYxymailcountdao(YxyMailCountDao yxymailcountdao) {
this.yxymailcountdao = yxymailcountdao;
}
public YxyUnsubscribeInfoDao getYxyunsubscribeinfodao() {
return yxyunsubscribeinfodao;
}
public void setYxyunsubscribeinfodao(YxyUnsubscribeInfoDao yxyunsubscribeinfodao) {
this.yxyunsubscribeinfodao = yxyunsubscribeinfodao;
}
public YxyReadingCountDao getYxyreadingcountdao() {
return yxyreadingcountdao;
}
public void setYxyreadingcountdao(YxyReadingCountDao yxyreadingcountdao) {
this.yxyreadingcountdao = yxyreadingcountdao;
}
public YxySendMailMasterBaseDao getYxysendmailmasterbasedao() {
return yxysendmailmasterbasedao;
}
public void setYxysendmailmasterbasedao(
YxySendMailMasterBaseDao yxysendmailmasterbasedao) {
this.yxysendmailmasterbasedao = yxysendmailmasterbasedao;
}
public YxyReadingInfoDao getYxyreadinginfodao() {
return yxyreadinginfodao;
}
public void setYxyreadinginfodao(YxyReadingInfoDao yxyreadinginfodao) {
this.yxyreadinginfodao = yxyreadinginfodao;
}
public YxyUserAddressDao getYxyuseraddressdao() {
return yxyuseraddressdao;
}
public void setYxyuseraddressdao(YxyUserAddressDao yxyuseraddressdao) {
this.yxyuseraddressdao = yxyuseraddressdao;
}
public YxyReplyInfoDao getYxyreplyinfodao() {
return yxyreplyinfodao;
}
public void setYxyreplyinfodao(YxyReplyInfoDao yxyreplyinfodao) {
this.yxyreplyinfodao = yxyreplyinfodao;
}
public YxyTimeCountDao getTimecountdao() {
return timecountdao;
}
public void setTimecountdao(YxyTimeCountDao timecountdao) {
this.timecountdao = timecountdao;
}
public YxyUserInfoDao getYxyuserinfodao() {
return yxyuserinfodao;
}
public void setYxyuserinfodao(YxyUserInfoDao yxyuserinfodao) {
this.yxyuserinfodao = yxyuserinfodao;
}
}