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
<?xml version="1.0" encoding="UTF-8"?>
<a:service xmlns:p="uncertain.proc" xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" trace="true">
<a:init-procedure>
<s:server-script><![CDATA[
importPackage(Packages.com.hand.hls.hlcm.ccx.service);
var service = $spring(ICcxIcInfoService);
// 配置信息
var interface_code = 'CCX_ORG_INTERFACE';
var interface_parameter_bm = $bm('interface.hls_interface_parameter');
var interface_parameter_result = interface_parameter_bm.queryAsMap({
"interface_code": interface_code
});
var interface_parameter_records = interface_parameter_result.getChildren();
var apiUrl = interface_parameter_records[0].INTERFACE_URL; //环境地址
var account = interface_parameter_records[0].INTERFACE_USERNAME; //用户名
var privateKey = interface_parameter_records[0].INTERFACE_PASSWORD; //密码
//var apiUrl = 'https://tapi.ccxcredit.com/data-service/icinfo/report';
//var account = 'DCFL0011';
//var privateKey = '0c95ab2ec86a4a018f77eb56d7ed26e7';
// 测试数据
//var cid = '310000400308460';
//var name = '上海汉得信息技术股份有限公司';
var cid = $ctx.parameter.business_license_num;
var name = $ctx.parameter.bp_name;
try {
//发起请求
var resultString = service.sendCcxIcInfoMessage(apiUrl, account, privateKey, cid, name);
//转成json数组
var json_msg = JSON.parse(resultString);
var json_str = null;
//根据时间戳生成一个随机数作为外键
var chk_list_id = (new Date()).valueOf();
println("111:" + json_msg + json_msg.entities.length);
var rescode = json_msg.resCode;
var resmsg = json_msg.resMsg;
var reqtid = json_msg.reqTid;
var tid = json_msg.tid;
var sign = json_msg.sign;
println("rescode:" + rescode);
//循环json数组取出data值
for (var i = 0;i < json_msg.entities.length;i++) {
//获取接口的数据类型
var interface_type = json_msg.entities[i].type;
//如果接口返回数据为数据分析,进一步解析
if (interface_type == 20) {
//遍历map,获取相应key的数组
for (var key in json_msg.entities[i].data) {
//获取entDBRank
if (key == "entDBRank") {
interface_type = 21;
json_str = JSON.stringify(json_msg.entities[i].data.entDBRank);
println("entDBRank:" + chk_list_id + ',' + interface_type + ',' + json_str);
// 插入接口表
$bm('interface.CCX_INTERFACE.ccx_insert_interface').update({
chk_list_id: chk_list_id,
bp_id: $ctx.parameter.bp_id,
interface_type: interface_type,
json_str: json_str,
rescode: rescode,
resmsg: resmsg,
reqtid: reqtid,
tid: tid,
sign: sign
});
} else if (key == "comRankInfo") { //获取comRankInfo的map
for (var key in json_msg.entities[i].data.comRankInfo) { //遍历comRankInfo
if (key == "comRanks") { //获取comRanks的数组
interface_type = 22; //设置interface_type为22,便于插入对应的表
if (json_msg.entities[i].data.comRankInfo.comRanks != null && json_msg.entities[i].data.comRankInfo.comRanks != []) {
for (var a = 0;a < json_msg.entities[i].data.comRankInfo.comRanks.length;a++) {
println("year:" + json_msg.entities[i].data.comRankInfo.comRanks[a].year);
json_msg.entities[i].data.comRankInfo.comRanks[a].comRankModels[0].year = json_msg.entities[i].data.comRankInfo.comRanks[a].year;
json_str = JSON.stringify(json_msg.entities[i].data.comRankInfo.comRanks[a].comRankModels[0]);
println("comRankModels:" + chk_list_id + ',' + interface_type + ',' + json_str);
// 插入接口表
$bm('interface.CCX_INTERFACE.ccx_insert_interface').update({
chk_list_id: chk_list_id,
bp_id: $ctx.parameter.bp_id,
interface_type: interface_type,
json_str: json_str,
rescode: rescode,
resmsg: resmsg,
reqtid: reqtid,
tid: tid,
sign: sign
});
}
}
} else if (key == "comRatios") {
interface_type = 23; //设置interface_type为23,便于插入对应的表
if (json_msg.entities[i].data.comRankInfo.comRatios != null && json_msg.entities[i].data.comRankInfo.comRatios != []) {
for (var b = 0;b < json_msg.entities[i].data.comRankInfo.comRatios.length;b++) {
json_str = JSON.stringify(json_msg.entities[i].data.comRankInfo.comRatios[b]);
println("comRatios:" + chk_list_id + ',' + interface_type + ',' + json_str);
// 插入接口表
$bm('interface.CCX_INTERFACE.ccx_insert_interface').update({
chk_list_id: chk_list_id,
bp_id: $ctx.parameter.bp_id,
interface_type: interface_type,
json_str: json_str,
rescode: rescode,
resmsg: resmsg,
reqtid: reqtid,
tid: tid,
sign: sign
});
}
}
} else if (key == "avgIndustries") {
interface_type = 24; //设置interface_type为24,便于插入对应的表
if (json_msg.entities[i].data.comRankInfo.avgIndustries != null && json_msg.entities[i].data.comRankInfo.avgIndustries != []) {
for (var c = 0;c < json_msg.entities[i].data.comRankInfo.avgIndustries.length;c++) {
json_str = JSON.stringify(json_msg.entities[i].data.comRankInfo.avgIndustries[c]);
println("avgIndustries:" + chk_list_id + ',' + interface_type + ',' + json_str);
// 插入接口表
$bm('interface.CCX_INTERFACE.ccx_insert_interface').update({
chk_list_id: chk_list_id,
bp_id: $ctx.parameter.bp_id,
interface_type: interface_type,
json_str: json_str,
rescode: rescode,
resmsg: resmsg,
reqtid: reqtid,
tid: tid,
sign: sign
});
}
}
}
}
}
}
} else {
json_str = JSON.stringify(json_msg.entities[i].data);
println("all:" + chk_list_id + ',' + interface_type + ',' + json_str);
// 插入接口表
$bm('interface.CCX_INTERFACE.ccx_insert_interface').update({
chk_list_id: chk_list_id,
bp_id: $ctx.parameter.bp_id,
interface_type: interface_type,
json_str: json_str,
rescode: rescode,
resmsg: resmsg,
reqtid: reqtid,
tid: tid,
sign: sign
});
}
}
} catch (e) {
println("抛出异常:" + e);
}
]]></s:server-script>
</a:init-procedure>
<a:service-output output="/parameter"/>
</a:service>