|
@@ -21,6 +21,7 @@ import cn.com.qmth.examcloud.support.cache.bean.SysPropertyCacheBean;
|
|
|
import cn.com.qmth.examcloud.web.baidu.BaiduClient;
|
|
|
import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
|
|
|
import cn.com.qmth.examcloud.web.facepp.FaceppClient;
|
|
|
+import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import org.apache.commons.io.IOUtils;
|
|
@@ -69,11 +70,11 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
@Autowired
|
|
|
private GainBaseDataService gainBaseDataService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private RedisTemplate<String, Object> redisTemplate;
|
|
|
-
|
|
|
public static final String TEMP_FILE_EXP = "face_compare/";
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisClient redisClient;
|
|
|
+
|
|
|
/**
|
|
|
* 对图片进行人脸对比
|
|
|
*
|
|
@@ -359,6 +360,43 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
examCaptureQueueRepo.deleteById(examCaptureQueue.getId());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存同步比较的抓拍照片结果
|
|
|
+ *
|
|
|
+ * @param studentId 学生id
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void saveExamCaptureSyncCompareResult(Long studentId,Long examRecordDataId) {
|
|
|
+ String syncCopareResultkey = Constants.FACE_SYNC_COMPARE_RESULT_PREFIX + studentId;
|
|
|
+ CompareFaceSyncInfo compareFaceSyncInfo =
|
|
|
+ redisClient.get(syncCopareResultkey, CompareFaceSyncInfo.class);
|
|
|
+ if (compareFaceSyncInfo == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ ExamCaptureEntity examCaptureEntity = new ExamCaptureEntity();
|
|
|
+ examCaptureEntity.setExamRecordDataId(examRecordDataId);
|
|
|
+ examCaptureEntity.setFaceCompareResult(compareFaceSyncInfo.getFaceCompareResult());
|
|
|
+ examCaptureEntity.setFileName(compareFaceSyncInfo.getFileName());
|
|
|
+ examCaptureEntity.setFileUrl(compareFaceSyncInfo.getFileUrl());
|
|
|
+ examCaptureEntity.setIsStranger(compareFaceSyncInfo.getIsStranger());
|
|
|
+ examCaptureEntity.setIsPass(compareFaceSyncInfo.getIsPass());
|
|
|
+ examCaptureEntity.setProcessTime(compareFaceSyncInfo.getProcessTime());
|
|
|
+
|
|
|
+ //同一考试记录下如果有重复的照片,则直接跳过
|
|
|
+ ExamCaptureEntity query = new ExamCaptureEntity();
|
|
|
+ query.setExamRecordDataId(examRecordDataId);
|
|
|
+ query.setFileName(compareFaceSyncInfo.getFileName());
|
|
|
+ Example<ExamCaptureEntity> example = Example.of(query);
|
|
|
+ //照片处理结果中如果已存在,则以已有的数据为准
|
|
|
+ if (!examCaptureRepo.exists(example)) {
|
|
|
+ examCaptureRepo.save(examCaptureEntity);
|
|
|
+ }
|
|
|
+ //删除redis中的同步数据
|
|
|
+ redisClient.delete(syncCopareResultkey);
|
|
|
+ }
|
|
|
+
|
|
|
private ExamCaptureEntity getExamCaptureFromQueue(ExamCaptureQueueInfo queue) {
|
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
|
long createTimeMillis = queue.getCreationTime().getTime();
|
|
@@ -432,6 +470,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
return compareFaceSyncInfo;
|
|
|
}
|
|
|
if (facePPResult.containsKey(Constants.ERROR_MSG)) {
|
|
|
+ compareFaceSyncInfo.setFaceCompareResult(facePPResult.toString());
|
|
|
compareFaceSyncInfo.setIsPass(false);
|
|
|
String errMsg = facePPResult.getString(Constants.ERROR_MSG);
|
|
|
if (errMsg.contains(Constants.FACE_COMPARE_CONCURRENCY_LIMIT_EXCEEDED) ||
|
|
@@ -441,6 +480,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
compareFaceSyncInfo.setErrorMsg(facePPResult.toString());
|
|
|
return compareFaceSyncInfo;
|
|
|
} else {
|
|
|
+ compareFaceSyncInfo.setFaceCompareResult(facePPResult.toString());
|
|
|
if (facePPResult.containsKey("confidence")) {
|
|
|
double confidence = facePPResult.getDouble("confidence");
|
|
|
JSONObject thresholdsJsonObject = facePPResult.getJSONObject("thresholds");
|