FanQun 2 лет назад
Родитель
Сommit
52837fdf79

+ 9 - 4
src/main/java/com/rshy/project/hy/manager/impl/RshyJkManagerImpl.java

@@ -2,6 +2,8 @@ package com.rshy.project.hy.manager.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.convert.Convert;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.IdcardUtil;
@@ -55,11 +57,13 @@ public class RshyJkManagerImpl implements RshyJkManager {
 
     @Override
     public RshyVo getRshyInfo(RshyParam rshyParam) {
-        rshyParam.setTimeout(rshyParam.getTimeout() - 1);
+        // timeout 转成毫秒
+        rshyParam.setTimeout((rshyParam.getTimeout() - 1) * 1000);
         log.info("普通核验接口请求参数:{}", JSON.toJSONString(rshyParam));
         RshyVo rshyVo = new RshyVo();
         ResultDTO resultDTO = new ResultDTO();
         if (StringUtils.isNotBlank(rshyParam.getBarCode())) {
+            DateTime beginDate = DateTime.now();
             PctjkmInfoDTO barCodes = null;
             try {
                 //查询健康码信息
@@ -75,8 +79,8 @@ public class RshyJkManagerImpl implements RshyJkManager {
 
             rshyParam.setSfzh(barCodes.getId_num());
             rshyParam.setXm(barCodes.getUser_name());
-            String codeLabel = barCodes != null ? barCodes.getCOLOR_CODE_LABEL() : null;
-            String phone = barCodes != null ? barCodes.getPn() : null;
+            String codeLabel = barCodes.getCOLOR_CODE_LABEL();
+            String phone = barCodes.getPn();
             rshyVo.setXm(rshyParam.getXm()).setSfzh(rshyParam.getSfzh()).setHealthCode(codeLabel).setPhone(phone);
 
             if (PassStatusEnum.RED_CODE.getDesc().equalsIgnoreCase(barCodes.getCOLOR_CODE_LABEL())) {
@@ -88,6 +92,7 @@ public class RshyJkManagerImpl implements RshyJkManager {
             } else {
                 rshyVo.setTts(barCodes.getCOLOR_CODE_LABEL());
             }
+            rshyParam.setTimeout((int) (rshyParam.getTimeout() - DateUtil.between(beginDate, DateTime.now(), DateUnit.MS)));
         }
 
         List<Runnable> taskList = new ArrayList<Runnable>() {
@@ -108,7 +113,7 @@ public class RshyJkManagerImpl implements RshyJkManager {
             try {
                 v.run();
             } catch (Exception e) {
-                log.error("异常信息:{} {}", e.getMessage(), e.getLocalizedMessage());
+                log.error("异常信息:{}", e.getMessage());
                 e.printStackTrace();
             }
         });

+ 5 - 4
src/main/java/com/rshy/project/hy/model/enums/SexEnum.java

@@ -16,16 +16,17 @@ public enum SexEnum {
      */
     MAN(1, "男"),
     WOMAN(2, "女"),
-    UNKNOWN(3, "未知");
+    UNKNOWN(3, "未知"),
+    FEMALE(0, "女");
 
     private Integer code;
 
     private String desc;
 
 
-    public static SexEnum codeOf(Integer code){
-        for(SexEnum sexEnum : SexEnum.values()){
-            if(sexEnum.getCode().equals(code)){
+    public static SexEnum codeOf(Integer code) {
+        for (SexEnum sexEnum : SexEnum.values()) {
+            if (sexEnum.getCode().equals(code)) {
                 return sexEnum;
             }
         }

+ 14 - 13
src/main/java/com/rshy/project/hy/server/ItfwServer.java

@@ -62,7 +62,7 @@ public class ItfwServer {
      * @return
      */
     public String baseAgentApi(AgentApiParam param, Integer timeout) {
-        return HttpUtil.post(baseUrl, JSON.toJSONString(param), timeout * 1000);
+        return HttpUtil.post(baseUrl, JSON.toJSONString(param), timeout);
     }
 
     /**
@@ -88,7 +88,7 @@ public class ItfwServer {
         PctjkmProperties properties = new PctjkmProperties();
         BeanUtil.copyProperties(pctjkmProperties, properties);
         properties.setQuery(new BarcodeQueryDTO().setBar_code(barCode));
-        log.info("健康码请求第三方健康码入参信息:{}", JSON.toJSONString(properties));
+        log.info("健康码请求第三方接口入参信息:{}", JSON.toJSONString(properties));
         String body = this.baseAgentApi(properties, timeout);
         log.info("请求健康码服务响应信息:{}", body);
         if (StrUtil.isEmpty(body)) {
@@ -117,7 +117,7 @@ public class ItfwServer {
             return null;
         }
 
-        String cacheKey = new StringBuilder().append(idNumber).append(ItfwConstant.PCTZDRY_KEY).toString();
+        String cacheKey = idNumber + ':' + ItfwConstant.PCTZDRY_KEY;
         String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey);
         if (StrUtil.isNotEmpty(cacheValue)) {
             log.info("重点人员服务走缓存读取,响应内容: {}", cacheValue);
@@ -174,7 +174,7 @@ public class ItfwServer {
             return null;
         }
 
-        String cacheKey = new StringBuilder().append(idNumber).append(ItfwConstant.PCTZT_KEY).toString();
+        String cacheKey = idNumber + ':' + ItfwConstant.PCTZT_KEY;
         String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey);
         if (StrUtil.isNotEmpty(cacheValue)) {
             log.info("人员劣迹服务走缓存读取,响应内容: {}", cacheValue);
@@ -232,7 +232,7 @@ public class ItfwServer {
             return null;
         }
 
-        String cacheKey = new StringBuilder().append(idNumber).append(ItfwConstant.PCTZFBA_KEY).toString();
+        String cacheKey = idNumber + ':' + ItfwConstant.PCTZFBA_KEY;
         String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey);
         if (StrUtil.isNotEmpty(cacheValue)) {
             log.info("执法办案服务走缓存读取,响应内容: {}", cacheValue);
@@ -293,7 +293,7 @@ public class ItfwServer {
             return null;
         }
 
-        String cacheKey = new StringBuilder().append(idNumber).append(ItfwConstant.PCTDFK_KEY).toString();
+        String cacheKey = idNumber + ':' + ItfwConstant.PCTDFK_KEY;
         String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey);
         if (StrUtil.isNotEmpty(cacheValue)) {
             log.info("打防控信息服务走缓存读取,响应内容: {}", cacheValue);
@@ -350,7 +350,7 @@ public class ItfwServer {
             return null;
         }
 
-        String cacheKey = new StringBuilder().append(idNumber).append(ItfwConstant.PCTJSRY_KEY).toString();
+        String cacheKey = idNumber + ':' + ItfwConstant.PCTJSRY_KEY;
         String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey);
         if (StrUtil.isNotEmpty(cacheValue)) {
             log.info("监所人员服务走缓存读取,响应内容: {}", cacheValue);
@@ -410,7 +410,7 @@ public class ItfwServer {
             return null;
         }
 
-        String cacheKey = new StringBuilder().append(idNumber).append(ItfwConstant.PCTXDRY_KEY).toString();
+        String cacheKey = idNumber + ':' + ItfwConstant.PCTXDRY_KEY;
         String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey);
         if (StrUtil.isNotEmpty(cacheValue)) {
             log.info("吸毒人员服务走缓存读取,响应内容: {}", cacheValue);
@@ -471,7 +471,7 @@ public class ItfwServer {
             return null;
         }
 
-        String cacheKey = new StringBuilder().append(idNumber).append(ItfwConstant.PCTQKRY_KEY).toString();
+        String cacheKey = idNumber + ':' + ItfwConstant.PCTQKRY_KEY;
         String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey);
         if (StrUtil.isNotEmpty(cacheValue)) {
             log.info("前科人员服务走缓存读取,响应内容: {}", cacheValue);
@@ -525,13 +525,13 @@ public class ItfwServer {
      * @return
      */
     private Integer times(String key) {
-        String cacheKey = new StringBuilder().append(key).append(":times").toString();
-        Integer times = 1;
+        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.valueOf(timesStr) + 1;
+            times = Integer.parseInt(timesStr) + 1;
             if (times > WebConstant.TIMEOUT_TIMES) {
                 Set<String> keys = stringRedisTemplate.keys(cacheKey + "*");
                 stringRedisTemplate.delete(keys);
@@ -554,7 +554,7 @@ public class ItfwServer {
             return null;
         }
 
-        String cacheKey = new StringBuilder().append(idNumber).append(ItfwConstant.PCTRCHL_KEY).toString();
+        String cacheKey = idNumber + ':' + ItfwConstant.PCTRCHL_KEY;
         String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey);
         if (StrUtil.isNotEmpty(cacheValue)) {
             log.info("人车核录服务走缓存读取,响应内容: {}", cacheValue);
@@ -605,4 +605,5 @@ public class ItfwServer {
         stringRedisTemplate.opsForValue().set(cacheKey, JSON.toJSONString(pctrchlDTO), DateUtil.endOfDay(DateUtil.date()).getTime() - DateUtil.date().getTime(), TimeUnit.MILLISECONDS);
         return pctrchlDTO;
     }
+
 }