wangliang 4 роки тому
батько
коміт
0963b2e46c

+ 7 - 1
themis-business/src/main/java/com/qmth/themis/business/enums/FieldUniqueEnum.java

@@ -25,7 +25,9 @@ public enum FieldUniqueEnum {
 
     t_b_exam_invigilate_user_orgId_userId_roomCode_Idx("监考员"),
 
-    t_b_user_loginName_orgId_Idx("用户名");
+    t_b_user_loginName_orgId_Idx("用户名"),
+
+    t_ie_exam_invigilate_call_recordId_source_Idx("监考视频源");
 
     private String code;
 
@@ -60,6 +62,8 @@ public enum FieldUniqueEnum {
             return t_b_exam_invigilate_user_orgId_userId_roomCode_Idx.name();
         } else if (Objects.equals(value.trim(), t_b_user_loginName_orgId_Idx.code)) {
             return t_b_user_loginName_orgId_Idx.name();
+        } else if (Objects.equals(value.trim(), t_ie_exam_invigilate_call_recordId_source_Idx.code)) {
+            return t_ie_exam_invigilate_call_recordId_source_Idx.name();
         } else {
             return t_e_exam_activity_examId_code_Idx.name();
         }
@@ -88,6 +92,8 @@ public enum FieldUniqueEnum {
             return t_b_exam_invigilate_user_orgId_userId_roomCode_Idx.code;
         } else if (value.trim().contains(t_b_user_loginName_orgId_Idx.name())) {
             return t_b_user_loginName_orgId_Idx.code;
+        } else if (value.trim().contains(t_ie_exam_invigilate_call_recordId_source_Idx.name())) {
+            return t_ie_exam_invigilate_call_recordId_source_Idx.code;
         } else {
             return t_e_exam_activity_examId_code_Idx.code;
         }

+ 39 - 14
themis-exam/src/main/java/com/qmth/themis/exam/api/TIeInvigilateCallController.java

@@ -5,6 +5,7 @@ import com.qmth.themis.business.annotation.ApiJsonObject;
 import com.qmth.themis.business.annotation.ApiJsonProperty;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.entity.TIeExamInvigilateCall;
+import com.qmth.themis.business.enums.FieldUniqueEnum;
 import com.qmth.themis.business.service.TIeExamInvigilateCallService;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
@@ -13,11 +14,9 @@ import com.qmth.themis.common.util.ResultUtil;
 import io.swagger.annotations.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.dao.DuplicateKeyException;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.HashMap;
@@ -53,17 +52,31 @@ public class TIeInvigilateCallController {
         if (Objects.isNull(mapParameter.get("recordId")) || Objects.equals(mapParameter.get("recordId"), "")) {
             throw new BusinessException(ExceptionResultEnum.RECORD_ID_IS_NULL);
         }
-        Long recordId = Long.parseLong(String.valueOf(mapParameter.get("recordId")));
-        if (Objects.isNull(mapParameter.get("source")) || Objects.equals(mapParameter.get("source"), "")) {
-            throw new BusinessException("监考视频源不能为空");
-        }
-        String source = String.valueOf(mapParameter.get("source"));
-        if (Objects.isNull(mapParameter.get("liveUrl")) || Objects.equals(mapParameter.get("liveUrl"), "")) {
-            throw new BusinessException("观看地址不能为空");
+        Long recordId = null;
+        try {
+            recordId = Long.parseLong(String.valueOf(mapParameter.get("recordId")));
+            if (Objects.isNull(mapParameter.get("source")) || Objects.equals(mapParameter.get("source"), "")) {
+                throw new BusinessException("监考视频源不能为空");
+            }
+            String source = String.valueOf(mapParameter.get("source"));
+            if (Objects.isNull(mapParameter.get("liveUrl")) || Objects.equals(mapParameter.get("liveUrl"), "")) {
+                throw new BusinessException("观看地址不能为空");
+            }
+            String liveUrl = String.valueOf(mapParameter.get("liveUrl"));
+            TIeExamInvigilateCall tIeExamInvigilateCall = new TIeExamInvigilateCall(recordId, source, liveUrl);
+            tIeExamInvigilateCallService.save(tIeExamInvigilateCall);
+        } catch (Exception e) {
+            e.printStackTrace();
+            if (e instanceof DuplicateKeyException) {
+                String errorColumn = e.getCause().toString();
+                String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
+                throw new BusinessException("考试记录id[" + recordId + "]下的" + FieldUniqueEnum.convertToCode(columnStr) + "数据不允许重复插入");
+            } else if (e instanceof BusinessException) {
+                throw new BusinessException(e.getMessage());
+            } else {
+                throw new RuntimeException(e);
+            }
         }
-        String liveUrl = String.valueOf(mapParameter.get("liveUrl"));
-        TIeExamInvigilateCall tIeExamInvigilateCall = new TIeExamInvigilateCall(recordId, source, liveUrl);
-        tIeExamInvigilateCallService.save(tIeExamInvigilateCall);
         return ResultUtil.ok(SystemConstant.SUCCESS);
     }
 
@@ -122,4 +135,16 @@ public class TIeInvigilateCallController {
         map.put(SystemConstant.RECORDS, tIeExamInvigilateCallList);
         return ResultUtil.ok(map);
     }
+
+    @ApiOperation(value = "监考监控通话查询来源接口")
+    @RequestMapping(value = "/call/query", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "监考监控信息", response = TIeExamInvigilateCall.class)})
+    public Result callQuery(@ApiParam(value = "考试记录id", required = true) @RequestParam(required = true) Long recordId) {
+        QueryWrapper<TIeExamInvigilateCall> tIeExamInvigilateCallQueryWrapper = new QueryWrapper<>();
+        tIeExamInvigilateCallQueryWrapper.lambda().eq(TIeExamInvigilateCall::getExamRecordId, recordId);
+        List<TIeExamInvigilateCall> tIeExamInvigilateCallList = tIeExamInvigilateCallService.list(tIeExamInvigilateCallQueryWrapper);
+        Map map = new HashMap<>();
+        map.put(SystemConstant.RECORDS, tIeExamInvigilateCallList);
+        return ResultUtil.ok(map);
+    }
 }