From 94cb9630a06bcacfc0b0607f3c8a96ee7a00e4c9 Mon Sep 17 00:00:00 2001 From: unclekh <5177787+unclekh@user.noreply.gitee.com> Date: Wed, 3 Jun 2020 20:37:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=8C=E4=BF=AE=E6=94=B9=E8=80=83=E8=AF=95=E8=BF=9B?= =?UTF-8?q?=E5=85=A5=E9=80=BB=E8=BE=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yyyf/controller/ExamController.java | 3 +-- .../yyyf/controller/LoginController.java | 26 ++++++++++++------- .../service/impl/AssessUserServiceImpl.java | 1 - 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/ExamController.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/ExamController.java index b010c59..3e607eb 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/ExamController.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/ExamController.java @@ -115,9 +115,8 @@ public class ExamController { throw new YyyfException(YyyfEnums.FODBID_EXAM_RESTART); } Date now=new Date(); - System.out.println(now.getTime()); //系统账户初始化 - String tel=new SimpleDateFormat("yyMMddHHmm").format(now).concat(String.valueOf(yyyfUserDto.getUserId())); + String tel=new SimpleDateFormat("yyMMddHHmmss").format(now).concat(String.valueOf(yyyfUserDto.getUserId())); //第一次进入进行注册 String code=String.format("%06d",new Random().nextInt(1000000)); redisTemplate.opsForValue().set(YyyfConstant.REGISTER_KEY.concat(tel),code,YyyfConstant.TIME_OUT, TimeUnit.MINUTES); diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java index 9373a41..a54c6c3 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java @@ -99,7 +99,7 @@ public class LoginController { AssessUser assessUser = this.assessUserService.selectAssessUserByUserIdAndissueIdForNotEnd(userId, examId); if (assessUser == null) { Date now = new Date(); - String tel=new SimpleDateFormat("yyMMddHHmm").format(now).concat(String.valueOf(userId)); + String tel=new SimpleDateFormat("yyMMddHHmmss").format(now).concat(String.valueOf(userId)); //第一次进入进行注册 String code=String.format("%06d",new Random().nextInt(1000000)); @@ -168,6 +168,14 @@ public class LoginController { if (joinStuIds == null) { joinStuIds = new ArrayList(); } + + Map map = new HashMap(); + map.put("examPaperId", examDto.getExamPaperId()); + map.put("examId", examDto.getExamId()); + + redisTemplate.opsForValue().set(caseKey, map); + redisTemplate.expire(caseKey, 30, TimeUnit.DAYS); + //如果等于0 if (joinStuIds.stream() .filter(stuIds -> (stuIds.equals(userId))).count() == 0) { @@ -192,6 +200,14 @@ public class LoginController { yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE); ExamDto examDto = examDtoOpsForHash.get(YyyfConstant.EXAM_KEY, examId); yyyfLoginDto.setRemainingTime((examDto.getEndTime().getTime() - new Date().getTime() )/ 1000); + + Map map = new HashMap(); + map.put("examPaperId", examDto.getExamPaperId()); + map.put("examId", examDto.getExamId()); + + redisTemplate.opsForValue().set(caseKey, map); + redisTemplate.expire(caseKey, 30, TimeUnit.DAYS); + return handleAfterLogin(yyyfLoginDto, yyyfUserDto); } @@ -199,14 +215,6 @@ public class LoginController { } //删除强制提醒的缓存 // redisTemplate.delete(YyyfConstant.ANSER_KEY + userId); - - - Map map = new HashMap(); - map.put("examPaperId", examPaperId); - map.put("examId", examId); - - redisTemplate.opsForValue().set(caseKey, map); - redisTemplate.expire(caseKey, 2, TimeUnit.HOURS); yyyfLoginDto.setStatus(1); } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java index b428e05..8f57522 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java @@ -141,7 +141,6 @@ public class AssessUserServiceImpl implements AssessUserService { @Override public AssessUserDto submit(String assessUserId) { AssessUser assessUser = this.selectAssessUserById(assessUserId); - if (assessUser.getEndTime() != null) { throw new YyyfException(YyyfEnums.PROHIBIT_DUPLICATE_SUBMISSION); }