|
@@ -21,7 +21,9 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
import java.util.Set;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
@@ -63,6 +65,10 @@ public class ItfwServer {
|
|
|
@Autowired
|
|
|
private PctzdrydkProperties pctzdrydkProperties;
|
|
|
@Autowired
|
|
|
+ private PctsfzProperties pctsfzProperties;
|
|
|
+ @Autowired
|
|
|
+ private PctxcmProperties pctxcmProperties;
|
|
|
+ @Autowired
|
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
|
|
|
|
/**
|
|
@@ -101,8 +107,6 @@ public class ItfwServer {
|
|
|
cacheKey = idNum + ":" + ItfwConstant.BARCODE_KEY;
|
|
|
}
|
|
|
|
|
|
- System.out.println("cacheKey: " + cacheKey);
|
|
|
-
|
|
|
String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey);
|
|
|
if (StrUtil.isNotEmpty(cacheValue)) {
|
|
|
log.info("健康码服务走缓存读取,响应内容: {}", cacheValue);
|
|
@@ -176,8 +180,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;
|
|
|
}
|
|
@@ -238,15 +243,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;
|
|
|
}
|
|
@@ -295,8 +301,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;
|
|
|
}
|
|
@@ -355,8 +362,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;
|
|
|
}
|
|
@@ -415,8 +423,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;
|
|
|
}
|
|
@@ -477,8 +486,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;
|
|
|
}
|
|
@@ -538,8 +548,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;
|
|
|
}
|
|
@@ -554,31 +565,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;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 人车核录
|
|
|
*
|
|
@@ -626,8 +612,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;
|
|
@@ -687,8 +674,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;
|
|
@@ -721,7 +709,7 @@ public class ItfwServer {
|
|
|
BeanUtil.copyProperties(pcthsProperties, properties);
|
|
|
properties.setQuery(new PcthsQueryDTO().setZjhm(idNumber));
|
|
|
log.info("核酸接口数据服务请求入参:{}", JSON.toJSONString(properties));
|
|
|
- String body = null;
|
|
|
+ String body;
|
|
|
|
|
|
try {
|
|
|
body = this.baseAgentApi(properties, timeout);
|
|
@@ -733,7 +721,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);
|
|
@@ -741,8 +729,7 @@ public class ItfwServer {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- PcthsResultDTO pcthsResultDTO = pcthsVO.getData().getResult().stream().findFirst().get();
|
|
|
- return pcthsResultDTO;
|
|
|
+ return pcthsVO.getData().getResult().stream().max(Comparator.comparing(PcthsResultDTO::getYU_CJSJ)).orElse(null);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -796,8 +783,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;
|
|
|
}
|
|
@@ -854,13 +842,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;
|
|
@@ -868,4 +856,154 @@ public class ItfwServer {
|
|
|
|
|
|
return pctzdrydkResultDTO;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询扫行程码记录接口数据服务
|
|
|
+ *
|
|
|
+ * @param idNumber
|
|
|
+ * @param timeout
|
|
|
+ */
|
|
|
+ public PctxcmResultDTO getPctxcm(String idNumber, Integer timeout) {
|
|
|
+ if (StringUtils.isBlank(idNumber)) {
|
|
|
+ log.warn("身份证号码为空");
|
|
|
+ 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));
|
|
|
+ log.info("查询扫行程码记录接口数据服务请求入参:{}", JSON.toJSONString(properties));
|
|
|
+ String body;
|
|
|
+
|
|
|
+ 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;
|
|
|
+// }
|
|
|
+
|
|
|
+ return pctxcmResultDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 警察叔叔身份证接口数据服务
|
|
|
+ *
|
|
|
+ * @param idNumber
|
|
|
+ * @param timeout
|
|
|
+ */
|
|
|
+ public PctsfzResultDTO.SfzResult getPctsfz(String idNumber, Integer timeout) {
|
|
|
+ if (StringUtils.isBlank(idNumber)) {
|
|
|
+ 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);
|
|
|
+ properties.setQuery(new PctsfzParamDTO().setCzrkgmsfhm(idNumber));
|
|
|
+ log.info("警察叔叔身份证接口数据服务请求入参:{}", JSON.toJSONString(properties));
|
|
|
+ String body;
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ PctsfzResultDTO pctsfzResultDTO = JSON.parseObject(body, PctsfzResultDTO.class);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 异常次数
|
|
|
+ *
|
|
|
+ * @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));
|
|
|
+ }
|
|
|
+
|
|
|
}
|