4 Commits d40ea0e0a4 ... 78cef4336a

Author SHA1 Message Date
  FanQun 78cef4336a 身份信息持久化,保存证件照片 2 years ago
  FanQun 64f656f1b1 身份信息持久化,保存证件照片 2 years ago
  FanQun 658e49a4a5 锁屏状态下,不进行盘查接口比对 2 years ago
  FanQun bb422f4150 增加普通核验接口请求的登录信息字段 2 years ago

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

@@ -10,6 +10,7 @@ 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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.rshy.project.hy.manager.RshyJkManager;
 import com.rshy.project.hy.model.constant.ItfwConstant;
 import com.rshy.project.hy.model.dto.NucleicAcidDTO;
@@ -77,7 +78,7 @@ public class RshyJkManagerImpl implements RshyJkManager {
     public Future<RshyVo> getRshyInfo(RshyParam rshyParam) {
         // timeout 转成毫秒 这里考虑到网络传输延时等原因,减去300ms
         rshyParam.setTimeout((int) TimeUnit.MILLISECONDS.convert(rshyParam.getTimeout(), TimeUnit.SECONDS));
-        int jkmTimeout = rshyParam.getTimeout() - 300;
+        int jkmTimeout = rshyParam.getTimeout() - 500;
         RshyVo rshyVo = new RshyVo();
         PctgkryDTO gkryDTO = new PctgkryDTO();
         ResultDTO resultDTO = new ResultDTO();
@@ -103,19 +104,25 @@ public class RshyJkManagerImpl implements RshyJkManager {
         if (jkmInfo != null) {
             rshyParam.setSfzh(jkmInfo.getId_num());
             rshyVo.setSfzh(jkmInfo.getId_num()).setXm(jkmInfo.getUser_name()).setHealthCode(jkmInfo.getColor_code_label()).setPhone(jkmInfo.getPn());
-            saveIdentity(rshyParam.getBarCode(), rshyVo);
             resultDTO.setPctjkmInfoDTO(jkmInfo);
+            if (rshyParam.getIdentity() == null) {
+                saveBarcode2DB(jkmInfo.getBar_code(), jkmInfo.getId_num());
+            }
         } else {
             rshyVo.setSfzh(rshyParam.getSfzh());
             if (rshyParam.getIdentity() != null) {
                 rshyVo.setXm(rshyParam.getIdentity().getName());
                 rshyVo.setPhone(rshyParam.getIdentity().getPhone());
+                rshyVo.setAddress(rshyParam.getIdentity().getAddress());
+                rshyVo.setPhoto(rshyParam.getIdentity().getPhoto());
+            } else {
+                saveBarcode2DB(StrUtil.EMPTY, rshyParam.getSfzh());
             }
         }
         int jkmUsedTime = (int) DateUtil.between(beginDate, DateTime.now(), DateUnit.MS);
         System.out.println("健康码接口用时: " + jkmUsedTime + "毫秒");
 
-        rshyParam.setTimeout(rshyParam.getTimeout() - jkmUsedTime - 400);
+        rshyParam.setTimeout(rshyParam.getTimeout() - jkmUsedTime - 600);
         //剩余时间不到50ms,直接返回
         if (rshyParam.getTimeout() <= 50) {
             return new AsyncResult<>(rshyVo);
@@ -135,27 +142,30 @@ public class RshyJkManagerImpl implements RshyJkManager {
                 add(() -> resultDTO.setPctxcmResultDTO(itfwServer.getPctxcm(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(getYitu(rshyParam.getPhoto(), (rshyParam.getTimeout()))));
+                } else {
+                    add(() -> itfwServer.savePhoto2DB(rshyParam.getSfzh(), rshyParam.getPhoto()));
+                    rshyVo.setPhoto(null);
                 }
             }
         };
 
-        //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())));
-        taskList.add(() -> resultDTO.getPctgkryDTO().setPctztDTO(itfwServer.getPctzt(rshyParam.getSfzh(), rshyParam.getTimeout())));
-        taskList.add(() -> resultDTO.getPctgkryDTO().setPctzfbaDTO(itfwServer.getPctzfba(rshyParam.getSfzh(), rshyParam.getTimeout())));
-        taskList.add(() -> resultDTO.getPctgkryDTO().setPctqkryDTO(itfwServer.getPctqkry(rshyParam.getSfzh(), rshyParam.getTimeout())));
-        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())));
-        //}
+        if (rshyParam.getScreenLocked() == 0) {
+            //没锁屏的情况下,继续进行七大类管控接口、人车核录接口、杭州市重点人员底库数据查询接口以及依图的比对
+            if (StrUtil.isNotBlank(rshyParam.getPhoto())) {
+                //add(() -> resultDTO.setPersonIdentifyDTO(viidServer.personIdentify(rshyParam.getPhoto(), rshyParam.getTimeout())));
+                taskList.add(() -> quickRshyVo.set(getYitu(rshyParam.getPhoto(), (rshyParam.getTimeout()))));
+            }
+            taskList.add(() -> resultDTO.getPctgkryDTO().setPctdfkDTO(itfwServer.getPctdfk(rshyParam.getSfzh(), "", rshyParam.getTimeout())));
+            taskList.add(() -> resultDTO.getPctgkryDTO().setPctjsryDTO(itfwServer.getPctjsry(rshyParam.getSfzh(), rshyParam.getTimeout())));
+            taskList.add(() -> resultDTO.getPctgkryDTO().setPctztDTO(itfwServer.getPctzt(rshyParam.getSfzh(), rshyParam.getTimeout())));
+            taskList.add(() -> resultDTO.getPctgkryDTO().setPctzfbaDTO(itfwServer.getPctzfba(rshyParam.getSfzh(), rshyParam.getTimeout())));
+            taskList.add(() -> resultDTO.getPctgkryDTO().setPctqkryDTO(itfwServer.getPctqkry(rshyParam.getSfzh(), rshyParam.getTimeout())));
+            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())));
+        }
+
 
         //异步流并发处理
 //        taskList.parallelStream().forEach(v -> {
@@ -194,17 +204,18 @@ public class RshyJkManagerImpl implements RshyJkManager {
         //出生日期 从身份证号码中获取
         Date date = DateUtil.parse(IdcardUtil.getBirthByIdCard(rshyVo.getSfzh()));
         rshyVo.setBirthday(DateUtil.format(date, "yyyy-M-d"));
-        //不是刷身份证,取地址、姓名、民族
-        if (StrUtil.isBlank(rshyParam.getXm())) {
-            if (resultDTO.getPctsfzResult() != null) {
-                //有警察叔叔身份证接口返回数据
-                rshyVo.setXm(resultDTO.getPctsfzResult().getCZRKXM());
-                rshyVo.setAddress(resultDTO.getPctsfzResult().getCZRKZZ());
-                rshyVo.setMz(resultDTO.getPctsfzResult().getCZRKMZ());
-            } else {
-                //户籍省份 从身份证号码中获取
-                rshyVo.setAddress(IdcardUtil.getProvinceByIdCard(rshyVo.getSfzh()));
-            }
+        //取地址、姓名、民族
+        if (resultDTO.getPctsfzResult() != null) {
+            //有警察叔叔身份证接口返回数据
+            rshyVo.setXm(resultDTO.getPctsfzResult().getCZRKXM());
+            rshyVo.setAddress(resultDTO.getPctsfzResult().getCZRKZZ());
+            rshyVo.setMz(resultDTO.getPctsfzResult().getCZRKMZ());
+        } else {
+            //户籍省份 从身份证号码中获取
+            rshyVo.setAddress(IdcardUtil.getProvinceByIdCard(rshyVo.getSfzh()));
+        }
+        if (StrUtil.isNotBlank(rshyParam.getXm()) && rshyVo.getXm() == null) {
+            rshyVo.setXm(rshyParam.getXm());
         }
         //人车核录核查结果
         String hcjg = resultDTO.getPctrchlDTO() == null ? "" : resultDTO.getPctrchlDTO().getHcjg();
@@ -256,9 +267,10 @@ public class RshyJkManagerImpl implements RshyJkManager {
             rshyVo.setPhoto(resultDTO.getPctzjzpResultDTO().getPhoto());
         }
 
-        //System.out.println(JSONObject.toJSONString(resultDTO));
         if (resultDTO.getPctjkmInfoDTO() != null) {
-            saveIdentity(resultDTO.getPctjkmInfoDTO().getBar_code(), rshyVo);
+            saveIdentity2DB(resultDTO.getPctjkmInfoDTO().getBar_code(), rshyVo);
+        } else {
+            saveIdentity2DB(StrUtil.EMPTY, rshyVo);
         }
         return new AsyncResult<>(rshyVo);
     }
@@ -295,8 +307,14 @@ public class RshyJkManagerImpl implements RshyJkManager {
     }
 
 
+    /**
+     * 保存身份信息到数据库
+     *
+     * @param barCode 健康码bar_code
+     * @param rshyVo
+     */
     @Async
-    protected void saveIdentity(String barCode, RshyVo rshyVo) {
+    protected void saveIdentity2DB(String barCode, RshyVo rshyVo) {
         log.info("保存身份信息到数据库, 身份证号码: {}", rshyVo.getSfzh());
         Identity identity = new Identity();
         if (StrUtil.isNotBlank(barCode)) {
@@ -306,10 +324,24 @@ public class RshyJkManagerImpl implements RshyJkManager {
         identity.setName(rshyVo.getXm());
         identity.setAddress(rshyVo.getAddress());
         identity.setPhone(rshyVo.getPhone());
-        identity.setPhoto(rshyVo.getPhoto());
+        //identity.setPhoto(rshyVo.getPhoto());
         identityService.saveOK(identity);
     }
 
+    @Async
+    protected void saveBarcode2DB(String barCode, String idNum) {
+        LambdaQueryWrapper<Identity> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(Identity::getIdNum, idNum);
+        Identity identity = identityService.getOne(wrapper);
+        if (identity != null) return;
+        identity = new Identity();
+        if (StrUtil.isNotBlank(barCode)) {
+            identity.setBarCode(barCode);
+        }
+        identity.setIdNum(idNum);
+        identityService.save(identity);
+    }
+
     /**
      * 组装返回的核酸信息
      *

+ 8 - 0
src/main/java/com/rshy/project/hy/mapper/IdentityMapper.java

@@ -3,6 +3,8 @@ package com.rshy.project.hy.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.rshy.project.hy.model.entity.Identity;
 
+import java.util.Map;
+
 /**
  * <p>
  * Mapper 接口
@@ -15,4 +17,10 @@ public interface IdentityMapper extends BaseMapper<Identity> {
 
     String getIdNum(String barCode);
 
+    Map<String, String> getPhoto(String idNum);
+
+    void addPhoto(String idNum, String photo);
+
+    void updatePhoto(String idNum, String photo);
+
 }

+ 1 - 1
src/main/java/com/rshy/project/hy/model/constant/WebConstant.java

@@ -24,5 +24,5 @@ public class WebConstant {
     /**
      * 接口响应内容过长时,最长显示的字符长度
      */
-    public static final Integer DISPLAY_MAX_LENGTH = 80;
+    public static final Integer DISPLAY_MAX_LENGTH = 400;
 }

+ 0 - 1
src/main/java/com/rshy/project/hy/model/entity/Identity.java

@@ -34,7 +34,6 @@ public class Identity implements Serializable {
 
     private String photo;
 
-
     @Override
     public String toString() {
         return "Identity{" +

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

@@ -8,17 +8,23 @@ import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.rshy.project.hy.config.properties.*;
 import com.rshy.project.hy.model.constant.ItfwConstant;
 import com.rshy.project.hy.model.constant.WebConstant;
+import com.rshy.project.hy.model.entity.Identity;
 import com.rshy.project.hy.server.dto.*;
 import com.rshy.project.hy.server.param.AgentApiParam;
+import com.rshy.project.hy.server.param.IdphotoParam;
 import com.rshy.project.hy.server.vo.*;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.env.Environment;
 import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.stereotype.Component;
 
 import java.util.Comparator;
@@ -35,6 +41,7 @@ import java.util.concurrent.TimeUnit;
  */
 @Component
 @Slf4j
+@EnableAsync
 public class ItfwServer {
     @Value("${base.url}")
     private String baseUrl;
@@ -70,6 +77,8 @@ public class ItfwServer {
     private PctxcmProperties pctxcmProperties;
     @Autowired
     private StringRedisTemplate stringRedisTemplate;
+    @Autowired
+    private Environment environment;
 
     /**
      * 基础服务访问
@@ -82,6 +91,15 @@ public class ItfwServer {
         return HttpUtil.post(baseUrl, JSON.toJSONString(param), timeout);
     }
 
+    @Async("hstTaskExecutor")
+    public void savePhoto2DB(String idNum, String photoBase64) {
+        IdphotoParam param = new IdphotoParam();
+        param.setSfzh(idNum);
+        param.setPhoto(photoBase64);
+        HttpUtil.post("http://localhost:" + environment.getProperty("server.port") +
+                environment.getProperty("server.servlet.context-path") + "/identity/savePhoto", JSON.toJSONString(param));
+    }
+
     /**
      * 健康码服务
      * <p>
@@ -749,7 +767,7 @@ public class ItfwServer {
         String cacheKey = idNumber + ':' + ItfwConstant.PCTZJZP_KEY;
         String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey);
         if (StrUtil.isNotEmpty(cacheValue)) {
-            log.info("证件照片接口服务走缓存读取,响应内容: {}", cacheValue);
+            log.info("证件照片接口服务走缓存读取,响应内容: {}", StrUtil.brief(cacheValue, WebConstant.DISPLAY_MAX_LENGTH));
             return JSON.parseObject(cacheValue, PctzjzpResultDTO.class);
         }
 
@@ -777,7 +795,7 @@ public class ItfwServer {
             return null;
         }
 
-        log.info("证件照片接口服务响应信息:{}", body);
+        log.info("证件照片接口服务响应信息:{}", StrUtil.brief(body, WebConstant.DISPLAY_MAX_LENGTH));
 
         if (StrUtil.isEmpty(body) || body.contains("errCode")) {
             return null;
@@ -793,6 +811,7 @@ public class ItfwServer {
         byte[] bytes = HttpRequest.get(pctzjzpResultDTO.getZjzUrl()).timeout(200).execute().bodyBytes();
         pctzjzpResultDTO.setPhoto(Base64.encode(bytes));
         stringRedisTemplate.opsForValue().set(cacheKey, JSON.toJSONString(pctzjzpResultDTO));//DateUtil.endOfDay(DateUtil.date()).getTime() - DateUtil.date().getTime(), TimeUnit.MILLISECONDS);
+        savePhoto2DB(idNumber, pctzjzpResultDTO.getPhoto());
         return pctzjzpResultDTO;
     }
 

+ 1 - 1
src/main/java/com/rshy/project/hy/server/YituFaceServer.java

@@ -197,7 +197,7 @@ public class YituFaceServer {
                 //.setRetrieval_query_id("1")
                 .setRetrieval(new RetrievalDTO().setPicture_image_content_base64(photo).setFast(true).setThreshold(threshold)
                         .setRepository_ids(voList.stream().map(RepositoryVO::getId).collect(Collectors.toList())));
-        log.info("依图调用参数: {}", JSON.toJSONString(param));
+        log.info("依图调用参数: {}", StrUtil.brief(JSON.toJSONString(param), WebConstant.DISPLAY_MAX_LENGTH));
         String body = HttpRequest.post(retrievalUrl).header(HEADERS_KEY, login.getSession_id()).body(JSON.toJSONString(param)).timeout(timeout).execute().body();
         log.info("依图返回结果: {}", body);
         return JSON.parseObject(body, RetrievaResultVO.class);

+ 21 - 0
src/main/java/com/rshy/project/hy/server/param/IdphotoParam.java

@@ -0,0 +1,21 @@
+package com.rshy.project.hy.server.param;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * Created by fanqun on 2022/6/14.
+ */
+@Data
+@Accessors(chain = true)
+@ApiModel("证件照片请求参数")
+public class IdphotoParam {
+
+    @ApiModelProperty(value = "身份证号", required = true)
+    private String sfzh;
+
+    @ApiModelProperty("证件照片 Base64")
+    private String photo;
+}

+ 50 - 0
src/main/java/com/rshy/project/hy/server/param/LoginInfo.java

@@ -0,0 +1,50 @@
+package com.rshy.project.hy.server.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 登录信息入参
+ * <p>
+ * Created by fanqun on 2022/6/13.
+ */
+@Data
+@Accessors(chain = true)
+public class LoginInfo {
+    /**
+     * 登录ID,警号
+     */
+    @ApiModelProperty("登录ID,即警员警号")
+    private String id;
+    /**
+     * 登录姓名,警员姓名
+     */
+    @ApiModelProperty("警员姓名")
+    private String name;
+    /**
+     * 警员身份证号
+     */
+    @ApiModelProperty("警员身份证")
+    private String idNum;
+    /**
+     * 警员手机号码
+     */
+    @ApiModelProperty("警员手机号")
+    private String phone;
+    /**
+     * 证码通设备IP
+     */
+    @ApiModelProperty("证码通设备IP")
+    private String ip;
+    /**
+     * 管辖派出所内部组织代码
+     */
+    @ApiModelProperty("管辖派出所组织代码")
+    private String orgCode;
+    /**
+     * 证码通设备放置位置
+     */
+    @ApiModelProperty("证码通设备放置位置")
+    private String location;
+}

+ 10 - 8
src/main/java/com/rshy/project/hy/server/param/RshyParam.java

@@ -1,6 +1,8 @@
 package com.rshy.project.hy.server.param;
 
 import com.alibaba.fastjson.annotation.JSONField;
+import com.alibaba.fastjson.annotation.JSONType;
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.rshy.project.hy.model.constant.WebConstant;
 import com.rshy.project.hy.model.entity.Identity;
 import io.swagger.annotations.ApiModel;
@@ -9,17 +11,12 @@ import lombok.Data;
 import lombok.experimental.Accessors;
 
 /**
- * @ProjectName: rshy
- * @Package: com.rshy.project.hy.server.param
- * @ClassName: RshyParam
- * @Author: shihongbo
- * @Description:
- * @Date: 2022/3/2 14:48
- * @Version: 1.0
+ * 普通核验请求参数
  */
 @Data
 @Accessors(chain = true)
 @ApiModel("普通核验请求参数")
+@JSONType(orders = {"barCode", "sfzh", "xm", "photo", "loginInfo", "timeout", "screenLocked"})
 public class RshyParam {
     @ApiModelProperty("身份证号")
     private String sfzh;
@@ -30,7 +27,7 @@ public class RshyParam {
     @ApiModelProperty("健康码")
     private String barCode;
 
-    @ApiModelProperty("超时时间")
+    @ApiModelProperty("超时时间,单位秒")
     private Integer timeout = WebConstant.TIMEOUT;
 
     @ApiModelProperty("人脸照片 Base64")
@@ -39,7 +36,12 @@ public class RshyParam {
     @ApiModelProperty("锁屏状态")
     private Integer screenLocked;
 
+    @ApiModelProperty("登录信息")
+    private LoginInfo loginInfo;
+
     @JSONField(serialize = false, deserialize = false)
+    @ApiModelProperty(hidden = true)
+    @JsonIgnore
     private Identity identity;
 
     @Override

+ 6 - 9
src/main/java/com/rshy/project/hy/server/vo/RshyVo.java

@@ -1,5 +1,6 @@
 package com.rshy.project.hy.server.vo;
 
+import com.alibaba.fastjson.annotation.JSONType;
 import com.rshy.project.hy.model.dto.NucleicAcidDTO;
 import com.rshy.project.hy.model.enums.PassStatusEnum;
 import io.swagger.annotations.ApiModel;
@@ -8,17 +9,13 @@ import lombok.Data;
 import lombok.experimental.Accessors;
 
 /**
- * @ProjectName: rshy
- * @Package: com.rshy.project.hy.server.vo
- * @ClassName: RshyVo
- * @Author: shihongbo
- * @Description:
- * @Date: 2022/3/2 14:53
- * @Version: 1.0
+ * 返回数据
  */
 @Data
 @Accessors(chain = true)
 @ApiModel("返回数据")
+@JSONType(orders = {"pass", "sfzh", "xm", "xb", "birthday", "mz", "address", "phone", "photo",
+        "vaccine", "nucleic_acid", "travel_card", "kind", "warning", "displayMsg", "tts", "healthCode", "times"})
 public class RshyVo {
     @ApiModelProperty("是否通行")
     private Integer pass = PassStatusEnum.NORMAL_TRAFFIC.getCode();
@@ -41,8 +38,8 @@ public class RshyVo {
     @ApiModelProperty("身份证号")
     private String sfzh;
 
-    @ApiModelProperty("证件类型")
-    private String zjlx = "居民身份证";
+    //@ApiModelProperty("证件类型")
+    //private String zjlx = "居民身份证";
 
     @ApiModelProperty("姓名")
     private String xm;

+ 2 - 0
src/main/java/com/rshy/project/hy/service/IdentityService.java

@@ -20,4 +20,6 @@ public interface IdentityService extends IService<Identity> {
 
     Identity saveOK(Identity identity);
 
+    void savePhoto(String idNum, String photo);
+
 }

+ 28 - 4
src/main/java/com/rshy/project/hy/service/impl/IdentityServiceImpl.java

@@ -7,12 +7,16 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rshy.project.hy.mapper.IdentityMapper;
 import com.rshy.project.hy.model.entity.Identity;
 import com.rshy.project.hy.service.IdentityService;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.cache.annotation.CachePut;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.Map;
 
 /**
  * <p>
@@ -24,13 +28,15 @@ import javax.annotation.Resource;
  */
 @Service
 @EnableCaching
+@Slf4j
+@EnableAsync
 public class IdentityServiceImpl extends ServiceImpl<IdentityMapper, Identity> implements IdentityService {
 
     @Resource
     private IdentityMapper identityMapper;
 
     @Override
-    @Cacheable(value = "identity", key = "#p0", unless = "#result == null")
+    @Cacheable(value = "identity", key = "#p0", unless = "#result==null || #result.name == null")
     public Identity getIdentity(String idNum) {
         LambdaQueryWrapper<Identity> wrapper = new LambdaQueryWrapper<>();
         if (StrUtil.isNotBlank(idNum)) {
@@ -48,10 +54,28 @@ public class IdentityServiceImpl extends ServiceImpl<IdentityMapper, Identity> i
     }
 
     @Override
-    @CachePut(value = "identity", key = "#p0.idNum", unless = "#result == null")
+    @Async("hstTaskExecutor")
+    @CachePut(value = "identity", key = "#p0.idNum", unless = "#result.name == null")
     public Identity saveOK(Identity identity) {
-        if (super.saveOrUpdate(identity))
-            return identity;
+        if (super.saveOrUpdate(identity)) {
+            LambdaQueryWrapper<Identity> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(Identity::getIdNum, identity.getIdNum());
+            return identityMapper.selectOne(wrapper);
+        }
         return null;
     }
+
+    @Override
+    @Async("hstTaskExecutor")
+    public void savePhoto(String idNum, String photo) {
+        log.info("保存证件照片到数据库, 身份证号码: {}", idNum);
+        if (StrUtil.isBlank(idNum)) return;
+        Map<String, String> map = identityMapper.getPhoto(idNum);
+        if (map == null) {
+            identityMapper.addPhoto(idNum, photo);
+        } else if (StrUtil.isBlank(map.get("photo"))) {
+            identityMapper.updatePhoto(idNum, photo);
+        }
+
+    }
 }

+ 48 - 0
src/main/java/com/rshy/project/hy/web/controller/IdentityController.java

@@ -0,0 +1,48 @@
+package com.rshy.project.hy.web.controller;
+
+
+import cn.hutool.core.util.IdcardUtil;
+import cn.hutool.core.util.StrUtil;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+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.server.param.IdphotoParam;
+import com.rshy.project.hy.service.IdentityService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModelProperty;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+/**
+ * <p>
+ * 前端控制器
+ * </p>
+ *
+ * @author fanqun
+ * @since 2022-06-11
+ */
+@RestController
+@Api(tags = "身份信息控制层", hidden = true)
+@RequestMapping("/identity")
+public class IdentityController {
+    @Resource
+    private IdentityService identityService;
+
+    @ApiModelProperty(value = "保存证件照片")
+    @ApiOperationSupport(order = 900)
+    @PostMapping("/savePhoto")
+    public Ret<?> savePhoto(@RequestBody IdphotoParam body) {
+        if (StrUtil.isBlank(body.getSfzh()) && !IdcardUtil.isValidCard(body.getSfzh())) {
+            throw new BaseException(ResultCode.INVALID_ID_NUMBER);
+        }
+        identityService.savePhoto(body.getSfzh(), body.getPhoto());
+        return Ret.success(null);
+    }
+
+}
+

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

@@ -10,6 +10,7 @@ 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.constant.WebConstant;
 import com.rshy.project.hy.model.entity.Identity;
 import com.rshy.project.hy.model.enums.PassStatusEnum;
 import com.rshy.project.hy.server.param.RshyParam;
@@ -30,13 +31,10 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
 /**
- * @ProjectName: rshy
- * @Package: com.rshy.project.hy.web.controller
  * @ClassName: RshyController
- * @Author: shihongbo
+ * @Author:
  * @Description:
  * @Date: 2022/3/2 15:22
- * @Version: 1.0
  */
 @RestController
 @Api(tags = "人身核验控制层")
@@ -50,7 +48,7 @@ public class RshyController {
 
     @GetMapping(value = "/version")
     public String version() {
-        return "1.2.4.220613";
+        return "1.2.4.220614";
     }
 
     @ApiOperation("普通核验模式")
@@ -73,7 +71,9 @@ public class RshyController {
 
         DateTime time1 = DateTime.now();
 
-        log.info("普通核验接口请求参数:{}", JSON.toJSONString(rshyParam));
+        rshyParam.setTimeout(5);
+
+        log.info("普通核验接口请求参数:{}", StrUtil.brief(JSON.toJSONString(rshyParam), WebConstant.DISPLAY_MAX_LENGTH));
 
         RshyVo rshyVo = new RshyVo().setPassStatus(PassStatusEnum.NORMAL_TRAFFIC);
         String sfz = rshyParam.getSfzh();
@@ -91,7 +91,7 @@ public class RshyController {
         try {
             //RshyVo rshyVo = rshyJkManager.getRshyInfo(rshyParam);
             Future<RshyVo> future = rshyJkManager.getRshyInfo(rshyParam);
-            rshyVo = future.get(rshyParam.getTimeout() * 1000 - 100, TimeUnit.MILLISECONDS);
+            rshyVo = future.get(rshyParam.getTimeout() * 1000 - 300, TimeUnit.MILLISECONDS);
         } catch (InterruptedException | ExecutionException e) {
             log.error("普通核验接口异常: {}", e.getMessage());
             //e.printStackTrace();
@@ -100,7 +100,7 @@ public class RshyController {
         } catch (Exception e) {
             throw new BaseException();
         }
-        log.info("普通核验响应内容:{}", JSON.toJSONString(rshyVo));
+        log.info("普通核验响应内容:{}", StrUtil.brief(JSON.toJSONString(rshyVo), WebConstant.DISPLAY_MAX_LENGTH * 2));
         System.out.println("普通核验接口用时: " + DateUtil.between(time1, DateTime.now(), DateUnit.MS) + "毫秒\n");
         return Ret.success(rshyVo);
     }

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

@@ -30,7 +30,7 @@ swagger:
   application-name: 智能证码通核验接口
   application-version: 1.2.4
   application-description: 智能证码通核验接口
-  try-host: http://localhost:${server.port}
+  try-host: http://localhost:${server.port}/${server.servlet.context-path}
 
 
 

+ 18 - 6
src/main/resources/mapper/IdentityMapper.xml

@@ -4,15 +4,27 @@
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.rshy.project.hy.model.entity.Identity">
-        <id column="id_num" property="idNum" />
-        <result column="bar_code" property="barCode" />
-        <result column="name" property="name" />
-        <result column="address" property="address" />
-        <result column="phone" property="phone" />
-        <result column="photo" property="photo" />
+        <id column="id_num" property="idNum"/>
+        <result column="bar_code" property="barCode"/>
+        <result column="name" property="name"/>
+        <result column="address" property="address"/>
+        <result column="phone" property="phone"/>
+        <result column="photo" property="photo"/>
     </resultMap>
 
     <select id="getIdNum" resultType="string">
         SELECT id_num FROM identity WHERE bar_code = #{barCode}
     </select>
+
+    <select id="getPhoto" resultType="map">
+        SELECT id_num,photo FROM identity WHERE id_num = #{idNum}
+    </select>
+
+    <insert id="addPhoto">
+        INSERT INTO identity (id_num,photo) VALUES (#{idNum},#{photo})
+    </insert>
+
+    <update id="updatePhoto">
+        UPDATE identity SET photo = #{photo} WHERE id_num = #{idNum}
+    </update>
 </mapper>