bd903cf09ef584329e6730d0274075558ee7ec78.svn-base
7.77 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
package com.thinkgem.jeesite.modules.reg.web.bus;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.utils.DateUtils;
import com.thinkgem.jeesite.common.utils.FileUtils;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusSbtj;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusBdcqzsdjxxService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusSbtjService;
import com.thinkgem.jeesite.modules.reg.service.updata.RegBusSjhjtableService;
import com.thinkgem.jeesite.modules.reg.web.bus.registlog.JrrzService;
import com.thinkgem.jeesite.modules.reg.web.bus.registlog.JrrzServiceService;
import com.thinkgem.jeesite.modules.reg.web.httprest.httpRestService.HttpactivityService;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;
import java.io.File;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
@Lazy(false)
public class CommitLog
{
@Autowired
private RegBusSbtjService regBusSbtjService;
@Autowired
private RegBusSjhjtableService regBusSjhjtableService;
@Autowired
private RegBusBdcqzsdjxxService regBusBdcqzsdjxxService;
@Autowired
private HttpactivityService httpactivityService;
protected Logger logger = LoggerFactory.getLogger(super.getClass());
public synchronized void autoCommitLog()
{
String bz_dataup = System.getProperty("timeservice.dataup");
logger.info("数据汇总标志:"+bz_dataup);
if(StringUtils.isBlank(bz_dataup) || !bz_dataup.equals("1")) {
logger.info("不是数据汇总服务器,登簿量上报直接返回");
return;
}
String[] qxdminfo = { "610702", "610721", "610722", "610723", "610724", "610725", "610726", "610727", "610728", "610729", "610730" };
for (int i = 0; i < qxdminfo.length; ++i)
{
String areacode = qxdminfo[i];
Map map = new HashMap();
map.put("areacode", areacode);
StringBuilder registrationLogXml = new StringBuilder();
registrationLogXml.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
registrationLogXml.append("<AccessLogs>\n");
registrationLogXml.append("<AccessLog>\n");
Date date = new Date();
RegBusSbtj regBusSbtj = new RegBusSbtj();
String dbsj = DateUtils.getDate("yyyy-MM-dd");
regBusSbtj.setAreacode(areacode);
registrationLogXml.append("<AreaCode>" + areacode + "</AreaCode>\n");
String areaName = DictUtils.getDictLabels(areacode, "reg_bus_xq", "");
registrationLogXml.append("<AreaName>" + areaName + "</AreaName>\n");
SimpleDateFormat myFmt = new SimpleDateFormat("yyyyMMdd");
String accessDate = myFmt.format(date);
registrationLogXml.append("<AccessDate>" + accessDate + "</AccessDate>\n");
String remark = "";
registrationLogXml.append("<Remark>" + remark + "</Remark>\n");
String accessTotalNum = this.regBusSjhjtableService.findAllnum(map);
String firstReg2 = this.regBusSjhjtableService.findScnum(map);
String transferReg2 = this.regBusSjhjtableService.findZynum(map);
String changeReg2 = this.regBusSjhjtableService.findBgnum(map);
String logoutReg2 = this.regBusSjhjtableService.findZxnum(map);
String riviseReg2 = this.regBusSjhjtableService.findGznum(map);
String dissentingReg2 = this.regBusSjhjtableService.findYynum(map);
String advanceReg2 = this.regBusSjhjtableService.findYgnum(map);
String seizeReg2 = this.regBusSjhjtableService.findCfnum(map);
String easementReg2 = this.regBusSjhjtableService.findDyiqnum(map);
String mortgageReg2 = this.regBusSjhjtableService.findDyaqnum(map);
String registerTotalNum = accessTotalNum;
String firstReg1 = firstReg2;
String transferReg1 = transferReg2;
String changeReg1 = changeReg2;
String logoutReg1 = logoutReg2;
String riviseReg1 = riviseReg2;
String dissentingReg1 = dissentingReg2;
String advanceReg1 = advanceReg2;
String seizeReg1 = seizeReg2;
String easementReg1 = easementReg2;
String mortgageReg1 = mortgageReg2;
String businessTypeCount = this.regBusSjhjtableService.findTypeCount(map);
regBusSbtj.setJrnum(accessTotalNum);
regBusSbtj.setJrsc(firstReg2);
regBusSbtj.setJrzy(transferReg2);
regBusSbtj.setJrbg(changeReg2);
regBusSbtj.setJrzx(logoutReg2);
regBusSbtj.setJrgz(riviseReg2);
regBusSbtj.setJryy(dissentingReg2);
regBusSbtj.setJryg(advanceReg2);
regBusSbtj.setJrcf(seizeReg2);
regBusSbtj.setJrdyi(easementReg2);
regBusSbtj.setJrdya(mortgageReg2);
regBusSbtj.setDbnum(registerTotalNum);
regBusSbtj.setDbsc(firstReg1);
regBusSbtj.setDbzy(transferReg1);
regBusSbtj.setDbbg(changeReg1);
regBusSbtj.setDbzx(logoutReg1);
regBusSbtj.setDbgz(riviseReg1);
regBusSbtj.setDbyy(dissentingReg1);
regBusSbtj.setDbyg(advanceReg1);
regBusSbtj.setDbcf(seizeReg1);
regBusSbtj.setDbdyi(easementReg1);
regBusSbtj.setDbdya(mortgageReg1);
regBusSbtj.setTjdate(dbsj);
this.regBusSbtjService.save(regBusSbtj);
registrationLogXml.append("<RegisterInfo totalNum=\"" + registerTotalNum + "\" firstReg=\"" + firstReg1 + "\" transferReg=\"" +
transferReg1 + "\" changeReg=\"" + changeReg1 + "\" logoutReg=\"" + logoutReg1 + "\" riviseReg=\"" + riviseReg1 + "\" dissentingReg=\"" +
dissentingReg1 + "\" advanceReg=\"" + advanceReg1 + "\" seizeReg=\"" + seizeReg1 + "\" easementReg=\"" + easementReg1 + "\" mortgageReg=\"" +
mortgageReg1 + "\" businessTypeCount=\"" + businessTypeCount + "\"" + "> </RegisterInfo>\n");
registrationLogXml.append("<AccessInfo totalNum=\"" + accessTotalNum + "\" firstReg=\"" + firstReg2 + "\" transferReg=\"" +
transferReg2 + "\" changeReg=\"" + changeReg2 + "\" logoutReg=\"" + logoutReg2 + "\" riviseReg=\"" + riviseReg2 + "\" dissentingReg=\"" +
dissentingReg2 + "\" advanceReg=\"" + advanceReg2 + "\" seizeReg=\"" + seizeReg2 + "\" easementReg=\"" + easementReg2 + "\" mortgageReg=\"" +
mortgageReg2 + "\"" + "> </AccessInfo>\n");
registrationLogXml.append("</AccessLog>\n");
registrationLogXml.append("</AccessLogs>");
String rzinfoXml = registrationLogXml.toString();
String msg = "";
try {
System.out.println(rzinfoXml + "********");
Date datenew = new Date();
SimpleDateFormat myFmtnew = new SimpleDateFormat("yyyyMMdd");
String accessDatenew = myFmtnew.format(datenew);
System.out.println("开始发送********");
JrrzServiceService jrrzsservice = new JrrzServiceService();
JrrzService jrrzsb = jrrzsservice.getJrrzServicePort();
msg = jrrzsb.exchangeInfo(rzinfoXml.toString());
System.out.println("结束发送********");
String filePath = Global.getUserfilesBaseDir() + "/booklogs/" + accessDatenew + System.currentTimeMillis() + ".txt";
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
FileUtils.writeStringToFile(new File(filePath), rzinfoXml.toString() + "\n" + msg + "\n" + "当前上报日志日期为:" + df.format(new Date()) + ",返回结果为:" + msg, "UTF-8");
} catch (Exception e) {
System.out.println("日志上报失败 :" + e.getMessage());
this.logger.error(errorTrackSpace(e));
}
}
}
public static String errorTrackSpace(Exception e)
{
StringBuffer sb = new StringBuffer();
if (e != null) {
for (StackTraceElement element : e.getStackTrace()) {
sb.append("\r\n\t").append(element);
}
}
return ((sb.length() == 0) ? null : sb.toString());
}
}