Browse Source

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

FanQun 2 years ago
parent
commit
74e5f312bc

+ 21 - 0
src/main/java/com/rshy/project/hy/config/properties/PctsfzProperties.java

@@ -0,0 +1,21 @@
+package com.rshy.project.hy.config.properties;
+
+import com.rshy.project.hy.server.dto.PctsfzParamDTO;
+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;
+
+/**
+ * Created by fanqun on 2022/5/30.
+ */
+@Data
+@Accessors(chain = true)
+@Configuration
+@ConfigurationProperties(prefix = "itfw.pctsfz")
+public class PctsfzProperties extends AgentApiParam {
+    private ItfwApiHeader header;
+
+    private PctsfzParamDTO query;
+}

+ 21 - 0
src/main/java/com/rshy/project/hy/config/properties/PctxcmProperties.java

@@ -0,0 +1,21 @@
+package com.rshy.project.hy.config.properties;
+
+import com.rshy.project.hy.server.dto.PctxcmParamDTO;
+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;
+
+/**
+ * Created by fanqun on 2022/5/30.
+ */
+@Data
+@Accessors(chain = true)
+@Configuration
+@ConfigurationProperties(prefix = "itfw.pctxcm")
+public class PctxcmProperties extends AgentApiParam {
+    private ItfwApiHeader header;
+
+    private PctxcmParamDTO query;
+}

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

@@ -101,8 +101,10 @@ public class RshyJkManagerImpl implements RshyJkManager {
         AtomicReference<RshyVo> quickRshyVo = new AtomicReference<>(new RshyVo());
         List<Runnable> taskList = new ArrayList<Runnable>() {
             {
+                add(() -> resultDTO.setPctsfzResult(itfwServer.getPctsfz(rshyParam.getSfzh(), rshyParam.getTimeout())));
                 add(() -> resultDTO.setPctymDataDTOS(itfwServer.getPctym(rshyParam.getSfzh(), rshyParam.getTimeout())));
                 add(() -> resultDTO.setPcthsResultDTO(itfwServer.getPcths(rshyParam.getSfzh(), rshyParam.getTimeout())));
+                add(() -> resultDTO.setPctxcmResultDTO(itfwServer.getPctxcm(rshyParam.getSfzh(), rshyParam.getTimeout())));
                 if (StrUtil.isBlank(rshyParam.getXm())) {   // 刷健康码或者手动输入身份证号码,获取证件照片
                     add(() -> resultDTO.setPctzjzpResultDTO(itfwServer.getPctzjzp(rshyParam.getSfzh(), rshyParam.getTimeout())));
                 }
@@ -145,8 +147,8 @@ public class RshyJkManagerImpl implements RshyJkManager {
 
         //核酸报告
         rshyVo.setNucleic_acid(nucleicAcid(resultDTO.getPcthsResultDTO()));
-        //行程卡(暂时没接口,默认0)
-        rshyVo.setTravel_card(0);
+        //行程卡
+        rshyVo.setTravel_card(resultDTO.getPctxcmResultDTO() != null && resultDTO.getPctxcmResultDTO().getData() != null && resultDTO.getPctxcmResultDTO().getData().getResult().size() > 0 ? 1 : 0);
         //性别 从身份证号码中获取
         rshyVo.setXb(SexEnum.codeOf(IdcardUtil.getGenderByIdCard(rshyVo.getSfzh())).getDesc());
         //出生日期 从身份证号码中获取
@@ -154,9 +156,10 @@ public class RshyJkManagerImpl implements RshyJkManager {
         rshyVo.setBirthday(DateUtil.format(date, "yyyy-M-d"));
         //不是刷身份证,取地址
         if (StrUtil.isBlank(rshyParam.getXm())) {
-            if (rshyVo.getVaccine() != 0) {
-                //有疫苗信息,从接种疫苗信息里取地址
-                rshyVo.setAddress(resultDTO.getPctymDataDTOS().get(rshyVo.getVaccine() - 1).getResidentialAddress());
+            if (resultDTO.getPctsfzResult() != null) {
+                //有警察叔叔身份证接口返回数据,取地址
+                rshyVo.setAddress(resultDTO.getPctsfzResult().getCZRKZZ());
+                rshyVo.setMz(resultDTO.getPctsfzResult().getCZRKMZ());
             } else {
                 //户籍省份 从身份证号码中获取
                 rshyVo.setAddress(IdcardUtil.getProvinceByIdCard(rshyVo.getSfzh()));
@@ -166,9 +169,10 @@ public class RshyJkManagerImpl implements RshyJkManager {
         String hcjg = resultDTO.getPctrchlDTO() == null ? "" : resultDTO.getPctrchlDTO().getHcjg();
 
 
-        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.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())) {
             //红码
             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())) {
@@ -218,6 +222,7 @@ public class RshyJkManagerImpl implements RshyJkManager {
 
         if (pcthsResultDTO.getYU_CJSJ() != null) {
             DateTime parse = DateUtil.date(Long.parseLong(pcthsResultDTO.getYU_CJSJ()) * 1000);
+            log.info("最近一次核酸采样时间: {}", parse.toString());
             long betweenMs = DateUtil.betweenMs(parse, DateUtil.date());
             //72h防疫规则
             if (betweenMs > 72 * 60 * 60 * 1000) {

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

@@ -21,6 +21,7 @@ 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;
@@ -64,6 +65,10 @@ public class ItfwServer {
     @Autowired
     private PctzdrydkProperties pctzdrydkProperties;
     @Autowired
+    private PctsfzProperties pctsfzProperties;
+    @Autowired
+    private PctxcmProperties pctxcmProperties;
+    @Autowired
     private StringRedisTemplate stringRedisTemplate;
 
     /**
@@ -704,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);
@@ -724,7 +729,7 @@ public class ItfwServer {
             return null;
         }
 
-        return pcthsVO.getData().getResult().stream().findFirst().orElse(null);
+        return pcthsVO.getData().getResult().stream().max(Comparator.comparing(PcthsResultDTO::getYU_CJSJ)).orElse(null);
     }
 
 
@@ -852,6 +857,84 @@ public class ItfwServer {
         return pctzdrydkResultDTO;
     }
 
+    /**
+     * 查询扫行程码记录接口数据服务
+     *
+     * @param idNumber
+     * @param timeout
+     */
+    public PctxcmResultDTO getPctxcm(String idNumber, Integer timeout) {
+        if (StringUtils.isBlank(idNumber)) {
+            log.warn("身份证号码为空");
+            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) {
+            log.error("查询扫行程码记录接口数据服务接口异常:{}", e.getMessage());
+            //e.printStackTrace();
+            return null;
+        }
+
+        log.info("查询扫行程码记录接口数据服务响应信息:{}", body);
+
+        if (StrUtil.isEmpty(body) || !StrUtil.containsAnyIgnoreCase(body, "data")) {
+            return null;
+        }
+        PctxcmResultDTO pctxcmResultDTO = JSON.parseObject(body, PctxcmResultDTO.class);
+//        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;
+        }
+
+        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) {
+            log.error("警察叔叔身份证接口数据服务接口异常:{}", e.getMessage());
+            //e.printStackTrace();
+            return null;
+        }
+
+        log.info("警察叔叔身份证接口数据服务响应信息:{}", body);
+
+        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;
+        }
+
+        return pctsfzResultDTO.getData().getResult().stream().max(Comparator.comparing(PctsfzResultDTO.SfzResult::getCZRKYXQXJZRQ)).orElse(null);
+    }
+
     /**
      * 异常次数
      *

+ 22 - 0
src/main/java/com/rshy/project/hy/server/dto/PctsfzParamDTO.java

@@ -0,0 +1,22 @@
+package com.rshy.project.hy.server.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author: fanqun
+ * @date: 2022/5/30 23:07
+ * @description:
+ */
+@Data
+@Accessors(chain = true)
+public class PctsfzParamDTO {
+    /**
+     * 身份证号码
+     */
+    private String czrkgmsfhm;
+
+    private Integer offSet = 0;
+
+    private Integer rowCount = 10;
+}

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

@@ -0,0 +1,92 @@
+package com.rshy.project.hy.server.dto;
+
+import com.alibaba.fastjson.JSON;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Created by fanqun on 2022/5/30.
+ */
+@Data
+@Accessors(chain = true)
+public class PctsfzResultDTO {
+
+    private int code;
+    private String msg;
+
+    private SfzData data;
+
+    @Data
+    public static class SfzData implements Serializable {
+        private List<SfzResult> result;
+        private int excuteTime;
+
+    }
+
+    @Data
+    public static class SfzResult implements Serializable {
+        private String CZRKGMSFHM;
+        private String CZRKXM;
+        private String CZRKQFJG;
+        private String CZRKMZ;
+        private String CZRKZZ;
+        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));
+    }
+}

+ 24 - 0
src/main/java/com/rshy/project/hy/server/dto/PctxcmParamDTO.java

@@ -0,0 +1,24 @@
+package com.rshy.project.hy.server.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author: fanqun
+ * @date: 2022/5/30 23:07
+ * @description:
+ */
+@Data
+@Accessors(chain = true)
+public class PctxcmParamDTO {
+    /**
+     * 身份证号码
+     */
+    private String gmsfhm;
+
+    private String sfdgzgfxqy_xxdm02 = "2";
+
+    private Integer offSet = 0;
+
+    private Integer rowCount = 10;
+}

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

@@ -0,0 +1,51 @@
+package com.rshy.project.hy.server.dto;
+
+import com.alibaba.fastjson.JSON;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Created by fanqun on 2022/5/30.
+ */
+@Data
+@Accessors(chain = true)
+public class PctxcmResultDTO {
+
+    private int code;
+    private String msg;
+
+    private XcmData data;
+
+    @Data
+    public static class XcmData implements Serializable {
+        private List<XcmResult> result;
+        private int excuteTime;
+
+    }
+
+    @Data
+    public static class XcmResult implements Serializable {
+        private String XG_RQSJ;
+        private String ZJHM;
+        private String GMSFHM;
+        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);
+    }
+}

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

@@ -36,9 +36,13 @@ public class ResultDTO {
 
     private PcthsResultDTO pcthsResultDTO;
 
+    private PctxcmResultDTO pctxcmResultDTO;
+
     private PersonIdentifyDTO personIdentifyDTO;
 
     private PctzjzpResultDTO pctzjzpResultDTO;
 
     private PctzdrydkResultDTO pctzdrydkResultDTO;
+
+    private PctsfzResultDTO.SfzResult pctsfzResult;
 }

+ 19 - 1
src/main/resources/application-local.yml

@@ -95,7 +95,16 @@ itfw:
       APP_KEY: 1618208939768204
       APP_SECRET: 9d98c9d9d14d4d298f4408c0338c1af5
     appCode: pcths
-    apiPath: /165275993242
+    apiPath: /1653564781591
+    apiConfig: 1618208939768204,9d98c9d9d14d4d298f4408c0338c1af5,5cf7f9ec93964f8a86e1a819dbb54c5b.apigateway.cn-deqing-zjzfy01-zjga01.hzs.zj,HTTPS
+    method: GET
+  #查询行程码记录服务
+  pctxcm:
+    header:
+      APP_KEY: 1618208939768204
+      APP_SECRET: 9d98c9d9d14d4d298f4408c0338c1af5
+    appCode: pctxcm
+    apiPath: /1653564778214
     apiConfig: 1618208939768204,9d98c9d9d14d4d298f4408c0338c1af5,5cf7f9ec93964f8a86e1a819dbb54c5b.apigateway.cn-deqing-zjzfy01-zjga01.hzs.zj,HTTPS
     method: GET
   #证件照片服务
@@ -113,6 +122,15 @@ itfw:
     apiPath: /165275993242
     apiConfig: 1618208939768204,9d98c9d9d14d4d298f4408c0338c1af5,5cf7f9ec93964f8a86e1a819dbb54c5b.apigateway.cn-deqing-zjzfy01-zjga01.hzs.zj,HTTPS
     method: POST_BODY
+  #警察叔叔身份证服务
+  pctsfz:
+    header:
+      APP_KEY: 1618208939768204
+      APP_SECRET: 9d98c9d9d14d4d298f4408c0338c1af5
+    appCode: pctsfz
+    apiPath: /1653621114822
+    apiConfig: 1618208939768204,9d98c9d9d14d4d298f4408c0338c1af5,b534d232ec6342009c27d0d9ab6259c7.apigateway.cn-deqing-zjzfy01-zjga01.hzs.zj,HTTPS
+    method: GET
 
 #依图人脸检索第三方服务
 face:

+ 19 - 1
src/main/resources/application-prod.yml

@@ -99,7 +99,16 @@ itfw:
       APP_KEY: 1618208939768204
       APP_SECRET: 9d98c9d9d14d4d298f4408c0338c1af5
     appCode: pcths
-    apiPath: /165275993242
+    apiPath: /1653564781591
+    apiConfig: 1618208939768204,9d98c9d9d14d4d298f4408c0338c1af5,5cf7f9ec93964f8a86e1a819dbb54c5b.apigateway.cn-deqing-zjzfy01-zjga01.hzs.zj,HTTPS
+    method: GET
+  #查询行程码记录服务
+  pctxcm:
+    header:
+      APP_KEY: 1618208939768204
+      APP_SECRET: 9d98c9d9d14d4d298f4408c0338c1af5
+    appCode: pctxcm
+    apiPath: /1653564778214
     apiConfig: 1618208939768204,9d98c9d9d14d4d298f4408c0338c1af5,5cf7f9ec93964f8a86e1a819dbb54c5b.apigateway.cn-deqing-zjzfy01-zjga01.hzs.zj,HTTPS
     method: GET
   #证件照片服务
@@ -117,6 +126,15 @@ itfw:
     apiPath: /165275993242
     apiConfig: 1618208939768204,9d98c9d9d14d4d298f4408c0338c1af5,5cf7f9ec93964f8a86e1a819dbb54c5b.apigateway.cn-deqing-zjzfy01-zjga01.hzs.zj,HTTPS
     method: POST_BODY
+  #警察叔叔身份证服务
+  pctsfz:
+    header:
+      APP_KEY: 1618208939768204
+      APP_SECRET: 9d98c9d9d14d4d298f4408c0338c1af5
+    appCode: pctsfz
+    apiPath: /1653621114822
+    apiConfig: 1618208939768204,9d98c9d9d14d4d298f4408c0338c1af5,b534d232ec6342009c27d0d9ab6259c7.apigateway.cn-deqing-zjzfy01-zjga01.hzs.zj,HTTPS
+    method: GET
 
 #依图人脸检索第三方服务
 face: