4d1c39b2f0e5c83f71783d2fd45a691232a5d8b8.svn-base
14.2 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
package yxy.timer.method;
import java.util.List;
import org.apache.commons.lang.StringEscapeUtils;
import yxy.timer.dao.TimerCountYxyDao;
import yxy.timer.dao.YxyMailDayCountDao;
import yxy.timer.dao.YxyReadDao;
import yxy.timer.dao.YxyReplyInfoDao;
import yxy.timer.dao.YxyUnsubscribeDao;
import yxy.timer.pojo.TimerCountYxy;
import yxy.timer.tool.DateFormat;
/**
* 统计分析定时器
* @author 陈南巧
*/
public class YxyCountAnalysisTime
{
//定时器运行的主方法
public void counting()
{
try
{
System.out.println("营销邮统计分析定时器开始,开始时间:"+DateFormat.getNowDate());
//营销邮统计发送总次数与发送总数
yxyCountSMailInfo();
//营销邮统计点读总数yxyCoutReadMail
yxyCountReadMail();
//营销邮统计退订总数
yxyCountUnsubscribeMail();
//营销邮统计回复总数
yxyCountReplyMail();
System.out.println("营销邮统计分析定时器结束,结束时间:"+DateFormat.getNowDate());
}
catch (Exception e)
{
System.out.println("营销邮统计分析定时器异常......");
e.printStackTrace();
}
}
//营销邮统计发送总次数与发送总数
public void yxyCountSMailInfo()
{
try
{
System.out.println("营销邮-按时间统计发送总次数与发送总数开始,开始时间:"+DateFormat.getNowDate());
String sql = "select yxy_day_count_id,yxy_day_count_loiginid,yxy_day_count_domain,yxy_day_count_date,yxy_day_count_ci_num,yxy_day_count_tol_num " +
"from yxy_mail_day_count where is_timer_count = 0 limit 0,100";
List<Object> objects = yxymaildaycountdao.findBySqlQuery(sql);
if(objects.size() > 0)
{
String ids = "";
for(int i = 0; i < objects.size(); i++)
{
Object []obj=(Object[])objects.get(i);
//日统计表的id
int yxy_day_count_id = Integer.parseInt(obj[0].toString());
ids += yxy_day_count_id + ",";
//登录帐号
String loginid = obj[1].toString();
//登录域名
String domain = obj[2].toString();
//日期
String date = obj[3].toString();
//当天发送次数
int ci_num = Integer.parseInt(obj[4].toString());
//当天发送总数
int tol_num = Integer.parseInt(obj[5].toString());
//先判断记录是否存在,不存在则添加,存在则更新
sql = "select timer_id from timer_count_yxy where count_id = 8 and count_date = '"+date+"' and login_id = '"+StringEscapeUtils.escapeSql(loginid)+"' and domain = '"+StringEscapeUtils.escapeSql(domain)+"'";
List<Object> select_objects = timercountyxydao.findBySqlQuery(sql);
if(select_objects.size() > 0)//已存在,则更新记录
{
int timer_id = Integer.parseInt(select_objects.get(0).toString());
String hql = "update TimerCountYxy set day_count = "+ci_num+" where timer_id = "+timer_id;
timercountyxydao.updateByHql(hql);
}
else//不存在,则添加记录
{
TimerCountYxy yxy1 = new TimerCountYxy();
yxy1.setCount_date(date);
yxy1.setDay(date.split("-")[2]);
yxy1.setMonth(date.split("-")[1]);
yxy1.setYear(Integer.parseInt(date.split("-")[0]));
yxy1.setLogin_id(loginid);
yxy1.setDomain(domain);
yxy1.setCount_id(8);
yxy1.setDay_count(ci_num);
yxy1.setRecord_id("");
timercountyxydao.addPojo(yxy1);
}
sql = "select timer_id from timer_count_yxy where count_id = 9 and count_date = '"+date+"' and login_id = '"+StringEscapeUtils.escapeSql(loginid)+"' and domain = '"+StringEscapeUtils.escapeSql(domain)+"'";
select_objects = timercountyxydao.findBySqlQuery(sql);
if(select_objects.size() > 0)//已存在,则更新记录
{
int timer_id = Integer.parseInt(select_objects.get(0).toString());
String hql = "update TimerCountYxy set day_count = "+ci_num+" where timer_id = "+timer_id;
timercountyxydao.updateByHql(hql);
}
else//不存在,则添加记录
{
TimerCountYxy yxy2 = new TimerCountYxy();
yxy2.setCount_date(date);
yxy2.setDay(date.split("-")[2]);
yxy2.setMonth(date.split("-")[1]);
yxy2.setYear(Integer.parseInt(date.split("-")[0]));
yxy2.setLogin_id(loginid);
yxy2.setDomain(domain);
yxy2.setCount_id(9);
yxy2.setDay_count(tol_num);
yxy2.setRecord_id("");
timercountyxydao.addPojo(yxy2);
}
}
ids = ids.substring(0, ids.length()-1);//去掉最后一个分号
//操作完毕后改变该日统计表的状态为已统计
String hql = "update YxyMailDayCount set is_timer_count = 1 where yxy_day_count_id in("+ids+")";
yxymaildaycountdao.updateByHql(hql);
}
System.out.println("营销邮-按时间统计发送总次数与发送总数结束,结束时间:"+DateFormat.getNowDate());
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("营销邮--统计发送总次数与发送总数异常......");
}
}
//营销邮统计点读总数
public void yxyCountReadMail()
{
try
{
System.out.println("营销邮-按时间统计点读总数开始,开始时间:"+DateFormat.getNowDate());
String sql = "select * from yxy_reading_info where is_timer_count = 0 LIMIT 0,100";
List<Object> objects = yxyreaddao.findBySql(sql);
if(objects.size() > 0)
{
String ids = "";
for(int i = 0; i < objects.size(); i++)
{
Object []obj = (Object[])objects.get(i);
//点读id
int yxy_reading_id = Integer.parseInt(obj[0].toString());
ids += yxy_reading_id + ",";
//登录帐号
String loginid = obj[1].toString();
//登录域名
String domain = obj[2].toString();
//当天点读数量
int count = Integer.parseInt(obj[7].toString());
//日期
String date = obj[5].toString().split(" ")[0];
//先判断记录是否存在,不存在则添加,存在则更新
sql = "select timer_id,day_count from timer_count_yxy where count_id = 10 and count_date = '"+date+"' and login_id = '"+StringEscapeUtils.escapeSql(loginid)+"' and domain = '"+StringEscapeUtils.escapeSql(domain)+"'";
List<Object> select_objects = timercountyxydao.findBySqlQuery(sql);
if(select_objects.size() > 0)//已存在,则更新记录
{
Object []arr_select_objects = (Object[])select_objects.get(0);
int timer_id = Integer.parseInt(arr_select_objects[0].toString());
int day_count = Integer.parseInt(arr_select_objects[1].toString());
day_count = day_count + count;
String hql = "update TimerCountYxy set day_count = "+day_count+" where timer_id = "+timer_id;
timercountyxydao.updateByHql(hql);
}
else//不存在,则添加记录
{
TimerCountYxy yxy1 = new TimerCountYxy();
yxy1.setCount_date(date);
yxy1.setDay(date.split("-")[2]);
yxy1.setMonth(date.split("-")[1]);
yxy1.setYear(Integer.parseInt(date.split("-")[0]));
yxy1.setLogin_id(loginid);
yxy1.setDomain(domain);
yxy1.setCount_id(10);
yxy1.setDay_count(count);
yxy1.setRecord_id("");
timercountyxydao.addPojo(yxy1);
}
}
ids = ids.substring(0, ids.length()-1);//去掉最后一个分号
//操作完毕后改变该点读表的状态为已统计
String hql = "update YxyReadingInfo set is_timer_count = 1 where yxy_reading_id in("+ids+")";
yxyreaddao.updateByHql(hql);
}
System.out.println("营销邮-按时间统计点读总数结束,结束时间:"+DateFormat.getNowDate());
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("营销邮--统计点读总数异常......");
}
}
//营销邮统计退订总数
public void yxyCountUnsubscribeMail()
{
try
{
System.out.println("营销邮-按时间统计退订总数开始,开始时间:"+DateFormat.getNowDate());
String sql = "select * from yxy_unsubscribe_info where is_timer_count = 0 LIMIT 0,100";
List<Object> objects = yxyunsubscribedao.findBySql(sql);
if(objects.size() > 0)
{
String ids = "";
for(int i = 0; i < objects.size(); i++)
{
Object []obj=(Object[])objects.get(i);
//退订id
int unsubscribe_id = Integer.parseInt(obj[0].toString());
ids += unsubscribe_id + ",";
//登录帐号
String loginid = obj[1].toString();
//登录域名
String domain = obj[2].toString();
//日期
String date = obj[4].toString().split(" ")[0];
//先判断记录是否存在,不存在则添加,存在则更新
sql = "select timer_id,day_count from timer_count_yxy where count_id = 11 and count_date = '"+date+"' and login_id = '"+StringEscapeUtils.escapeSql(loginid)+"' and domain = '"+StringEscapeUtils.escapeSql(domain)+"'";
List<Object> select_objects = timercountyxydao.findBySqlQuery(sql);
if(select_objects.size() > 0)//已存在,则更新记录
{
Object []arr_select_objects = (Object[])select_objects.get(0);
int timer_id = Integer.parseInt(arr_select_objects[0].toString());
int day_count = Integer.parseInt(arr_select_objects[1].toString());
day_count = day_count + 1;
String hql = "update TimerCountYxy set day_count = "+day_count+" where timer_id = "+timer_id;
timercountyxydao.updateByHql(hql);
}
else//不存在,则添加记录
{
TimerCountYxy yxy = new TimerCountYxy();
yxy.setCount_date(date);
yxy.setDay(date.split("-")[2]);
yxy.setMonth(date.split("-")[1]);
yxy.setYear(Integer.parseInt(date.split("-")[0]));
yxy.setLogin_id(loginid);
yxy.setDomain(domain);
yxy.setCount_id(11);
yxy.setDay_count(1);
yxy.setRecord_id("");
timercountyxydao.addPojo(yxy);
}
}
ids = ids.substring(0, ids.length()-1);//去掉最后一个分号
//操作完毕后改变该退订表的状态为已统计
String hql = "update YxyUnsubscribeInfo set is_timer_count = 1 where unsubscribe_id in("+ids+")";
yxyunsubscribedao.updateByHql(hql);
}
System.out.println("营销邮-按时间统计退订总数结束,结束时间:"+DateFormat.getNowDate());
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("营销邮--统计退订总数异常......");
}
}
//营销邮统计回复总数
public void yxyCountReplyMail()
{
try
{
System.out.println("营销邮-按时间统计回复总数开始,开始时间:"+DateFormat.getNowDate());
String sql = "select * from yxy_reply_info where is_timer_count = 0 LIMIT 0,100";
List<Object> objects = yxyreplyinfodao.findBySql(sql);
if(objects.size() > 0)
{
String ids = "";
for(int i = 0; i < objects.size(); i++)
{
Object []obj=(Object[])objects.get(i);
//回复id
int replyid = Integer.parseInt(obj[0].toString());
ids += replyid + ",";
//登录帐号
String loginid = obj[1].toString();
//登录域名
String domain = obj[2].toString();
//日期
String date = obj[3].toString().split(" ")[0];
//先判断记录是否存在,不存在则添加,存在则更新
sql = "select timer_id,day_count from timer_count_yxy where count_id = 12 and count_date = '"+date+"' and login_id = '"+StringEscapeUtils.escapeSql(loginid)+"' and domain = '"+StringEscapeUtils.escapeSql(domain)+"'";
List<Object> select_objects = timercountyxydao.findBySqlQuery(sql);
if(select_objects.size() > 0)//已存在,则更新记录
{
Object []arr_select_objects = (Object[])select_objects.get(0);
int timer_id = Integer.parseInt(arr_select_objects[0].toString());
int day_count = Integer.parseInt(arr_select_objects[1].toString());
day_count = day_count + 1;
String hql = "update TimerCountYxy set day_count = "+day_count+" where timer_id = "+timer_id;
timercountyxydao.updateByHql(hql);
}
else//不存在,则添加记录
{
TimerCountYxy yxy = new TimerCountYxy();
yxy.setCount_date(date);
yxy.setDay(date.split("-")[2]);
yxy.setMonth(date.split("-")[1]);
yxy.setYear(Integer.parseInt(date.split("-")[0]));
yxy.setLogin_id(loginid);
yxy.setDomain(domain);
yxy.setCount_id(12);
yxy.setDay_count(1);
yxy.setRecord_id("");
timercountyxydao.addPojo(yxy);
}
}
ids = ids.substring(0, ids.length()-1);//去掉最后一个分号
//操作完毕后改变该回复表的状态为已统计
String hql = "update YxyReplyInfo set is_timer_count = 1 where replyid in("+ids+")";
yxyreplyinfodao.updateByHql(hql);
}
System.out.println("营销邮-按时间统计回复总数结束,结束时间:"+DateFormat.getNowDate());
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("营销邮--统计回复总数异常......");
}
}
private TimerCountYxyDao timercountyxydao;//营销邮时间统计dao
private YxyMailDayCountDao yxymaildaycountdao;//营销邮日总统计dao
private YxyReadDao yxyreaddao;//点读dao
private YxyUnsubscribeDao yxyunsubscribedao;//退订dao
private YxyReplyInfoDao yxyreplyinfodao;//回复dao
public TimerCountYxyDao getTimercountyxydao() {
return timercountyxydao;
}
public void setTimercountyxydao(TimerCountYxyDao timercountyxydao) {
this.timercountyxydao = timercountyxydao;
}
public YxyMailDayCountDao getYxymaildaycountdao() {
return yxymaildaycountdao;
}
public void setYxymaildaycountdao(YxyMailDayCountDao yxymaildaycountdao) {
this.yxymaildaycountdao = yxymaildaycountdao;
}
public YxyReadDao getYxyreaddao() {
return yxyreaddao;
}
public void setYxyreaddao(YxyReadDao yxyreaddao) {
this.yxyreaddao = yxyreaddao;
}
public YxyUnsubscribeDao getYxyunsubscribedao() {
return yxyunsubscribedao;
}
public void setYxyunsubscribedao(YxyUnsubscribeDao yxyunsubscribedao) {
this.yxyunsubscribedao = yxyunsubscribedao;
}
public YxyReplyInfoDao getYxyreplyinfodao() {
return yxyreplyinfodao;
}
public void setYxyreplyinfodao(YxyReplyInfoDao yxyreplyinfodao) {
this.yxyreplyinfodao = yxyreplyinfodao;
}
}