7a5f3ec9afef6e03e2f33610c1dc9bd4a11ac5d5.svn-base
12.8 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
package com.thinkgem.jeesite.modules.interfaces.service;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.mapper.JsonMapper;
import com.thinkgem.jeesite.common.service.ServiceException;
import com.thinkgem.jeesite.common.utils.DateUtils;
import com.thinkgem.jeesite.common.utils.JsonUtil;
import com.thinkgem.jeesite.modules.reg.dao.bus.RegBusBdcqzsdjxxDao;
import com.thinkgem.jeesite.modules.reg.dao.bus.RegBusQlrDao;
import com.thinkgem.jeesite.modules.reg.dao.bus.RegBusSlsqDao;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseH;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseZdjbxx;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseHService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseZdjbxxService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusSlsqService;
import com.thinkgem.jeesite.modules.reg.utils.RegUtils;
import com.thinkgem.jeesite.modules.sys.service.InterSiService;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
import com.thinkgem.jeesite.modules.wechat.entity.WxOrder;
import freemarker.core.ParseException;
import net.sf.json.JSON;
import net.sf.json.JSONObject;
@Service
public class WXService {
private Logger logger = LoggerFactory.getLogger(InterSiService.class);
@Autowired
RegBusQlrDao qlrDao;
@Autowired
RegBusSlsqDao slsqDao;
@Autowired
RegBusBdcqzsdjxxDao regBusBdcqsdjxxDao;
@Autowired
RegBaseZdjbxxService zdjbxxService;
@Autowired
RegBaseHService hService;
@Autowired
RegBusSlsqService slsqService;
// 进度查询
public Map query_pro(HttpServletRequest request) {
logger.info("入参:" + request);
Map<String,String> res_map = slsqService.progress(request.getParameter("slglh"));
if(res_map==null) {
throw new ServiceException("无此业务相关信息");
}
Map res_data = new HashMap();
String task = res_map.get("TASKDEFKEY");
if (task.equals("reg_end")) {
res_data.put("blzt", "3");
} else if (task.equals("reg_audit56") || task.equals("reg_audit6")) {
res_data.put("blzt", "2");
} else {
res_data.put("blzt", "1");
}
Map data = new HashMap();
data.put("data", res_data);
return res_data;
}
// 解析参数
public Map params(HttpServletRequest request) {
Map map_data = new HashMap();
String param = request.getParameter("data");
JSONObject jb = JSONObject.fromObject(param);
Map map = (Map) jb;
return map;
}
// 证明核验
public Map check_ident(HttpServletRequest request) {
Map<String,String> res_list = regBusBdcqsdjxxDao.queryIdent(request.getParameter("qlrmc"), request.getParameter("cardcode"),
request.getParameter("year"), "登记证明", request.getParameter("zsbm"));
Map res_data = new HashMap();
if(res_list==null) {
throw new ServiceException("无此证明相关信息");
}
if(StringUtils.isBlank(res_list.get("YWH"))) {
throw new ServiceException("数据错误");
}
Map<String,String> qlr_map = qlrDao.querywxQlr(res_list.get("YWH"));
res_list.put("qlrmc",qlr_map.get("QLRMC"));
res_data.put("data", res_list);
return res_data;
}
// 证书核验
public Map check_cret(HttpServletRequest request) {
Map<String,String> res_list = regBusBdcqsdjxxDao.queryIdent(request.getParameter("qlrmc"), request.getParameter("cardcode"),
request.getParameter("year"), "不动产权", request.getParameter("zsbm"));
Map res_data = new HashMap();
if(res_list==null) {
throw new ServiceException("无此证书相关信息");
}
if(StringUtils.isBlank(res_list.get("YWH"))) {
throw new ServiceException("数据错误");
}
Map<String,String> qlr_map = qlrDao.querywxQlr(res_list.get("YWH"));
res_list.put("qlrmc",qlr_map.get("QLRMC"));
res_data.put("data", res_list);
return res_data;
}
//叫号推送
public Map call(HttpServletRequest request) {
String url = Global.getWxUrl() + "/start/appointmentProcess";
String yyid = request.getParameter("yyid");
Map params = new HashMap();
params.put("yyid", yyid);
String ckbh = UserUtils.getUser().getCkbh();
params.put("blck", ckbh);
if(StringUtils.isBlank(ckbh)) {
throw new ServiceException("请先维护窗口编号");
}
String content = "";
try {
content = posturl(params, url);
} catch (IOException e) {
e.printStackTrace();
}
Map map = JsonUtil.jsonToMap(content);
return map;
}
// post方式向微信端传递数据
private String posturl(Map params, String url) throws IOException {
Integer URLOUTTIME = 1000 * 60;
String res = "";
HttpPost httppost = null;
CloseableHttpClient client = null;
CloseableHttpResponse response = null;
Exception exception = null;
try {
client = HttpClientBuilder.create().build();
httppost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(URLOUTTIME)
.setConnectTimeout(URLOUTTIME).setSocketTimeout(URLOUTTIME).build();
httppost.setConfig(requestConfig);
List<NameValuePair> urlParameters = Lists.newArrayList();
if(params != null && params.size()>0) {
Iterator<String> it = params.keySet().iterator();
while (it.hasNext()) {
String key = it.next();
urlParameters.add(new BasicNameValuePair(key,params.get(key).toString()));
}
httppost.setEntity(new UrlEncodedFormEntity(urlParameters, "utf-8"));
}
httppost.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
response = client.execute(httppost);
res = EntityUtils.toString(response.getEntity(), "utf-8");
logger.info("返回信息:" + res);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (httppost != null) {
httppost.releaseConnection();
}
if (response != null) {
response.close();
}
if (client != null) {
client.close();
}
}
return res;
}
public Map check_rig(HttpServletRequest request) {
// TODO Auto-generated method stub
Map map = new HashMap();
List list = new ArrayList();
List alist = Lists.newArrayList();
String name = request.getParameter("name");
String carcode = request.getParameter("carcode");
List<Map<String, String>> res_data = regBusBdcqsdjxxDao.queryRights(name,carcode);
if(res_data.size()>0) {
for(int i=0;i<res_data.size();i++) {
Map<String,String> res_map = res_data.get(i);
res_map.put("qlrmc", name);//产权人
res_map.put("carcode",carcode);//身份证号
if(StringUtils.isBlank(res_map.get("YWH"))) {
logger.info("业务号为空");
continue;
}
Map<String,String> qlr_map = qlrDao.querywxGyr(res_map.get("YWH"),carcode);
Integer sxh =1;
if(qlr_map==null) {
res_map.put("gyrmc","无");
}else {
sxh =qlrDao.getSxh(res_map.get("YWH"),name,carcode);
if(sxh==null) {
logger.info("权利人顺序号为空");
continue;
}
res_map.put("gyrmc",qlr_map.get("GYRMC"));
}
String bdcqzh = res_map.get("BDCQZH");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
res_map.put("cxsj", sdf.format(new Date()));
if(StringUtils.isNotBlank(bdcqzh)) {
if(bdcqzh.indexOf(",") == -1) {
res_map.put("cqzh", bdcqzh);
}else {
String newbdcqzh = bdcqzh.substring(bdcqzh.indexOf("第")).split(",")[sxh-1];
logger.info(bdcqzh.substring(0,bdcqzh.indexOf("第")));
res_map.put("cqzh", bdcqzh.substring(0,bdcqzh.indexOf("第")+1)+newbdcqzh);
}
}
String bdcdyh = res_map.get("BDCDYH");
if(bdcdyh.indexOf("W")==-1) {//房权
RegBaseH h = hService.getdy(bdcdyh);
if(h==null) {
logger.info("户信息为空");
continue;
}
String zt="";
if(!(h.getIsdiya()).equals("0")) {
zt = zt +"已抵押";
}
if(!(h.getIschafeng()).equals("0")) {
zt = zt+" 已查封";
}
if(!(h.getIsyiyi()).equals("0")) {
zt = zt +" 已异议";
}
if(StringUtils.isBlank(zt)) {
zt = "无";
}
res_map.put("bdczt",zt);
res_map.put("MJ",res_map.get("MJ")+DictUtils.getDictLabel(h.getMjdw(), "reg_bus_mjdw", ""));
}else {
RegBaseZdjbxx zdjbxx = zdjbxxService.getbdcdyh(bdcdyh);
if(zdjbxx==null) {
logger.info("宗地信息为空");
continue;
}
String zt="";
if(!(zdjbxx.getIsdiya()).equals("0")) {
zt = zt +"已抵押";
}
if(!(zdjbxx.getIschafeng()).equals("0")) {
zt = zt+" 已查封";
}
if(!(zdjbxx.getIsyiyi()).equals("0")) {
zt = zt +" 已异议";
}
if(StringUtils.isBlank(zt)){
zt = "无";
}
res_map.put("bdczt",zt);
res_map.put("MJ",res_map.get("MJ")+DictUtils.getDictLabel(zdjbxx.getMjdw(), "reg_bus_mjdw", ""));
}
alist.add(res_map);
}
}else {
throw new ServiceException("无产权信息");
}
map.put("aaData", alist);
return map;
}
//业务完结推送
public Map send(HttpServletRequest request) {
String url = Global.getWxUrl() + "/end/bussProcess";
String ywh = request.getParameter("ywh");
String djxl = request.getParameter("djxl");
List<Map<String, String>> list = qlrDao.getXgry(ywh);
Map params = Maps.newHashMap();
params.put("ywh",ywh);
params.put("djxl",DictUtils.getDictLabel(djxl, "reg_bus_djxl", ""));
params.put("xgry", list);
String content = "";
try {
content = posturl(params, url);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Map map = JsonUtil.jsonToMap(content);
return map;
}
public Map sign(WxOrder wxOrder) {
String url = Global.getWxUrl() + "/end/order";
Map params = new HashMap();
params.put("yyid", wxOrder.getYyid());
params.put("sign", wxOrder.getSign());
String content = "";
try {
content = posturl(params, url);
} catch (IOException e) {
e.printStackTrace();
}
Map map = JsonUtil.jsonToMap(content);
return map;
}
public Map getFlow() {
Map map = Maps.newHashMap();
//目前排除法定假节日还未实现,只是周内
//获取前一个工作日
Calendar now = Calendar.getInstance();
int today = now.getTime().getDay();//取得今天的星期值
if(today == now.getFirstDayOfWeek()){//今天在这个星期中是否为第一天
now.roll(Calendar.DAY_OF_YEAR, -3);
}else{
now.roll(Calendar.DAY_OF_YEAR, -1);
}
System.out.println(now.getTime());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
List<Map<String,String>> ymap = slsqService.getYflow(sdf.format(now.getTime()));
map.put("yData", ymap);
logger.info("yData:"+JsonUtil.toJsonString(ymap));
//获取前一周工作日,没法周一周五关联查询,所以循环吧、、
Date a = DateUtils.addDays(new Date(), -1);
Calendar cale = Calendar.getInstance();
cale.setTime(a);
cale.add(Calendar.WEEK_OF_YEAR, -1);// 一周
cale.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
List<Map<String,String>> wmap = slsqService.getWflow(sdf.format(cale.getTime()));
logger.info("日期"+sdf.format(cale.getTime()));
String[] weekDays = {"一", "二", "三", "四", "五"};
if(wmap.size()>0) {
for(int w=0;w<wmap.size();w++) {
SimpleDateFormat f = new SimpleDateFormat("yyyy/MM/dd");
Calendar cal = Calendar.getInstance(); // 获得一个日历
Date datet = null;
try {
datet = f.parse(wmap.get(w).get("SJ"));
cal.setTime(datet);
} catch (Exception e) {
e.printStackTrace();
}
String week = "周"+weekDays[w];
wmap.get(w).put("SJ", week);
}
}
map.put("wData", wmap);
logger.info("wData:"+JsonUtil.toJsonString(ymap));
return map;
}
}