Browse Source

新增 IT服务平台 警察叔叔身份证查询接口 和 查询行程码记录接口

FanQun 2 years ago
parent
commit
4b99f001d1

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

@@ -172,7 +172,10 @@ public class RshyJkManagerImpl implements RshyJkManager {
 //        if (rshyVo.getNucleic_acid().getStatus() == 0) {
 //            rshyVo.setPassStatus(PassStatusEnum.NON_CONFORMANCE).setKind(PassStatusEnum.NON_CONFORMANCE.getDesc()).setWarning(PassStatusEnum.NON_CONFORMANCE.getDesc());
 //        } else
-        if (PassStatusEnum.RED_CODE.getDesc().equalsIgnoreCase(jkmInfo.getColor_code_label())) {
+        if (rshyVo.getTravel_card() != 0) {
+            //行程码到过中高风险地区
+            rshyVo.setPassStatus(PassStatusEnum.ABNORMAL_TRAVEL_CARD).setKind(PassStatusEnum.ABNORMAL_TRAVEL_CARD.getDesc());
+        } else if (PassStatusEnum.RED_CODE.getDesc().equalsIgnoreCase(jkmInfo.getColor_code_label())) {
             //红码
             rshyVo.setPass(PassStatusEnum.RED_CODE.getCode()).setTts(PassStatusEnum.RED_CODE.getTts()).setDisplayMsg(PassStatusEnum.RED_CODE.getDesc()).setWarning(PassStatusEnum.RED_CODE.getDesc()).setKind("健康码" + PassStatusEnum.RED_CODE.getDesc());
         } else if (PassStatusEnum.YELLOW_CODE.getDesc().equalsIgnoreCase(jkmInfo.getColor_code_label())) {

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

@@ -93,4 +93,16 @@ public class ItfwConstant {
      */
     public static final String PCTZDRYDK_KEY = "itfw:pctzdrydk";
     public static final String PCTZDRYDK_STATUS_KEY = "itfw:pctzdrydk:status";
+
+    /**
+     * 查询行程码记录接口
+     */
+    public static final String PCTXCM_KEY = "itfw:pctxcm";
+    public static final String PCTXCM_STATUS_KEY = "itfw:pctxcm:status";
+
+    /**
+     * 警察叔叔身份证接口
+     */
+    public static final String PCTSFZ_KEY = "itfw:pctsfz";
+    public static final String PCTSFZ_STATUS_KEY = "itfw:pctsfz:status";
 }

+ 1 - 0
src/main/java/com/rshy/project/hy/model/enums/PassStatusEnum.java

@@ -19,6 +19,7 @@ public enum PassStatusEnum {
     RED_CODE(3, "红码", "健康码异常"),
     YELLOW_CODE(3, "黄码", "健康码异常"),
     NO_HEALTH_CODE(3, "无健康码", "健康码异常"),
+    ABNORMAL_TRAVEL_CARD(3, "行程码异常", "健康码异常"),
     //人证或人码不符
     NO_MATCHED(3, "人证(码)不符", "健康码异常"),
     //不符合防疫要求

+ 39 - 2
src/main/java/com/rshy/project/hy/server/ItfwServer.java

@@ -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);
     }

+ 0 - 53
src/main/java/com/rshy/project/hy/server/dto/PctsfzResultDTO.java

@@ -36,57 +36,4 @@ public class PctsfzResultDTO {
         private String CZRKYXQXJZRQ;
     }
 
-
-    public static void main(String[] args) {
-        String string = "{\n" +
-                "    \"msg\": \"操作成功\",\n" +
-                "    \"code\": 0,\n" +
-                "    \"data\": {\n" +
-                "        \"result\": [\n" +
-                "            {\n" +
-                "                \"CZRKGMSFHM\": \"33018419950510501X\",\n" +
-                "                \"CZRKXM\": \"徐世杰\",\n" +
-                "                \"CZRKSLQFID\": \"\",\n" +
-                "                \"CZRKYXQXQSRQ\": \"20110514\",\n" +
-                "                \"FILE_URL\": \"\",\n" +
-                "                \"NAME\": \"\",\n" +
-                "                \"FZJG\": \"杭州市公安局江干分局\",\n" +
-                "                \"CZRKQFJG\": \"杭州市公安局江干分局\",\n" +
-                "                \"PICHASHCODE\": \"\",\n" +
-                "                \"CZRKCSRQ\": \"19950510\",\n" +
-                "                \"CZRKMZ\": \"汉族\",\n" +
-                "                \"CZRKXB\": \"男\",\n" +
-                "                \"CZRKSDZPID\": \"\",\n" +
-                "                \"LYBM\": \"ysk_kx.ods_zjt_slxxb\",\n" +
-                "                \"CZRKYXQXJZRQ\": \"20210514\",\n" +
-                "                \"ELC_LICENCE_RELATES\": \"\",\n" +
-                "                \"CZRKZZ\": \"杭州市江干区青荷苑10幢2单元201室\"\n" +
-                "            },\n" +
-                "            {\n" +
-                "                \"CZRKGMSFHM\": \"33018419950510501X\",\n" +
-                "                \"CZRKXM\": \"徐世杰\",\n" +
-                "                \"CZRKSLQFID\": \"\",\n" +
-                "                \"CZRKYXQXQSRQ\": \"20171227\",\n" +
-                "                \"FILE_URL\": \"\",\n" +
-                "                \"NAME\": \"\",\n" +
-                "                \"FZJG\": \"杭州市公安局江干分局\",\n" +
-                "                \"CZRKQFJG\": \"杭州市公安局江干分局\",\n" +
-                "                \"PICHASHCODE\": \"\",\n" +
-                "                \"CZRKCSRQ\": \"19950510\",\n" +
-                "                \"CZRKMZ\": \"汉族\",\n" +
-                "                \"CZRKXB\": \"男\",\n" +
-                "                \"CZRKSDZPID\": \"\",\n" +
-                "                \"LYBM\": \"ysk_kx.ods_zjt_slxxb\",\n" +
-                "                \"CZRKYXQXJZRQ\": \"20271227\",\n" +
-                "                \"ELC_LICENCE_RELATES\": \"\",\n" +
-                "                \"CZRKZZ\": \"杭州市江干区青荷苑10幢2单元201室\"\n" +
-                "            }\n" +
-                "        ],\n" +
-                "        \"excuteTime\": 14\n" +
-                "    }\n" +
-                "}";
-
-        PctsfzResultDTO pctsfzResultDTO = JSON.parseObject(string, PctsfzResultDTO.class);
-        System.out.println(JSON.toJSONString(pctsfzResultDTO));
-    }
 }

+ 0 - 14
src/main/java/com/rshy/project/hy/server/dto/PctxcmResultDTO.java

@@ -34,18 +34,4 @@ public class PctxcmResultDTO {
         private String SFDGZGFXQY_MC;
     }
 
-
-    public static void main(String[] args) {
-        String string = "{\n" +
-                "    \"msg\": \"操作成功\",\n" +
-                "    \"code\": 0,\n" +
-                "    \"data\": {\n" +
-                "        \"result\": [],\n" +
-                "        \"excuteTime\": 172\n" +
-                "    }\n" +
-                "}";
-
-        PctxcmResultDTO pctxcmResultDTO = JSON.parseObject(string, PctxcmResultDTO.class);
-        System.out.println(pctxcmResultDTO != null && pctxcmResultDTO.getData() != null && pctxcmResultDTO.getData().getResult().size() > 0 ? 1 : 0);
-    }
 }