ContractDetailsRest.java
2.16 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
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.ContractDetailsResponse;
import com.thinkgem.jeesite.modules.eci.entity.ElecLicenseInfo;
import com.thinkgem.jeesite.modules.eci.utils.EciHttpUtil;
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.List;
/**
* 请求合同详情方法
*/
@Component
public class ContractDetailsRest {
private static final String DETAILS = "/contract/detail";
private Logger logger = LoggerFactory.getLogger(ContractDetailsRest.class);
@Autowired
ElecLicenseInfoDao licenseInfoDao;
@Transactional(rollbackFor = Exception.class)
public void accessDetails() {
List<ElecLicenseInfo> waitForDetails = licenseInfoDao.getDocumentIdIsNull();
for (ElecLicenseInfo waitForDetail : waitForDetails) {
Long contractId = waitForDetail.getContractId();
String bizId = waitForDetail.getBizId();
String url = Global.ECI_HOST + DETAILS + "?contractId=" + contractId;
logger.info("请求合同详情接口url:" + url);
try {
String result = null;
result = EciHttpUtil.doGet(url);
logger.info("合同详情接口请求结果:" + result);
ContractDetailsResponse response = JsonUtil.fromJson(result, ContractDetailsResponse.class);
if (response != null && response.getCode() == 0) {
// TODO: 2022/2/15/0015 目前先取文档详情集合第一个
Long documentId = response.getContract().getDocuments().get(0).getId();
//文档ID入库
licenseInfoDao.updateDocumentId(bizId, documentId);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}