浏览代码

增加不良人接口-不拼接接口

15810770710@163.com 3 年之前
父节点
当前提交
c63c3e4326

+ 39 - 0
src/main/java/com/jkcredit/illegal/info/controller/IllegalInfoController.java

@@ -25,6 +25,11 @@ public class IllegalInfoController {
     @Autowired
     IllegalInfoTestService illegalInfoTestService;
 
+    /**
+     * 社会风险预警-超时跳转接口
+     * @param requestParams 姓名 身份证号 流水号
+     * @return 结果
+     */
     @PostMapping("/checkIllegalInfo.do")
     public CommonResponseObject checkIllegalInfo(@RequestBody IllegalInfoRequestParam requestParams) {
         log.info("checkIllegalInfo-接收参数:{}", requestParams);
@@ -37,6 +42,40 @@ public class IllegalInfoController {
         }
     }
 
+    /**
+     * 社会风险预警-超时返回一致
+     * @param requestParams 姓名 身份证号 流水号
+     * @return 结果
+     */
+    @PostMapping("/checkIllegalInfoNormalResponse.do")
+    public CommonResponseObject checkIllegalInfoNormalResponse(@RequestBody IllegalInfoRequestParam requestParams) {
+        log.info("checkIllegalInfoNormalResponse-接收参数:{}", requestParams);
+        IllegalInfoResult illegalInfoResult = illegalInfoService.checkIllegalInfo(requestParams);
+        if (illegalInfoResult != null) {
+            log.info("checkIllegalInfoNormalResponse-返回:{}", illegalInfoResult);
+            return CommonResponseObject.success(illegalInfoResult);
+        } else {
+            return CommonResponseObject.failure();
+        }
+    }
+
+    /**
+     * 社会风险预警
+     * @param requestParams 姓名 身份证号 流水号
+     * @return 结果
+     */
+    @PostMapping("/checkIllegalInfoCommon.do")
+    public CommonResponseObject checkIllegalInfoCommon(@RequestBody IllegalInfoRequestParam requestParams) {
+        log.info("checkIllegalInfoCommon-接收参数:{}", requestParams);
+        IllegalInfoResult illegalInfoResult = illegalInfoService.checkIllegalInfoV3(requestParams);
+        if (illegalInfoResult != null) {
+            log.info("checkIllegalInfoCommon-返回:{}", illegalInfoResult);
+            return CommonResponseObject.success(illegalInfoResult);
+        } else {
+            return CommonResponseObject.failure();
+        }
+    }
+
     @PostMapping("/checkVehicleIllegalInfo.do")
     public CommonResponseObject checkVehicleIllegalInfo(@RequestBody CommonParamObject params) {
 

+ 2 - 1
src/main/java/com/jkcredit/illegal/info/service/IllegalInfoService.java

@@ -2,7 +2,6 @@ package com.jkcredit.illegal.info.service;
 
 import com.jkcredit.illegal.info.model.IllegalInfoRequestParam;
 import com.jkcredit.illegal.info.model.IllegalInfoResult;
-import com.jkcredit.illegal.info.model.VehicleIllegalInfoRequestParam;
 import com.jkcredit.illegal.info.model.VehicleIllegalInfoResult;
 
 /**
@@ -19,4 +18,6 @@ public interface IllegalInfoService {
     IllegalInfoResult checkPersonIllegalInfo(String params);
 
     IllegalInfoResult checkIllegalInfoV2(IllegalInfoRequestParam requestParams);
+
+    IllegalInfoResult checkIllegalInfoV3(IllegalInfoRequestParam requestParams);
 }

+ 44 - 0
src/main/java/com/jkcredit/illegal/info/service/impl/IllegalInfoServiceImpl.java

@@ -40,6 +40,11 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
 
     private static final Log CHARGE_LOGGER = LogFactory.getLog("CHARGE_LOGGER");
 
+    /**
+     * 社会风险预警-超时返回一致
+     * @param requestParams 姓名 身份证号 流水号
+     * @return 结果
+     */
     @Override
     public IllegalInfoResult checkIllegalInfo(IllegalInfoRequestParam requestParams) {
         String body = JSON.toJSONString(requestParams);
@@ -220,6 +225,11 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
         }
     }
 
+    /**
+     * 社会风险预警-超时跳转接口
+     * @param requestParams 姓名 身份证号 流水号
+     * @return 结果
+     */
     @Override
     public IllegalInfoResult checkIllegalInfoV2(IllegalInfoRequestParam requestParams) {
         String body = JSON.toJSONString(requestParams);
@@ -260,4 +270,38 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
         }
         return illegalInfoResult;
     }
+
+    /**
+     * 社会风险预警
+     * @param requestParams 姓名 身份证号 流水号
+     * @return 结果
+     */
+    @Override
+    public IllegalInfoResult checkIllegalInfoV3(IllegalInfoRequestParam requestParams) {
+        String body = JSON.toJSONString(requestParams);
+
+        Long startTime = System.currentTimeMillis();
+        String result = OkHttpUtil.doPost(illegalInfoUrl, body, CommonConstant.PERSON_TIME_OUT);
+        log.info("调用上游接口-流水号:{}, 入参:{}, 返回:{}, 时延:{}", requestParams.getTraceId(), body, result, System.currentTimeMillis() - startTime);
+        if (StringUtils.isBlank(result)) {
+            log.info("调用上游接口-流水号:{}, 入参:{}, 请求上游失败无返回", requestParams.getTraceId(), body);
+            stringRedisTemplate.boundValueOps(CommonConstant.PERSON_ILLEGAL_INFO_TIME_OUT).increment();
+            return null;
+        }
+
+        IllegalInfoResult illegalInfoResult = JSON.toJavaObject(JSON.parseObject(result), IllegalInfoResult.class);
+        // 返回4个参数,code0表示结果正常,其他表示异常
+        if (!illegalInfoResult.getCode().equals("0")
+                || illegalInfoResult.getIsDrugs().equals("2")
+                || illegalInfoResult.getIsEscape().equals("2")
+                || illegalInfoResult.getIsPedigree().equals("2")) {
+            // 查询错误,不计费
+            CHARGE_LOGGER.info(JSON.toJSONString(new IllegalInfoChargeObject(illegalInfoResult, false, requestParams.getTraceId())));
+            stringRedisTemplate.boundValueOps(CommonConstant.PERSON_ILLEGAL_INFO_QUERY_FAILED).increment();
+        } else {
+            // 查询成功,计费
+            CHARGE_LOGGER.info(JSON.toJSONString(new IllegalInfoChargeObject(illegalInfoResult, true, requestParams.getTraceId())));
+        }
+        return illegalInfoResult;
+    }
 }