Преглед на файлове

活体识别-定时器拉取结果

haogh преди 7 месеца
родител
ревизия
a1d3e0da30

+ 15 - 0
src/cn/hmsoft/art/data/dao/live/TxStdLiveLogDao.java

@@ -4,7 +4,22 @@ import cn.hmsoft.art.data.model.live.TxStdLiveLog;
 import cn.hmsoft.jdbc.core.PlatformDaoSupport;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 @Repository
 public class TxStdLiveLogDao extends PlatformDaoSupport<TxStdLiveLog> {
 
+    /**
+     *  查找未拉取活体识别结果的考生
+     * @param minute 分钟
+     * @return 活体识别请求列表
+     */
+    public List<TxStdLiveLog> listNoPullMaterial(int minute) {
+        String sql = "SELECT t1.* FROM tx_std_live_log t1 " + " JOIN (  SELECT std_id, MAX(create_time) as create_time "
+                + "  FROM tx_std_live_log where pull_flag=0 GROUP BY std_id "
+                + " ) t2 ON t1.std_id = t2.std_id AND t1.create_time = t2.create_time "
+                + " where t1.std_id in (select std_id from std_reg where  STD_VERIFY_FLAG = 'InActive' or STD_VERIFY_FLAG is null) "
+                + " and TIMESTAMPDIFF(MINUTE,t1.create_time,now())> ? ";
+        return this.listBySql(sql, minute);
+    }
 }

+ 20 - 0
src/cn/hmsoft/art/helper/TxLivePullMaterialJob.java

@@ -0,0 +1,20 @@
+package cn.hmsoft.art.helper;
+
+import cn.hmsoft.application.SpringHelper;
+import cn.hmsoft.art.service.live.LiveRecognitionService;
+import cn.hmsoft.frame.timer.FrameTimerConfig;
+
+/**
+ * @Description 腾讯拉取活体识别结果Job
+ */
+public class TxLivePullMaterialJob extends FrameTimerConfig {
+
+    @Override
+    protected boolean execute() throws Exception {
+        synchronized(TxLivePullMaterialJob.class) {
+            LiveRecognitionService recognitionService = SpringHelper.getBean(LiveRecognitionService.class);
+            recognitionService.pullLiveMaterial();
+        }
+        return false;
+    }
+}

+ 23 - 0
src/cn/hmsoft/art/service/live/LiveRecognitionService.java

@@ -1,5 +1,6 @@
 package cn.hmsoft.art.service.live;
 
+import cn.hmsoft.application.SpringHelper;
 import cn.hmsoft.art.constants.*;
 import cn.hmsoft.art.data.dao.live.TxLivenessDetailDao;
 import cn.hmsoft.art.data.dao.live.TxStdLiveLogDao;
@@ -13,11 +14,13 @@ import cn.hmsoft.art.data.model.std.StdReg;
 import cn.hmsoft.art.data.model.std.StdRes;
 import cn.hmsoft.art.data.response.live.*;
 import cn.hmsoft.art.data.vo.live.DetectAuthVO;
+import cn.hmsoft.art.data.vo.live.DetectInfoVO;
 import cn.hmsoft.art.enrol.data.dao.std.EnrolStdResDao;
 import cn.hmsoft.art.enrol.helper.EnrolMaterialHelper;
 import cn.hmsoft.art.helper.ArtParamHelper;
 import cn.hmsoft.art.helper.GsonHelper;
 import cn.hmsoft.art.helper.ImageUtil;
+import cn.hmsoft.art.helper.TencentLiveHelper;
 import cn.hmsoft.art.service.ArtService;
 import cn.hmsoft.frame.constants.FrameStatus;
 import cn.hmsoft.frame.exception.BusinessException;
@@ -250,4 +253,24 @@ public class LiveRecognitionService extends ArtService {
         }
         return stdReg;
     }
+
+    public void pullLiveMaterial() {
+        // 未及时拉取的时间(分钟)
+        int minute = Integer.parseInt(CollectionHelper.getParamValue(ArtParamHelper.GobalParamMap, "NoPullMaterialMinute", "10"));
+        // 查询未及时拉取活体识别结果的考生
+        List<TxStdLiveLog> stdLiveLogList = SpringHelper.getBean(TxStdLiveLogDao.class).listNoPullMaterial(minute);
+
+        //调用腾讯接口参数组装
+        DetectInfoVO detectInfoVO = new DetectInfoVO();
+        detectInfoVO.setRuleId(ArtParamHelper.TencentLiveRuleId);
+        detectInfoVO.setInfoType(ArtParamHelper.TencentLiveInfoType);
+
+        for (TxStdLiveLog stdLiveLog : stdLiveLogList) {
+            String bizToken = stdLiveLog.getBiz_token();
+            detectInfoVO.setBizToken(bizToken);
+            String result = TencentLiveHelper.getDetectInfoEnhanced(detectInfoVO);
+            //拉取活体识别结果
+            saveDetectResult(bizToken, result);
+        }
+    }
 }