|
@@ -2,6 +2,7 @@ package com.jkcredit.illegal.info.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.jkcredit.illegal.info.constant.CommonConstant;
|
|
|
import com.jkcredit.illegal.info.model.*;
|
|
|
import com.jkcredit.illegal.info.service.IllegalInfoService;
|
|
|
import com.jkcredit.illegal.info.util.AesUtil;
|
|
@@ -11,7 +12,9 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.logging.Log;
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
/**
|
|
@@ -29,6 +32,9 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
|
|
|
private String vehicleIllegalInfoUrl;
|
|
|
@Value("${illegalInfo.decodeKey}")
|
|
|
private String decodeKey;
|
|
|
+ @Autowired
|
|
|
+ StringRedisTemplate stringRedisTemplate;
|
|
|
+
|
|
|
private static final Log CHARGE_LOGGER = LogFactory.getLog("CHARGE_LOGGER");
|
|
|
@Override
|
|
|
public IllegalInfoResult checkIllegalInfo(IllegalInfoRequestParam requestParams) {
|
|
@@ -39,8 +45,10 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
|
|
|
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")
|
|
@@ -49,6 +57,7 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
|
|
|
|| 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())));
|
|
@@ -72,6 +81,7 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
|
|
|
log.info("调用上游接口-流水号:{}, 入参:{}, 返回:{}, 时延:{}", requestParam.getTraceId(), body, result, System.currentTimeMillis() - startTime);
|
|
|
if (StringUtils.isBlank(result)) {
|
|
|
log.info("调用上游接口-流水号:{}, 入参:{}, 请求上游失败无返回", requestParam.getTraceId(), body);
|
|
|
+ stringRedisTemplate.boundValueOps(CommonConstant.VEHICLE_ILLEGAL_INFO_TIME_OUT).increment();
|
|
|
return null;
|
|
|
}
|
|
|
VehicleIllegalInfoResult vehicleIllegalInfoResult = JSON.toJavaObject(JSON.parseObject(result), VehicleIllegalInfoResult.class);
|
|
@@ -80,6 +90,7 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
|
|
|
|| vehicleIllegalInfoResult.getResult().equals("2")) {
|
|
|
// 查询错误,不计费
|
|
|
CHARGE_LOGGER.info(JSON.toJSONString(new VehicleIllegalInfoChargeObject(vehicleIllegalInfoResult, false, requestParam.getTraceId())));
|
|
|
+ stringRedisTemplate.boundValueOps(CommonConstant.VEHICLE_ILLEGAL_INFO_QUERY_FAILED).increment();
|
|
|
} else {
|
|
|
// 查询成功,计费
|
|
|
CHARGE_LOGGER.info(JSON.toJSONString(new VehicleIllegalInfoChargeObject(vehicleIllegalInfoResult, true, requestParam.getTraceId())));
|
|
@@ -114,6 +125,7 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
|
|
|
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);
|
|
@@ -124,6 +136,7 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
|
|
|
|| 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())));
|