Browse Source

刷身份证调健康码接口

FanQun 2 years ago
parent
commit
753df727e3

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

@@ -58,16 +58,16 @@ public class RshyJkManagerImpl implements RshyJkManager {
     @Override
     public RshyVo getRshyInfo(RshyParam rshyParam) {
         // timeout 转成毫秒
-        rshyParam.setTimeout((rshyParam.getTimeout() - 1) * 1000);
+        rshyParam.setTimeout(rshyParam.getTimeout() * 1000);
         log.info("普通核验接口请求参数:{}", JSON.toJSONString(rshyParam));
         RshyVo rshyVo = new RshyVo();
         ResultDTO resultDTO = new ResultDTO();
-        if (StringUtils.isNotBlank(rshyParam.getBarCode())) {
+        if (StringUtils.isNotBlank(rshyParam.getBarCode()) || StringUtils.isNotBlank(rshyParam.getSfzh())) {
             DateTime beginDate = DateTime.now();
             PctjkmInfoDTO barCodes = null;
             try {
                 //查询健康码信息
-                barCodes = itfwServer.getPctjkm(rshyParam.getBarCode(), rshyParam.getTimeout());
+                barCodes = itfwServer.getPctjkm(rshyParam.getBarCode(), rshyParam.getSfzh(), rshyParam.getTimeout());
             } catch (Exception e) {
                 log.error("查询健康码信息异常:{}", e.getMessage());
                 e.printStackTrace();
@@ -178,14 +178,14 @@ public class RshyJkManagerImpl implements RshyJkManager {
      * @return
      */
     private Integer times(String idNumber) {
-        String cacheKey = new StringBuilder().append(ItfwConstant.TIMES_KEY).append(idNumber).toString();
-        Integer times = 1;
+        String cacheKey = idNumber + ":" + ItfwConstant.TIMES_KEY;
+        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;
             stringRedisTemplate.opsForValue().increment(cacheKey);
         }
 

+ 10 - 10
src/main/java/com/rshy/project/hy/model/constant/ItfwConstant.java

@@ -10,17 +10,17 @@ public class ItfwConstant {
     /**
      * 今日进站次数
      */
-    public static final String TIMES_KEY = "itfw:times:";
+    public static final String TIMES_KEY = "itfw:times";
 
     /**
      * 健康码信息缓存标识
      */
-    public static final String BARCODE_KEY = "itfw:barcode:";
+    public static final String BARCODE_KEY = "itfw:barcode";
 
     /**
      * 重点人员缓存标识
      */
-    public static final String PCTZDRY_KEY = "itfw:pctzdry:";
+    public static final String PCTZDRY_KEY = "itfw:pctzdry";
 
     /**
      * 重点人员接口访问状态标识
@@ -30,48 +30,48 @@ public class ItfwConstant {
     /**
      * 人员劣迹缓存标识
      */
-    public static final String PCTZT_KEY = "itfw:pctzt:";
+    public static final String PCTZT_KEY = "itfw:pctzt";
 
     public static final String PCTZT_STATUS_KEY = "itfw:pctzt:status";
 
     /**
      * 新的执法办案缓存标识
      */
-    public static final String PCTZFBA_KEY = "itfw:pctzfba:";
+    public static final String PCTZFBA_KEY = "itfw:pctzfba";
 
     public static final String PCTZFBA_STATUS_KEY = "itfw:pctzfba:status";
 
     /**
      * 打防控信息缓存标识
      */
-    public static final String PCTDFK_KEY = "itfw:pctdfk:";
+    public static final String PCTDFK_KEY = "itfw:pctdfk";
 
     public static final String PCTDFK_STATUS_KEY = "itfw:pctdfk:status";
 
     /**
      * 监所人员缓存标识
      */
-    public static final String PCTJSRY_KEY = "itfw:pctjsry:";
+    public static final String PCTJSRY_KEY = "itfw:pctjsry";
 
     public static final String PCTJSRY_STATUS_KEY = "itfw:pctjsry:status";
 
     /**
      * 吸毒人员缓存标识
      */
-    public static final String PCTXDRY_KEY = "itfw:pctxdry:";
+    public static final String PCTXDRY_KEY = "itfw:pctxdry";
 
     public static final String PCTXDRY_STATUS_KEY = "itfw:pctxdry:status";
 
     /**
      * 前科人员缓存标识
      */
-    public static final String PCTQKRY_KEY = "itfw:pctqkry:";
+    public static final String PCTQKRY_KEY = "itfw:pctqkry";
     public static final String PCTQKRY_STATUS_KEY = "itfw:pctqkry:status";
 
     /**
      * 人车核录
      */
-    public static final String PCTRCHL_KEY = "itfw:pctrchl:";
+    public static final String PCTRCHL_KEY = "itfw:pctrchl";
 
     public static final String PCTRCHL_STATUS_KEY = "itfw:pctrchl:status";
 }

+ 19 - 6
src/main/java/com/rshy/project/hy/server/ItfwServer.java

@@ -67,18 +67,29 @@ public class ItfwServer {
 
     /**
      * 健康码服务
+     * <p>
+     * 健康码和身份证号码不能都为空
      *
      * @param barCode 健康码
+     * @param idNum   身份证号码
      * @param timeout 超时时间 秒
      * @return
      */
-    public PctjkmInfoDTO getPctjkm(String barCode, Integer timeout) {
-        if (StringUtils.isBlank(barCode)) {
-            log.warn("barCode为空");
+    public PctjkmInfoDTO getPctjkm(String barCode, String idNum, Integer timeout) {
+
+        if (StringUtils.isBlank(barCode) && StringUtils.isBlank(idNum)) {
+            log.warn("barCode和身份证号码都为空");
             return null;
         }
 
-        String cacheKey = new StringBuilder().append(ItfwConstant.BARCODE_KEY).append(barCode).toString();
+
+        String cacheKey;
+        if (StringUtils.isNotBlank(barCode)) {
+            cacheKey = ItfwConstant.BARCODE_KEY + ":" + barCode;
+        } else {
+            cacheKey = idNum + ":" + ItfwConstant.BARCODE_KEY;
+        }
+
         String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey);
         if (StrUtil.isNotEmpty(cacheValue)) {
             log.info("健康码服务走缓存读取,响应内容: {}", cacheValue);
@@ -87,7 +98,8 @@ public class ItfwServer {
 
         PctjkmProperties properties = new PctjkmProperties();
         BeanUtil.copyProperties(pctjkmProperties, properties);
-        properties.setQuery(new BarcodeQueryDTO().setBar_code(barCode));
+        properties.setQuery(new BarcodeQueryDTO().setBar_code(StrUtil.isNotEmpty(barCode) ? barCode : null).setId_num(StrUtil.isNotEmpty(idNum) ? idNum : null));
+
         log.info("健康码请求第三方接口入参信息:{}", JSON.toJSONString(properties));
         String body = this.baseAgentApi(properties, timeout);
         log.info("请求健康码服务响应信息:{}", body);
@@ -101,7 +113,8 @@ public class ItfwServer {
         }
 
         PctjkmInfoDTO pctjkmInfoDTO = pctjkmVO.getData().getResult().stream().findFirst().get();
-        stringRedisTemplate.opsForValue().set(cacheKey, JSON.toJSONString(pctjkmInfoDTO), DateUtil.endOfDay(DateUtil.date()).getTime() - DateUtil.date().getTime(), TimeUnit.MILLISECONDS);
+        stringRedisTemplate.opsForValue().set(ItfwConstant.BARCODE_KEY + ":" + pctjkmInfoDTO.getBar_code(), JSON.toJSONString(pctjkmInfoDTO), DateUtil.endOfDay(DateUtil.date()).getTime() - DateUtil.date().getTime(), TimeUnit.MILLISECONDS);
+        stringRedisTemplate.opsForValue().set(pctjkmInfoDTO.getId_num() + ":" + ItfwConstant.BARCODE_KEY, JSON.toJSONString(pctjkmInfoDTO), DateUtil.endOfDay(DateUtil.date()).getTime() - DateUtil.date().getTime(), TimeUnit.MILLISECONDS);
         return pctjkmInfoDTO;
     }
 

+ 2 - 16
src/main/java/com/rshy/project/hy/server/dto/BarcodeQueryDTO.java

@@ -15,25 +15,11 @@ public class BarcodeQueryDTO {
      * 健康码
      */
     private String bar_code;
-
     /**
-     * 身份证
+     * 身份证号码
      */
-    private String zjhm;
-
-    private String bar_zjhm;
-
-    private String ajbh;
-
-    private String zjid;
-
-    private String xm;
-
-    private String zjzldm;
-
-    private String zjzl;
+    private String id_num;
 
-    private String chrq;
 
     private Integer offSet = 0;
 

+ 5 - 0
src/main/java/com/rshy/project/hy/server/dto/PctjkmInfoDTO.java

@@ -11,6 +11,11 @@ import lombok.experimental.Accessors;
 @Data
 @Accessors(chain = true)
 public class PctjkmInfoDTO {
+    /**
+     * barCode
+     */
+    private String bar_code;
+
     /**
      * 身份证
      */