Browse Source

新增 IT服务平台 杭州市重点人员底库查询数据接口

FanQun 2 years ago
parent
commit
286df7e4ae

+ 5 - 6
pom.xml

@@ -45,12 +45,6 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>
             <scope>test</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.junit.vintage</groupId>
-                    <artifactId>junit-vintage-engine</artifactId>
-                </exclusion>
-            </exclusions>
         </dependency>
 
         <dependency>
@@ -127,6 +121,11 @@
             <artifactId>fastjson</artifactId>
             <version>1.2.80</version>
         </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>

+ 1 - 1
src/main/java/com/rshy/project/hy/aop/ExceptionAdvice.java

@@ -55,7 +55,7 @@ public class ExceptionAdvice {
 
 
     /**
-     * 通用星互动平台异常发生时调用,返回json格式
+     * BaseException异常发生时调用,返回json格式
      *
      * @param e
      * @return

+ 23 - 0
src/main/java/com/rshy/project/hy/config/properties/PctzdrydkProperties.java

@@ -0,0 +1,23 @@
+package com.rshy.project.hy.config.properties;
+
+import com.rshy.project.hy.server.dto.PctzdrydkParamDTO;
+import com.rshy.project.hy.server.param.AgentApiParam;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author: fanqun
+ * @date: 2022/5/19 20:02
+ * @description: 杭州市重点人员底库接口参数配置
+ */
+@Data
+@Accessors(chain = true)
+@Configuration
+@ConfigurationProperties(prefix = "itfw.pctzdrydk")
+public class PctzdrydkProperties extends AgentApiParam {
+
+    private PctzdrydkParamDTO body;
+    private PctzdrydkParamDTO.Query query;
+}

+ 3 - 3
src/main/java/com/rshy/project/hy/manager/RshyJkManager.java

@@ -15,15 +15,15 @@ public interface RshyJkManager {
     /**
      * 普通核验模式
      *
-     * @param rshyParam
+     * @param rshyParam 核验参数
      * @return
      */
-    Future<RshyVo> getRshyInfo(RshyParam rshyParam);
+    RshyVo getRshyInfo(RshyParam rshyParam);
 
     /**
      * 人脸快速核验模式
      *
-     * @param rshyQuickParam
+     * @param rshyQuickParam 核验参数
      * @return
      */
     RshyVo getQuickRyhyInfo(RshyQuickParam rshyQuickParam);

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

@@ -9,6 +9,7 @@ import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.EnumUtil;
 import cn.hutool.core.util.IdcardUtil;
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
 import com.rshy.project.hy.manager.RshyJkManager;
 import com.rshy.project.hy.model.constant.ItfwConstant;
 import com.rshy.project.hy.model.dto.NucleicAcidDTO;
@@ -26,16 +27,14 @@ import com.rshy.project.hy.util.ObjectUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.DependsOn;
 import org.springframework.data.redis.core.StringRedisTemplate;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.scheduling.annotation.AsyncResult;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
@@ -47,6 +46,7 @@ import java.util.stream.Collectors;
  */
 @Component
 @Slf4j
+@DependsOn("itfwServer")
 public class RshyJkManagerImpl implements RshyJkManager {
     @Autowired
     private YituFaceServer yituFaceServer;
@@ -58,12 +58,11 @@ public class RshyJkManagerImpl implements RshyJkManager {
     private StringRedisTemplate stringRedisTemplate;
 
     @Override
-    @Async("hstTaskExecutor")
-    public Future<RshyVo> getRshyInfo(RshyParam rshyParam) {
-        // timeout 转成毫秒
-        rshyParam.setTimeout(rshyParam.getTimeout() * 1000);
-        //健康码最多只能用timeout入参-2秒,不然其他的接口不够
-        int jkmTimeout = rshyParam.getTimeout() - 2000;
+    //@Async("hstTaskExecutor")
+    public RshyVo getRshyInfo(RshyParam rshyParam) {
+        // timeout 转成毫秒 这里考虑到网络传输延时等原因,减去200ms
+        rshyParam.setTimeout((int) TimeUnit.MILLISECONDS.convert(rshyParam.getTimeout(), TimeUnit.SECONDS) - 200);
+        int jkmTimeout = rshyParam.getTimeout();
         RshyVo rshyVo = new RshyVo();
         PctgkryDTO gkryDTO = new PctgkryDTO();
         ResultDTO resultDTO = new ResultDTO();
@@ -77,36 +76,42 @@ public class RshyJkManagerImpl implements RshyJkManager {
                 jkmInfo = itfwServer.getPctjkm(rshyParam.getBarCode(), rshyParam.getSfzh(), jkmTimeout);
             } catch (Exception e) {
                 log.error("查询健康码信息异常:{}", e.getMessage());
-                e.printStackTrace();
+                //e.printStackTrace();
             }
         }
         if (jkmInfo == null) {
-            return new AsyncResult<>(rshyVo.setPassStatus(PassStatusEnum.NO_CODE).setSfzh(rshyParam.getSfzh()).setXm(rshyParam.getXm()).setWarning(PassStatusEnum.NO_CODE.getDesc())
-                    .setNucleic_acid(new NucleicAcidDTO().setStatus(NucleicAcidEnum.NO_DATA.getCode()).setResults(NucleicAcidEnum.NO_DATA.getDesc())));
+            return rshyVo.setPassStatus(PassStatusEnum.NO_CODE).setSfzh(rshyParam.getSfzh()).setXm(rshyParam.getXm()).setWarning(PassStatusEnum.NO_CODE.getDesc())
+                    .setNucleic_acid(new NucleicAcidDTO().setStatus(NucleicAcidEnum.NO_DATA.getCode()).setResults(NucleicAcidEnum.NO_DATA.getDesc()));
         }
 
         rshyParam.setSfzh(jkmInfo.getId_num());
         rshyVo.setSfzh(jkmInfo.getId_num()).setXm(jkmInfo.getUser_name()).setHealthCode(jkmInfo.getColor_code_label()).setPhone(jkmInfo.getPn());
+        int jkmElapsedTime = (int) DateUtil.between(beginDate, DateTime.now(), DateUnit.MS);
+        System.out.println("健康码接口用时: " + jkmElapsedTime + "毫秒");
 
-        rshyParam.setTimeout(rshyParam.getTimeout() - (int) DateUtil.between(beginDate, DateTime.now(), DateUnit.MS) - 1000);
+        rshyParam.setTimeout(rshyParam.getTimeout() - jkmElapsedTime - 50);
+        //剩余时间不到10ms,直接返回
+        if (rshyParam.getTimeout() <= 10) {
+            return rshyVo;
+        }
 
         AtomicReference<RshyVo> quickRshyVo = new AtomicReference<>(new RshyVo());
         List<Runnable> taskList = new ArrayList<Runnable>() {
             {
                 add(() -> resultDTO.setPctymDataDTOS(itfwServer.getPctym(rshyParam.getSfzh(), rshyParam.getTimeout())));
-                add(() -> resultDTO.setPcthsResultDTO(itfwServer.getPcths(rshyParam.getSfzh(), rshyParam.getTimeout())));
-                if (StrUtil.isBlank(rshyParam.getXm())) {   // 刷健康码或者手动输入身份证号码
+                //add(() -> resultDTO.setPcthsResultDTO(itfwServer.getPcths(rshyParam.getSfzh(), rshyParam.getTimeout())));
+                if (StrUtil.isBlank(rshyParam.getXm())) {   // 刷健康码或者手动输入身份证号码,获取证件照片
                     add(() -> resultDTO.setPctzjzpResultDTO(itfwServer.getPctzjzp(rshyParam.getSfzh(), rshyParam.getTimeout())));
                 }
                 if (StrUtil.isNotBlank(rshyParam.getPhoto())) {
                     //add(() -> resultDTO.setPersonIdentifyDTO(viidServer.personIdentify(rshyParam.getPhoto(), rshyParam.getTimeout())));
-                    add(() -> quickRshyVo.set(getQuickRyhyInfo(new RshyQuickParam().setPhoto(rshyParam.getPhoto()).setTimeout(rshyParam.getTimeout()))));
+                    add(() -> quickRshyVo.set(getYitu(rshyParam.getPhoto(), (rshyParam.getTimeout()))));
                 }
             }
         };
 
         //if (rshyParam.getScreenLocked() == 0 && (barCodes == null || PassStatusEnum.GREEN_CODE.getDesc().equals(barCodes.getCOLOR_CODE_LABEL()))) {
-        //绿码人员继续进行七大类管控接口和人车核录接口比对
+        //绿码人员继续进行七大类管控接口、人车核录接口、杭州市重点人员底库数据查询接口比对
         if (PassStatusEnum.GREEN_CODE.getDesc().equals(jkmInfo.getColor_code_label())) {
             taskList.add(() -> resultDTO.getPctgkryDTO().setPctdfkDTO(itfwServer.getPctdfk(rshyParam.getSfzh(), "", rshyParam.getTimeout())));
             taskList.add(() -> resultDTO.getPctgkryDTO().setPctjsryDTO(itfwServer.getPctjsry(rshyParam.getSfzh(), rshyParam.getTimeout())));
@@ -116,6 +121,7 @@ public class RshyJkManagerImpl implements RshyJkManager {
             taskList.add(() -> resultDTO.getPctgkryDTO().setPctxdryDTO(itfwServer.getPctxdry(rshyParam.getSfzh(), "", rshyParam.getTimeout())));
             taskList.add(() -> resultDTO.getPctgkryDTO().setPctzdryDTO(itfwServer.getPctzdry(rshyParam.getSfzh(), rshyParam.getTimeout())));
             taskList.add(() -> resultDTO.setPctrchlDTO(itfwServer.getPctrchl(rshyParam.getSfzh(), rshyParam.getTimeout())));
+            taskList.add(() -> resultDTO.setPctzdrydkResultDTO(itfwServer.getPctzdrydk(rshyParam.getSfzh(), rshyParam.getTimeout())));
         }
 
         //异步流并发处理
@@ -172,14 +178,17 @@ public class RshyJkManagerImpl implements RshyJkManager {
         } else if (PassStatusEnum.YELLOW_CODE.getDesc().equalsIgnoreCase(jkmInfo.getColor_code_label())) {
             //黄码
             rshyVo.setPassStatus(PassStatusEnum.YELLOW_CODE).setKind("健康码" + PassStatusEnum.YELLOW_CODE.getDesc()).setWarning(PassStatusEnum.YELLOW_CODE.getDesc());
-        } else if (resultDTO.getPctgkryDTO().getPctztDTO() != null || StrUtil.containsAnyIgnoreCase(hcjg, "抓捕") || StrUtil.containsAnyIgnoreCase(hcjg, "拦截")) {
+        } else if (resultDTO.getPctgkryDTO().getPctztDTO() != null || StrUtil.containsAnyIgnoreCase(hcjg, RchljgEnum.CAPTURE.getDesc()) || StrUtil.containsAnyIgnoreCase(hcjg, RchljgEnum.INTERCEPT.getDesc())) {
             //在逃 或者 人车核录接口返回 抓捕或者拦截
             rshyVo.setPassStatus(PassStatusEnum.NO_PASSING).setKind(kind(resultDTO)).setWarning(warning(resultDTO));//.setWarning("在逃人员:" + resultDTO.getPctgkryDTO().getPctztDTO().getJyaq()).setKind(resultDTO.getPctgkryDTO().getPctztDTO().getZtrylxmc());
             //} else if (ObjectUtils.allFieldIsNULL(resultDTO.getPctgkryDTO()) || StrUtil.containsAnyIgnoreCase(hcjg, "通过")) {
             //    rshyVo.setPass(PassStatusEnum.NORMAL_TRAFFIC.getCode()).setDisplayMsg(PassStatusEnum.NORMAL_TRAFFIC.getDesc()).setTts(PassStatusEnum.NORMAL_TRAFFIC.getTts());
-        } else if (!ObjectUtils.allFieldIsNULL(resultDTO.getPctgkryDTO()) || StrUtil.containsAnyIgnoreCase(hcjg, "存疑")) {
+        } else if (!ObjectUtils.allFieldIsNULL(resultDTO.getPctgkryDTO()) || StrUtil.containsAnyIgnoreCase(hcjg, RchljgEnum.IN_DOUBT.getDesc())) {
             //七大类管控人员(在逃除外)和人车核录接口返回存疑人员
             rshyVo.setPassStatus(PassStatusEnum.RIGHT_WAY).setKind(kind(resultDTO)).setWarning(warning(resultDTO));
+        } else if (resultDTO.getPctzdrydkResultDTO() != null && resultDTO.getPctzdrydkResultDTO().getTotal() > 0) {
+            //杭州市重点人员底库查询接口
+            rshyVo.setPassStatus(PassStatusEnum.RIGHT_WAY).setKind(resultDTO.getPctzdrydkResultDTO().getData().get(0).getRyflList()[0]);
         } else if (quickRshyVo.get() != null && StrUtil.isNotEmpty(quickRshyVo.get().getSfzh())) {
             //依图接口
             //rshyVo = quickRshyVo.get().setTimes(times(rshyParam.getSfzh()));
@@ -196,9 +205,15 @@ public class RshyJkManagerImpl implements RshyJkManager {
             rshyVo.setPhoto(resultDTO.getPctzjzpResultDTO().getPhoto());
         }
 
-        return new AsyncResult<>(rshyVo);
+        //System.out.println(JSONObject.toJSONString(resultDTO));
+        return rshyVo;
     }
 
+    /**
+     * 组装返回的核酸信息
+     * @param pcthsResultDTO 第三方核酸接口返回数据
+     * @return
+     */
     private NucleicAcidDTO nucleicAcid(PcthsResultDTO pcthsResultDTO) {
         NucleicAcidDTO nucleicAcidDTO = new NucleicAcidDTO();
         if (pcthsResultDTO == null) {
@@ -233,17 +248,28 @@ public class RshyJkManagerImpl implements RshyJkManager {
 
     @Override
     public RshyVo getQuickRyhyInfo(RshyQuickParam rshyQuickParam) {
-        // timeout 转成毫秒
-        rshyQuickParam.setTimeout(rshyQuickParam.getTimeout() * 1000);
+        RshyVo rshyVo = getYitu(rshyQuickParam.getPhoto(), rshyQuickParam.getTimeout() * 1000);
+        log.info("快速核验响应内容:{}", JSON.toJSONString(rshyVo));
+        return rshyVo;
+    }
+
+    /**
+     * 依图接口
+     *
+     * @param photo   人脸照片
+     * @param timeout 超时时间 单位ms
+     * @return
+     */
+    private RshyVo getYitu(String photo, int timeout) {
         RshyVo rshyVo = new RshyVo().setNucleic_acid(new NucleicAcidDTO().setStatus(NucleicAcidEnum.NO_DATA.getCode()).setResults(NucleicAcidEnum.NO_DATA.getDesc()));
-        RetrievaResultVO retrievaResultVO = yituFaceServer.retrieval(rshyQuickParam.getPhoto(), rshyQuickParam.getTimeout());
+        RetrievaResultVO retrievaResultVO = yituFaceServer.retrieval(photo, timeout);
         List<RetrievalRepositoryVO> voList = Convert.toList(RetrievalRepositoryVO.class, retrievaResultVO.getResults());
         if (CollectionUtil.isEmpty(voList)) {
             return rshyVo.setPass(PassStatusEnum.NORMAL_TRAFFIC.getCode()).setDisplayMsg(PassStatusEnum.NORMAL_TRAFFIC.getDesc()).setTts(PassStatusEnum.NORMAL_TRAFFIC.getTts());
         }
 
         //查询依图人像库信息
-        RetrievaResultVO repository = yituFaceServer.repository(rshyQuickParam.getTimeout());
+        RetrievaResultVO repository = yituFaceServer.repository(timeout);
         List<RepositoryDTO> dtoList = Convert.toList(RepositoryDTO.class, repository.getResults());
         Map<String, String> stringMap = CollectionUtil.isNotEmpty(dtoList) ? dtoList.stream().collect(Collectors.toMap(RepositoryDTO::getId, RepositoryDTO::getName, (v1, v2) -> v1)) : MapUtil.newHashMap();
         RetrievalRepositoryVO repositoryVO = voList.stream().findFirst().get();
@@ -252,7 +278,6 @@ public class RshyJkManagerImpl implements RshyJkManager {
                 .setWarning(stringMap.get(repositoryVO.getRepository_id())).setDisplayMsg(RepositoryEnum.COUNTRY_LARGE.getId().equals(repositoryVO.getRepository_id()) ? PassStatusEnum.NO_PASSING.getDesc() : PassStatusEnum.RIGHT_WAY.getDesc())
                 .setTts(RepositoryEnum.COUNTRY_LARGE.getId().equals(repositoryVO.getRepository_id()) ? PassStatusEnum.NO_PASSING.getTts() : PassStatusEnum.RIGHT_WAY.getTts()).setHealthCode(StrUtil.EMPTY).setSfzh(repositoryVO.getPersonId())
                 .setXm(repositoryVO.getName()).setXb(SexEnum.codeOf(repositoryVO.getGender()).getDesc()).setMz(StrUtil.EMPTY).setPhone(StrUtil.EMPTY).setAddress(StrUtil.EMPTY);//.setPhoto(rshyQuickParam.getPhoto());
-        //log.info("快速核验响应内容:{}", JSON.toJSONString(rshyVo));
         return rshyVo;
     }
 
@@ -280,7 +305,7 @@ public class RshyJkManagerImpl implements RshyJkManager {
     /**
      * 人员类型简要概述
      *
-     * @param resultDTO
+     * @param resultDTO 所有第三方的管控人员接口返回数据
      * @return
      */
     private String kind(ResultDTO resultDTO) {
@@ -300,7 +325,7 @@ public class RshyJkManagerImpl implements RshyJkManager {
     /**
      * 警示信息
      *
-     * @param resultDTO
+     * @param resultDTO 所有第三方的管控人员接口返回数据
      * @return
      */
     private String warning(ResultDTO resultDTO) {

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

@@ -87,4 +87,10 @@ public class ItfwConstant {
      */
     public static final String PCTZJZP_KEY = "itfw:pctzjzp";
     public static final String PCTZJZP_STATUS_KEY = "itfw:pctzjzp:status";
+
+    /**
+     * 杭州市重点人员底库接口
+     */
+    public static final String PCTZDRYDK_KEY = "itfw:pctzdrydk";
+    public static final String PCTZDRYDK_STATUS_KEY = "itfw:pctzdrydk:status";
 }

+ 20 - 0
src/main/java/com/rshy/project/hy/model/enums/RchljgEnum.java

@@ -0,0 +1,20 @@
+package com.rshy.project.hy.model.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 人车核录结果
+ * <p>
+ * Created by fanqun on 2022/5/13.
+ */
+@Getter
+@AllArgsConstructor
+public enum RchljgEnum {
+    CAPTURE("抓捕"),
+    INTERCEPT("拦截"),
+    IN_DOUBT("存疑"),
+    GET_PAST("通过");
+
+    private String desc;
+}

+ 74 - 12
src/main/java/com/rshy/project/hy/server/ItfwServer.java

@@ -61,6 +61,8 @@ public class ItfwServer {
     @Autowired
     private PctzjzpProperties pctzjzpProperties;
     @Autowired
+    private PctzdrydkProperties pctzdrydkProperties;
+    @Autowired
     private StringRedisTemplate stringRedisTemplate;
 
     /**
@@ -169,8 +171,8 @@ public class ItfwServer {
             if (exceptionTimes(cacheStatusKey) > WebConstant.TIMEOUT_TIMES) {
                 stringRedisTemplate.opsForValue().set(cacheStatusKey, cacheStatusKey, WebConstant.STATUS_TIMEOUT, TimeUnit.MINUTES);
             }
-            log.error("请求重点人员服务接口超时异常:{}", e.getMessage());
-            e.printStackTrace();
+            log.error("请求重点人员服务接口异常:{}", e.getMessage());
+            //e.printStackTrace();
             return null;
         }
         log.info("重点人员服务响应信息:{}", body);
@@ -229,7 +231,7 @@ public class ItfwServer {
                 stringRedisTemplate.opsForValue().set(cacheStatusKey, cacheStatusKey, WebConstant.STATUS_TIMEOUT, TimeUnit.MINUTES);
             }
             log.error("请求人员劣迹服务接口异常:{}", e.getMessage());
-            e.printStackTrace();
+            //e.printStackTrace();
             return null;
         }
         if (StrUtil.isEmpty(body)) {
@@ -288,7 +290,7 @@ public class ItfwServer {
                 stringRedisTemplate.opsForValue().set(cacheStatusKey, cacheStatusKey, WebConstant.STATUS_TIMEOUT, TimeUnit.MINUTES);
             }
             log.error("请求执法办案服务接口异常:{}", e.getMessage());
-            e.printStackTrace();
+            //e.printStackTrace();
             return null;
         }
 
@@ -349,7 +351,7 @@ public class ItfwServer {
                 stringRedisTemplate.opsForValue().set(cacheStatusKey, cacheStatusKey, WebConstant.STATUS_TIMEOUT, TimeUnit.MINUTES);
             }
             log.error("请求打防控信息服务接口异常:{}", e.getMessage());
-            e.printStackTrace();
+            //e.printStackTrace();
             return null;
         }
         log.info("打防控信息服务响应信息:{}", body);
@@ -408,7 +410,7 @@ public class ItfwServer {
                 stringRedisTemplate.opsForValue().set(cacheStatusKey, cacheStatusKey, WebConstant.STATUS_TIMEOUT, TimeUnit.MINUTES);
             }
             log.error("请求监所人员服务接口异常:{}", e.getMessage());
-            e.printStackTrace();
+            //e.printStackTrace();
             return null;
         }
 
@@ -470,7 +472,7 @@ public class ItfwServer {
                 stringRedisTemplate.opsForValue().set(cacheStatusKey, cacheStatusKey, WebConstant.STATUS_TIMEOUT, TimeUnit.MINUTES);
             }
             log.error("请求吸毒人员服务接口异常:{}", e.getMessage());
-            e.printStackTrace();
+            //e.printStackTrace();
             return null;
         }
 
@@ -531,7 +533,7 @@ public class ItfwServer {
                 stringRedisTemplate.opsForValue().set(cacheStatusKey, cacheStatusKey, WebConstant.STATUS_TIMEOUT, TimeUnit.MINUTES);
             }
             log.error("请求前科人员服务接口异常:{}", e.getMessage());
-            e.printStackTrace();
+            //e.printStackTrace();
             return null;
         }
 
@@ -619,7 +621,7 @@ public class ItfwServer {
             }
 
             log.error("请求人车核录服务接口异常:{}", e.getMessage());
-            e.printStackTrace();
+            //e.printStackTrace();
             return null;
         }
 
@@ -680,7 +682,7 @@ public class ItfwServer {
             }
 
             log.error("浙江省疫苗注射数据服务接口异常:{}", e.getMessage());
-            e.printStackTrace();
+            //e.printStackTrace();
             return null;
         }
 
@@ -725,7 +727,7 @@ public class ItfwServer {
             body = this.baseAgentApi(properties, timeout);
         } catch (Exception e) {
             log.error("核酸接口数据服务接口异常:{}", e.getMessage());
-            e.printStackTrace();
+            //e.printStackTrace();
             return null;
         }
 
@@ -784,7 +786,7 @@ public class ItfwServer {
             }
 
             log.error("证件照片接口服务接口异常:{}", e.getMessage());
-            e.printStackTrace();
+            //e.printStackTrace();
             return null;
         }
 
@@ -806,4 +808,64 @@ public class ItfwServer {
         return pctzjzpResultDTO;
     }
 
+
+    /**
+     * 杭州市重点人员底库查询接口
+     *
+     * @param idNumber 身份证号码
+     * @param timeout  超时时间,单位ms
+     * @return
+     */
+    public PctzdrydkResultDTO getPctzdrydk(String idNumber, Integer timeout) {
+        if (StringUtils.isBlank(idNumber)) {
+            log.warn("身份证号码为空");
+            return null;
+        }
+
+        String cacheKey = idNumber + ':' + ItfwConstant.PCTZDRYDK_KEY;
+        String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey);
+        if (StrUtil.isNotEmpty(cacheValue)) {
+            log.info("杭州市重点人员底库接口服务走缓存读取,响应内容: {}", cacheValue);
+            return JSON.parseObject(cacheValue, PctzdrydkResultDTO.class);
+        }
+
+        String cacheStatusKey = ItfwConstant.PCTZDRYDK_STATUS_KEY;
+        String cacheStatusValue = stringRedisTemplate.opsForValue().get(cacheStatusKey);
+        if (StrUtil.isNotEmpty(cacheStatusValue)) {
+            return null;
+        }
+
+        PctzdrydkProperties properties = new PctzdrydkProperties();
+        BeanUtil.copyProperties(pctzdrydkProperties, properties);
+        properties.setQuery(new PctzdrydkParamDTO.Query()).setBody(new PctzdrydkParamDTO().setZjhm(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);
+
+        if (StrUtil.isEmpty(body)) {
+            return null;
+        }
+        PctzdrydkResultDTO pctzdrydkResultDTO = JSON.parseObject(body, PctzdrydkResultDTO.class);
+        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;
+        //}
+
+        return pctzdrydkResultDTO;
+    }
 }

+ 26 - 0
src/main/java/com/rshy/project/hy/server/dto/PctzdrydkParamDTO.java

@@ -0,0 +1,26 @@
+package com.rshy.project.hy.server.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 杭州市重点人员库
+ * <p>
+ * Created by fanqun on 2022/5/19.
+ */
+@Data
+@Accessors(chain = true)
+public class PctzdrydkParamDTO {
+
+    private String[] ryfl = {"110402008", "112502", "110404", "1108"};
+    private String zjhm;
+
+
+    @Data
+    public static class Query implements Serializable {
+        private int pageNum = 1;
+        private int pageSize = 10;
+    }
+}

+ 34 - 0
src/main/java/com/rshy/project/hy/server/dto/PctzdrydkResultDTO.java

@@ -0,0 +1,34 @@
+package com.rshy.project.hy.server.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 杭州市重点人员底库接口查询结果
+ * <p>
+ * Created by fanqun on 2022/5/19.
+ */
+@Data
+@Accessors(chain = true)
+public class PctzdrydkResultDTO {
+    private Integer errCode;
+    private String errMsg;
+    private Integer total;
+    private Boolean success;
+    private Boolean wrapped;
+    private List<Result> data;
+
+    @Data
+    public static class Result implements Serializable {
+        private String gxdwdm;
+        private String zrjz;
+        private String xm;
+        private String[] ryflList;
+        private String gxdwmc;
+        private String ryfl;
+        private String zjhm;
+    }
+}

+ 2 - 0
src/main/java/com/rshy/project/hy/server/dto/ResultDTO.java

@@ -39,4 +39,6 @@ public class ResultDTO {
     private PersonIdentifyDTO personIdentifyDTO;
 
     private PctzjzpResultDTO pctzjzpResultDTO;
+
+    private PctzdrydkResultDTO pctzdrydkResultDTO;
 }

+ 20 - 16
src/main/java/com/rshy/project/hy/web/controller/RshyController.java

@@ -6,10 +6,10 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.IdcardUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
+import com.rshy.project.hy.baseRe.BaseException;
 import com.rshy.project.hy.baseRe.ResultCode;
 import com.rshy.project.hy.baseRe.Ret;
 import com.rshy.project.hy.manager.RshyJkManager;
-import com.rshy.project.hy.model.enums.PassStatusEnum;
 import com.rshy.project.hy.server.param.RshyParam;
 import com.rshy.project.hy.server.param.RshyQuickParam;
 import com.rshy.project.hy.server.vo.RshyVo;
@@ -24,10 +24,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 
 /**
  * @ProjectName: rshy
@@ -51,28 +48,35 @@ public class RshyController {
     @PostMapping("getRyhyInfo")
     public Ret<RshyVo> getRyhyInfo(@RequestBody RshyParam rshyParam) {
         if (StringUtils.isNotBlank(rshyParam.getSfzh()) && !IdcardUtil.isValidCard(rshyParam.getSfzh()) && !PatternUtil.isIDNumber(rshyParam.getSfzh())) {
-            log.warn("无效的身份证号码");
-            return Ret.error(ResultCode.INVALID_ID_NUMBER);
+            log.error("无效的身份证号码");
+            //return Ret.error(ResultCode.INVALID_ID_NUMBER);
+            throw new BaseException(ResultCode.INVALID_ID_NUMBER);
         }
 
 
         if (StrUtil.isEmpty(rshyParam.getPhoto())) {
-            log.warn("缺少人员照片参数");
-            return Ret.error(ResultCode.MISSING_PARAMETER_PHOTO);
+            log.error("缺少人员照片参数");
+            //return Ret.error(ResultCode.MISSING_PARAMETER_PHOTO);
+            throw new BaseException(ResultCode.MISSING_PARAMETER_PHOTO);
         }
 
 
         DateTime time1 = DateTime.now();
         log.info("普通核验接口请求参数:{}", JSON.toJSONString(rshyParam));
-        RshyVo rshyVo = new RshyVo().setPassStatus(PassStatusEnum.NORMAL_TRAFFIC);
-        try {
-            Future<RshyVo> future = rshyJkManager.getRshyInfo(rshyParam);
-            rshyVo = future.get(rshyParam.getTimeout() * 1000 - 100, TimeUnit.MILLISECONDS);
-        } catch (InterruptedException | ExecutionException | TimeoutException e) {
-            log.error("普通核验接口异常: {}", e.getMessage());
-            e.printStackTrace();
-        }
+        //RshyVo rshyVo = new RshyVo().setPassStatus(PassStatusEnum.NORMAL_TRAFFIC);
+        //try {
+        RshyVo rshyVo = rshyJkManager.getRshyInfo(rshyParam);
+        //rshyVo = future.get(rshyParam.getTimeout(), TimeUnit.MILLISECONDS);
+        //} catch (InterruptedException | ExecutionException e) {
+        //  log.error("普通核验接口异常: {}", e.getMessage());
+        //e.printStackTrace();
+        //} catch (TimeoutException e) {
+        //  log.error("普通核验接口异常: 等待超时");
+        //} catch (Exception e) {
+        // throw new BaseException();
+        //}
         log.info("普通核验响应内容:{}", JSON.toJSONString(rshyVo));
+
         System.out.println("普通核验接口用时: " + DateUtil.between(time1, DateTime.now(), DateUnit.MS) + "毫秒\n");
         return Ret.success(rshyVo);
     }

+ 6 - 0
src/main/resources/application-dev.yml

@@ -111,6 +111,12 @@ itfw:
     apiPath: /1650782800735
     apiConfig: 1618208939768204,9d98c9d9d14d4d298f4408c0338c1af5,5cf7f9ec93964f8a86e1a819dbb54c5b.apigateway.cn-deqing-zjzfy01-zjga01.hzs.zj,HTTPS
     method: POST_BODY
+  #杭州市重点人员底库数据查询
+  pctzdrydk:
+    appCode: pctzdrydk
+    apiPath: /165275993242
+    apiConfig: 1618208939768204,9d98c9d9d14d4d298f4408c0338c1af5,5cf7f9ec93964f8a86e1a819dbb54c5b.apigateway.cn-deqing-zjzfy01-zjga01.hzs.zj,HTTPS
+    method: POST_BODY
 
 #依图人脸检索第三方服务
 face:

+ 9 - 3
src/main/resources/application-local.yml

@@ -6,10 +6,10 @@ spring:
     driver-class-name: com.mysql.cj.jdbc.Driver
     type: com.alibaba.druid.pool.DruidDataSource
   redis:
-    host: 127.0.0.1 # Redis服务器地址
+    host: ac.heishitech.com # Redis服务器地址
     database: 4 # Redis数据库索引(默认为0)
-    port: 6379 # Redis服务器连接端口
-    password: rshy # Redis服务器连接密码(默认为空)
+    port: 1633 # Redis服务器连接端口
+    password: SN0X#BG6&%Q # Redis服务器连接密码(默认为空)
     jedis:
       pool:
         #最大连接数据库连接数,设0为没有限制
@@ -107,6 +107,12 @@ itfw:
     apiPath: /1650782800735
     apiConfig: 1618208939768204,9d98c9d9d14d4d298f4408c0338c1af5,5cf7f9ec93964f8a86e1a819dbb54c5b.apigateway.cn-deqing-zjzfy01-zjga01.hzs.zj,HTTPS
     method: POST_BODY
+  #杭州市重点人员底库数据查询
+  pctzdrydk:
+    appCode: pctzdrydk
+    apiPath: /165275993242
+    apiConfig: 1618208939768204,9d98c9d9d14d4d298f4408c0338c1af5,5cf7f9ec93964f8a86e1a819dbb54c5b.apigateway.cn-deqing-zjzfy01-zjga01.hzs.zj,HTTPS
+    method: POST_BODY
 
 #依图人脸检索第三方服务
 face:

+ 6 - 0
src/main/resources/application-prod.yml

@@ -111,6 +111,12 @@ itfw:
     apiPath: /1650782800735
     apiConfig: 1618208939768204,9d98c9d9d14d4d298f4408c0338c1af5,5cf7f9ec93964f8a86e1a819dbb54c5b.apigateway.cn-deqing-zjzfy01-zjga01.hzs.zj,HTTPS
     method: POST_BODY
+  #杭州市重点人员底库数据查询
+  pctzdrydk:
+    appCode: pctzdrydk
+    apiPath: /165275993242
+    apiConfig: 1618208939768204,9d98c9d9d14d4d298f4408c0338c1af5,5cf7f9ec93964f8a86e1a819dbb54c5b.apigateway.cn-deqing-zjzfy01-zjga01.hzs.zj,HTTPS
+    method: POST_BODY
 
 #依图人脸检索第三方服务
 face: