83918448579adc8b8a0dc2150235640608b0cd59.svn-base
4.9 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
package yxy.timer.method;
import java.util.List;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import com.alibaba.fastjson.JSON;
import yxy.timer.pojo.YxyMailNumCount;
import yxy.timer.pojo.YxyReplyInfo;
import yxy.timer.service.YxyReplyInfoService;
import yxy.timer.tool.ConfigPath;
import yxy.timer.tool.getArea;
/***
* 从webmail获取回复信息
*/
public class GetReplyInfo {
private boolean isRun = false; //判断定时器是否在运行 默认false
public void getReplyInfo()
{
try {
if(!isRun)
{
System.out.println("正在从webmail获取回复信息...");
isRun = true;//在运行
//查询数据库 获取回复最后一条的id
String hql = "from YxyReplyInfo ORDER BY replyid desc";
List<YxyReplyInfo> replyInfos = yxyreplyinfoservice.findByHqlSet(hql, 1);
int replyid = 0;
//判断是否有数据
if(replyInfos.size()>0)
{
replyid = replyInfos.get(0).getReplyid();//得到replyid
}
//访问webmail接口
String webmail = ConfigPath.getWebmailInterfaceUrl();
String url = webmail+"/webmailWebservice/yxyreplyinfoservice?wsdl";
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
org.apache.cxf.endpoint.Client client = dcf.createClient(url);
Object[] response = client.invoke("findYxyReplyInfos", replyid);
//判断是否为空
if(response[0] != null)//不为空
{
String result = response[0].toString();
//把json字符串转换为集合
List<YxyReplyInfo> replylist = JSON.parseArray(result,YxyReplyInfo.class);
if(replylist.size() > 0){
for(YxyReplyInfo reply : replylist){
YxyMailNumCount count = yxyreplyinfoservice.getYxyMailNumCount(reply.getMailuid());
if(count == null){//添加
count = new YxyMailNumCount();
count.setId(0);
count.setMail_uid(reply.getMailuid());
count.setReplay_person(1);
}else{//编辑
count.setReplay_person(count.getReplay_person()+1);
}
//获取ip所属地区
if(reply.getIp()!=null&&!reply.getIp().equals("")&&!reply.getIp().equals("unknown")){
reply.setArea(getArea.getArea(reply.getIp()));
}else{
reply.setArea("未知");
}
int replyyear = Integer.parseInt(reply.getNowdate().split("-")[0]);
int replyday = Integer.parseInt(reply.getNowdate().split("-")[2]);
reply.setReplyyear(replyyear);
reply.setReplyday(replyday);
//添加回复信息
yxyreplyinfoservice.addReply(reply);
//添加邮件对应的数量统计
yxyreplyinfoservice.addEditYxyMailNumCount(count);
System.out.println("邮件回复量处理中...");
}
}
// String result = response[0].toString();
// //把json字符串转换为集合
// replylist = JSON.parseArray(result,YxyReplyInfo.class);
// yxyreplyinfoservice.addReply(replylist);
// try {
// System.out.println("开始处理邮件具体回复量");
// Map<String,Integer> readmap=new HashMap<String,Integer>();
// for(int i=0;i<replylist.size();i++){
// String mailuid=replylist.get(i).getMailuid();//邮件唯一码
// //判断是否存在此键(uid作为键)
// boolean isexits=readmap.containsKey(mailuid);
// if(isexits){
// int mailnum=readmap.get(mailuid);
// readmap.put(mailuid,mailnum+1);
// }else{
// readmap.put(mailuid,1);
// }
// }
// //循环map
// Iterator<Entry<String, Integer>> iter = readmap.entrySet().iterator();
// while (iter.hasNext()){
// Entry<String, Integer> entry=iter.next();
// String key =entry.getKey();
// int value =entry.getValue();
// //查询历史的
// hql="from YxySendMailMasterBase where mail_uid='"+key+"'";
// List<YxySendMailMasterBase> bases=yxyreplyinfoservice.findMailByHql(hql);
// if(bases.size()>0){
// value=value+bases.get(0).getReply_mail_count();
// //修改邮件信息
// hql="update YxySendMailMasterBase set reply_mail_count="+value+" where mail_uid='"+key+"'";
// yxyreplyinfoservice.updateMailInfoByHql(hql);
// }
// System.out.println("邮件回复量处理中...");
// }
// System.out.println("处理邮件具体回复量结束!");
// } catch (Exception e) {
// e.printStackTrace();
// }
System.out.println("正常结束从webmail获取回复信息");
}
isRun = false;//更改状态为非执行
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("异常从webmail获取回复信息");
isRun = false;//更改状态为非执行
}
}
private YxyReplyInfoService yxyreplyinfoservice;//回复service
public YxyReplyInfoService getYxyreplyinfoservice() {
return yxyreplyinfoservice;
}
public void setYxyreplyinfoservice(YxyReplyInfoService yxyreplyinfoservice) {
this.yxyreplyinfoservice = yxyreplyinfoservice;
}
}