CreateContractRest.java
4.14 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
package com.thinkgem.jeesite.modules.eci.method;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.utils.JsonUtil;
import com.thinkgem.jeesite.modules.eci.dao.ElecLicenseInfoDao;
import com.thinkgem.jeesite.modules.eci.entity.BdcqzsTemplate;
import com.thinkgem.jeesite.modules.eci.entity.CreateContractRequest;
import com.thinkgem.jeesite.modules.eci.entity.CreateContractResponse;
import com.thinkgem.jeesite.modules.eci.entity.ElecLicenseInfo;
import com.thinkgem.jeesite.modules.eci.utils.EciHttpUtil;
import org.apache.commons.beanutils.BeanUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 请求创建合同方法
*/
@Component
public class CreateContractRest {
private Logger logger = LoggerFactory.getLogger(CreateContractRest.class);
private static final String CREATE_BY_CATEGORY = "/contract/createbycategory";
@Autowired
ElecLicenseInfoDao licenseInfoDao;
/**
* 批量创建
*
* @return
*/
@Transactional(rollbackFor = Exception.class)
public void accessCreateContract() {
String url = Global.ECI_HOST + CREATE_BY_CATEGORY;
logger.info("http request url:" + url);
// List<CreateContractRequest> requests = new ArrayList<>();
List<ElecLicenseInfo> waitForCreateContracts = licenseInfoDao.getContractIdIsNull();
for (ElecLicenseInfo waitForCreateContract : waitForCreateContracts) {
String result = null;
CreateContractRequest request = new CreateContractRequest();
request.setSubject("不动产合同");
request.setSn(waitForCreateContract.getYwh());
String htlx = waitForCreateContract.getHtlx();
if ("1".equals(htlx) || "2".equals(htlx)) {
//不动产登记证明和不动产权证书类型使用证照专用章
request.setCategoryId(Global.ECI_ZZZYZ);
} else if ("3".equals(htlx)) {
//不动产查询证明使用档案查询专用章
request.setCategoryId(Global.ECI_DACXZYZ);
}
request.setBizId(waitForCreateContract.getBizId());
// TODO: 2022/2/14/0014 获取模板参数json字符串,处理方式待定
String bdcqzsTemplateStr = waitForCreateContract.getDocumentParam();
BdcqzsTemplate bdcqzsTemplate = JsonUtil.fromJson(bdcqzsTemplateStr, BdcqzsTemplate.class);
List<BdcqzsTemplate> templates = new ArrayList(){{
add(bdcqzsTemplate);
}};
request.setDocumentParams(templates);
//提交参数入库
String tjcs = JsonUtil.toJsonString(request);
logger.info("提交参数:" + tjcs);
waitForCreateContract.setTjcs(tjcs);
try {
Map map = new HashMap();
BeanUtils.populate(request, map);
result = EciHttpUtil.doPost(url, map);
logger.info("创建合同接口返回结果:" + result);
CreateContractResponse response = JsonUtil.fromJson(result, CreateContractResponse.class);
if (response != null) {
if (0 == (response.getCode())) {
Long contractId = response.getContractId();
//合同ID入库
waitForCreateContract.setContractId(contractId);
//返回结果入库
waitForCreateContract.setFhjg(result);
//未下载
waitForCreateContract.setSfxz("2");
//未转换
waitForCreateContract.setSfzh("2");
licenseInfoDao.updateContractIdAndStatus(waitForCreateContract);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}