|
@@ -57,20 +57,20 @@ import org.springframework.stereotype.Service;
|
|
|
@Service("examFaceLivenessVerifyService")
|
|
|
public class ExamFaceLivenessVerifyServiceImpl implements ExamFaceLivenessVerifyService {
|
|
|
|
|
|
- private static final Logger log = LoggerFactory.getLogger(ExamFaceLivenessVerifyServiceImpl.class);
|
|
|
-
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(ExamFaceLivenessVerifyServiceImpl.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
private ExamFaceLivenessVerifyRepo examFaceLivenessVerifyRepo;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private ExamRecordDataService examRecordDataService;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private ExamRecordDataRepo examRecordDataRepo;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private ExamSessionInfoService examSessionInfoService;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private GainBaseDataService gainBaseDataService;
|
|
|
|
|
@@ -96,7 +96,7 @@ public class ExamFaceLivenessVerifyServiceImpl implements ExamFaceLivenessVerify
|
|
|
|
|
|
@Override
|
|
|
public ExamFaceLivenessVerifyEntity saveFaceVerify(Long examRecordDataId) {
|
|
|
- ExamFaceLivenessVerifyEntity faceVerify = new ExamFaceLivenessVerifyEntity();
|
|
|
+ ExamFaceLivenessVerifyEntity faceVerify = new ExamFaceLivenessVerifyEntity();
|
|
|
faceVerify.setExamRecordDataId(examRecordDataId);
|
|
|
faceVerify.setStartTime(new Date());
|
|
|
faceVerify.setIsError(false);
|
|
@@ -105,61 +105,61 @@ public class ExamFaceLivenessVerifyServiceImpl implements ExamFaceLivenessVerify
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<ExamFaceLivenessVerifyEntity> listFaceVerifyByExamRecordId(Long examRecordDataId){
|
|
|
- if(examRecordDataId == null){
|
|
|
+ public List<ExamFaceLivenessVerifyEntity> listFaceVerifyByExamRecordId(Long examRecordDataId) {
|
|
|
+ if (examRecordDataId == null) {
|
|
|
return new ArrayList<ExamFaceLivenessVerifyEntity>();
|
|
|
}
|
|
|
return examFaceLivenessVerifyRepo.findByExamRecordDataIdOrderById(examRecordDataId);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ExamFaceLivenessVerifyEntity faceIdNotify(String faceIdResultJson){
|
|
|
+ public ExamFaceLivenessVerifyEntity faceIdNotify(String faceIdResultJson) {
|
|
|
JSONObject faceIdResultJsonObject;
|
|
|
Long faceVerifyId;
|
|
|
ExamFaceLivenessVerifyEntity faceVerify = new ExamFaceLivenessVerifyEntity();
|
|
|
- try{
|
|
|
- faceIdResultJsonObject = new JSONObject(faceIdResultJson);
|
|
|
- faceVerifyId = faceIdResultJsonObject.getLong("biz_no");
|
|
|
+ try {
|
|
|
+ faceIdResultJsonObject = new JSONObject(faceIdResultJson);
|
|
|
+ faceVerifyId = faceIdResultJsonObject.getLong("biz_no");
|
|
|
faceVerify = findFaceVerifyById(faceVerifyId);
|
|
|
- if(faceIdResultJsonObject.has("verify_result")
|
|
|
- && faceIdResultJsonObject.get("verify_result") != null
|
|
|
- && !"null".equals(faceIdResultJsonObject.get("verify_result")+"")){
|
|
|
- JSONObject verifyResultJson = faceIdResultJsonObject.getJSONObject("verify_result");
|
|
|
- JSONObject result_ref1 = verifyResultJson.getJSONObject("result_ref1");
|
|
|
- double confidence = result_ref1.getDouble("confidence");
|
|
|
- //人脸相似度
|
|
|
- if(confidence > 50D){
|
|
|
- JSONObject livenessResultJson = faceIdResultJsonObject.getJSONObject("liveness_result");
|
|
|
- if(livenessResultJson.has("result") && "success".equals(livenessResultJson.getString("result"))){
|
|
|
- faceVerify.setVerifyResult(FaceVerifyResult.VERIFY_SUCCESS);
|
|
|
- }
|
|
|
- }else{
|
|
|
- faceVerify.setVerifyResult(FaceVerifyResult.NOT_ONESELF);
|
|
|
- }
|
|
|
- }else{
|
|
|
- faceVerify.setVerifyResult(FaceVerifyResult.VERIFY_FAILED);
|
|
|
- }
|
|
|
- faceVerify.setResultJson(faceIdResultJsonObject.toString());
|
|
|
- faceVerify.setBizId(faceIdResultJsonObject.getString("biz_id"));
|
|
|
- }catch(Exception e){
|
|
|
- log.error("faceIdNotify error",e);
|
|
|
- faceVerify.setVerifyResult(FaceVerifyResult.VERIFY_FAILED);
|
|
|
- }
|
|
|
- long usedTime = System.currentTimeMillis()-faceVerify.getStartTime().getTime();
|
|
|
+ if (faceIdResultJsonObject.has("verify_result")
|
|
|
+ && faceIdResultJsonObject.get("verify_result") != null
|
|
|
+ && !"null".equals(faceIdResultJsonObject.get("verify_result") + "")) {
|
|
|
+ JSONObject verifyResultJson = faceIdResultJsonObject.getJSONObject("verify_result");
|
|
|
+ JSONObject result_ref1 = verifyResultJson.getJSONObject("result_ref1");
|
|
|
+ double confidence = result_ref1.getDouble("confidence");
|
|
|
+ //人脸相似度
|
|
|
+ if (confidence > 50D) {
|
|
|
+ JSONObject livenessResultJson = faceIdResultJsonObject.getJSONObject("liveness_result");
|
|
|
+ if (livenessResultJson.has("result") && "success".equals(livenessResultJson.getString("result"))) {
|
|
|
+ faceVerify.setVerifyResult(FaceVerifyResult.VERIFY_SUCCESS);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ faceVerify.setVerifyResult(FaceVerifyResult.NOT_ONESELF);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ faceVerify.setVerifyResult(FaceVerifyResult.VERIFY_FAILED);
|
|
|
+ }
|
|
|
+ faceVerify.setResultJson(faceIdResultJsonObject.toString());
|
|
|
+ faceVerify.setBizId(faceIdResultJsonObject.getString("biz_id"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("faceIdNotify error", e);
|
|
|
+ faceVerify.setVerifyResult(FaceVerifyResult.VERIFY_FAILED);
|
|
|
+ }
|
|
|
+ long usedTime = System.currentTimeMillis() - faceVerify.getStartTime().getTime();
|
|
|
faceVerify.setUsedTime(usedTime);
|
|
|
return examFaceLivenessVerifyRepo.save(faceVerify);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public GetFaceVerifyTokenInfo getFaceVerifyToken(Long studentId,String bizNo){
|
|
|
- GetFaceVerifyTokenInfo getFaceVerifyTokenInfo = new GetFaceVerifyTokenInfo();
|
|
|
- CloseableHttpResponse httpResponse = null;
|
|
|
- CloseableHttpClient httpClient = null;
|
|
|
- try{
|
|
|
- httpClient = HttpPoolUtil.getHttpClient();
|
|
|
+ public GetFaceVerifyTokenInfo getFaceVerifyToken(Long studentId, String bizNo) {
|
|
|
+ GetFaceVerifyTokenInfo getFaceVerifyTokenInfo = new GetFaceVerifyTokenInfo();
|
|
|
+ CloseableHttpResponse httpResponse = null;
|
|
|
+ CloseableHttpClient httpClient = null;
|
|
|
+ try {
|
|
|
+ httpClient = HttpPoolUtil.getHttpClient();
|
|
|
HttpPost httpPost = new HttpPost(faceIdGetTokenUrl);
|
|
|
File basePhotoFile = getStudentBasePhotoFile(studentId);
|
|
|
- MultipartEntityBuilder multipartEntityBuilder = getMultipartEntityBuilder(bizNo,basePhotoFile);
|
|
|
+ MultipartEntityBuilder multipartEntityBuilder = getMultipartEntityBuilder(bizNo, basePhotoFile);
|
|
|
HttpEntity httpEntity = multipartEntityBuilder.build();
|
|
|
httpPost.setEntity(httpEntity);
|
|
|
httpResponse = httpClient.execute(httpPost);
|
|
@@ -167,36 +167,36 @@ public class ExamFaceLivenessVerifyServiceImpl implements ExamFaceLivenessVerify
|
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(responseEntity.getContent()));
|
|
|
StringBuffer buffer = new StringBuffer();
|
|
|
String str = "";
|
|
|
- while(StringUtils.isNoneBlank((str = reader.readLine()))) {
|
|
|
+ while (StringUtils.isNoneBlank((str = reader.readLine()))) {
|
|
|
buffer.append(str);
|
|
|
}
|
|
|
String result = buffer.toString();
|
|
|
basePhotoFile.delete();
|
|
|
JSONObject jsonObject = new JSONObject(result);
|
|
|
- if(jsonObject.has("error_message")){
|
|
|
- getFaceVerifyTokenInfo.setSuccess(false);
|
|
|
- getFaceVerifyTokenInfo.setErrorMsg(jsonObject.getString("error_message"));
|
|
|
- log.error("getFaceVerifyToken error",result);
|
|
|
- }else if(jsonObject.has("error")){
|
|
|
- getFaceVerifyTokenInfo.setSuccess(false);
|
|
|
- getFaceVerifyTokenInfo.setErrorMsg(jsonObject.getString("error"));
|
|
|
- log.error("getFaceVerifyToken error",result);
|
|
|
- }else if(jsonObject.has("token")){
|
|
|
- getFaceVerifyTokenInfo.setSuccess(true);
|
|
|
- getFaceVerifyTokenInfo.setFaceLivenessToken(jsonObject.getString("token"));
|
|
|
+ if (jsonObject.has("error_message")) {
|
|
|
+ getFaceVerifyTokenInfo.setSuccess(false);
|
|
|
+ getFaceVerifyTokenInfo.setErrorMsg(jsonObject.getString("error_message"));
|
|
|
+ log.error("getFaceVerifyToken error", result);
|
|
|
+ } else if (jsonObject.has("error")) {
|
|
|
+ getFaceVerifyTokenInfo.setSuccess(false);
|
|
|
+ getFaceVerifyTokenInfo.setErrorMsg(jsonObject.getString("error"));
|
|
|
+ log.error("getFaceVerifyToken error", result);
|
|
|
+ } else if (jsonObject.has("token")) {
|
|
|
+ getFaceVerifyTokenInfo.setSuccess(true);
|
|
|
+ getFaceVerifyTokenInfo.setFaceLivenessToken(jsonObject.getString("token"));
|
|
|
}
|
|
|
httpPost.abort();
|
|
|
- }catch(Exception e){
|
|
|
- log.error("getFaceVerifyToken error",e);
|
|
|
- getFaceVerifyTokenInfo.setSuccess(false);
|
|
|
- getFaceVerifyTokenInfo.setErrorMsg(e.getMessage());
|
|
|
- }finally{
|
|
|
- if(httpResponse!=null){
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("getFaceVerifyToken error", e);
|
|
|
+ getFaceVerifyTokenInfo.setSuccess(false);
|
|
|
+ getFaceVerifyTokenInfo.setErrorMsg(e.getMessage());
|
|
|
+ } finally {
|
|
|
+ if (httpResponse != null) {
|
|
|
try {
|
|
|
- httpResponse.close();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ httpResponse.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return getFaceVerifyTokenInfo;
|
|
@@ -204,50 +204,46 @@ public class ExamFaceLivenessVerifyServiceImpl implements ExamFaceLivenessVerify
|
|
|
|
|
|
@Override
|
|
|
public ExamFaceLivenessVerifyEntity findFaceVerifyById(Long id) {
|
|
|
- if(id == null){
|
|
|
+ if (id == null) {
|
|
|
return null;
|
|
|
}
|
|
|
- return GlobalHelper.getEntity(examFaceLivenessVerifyRepo,id,ExamFaceLivenessVerifyEntity.class);
|
|
|
+ return GlobalHelper.getEntity(examFaceLivenessVerifyRepo, id, ExamFaceLivenessVerifyEntity.class);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void faceTestTimeOut(Long examRecordDataId){
|
|
|
+ public void faceTestTimeOut(Long examRecordDataId) {
|
|
|
List<ExamFaceLivenessVerifyEntity> faceVerifies = examFaceLivenessVerifyRepo.findByExamRecordDataIdOrderById(examRecordDataId);
|
|
|
- ExamFaceLivenessVerifyEntity faceVerify = faceVerifies.get(faceVerifies.size()-1);
|
|
|
- if(faceVerify.getVerifyResult() == null){
|
|
|
- faceVerify.setVerifyResult(FaceVerifyResult.TIME_OUT);
|
|
|
- examFaceLivenessVerifyRepo.save(faceVerify);
|
|
|
+ ExamFaceLivenessVerifyEntity faceVerify = faceVerifies.get(faceVerifies.size() - 1);
|
|
|
+ if (faceVerify.getVerifyResult() == null) {
|
|
|
+ faceVerify.setVerifyResult(FaceVerifyResult.TIME_OUT);
|
|
|
+ examFaceLivenessVerifyRepo.save(faceVerify);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void faceTestEndHandle(Long examRecordDataId, String result) {
|
|
|
- ExamRecordDataEntity examRecordDataEntity = GlobalHelper.getEntity(examRecordDataRepo,examRecordDataId,ExamRecordDataEntity.class);
|
|
|
- if(IsSuccess.strToEnum(result) == IsSuccess.FAILED){
|
|
|
-
|
|
|
- ExamRecordEntity examRecord =GlobalHelper.getEntity(
|
|
|
- examRecordRepo,examRecordDataEntity.getExamRecordId(),ExamRecordEntity.class);
|
|
|
- examSessionInfoService.deleteExamSessionInfo(examRecord.getStudentId());
|
|
|
- examRecordDataEntity.setFaceVerifyResult(IsSuccess.FAILED);
|
|
|
-
|
|
|
- //尝试交卷
|
|
|
- examControlService.handInExam(examRecordDataEntity,HandInExamType.AUTO);
|
|
|
- }else{
|
|
|
- examRecordDataEntity.setFaceVerifyResult(IsSuccess.SUCCESS);
|
|
|
- examRecordDataRepo.save(examRecordDataEntity);
|
|
|
+ public void faceTestEndHandle(Long examRecordDataId,Long studentId, String result) {
|
|
|
+ //保存活体检测的结果
|
|
|
+ ExamRecordDataEntity examRecordDataEntity = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId, ExamRecordDataEntity.class);
|
|
|
+ examRecordDataEntity.setFaceVerifyResult(IsSuccess.strToEnum(result) == IsSuccess.FAILED ? IsSuccess.FAILED : IsSuccess.SUCCESS);
|
|
|
+ examRecordDataRepo.save(examRecordDataEntity);
|
|
|
+
|
|
|
+ //如果活体检失败,需要清除会话并自动交卷
|
|
|
+ if (IsSuccess.strToEnum(result) == IsSuccess.FAILED) {
|
|
|
+ examSessionInfoService.deleteExamSessionInfo(studentId);
|
|
|
+ examControlService.handInExam(examRecordDataId, HandInExamType.AUTO);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ExamFaceLivenessVerifyEntity saveFaceVerifyByExamRecordDataId(Long examRecordDataId) {
|
|
|
- ExamFaceLivenessVerifyEntity examFaceVerifyEntity = examFaceLivenessVerifyRepo.findErrorFaceVerifyByExamRecordDataId(examRecordDataId);
|
|
|
- if(examFaceVerifyEntity !=null){
|
|
|
+ ExamFaceLivenessVerifyEntity examFaceVerifyEntity = examFaceLivenessVerifyRepo.findErrorFaceVerifyByExamRecordDataId(examRecordDataId);
|
|
|
+ if (examFaceVerifyEntity != null) {
|
|
|
examFaceVerifyEntity.setStartTime(new Date());
|
|
|
examFaceVerifyEntity.setIsError(false);
|
|
|
examFaceVerifyEntity.setErrorMsg(null);
|
|
|
- examFaceVerifyEntity.setOperateNum(examFaceVerifyEntity.getOperateNum().intValue()+1);
|
|
|
+ examFaceVerifyEntity.setOperateNum(examFaceVerifyEntity.getOperateNum().intValue() + 1);
|
|
|
return examFaceLivenessVerifyRepo.save(examFaceVerifyEntity);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
examFaceVerifyEntity = saveFaceVerify(examRecordDataId);
|
|
|
}
|
|
|
return examFaceVerifyEntity;
|
|
@@ -255,78 +251,79 @@ public class ExamFaceLivenessVerifyServiceImpl implements ExamFaceLivenessVerify
|
|
|
|
|
|
private MultipartEntityBuilder getMultipartEntityBuilder(String bizNo, File basePhotoFile) {
|
|
|
SysPropertyCacheBean sysProperty = CacheHelper.getSysProperty("app.faceid.notify_url");
|
|
|
- if (!sysProperty.getHasValue()){
|
|
|
- throw new StatusException("200001","未找到活体检测回调地址的配置信息");
|
|
|
+ if (!sysProperty.getHasValue()) {
|
|
|
+ throw new StatusException("200001", "未找到活体检测回调地址的配置信息");
|
|
|
}
|
|
|
- String faceidNotifyUrl=sysProperty.getValue().toString();
|
|
|
+ String faceidNotifyUrl = sysProperty.getValue().toString();
|
|
|
//详见:https://faceid.com/pages/documents/5680502
|
|
|
MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
|
|
|
- multipartEntityBuilder.addTextBody("api_key",faceIdApiKey);
|
|
|
- multipartEntityBuilder.addTextBody("api_secret",faceIdApiSecret);
|
|
|
+ multipartEntityBuilder.addTextBody("api_key", faceIdApiKey);
|
|
|
+ multipartEntityBuilder.addTextBody("api_secret", faceIdApiSecret);
|
|
|
multipartEntityBuilder.addTextBody("comparison_type", "0");
|
|
|
- multipartEntityBuilder.addTextBody("return_url",faceidNotifyUrl);
|
|
|
- multipartEntityBuilder.addTextBody("notify_url",faceidNotifyUrl);
|
|
|
- multipartEntityBuilder.addTextBody("biz_no",bizNo);
|
|
|
- multipartEntityBuilder.addTextBody("uuid",bizNo);
|
|
|
+ multipartEntityBuilder.addTextBody("return_url", faceidNotifyUrl);
|
|
|
+ multipartEntityBuilder.addTextBody("notify_url", faceidNotifyUrl);
|
|
|
+ multipartEntityBuilder.addTextBody("biz_no", bizNo);
|
|
|
+ multipartEntityBuilder.addTextBody("uuid", bizNo);
|
|
|
|
|
|
- multipartEntityBuilder.addBinaryBody("image_ref1",basePhotoFile);
|
|
|
+ multipartEntityBuilder.addBinaryBody("image_ref1", basePhotoFile);
|
|
|
return multipartEntityBuilder;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取学生底照文件
|
|
|
+ *
|
|
|
* @param studentId
|
|
|
* @return
|
|
|
*/
|
|
|
- private File getStudentBasePhotoFile(Long studentId){
|
|
|
+ private File getStudentBasePhotoFile(Long studentId) {
|
|
|
StudentCacheBean studentBean = CacheHelper.getStudent(studentId);
|
|
|
String photoUrl = studentBean.getPhotoPath();
|
|
|
- String photoName = photoUrl.substring(photoUrl.lastIndexOf("/")+1,photoUrl.length());
|
|
|
- FileDisposeUtil.saveUrlAs(photoUrl,photoName);
|
|
|
+ String photoName = photoUrl.substring(photoUrl.lastIndexOf("/") + 1, photoUrl.length());
|
|
|
+ FileDisposeUtil.saveUrlAs(photoUrl, photoName);
|
|
|
return new File(photoName);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public Integer getFaceLivenessVerifyMinute(Long orgId,Long examId,Long examRecordDataId, Integer heartbeat) {
|
|
|
- String isFaceVerifyStr = CacheHelper.getExamOrgProperty(examId,orgId,
|
|
|
+ @Override
|
|
|
+ public Integer getFaceLivenessVerifyMinute(Long orgId, Long examId, Long examRecordDataId, Integer heartbeat) {
|
|
|
+ String isFaceVerifyStr = CacheHelper.getExamOrgProperty(examId, orgId,
|
|
|
ExamProperties.IS_FACE_VERIFY.name()).getValue();
|
|
|
- //开启了人脸检测
|
|
|
- if(Constants.isTrue.equals(isFaceVerifyStr)){
|
|
|
-
|
|
|
- List<ExamFaceLivenessVerifyEntity> faceLivenessVerifys = listFaceVerifyByExamRecordId(examRecordDataId);
|
|
|
- //如果没有进行过人脸检测
|
|
|
- if(faceLivenessVerifys.size() == 0){
|
|
|
-
|
|
|
- String faceVerifyStartMinuteStr = CacheHelper.getExamOrgProperty(examId,orgId,
|
|
|
+ //开启了人脸检测
|
|
|
+ if (Constants.isTrue.equals(isFaceVerifyStr)) {
|
|
|
+
|
|
|
+ List<ExamFaceLivenessVerifyEntity> faceLivenessVerifys = listFaceVerifyByExamRecordId(examRecordDataId);
|
|
|
+ //如果没有进行过人脸检测
|
|
|
+ if (faceLivenessVerifys.size() == 0) {
|
|
|
+
|
|
|
+ String faceVerifyStartMinuteStr = CacheHelper.getExamOrgProperty(examId, orgId,
|
|
|
ExamProperties.FACE_VERIFY_START_MINUTE.name()).getValue();
|
|
|
- Integer faceVerifyStartMinute = Integer.valueOf(faceVerifyStartMinuteStr);
|
|
|
-
|
|
|
- String faceVerifyEndMinuteStr = CacheHelper.getExamOrgProperty(examId,orgId,
|
|
|
+ Integer faceVerifyStartMinute = Integer.valueOf(faceVerifyStartMinuteStr);
|
|
|
+
|
|
|
+ String faceVerifyEndMinuteStr = CacheHelper.getExamOrgProperty(examId, orgId,
|
|
|
ExamProperties.FACE_VERIFY_END_MINUTE.name()).getValue();
|
|
|
- Integer faceVerifyEndMinute = Integer.valueOf(faceVerifyEndMinuteStr);
|
|
|
- // case1.如果考生已使用的考试时间(即心跳时间)还未达到系统设置的活体检测开始时间,则实际活体检测时间=random(配置结束时间-配置结束时间)-考试已用时间
|
|
|
- if(heartbeat<faceVerifyStartMinute){
|
|
|
- return CommonUtil.calculationRandomNumber(faceVerifyStartMinute, faceVerifyEndMinute)-heartbeat;
|
|
|
- }
|
|
|
- // case2如果配置开始时间<考生已使用的考试时间<配置结束时间,则实际活体检测时间=random(配置结束时间-考试已用时间)-考试已用时间,如果结果小于1分钟则默认1分钟
|
|
|
- else if(heartbeat>=faceVerifyStartMinute&&heartbeat<faceVerifyEndMinute){
|
|
|
- int verifyTime = CommonUtil.calculationRandomNumber(heartbeat, faceVerifyEndMinute)-heartbeat;
|
|
|
- return verifyTime<1?1:verifyTime;
|
|
|
- }
|
|
|
- //case3如果考试已用时间>配置结束时间,则默认1分钟后开始人脸检测
|
|
|
- else if(heartbeat>=faceVerifyEndMinute){
|
|
|
- return CommonUtil.calculationRandomNumber(1, secondFaceCheckMinute);
|
|
|
- }
|
|
|
- }else if(faceLivenessVerifys.size()==1){
|
|
|
- //如果已经人脸检测过一次且未成功,再安排一次检测
|
|
|
- ExamFaceLivenessVerifyEntity faceVerify = faceLivenessVerifys.get(0);
|
|
|
- if(faceVerify.getVerifyResult()==null
|
|
|
- ||faceVerify.getVerifyResult() != FaceVerifyResult.VERIFY_SUCCESS){
|
|
|
- return CommonUtil.calculationRandomNumber(1, secondFaceCheckMinute);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return null;
|
|
|
- }
|
|
|
+ Integer faceVerifyEndMinute = Integer.valueOf(faceVerifyEndMinuteStr);
|
|
|
+ // case1.如果考生已使用的考试时间(即心跳时间)还未达到系统设置的活体检测开始时间,则实际活体检测时间=random(配置结束时间-配置结束时间)-考试已用时间
|
|
|
+ if (heartbeat < faceVerifyStartMinute) {
|
|
|
+ return CommonUtil.calculationRandomNumber(faceVerifyStartMinute, faceVerifyEndMinute) - heartbeat;
|
|
|
+ }
|
|
|
+ // case2如果配置开始时间<考生已使用的考试时间<配置结束时间,则实际活体检测时间=random(配置结束时间-考试已用时间)-考试已用时间,如果结果小于1分钟则默认1分钟
|
|
|
+ else if (heartbeat >= faceVerifyStartMinute && heartbeat < faceVerifyEndMinute) {
|
|
|
+ int verifyTime = CommonUtil.calculationRandomNumber(heartbeat, faceVerifyEndMinute) - heartbeat;
|
|
|
+ return verifyTime < 1 ? 1 : verifyTime;
|
|
|
+ }
|
|
|
+ //case3如果考试已用时间>配置结束时间,则默认1分钟后开始人脸检测
|
|
|
+ else if (heartbeat >= faceVerifyEndMinute) {
|
|
|
+ return CommonUtil.calculationRandomNumber(1, secondFaceCheckMinute);
|
|
|
+ }
|
|
|
+ } else if (faceLivenessVerifys.size() == 1) {
|
|
|
+ //如果已经人脸检测过一次且未成功,再安排一次检测
|
|
|
+ ExamFaceLivenessVerifyEntity faceVerify = faceLivenessVerifys.get(0);
|
|
|
+ if (faceVerify.getVerifyResult() == null
|
|
|
+ || faceVerify.getVerifyResult() != FaceVerifyResult.VERIFY_SUCCESS) {
|
|
|
+ return CommonUtil.calculationRandomNumber(1, secondFaceCheckMinute);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|