|
@@ -32,26 +32,26 @@ import java.util.*;
|
|
|
*/
|
|
|
@Service("examCaptureQueueService")
|
|
|
public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
|
|
|
-
|
|
|
- private static final Logger log = LoggerFactory.getLogger(ExamCaptureQueueServiceImpl.class);
|
|
|
+
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(ExamCaptureQueueServiceImpl.class);
|
|
|
|
|
|
@Autowired
|
|
|
private ExamCaptureQueueRepo examCaptureQueueRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private FaceCloudService faceCloudService;
|
|
|
-
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FaceCloudService faceCloudService;
|
|
|
+
|
|
|
/**
|
|
|
* 一次启动的线程个数
|
|
|
*/
|
|
|
@Value("${$capture.thread.num}")
|
|
|
- private int threadNum;
|
|
|
-
|
|
|
+ private int threadNum;
|
|
|
+
|
|
|
/**
|
|
|
* 一次从数据库取出的最大记录数
|
|
|
*/
|
|
|
@Value("${$capture.queue.limit:200}")
|
|
|
- private int queueLimit;
|
|
|
+ private int queueLimit;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -78,97 +78,98 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
|
|
|
@Override
|
|
|
public void changeExamCaptureQueueStatus() {
|
|
|
long nowTime = System.currentTimeMillis();
|
|
|
- int queueTimeOut = PropertyHolder.getInt("$capture.process.timeout",5);
|
|
|
+ int queueTimeOut = PropertyHolder.getInt("$capture.process.timeout", 5);
|
|
|
List<ExamCaptureQueueEntity> examCaptureQueueList = examCaptureQueueRepo.findByStatusOrderByCreationTimeAsc(ExamCaptureQueueStatus.PROCESSING);
|
|
|
List<ExamCaptureQueueEntity> newExamCaptureQueueList = new ArrayList<ExamCaptureQueueEntity>();
|
|
|
- for(ExamCaptureQueueEntity examCaptureQueue:examCaptureQueueList){
|
|
|
- if(nowTime-examCaptureQueue.getCreationTime().getTime()>queueTimeOut*60*1000){
|
|
|
- examCaptureQueue.setStatus(ExamCaptureQueueStatus.PENDING);//重置为 待处理
|
|
|
+ for (ExamCaptureQueueEntity examCaptureQueue : examCaptureQueueList) {
|
|
|
+ if (nowTime - examCaptureQueue.getCreationTime().getTime() > queueTimeOut * 60 * 1000) {
|
|
|
+ examCaptureQueue.setStatus(ExamCaptureQueueStatus.PENDING);//重置为 待处理
|
|
|
newExamCaptureQueueList.add(examCaptureQueue);
|
|
|
}
|
|
|
}
|
|
|
examCaptureQueueRepo.saveAll(newExamCaptureQueueList);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void saveExamCaptureQueueEntityByFailed(ExamCaptureQueueEntity examCaptureQueueEntity, String errorMsg,ExamCaptureQueueStatus examCaptureQueueStatus) {
|
|
|
- examCaptureQueueEntity.setErrorMsg(errorMsg);
|
|
|
- examCaptureQueueEntity.setStatus(examCaptureQueueStatus);
|
|
|
- examCaptureQueueEntity.setUpdateTime(new Date());
|
|
|
- int errorNum = examCaptureQueueEntity.getErrorNum()==null?0:examCaptureQueueEntity.getErrorNum();
|
|
|
- examCaptureQueueEntity.setErrorNum(errorNum+1);
|
|
|
- examCaptureQueueEntity.setProcessBatchNum("000000");
|
|
|
- examCaptureQueueRepo.save(examCaptureQueueEntity);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public String saveExamCaptureQueue(SaveExamCaptureQueueInfo saveExamCaptureQueueInfo,Long studentId) {
|
|
|
- //查询学生底照faceToken
|
|
|
- StudentCacheBean studentCache = CacheHelper.getStudent(studentId);
|
|
|
- String baseFaceToken = studentCache.getFaceToken();
|
|
|
- Check.isBlank(baseFaceToken, "学生底照的faceToken为空");
|
|
|
+ @Override
|
|
|
+ public void saveExamCaptureQueueEntityByFailed(ExamCaptureQueueEntity examCaptureQueueEntity,
|
|
|
+ String errorMsg, ExamCaptureQueueStatus examCaptureQueueStatus) {
|
|
|
+ examCaptureQueueEntity.setErrorMsg(errorMsg);
|
|
|
+ examCaptureQueueEntity.setStatus(examCaptureQueueStatus);
|
|
|
+ examCaptureQueueEntity.setUpdateTime(new Date());
|
|
|
+ int errorNum = examCaptureQueueEntity.getErrorNum() == null ? 0 : examCaptureQueueEntity.getErrorNum();
|
|
|
+ examCaptureQueueEntity.setErrorNum(errorNum + 1);
|
|
|
+ examCaptureQueueEntity.setProcessBatchNum("000000");
|
|
|
+ examCaptureQueueRepo.save(examCaptureQueueEntity);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String saveExamCaptureQueue(SaveExamCaptureQueueInfo saveExamCaptureQueueInfo, Long studentId) {
|
|
|
+ //查询学生底照faceToken
|
|
|
+ StudentCacheBean studentCache = CacheHelper.getStudent(studentId);
|
|
|
+ String baseFaceToken = studentCache.getFaceToken();
|
|
|
+ Check.isBlank(baseFaceToken, "学生底照的faceToken为空");
|
|
|
|
|
|
// AES aes = new AES();
|
|
|
- //解密fileUrl
|
|
|
+ //解密fileUrl
|
|
|
// String fileUrl = aes.decrypt(saveExamCaptureQueueInfo.getFileUrl());
|
|
|
- String fileUrl = UrlUtil.decode(saveExamCaptureQueueInfo.getFileUrl());
|
|
|
- if(!StringUtil.isAscString(fileUrl)){
|
|
|
- log.error("The fileUrl is invalid:"+saveExamCaptureQueueInfo.getFileUrl());
|
|
|
- throw new StatusException("300001","文件路径格式不正确");
|
|
|
- }
|
|
|
- String fileName = fileUrl.substring(fileUrl.lastIndexOf("/")+1, fileUrl.length());
|
|
|
-
|
|
|
- ExamCaptureQueueEntity examCaptureQueue = new ExamCaptureQueueEntity();
|
|
|
- examCaptureQueue.setStudentId(studentId);
|
|
|
- examCaptureQueue.setFileUrl(fileUrl);
|
|
|
- examCaptureQueue.setFileName(fileName);
|
|
|
- examCaptureQueue.setBaseFaceToken(baseFaceToken);
|
|
|
- examCaptureQueue.setExamRecordDataId(saveExamCaptureQueueInfo.getExamRecordDataId());
|
|
|
- examCaptureQueue.setHasVirtualCamera(saveExamCaptureQueueInfo.getHasVirtualCamera());
|
|
|
- examCaptureQueue.setCameraInfos(saveExamCaptureQueueInfo.getCameraInfos());
|
|
|
- examCaptureQueue.setExtMsg(saveExamCaptureQueueInfo.getExtMsg());
|
|
|
+ String fileUrl = UrlUtil.decode(saveExamCaptureQueueInfo.getFileUrl());
|
|
|
+ if (!StringUtil.isAscString(fileUrl)) {
|
|
|
+ log.error("The fileUrl is invalid:" + saveExamCaptureQueueInfo.getFileUrl());
|
|
|
+ throw new StatusException("300001", "文件路径格式不正确");
|
|
|
+ }
|
|
|
+ String fileName = fileUrl.substring(fileUrl.lastIndexOf("/") + 1, fileUrl.length());
|
|
|
+
|
|
|
+ ExamCaptureQueueEntity examCaptureQueue = new ExamCaptureQueueEntity();
|
|
|
+ examCaptureQueue.setStudentId(studentId);
|
|
|
+ examCaptureQueue.setFileUrl(fileUrl);
|
|
|
+ examCaptureQueue.setFileName(fileName);
|
|
|
+ examCaptureQueue.setBaseFaceToken(baseFaceToken);
|
|
|
+ examCaptureQueue.setExamRecordDataId(saveExamCaptureQueueInfo.getExamRecordDataId());
|
|
|
+ examCaptureQueue.setHasVirtualCamera(saveExamCaptureQueueInfo.getHasVirtualCamera());
|
|
|
+ examCaptureQueue.setCameraInfos(saveExamCaptureQueueInfo.getCameraInfos());
|
|
|
+ examCaptureQueue.setExtMsg(saveExamCaptureQueueInfo.getExtMsg());
|
|
|
examCaptureQueue.setStatus(ExamCaptureQueueStatus.PENDING);
|
|
|
examCaptureQueue.setErrorNum(0);
|
|
|
examCaptureQueue.setCreationTime(new Date());
|
|
|
examCaptureQueueRepo.save(examCaptureQueue);
|
|
|
return fileName;
|
|
|
- }
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- Map<String, String> maps = new HashMap<String, String>();
|
|
|
- maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d374bbd39e3f9ea015abee61fa4f76633cc25fc7ed1c78e238504ce96d4ae7387c", "3128451");
|
|
|
- maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d374bbd39e3f9ea015abee61fa4f76633c29837bbd269707405ea488f66da1ac62","3128451");
|
|
|
- maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d374bbd39e3f9ea015abee61fa4f76633c6a82cb34ce4255959c94631810163f50","3128451 ");
|
|
|
- maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d374bbd39e3f9ea015abee61fa4f76633c9769c30d115e755f3cbc1f9d0a39e736","3128490 ");
|
|
|
- maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d374bbd39e3f9ea015abee61fa4f76633cf53d05df77c751ff631ed2f2d97e2b6c","3128490 ");
|
|
|
- maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d38781c711ec73032b53bfefd151d9960f0bd747235a4510d179d2e46db7ef1a0e","3128531 ");
|
|
|
- maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d38781c711ec73032b53bfefd151d9960f73c618429fb5902a19e793ab5b1a341f","3128531 ");
|
|
|
- maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d38781c711ec73032b53bfefd151d9960f2145e4f9fd766e07d11784d6eea6708a","3128545 ");
|
|
|
- maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d38781c711ec73032b53bfefd151d9960f5f5045b1a9e92a1a58672a1588112cc4","3128545 ");
|
|
|
- maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d38781c711ec73032b53bfefd151d9960f9cc90589d78a800afa44d9e28f5e0165","3128563 ");
|
|
|
- maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d38781c711ec73032b53bfefd151d9960f56cd9130daba0ba797e74614e3f809d7","3128563 ");
|
|
|
-
|
|
|
- Set<String> fileUrls = maps.keySet();
|
|
|
- Map<String,Integer> countMap = new HashMap<String, Integer>();
|
|
|
- for(String fileUrl:fileUrls){
|
|
|
- AES aes = new AES();
|
|
|
- String url = aes.decrypt(fileUrl.trim());
|
|
|
- String fileName = url.substring(url.lastIndexOf("/")+1, url.length());
|
|
|
- String examRecordDataId = maps.get(fileUrl).trim();
|
|
|
- String sql = "INSERT INTO `ec_oe_exam_capture` (`exam_record_data_id`, `file_name`, `file_url`, `is_stranger`, `is_pass`, `creation_time`, `update_time`,`ext_msg`) "
|
|
|
- + " VALUES"
|
|
|
- +"('"+examRecordDataId+"', '"+fileName+"', '"+url+"', b'0', '1',NOW(),NOW(), '手动修改');";
|
|
|
- System.out.println(sql);
|
|
|
- Integer num = countMap.get(examRecordDataId);
|
|
|
- countMap.put(examRecordDataId, num==null?1:num+1);
|
|
|
- }
|
|
|
-
|
|
|
- Set<String> examRecordDataIdNums = countMap.keySet();
|
|
|
- for(String examRecordDataId:examRecordDataIdNums){
|
|
|
- int num = countMap.get(examRecordDataId);
|
|
|
- String sql = "update ec_oe_exam_record_data set face_total_count = "+num+",face_success_count = "+num+",face_success_percent=100,baidu_face_liveness_success_percent=100 where id = "+examRecordDataId+";";
|
|
|
- System.out.println(sql);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ Map<String, String> maps = new HashMap<String, String>();
|
|
|
+ maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d374bbd39e3f9ea015abee61fa4f76633cc25fc7ed1c78e238504ce96d4ae7387c", "3128451");
|
|
|
+ maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d374bbd39e3f9ea015abee61fa4f76633c29837bbd269707405ea488f66da1ac62", "3128451");
|
|
|
+ maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d374bbd39e3f9ea015abee61fa4f76633c6a82cb34ce4255959c94631810163f50", "3128451 ");
|
|
|
+ maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d374bbd39e3f9ea015abee61fa4f76633c9769c30d115e755f3cbc1f9d0a39e736", "3128490 ");
|
|
|
+ maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d374bbd39e3f9ea015abee61fa4f76633cf53d05df77c751ff631ed2f2d97e2b6c", "3128490 ");
|
|
|
+ maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d38781c711ec73032b53bfefd151d9960f0bd747235a4510d179d2e46db7ef1a0e", "3128531 ");
|
|
|
+ maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d38781c711ec73032b53bfefd151d9960f73c618429fb5902a19e793ab5b1a341f", "3128531 ");
|
|
|
+ maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d38781c711ec73032b53bfefd151d9960f2145e4f9fd766e07d11784d6eea6708a", "3128545 ");
|
|
|
+ maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d38781c711ec73032b53bfefd151d9960f5f5045b1a9e92a1a58672a1588112cc4", "3128545 ");
|
|
|
+ maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d38781c711ec73032b53bfefd151d9960f9cc90589d78a800afa44d9e28f5e0165", "3128563 ");
|
|
|
+ maps.put("35d2ccfa922c406f45acc7b1bad1d9edf72391cd2208312906129712f5215f75db9c6f1ab31974bf2a7d590e677655d38781c711ec73032b53bfefd151d9960f56cd9130daba0ba797e74614e3f809d7", "3128563 ");
|
|
|
+
|
|
|
+ Set<String> fileUrls = maps.keySet();
|
|
|
+ Map<String, Integer> countMap = new HashMap<String, Integer>();
|
|
|
+ for (String fileUrl : fileUrls) {
|
|
|
+ AES aes = new AES();
|
|
|
+ String url = aes.decrypt(fileUrl.trim());
|
|
|
+ String fileName = url.substring(url.lastIndexOf("/") + 1, url.length());
|
|
|
+ String examRecordDataId = maps.get(fileUrl).trim();
|
|
|
+ String sql = "INSERT INTO `ec_oe_exam_capture` (`exam_record_data_id`, `file_name`, `file_url`, `is_stranger`, `is_pass`, `creation_time`, `update_time`,`ext_msg`) "
|
|
|
+ + " VALUES"
|
|
|
+ + "('" + examRecordDataId + "', '" + fileName + "', '" + url + "', b'0', '1',NOW(),NOW(), '手动修改');";
|
|
|
+ System.out.println(sql);
|
|
|
+ Integer num = countMap.get(examRecordDataId);
|
|
|
+ countMap.put(examRecordDataId, num == null ? 1 : num + 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<String> examRecordDataIdNums = countMap.keySet();
|
|
|
+ for (String examRecordDataId : examRecordDataIdNums) {
|
|
|
+ int num = countMap.get(examRecordDataId);
|
|
|
+ String sql = "update ec_oe_exam_record_data set face_total_count = " + num + ",face_success_count = " + num + ",face_success_percent=100,baidu_face_liveness_success_percent=100 where id = " + examRecordDataId + ";";
|
|
|
+ System.out.println(sql);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|