Browse Source

improve:快速人脸核验通行判断改进

lileilei 2 years ago
parent
commit
b5e3bd90d5

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

@@ -7,7 +7,6 @@ import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
-import com.google.common.collect.Lists;
 import com.rshy.project.hy.baseRe.BaseException;
 import com.rshy.project.hy.server.dto.OrderDTO;
 import com.rshy.project.hy.server.dto.RetrievalDTO;
@@ -59,6 +58,7 @@ public class FaceRetrievaServer {
      */
     private static TimedCache<String, String> timedCache = CacheUtil.newTimedCache(15 * 60 * 1000);
 
+
     /**
      * 登录接口
      *
@@ -76,6 +76,15 @@ public class FaceRetrievaServer {
         return JSON.parseObject(body, RetrievaResultVO.class);
     }
 
+    /**
+     * 登录接口
+     *
+     * @return
+     */
+    public RetrievaResultVO login() {
+        return this.login(new RetrievaLoginParam().setName(name).setPassword(password));
+    }
+
     /**
      * 获取人像库
      *
@@ -92,6 +101,21 @@ public class FaceRetrievaServer {
         return JSON.parseObject(body, RetrievaResultVO.class);
     }
 
+
+    /**
+     * 获取人像库
+     *
+     */
+    public RetrievaResultVO repository() {
+        RetrievaResultVO login = this.login(new RetrievaLoginParam().setName(name).setPassword(password));
+        log.info("依图 login: {}", login.toString());
+        if (login.getRtn() != null && !login.getRtn().equals(0)) {
+            throw new BaseException(login.getMessage());
+        }
+
+        return this.repository(login.getSession_id());
+    }
+
     /**
      * 人脸库检索
      *

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

@@ -2,6 +2,7 @@ package com.rshy.project.hy.server;
 
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.convert.Convert;
+import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSONObject;
@@ -9,6 +10,7 @@ import com.rshy.project.hy.model.entity.RshyJk;
 import com.rshy.project.hy.model.enums.HyTypeEnum;
 import com.rshy.project.hy.model.enums.PassStatusEnum;
 import com.rshy.project.hy.model.enums.SexEnum;
+import com.rshy.project.hy.server.dto.RepositoryDTO;
 import com.rshy.project.hy.server.param.RshyParam;
 import com.rshy.project.hy.server.param.RshyQuickParam;
 import com.rshy.project.hy.server.vo.*;
@@ -84,9 +86,24 @@ public class RshyServer {
             return rshyVo;
         }
 
+        //查询人像库信息
+        RetrievaResultVO repository = faceRetrievaServer.repository();
+        List<RepositoryDTO> dtoList = Convert.toList(RepositoryDTO.class, repository.getResults());
+        Map<String, String> stringMap = MapUtil.newHashMap();
+
+        if(CollectionUtil.isNotEmpty(dtoList)){
+            stringMap = dtoList.stream().collect(Collectors.toMap(RepositoryDTO::getId, RepositoryDTO::getName, (v1, v2) -> v1));
+        }
+
         RetrievalRepositoryVO repositoryVO = voList.stream().findFirst().get();
 
-        rshyVo.setPass(PassStatusEnum.NO_PASSING.getCode()).setKind(StrUtil.EMPTY).setWarning(StrUtil.EMPTY).setDisplayMsg("核验不通过").setTts("核验不通过").setHealthCode(StrUtil.EMPTY).setSfzh(repositoryVO.getPersonId())
+        if("1".equals(repositoryVO.getRepository_id())){
+            rshyVo.setPass(PassStatusEnum.NO_PASSING.getCode());
+        }else{
+            rshyVo.setPass(PassStatusEnum.RIGHT_WAY.getCode());
+        }
+
+        rshyVo.setKind(StrUtil.EMPTY).setWarning(stringMap.get(repositoryVO.getRepository_id())).setDisplayMsg("核验不通过").setTts("核验不通过").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());
         return rshyVo;
     }

+ 27 - 0
src/main/java/com/rshy/project/hy/server/dto/RepositoryDTO.java

@@ -0,0 +1,27 @@
+package com.rshy.project.hy.server.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * @author: lileilei
+ * @date: 2022/4/22 21:30
+ * @description:
+ */
+@Data
+@Accessors(chain = true)
+public class RepositoryDTO {
+    private String id;
+
+    private String name;
+
+    private Integer face_image_num;
+
+    private Integer creator_id;
+
+    private Date create_time;
+
+    private Map<String, Integer> permission_map;
+}