|
@@ -22,6 +22,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
import java.util.Set;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
@@ -174,8 +175,9 @@ public class ItfwServer {
|
|
|
return null;
|
|
|
}
|
|
|
log.info("重点人员服务响应信息:{}", body);
|
|
|
- Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
- stringRedisTemplate.delete(keys);
|
|
|
+ deleteKeys(cacheStatusKey);
|
|
|
+ //Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
+ //stringRedisTemplate.delete(keys);
|
|
|
if (StrUtil.isEmpty(body)) {
|
|
|
return null;
|
|
|
}
|
|
@@ -236,15 +238,16 @@ public class ItfwServer {
|
|
|
return null;
|
|
|
}
|
|
|
log.info("人员劣迹服务响应信息:{}", body);
|
|
|
- Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
- stringRedisTemplate.delete(keys);
|
|
|
+ deleteKeys(cacheStatusKey);
|
|
|
+ //Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
+ //stringRedisTemplate.delete(keys);
|
|
|
PctztVO pctztVO = JSON.parseObject(body, PctztVO.class);
|
|
|
if (CollectionUtil.isEmpty(pctztVO.getData())) {
|
|
|
stringRedisTemplate.opsForValue().set(cacheKey, JSON.toJSONString(null), DateUtil.endOfDay(DateUtil.date()).getTime() - DateUtil.date().getTime(), TimeUnit.MILLISECONDS);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- PctztDTO pctztDTO = pctztVO.getData().stream().findFirst().get();
|
|
|
+ PctztDTO pctztDTO = pctztVO.getData().stream().findFirst().orElse(null);
|
|
|
stringRedisTemplate.opsForValue().set(cacheKey, JSON.toJSONString(pctztDTO), DateUtil.endOfDay(DateUtil.date()).getTime() - DateUtil.date().getTime(), TimeUnit.MILLISECONDS);
|
|
|
return pctztDTO;
|
|
|
}
|
|
@@ -293,8 +296,9 @@ public class ItfwServer {
|
|
|
}
|
|
|
|
|
|
log.info("新的执法办案服务响应信息:{}", body);
|
|
|
- Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
- stringRedisTemplate.delete(keys);
|
|
|
+ deleteKeys(cacheStatusKey);
|
|
|
+ //Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
+ //stringRedisTemplate.delete(keys);
|
|
|
if (StrUtil.isEmpty(body)) {
|
|
|
return null;
|
|
|
}
|
|
@@ -353,8 +357,9 @@ public class ItfwServer {
|
|
|
return null;
|
|
|
}
|
|
|
log.info("打防控信息服务响应信息:{}", body);
|
|
|
- Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
- stringRedisTemplate.delete(keys);
|
|
|
+ deleteKeys(cacheStatusKey);
|
|
|
+ //Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
+ //stringRedisTemplate.delete(keys);
|
|
|
if (StrUtil.isEmpty(body)) {
|
|
|
return null;
|
|
|
}
|
|
@@ -413,8 +418,9 @@ public class ItfwServer {
|
|
|
}
|
|
|
|
|
|
log.info("监所人员服务响应信息:{}", body);
|
|
|
- Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
- stringRedisTemplate.delete(keys);
|
|
|
+ deleteKeys(cacheStatusKey);
|
|
|
+ //Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
+ //stringRedisTemplate.delete(keys);
|
|
|
if (StrUtil.isEmpty(body)) {
|
|
|
return null;
|
|
|
}
|
|
@@ -475,8 +481,9 @@ public class ItfwServer {
|
|
|
}
|
|
|
|
|
|
log.info("吸毒人员服务响应信息:{}", body);
|
|
|
- Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
- stringRedisTemplate.delete(keys);
|
|
|
+ deleteKeys(cacheStatusKey);
|
|
|
+ //Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
+ //stringRedisTemplate.delete(keys);
|
|
|
if (StrUtil.isEmpty(body)) {
|
|
|
return null;
|
|
|
}
|
|
@@ -536,8 +543,9 @@ public class ItfwServer {
|
|
|
}
|
|
|
|
|
|
log.info("前科人员服务响应信息:{}", body);
|
|
|
- Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
- stringRedisTemplate.delete(keys);
|
|
|
+ deleteKeys(cacheStatusValue);
|
|
|
+ //Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
+ //stringRedisTemplate.delete(keys);
|
|
|
if (StrUtil.isEmpty(body)) {
|
|
|
return null;
|
|
|
}
|
|
@@ -552,31 +560,6 @@ public class ItfwServer {
|
|
|
return pctqkryDTO;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 异常次数
|
|
|
- *
|
|
|
- * @param key
|
|
|
- * @return
|
|
|
- */
|
|
|
- private Integer exceptionTimes(String key) {
|
|
|
- String cacheKey = key + ":times";
|
|
|
- int times = 1;
|
|
|
- String timesStr = stringRedisTemplate.opsForValue().get(cacheKey);
|
|
|
- if (timesStr == null) {
|
|
|
- stringRedisTemplate.opsForValue().set(cacheKey, String.valueOf(times));//,DateUtil.endOfDay(DateUtil.date()).getTime() - DateUtil.date().getTime(), TimeUnit.MILLISECONDS);
|
|
|
- } else {
|
|
|
- times = Integer.parseInt(timesStr) + 1;
|
|
|
- if (times > WebConstant.TIMEOUT_TIMES) {
|
|
|
- Set<String> keys = stringRedisTemplate.keys(cacheKey + "*");
|
|
|
- stringRedisTemplate.delete(keys);
|
|
|
- } else {
|
|
|
- stringRedisTemplate.opsForValue().increment(cacheKey);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return times;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 人车核录
|
|
|
*
|
|
@@ -624,8 +607,9 @@ public class ItfwServer {
|
|
|
}
|
|
|
|
|
|
log.info("人车核录服务响应信息:{}", body);
|
|
|
- Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
- stringRedisTemplate.delete(keys);
|
|
|
+ deleteKeys(cacheStatusKey);
|
|
|
+ //Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
+ //stringRedisTemplate.delete(keys);
|
|
|
|
|
|
if (StrUtil.isEmpty(body) || !StrUtil.containsAnyIgnoreCase(body, "datas")) {
|
|
|
return null;
|
|
@@ -685,8 +669,9 @@ public class ItfwServer {
|
|
|
}
|
|
|
|
|
|
log.info("浙江省疫苗注射数据服务响应信息:{}", body);
|
|
|
- Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
- stringRedisTemplate.delete(keys);
|
|
|
+ deleteKeys(cacheStatusKey);
|
|
|
+ //Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
+ //stringRedisTemplate.delete(keys);
|
|
|
|
|
|
if (StrUtil.isEmpty(body) || !StrUtil.containsAnyIgnoreCase(body, "datas")) {
|
|
|
return null;
|
|
@@ -731,7 +716,7 @@ public class ItfwServer {
|
|
|
|
|
|
log.info("核酸接口数据服务响应信息:{}", body);
|
|
|
|
|
|
- if (StrUtil.isEmpty(body) || !StrUtil.containsAnyIgnoreCase(body, "datas")) {
|
|
|
+ if (StrUtil.isEmpty(body) || !StrUtil.containsAnyIgnoreCase(body, "data")) {
|
|
|
return null;
|
|
|
}
|
|
|
PcthsVO pcthsVO = JSON.parseObject(body, PcthsVO.class);
|
|
@@ -739,8 +724,7 @@ public class ItfwServer {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- PcthsResultDTO pcthsResultDTO = pcthsVO.getData().getResult().stream().findFirst().get();
|
|
|
- return pcthsResultDTO;
|
|
|
+ return pcthsVO.getData().getResult().stream().findFirst().orElse(null);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -794,8 +778,9 @@ public class ItfwServer {
|
|
|
return null;
|
|
|
}
|
|
|
PctzjzpResultDTO pctzjzpResultDTO = JSON.parseObject(body, PctzjzpResultDTO.class);
|
|
|
- Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
- stringRedisTemplate.delete(keys);
|
|
|
+ deleteKeys(cacheStatusKey);
|
|
|
+ //Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
+ //stringRedisTemplate.delete(keys);
|
|
|
if (Integer.parseInt(pctzjzpResultDTO.getStatus()) != 200) {
|
|
|
return null;
|
|
|
}
|
|
@@ -852,13 +837,13 @@ public class ItfwServer {
|
|
|
}
|
|
|
|
|
|
log.info("杭州市重点人员底库数据查询接口服务响应信息:{}", body);
|
|
|
-
|
|
|
+ deleteKeys(cacheStatusKey);
|
|
|
if (StrUtil.isEmpty(body)) {
|
|
|
return null;
|
|
|
}
|
|
|
PctzdrydkResultDTO pctzdrydkResultDTO = JSON.parseObject(body, PctzdrydkResultDTO.class);
|
|
|
- Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
- stringRedisTemplate.delete(keys);
|
|
|
+ //Set<String> keys = stringRedisTemplate.keys(cacheStatusKey + "*");
|
|
|
+ //stringRedisTemplate.delete(keys);
|
|
|
stringRedisTemplate.opsForValue().set(cacheKey, JSON.toJSONString(pctzdrydkResultDTO), DateUtil.endOfDay(DateUtil.date()).getTime() - DateUtil.date().getTime(), TimeUnit.MILLISECONDS);
|
|
|
//if (pctzdrydkResultDTO.getErrCode() == 0 && pctzdrydkResultDTO.getTotal() == 0) {
|
|
|
// return null;
|
|
@@ -866,4 +851,39 @@ public class ItfwServer {
|
|
|
|
|
|
return pctzdrydkResultDTO;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 异常次数
|
|
|
+ *
|
|
|
+ * @param key
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Integer exceptionTimes(String key) {
|
|
|
+ String cacheKey = key + ":times";
|
|
|
+ int times = 1;
|
|
|
+ String timesStr = stringRedisTemplate.opsForValue().get(cacheKey);
|
|
|
+ if (timesStr == null) {
|
|
|
+ stringRedisTemplate.opsForValue().set(cacheKey, String.valueOf(times));//,DateUtil.endOfDay(DateUtil.date()).getTime() - DateUtil.date().getTime(), TimeUnit.MILLISECONDS);
|
|
|
+ } else {
|
|
|
+ times = Integer.parseInt(timesStr) + 1;
|
|
|
+ if (times > WebConstant.TIMEOUT_TIMES) {
|
|
|
+ deleteKeys(cacheKey);
|
|
|
+ } else {
|
|
|
+ stringRedisTemplate.opsForValue().increment(cacheKey);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return times;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除redis 缓存
|
|
|
+ *
|
|
|
+ * @param key
|
|
|
+ */
|
|
|
+ private void deleteKeys(String key) {
|
|
|
+ Set<String> keys = stringRedisTemplate.keys(key + "*");
|
|
|
+ Optional.ofNullable(keys).ifPresent(k -> stringRedisTemplate.delete(k));
|
|
|
+ }
|
|
|
+
|
|
|
}
|