소스 검색

vid或pid任一个空为虚拟设备

xiatian 3 년 전
부모
커밋
fbe75eb9d4

+ 2 - 1
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/provider/SyncExamDataCloudServiceProvider.java

@@ -755,7 +755,8 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
         		ci.setName(getVal(jsonObject, "name"));
         		ci.setPid(getVal(jsonObject, "pid"));
         		ci.setVid(getVal(jsonObject, "vid"));
-        		if (jsonObject.isNull("pid") || StringUtils.isBlank(jsonObject.getString("pid"))) {
+        		if (jsonObject.isNull("pid") || StringUtils.isBlank(jsonObject.getString("pid"))
+        				||jsonObject.isNull("vid") || StringUtils.isBlank(jsonObject.getString("vid"))) {
         			ci.setVirtualCamera(true);
         		}else {
         			ci.setVirtualCamera(false);

+ 31 - 33
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamCaptureServiceImpl.java

@@ -7,7 +7,6 @@
 
 package cn.com.qmth.examcloud.core.oe.admin.service.impl;
 
-import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.core.oe.admin.dao.ExamCaptureCameraInfoRepo;
 import cn.com.qmth.examcloud.core.oe.admin.dao.ExamCaptureRepo;
 import cn.com.qmth.examcloud.core.oe.admin.dao.ExamRecordDataRepo;
@@ -30,7 +29,6 @@ import cn.com.qmth.examcloud.support.helper.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import com.google.common.collect.Lists;
 import org.apache.commons.lang3.StringUtils;
-import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.slf4j.Logger;
@@ -214,40 +212,40 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
         String faceLivenessResult = entity.getFacelivenessResult();
         info.setIsFacelivenessPass(isFaceLivenessPass(faceLivenessResult));
 
-        String cameraInfos = entity.getCameraInfos();
-        info.setVirtualCameraNames(getVirtualCameraNames(cameraInfos));
+//        String cameraInfos = entity.getCameraInfos();
+//        info.setVirtualCameraNames(getVirtualCameraNames(cameraInfos));
         return info;
     }
 
-    private String getVirtualCameraNames(String cameraInfos) {
-        StringBuffer sb = new StringBuffer();
-        if (StringUtils.isNotBlank(cameraInfos)) {
-            JSONArray jsonArray;
-            try {
-                jsonArray = new JSONArray(cameraInfos);
-                for (int i = 0; i < jsonArray.length(); i++) {
-                    try {
-                        JSONObject jsonObject = (JSONObject) jsonArray.get(i);
-                        if (jsonObject.isNull("pid") || StringUtils.isBlank(jsonObject.getString("pid"))) {
-                            sb.append(jsonObject.getString("name") + ",");
-                        }
-                    } catch (JSONException e) {
-                        //主要针对json数组最后的空对象处理,不影响业务eg:"[   {      \"name\" : \"Camera\",      \"pid\" : \"\",      \"vid\" : \"\"   },]";
-                        LOG.error("抓拍照片格式不正确", e);
-                        continue;
-                    }
-                }
-            } catch (JSONException e) {
-                LOG.error("获取虚拟摄像头名称失败", e);
-                throw new StatusException("ExamCaptureService-002", "获取虚拟摄像头名称失败");
-            }
-
-            if (sb.lastIndexOf(",") > -1) {
-                return sb.substring(0, sb.lastIndexOf(","));
-            }
-        }
-        return sb.toString();
-    }
+//    private String getVirtualCameraNames(String cameraInfos) {
+//        StringBuffer sb = new StringBuffer();
+//        if (StringUtils.isNotBlank(cameraInfos)) {
+//            JSONArray jsonArray;
+//            try {
+//                jsonArray = new JSONArray(cameraInfos);
+//                for (int i = 0; i < jsonArray.length(); i++) {
+//                    try {
+//                        JSONObject jsonObject = (JSONObject) jsonArray.get(i);
+//                        if (jsonObject.isNull("pid") || StringUtils.isBlank(jsonObject.getString("pid"))) {
+//                            sb.append(jsonObject.getString("name") + ",");
+//                        }
+//                    } catch (JSONException e) {
+//                        //主要针对json数组最后的空对象处理,不影响业务eg:"[   {      \"name\" : \"Camera\",      \"pid\" : \"\",      \"vid\" : \"\"   },]";
+//                        LOG.error("抓拍照片格式不正确", e);
+//                        continue;
+//                    }
+//                }
+//            } catch (JSONException e) {
+//                LOG.error("获取虚拟摄像头名称失败", e);
+//                throw new StatusException("ExamCaptureService-002", "获取虚拟摄像头名称失败");
+//            }
+//
+//            if (sb.lastIndexOf(",") > -1) {
+//                return sb.substring(0, sb.lastIndexOf(","));
+//            }
+//        }
+//        return sb.toString();
+//    }
 
     private boolean isFaceLivenessPass(String faceLivenessResult) {
         if (StringUtils.isNotBlank(faceLivenessResult)) {