|
@@ -869,6 +869,19 @@ public class ItfwServer {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ String cacheKey = idNumber + ':' + ItfwConstant.PCTXCM_KEY;
|
|
|
+ String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey);
|
|
|
+ if (StrUtil.isNotEmpty(cacheValue)) {
|
|
|
+ log.info("查询扫行程码记录接口服务走缓存读取,响应内容: {}", cacheValue);
|
|
|
+ return JSON.parseObject(cacheValue, PctxcmResultDTO.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ String cacheStatusKey = ItfwConstant.PCTXCM_STATUS_KEY;
|
|
|
+ String cacheStatusValue = stringRedisTemplate.opsForValue().get(cacheStatusKey);
|
|
|
+ if (StrUtil.isNotEmpty(cacheStatusValue)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
PctxcmProperties properties = new PctxcmProperties();
|
|
|
BeanUtil.copyProperties(pctxcmProperties, properties);
|
|
|
properties.setQuery(new PctxcmParamDTO().setGmsfhm(idNumber));
|
|
@@ -878,17 +891,22 @@ public class ItfwServer {
|
|
|
try {
|
|
|
body = this.baseAgentApi(properties, timeout);
|
|
|
} catch (Exception e) {
|
|
|
+ if (exceptionTimes(cacheStatusKey) > WebConstant.TIMEOUT_TIMES) {
|
|
|
+ stringRedisTemplate.opsForValue().set(cacheStatusKey, cacheStatusKey, WebConstant.STATUS_TIMEOUT, TimeUnit.MINUTES);
|
|
|
+ }
|
|
|
+
|
|
|
log.error("查询扫行程码记录接口数据服务接口异常:{}", e.getMessage());
|
|
|
//e.printStackTrace();
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
log.info("查询扫行程码记录接口数据服务响应信息:{}", body);
|
|
|
-
|
|
|
+ deleteKeys(cacheStatusKey);
|
|
|
if (StrUtil.isEmpty(body) || !StrUtil.containsAnyIgnoreCase(body, "data")) {
|
|
|
return null;
|
|
|
}
|
|
|
PctxcmResultDTO pctxcmResultDTO = JSON.parseObject(body, PctxcmResultDTO.class);
|
|
|
+ stringRedisTemplate.opsForValue().set(cacheKey, JSON.toJSONString(pctxcmResultDTO), DateUtil.endOfDay(DateUtil.date()).getTime() - DateUtil.date().getTime(), TimeUnit.MILLISECONDS);
|
|
|
// if (CollectionUtil.isEmpty(pctxcmResultDTO.getData().getResult())) {
|
|
|
// return null;
|
|
|
// }
|
|
@@ -907,6 +925,20 @@ public class ItfwServer {
|
|
|
log.warn("身份证号码为空");
|
|
|
return null;
|
|
|
}
|
|
|
+ String cacheKey = idNumber + ':' + ItfwConstant.PCTSFZ_KEY;
|
|
|
+ String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey);
|
|
|
+ if (StrUtil.isNotEmpty(cacheValue)) {
|
|
|
+ log.info("警察叔叔身份证接口服务走缓存读取,响应内容: {}", cacheValue);
|
|
|
+ PctsfzResultDTO pctsfzResultDTO = JSON.parseObject(cacheValue, PctsfzResultDTO.class);
|
|
|
+ assert pctsfzResultDTO != null;
|
|
|
+ return pctsfzResultDTO.getData().getResult().stream().max(Comparator.comparing(PctsfzResultDTO.SfzResult::getCZRKYXQXJZRQ)).orElse(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ String cacheStatusKey = ItfwConstant.PCTSFZ_STATUS_KEY;
|
|
|
+ String cacheStatusValue = stringRedisTemplate.opsForValue().get(cacheStatusKey);
|
|
|
+ if (StrUtil.isNotEmpty(cacheStatusValue)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
PctsfzProperties properties = new PctsfzProperties();
|
|
|
BeanUtil.copyProperties(pctsfzProperties, properties);
|
|
@@ -917,13 +949,17 @@ public class ItfwServer {
|
|
|
try {
|
|
|
body = this.baseAgentApi(properties, timeout);
|
|
|
} catch (Exception e) {
|
|
|
+ if (exceptionTimes(cacheStatusKey) > WebConstant.TIMEOUT_TIMES) {
|
|
|
+ stringRedisTemplate.opsForValue().set(cacheStatusKey, cacheStatusKey, WebConstant.STATUS_TIMEOUT, TimeUnit.MINUTES);
|
|
|
+ }
|
|
|
+
|
|
|
log.error("警察叔叔身份证接口数据服务接口异常:{}", e.getMessage());
|
|
|
//e.printStackTrace();
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
log.info("警察叔叔身份证接口数据服务响应信息:{}", body);
|
|
|
-
|
|
|
+ deleteKeys(cacheStatusKey);
|
|
|
if (StrUtil.isEmpty(body) || !StrUtil.containsAnyIgnoreCase(body, "data")) {
|
|
|
return null;
|
|
|
}
|
|
@@ -931,6 +967,7 @@ public class ItfwServer {
|
|
|
if (CollectionUtil.isEmpty(pctsfzResultDTO.getData().getResult())) {
|
|
|
return null;
|
|
|
}
|
|
|
+ stringRedisTemplate.opsForValue().set(cacheKey, JSON.toJSONString(pctsfzResultDTO));//, DateUtil.endOfDay(DateUtil.date()).getTime() - DateUtil.date().getTime(), TimeUnit.MILLISECONDS);
|
|
|
|
|
|
return pctsfzResultDTO.getData().getResult().stream().max(Comparator.comparing(PctsfzResultDTO.SfzResult::getCZRKYXQXJZRQ)).orElse(null);
|
|
|
}
|