Browse Source

优化百度和face++代码

lideyin 5 years ago
parent
commit
2f16bcc051

+ 3 - 0
examcloud-core-oe-face-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/face/service/impl/BaiduFaceLivenessWorker.java

@@ -21,6 +21,9 @@ public class BaiduFaceLivenessWorker implements Worker {
     @Override
     public void process(WorkerController controller, Object element) {
         ExamCaptureProcessStatisticController.increaseFaceLivenessDetectCount();
+        if (captureLog.isDebugEnabled()){
+            captureLog.debug("[BAIDU_FACELIVENESS_WORKER.] 图片处理数量+1,count= " + ExamCaptureProcessStatisticController.getFaceLivenessDetectCount());
+        }
         ExamCaptureService examCaptureService = SpringContextHolder.getBean(ExamCaptureService.class);
         ExamCaptureQueueEntity examCaptureQueue = (ExamCaptureQueueEntity) element;
         try {

+ 2 - 1
examcloud-core-oe-face-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/face/service/impl/ExamCaptureServiceImpl.java

@@ -178,6 +178,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
                 examCaptureQueueService.saveExamCaptureQueueEntityByFailed(examCaptureQueue,
                         "SatusCode:" + jsonHttpResponseHolder.getStatusCode() + " | " + faceCompareResult.toString(), ExamCaptureQueueStatus.PROCESS_FACE_COMPARE_FAILED);
                 ExamCaptureProcessStatisticController.increaseFaceCompareFailedCount();//增加错误次数
+                captureLog.debug("[DISPOSE_FACE_COMPARE] face++人脸比对出现错误,增加错误次数后failedCount:" + ExamCaptureProcessStatisticController.getFaceCompareCount());
             } else {
                 //face++的结果检测到人脸,才执行百度活体检测
                 if (faceCompareResult.containsKey("confidence")) {
@@ -315,7 +316,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
                 examCaptureQueueService.saveExamCaptureQueueEntityByFailed(examCaptureQueue,
                         "SatusCode:" + jsonHttpResponseHolder.getStatusCode() + " | " + faceLivenessResultJson.toString(), ExamCaptureQueueStatus.PROCESS_FACELIVENESS_FAILED);
                 ExamCaptureProcessStatisticController.increaseFaceLivenessDetectFailedCount();//增加错误次数
-
+                captureLog.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活体检测出现错误,增加错误次数后failedCount:" + ExamCaptureProcessStatisticController.getFaceLivenessDetectFailedCount());
             }
             //百度活体检测成功,则保存最终检测结果,并删除临时的图片处理队列
             else {

+ 5 - 2
examcloud-core-oe-face-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/face/service/impl/FacePPCompareWorker.java

@@ -24,6 +24,9 @@ public class FacePPCompareWorker implements Worker {
     public void process(WorkerController controller, Object element) {
         //图片处理数量+1
         ExamCaptureProcessStatisticController.increaseFaceCompareCount();
+        if (captureLog.isDebugEnabled()){
+            captureLog.debug("[FACEPP_COMPARE_WORKER.] 图片处理数量+1,count= " + ExamCaptureProcessStatisticController.getFaceCompareCount());
+        }
         ExamCaptureService examCaptureService = SpringContextHolder
                 .getBean(ExamCaptureService.class);
         ExamCaptureQueueEntity examCaptureQueueEntity = (ExamCaptureQueueEntity) element;
@@ -38,14 +41,14 @@ public class FacePPCompareWorker implements Worker {
                 controller.addConcurrencyWarn();
             } else {
                 ExamCaptureProcessStatisticController.increaseFaceCompareFailedCount();
-                captureLog.error("[BAIDU_FACELIVENESS_WORKER.] 自定义异常 " + e.getDesc(), e);
+                captureLog.error("[FACEPP_COMPARE_WORKER.] 自定义异常 " + e.getDesc(), e);
             }
         } catch (Exception e) {
             ExamCaptureProcessStatisticController.increaseFaceCompareFailedCount();
             //异常处理
             examCaptureQueueEntity.setErrorMsg(e.getMessage());
             examCaptureService.disposeFaceCompareFaild(examCaptureQueueEntity);
-            captureLog.error("[BAIDU_FACELIVENESS_WORKER.] 系统异常 " + e.getMessage(), e);
+            captureLog.error("[FACEPP_COMPARE_WORKER.] 系统异常 " + e.getMessage(), e);
         }
     }
 }

+ 29 - 7
examcloud-core-oe-face-starter/src/main/java/cn/com/qmth/examcloud/core/oe/student/face/starter/config/ProcessPhotoAlarmTask.java

@@ -52,18 +52,28 @@ public class ProcessPhotoAlarmTask implements ApplicationRunner {
      */
     private void faceCompareAlarm() {
         while (true) {
-            captureLog.debug("[FACE_COMPARE_ALARM] 进入人脸" + System.currentTimeMillis() + "....totalCount=" +
-                    ExamCaptureProcessStatisticController.getFaceCompareCount() + " ,failCount=" +
-                    ExamCaptureProcessStatisticController.getFaceCompareFailedCount());
+            if (captureLog.isDebugEnabled()){
+                captureLog.debug("[FACE_COMPARE_ALARM] 进入人脸" + System.currentTimeMillis() + "....totalCount=" +
+                        ExamCaptureProcessStatisticController.getFaceCompareCount() + " ,failCount=" +
+                        ExamCaptureProcessStatisticController.getFaceCompareFailedCount());
+            }
+
             //如果每分钟失败率超过50%则发短信报警,且总数不少于10次则短信报警
             if (ExamCaptureProcessStatisticController.getFaceCompareCount() > COUNT_WARN_THRESHOLD &&
                     ExamCaptureProcessStatisticController.getFaceCompareFailureRate() > RATE_WARN_THRESHOLD) {
                 SysPropertyCacheBean faceCompareSmsAssemblyCodeProperty = CacheHelper.getSysProperty("capture.faceCompare.smsAssemblyCode");
+
                 if (!faceCompareSmsAssemblyCodeProperty.getHasValue()) {
+                    if (captureLog.isErrorEnabled()){
+                        captureLog.error("[FACE_COMPARE_ALARM.] 未配置人脸比对的短信模板代码,totalCount="+ExamCaptureProcessStatisticController.getFaceCompareCount()+",errorCount="+ExamCaptureProcessStatisticController.getFaceCompareFailedCount());
+                    }
                     throw new StatusException("300001", "未配置人脸比对的短信模板代码");
                 }
                 SysPropertyCacheBean smsPhoneProperty = CacheHelper.getSysProperty("capture.sms.phones");
                 if (!smsPhoneProperty.getHasValue()) {
+                    if (captureLog.isErrorEnabled()){
+                        captureLog.error("[FACE_COMPARE_ALARM.] 未配置图片处理失败的通知手机号,totalCount="+ExamCaptureProcessStatisticController.getFaceCompareCount()+",errorCount="+ExamCaptureProcessStatisticController.getFaceCompareFailedCount());
+                    }
                     throw new StatusException("300002", "未配置图片处理失败的通知手机号");
                 }
 
@@ -79,9 +89,12 @@ public class ProcessPhotoAlarmTask implements ApplicationRunner {
                 params.put("errorCount", String.valueOf(ExamCaptureProcessStatisticController.getFaceCompareFailedCount()));
                 sendSmsReq.setParams(params);
                 try {
+                    if (captureLog.isDebugEnabled()){
+                        captureLog.debug("[FACE_COMPARE_ALARM.] 开始调用发送短信接口,totalCount="+ExamCaptureProcessStatisticController.getFaceCompareCount()+",errorCount="+ExamCaptureProcessStatisticController.getFaceCompareFailedCount());
+                    }
                     smsCloudService.sendSms(sendSmsReq);
                 } catch (Exception e) {
-                    captureLog.error("[PROCESS_FACEPP.] 发送短信出现异常", e);
+                    captureLog.error("[FACE_COMPARE_ALARM.] 发送短信出现异常", e);
                 }
             }
             //每1分钟重置一次总数量与失败数量
@@ -99,18 +112,27 @@ public class ProcessPhotoAlarmTask implements ApplicationRunner {
      */
     private void faceLivenessDectectAlarm() {
         while (true) {
-            captureLog.debug("[FACE_COMPARE_ALARM] 进入活体检测" + System.currentTimeMillis() + "....totalCount=" +
-                    ExamCaptureProcessStatisticController.getFaceLivenessDetectCount() + " ,failCount=" +
-                    ExamCaptureProcessStatisticController.getFaceLivenessDetectFailedCount());
+            if (captureLog.isDebugEnabled()){
+                captureLog.debug("[FACE_LIVENESS_ALARM] 进入活体检测" + System.currentTimeMillis() + "....totalCount=" +
+                        ExamCaptureProcessStatisticController.getFaceLivenessDetectCount() + " ,failCount=" +
+                        ExamCaptureProcessStatisticController.getFaceLivenessDetectFailedCount());
+            }
+
             //如果每分钟失败率超过50%则发短信报警,且总数不少于10次则短信报警
             if (ExamCaptureProcessStatisticController.getFaceLivenessDetectCount() > COUNT_WARN_THRESHOLD &&
                     ExamCaptureProcessStatisticController.getFaceLivenessDetectFailureRate() > RATE_WARN_THRESHOLD) {
                 SysPropertyCacheBean faceLivenessSmsAssemblyCodeProperty = CacheHelper.getSysProperty("capture.faceLiveness.smsAssemblyCode");
                 if (!faceLivenessSmsAssemblyCodeProperty.getHasValue()) {
+                    if (captureLog.isErrorEnabled()){
+                        captureLog.error("[FACE_LIVENESS_ALARM.] 未配置人脸比对的短信模板代码,totalCount="+ExamCaptureProcessStatisticController.getFaceCompareCount()+",errorCount="+ExamCaptureProcessStatisticController.getFaceCompareFailedCount());
+                    }
                     throw new StatusException("300003", "未配置人脸活体检测的短信模板代码");
                 }
                 SysPropertyCacheBean smsPhoneProperty = CacheHelper.getSysProperty("capture.sms.phones");
                 if (!smsPhoneProperty.getHasValue()) {
+                    if (captureLog.isErrorEnabled()){
+                        captureLog.error("[FACE_LIVENESS_ALARM.] 未配置图片处理失败的通知手机号,totalCount="+ExamCaptureProcessStatisticController.getFaceCompareCount()+",errorCount="+ExamCaptureProcessStatisticController.getFaceCompareFailedCount());
+                    }
                     throw new StatusException("300004", "未配置图片处理失败的通知手机号");
                 }