SpecialServiceImpl.java
17.3 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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
package com.lhcredit.project.business.special.service;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.lhcredit.common.utils.StringUtils;
import com.lhcredit.common.utils.http.DBHttpTemplate;
import com.lhcredit.common.utils.http.HttpTemplate;
import com.lhcredit.project.business.TianYC.entity.param.RequestParams;
import com.lhcredit.project.business.TianYC.entity.param.SFParams;
import com.lhcredit.project.business.apiDataService.common.TreeBuilder;
import com.lhcredit.project.business.special.enums.RiskLevelEnum;
import com.lhcredit.project.business.special.enums.RiskTypeEnum;
import com.lhcredit.project.business.zareaInfo.domain.ZareaInfo;
import com.lhcredit.project.business.zareaInfo.service.IZareaInfoService;
import com.lhcredit.project.business.zindustryInfo.domain.ZindustryInfo;
import com.lhcredit.project.business.zindustryInfo.service.IZindustryInfoService;
import com.lhcredit.project.business.zproductInfo.domain.ZproductInfo;
import com.lhcredit.project.business.zproductInfo.service.IZproductInfoService;
import com.lhcredit.project.system.dict.domain.DictData;
import com.lhcredit.project.system.dict.service.IDictDataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Autchor : liyang
* @Date: 2025/4/18
*/
@Service
public class SpecialServiceImpl implements SpecialService {
private static Logger log = LoggerFactory.getLogger(SpecialServiceImpl.class);
@Value("${special.url}")
private String specialUrl;
@Value("${special.zhUrl}")
private String zhUrl;
@Value("${dataCenters.url}")
private String apiUrl;
@Value("${DB.url}")
private String DBUrl;
@Resource
private HttpTemplate httpTemplate;
@Resource
private DBHttpTemplate dbHttpTemplate;
private static String token = "d833e14b907442f8b1060cfb3c4fd31d";
@Resource
private IDictDataService dictDataService;
@Resource
private IZareaInfoService zareaInfoService;
@Resource
private IZindustryInfoService zindustryInfoService;
@Resource
private IZproductInfoService zproductInfoService;
@Override
public String comAddsServiceInfo(JSONObject jsonObject) {
log.info("comAddsServiceInfo请求参数:{}", jsonObject);
try {
String creditCode = jsonObject.getString("creditCode");
String creditName = jsonObject.getString("creditName");
if (StringUtils.isNotEmpty(creditCode) && StringUtils.isNotEmpty(creditName)) {
return "creditCode/creditName必选1参数";
}
String url = specialUrl + "lhdb/comAddsServiceInfo/xygj";
JSONObject obj = new JSONObject();
obj.put("creditCode", creditCode);
obj.put("creditName", creditName);
String body = HttpRequest.post(url).body(obj.toJSONString())
.header("token",token).execute().body();
log.info("企业常用地址服务介绍相应结果:{}", body);
return body;
}catch (Exception e){
log.info("comAddsServiceInfo请求异常:{}", e.getMessage());
}
return null;
}
@Override
public String comActive(JSONObject jsonObject) {
log.info("comActive请求参数:{}", jsonObject);
try {
String creditCode = jsonObject.getString("creditCode");
String creditName = jsonObject.getString("creditName");
if (StringUtils.isNotEmpty(creditCode) && StringUtils.isNotEmpty(creditName)) {
return "creditCode/creditName必选1参数";
}
String url = specialUrl + "lhdb/comActive/xygj";
JSONObject obj = new JSONObject();
obj.put("creditCode", creditCode);
obj.put("creditName", creditName);
String body = HttpRequest.post(url).body(obj.toJSONString())
.header("token",token).execute().body();
log.info("企业常用地址服务介绍响应结果:{}", body);
return body;
}catch (Exception e){
log.info("comActive请求异常:{}", e.getMessage());
}
return null;
}
@Override
public String fdfzfw(JSONObject jsonObject) {
log.info("fdzpfwx请求参数:{}", jsonObject);
try {
String url = specialUrl + "blackPupil/fdzpfw";
String type = jsonObject.getString("type");
String id = jsonObject.getString("id");
if (StringUtils.isEmpty(type) || StringUtils.isEmpty(id)) {
return "type和id为必填参数";
}
String body = HttpRequest.post(url).body(jsonObject.toJSONString()).execute().body();
log.info("fdzpfwx响应结果:{}", body);
JSONObject bodyJsonObject = JSONObject.parseObject(body);
if (bodyJsonObject.getInteger("code") == 2000) {
JSONObject o = bodyJsonObject.getJSONObject("data");
if (Objects.nonNull(o) && Objects.nonNull(o.get("FraudRiskItems"))) {
JSONArray jsonArray = o.getJSONArray("FraudRiskItems");
jsonArray.stream().forEach(j -> {
JSONObject item = (JSONObject) j;
RiskLevelEnum riskLevel = RiskLevelEnum.getRiskLevel(item.getString("RiskLevel"));
RiskTypeEnum riskType = RiskTypeEnum.getRiskType(item.getString("RiskLevel"));
item.put("RiskLevel", riskLevel.getLevel());
item.put("RiskLevelMessage", riskLevel.getMessage());
item.put("RiskType", riskType.getMessage());
});
}
}
return bodyJsonObject.toJSONString();
}catch (Exception e){
log.info("fdzpfwx请求异常:{}", e.getMessage());
}
return null;
}
@Override
public String qzfxfw(JSONObject jsonObject) {
log.info("qzfxfw请求参数:{}", jsonObject);
try {
String name = jsonObject.getString("name");
String id = jsonObject.getString("id");
if (StringUtils.isEmpty(name) || StringUtils.isEmpty(id)) {
return "name和id为必填参数";
}
String url = specialUrl + "blackPupil/zppfxpf";
String body = HttpRequest.post(url).body(jsonObject.toJSONString()).execute().body();
log.info("qzfxfw响应结果:{}", body);
JSONObject bodyJsonObject = JSONObject.parseObject(body);
if (bodyJsonObject.getInteger("code") == 2000) {
JSONObject o = bodyJsonObject.getJSONObject("data");
if (Objects.nonNull(o) && Objects.nonNull(o.getInteger("Score"))) {
Integer score = o.getInteger("Score");
if (20 <= score && score < 30) {
o.put("ScoreMessage", "命中在逃名单");
}
if (30 <= score && score < 40) {
o.put("ScoreMessage", "命中吸毒名单");
}
if (40 <= score && score < 50) {
o.put("ScoreMessage", "命中涉毒名单");
}
if (50 <= score && score < 60) {
o.put("ScoreMessage", "命中前科名单");
}
if (60 <= score && score <= 100) {
o.put("ScoreMessage", "未命中关注名单");
}
}
}
return bodyJsonObject.toJSONString();
}catch (Exception e){
log.info("qzfxfw请求异常:{}", e.getMessage());
}
return null;
}
@Override
public String fourBasicInfo(JSONObject jsonObject) {
log.info("fourBasicInfo请求参数:{}", jsonObject);
try{
String entName = jsonObject.getString("entName");
String uniscId = jsonObject.getString("uniscId");
String name = jsonObject.getString("name");
String xId = jsonObject.getString("xId");
if (StringUtils.isEmpty(entName) || StringUtils.isEmpty(uniscId) || StringUtils.isEmpty(name) || StringUtils.isEmpty(xId)) {
return "entName、uniscId、name、xId为必填参数";
}
String url = specialUrl + "zhonghu/fourBasicInfo";
String body = HttpRequest.post(url).body(jsonObject.toJSONString()).execute().body();
log.info("fourBasicInfo响应结果:{}", body);
JSONObject bodyJsonObject = JSONObject.parseObject(body);
if (bodyJsonObject.getInteger("code") == 2000) {
JSONObject data = bodyJsonObject.getJSONObject("data");
JSONObject resultData = data.getJSONObject("resultData");
if (Objects.nonNull(data) && Objects.nonNull(resultData)) {
String result = resultData.getString("result");
if ("1".equals(result)) {
resultData.put("resultMessage", "没找到统代主体无法验证。");
}
if ("2".equals(result)) {
resultData.put("resultMessage", "多个统代主体无法验证。");
}
if ("3".equals(result)) {
resultData.put("resultMessage", "3要素验证,未找到身份证相关数据,无法验证。");
}
if ("4".equals(result)) {
resultData.put("resultMessage", "4要素正常验证。");
}
}
//data.put("resultData", resultData);
}
return bodyJsonObject.toJSONString();
}catch (Exception e){
log.info("fourBasicInfo请求异常:{}", e.getMessage());
}
return null;
}
@Override
public String queryEducationResumeV4(JSONObject jsonObject) {
log.info("queryEducationResumeV4请求参数:{}", jsonObject);
try{
String name = jsonObject.getString("name");
String id = jsonObject.getString("id");
if (StringUtils.isEmpty(name) || StringUtils.isEmpty(id)) return "name、id为必填参数";
String url = specialUrl + "zhonghu/queryEducationResumeV4";
String body = HttpRequest.post(url).body(jsonObject.toJSONString()).execute().body();
log.info("queryEducationResumeV4响应结果:{}", body);
return body;
}catch (Exception e){
log.info("queryEducationResumeV4请求异常:{}", e.getMessage());
}
return null;
}
@Override
public String getFinancingByName(JSONObject jsonObject) {
log.info("getFinancingByName请求参数:{}", jsonObject);
try {
String name = jsonObject.getString("name");
if (StringUtils.isEmpty(name)){
return "企业名称为空";
}
String url = DBUrl + "/lhdb/getFinancingByName/xygj";
RequestParams requestParams = new RequestParams();
requestParams.setName(name);
String tycUrl = dbHttpTemplate.getNameTycUrl(url, requestParams);
log.info("getFinancingByName请求url:{}", tycUrl);
JSONObject result = dbHttpTemplate.getResult(tycUrl);
log.info("getFinancingByName响应结果:{}", result);
return result.toJSONString();
}catch (Exception e){
log.info("getFinancingByName请求异常:{}",e.getMessage());
}
return null;
}
@Override
public String noticeSearch(JSONObject jsonObject) {
log.info("noticeSearch请求参数:{}", jsonObject);
try {
String url = specialUrl + "other/notice/noticeSearch";
String body = HttpRequest.post(url).body(jsonObject.toJSONString()).execute().body();
log.info("noticeSearch响应结果:{}", body);
return body;
}catch (Exception e){
log.info("noticeSearch请求异常:{}",e.getMessage());
}
return null;
}
@Override
public String noticeDetail(JSONObject jsonObject) {
log.info("noticeDetail请求参数:{}", jsonObject);
try {
String url = specialUrl + "other/notice/noticeDetail";
String body = HttpRequest.post(url).body(jsonObject.toJSONString()).execute().body();
log.info("noticeDetail响应结果:{}", body);
return body;
}catch (Exception e){
log.info("noticeDetail请求异常:{}",e.getMessage());
}
return null;
}
@Override
public String noticeComponent(JSONObject jsonObject) {
log.info("noticeComponent请求参数:{}", jsonObject);
try {
String url = specialUrl + "other/notice/noticeComponent";
String body = HttpRequest.post(url).body(jsonObject.toJSONString()).execute().body();
log.info("noticeComponent响应结果:{}", body);
return body;
}catch (Exception e){
log.info("noticeComponent请求异常:{}",e.getMessage());
}
return null;
}
@Override
public JSONObject getNoticeDict() {
JSONObject jsonObject = new JSONObject();
List<DictData> noticeType = dictDataService.selectDictDataByType("notice_type");
List<ZareaInfo> all = zareaInfoService.selectZareaInfoList(new ZareaInfo());
List<ZindustryInfo> industryType = zindustryInfoService.selectZindustryInfoList(new ZindustryInfo());
List<ZareaInfo> zareaInfos = TreeBuilder.buildAreaTree(all);
List<ZindustryInfo> industryTypes = TreeBuilder.buildIndustryTree(industryType);
List<DictData> purchaseType = dictDataService.selectDictDataByType("purchase_type");
List<ZproductInfo> productType = zproductInfoService.selectZproductInfoList(null);
jsonObject.put("noticeTypeList", noticeType);
jsonObject.put("areaTypeList", zareaInfos);
jsonObject.put("industryTypeList", industryTypes);
jsonObject.put("purchaseTypeList", purchaseType);
jsonObject.put("productTypeList", productType);
return jsonObject;
}
@Override
public JSONObject xgbzxrorg(SFParams sfParams) {
sfParams.setType("xgbzxrpeople");
if (StringUtils.isBlank(sfParams.getName())) {
return httpTemplate.getErr("查询实体名称为空", "4000");
}
String url = apiUrl + "sf/xgbzxrpeople/list";
return httpTemplate.getResult(httpTemplate.getSFUrl(url, sfParams));
}
@Override
public JSONObject humanDishonest(SFParams sfParams) {
sfParams.setType("sxbzxrpeople");
if (StringUtils.isBlank(sfParams.getName())) {
return httpTemplate.getErr("查询实体名称为空", "4000");
}
String url = apiUrl + "sf/sxbzxrpeople/list";
return httpTemplate.getResult(httpTemplate.getSFUrl(url, sfParams));
}
@Override
public JSONObject entoutdetail(SFParams sfParams) {
if (StringUtils.isBlank(sfParams.getName())) {
return httpTemplate.getErr("查询实体名称为空", "4000");
}
if (StringUtils.isBlank(sfParams.getType())) {
return httpTemplate.getErr("案件类型为空", "4000");
}
// String url = apiUrl + "sf/entoutdetail/list";
String url = apiUrl + "sf/entoutpeople/list";
return httpTemplate.getResult(httpTemplate.getSFUrl(url, sfParams));
}
@Override
public String getsingleMarriageInfo(JSONObject obj) {
log.info("婚姻接口查询结合参数: {}", obj);
try{
String url = specialUrl + "zhonghu/getSingleMarriageInfo";
String body = HttpRequest.post(url).body(obj.toJSONString()).execute().body();
log.info("getSingleMarriageResult响应结果:{}", body);
JSONObject bodyJsonObject = JSONObject.parseObject(body);
if (bodyJsonObject.getInteger("code") == 2000) {
JSONObject o = bodyJsonObject.getJSONObject("data");
if (Objects.nonNull(o) && Objects.nonNull(o.getString("marriageCode"))) {
if ("10000".equals(o.getString("marriageCode"))) {
o.put("marriageMessage", "强");
}
if ("10001".equals(o.getString("marriageCode"))) {
o.put("marriageMessage", "一般");
}
if ("10002".equals(o.getString("marriageCode"))) {
o.put("marriageMessage", "弱");
}
if ("10003".equals(o.getString("marriageCode"))) {
o.put("marriageMessage", "较弱");
}
if ("10004".equals(o.getString("marriageCode"))) {
o.put("marriageMessage", "未知");
}
}
bodyJsonObject.put("data", o);
}
return bodyJsonObject.toJSONString();
}catch (Exception e){
log.info("婚姻接口查询异常:{}", e.getMessage());
}
return null;
}
}