xiatian il y a 3 ans
Parent
commit
c15f278af5

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

@@ -23,6 +23,8 @@ import cn.com.qmth.examcloud.web.redis.RedisClient;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.json.JSONArray;
 import org.json.JSONException;
@@ -32,7 +34,6 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Example;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -733,6 +734,7 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
         for (ExamCaptureBean bean : examCaptures) {
             ExamCaptureEntity examCaptureEntity = copyExamCaptureFrom(bean, examRecordDataId);
             saveExamCaptureCameraInfo(examCaptureEntity);
+            examCaptureEntity.setCameraInfos(null);
             examCaptureRepo.saveAndFlush(examCaptureEntity);
         }
     }
@@ -755,7 +757,10 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
         		}else {
         			ci.setVirtualCamera(false);
         		}
-        		examCaptureCameraInfoRepo.saveAndFlush(ci);
+        		List<ExamCaptureCameraInfoEntity> olds=examCaptureCameraInfoRepo.findByExamRecordDataIdAndPidAndVidAndName(examCaptureEntity.getExamRecordDataId(),ci.getPid(),ci.getVid(),ci.getName());
+        		if(CollectionUtils.isEmpty(olds)) {
+        			examCaptureCameraInfoRepo.saveAndFlush(ci);
+        		}
             }
         } catch (Exception e) {
         	LOG.error("保存摄像信息失败:"+examCaptureEntity.getExamRecordDataId()+" "+examCaptureEntity.getCameraInfos(), e);

+ 3 - 0
examcloud-core-oe-admin-dao/src/main/java/cn/com/qmth/examcloud/core/oe/admin/dao/ExamCaptureCameraInfoRepo.java

@@ -20,5 +20,8 @@ public interface ExamCaptureCameraInfoRepo extends JpaRepository<ExamCaptureCame
 	List<ExamCaptureCameraInfoEntity> findByExamRecordDataIdAndVirtualCamera(Long examRecordDataId, boolean b);
 
 	List<ExamCaptureCameraInfoEntity> findByExamRecordDataIdInAndVirtualCamera(List<Long> ids, boolean b);
+
+	List<ExamCaptureCameraInfoEntity> findByExamRecordDataIdAndPidAndVidAndName(Long examRecordDataId, String pid, String vid,
+			String name);
 	
 }

+ 1 - 1
examcloud-core-oe-admin-dao/src/main/java/cn/com/qmth/examcloud/core/oe/admin/dao/entity/ExamCaptureCameraInfoEntity.java

@@ -20,7 +20,7 @@ import cn.com.qmth.examcloud.web.jpa.JpaEntity;
 @Table(name = "ec_oe_exam_capture_camera_info", indexes = {
         @Index(name = "IDX_OE_CCI_001", columnList = "examRecordDataId"),
         @Index(name = "IDX_OE_CCI_002", columnList = "name"),
-        @Index(name = "IDX_OE_CCI_003", columnList = "examRecordDataId,pid,vid,name", unique = true)
+        @Index(name = "IDX_OE_CCI_003", columnList = "examRecordDataId,pid,vid,name")
 })
 public class ExamCaptureCameraInfoEntity extends JpaEntity {