wangliang 4 жил өмнө
parent
commit
71729f1781

+ 3 - 0
themis-backend/src/main/java/com/qmth/themis/backend/api/TBUserController.java

@@ -586,6 +586,9 @@ public class TBUserController {
             if (Objects.nonNull(roleList) && roleList.size() > 0) {
             if (Objects.nonNull(roleList) && roleList.size() > 0) {
                 roleSet = new HashSet<>(roleList);
                 roleSet = new HashSet<>(roleList);
             }
             }
+            if (Objects.nonNull(roleSet) && roleSet.size() > 1) {
+                throw new BusinessException("暂不支持多个角色");
+            }
             if (Objects.isNull(tbUser.getId())) {
             if (Objects.isNull(tbUser.getId())) {
                 tbUser.setId(Constants.idGen.next());
                 tbUser.setId(Constants.idGen.next());
                 tbUser.setOrgId(orgId);
                 tbUser.setOrgId(orgId);

+ 8 - 3
themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamActivityController.java

@@ -63,6 +63,7 @@ public class TEExamActivityController {
         if (Objects.isNull(teExamActivityList) || teExamActivityList.size() == 0) {
         if (Objects.isNull(teExamActivityList) || teExamActivityList.size() == 0) {
             throw new BusinessException(ExceptionResultEnum.EXAM_INFO_IS_NULL);
             throw new BusinessException(ExceptionResultEnum.EXAM_INFO_IS_NULL);
         }
         }
+        Long examId = null;
         try {
         try {
             TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
             TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
             teExamActivityList.forEach(s -> {
             teExamActivityList.forEach(s -> {
@@ -71,9 +72,10 @@ public class TEExamActivityController {
                 } else {
                 } else {
                     s.setId(Constants.idGen.next());
                     s.setId(Constants.idGen.next());
                     s.setCreateId(tbUser.getId());
                     s.setCreateId(tbUser.getId());
-                    s.setCode(String.valueOf(redisUtil.getRedisActivityCodeSequence()));
+                    s.setCode(String.valueOf(redisUtil.getRedisActivityCodeSequence(s.getExamId())));
                 }
                 }
             });
             });
+            examId = teExamActivityList.get(0).getExamId();
             teExamActivityService.saveOrUpdateBatch(teExamActivityList);
             teExamActivityService.saveOrUpdateBatch(teExamActivityList);
             TEExam teExam = teExamService.getById(teExamActivityList.get(0).getExamId());
             TEExam teExam = teExamService.getById(teExamActivityList.get(0).getExamId());
             //新增quartz任务,发送mq消息start
             //新增quartz任务,发送mq消息start
@@ -90,6 +92,9 @@ public class TEExamActivityController {
             });
             });
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
+            if (Objects.nonNull(examId) && Objects.nonNull(teExamActivityList) && (Objects.nonNull(teExamActivityList) && teExamActivityList.size() > 0 && Objects.nonNull(teExamActivityList.get(0)))) {
+                redisUtil.setRedisActivityCodeSequence(examId, Integer.parseInt(teExamActivityList.get(0).getCode()) - 1);
+            }
             if (e instanceof DuplicateKeyException) {
             if (e instanceof DuplicateKeyException) {
                 String errorColumn = e.getCause().toString();
                 String errorColumn = e.getCause().toString();
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
@@ -106,8 +111,8 @@ public class TEExamActivityController {
     @ApiOperation(value = "考试场次查询接口")
     @ApiOperation(value = "考试场次查询接口")
     @RequestMapping(value = "/query", method = RequestMethod.POST)
     @RequestMapping(value = "/query", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "考试场次信息", response = TEExamActivity.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "考试场次信息", response = TEExamActivity.class)})
-    public Result query(@ApiParam(value = "主键", required = false) @RequestParam(required = false) Long id,@ApiParam(value = "考试批次id", required = false) @RequestParam(required = false) Long examId, @ApiParam(value = "考试场次编码", required = false) @RequestParam(required = false) String code, @ApiParam(value = "开始日期", required = false) @RequestParam(required = false) String startDate, @ApiParam(value = "结束日期", required = false) @RequestParam(required = false) String finishDate, @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber, @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
-        IPage<TEExamActivityQueryDto> teExamActivityIPage = teExamActivityService.examActivityQuery(new Page<>(pageNumber, pageSize), id,examId, code, startDate, finishDate);
+    public Result query(@ApiParam(value = "主键", required = false) @RequestParam(required = false) Long id, @ApiParam(value = "考试批次id", required = false) @RequestParam(required = false) Long examId, @ApiParam(value = "考试场次编码", required = false) @RequestParam(required = false) String code, @ApiParam(value = "开始日期", required = false) @RequestParam(required = false) String startDate, @ApiParam(value = "结束日期", required = false) @RequestParam(required = false) String finishDate, @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber, @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
+        IPage<TEExamActivityQueryDto> teExamActivityIPage = teExamActivityService.examActivityQuery(new Page<>(pageNumber, pageSize), id, examId, code, startDate, finishDate);
         BasePage basePage = new BasePage(teExamActivityIPage.getRecords(), teExamActivityIPage.getCurrent(), teExamActivityIPage.getSize(), teExamActivityIPage.getTotal());
         BasePage basePage = new BasePage(teExamActivityIPage.getRecords(), teExamActivityIPage.getCurrent(), teExamActivityIPage.getSize(), teExamActivityIPage.getTotal());
         return ResultUtil.ok(basePage);
         return ResultUtil.ok(basePage);
     }
     }

+ 12 - 3
themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamController.java

@@ -87,6 +87,7 @@ public class TEExamController {
         }
         }
         TEExam teExam = null;
         TEExam teExam = null;
         Long oldId = null;
         Long oldId = null;
+        String activityCode = null;
         try {
         try {
             TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
             TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
             TBOrg tbOrg = (TBOrg) ServletUtil.getRequestOrg();
             TBOrg tbOrg = (TBOrg) ServletUtil.getRequestOrg();
@@ -153,7 +154,8 @@ public class TEExamController {
                     });
                     });
                 } else {
                 } else {
                     TEExamActivity teExamActivity = new TEExamActivity(teExam.getId(), teExam.getPrepareSeconds(), teExam.getMaxDurationSeconds(), teExam.getOpeningSeconds(), teExam.getStartTime(), teExam.getEndTime(), tbUser.getId());
                     TEExamActivity teExamActivity = new TEExamActivity(teExam.getId(), teExam.getPrepareSeconds(), teExam.getMaxDurationSeconds(), teExam.getOpeningSeconds(), teExam.getStartTime(), teExam.getEndTime(), tbUser.getId());
-                    teExamActivity.setCode(String.valueOf(redisUtil.getRedisActivityCodeSequence()));
+                    teExamActivity.setCode(String.valueOf(redisUtil.getRedisActivityCodeSequence(teExam.getId())));
+                    activityCode = teExamActivity.getCode();
                     teExamActivity.setEnable(1);
                     teExamActivity.setEnable(1);
                     teExamActivityService.saveOrUpdate(teExamActivity);
                     teExamActivityService.saveOrUpdate(teExamActivity);
 
 
@@ -169,6 +171,9 @@ public class TEExamController {
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
+            if (Objects.nonNull(teExam) && Objects.nonNull(teExam.getId()) && Objects.nonNull(activityCode)) {
+                redisUtil.setRedisActivityCodeSequence(teExam.getId(), Integer.parseInt(activityCode) - 1);
+            }
             if (e instanceof DuplicateKeyException) {
             if (e instanceof DuplicateKeyException) {
                 String errorColumn = e.getCause().toString();
                 String errorColumn = e.getCause().toString();
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
@@ -277,6 +282,7 @@ public class TEExamController {
         if (Objects.isNull(teExam)) {
         if (Objects.isNull(teExam)) {
             throw new BusinessException(ExceptionResultEnum.EXAM_NO);
             throw new BusinessException(ExceptionResultEnum.EXAM_NO);
         }
         }
+        List<TEExamActivity> teExamActivityList = null;
         try {
         try {
             teExam.setId(null);
             teExam.setId(null);
             teExam.setUpdateId(null);
             teExam.setUpdateId(null);
@@ -289,7 +295,7 @@ public class TEExamController {
 
 
             QueryWrapper<TEExamActivity> teExamActivityQueryWrapper = new QueryWrapper<>();
             QueryWrapper<TEExamActivity> teExamActivityQueryWrapper = new QueryWrapper<>();
             teExamActivityQueryWrapper.lambda().eq(TEExamActivity::getExamId, examId);
             teExamActivityQueryWrapper.lambda().eq(TEExamActivity::getExamId, examId);
-            List<TEExamActivity> teExamActivityList = teExamActivityService.list(teExamActivityQueryWrapper);
+            teExamActivityList = teExamActivityService.list(teExamActivityQueryWrapper);
             if (Objects.nonNull(teExamActivityList)) {
             if (Objects.nonNull(teExamActivityList)) {
                 teExamActivityList.forEach(s -> {
                 teExamActivityList.forEach(s -> {
                     s.setId(null);
                     s.setId(null);
@@ -297,12 +303,15 @@ public class TEExamController {
                     s.setCreateId(teExam.getCreateId());
                     s.setCreateId(teExam.getCreateId());
                     s.setUpdateId(null);
                     s.setUpdateId(null);
                     s.setUpdateTime(null);
                     s.setUpdateTime(null);
-                    s.setCode(String.valueOf(redisUtil.getRedisActivityCodeSequence()));
+                    s.setCode(String.valueOf(redisUtil.getRedisActivityCodeSequence(teExam.getId())));
                 });
                 });
                 teExamActivityService.saveOrUpdateBatch(teExamActivityList);
                 teExamActivityService.saveOrUpdateBatch(teExamActivityList);
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
+            if (Objects.nonNull(examId) && Objects.nonNull(teExam.getId()) && (Objects.nonNull(teExamActivityList) && teExamActivityList.size() > 0 && Objects.nonNull(teExamActivityList.get(0)))) {
+                redisUtil.setRedisActivityCodeSequence(examId, Integer.parseInt(teExamActivityList.get(0).getCode()) - 1);
+            }
             if (e instanceof DuplicateKeyException) {
             if (e instanceof DuplicateKeyException) {
                 String errorColumn = e.getCause().toString();
                 String errorColumn = e.getCause().toString();
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");

+ 1 - 1
themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java

@@ -89,7 +89,7 @@ public class SystemConstant {
     public static final String MONITOR_STATUS_ = "monitorStatus_";
     public static final String MONITOR_STATUS_ = "monitorStatus_";
     public static final String MONITOR_CALL_STATUS_ = "monitorCallStatus_";
     public static final String MONITOR_CALL_STATUS_ = "monitorCallStatus_";
     public final static String REDIS_MONITOR_SEQUENCE = "redis:seq:monitor";
     public final static String REDIS_MONITOR_SEQUENCE = "redis:seq:monitor";
-    public final static String REDIS_ACTIVITY_CODE_SEQUENCE = "redis:seq:activity:code";
+    public final static String REDIS_ACTIVITY_CODE_SEQUENCE = "redis:seq:activity:code:";
 
 
     /**
     /**
      * session过期时间
      * session过期时间

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

@@ -75,11 +75,11 @@ public class TEExam extends BaseEntity {
     private Integer examCount;
     private Integer examCount;
 
 
     @ApiModelProperty(value = "断点失效时间(秒)")
     @ApiModelProperty(value = "断点失效时间(秒)")
-    @TableField(value = "break_expire_seconds")
+    @TableField(value = "break_expire_seconds", updateStrategy = FieldStrategy.IGNORED)
     private Integer breakExpireSeconds;
     private Integer breakExpireSeconds;
 
 
     @ApiModelProperty(value = "断点续考次数")
     @ApiModelProperty(value = "断点续考次数")
-    @TableField(value = "break_resume_count")
+    @TableField(value = "break_resume_count", updateStrategy = FieldStrategy.IGNORED)
     private Integer breakResumeCount;
     private Integer breakResumeCount;
 
 
     @ApiModelProperty(value = "是否允许使用摄像头拍照答题,0:不允许,1:允许")
     @ApiModelProperty(value = "是否允许使用摄像头拍照答题,0:不允许,1:允许")

+ 24 - 2
themis-business/src/main/java/com/qmth/themis/business/util/RedisUtil.java

@@ -338,10 +338,32 @@ public class RedisUtil {
     /**
     /**
      * 获取redis activity code序列
      * 获取redis activity code序列
      *
      *
+     * @param key
      * @return
      * @return
      */
      */
-    public Integer getRedisActivityCodeSequence() {
-        RedisAtomicInteger entityIdCounter = new RedisAtomicInteger(SystemConstant.REDIS_ACTIVITY_CODE_SEQUENCE, redisTemplate.getConnectionFactory());
+    public Integer getRedisActivityCodeSequence(Long key) {
+        RedisAtomicInteger entityIdCounter = new RedisAtomicInteger(SystemConstant.REDIS_ACTIVITY_CODE_SEQUENCE + key, redisTemplate.getConnectionFactory());
         return entityIdCounter.incrementAndGet();
         return entityIdCounter.incrementAndGet();
     }
     }
+
+    /**
+     * 设置redis activity code序列
+     *
+     * @param key
+     * @param initialValue
+     * @return
+     */
+    public Integer setRedisActivityCodeSequence(Long key, int initialValue) {
+        RedisAtomicInteger entityIdCounter = new RedisAtomicInteger(SystemConstant.REDIS_ACTIVITY_CODE_SEQUENCE + key, redisTemplate.getConnectionFactory(), initialValue);
+        return entityIdCounter.get();
+    }
+
+    /**
+     * 删除redis activity code序列
+     *
+     * @param key
+     */
+    public void deleteRedisActivityCodeSequence(Long key) {
+        this.delete(SystemConstant.REDIS_ACTIVITY_CODE_SEQUENCE + key);
+    }
 }
 }