فهرست منبع

加入删除历史视频和交卷ip判断

wangliang 2 سال پیش
والد
کامیت
3f46a0d323

+ 66 - 0
themis-admin/src/main/java/com/qmth/themis/admin/api/SysController.java

@@ -17,6 +17,7 @@ import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.AuthDto;
 import com.qmth.themis.business.dto.response.RoomCodeQueryDto;
 import com.qmth.themis.business.dto.response.TEExamQueryDto;
+import com.qmth.themis.business.dto.response.TEStudentMonitorRecordDto;
 import com.qmth.themis.business.entity.*;
 import com.qmth.themis.business.enums.*;
 import com.qmth.themis.business.service.*;
@@ -584,6 +585,7 @@ public class SysController {
     @ApiResponses({@ApiResponse(code = 200, message = "超管视频存储删除接口", response = Result.class)})
     @Transactional
     public Result videoDelete(@ApiParam(value = "考试id", required = true) @RequestParam Long examId) {
+        //新考试视频
         List<TMTencentVideoMessage> tmTencentVideoMessageList = tmTencentVideoMessageService.videoQuery(examId);
         if (!CollectionUtils.isEmpty(tmTencentVideoMessageList)) {
             Boolean lock = redisUtil.lock(SystemConstant.REDIS_LOCK_TENCENT_VIDEO_DELETE_PREFIX + examId, SystemConstant.REDIS_LOCK_TENCENT_VIDEO_DELETE_TIME_OUT);
@@ -638,6 +640,70 @@ public class SysController {
                 throw new BusinessException("该考试批次正在删除视频,请稍候再试");
             }
         }
+        //老考试视频
+        QueryWrapper<TOeExamRecord> tOeExamRecordQueryWrapper = new QueryWrapper<>();
+        tOeExamRecordQueryWrapper.lambda().eq(TOeExamRecord::getExamId, examId)
+                .isNotNull(TOeExamRecord::getTencentVideoUrl);
+        List<TOeExamRecord> tOeExamRecordList = tOeExamRecordService.list(tOeExamRecordQueryWrapper);
+        if (!CollectionUtils.isEmpty(tOeExamRecordList)) {
+            Boolean lock = redisUtil.lock(SystemConstant.REDIS_LOCK_TENCENT_VIDEO_DELETE_PREFIX + examId, SystemConstant.REDIS_LOCK_TENCENT_VIDEO_DELETE_TIME_OUT);
+            if (lock) {
+                try {
+                    Map<Long, TMTencentVideoMessage> tmTencentVideoMessageMap = new HashMap<>();
+                    Set<Long> tencentVideoMessageIds = new HashSet<>();
+                    Map<Long, TOeExamRecord> tOeExamRecordMap = tOeExamRecordList.stream().collect(
+                            Collectors.toMap(TOeExamRecord::getId, Function.identity(), (dto1, dto2) -> dto1));
+                    for (TOeExamRecord t : tOeExamRecordList) {
+                        List<TEStudentMonitorRecordDto> monitorRecordList = GsonUtil.fromJson(t.getTencentVideoUrl(), new TypeToken<List<TEStudentMonitorRecordDto>>() {
+                        }.getType());
+                        for (TEStudentMonitorRecordDto teStudentMonitorRecordDto : monitorRecordList) {
+                            QueryWrapper<TMTencentVideoMessage> tencentVideoMessageQueryWrapper = new QueryWrapper<>();
+                            tencentVideoMessageQueryWrapper.lambda().like(TMTencentVideoMessage::getObject, teStudentMonitorRecordDto.getVideoSource());
+                            List<TMTencentVideoMessage> tencentVideoMessageList = tmTencentVideoMessageService.list(tencentVideoMessageQueryWrapper);
+                            for (TMTencentVideoMessage tencentVideoMessage : tencentVideoMessageList) {
+                                if (!tmTencentVideoMessageMap.containsKey(tencentVideoMessage.getId())) {
+                                    tmTencentVideoMessageMap.put(tencentVideoMessage.getId(), tencentVideoMessage);
+                                } else {
+                                    continue;
+                                }
+                                tencentVideoMessageIds.add(t.getId());
+                                if (Objects.nonNull(tencentVideoMessage.getObject()) && !Objects.equals(tencentVideoMessage.getObject().trim(), "")) {
+                                    JSONObject jsonObject = JSONObject.parseObject(tencentVideoMessage.getObject());
+                                    if (Objects.nonNull(jsonObject.get("mediaInfoSet")) && !Objects.equals(jsonObject.getString("mediaInfoSet").trim(), "")) {
+                                        JSONArray jsonArray = JSONArray.parseArray(jsonObject.getString("mediaInfoSet"));
+                                        for (int i = 0; i < jsonArray.size(); i++) {
+                                            JSONObject object = jsonArray.getJSONObject(i);
+                                            if (Objects.nonNull(object.get("fileId")) && !Objects.equals(object.getString("fileId").trim(), "")) {
+                                                tencentYunUtil.deleteMedia(tencentYunUtil.getSecretId(),
+                                                        tencentYunUtil.getSecretKey(),
+                                                        tencentYunUtil.getQueryUrl(),
+                                                        "",
+                                                        tencentYunUtil.getVodAppId(),
+                                                        object.getString("fileId"));
+                                                t.setVideoStatus(true);
+                                            }
+                                        }
+                                    } else if (Objects.nonNull(jsonObject.get("file_id")) && !Objects.equals(jsonObject.getString("file_id").trim(), "")) {
+                                        tencentYunUtil.deleteMedia(tencentYunUtil.getSecretId(),
+                                                tencentYunUtil.getSecretKey(),
+                                                tencentYunUtil.getQueryUrl(),
+                                                "",
+                                                tencentYunUtil.getVodAppId(),
+                                                jsonObject.getString("file_id"));
+                                        t.setVideoStatus(true);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    tmTencentVideoMessageService.removeByIds(tencentVideoMessageIds);
+                    tOeExamRecordService.updateBatchById(tOeExamRecordMap.values());
+                } finally {
+                    redisUtil.releaseLock(SystemConstant.REDIS_LOCK_TENCENT_VIDEO_DELETE_PREFIX + examId);
+                }
+            }
+        }
+
         TEExam teExam = teExamService.getById(examId);
         Optional.ofNullable(teExam).orElseThrow(() -> new BusinessException(ExceptionResultEnum.EXAM_NO));
 

+ 28 - 0
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamController.java

@@ -1,6 +1,7 @@
 package com.qmth.themis.admin.api;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.themis.business.annotation.ApiJsonObject;
 import com.qmth.themis.business.annotation.ApiJsonProperty;
@@ -97,6 +98,9 @@ public class TEExamController {
     @Resource
     CommonService commonService;
 
+    @Resource
+    TEStudentService teStudentService;
+
     @ApiOperation(value = "考试批次修改/新增接口")
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     @Transactional
@@ -767,4 +771,28 @@ public class TEExamController {
         }
         return ResultUtil.ok(true);
     }
+
+    @ApiOperation(value = "修正学生id")
+    @RequestMapping(value = "/updateStudentId", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "考试信息", response = Objects.class)})
+    public Result updateStudentId(@ApiParam(value = "修正学生") @RequestParam(required = false) boolean updateStudentId,
+                                  @ApiParam(value = "修正考生") @RequestParam(required = false) boolean updateExamStudentId) {
+        if (Objects.nonNull(updateStudentId) && updateStudentId) {
+            List<TEExamStudent> teExamStudentList = teExamStudentService.updateStudentId();
+            if (!CollectionUtils.isEmpty(teExamStudentList)) {
+                for (TEExamStudent t : teExamStudentList) {
+                    ExamCacheBean examCacheBean = teExamService.getExamCacheBean(t.getExamId());
+                    Objects.requireNonNull(examCacheBean, "考试为空");
+                    UpdateWrapper<TEStudent> teStudentUpdateWrapper = new UpdateWrapper<>();
+                    teStudentUpdateWrapper.lambda().set(TEStudent::getId, t.getStudentId())
+                            .eq(TEStudent::getOrgId, examCacheBean.getOrgId())
+                            .eq(TEStudent::getIdentity, t.getIdentity());
+                    teStudentService.update(teStudentUpdateWrapper);
+                }
+            }
+        } else if (Objects.nonNull(updateExamStudentId) && updateExamStudentId) {
+
+        }
+        return ResultUtil.ok(true);
+    }
 }

+ 7 - 0
themis-business/src/main/java/com/qmth/themis/business/dao/TEExamStudentMapper.java

@@ -130,4 +130,11 @@ public interface TEExamStudentMapper extends CustomBaseMapper<TEExamStudent> {
      * @return
      */
     public List<TEExamStudent> findAlreadyExamCountZero(@Param("examId") Long examId, @Param("examActivityId") Long examActivityId, @Param("id") Long id, @Param("examRecordId") Long examRecordId);
+
+    /**
+     * 修正学生id
+     *
+     * @return
+     */
+    public List<TEExamStudent> updateStudentId();
 }

+ 6 - 2
themis-business/src/main/java/com/qmth/themis/business/entity/TEExamStudentLog.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.themis.business.enums.ExamRecordStatusEnum;
 import com.qmth.themis.business.util.UidUtil;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -162,8 +163,11 @@ public class TEExamStudentLog implements Serializable {
                 currentIp = ip;
                 continue;
             } else if (Objects.nonNull(currentIp) && !Objects.equals(currentIp.trim(), "") && !Objects.equals(currentIp, ip)) {
-                teExamStudentLogList.get(i).setIpChange(true);
-                currentIp = ip;
+                if (!Objects.equals(teExamStudentLogList.get(i).getType(), ExamRecordStatusEnum.FINISHED.name())
+                        || (Objects.equals(teExamStudentLogList.get(i).getType(), ExamRecordStatusEnum.FINISHED.name()) && Objects.nonNull(ip))) {
+                    teExamStudentLogList.get(i).setIpChange(true);
+                    currentIp = ip;
+                }
             }
         }
         return teExamStudentLogList;

+ 7 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TEExamStudentService.java

@@ -121,4 +121,11 @@ public interface TEExamStudentService extends IService<TEExamStudent> {
      * @return
      */
     public List<TEExamStudent> findAlreadyExamCountZero(Long examId, Long examActivityId, Long id, Long examRecordId);
+
+    /**
+     * 修正学生id
+     *
+     * @return
+     */
+    public List<TEExamStudent> updateStudentId();
 }

+ 9 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamStudentServiceImpl.java

@@ -232,4 +232,13 @@ public class TEExamStudentServiceImpl extends ServiceImpl<TEExamStudentMapper, T
     public List<TEExamStudent> findAlreadyExamCountZero(Long examId, Long examActivityId, Long id, Long examRecordId) {
         return teExamStudentMapper.findAlreadyExamCountZero(examId, examActivityId, id, examRecordId);
     }
+
+    /**
+     * 修正学生id
+     * @return
+     */
+    @Override
+    public List<TEExamStudent> updateStudentId() {
+        return teExamStudentMapper.updateStudentId();
+    }
 }

+ 4 - 0
themis-business/src/main/resources/mapper/TEExamStudentMapper.xml

@@ -528,4 +528,8 @@
             </if>
         </where>
     </select>
+
+    <select id="updateStudentId" resultType="com.qmth.themis.business.entity.TEExamStudent">
+        select distinct tees.* from t_e_exam_student tees left join t_e_student tes on tees.student_id = tes.id where tes.id is null
+    </select>
 </mapper>